app.js 2.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134
  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./node_modules/@popperjs/core/lib/createPopper.js":
  4. /*!*********************************************************!*\
  5. !*** ./node_modules/@popperjs/core/lib/createPopper.js ***!
  6. \*********************************************************/
  7. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  8. "use strict";
  9. __webpack_require__.r(__webpack_exports__);
  10. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  11. /* harmony export */ createPopper: () => (/* binding */ createPopper),
  12. /* harmony export */ detectOverflow: () => (/* reexport safe */ _utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_13__["default"]),
  13. /* harmony export */ popperGenerator: () => (/* binding */ popperGenerator)
  14. /* harmony export */ });
  15. /* harmony import */ var _dom_utils_getCompositeRect_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./dom-utils/getCompositeRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js");
  16. /* harmony import */ var _dom_utils_getLayoutRect_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./dom-utils/getLayoutRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js");
  17. /* harmony import */ var _dom_utils_listScrollParents_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dom-utils/listScrollParents.js */ "./node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js");
  18. /* harmony import */ var _dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./dom-utils/getOffsetParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js");
  19. /* harmony import */ var _dom_utils_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./dom-utils/getComputedStyle.js */ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js");
  20. /* harmony import */ var _utils_orderModifiers_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils/orderModifiers.js */ "./node_modules/@popperjs/core/lib/utils/orderModifiers.js");
  21. /* harmony import */ var _utils_debounce_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./utils/debounce.js */ "./node_modules/@popperjs/core/lib/utils/debounce.js");
  22. /* harmony import */ var _utils_validateModifiers_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils/validateModifiers.js */ "./node_modules/@popperjs/core/lib/utils/validateModifiers.js");
  23. /* harmony import */ var _utils_uniqueBy_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/uniqueBy.js */ "./node_modules/@popperjs/core/lib/utils/uniqueBy.js");
  24. /* harmony import */ var _utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils/getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  25. /* harmony import */ var _utils_mergeByName_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils/mergeByName.js */ "./node_modules/@popperjs/core/lib/utils/mergeByName.js");
  26. /* harmony import */ var _utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./utils/detectOverflow.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  27. /* harmony import */ var _dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dom-utils/instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  28. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  29. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  30. var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
  31. var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
  32. var DEFAULT_OPTIONS = {
  33. placement: 'bottom',
  34. modifiers: [],
  35. strategy: 'absolute'
  36. };
  37. function areValidElements() {
  38. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  39. args[_key] = arguments[_key];
  40. }
  41. return !args.some(function (element) {
  42. return !(element && typeof element.getBoundingClientRect === 'function');
  43. });
  44. }
  45. function popperGenerator(generatorOptions) {
  46. if (generatorOptions === void 0) {
  47. generatorOptions = {};
  48. }
  49. var _generatorOptions = generatorOptions,
  50. _generatorOptions$def = _generatorOptions.defaultModifiers,
  51. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  52. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  53. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  54. return function createPopper(reference, popper, options) {
  55. if (options === void 0) {
  56. options = defaultOptions;
  57. }
  58. var state = {
  59. placement: 'bottom',
  60. orderedModifiers: [],
  61. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  62. modifiersData: {},
  63. elements: {
  64. reference: reference,
  65. popper: popper
  66. },
  67. attributes: {},
  68. styles: {}
  69. };
  70. var effectCleanupFns = [];
  71. var isDestroyed = false;
  72. var instance = {
  73. state: state,
  74. setOptions: function setOptions(setOptionsAction) {
  75. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  76. cleanupModifierEffects();
  77. state.options = Object.assign({}, defaultOptions, state.options, options);
  78. state.scrollParents = {
  79. reference: (0,_dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isElement)(reference) ? (0,_dom_utils_listScrollParents_js__WEBPACK_IMPORTED_MODULE_1__["default"])(reference) : reference.contextElement ? (0,_dom_utils_listScrollParents_js__WEBPACK_IMPORTED_MODULE_1__["default"])(reference.contextElement) : [],
  80. popper: (0,_dom_utils_listScrollParents_js__WEBPACK_IMPORTED_MODULE_1__["default"])(popper)
  81. }; // Orders the modifiers based on their dependencies and `phase`
  82. // properties
  83. var orderedModifiers = (0,_utils_orderModifiers_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,_utils_mergeByName_js__WEBPACK_IMPORTED_MODULE_3__["default"])([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  84. state.orderedModifiers = orderedModifiers.filter(function (m) {
  85. return m.enabled;
  86. }); // Validate the provided modifiers so that the consumer will get warned
  87. // if one of the modifiers is invalid for any reason
  88. if (true) {
  89. var modifiers = (0,_utils_uniqueBy_js__WEBPACK_IMPORTED_MODULE_4__["default"])([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
  90. var name = _ref.name;
  91. return name;
  92. });
  93. (0,_utils_validateModifiers_js__WEBPACK_IMPORTED_MODULE_5__["default"])(modifiers);
  94. if ((0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_6__["default"])(state.options.placement) === _enums_js__WEBPACK_IMPORTED_MODULE_7__.auto) {
  95. var flipModifier = state.orderedModifiers.find(function (_ref2) {
  96. var name = _ref2.name;
  97. return name === 'flip';
  98. });
  99. if (!flipModifier) {
  100. console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
  101. }
  102. }
  103. var _getComputedStyle = (0,_dom_utils_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_8__["default"])(popper),
  104. marginTop = _getComputedStyle.marginTop,
  105. marginRight = _getComputedStyle.marginRight,
  106. marginBottom = _getComputedStyle.marginBottom,
  107. marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
  108. // cause bugs with positioning, so we'll warn the consumer
  109. if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
  110. return parseFloat(margin);
  111. })) {
  112. console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
  113. }
  114. }
  115. runModifierEffects();
  116. return instance.update();
  117. },
  118. // Sync update – it will always be executed, even if not necessary. This
  119. // is useful for low frequency updates where sync behavior simplifies the
  120. // logic.
  121. // For high frequency updates (e.g. `resize` and `scroll` events), always
  122. // prefer the async Popper#update method
  123. forceUpdate: function forceUpdate() {
  124. if (isDestroyed) {
  125. return;
  126. }
  127. var _state$elements = state.elements,
  128. reference = _state$elements.reference,
  129. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  130. // anymore
  131. if (!areValidElements(reference, popper)) {
  132. if (true) {
  133. console.error(INVALID_ELEMENT_ERROR);
  134. }
  135. return;
  136. } // Store the reference and popper rects to be read by modifiers
  137. state.rects = {
  138. reference: (0,_dom_utils_getCompositeRect_js__WEBPACK_IMPORTED_MODULE_9__["default"])(reference, (0,_dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_10__["default"])(popper), state.options.strategy === 'fixed'),
  139. popper: (0,_dom_utils_getLayoutRect_js__WEBPACK_IMPORTED_MODULE_11__["default"])(popper)
  140. }; // Modifiers have the ability to reset the current update cycle. The
  141. // most common use case for this is the `flip` modifier changing the
  142. // placement, which then needs to re-run all the modifiers, because the
  143. // logic was previously ran for the previous placement and is therefore
  144. // stale/incorrect
  145. state.reset = false;
  146. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  147. // is filled with the initial data specified by the modifier. This means
  148. // it doesn't persist and is fresh on each update.
  149. // To ensure persistent data, use `${name}#persistent`
  150. state.orderedModifiers.forEach(function (modifier) {
  151. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  152. });
  153. var __debug_loops__ = 0;
  154. for (var index = 0; index < state.orderedModifiers.length; index++) {
  155. if (true) {
  156. __debug_loops__ += 1;
  157. if (__debug_loops__ > 100) {
  158. console.error(INFINITE_LOOP_ERROR);
  159. break;
  160. }
  161. }
  162. if (state.reset === true) {
  163. state.reset = false;
  164. index = -1;
  165. continue;
  166. }
  167. var _state$orderedModifie = state.orderedModifiers[index],
  168. fn = _state$orderedModifie.fn,
  169. _state$orderedModifie2 = _state$orderedModifie.options,
  170. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  171. name = _state$orderedModifie.name;
  172. if (typeof fn === 'function') {
  173. state = fn({
  174. state: state,
  175. options: _options,
  176. name: name,
  177. instance: instance
  178. }) || state;
  179. }
  180. }
  181. },
  182. // Async and optimistically optimized update – it will not be executed if
  183. // not necessary (debounced to run at most once-per-tick)
  184. update: (0,_utils_debounce_js__WEBPACK_IMPORTED_MODULE_12__["default"])(function () {
  185. return new Promise(function (resolve) {
  186. instance.forceUpdate();
  187. resolve(state);
  188. });
  189. }),
  190. destroy: function destroy() {
  191. cleanupModifierEffects();
  192. isDestroyed = true;
  193. }
  194. };
  195. if (!areValidElements(reference, popper)) {
  196. if (true) {
  197. console.error(INVALID_ELEMENT_ERROR);
  198. }
  199. return instance;
  200. }
  201. instance.setOptions(options).then(function (state) {
  202. if (!isDestroyed && options.onFirstUpdate) {
  203. options.onFirstUpdate(state);
  204. }
  205. }); // Modifiers have the ability to execute arbitrary code before the first
  206. // update cycle runs. They will be executed in the same order as the update
  207. // cycle. This is useful when a modifier adds some persistent data that
  208. // other modifiers need to use, but the modifier is run after the dependent
  209. // one.
  210. function runModifierEffects() {
  211. state.orderedModifiers.forEach(function (_ref3) {
  212. var name = _ref3.name,
  213. _ref3$options = _ref3.options,
  214. options = _ref3$options === void 0 ? {} : _ref3$options,
  215. effect = _ref3.effect;
  216. if (typeof effect === 'function') {
  217. var cleanupFn = effect({
  218. state: state,
  219. name: name,
  220. instance: instance,
  221. options: options
  222. });
  223. var noopFn = function noopFn() {};
  224. effectCleanupFns.push(cleanupFn || noopFn);
  225. }
  226. });
  227. }
  228. function cleanupModifierEffects() {
  229. effectCleanupFns.forEach(function (fn) {
  230. return fn();
  231. });
  232. effectCleanupFns = [];
  233. }
  234. return instance;
  235. };
  236. }
  237. var createPopper = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules
  238. /***/ }),
  239. /***/ "./node_modules/@popperjs/core/lib/dom-utils/contains.js":
  240. /*!***************************************************************!*\
  241. !*** ./node_modules/@popperjs/core/lib/dom-utils/contains.js ***!
  242. \***************************************************************/
  243. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  244. "use strict";
  245. __webpack_require__.r(__webpack_exports__);
  246. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  247. /* harmony export */ "default": () => (/* binding */ contains)
  248. /* harmony export */ });
  249. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  250. function contains(parent, child) {
  251. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  252. if (parent.contains(child)) {
  253. return true;
  254. } // then fallback to custom implementation with Shadow DOM support
  255. else if (rootNode && (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isShadowRoot)(rootNode)) {
  256. var next = child;
  257. do {
  258. if (next && parent.isSameNode(next)) {
  259. return true;
  260. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  261. next = next.parentNode || next.host;
  262. } while (next);
  263. } // Give up, the result is false
  264. return false;
  265. }
  266. /***/ }),
  267. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js":
  268. /*!****************************************************************************!*\
  269. !*** ./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js ***!
  270. \****************************************************************************/
  271. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  272. "use strict";
  273. __webpack_require__.r(__webpack_exports__);
  274. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  275. /* harmony export */ "default": () => (/* binding */ getBoundingClientRect)
  276. /* harmony export */ });
  277. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  278. /* harmony import */ var _utils_math_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  279. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  280. /* harmony import */ var _isLayoutViewport_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./isLayoutViewport.js */ "./node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js");
  281. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  282. if (includeScale === void 0) {
  283. includeScale = false;
  284. }
  285. if (isFixedStrategy === void 0) {
  286. isFixedStrategy = false;
  287. }
  288. var clientRect = element.getBoundingClientRect();
  289. var scaleX = 1;
  290. var scaleY = 1;
  291. if (includeScale && (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isHTMLElement)(element)) {
  292. scaleX = element.offsetWidth > 0 ? (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_1__.round)(clientRect.width) / element.offsetWidth || 1 : 1;
  293. scaleY = element.offsetHeight > 0 ? (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_1__.round)(clientRect.height) / element.offsetHeight || 1 : 1;
  294. }
  295. var _ref = (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isElement)(element) ? (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_2__["default"])(element) : window,
  296. visualViewport = _ref.visualViewport;
  297. var addVisualOffsets = !(0,_isLayoutViewport_js__WEBPACK_IMPORTED_MODULE_3__["default"])() && isFixedStrategy;
  298. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  299. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  300. var width = clientRect.width / scaleX;
  301. var height = clientRect.height / scaleY;
  302. return {
  303. width: width,
  304. height: height,
  305. top: y,
  306. right: x + width,
  307. bottom: y + height,
  308. left: x,
  309. x: x,
  310. y: y
  311. };
  312. }
  313. /***/ }),
  314. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js":
  315. /*!**********************************************************************!*\
  316. !*** ./node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js ***!
  317. \**********************************************************************/
  318. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  322. /* harmony export */ "default": () => (/* binding */ getClippingRect)
  323. /* harmony export */ });
  324. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  325. /* harmony import */ var _getViewportRect_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getViewportRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js");
  326. /* harmony import */ var _getDocumentRect_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./getDocumentRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js");
  327. /* harmony import */ var _listScrollParents_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./listScrollParents.js */ "./node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js");
  328. /* harmony import */ var _getOffsetParent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./getOffsetParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js");
  329. /* harmony import */ var _getDocumentElement_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  330. /* harmony import */ var _getComputedStyle_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./getComputedStyle.js */ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js");
  331. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  332. /* harmony import */ var _getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getBoundingClientRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js");
  333. /* harmony import */ var _getParentNode_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./getParentNode.js */ "./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js");
  334. /* harmony import */ var _contains_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./contains.js */ "./node_modules/@popperjs/core/lib/dom-utils/contains.js");
  335. /* harmony import */ var _getNodeName_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  336. /* harmony import */ var _utils_rectToClientRect_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/rectToClientRect.js */ "./node_modules/@popperjs/core/lib/utils/rectToClientRect.js");
  337. /* harmony import */ var _utils_math_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  338. function getInnerBoundingClientRect(element, strategy) {
  339. var rect = (0,_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element, false, strategy === 'fixed');
  340. rect.top = rect.top + element.clientTop;
  341. rect.left = rect.left + element.clientLeft;
  342. rect.bottom = rect.top + element.clientHeight;
  343. rect.right = rect.left + element.clientWidth;
  344. rect.width = element.clientWidth;
  345. rect.height = element.clientHeight;
  346. rect.x = rect.left;
  347. rect.y = rect.top;
  348. return rect;
  349. }
  350. function getClientRectFromMixedType(element, clippingParent, strategy) {
  351. return clippingParent === _enums_js__WEBPACK_IMPORTED_MODULE_1__.viewport ? (0,_utils_rectToClientRect_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,_getViewportRect_js__WEBPACK_IMPORTED_MODULE_3__["default"])(element, strategy)) : (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_4__.isElement)(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : (0,_utils_rectToClientRect_js__WEBPACK_IMPORTED_MODULE_2__["default"])((0,_getDocumentRect_js__WEBPACK_IMPORTED_MODULE_5__["default"])((0,_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_6__["default"])(element)));
  352. } // A "clipping parent" is an overflowable container with the characteristic of
  353. // clipping (or hiding) overflowing elements with a position different from
  354. // `initial`
  355. function getClippingParents(element) {
  356. var clippingParents = (0,_listScrollParents_js__WEBPACK_IMPORTED_MODULE_7__["default"])((0,_getParentNode_js__WEBPACK_IMPORTED_MODULE_8__["default"])(element));
  357. var canEscapeClipping = ['absolute', 'fixed'].indexOf((0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_9__["default"])(element).position) >= 0;
  358. var clipperElement = canEscapeClipping && (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_4__.isHTMLElement)(element) ? (0,_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_10__["default"])(element) : element;
  359. if (!(0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_4__.isElement)(clipperElement)) {
  360. return [];
  361. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  362. return clippingParents.filter(function (clippingParent) {
  363. return (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_4__.isElement)(clippingParent) && (0,_contains_js__WEBPACK_IMPORTED_MODULE_11__["default"])(clippingParent, clipperElement) && (0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_12__["default"])(clippingParent) !== 'body';
  364. });
  365. } // Gets the maximum area that the element is visible in due to any number of
  366. // clipping parents
  367. function getClippingRect(element, boundary, rootBoundary, strategy) {
  368. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  369. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  370. var firstClippingParent = clippingParents[0];
  371. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  372. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  373. accRect.top = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_13__.max)(rect.top, accRect.top);
  374. accRect.right = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_13__.min)(rect.right, accRect.right);
  375. accRect.bottom = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_13__.min)(rect.bottom, accRect.bottom);
  376. accRect.left = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_13__.max)(rect.left, accRect.left);
  377. return accRect;
  378. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  379. clippingRect.width = clippingRect.right - clippingRect.left;
  380. clippingRect.height = clippingRect.bottom - clippingRect.top;
  381. clippingRect.x = clippingRect.left;
  382. clippingRect.y = clippingRect.top;
  383. return clippingRect;
  384. }
  385. /***/ }),
  386. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js":
  387. /*!***********************************************************************!*\
  388. !*** ./node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js ***!
  389. \***********************************************************************/
  390. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  391. "use strict";
  392. __webpack_require__.r(__webpack_exports__);
  393. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  394. /* harmony export */ "default": () => (/* binding */ getCompositeRect)
  395. /* harmony export */ });
  396. /* harmony import */ var _getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getBoundingClientRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js");
  397. /* harmony import */ var _getNodeScroll_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getNodeScroll.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js");
  398. /* harmony import */ var _getNodeName_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  399. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  400. /* harmony import */ var _getWindowScrollBarX_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./getWindowScrollBarX.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js");
  401. /* harmony import */ var _getDocumentElement_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  402. /* harmony import */ var _isScrollParent_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./isScrollParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js");
  403. /* harmony import */ var _utils_math_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  404. function isElementScaled(element) {
  405. var rect = element.getBoundingClientRect();
  406. var scaleX = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_0__.round)(rect.width) / element.offsetWidth || 1;
  407. var scaleY = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_0__.round)(rect.height) / element.offsetHeight || 1;
  408. return scaleX !== 1 || scaleY !== 1;
  409. } // Returns the composite rect of an element relative to its offsetParent.
  410. // Composite means it takes into account transforms as well as layout.
  411. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  412. if (isFixed === void 0) {
  413. isFixed = false;
  414. }
  415. var isOffsetParentAnElement = (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_1__.isHTMLElement)(offsetParent);
  416. var offsetParentIsScaled = (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_1__.isHTMLElement)(offsetParent) && isElementScaled(offsetParent);
  417. var documentElement = (0,_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_2__["default"])(offsetParent);
  418. var rect = (0,_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_3__["default"])(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  419. var scroll = {
  420. scrollLeft: 0,
  421. scrollTop: 0
  422. };
  423. var offsets = {
  424. x: 0,
  425. y: 0
  426. };
  427. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  428. if ((0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_4__["default"])(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  429. (0,_isScrollParent_js__WEBPACK_IMPORTED_MODULE_5__["default"])(documentElement)) {
  430. scroll = (0,_getNodeScroll_js__WEBPACK_IMPORTED_MODULE_6__["default"])(offsetParent);
  431. }
  432. if ((0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_1__.isHTMLElement)(offsetParent)) {
  433. offsets = (0,_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_3__["default"])(offsetParent, true);
  434. offsets.x += offsetParent.clientLeft;
  435. offsets.y += offsetParent.clientTop;
  436. } else if (documentElement) {
  437. offsets.x = (0,_getWindowScrollBarX_js__WEBPACK_IMPORTED_MODULE_7__["default"])(documentElement);
  438. }
  439. }
  440. return {
  441. x: rect.left + scroll.scrollLeft - offsets.x,
  442. y: rect.top + scroll.scrollTop - offsets.y,
  443. width: rect.width,
  444. height: rect.height
  445. };
  446. }
  447. /***/ }),
  448. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js":
  449. /*!***********************************************************************!*\
  450. !*** ./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js ***!
  451. \***********************************************************************/
  452. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  453. "use strict";
  454. __webpack_require__.r(__webpack_exports__);
  455. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  456. /* harmony export */ "default": () => (/* binding */ getComputedStyle)
  457. /* harmony export */ });
  458. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  459. function getComputedStyle(element) {
  460. return (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element).getComputedStyle(element);
  461. }
  462. /***/ }),
  463. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js":
  464. /*!*************************************************************************!*\
  465. !*** ./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js ***!
  466. \*************************************************************************/
  467. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  468. "use strict";
  469. __webpack_require__.r(__webpack_exports__);
  470. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  471. /* harmony export */ "default": () => (/* binding */ getDocumentElement)
  472. /* harmony export */ });
  473. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  474. function getDocumentElement(element) {
  475. // $FlowFixMe[incompatible-return]: assume body is always available
  476. return (((0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isElement)(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  477. element.document) || window.document).documentElement;
  478. }
  479. /***/ }),
  480. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js":
  481. /*!**********************************************************************!*\
  482. !*** ./node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js ***!
  483. \**********************************************************************/
  484. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  485. "use strict";
  486. __webpack_require__.r(__webpack_exports__);
  487. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  488. /* harmony export */ "default": () => (/* binding */ getDocumentRect)
  489. /* harmony export */ });
  490. /* harmony import */ var _getDocumentElement_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  491. /* harmony import */ var _getComputedStyle_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./getComputedStyle.js */ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js");
  492. /* harmony import */ var _getWindowScrollBarX_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getWindowScrollBarX.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js");
  493. /* harmony import */ var _getWindowScroll_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getWindowScroll.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js");
  494. /* harmony import */ var _utils_math_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  495. // Gets the entire size of the scrollable document area, even extending outside
  496. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  497. function getDocumentRect(element) {
  498. var _element$ownerDocumen;
  499. var html = (0,_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element);
  500. var winScroll = (0,_getWindowScroll_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element);
  501. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  502. var width = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_2__.max)(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  503. var height = (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_2__.max)(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  504. var x = -winScroll.scrollLeft + (0,_getWindowScrollBarX_js__WEBPACK_IMPORTED_MODULE_3__["default"])(element);
  505. var y = -winScroll.scrollTop;
  506. if ((0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_4__["default"])(body || html).direction === 'rtl') {
  507. x += (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_2__.max)(html.clientWidth, body ? body.clientWidth : 0) - width;
  508. }
  509. return {
  510. width: width,
  511. height: height,
  512. x: x,
  513. y: y
  514. };
  515. }
  516. /***/ }),
  517. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js":
  518. /*!***************************************************************************!*\
  519. !*** ./node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js ***!
  520. \***************************************************************************/
  521. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  522. "use strict";
  523. __webpack_require__.r(__webpack_exports__);
  524. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  525. /* harmony export */ "default": () => (/* binding */ getHTMLElementScroll)
  526. /* harmony export */ });
  527. function getHTMLElementScroll(element) {
  528. return {
  529. scrollLeft: element.scrollLeft,
  530. scrollTop: element.scrollTop
  531. };
  532. }
  533. /***/ }),
  534. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js":
  535. /*!********************************************************************!*\
  536. !*** ./node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js ***!
  537. \********************************************************************/
  538. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  539. "use strict";
  540. __webpack_require__.r(__webpack_exports__);
  541. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  542. /* harmony export */ "default": () => (/* binding */ getLayoutRect)
  543. /* harmony export */ });
  544. /* harmony import */ var _getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getBoundingClientRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js");
  545. // Returns the layout rect of an element relative to its offsetParent. Layout
  546. // means it doesn't take into account transforms.
  547. function getLayoutRect(element) {
  548. var clientRect = (0,_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element); // Use the clientRect sizes if it's not been transformed.
  549. // Fixes https://github.com/popperjs/popper-core/issues/1223
  550. var width = element.offsetWidth;
  551. var height = element.offsetHeight;
  552. if (Math.abs(clientRect.width - width) <= 1) {
  553. width = clientRect.width;
  554. }
  555. if (Math.abs(clientRect.height - height) <= 1) {
  556. height = clientRect.height;
  557. }
  558. return {
  559. x: element.offsetLeft,
  560. y: element.offsetTop,
  561. width: width,
  562. height: height
  563. };
  564. }
  565. /***/ }),
  566. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js":
  567. /*!******************************************************************!*\
  568. !*** ./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js ***!
  569. \******************************************************************/
  570. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  571. "use strict";
  572. __webpack_require__.r(__webpack_exports__);
  573. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  574. /* harmony export */ "default": () => (/* binding */ getNodeName)
  575. /* harmony export */ });
  576. function getNodeName(element) {
  577. return element ? (element.nodeName || '').toLowerCase() : null;
  578. }
  579. /***/ }),
  580. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js":
  581. /*!********************************************************************!*\
  582. !*** ./node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js ***!
  583. \********************************************************************/
  584. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  585. "use strict";
  586. __webpack_require__.r(__webpack_exports__);
  587. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  588. /* harmony export */ "default": () => (/* binding */ getNodeScroll)
  589. /* harmony export */ });
  590. /* harmony import */ var _getWindowScroll_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getWindowScroll.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js");
  591. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  592. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  593. /* harmony import */ var _getHTMLElementScroll_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getHTMLElementScroll.js */ "./node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js");
  594. function getNodeScroll(node) {
  595. if (node === (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(node) || !(0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_1__.isHTMLElement)(node)) {
  596. return (0,_getWindowScroll_js__WEBPACK_IMPORTED_MODULE_2__["default"])(node);
  597. } else {
  598. return (0,_getHTMLElementScroll_js__WEBPACK_IMPORTED_MODULE_3__["default"])(node);
  599. }
  600. }
  601. /***/ }),
  602. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js":
  603. /*!**********************************************************************!*\
  604. !*** ./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js ***!
  605. \**********************************************************************/
  606. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  610. /* harmony export */ "default": () => (/* binding */ getOffsetParent)
  611. /* harmony export */ });
  612. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  613. /* harmony import */ var _getNodeName_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  614. /* harmony import */ var _getComputedStyle_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getComputedStyle.js */ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js");
  615. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  616. /* harmony import */ var _isTableElement_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./isTableElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/isTableElement.js");
  617. /* harmony import */ var _getParentNode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getParentNode.js */ "./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js");
  618. /* harmony import */ var _utils_userAgent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/userAgent.js */ "./node_modules/@popperjs/core/lib/utils/userAgent.js");
  619. function getTrueOffsetParent(element) {
  620. if (!(0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isHTMLElement)(element) || // https://github.com/popperjs/popper-core/issues/837
  621. (0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element).position === 'fixed') {
  622. return null;
  623. }
  624. return element.offsetParent;
  625. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  626. // return the containing block
  627. function getContainingBlock(element) {
  628. var isFirefox = /firefox/i.test((0,_utils_userAgent_js__WEBPACK_IMPORTED_MODULE_2__["default"])());
  629. var isIE = /Trident/i.test((0,_utils_userAgent_js__WEBPACK_IMPORTED_MODULE_2__["default"])());
  630. if (isIE && (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isHTMLElement)(element)) {
  631. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  632. var elementCss = (0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element);
  633. if (elementCss.position === 'fixed') {
  634. return null;
  635. }
  636. }
  637. var currentNode = (0,_getParentNode_js__WEBPACK_IMPORTED_MODULE_3__["default"])(element);
  638. if ((0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isShadowRoot)(currentNode)) {
  639. currentNode = currentNode.host;
  640. }
  641. while ((0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isHTMLElement)(currentNode) && ['html', 'body'].indexOf((0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_4__["default"])(currentNode)) < 0) {
  642. var css = (0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_1__["default"])(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  643. // create a containing block.
  644. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  645. if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
  646. return currentNode;
  647. } else {
  648. currentNode = currentNode.parentNode;
  649. }
  650. }
  651. return null;
  652. } // Gets the closest ancestor positioned element. Handles some edge cases,
  653. // such as table ancestors and cross browser bugs.
  654. function getOffsetParent(element) {
  655. var window = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_5__["default"])(element);
  656. var offsetParent = getTrueOffsetParent(element);
  657. while (offsetParent && (0,_isTableElement_js__WEBPACK_IMPORTED_MODULE_6__["default"])(offsetParent) && (0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_1__["default"])(offsetParent).position === 'static') {
  658. offsetParent = getTrueOffsetParent(offsetParent);
  659. }
  660. if (offsetParent && ((0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_4__["default"])(offsetParent) === 'html' || (0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_4__["default"])(offsetParent) === 'body' && (0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_1__["default"])(offsetParent).position === 'static')) {
  661. return window;
  662. }
  663. return offsetParent || getContainingBlock(element) || window;
  664. }
  665. /***/ }),
  666. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js":
  667. /*!********************************************************************!*\
  668. !*** ./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js ***!
  669. \********************************************************************/
  670. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  671. "use strict";
  672. __webpack_require__.r(__webpack_exports__);
  673. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  674. /* harmony export */ "default": () => (/* binding */ getParentNode)
  675. /* harmony export */ });
  676. /* harmony import */ var _getNodeName_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  677. /* harmony import */ var _getDocumentElement_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  678. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  679. function getParentNode(element) {
  680. if ((0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element) === 'html') {
  681. return element;
  682. }
  683. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  684. // $FlowFixMe[incompatible-return]
  685. // $FlowFixMe[prop-missing]
  686. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  687. element.parentNode || ( // DOM Element detected
  688. (0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_1__.isShadowRoot)(element) ? element.host : null) || // ShadowRoot detected
  689. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  690. (0,_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_2__["default"])(element) // fallback
  691. );
  692. }
  693. /***/ }),
  694. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js":
  695. /*!**********************************************************************!*\
  696. !*** ./node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js ***!
  697. \**********************************************************************/
  698. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  699. "use strict";
  700. __webpack_require__.r(__webpack_exports__);
  701. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  702. /* harmony export */ "default": () => (/* binding */ getScrollParent)
  703. /* harmony export */ });
  704. /* harmony import */ var _getParentNode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getParentNode.js */ "./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js");
  705. /* harmony import */ var _isScrollParent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isScrollParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js");
  706. /* harmony import */ var _getNodeName_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  707. /* harmony import */ var _instanceOf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  708. function getScrollParent(node) {
  709. if (['html', 'body', '#document'].indexOf((0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_0__["default"])(node)) >= 0) {
  710. // $FlowFixMe[incompatible-return]: assume body is always available
  711. return node.ownerDocument.body;
  712. }
  713. if ((0,_instanceOf_js__WEBPACK_IMPORTED_MODULE_1__.isHTMLElement)(node) && (0,_isScrollParent_js__WEBPACK_IMPORTED_MODULE_2__["default"])(node)) {
  714. return node;
  715. }
  716. return getScrollParent((0,_getParentNode_js__WEBPACK_IMPORTED_MODULE_3__["default"])(node));
  717. }
  718. /***/ }),
  719. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js":
  720. /*!**********************************************************************!*\
  721. !*** ./node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js ***!
  722. \**********************************************************************/
  723. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  724. "use strict";
  725. __webpack_require__.r(__webpack_exports__);
  726. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  727. /* harmony export */ "default": () => (/* binding */ getViewportRect)
  728. /* harmony export */ });
  729. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  730. /* harmony import */ var _getDocumentElement_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  731. /* harmony import */ var _getWindowScrollBarX_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getWindowScrollBarX.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js");
  732. /* harmony import */ var _isLayoutViewport_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isLayoutViewport.js */ "./node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js");
  733. function getViewportRect(element, strategy) {
  734. var win = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element);
  735. var html = (0,_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element);
  736. var visualViewport = win.visualViewport;
  737. var width = html.clientWidth;
  738. var height = html.clientHeight;
  739. var x = 0;
  740. var y = 0;
  741. if (visualViewport) {
  742. width = visualViewport.width;
  743. height = visualViewport.height;
  744. var layoutViewport = (0,_isLayoutViewport_js__WEBPACK_IMPORTED_MODULE_2__["default"])();
  745. if (layoutViewport || !layoutViewport && strategy === 'fixed') {
  746. x = visualViewport.offsetLeft;
  747. y = visualViewport.offsetTop;
  748. }
  749. }
  750. return {
  751. width: width,
  752. height: height,
  753. x: x + (0,_getWindowScrollBarX_js__WEBPACK_IMPORTED_MODULE_3__["default"])(element),
  754. y: y
  755. };
  756. }
  757. /***/ }),
  758. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js":
  759. /*!****************************************************************!*\
  760. !*** ./node_modules/@popperjs/core/lib/dom-utils/getWindow.js ***!
  761. \****************************************************************/
  762. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  763. "use strict";
  764. __webpack_require__.r(__webpack_exports__);
  765. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  766. /* harmony export */ "default": () => (/* binding */ getWindow)
  767. /* harmony export */ });
  768. function getWindow(node) {
  769. if (node == null) {
  770. return window;
  771. }
  772. if (node.toString() !== '[object Window]') {
  773. var ownerDocument = node.ownerDocument;
  774. return ownerDocument ? ownerDocument.defaultView || window : window;
  775. }
  776. return node;
  777. }
  778. /***/ }),
  779. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js":
  780. /*!**********************************************************************!*\
  781. !*** ./node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js ***!
  782. \**********************************************************************/
  783. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  784. "use strict";
  785. __webpack_require__.r(__webpack_exports__);
  786. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  787. /* harmony export */ "default": () => (/* binding */ getWindowScroll)
  788. /* harmony export */ });
  789. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  790. function getWindowScroll(node) {
  791. var win = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(node);
  792. var scrollLeft = win.pageXOffset;
  793. var scrollTop = win.pageYOffset;
  794. return {
  795. scrollLeft: scrollLeft,
  796. scrollTop: scrollTop
  797. };
  798. }
  799. /***/ }),
  800. /***/ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js":
  801. /*!**************************************************************************!*\
  802. !*** ./node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js ***!
  803. \**************************************************************************/
  804. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  805. "use strict";
  806. __webpack_require__.r(__webpack_exports__);
  807. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  808. /* harmony export */ "default": () => (/* binding */ getWindowScrollBarX)
  809. /* harmony export */ });
  810. /* harmony import */ var _getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getBoundingClientRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js");
  811. /* harmony import */ var _getDocumentElement_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  812. /* harmony import */ var _getWindowScroll_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getWindowScroll.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js");
  813. function getWindowScrollBarX(element) {
  814. // If <html> has a CSS width greater than the viewport, then this will be
  815. // incorrect for RTL.
  816. // Popper 1 is broken in this case and never had a bug report so let's assume
  817. // it's not an issue. I don't think anyone ever specifies width on <html>
  818. // anyway.
  819. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  820. // this (e.g. Edge 2019, IE11, Safari)
  821. return (0,_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element)).left + (0,_getWindowScroll_js__WEBPACK_IMPORTED_MODULE_2__["default"])(element).scrollLeft;
  822. }
  823. /***/ }),
  824. /***/ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js":
  825. /*!*****************************************************************!*\
  826. !*** ./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js ***!
  827. \*****************************************************************/
  828. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  829. "use strict";
  830. __webpack_require__.r(__webpack_exports__);
  831. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  832. /* harmony export */ isElement: () => (/* binding */ isElement),
  833. /* harmony export */ isHTMLElement: () => (/* binding */ isHTMLElement),
  834. /* harmony export */ isShadowRoot: () => (/* binding */ isShadowRoot)
  835. /* harmony export */ });
  836. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  837. function isElement(node) {
  838. var OwnElement = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(node).Element;
  839. return node instanceof OwnElement || node instanceof Element;
  840. }
  841. function isHTMLElement(node) {
  842. var OwnElement = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(node).HTMLElement;
  843. return node instanceof OwnElement || node instanceof HTMLElement;
  844. }
  845. function isShadowRoot(node) {
  846. // IE 11 has no ShadowRoot
  847. if (typeof ShadowRoot === 'undefined') {
  848. return false;
  849. }
  850. var OwnElement = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(node).ShadowRoot;
  851. return node instanceof OwnElement || node instanceof ShadowRoot;
  852. }
  853. /***/ }),
  854. /***/ "./node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js":
  855. /*!***********************************************************************!*\
  856. !*** ./node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js ***!
  857. \***********************************************************************/
  858. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  859. "use strict";
  860. __webpack_require__.r(__webpack_exports__);
  861. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  862. /* harmony export */ "default": () => (/* binding */ isLayoutViewport)
  863. /* harmony export */ });
  864. /* harmony import */ var _utils_userAgent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/userAgent.js */ "./node_modules/@popperjs/core/lib/utils/userAgent.js");
  865. function isLayoutViewport() {
  866. return !/^((?!chrome|android).)*safari/i.test((0,_utils_userAgent_js__WEBPACK_IMPORTED_MODULE_0__["default"])());
  867. }
  868. /***/ }),
  869. /***/ "./node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js":
  870. /*!*********************************************************************!*\
  871. !*** ./node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js ***!
  872. \*********************************************************************/
  873. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  874. "use strict";
  875. __webpack_require__.r(__webpack_exports__);
  876. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  877. /* harmony export */ "default": () => (/* binding */ isScrollParent)
  878. /* harmony export */ });
  879. /* harmony import */ var _getComputedStyle_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getComputedStyle.js */ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js");
  880. function isScrollParent(element) {
  881. // Firefox wants us to check `-x` and `-y` variations as well
  882. var _getComputedStyle = (0,_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element),
  883. overflow = _getComputedStyle.overflow,
  884. overflowX = _getComputedStyle.overflowX,
  885. overflowY = _getComputedStyle.overflowY;
  886. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  887. }
  888. /***/ }),
  889. /***/ "./node_modules/@popperjs/core/lib/dom-utils/isTableElement.js":
  890. /*!*********************************************************************!*\
  891. !*** ./node_modules/@popperjs/core/lib/dom-utils/isTableElement.js ***!
  892. \*********************************************************************/
  893. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  894. "use strict";
  895. __webpack_require__.r(__webpack_exports__);
  896. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  897. /* harmony export */ "default": () => (/* binding */ isTableElement)
  898. /* harmony export */ });
  899. /* harmony import */ var _getNodeName_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  900. function isTableElement(element) {
  901. return ['table', 'td', 'th'].indexOf((0,_getNodeName_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element)) >= 0;
  902. }
  903. /***/ }),
  904. /***/ "./node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js":
  905. /*!************************************************************************!*\
  906. !*** ./node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js ***!
  907. \************************************************************************/
  908. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  909. "use strict";
  910. __webpack_require__.r(__webpack_exports__);
  911. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  912. /* harmony export */ "default": () => (/* binding */ listScrollParents)
  913. /* harmony export */ });
  914. /* harmony import */ var _getScrollParent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getScrollParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js");
  915. /* harmony import */ var _getParentNode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getParentNode.js */ "./node_modules/@popperjs/core/lib/dom-utils/getParentNode.js");
  916. /* harmony import */ var _getWindow_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  917. /* harmony import */ var _isScrollParent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isScrollParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js");
  918. /*
  919. given a DOM element, return the list of all scroll parents, up the list of ancesors
  920. until we get to the top window object. This list is what we attach scroll listeners
  921. to, because if any of these parent elements scroll, we'll need to re-calculate the
  922. reference element's position.
  923. */
  924. function listScrollParents(element, list) {
  925. var _element$ownerDocumen;
  926. if (list === void 0) {
  927. list = [];
  928. }
  929. var scrollParent = (0,_getScrollParent_js__WEBPACK_IMPORTED_MODULE_0__["default"])(element);
  930. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  931. var win = (0,_getWindow_js__WEBPACK_IMPORTED_MODULE_1__["default"])(scrollParent);
  932. var target = isBody ? [win].concat(win.visualViewport || [], (0,_isScrollParent_js__WEBPACK_IMPORTED_MODULE_2__["default"])(scrollParent) ? scrollParent : []) : scrollParent;
  933. var updatedList = list.concat(target);
  934. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  935. updatedList.concat(listScrollParents((0,_getParentNode_js__WEBPACK_IMPORTED_MODULE_3__["default"])(target)));
  936. }
  937. /***/ }),
  938. /***/ "./node_modules/@popperjs/core/lib/enums.js":
  939. /*!**************************************************!*\
  940. !*** ./node_modules/@popperjs/core/lib/enums.js ***!
  941. \**************************************************/
  942. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  943. "use strict";
  944. __webpack_require__.r(__webpack_exports__);
  945. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  946. /* harmony export */ afterMain: () => (/* binding */ afterMain),
  947. /* harmony export */ afterRead: () => (/* binding */ afterRead),
  948. /* harmony export */ afterWrite: () => (/* binding */ afterWrite),
  949. /* harmony export */ auto: () => (/* binding */ auto),
  950. /* harmony export */ basePlacements: () => (/* binding */ basePlacements),
  951. /* harmony export */ beforeMain: () => (/* binding */ beforeMain),
  952. /* harmony export */ beforeRead: () => (/* binding */ beforeRead),
  953. /* harmony export */ beforeWrite: () => (/* binding */ beforeWrite),
  954. /* harmony export */ bottom: () => (/* binding */ bottom),
  955. /* harmony export */ clippingParents: () => (/* binding */ clippingParents),
  956. /* harmony export */ end: () => (/* binding */ end),
  957. /* harmony export */ left: () => (/* binding */ left),
  958. /* harmony export */ main: () => (/* binding */ main),
  959. /* harmony export */ modifierPhases: () => (/* binding */ modifierPhases),
  960. /* harmony export */ placements: () => (/* binding */ placements),
  961. /* harmony export */ popper: () => (/* binding */ popper),
  962. /* harmony export */ read: () => (/* binding */ read),
  963. /* harmony export */ reference: () => (/* binding */ reference),
  964. /* harmony export */ right: () => (/* binding */ right),
  965. /* harmony export */ start: () => (/* binding */ start),
  966. /* harmony export */ top: () => (/* binding */ top),
  967. /* harmony export */ variationPlacements: () => (/* binding */ variationPlacements),
  968. /* harmony export */ viewport: () => (/* binding */ viewport),
  969. /* harmony export */ write: () => (/* binding */ write)
  970. /* harmony export */ });
  971. var top = 'top';
  972. var bottom = 'bottom';
  973. var right = 'right';
  974. var left = 'left';
  975. var auto = 'auto';
  976. var basePlacements = [top, bottom, right, left];
  977. var start = 'start';
  978. var end = 'end';
  979. var clippingParents = 'clippingParents';
  980. var viewport = 'viewport';
  981. var popper = 'popper';
  982. var reference = 'reference';
  983. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  984. return acc.concat([placement + "-" + start, placement + "-" + end]);
  985. }, []);
  986. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  987. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  988. }, []); // modifiers that need to read the DOM
  989. var beforeRead = 'beforeRead';
  990. var read = 'read';
  991. var afterRead = 'afterRead'; // pure-logic modifiers
  992. var beforeMain = 'beforeMain';
  993. var main = 'main';
  994. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  995. var beforeWrite = 'beforeWrite';
  996. var write = 'write';
  997. var afterWrite = 'afterWrite';
  998. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  999. /***/ }),
  1000. /***/ "./node_modules/@popperjs/core/lib/index.js":
  1001. /*!**************************************************!*\
  1002. !*** ./node_modules/@popperjs/core/lib/index.js ***!
  1003. \**************************************************/
  1004. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1005. "use strict";
  1006. __webpack_require__.r(__webpack_exports__);
  1007. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1008. /* harmony export */ afterMain: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.afterMain),
  1009. /* harmony export */ afterRead: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.afterRead),
  1010. /* harmony export */ afterWrite: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.afterWrite),
  1011. /* harmony export */ applyStyles: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.applyStyles),
  1012. /* harmony export */ arrow: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.arrow),
  1013. /* harmony export */ auto: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.auto),
  1014. /* harmony export */ basePlacements: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.basePlacements),
  1015. /* harmony export */ beforeMain: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.beforeMain),
  1016. /* harmony export */ beforeRead: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.beforeRead),
  1017. /* harmony export */ beforeWrite: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.beforeWrite),
  1018. /* harmony export */ bottom: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.bottom),
  1019. /* harmony export */ clippingParents: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.clippingParents),
  1020. /* harmony export */ computeStyles: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.computeStyles),
  1021. /* harmony export */ createPopper: () => (/* reexport safe */ _popper_js__WEBPACK_IMPORTED_MODULE_4__.createPopper),
  1022. /* harmony export */ createPopperBase: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_2__.createPopper),
  1023. /* harmony export */ createPopperLite: () => (/* reexport safe */ _popper_lite_js__WEBPACK_IMPORTED_MODULE_5__.createPopper),
  1024. /* harmony export */ detectOverflow: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_3__["default"]),
  1025. /* harmony export */ end: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.end),
  1026. /* harmony export */ eventListeners: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.eventListeners),
  1027. /* harmony export */ flip: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.flip),
  1028. /* harmony export */ hide: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.hide),
  1029. /* harmony export */ left: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.left),
  1030. /* harmony export */ main: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.main),
  1031. /* harmony export */ modifierPhases: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.modifierPhases),
  1032. /* harmony export */ offset: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.offset),
  1033. /* harmony export */ placements: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.placements),
  1034. /* harmony export */ popper: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.popper),
  1035. /* harmony export */ popperGenerator: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_2__.popperGenerator),
  1036. /* harmony export */ popperOffsets: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.popperOffsets),
  1037. /* harmony export */ preventOverflow: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__.preventOverflow),
  1038. /* harmony export */ read: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.read),
  1039. /* harmony export */ reference: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.reference),
  1040. /* harmony export */ right: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.right),
  1041. /* harmony export */ start: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.start),
  1042. /* harmony export */ top: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.top),
  1043. /* harmony export */ variationPlacements: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.variationPlacements),
  1044. /* harmony export */ viewport: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.viewport),
  1045. /* harmony export */ write: () => (/* reexport safe */ _enums_js__WEBPACK_IMPORTED_MODULE_0__.write)
  1046. /* harmony export */ });
  1047. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1048. /* harmony import */ var _modifiers_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modifiers/index.js */ "./node_modules/@popperjs/core/lib/modifiers/index.js");
  1049. /* harmony import */ var _createPopper_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createPopper.js */ "./node_modules/@popperjs/core/lib/createPopper.js");
  1050. /* harmony import */ var _createPopper_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./createPopper.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1051. /* harmony import */ var _popper_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./popper.js */ "./node_modules/@popperjs/core/lib/popper.js");
  1052. /* harmony import */ var _popper_lite_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./popper-lite.js */ "./node_modules/@popperjs/core/lib/popper-lite.js");
  1053. // eslint-disable-next-line import/no-unused-modules
  1054. // eslint-disable-next-line import/no-unused-modules
  1055. // eslint-disable-next-line import/no-unused-modules
  1056. /***/ }),
  1057. /***/ "./node_modules/@popperjs/core/lib/modifiers/applyStyles.js":
  1058. /*!******************************************************************!*\
  1059. !*** ./node_modules/@popperjs/core/lib/modifiers/applyStyles.js ***!
  1060. \******************************************************************/
  1061. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1062. "use strict";
  1063. __webpack_require__.r(__webpack_exports__);
  1064. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1065. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1066. /* harmony export */ });
  1067. /* harmony import */ var _dom_utils_getNodeName_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../dom-utils/getNodeName.js */ "./node_modules/@popperjs/core/lib/dom-utils/getNodeName.js");
  1068. /* harmony import */ var _dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../dom-utils/instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  1069. // This modifier takes the styles prepared by the `computeStyles` modifier
  1070. // and applies them to the HTMLElements such as popper and arrow
  1071. function applyStyles(_ref) {
  1072. var state = _ref.state;
  1073. Object.keys(state.elements).forEach(function (name) {
  1074. var style = state.styles[name] || {};
  1075. var attributes = state.attributes[name] || {};
  1076. var element = state.elements[name]; // arrow is optional + virtual elements
  1077. if (!(0,_dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isHTMLElement)(element) || !(0,_dom_utils_getNodeName_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element)) {
  1078. return;
  1079. } // Flow doesn't support to extend this property, but it's the most
  1080. // effective way to apply styles to an HTMLElement
  1081. // $FlowFixMe[cannot-write]
  1082. Object.assign(element.style, style);
  1083. Object.keys(attributes).forEach(function (name) {
  1084. var value = attributes[name];
  1085. if (value === false) {
  1086. element.removeAttribute(name);
  1087. } else {
  1088. element.setAttribute(name, value === true ? '' : value);
  1089. }
  1090. });
  1091. });
  1092. }
  1093. function effect(_ref2) {
  1094. var state = _ref2.state;
  1095. var initialStyles = {
  1096. popper: {
  1097. position: state.options.strategy,
  1098. left: '0',
  1099. top: '0',
  1100. margin: '0'
  1101. },
  1102. arrow: {
  1103. position: 'absolute'
  1104. },
  1105. reference: {}
  1106. };
  1107. Object.assign(state.elements.popper.style, initialStyles.popper);
  1108. state.styles = initialStyles;
  1109. if (state.elements.arrow) {
  1110. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  1111. }
  1112. return function () {
  1113. Object.keys(state.elements).forEach(function (name) {
  1114. var element = state.elements[name];
  1115. var attributes = state.attributes[name] || {};
  1116. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  1117. var style = styleProperties.reduce(function (style, property) {
  1118. style[property] = '';
  1119. return style;
  1120. }, {}); // arrow is optional + virtual elements
  1121. if (!(0,_dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_0__.isHTMLElement)(element) || !(0,_dom_utils_getNodeName_js__WEBPACK_IMPORTED_MODULE_1__["default"])(element)) {
  1122. return;
  1123. }
  1124. Object.assign(element.style, style);
  1125. Object.keys(attributes).forEach(function (attribute) {
  1126. element.removeAttribute(attribute);
  1127. });
  1128. });
  1129. };
  1130. } // eslint-disable-next-line import/no-unused-modules
  1131. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1132. name: 'applyStyles',
  1133. enabled: true,
  1134. phase: 'write',
  1135. fn: applyStyles,
  1136. effect: effect,
  1137. requires: ['computeStyles']
  1138. });
  1139. /***/ }),
  1140. /***/ "./node_modules/@popperjs/core/lib/modifiers/arrow.js":
  1141. /*!************************************************************!*\
  1142. !*** ./node_modules/@popperjs/core/lib/modifiers/arrow.js ***!
  1143. \************************************************************/
  1144. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1145. "use strict";
  1146. __webpack_require__.r(__webpack_exports__);
  1147. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1148. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1149. /* harmony export */ });
  1150. /* harmony import */ var _utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  1151. /* harmony import */ var _dom_utils_getLayoutRect_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../dom-utils/getLayoutRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js");
  1152. /* harmony import */ var _dom_utils_contains_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../dom-utils/contains.js */ "./node_modules/@popperjs/core/lib/dom-utils/contains.js");
  1153. /* harmony import */ var _dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../dom-utils/getOffsetParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js");
  1154. /* harmony import */ var _utils_getMainAxisFromPlacement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/getMainAxisFromPlacement.js */ "./node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js");
  1155. /* harmony import */ var _utils_within_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/within.js */ "./node_modules/@popperjs/core/lib/utils/within.js");
  1156. /* harmony import */ var _utils_mergePaddingObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/mergePaddingObject.js */ "./node_modules/@popperjs/core/lib/utils/mergePaddingObject.js");
  1157. /* harmony import */ var _utils_expandToHashMap_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/expandToHashMap.js */ "./node_modules/@popperjs/core/lib/utils/expandToHashMap.js");
  1158. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1159. /* harmony import */ var _dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../dom-utils/instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  1160. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  1161. // eslint-disable-next-line import/no-unused-modules
  1162. var toPaddingObject = function toPaddingObject(padding, state) {
  1163. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  1164. placement: state.placement
  1165. })) : padding;
  1166. return (0,_utils_mergePaddingObject_js__WEBPACK_IMPORTED_MODULE_0__["default"])(typeof padding !== 'number' ? padding : (0,_utils_expandToHashMap_js__WEBPACK_IMPORTED_MODULE_1__["default"])(padding, _enums_js__WEBPACK_IMPORTED_MODULE_2__.basePlacements));
  1167. };
  1168. function arrow(_ref) {
  1169. var _state$modifiersData$;
  1170. var state = _ref.state,
  1171. name = _ref.name,
  1172. options = _ref.options;
  1173. var arrowElement = state.elements.arrow;
  1174. var popperOffsets = state.modifiersData.popperOffsets;
  1175. var basePlacement = (0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_3__["default"])(state.placement);
  1176. var axis = (0,_utils_getMainAxisFromPlacement_js__WEBPACK_IMPORTED_MODULE_4__["default"])(basePlacement);
  1177. var isVertical = [_enums_js__WEBPACK_IMPORTED_MODULE_2__.left, _enums_js__WEBPACK_IMPORTED_MODULE_2__.right].indexOf(basePlacement) >= 0;
  1178. var len = isVertical ? 'height' : 'width';
  1179. if (!arrowElement || !popperOffsets) {
  1180. return;
  1181. }
  1182. var paddingObject = toPaddingObject(options.padding, state);
  1183. var arrowRect = (0,_dom_utils_getLayoutRect_js__WEBPACK_IMPORTED_MODULE_5__["default"])(arrowElement);
  1184. var minProp = axis === 'y' ? _enums_js__WEBPACK_IMPORTED_MODULE_2__.top : _enums_js__WEBPACK_IMPORTED_MODULE_2__.left;
  1185. var maxProp = axis === 'y' ? _enums_js__WEBPACK_IMPORTED_MODULE_2__.bottom : _enums_js__WEBPACK_IMPORTED_MODULE_2__.right;
  1186. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  1187. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  1188. var arrowOffsetParent = (0,_dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_6__["default"])(arrowElement);
  1189. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  1190. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  1191. // outside of the popper bounds
  1192. var min = paddingObject[minProp];
  1193. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  1194. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  1195. var offset = (0,_utils_within_js__WEBPACK_IMPORTED_MODULE_7__.within)(min, center, max); // Prevents breaking syntax highlighting...
  1196. var axisProp = axis;
  1197. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  1198. }
  1199. function effect(_ref2) {
  1200. var state = _ref2.state,
  1201. options = _ref2.options;
  1202. var _options$element = options.element,
  1203. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  1204. if (arrowElement == null) {
  1205. return;
  1206. } // CSS selector
  1207. if (typeof arrowElement === 'string') {
  1208. arrowElement = state.elements.popper.querySelector(arrowElement);
  1209. if (!arrowElement) {
  1210. return;
  1211. }
  1212. }
  1213. if (true) {
  1214. if (!(0,_dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_8__.isHTMLElement)(arrowElement)) {
  1215. console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
  1216. }
  1217. }
  1218. if (!(0,_dom_utils_contains_js__WEBPACK_IMPORTED_MODULE_9__["default"])(state.elements.popper, arrowElement)) {
  1219. if (true) {
  1220. console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
  1221. }
  1222. return;
  1223. }
  1224. state.elements.arrow = arrowElement;
  1225. } // eslint-disable-next-line import/no-unused-modules
  1226. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1227. name: 'arrow',
  1228. enabled: true,
  1229. phase: 'main',
  1230. fn: arrow,
  1231. effect: effect,
  1232. requires: ['popperOffsets'],
  1233. requiresIfExists: ['preventOverflow']
  1234. });
  1235. /***/ }),
  1236. /***/ "./node_modules/@popperjs/core/lib/modifiers/computeStyles.js":
  1237. /*!********************************************************************!*\
  1238. !*** ./node_modules/@popperjs/core/lib/modifiers/computeStyles.js ***!
  1239. \********************************************************************/
  1240. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1241. "use strict";
  1242. __webpack_require__.r(__webpack_exports__);
  1243. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1244. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
  1245. /* harmony export */ mapToStyles: () => (/* binding */ mapToStyles)
  1246. /* harmony export */ });
  1247. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1248. /* harmony import */ var _dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../dom-utils/getOffsetParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js");
  1249. /* harmony import */ var _dom_utils_getWindow_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../dom-utils/getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  1250. /* harmony import */ var _dom_utils_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../dom-utils/getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  1251. /* harmony import */ var _dom_utils_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../dom-utils/getComputedStyle.js */ "./node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js");
  1252. /* harmony import */ var _utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  1253. /* harmony import */ var _utils_getVariation_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/getVariation.js */ "./node_modules/@popperjs/core/lib/utils/getVariation.js");
  1254. /* harmony import */ var _utils_math_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  1255. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  1256. // eslint-disable-next-line import/no-unused-modules
  1257. var unsetSides = {
  1258. top: 'auto',
  1259. right: 'auto',
  1260. bottom: 'auto',
  1261. left: 'auto'
  1262. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  1263. // Zooming can change the DPR, but it seems to report a value that will
  1264. // cleanly divide the values into the appropriate subpixels.
  1265. function roundOffsetsByDPR(_ref, win) {
  1266. var x = _ref.x,
  1267. y = _ref.y;
  1268. var dpr = win.devicePixelRatio || 1;
  1269. return {
  1270. x: (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_0__.round)(x * dpr) / dpr || 0,
  1271. y: (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_0__.round)(y * dpr) / dpr || 0
  1272. };
  1273. }
  1274. function mapToStyles(_ref2) {
  1275. var _Object$assign2;
  1276. var popper = _ref2.popper,
  1277. popperRect = _ref2.popperRect,
  1278. placement = _ref2.placement,
  1279. variation = _ref2.variation,
  1280. offsets = _ref2.offsets,
  1281. position = _ref2.position,
  1282. gpuAcceleration = _ref2.gpuAcceleration,
  1283. adaptive = _ref2.adaptive,
  1284. roundOffsets = _ref2.roundOffsets,
  1285. isFixed = _ref2.isFixed;
  1286. var _offsets$x = offsets.x,
  1287. x = _offsets$x === void 0 ? 0 : _offsets$x,
  1288. _offsets$y = offsets.y,
  1289. y = _offsets$y === void 0 ? 0 : _offsets$y;
  1290. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  1291. x: x,
  1292. y: y
  1293. }) : {
  1294. x: x,
  1295. y: y
  1296. };
  1297. x = _ref3.x;
  1298. y = _ref3.y;
  1299. var hasX = offsets.hasOwnProperty('x');
  1300. var hasY = offsets.hasOwnProperty('y');
  1301. var sideX = _enums_js__WEBPACK_IMPORTED_MODULE_1__.left;
  1302. var sideY = _enums_js__WEBPACK_IMPORTED_MODULE_1__.top;
  1303. var win = window;
  1304. if (adaptive) {
  1305. var offsetParent = (0,_dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_2__["default"])(popper);
  1306. var heightProp = 'clientHeight';
  1307. var widthProp = 'clientWidth';
  1308. if (offsetParent === (0,_dom_utils_getWindow_js__WEBPACK_IMPORTED_MODULE_3__["default"])(popper)) {
  1309. offsetParent = (0,_dom_utils_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_4__["default"])(popper);
  1310. if ((0,_dom_utils_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_5__["default"])(offsetParent).position !== 'static' && position === 'absolute') {
  1311. heightProp = 'scrollHeight';
  1312. widthProp = 'scrollWidth';
  1313. }
  1314. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  1315. offsetParent = offsetParent;
  1316. if (placement === _enums_js__WEBPACK_IMPORTED_MODULE_1__.top || (placement === _enums_js__WEBPACK_IMPORTED_MODULE_1__.left || placement === _enums_js__WEBPACK_IMPORTED_MODULE_1__.right) && variation === _enums_js__WEBPACK_IMPORTED_MODULE_1__.end) {
  1317. sideY = _enums_js__WEBPACK_IMPORTED_MODULE_1__.bottom;
  1318. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
  1319. offsetParent[heightProp];
  1320. y -= offsetY - popperRect.height;
  1321. y *= gpuAcceleration ? 1 : -1;
  1322. }
  1323. if (placement === _enums_js__WEBPACK_IMPORTED_MODULE_1__.left || (placement === _enums_js__WEBPACK_IMPORTED_MODULE_1__.top || placement === _enums_js__WEBPACK_IMPORTED_MODULE_1__.bottom) && variation === _enums_js__WEBPACK_IMPORTED_MODULE_1__.end) {
  1324. sideX = _enums_js__WEBPACK_IMPORTED_MODULE_1__.right;
  1325. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
  1326. offsetParent[widthProp];
  1327. x -= offsetX - popperRect.width;
  1328. x *= gpuAcceleration ? 1 : -1;
  1329. }
  1330. }
  1331. var commonStyles = Object.assign({
  1332. position: position
  1333. }, adaptive && unsetSides);
  1334. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  1335. x: x,
  1336. y: y
  1337. }, (0,_dom_utils_getWindow_js__WEBPACK_IMPORTED_MODULE_3__["default"])(popper)) : {
  1338. x: x,
  1339. y: y
  1340. };
  1341. x = _ref4.x;
  1342. y = _ref4.y;
  1343. if (gpuAcceleration) {
  1344. var _Object$assign;
  1345. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  1346. }
  1347. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  1348. }
  1349. function computeStyles(_ref5) {
  1350. var state = _ref5.state,
  1351. options = _ref5.options;
  1352. var _options$gpuAccelerat = options.gpuAcceleration,
  1353. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  1354. _options$adaptive = options.adaptive,
  1355. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  1356. _options$roundOffsets = options.roundOffsets,
  1357. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  1358. if (true) {
  1359. var transitionProperty = (0,_dom_utils_getComputedStyle_js__WEBPACK_IMPORTED_MODULE_5__["default"])(state.elements.popper).transitionProperty || '';
  1360. if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
  1361. return transitionProperty.indexOf(property) >= 0;
  1362. })) {
  1363. console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
  1364. }
  1365. }
  1366. var commonStyles = {
  1367. placement: (0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_6__["default"])(state.placement),
  1368. variation: (0,_utils_getVariation_js__WEBPACK_IMPORTED_MODULE_7__["default"])(state.placement),
  1369. popper: state.elements.popper,
  1370. popperRect: state.rects.popper,
  1371. gpuAcceleration: gpuAcceleration,
  1372. isFixed: state.options.strategy === 'fixed'
  1373. };
  1374. if (state.modifiersData.popperOffsets != null) {
  1375. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  1376. offsets: state.modifiersData.popperOffsets,
  1377. position: state.options.strategy,
  1378. adaptive: adaptive,
  1379. roundOffsets: roundOffsets
  1380. })));
  1381. }
  1382. if (state.modifiersData.arrow != null) {
  1383. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  1384. offsets: state.modifiersData.arrow,
  1385. position: 'absolute',
  1386. adaptive: false,
  1387. roundOffsets: roundOffsets
  1388. })));
  1389. }
  1390. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  1391. 'data-popper-placement': state.placement
  1392. });
  1393. } // eslint-disable-next-line import/no-unused-modules
  1394. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1395. name: 'computeStyles',
  1396. enabled: true,
  1397. phase: 'beforeWrite',
  1398. fn: computeStyles,
  1399. data: {}
  1400. });
  1401. /***/ }),
  1402. /***/ "./node_modules/@popperjs/core/lib/modifiers/eventListeners.js":
  1403. /*!*********************************************************************!*\
  1404. !*** ./node_modules/@popperjs/core/lib/modifiers/eventListeners.js ***!
  1405. \*********************************************************************/
  1406. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1407. "use strict";
  1408. __webpack_require__.r(__webpack_exports__);
  1409. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1410. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1411. /* harmony export */ });
  1412. /* harmony import */ var _dom_utils_getWindow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../dom-utils/getWindow.js */ "./node_modules/@popperjs/core/lib/dom-utils/getWindow.js");
  1413. // eslint-disable-next-line import/no-unused-modules
  1414. var passive = {
  1415. passive: true
  1416. };
  1417. function effect(_ref) {
  1418. var state = _ref.state,
  1419. instance = _ref.instance,
  1420. options = _ref.options;
  1421. var _options$scroll = options.scroll,
  1422. scroll = _options$scroll === void 0 ? true : _options$scroll,
  1423. _options$resize = options.resize,
  1424. resize = _options$resize === void 0 ? true : _options$resize;
  1425. var window = (0,_dom_utils_getWindow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(state.elements.popper);
  1426. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  1427. if (scroll) {
  1428. scrollParents.forEach(function (scrollParent) {
  1429. scrollParent.addEventListener('scroll', instance.update, passive);
  1430. });
  1431. }
  1432. if (resize) {
  1433. window.addEventListener('resize', instance.update, passive);
  1434. }
  1435. return function () {
  1436. if (scroll) {
  1437. scrollParents.forEach(function (scrollParent) {
  1438. scrollParent.removeEventListener('scroll', instance.update, passive);
  1439. });
  1440. }
  1441. if (resize) {
  1442. window.removeEventListener('resize', instance.update, passive);
  1443. }
  1444. };
  1445. } // eslint-disable-next-line import/no-unused-modules
  1446. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1447. name: 'eventListeners',
  1448. enabled: true,
  1449. phase: 'write',
  1450. fn: function fn() {},
  1451. effect: effect,
  1452. data: {}
  1453. });
  1454. /***/ }),
  1455. /***/ "./node_modules/@popperjs/core/lib/modifiers/flip.js":
  1456. /*!***********************************************************!*\
  1457. !*** ./node_modules/@popperjs/core/lib/modifiers/flip.js ***!
  1458. \***********************************************************/
  1459. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1460. "use strict";
  1461. __webpack_require__.r(__webpack_exports__);
  1462. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1463. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1464. /* harmony export */ });
  1465. /* harmony import */ var _utils_getOppositePlacement_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/getOppositePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getOppositePlacement.js");
  1466. /* harmony import */ var _utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  1467. /* harmony import */ var _utils_getOppositeVariationPlacement_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/getOppositeVariationPlacement.js */ "./node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js");
  1468. /* harmony import */ var _utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/detectOverflow.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1469. /* harmony import */ var _utils_computeAutoPlacement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/computeAutoPlacement.js */ "./node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js");
  1470. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1471. /* harmony import */ var _utils_getVariation_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/getVariation.js */ "./node_modules/@popperjs/core/lib/utils/getVariation.js");
  1472. // eslint-disable-next-line import/no-unused-modules
  1473. function getExpandedFallbackPlacements(placement) {
  1474. if ((0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(placement) === _enums_js__WEBPACK_IMPORTED_MODULE_1__.auto) {
  1475. return [];
  1476. }
  1477. var oppositePlacement = (0,_utils_getOppositePlacement_js__WEBPACK_IMPORTED_MODULE_2__["default"])(placement);
  1478. return [(0,_utils_getOppositeVariationPlacement_js__WEBPACK_IMPORTED_MODULE_3__["default"])(placement), oppositePlacement, (0,_utils_getOppositeVariationPlacement_js__WEBPACK_IMPORTED_MODULE_3__["default"])(oppositePlacement)];
  1479. }
  1480. function flip(_ref) {
  1481. var state = _ref.state,
  1482. options = _ref.options,
  1483. name = _ref.name;
  1484. if (state.modifiersData[name]._skip) {
  1485. return;
  1486. }
  1487. var _options$mainAxis = options.mainAxis,
  1488. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  1489. _options$altAxis = options.altAxis,
  1490. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  1491. specifiedFallbackPlacements = options.fallbackPlacements,
  1492. padding = options.padding,
  1493. boundary = options.boundary,
  1494. rootBoundary = options.rootBoundary,
  1495. altBoundary = options.altBoundary,
  1496. _options$flipVariatio = options.flipVariations,
  1497. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  1498. allowedAutoPlacements = options.allowedAutoPlacements;
  1499. var preferredPlacement = state.options.placement;
  1500. var basePlacement = (0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(preferredPlacement);
  1501. var isBasePlacement = basePlacement === preferredPlacement;
  1502. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [(0,_utils_getOppositePlacement_js__WEBPACK_IMPORTED_MODULE_2__["default"])(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  1503. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  1504. return acc.concat((0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(placement) === _enums_js__WEBPACK_IMPORTED_MODULE_1__.auto ? (0,_utils_computeAutoPlacement_js__WEBPACK_IMPORTED_MODULE_4__["default"])(state, {
  1505. placement: placement,
  1506. boundary: boundary,
  1507. rootBoundary: rootBoundary,
  1508. padding: padding,
  1509. flipVariations: flipVariations,
  1510. allowedAutoPlacements: allowedAutoPlacements
  1511. }) : placement);
  1512. }, []);
  1513. var referenceRect = state.rects.reference;
  1514. var popperRect = state.rects.popper;
  1515. var checksMap = new Map();
  1516. var makeFallbackChecks = true;
  1517. var firstFittingPlacement = placements[0];
  1518. for (var i = 0; i < placements.length; i++) {
  1519. var placement = placements[i];
  1520. var _basePlacement = (0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(placement);
  1521. var isStartVariation = (0,_utils_getVariation_js__WEBPACK_IMPORTED_MODULE_5__["default"])(placement) === _enums_js__WEBPACK_IMPORTED_MODULE_1__.start;
  1522. var isVertical = [_enums_js__WEBPACK_IMPORTED_MODULE_1__.top, _enums_js__WEBPACK_IMPORTED_MODULE_1__.bottom].indexOf(_basePlacement) >= 0;
  1523. var len = isVertical ? 'width' : 'height';
  1524. var overflow = (0,_utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_6__["default"])(state, {
  1525. placement: placement,
  1526. boundary: boundary,
  1527. rootBoundary: rootBoundary,
  1528. altBoundary: altBoundary,
  1529. padding: padding
  1530. });
  1531. var mainVariationSide = isVertical ? isStartVariation ? _enums_js__WEBPACK_IMPORTED_MODULE_1__.right : _enums_js__WEBPACK_IMPORTED_MODULE_1__.left : isStartVariation ? _enums_js__WEBPACK_IMPORTED_MODULE_1__.bottom : _enums_js__WEBPACK_IMPORTED_MODULE_1__.top;
  1532. if (referenceRect[len] > popperRect[len]) {
  1533. mainVariationSide = (0,_utils_getOppositePlacement_js__WEBPACK_IMPORTED_MODULE_2__["default"])(mainVariationSide);
  1534. }
  1535. var altVariationSide = (0,_utils_getOppositePlacement_js__WEBPACK_IMPORTED_MODULE_2__["default"])(mainVariationSide);
  1536. var checks = [];
  1537. if (checkMainAxis) {
  1538. checks.push(overflow[_basePlacement] <= 0);
  1539. }
  1540. if (checkAltAxis) {
  1541. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  1542. }
  1543. if (checks.every(function (check) {
  1544. return check;
  1545. })) {
  1546. firstFittingPlacement = placement;
  1547. makeFallbackChecks = false;
  1548. break;
  1549. }
  1550. checksMap.set(placement, checks);
  1551. }
  1552. if (makeFallbackChecks) {
  1553. // `2` may be desired in some cases – research later
  1554. var numberOfChecks = flipVariations ? 3 : 1;
  1555. var _loop = function _loop(_i) {
  1556. var fittingPlacement = placements.find(function (placement) {
  1557. var checks = checksMap.get(placement);
  1558. if (checks) {
  1559. return checks.slice(0, _i).every(function (check) {
  1560. return check;
  1561. });
  1562. }
  1563. });
  1564. if (fittingPlacement) {
  1565. firstFittingPlacement = fittingPlacement;
  1566. return "break";
  1567. }
  1568. };
  1569. for (var _i = numberOfChecks; _i > 0; _i--) {
  1570. var _ret = _loop(_i);
  1571. if (_ret === "break") break;
  1572. }
  1573. }
  1574. if (state.placement !== firstFittingPlacement) {
  1575. state.modifiersData[name]._skip = true;
  1576. state.placement = firstFittingPlacement;
  1577. state.reset = true;
  1578. }
  1579. } // eslint-disable-next-line import/no-unused-modules
  1580. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1581. name: 'flip',
  1582. enabled: true,
  1583. phase: 'main',
  1584. fn: flip,
  1585. requiresIfExists: ['offset'],
  1586. data: {
  1587. _skip: false
  1588. }
  1589. });
  1590. /***/ }),
  1591. /***/ "./node_modules/@popperjs/core/lib/modifiers/hide.js":
  1592. /*!***********************************************************!*\
  1593. !*** ./node_modules/@popperjs/core/lib/modifiers/hide.js ***!
  1594. \***********************************************************/
  1595. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1596. "use strict";
  1597. __webpack_require__.r(__webpack_exports__);
  1598. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1599. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1600. /* harmony export */ });
  1601. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1602. /* harmony import */ var _utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/detectOverflow.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1603. function getSideOffsets(overflow, rect, preventedOffsets) {
  1604. if (preventedOffsets === void 0) {
  1605. preventedOffsets = {
  1606. x: 0,
  1607. y: 0
  1608. };
  1609. }
  1610. return {
  1611. top: overflow.top - rect.height - preventedOffsets.y,
  1612. right: overflow.right - rect.width + preventedOffsets.x,
  1613. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  1614. left: overflow.left - rect.width - preventedOffsets.x
  1615. };
  1616. }
  1617. function isAnySideFullyClipped(overflow) {
  1618. return [_enums_js__WEBPACK_IMPORTED_MODULE_0__.top, _enums_js__WEBPACK_IMPORTED_MODULE_0__.right, _enums_js__WEBPACK_IMPORTED_MODULE_0__.bottom, _enums_js__WEBPACK_IMPORTED_MODULE_0__.left].some(function (side) {
  1619. return overflow[side] >= 0;
  1620. });
  1621. }
  1622. function hide(_ref) {
  1623. var state = _ref.state,
  1624. name = _ref.name;
  1625. var referenceRect = state.rects.reference;
  1626. var popperRect = state.rects.popper;
  1627. var preventedOffsets = state.modifiersData.preventOverflow;
  1628. var referenceOverflow = (0,_utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_1__["default"])(state, {
  1629. elementContext: 'reference'
  1630. });
  1631. var popperAltOverflow = (0,_utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_1__["default"])(state, {
  1632. altBoundary: true
  1633. });
  1634. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  1635. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  1636. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  1637. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  1638. state.modifiersData[name] = {
  1639. referenceClippingOffsets: referenceClippingOffsets,
  1640. popperEscapeOffsets: popperEscapeOffsets,
  1641. isReferenceHidden: isReferenceHidden,
  1642. hasPopperEscaped: hasPopperEscaped
  1643. };
  1644. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  1645. 'data-popper-reference-hidden': isReferenceHidden,
  1646. 'data-popper-escaped': hasPopperEscaped
  1647. });
  1648. } // eslint-disable-next-line import/no-unused-modules
  1649. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1650. name: 'hide',
  1651. enabled: true,
  1652. phase: 'main',
  1653. requiresIfExists: ['preventOverflow'],
  1654. fn: hide
  1655. });
  1656. /***/ }),
  1657. /***/ "./node_modules/@popperjs/core/lib/modifiers/index.js":
  1658. /*!************************************************************!*\
  1659. !*** ./node_modules/@popperjs/core/lib/modifiers/index.js ***!
  1660. \************************************************************/
  1661. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1662. "use strict";
  1663. __webpack_require__.r(__webpack_exports__);
  1664. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1665. /* harmony export */ applyStyles: () => (/* reexport safe */ _applyStyles_js__WEBPACK_IMPORTED_MODULE_0__["default"]),
  1666. /* harmony export */ arrow: () => (/* reexport safe */ _arrow_js__WEBPACK_IMPORTED_MODULE_1__["default"]),
  1667. /* harmony export */ computeStyles: () => (/* reexport safe */ _computeStyles_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
  1668. /* harmony export */ eventListeners: () => (/* reexport safe */ _eventListeners_js__WEBPACK_IMPORTED_MODULE_3__["default"]),
  1669. /* harmony export */ flip: () => (/* reexport safe */ _flip_js__WEBPACK_IMPORTED_MODULE_4__["default"]),
  1670. /* harmony export */ hide: () => (/* reexport safe */ _hide_js__WEBPACK_IMPORTED_MODULE_5__["default"]),
  1671. /* harmony export */ offset: () => (/* reexport safe */ _offset_js__WEBPACK_IMPORTED_MODULE_6__["default"]),
  1672. /* harmony export */ popperOffsets: () => (/* reexport safe */ _popperOffsets_js__WEBPACK_IMPORTED_MODULE_7__["default"]),
  1673. /* harmony export */ preventOverflow: () => (/* reexport safe */ _preventOverflow_js__WEBPACK_IMPORTED_MODULE_8__["default"])
  1674. /* harmony export */ });
  1675. /* harmony import */ var _applyStyles_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./applyStyles.js */ "./node_modules/@popperjs/core/lib/modifiers/applyStyles.js");
  1676. /* harmony import */ var _arrow_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arrow.js */ "./node_modules/@popperjs/core/lib/modifiers/arrow.js");
  1677. /* harmony import */ var _computeStyles_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./computeStyles.js */ "./node_modules/@popperjs/core/lib/modifiers/computeStyles.js");
  1678. /* harmony import */ var _eventListeners_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./eventListeners.js */ "./node_modules/@popperjs/core/lib/modifiers/eventListeners.js");
  1679. /* harmony import */ var _flip_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./flip.js */ "./node_modules/@popperjs/core/lib/modifiers/flip.js");
  1680. /* harmony import */ var _hide_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hide.js */ "./node_modules/@popperjs/core/lib/modifiers/hide.js");
  1681. /* harmony import */ var _offset_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./offset.js */ "./node_modules/@popperjs/core/lib/modifiers/offset.js");
  1682. /* harmony import */ var _popperOffsets_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./popperOffsets.js */ "./node_modules/@popperjs/core/lib/modifiers/popperOffsets.js");
  1683. /* harmony import */ var _preventOverflow_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./preventOverflow.js */ "./node_modules/@popperjs/core/lib/modifiers/preventOverflow.js");
  1684. /***/ }),
  1685. /***/ "./node_modules/@popperjs/core/lib/modifiers/offset.js":
  1686. /*!*************************************************************!*\
  1687. !*** ./node_modules/@popperjs/core/lib/modifiers/offset.js ***!
  1688. \*************************************************************/
  1689. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1690. "use strict";
  1691. __webpack_require__.r(__webpack_exports__);
  1692. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1693. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
  1694. /* harmony export */ distanceAndSkiddingToXY: () => (/* binding */ distanceAndSkiddingToXY)
  1695. /* harmony export */ });
  1696. /* harmony import */ var _utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  1697. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1698. // eslint-disable-next-line import/no-unused-modules
  1699. function distanceAndSkiddingToXY(placement, rects, offset) {
  1700. var basePlacement = (0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(placement);
  1701. var invertDistance = [_enums_js__WEBPACK_IMPORTED_MODULE_1__.left, _enums_js__WEBPACK_IMPORTED_MODULE_1__.top].indexOf(basePlacement) >= 0 ? -1 : 1;
  1702. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  1703. placement: placement
  1704. })) : offset,
  1705. skidding = _ref[0],
  1706. distance = _ref[1];
  1707. skidding = skidding || 0;
  1708. distance = (distance || 0) * invertDistance;
  1709. return [_enums_js__WEBPACK_IMPORTED_MODULE_1__.left, _enums_js__WEBPACK_IMPORTED_MODULE_1__.right].indexOf(basePlacement) >= 0 ? {
  1710. x: distance,
  1711. y: skidding
  1712. } : {
  1713. x: skidding,
  1714. y: distance
  1715. };
  1716. }
  1717. function offset(_ref2) {
  1718. var state = _ref2.state,
  1719. options = _ref2.options,
  1720. name = _ref2.name;
  1721. var _options$offset = options.offset,
  1722. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  1723. var data = _enums_js__WEBPACK_IMPORTED_MODULE_1__.placements.reduce(function (acc, placement) {
  1724. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  1725. return acc;
  1726. }, {});
  1727. var _data$state$placement = data[state.placement],
  1728. x = _data$state$placement.x,
  1729. y = _data$state$placement.y;
  1730. if (state.modifiersData.popperOffsets != null) {
  1731. state.modifiersData.popperOffsets.x += x;
  1732. state.modifiersData.popperOffsets.y += y;
  1733. }
  1734. state.modifiersData[name] = data;
  1735. } // eslint-disable-next-line import/no-unused-modules
  1736. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1737. name: 'offset',
  1738. enabled: true,
  1739. phase: 'main',
  1740. requires: ['popperOffsets'],
  1741. fn: offset
  1742. });
  1743. /***/ }),
  1744. /***/ "./node_modules/@popperjs/core/lib/modifiers/popperOffsets.js":
  1745. /*!********************************************************************!*\
  1746. !*** ./node_modules/@popperjs/core/lib/modifiers/popperOffsets.js ***!
  1747. \********************************************************************/
  1748. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1749. "use strict";
  1750. __webpack_require__.r(__webpack_exports__);
  1751. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1752. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1753. /* harmony export */ });
  1754. /* harmony import */ var _utils_computeOffsets_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/computeOffsets.js */ "./node_modules/@popperjs/core/lib/utils/computeOffsets.js");
  1755. function popperOffsets(_ref) {
  1756. var state = _ref.state,
  1757. name = _ref.name;
  1758. // Offsets are the actual position the popper needs to have to be
  1759. // properly positioned near its reference element
  1760. // This is the most basic placement, and will be adjusted by
  1761. // the modifiers in the next step
  1762. state.modifiersData[name] = (0,_utils_computeOffsets_js__WEBPACK_IMPORTED_MODULE_0__["default"])({
  1763. reference: state.rects.reference,
  1764. element: state.rects.popper,
  1765. strategy: 'absolute',
  1766. placement: state.placement
  1767. });
  1768. } // eslint-disable-next-line import/no-unused-modules
  1769. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1770. name: 'popperOffsets',
  1771. enabled: true,
  1772. phase: 'read',
  1773. fn: popperOffsets,
  1774. data: {}
  1775. });
  1776. /***/ }),
  1777. /***/ "./node_modules/@popperjs/core/lib/modifiers/preventOverflow.js":
  1778. /*!**********************************************************************!*\
  1779. !*** ./node_modules/@popperjs/core/lib/modifiers/preventOverflow.js ***!
  1780. \**********************************************************************/
  1781. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1782. "use strict";
  1783. __webpack_require__.r(__webpack_exports__);
  1784. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1785. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1786. /* harmony export */ });
  1787. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1788. /* harmony import */ var _utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  1789. /* harmony import */ var _utils_getMainAxisFromPlacement_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/getMainAxisFromPlacement.js */ "./node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js");
  1790. /* harmony import */ var _utils_getAltAxis_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/getAltAxis.js */ "./node_modules/@popperjs/core/lib/utils/getAltAxis.js");
  1791. /* harmony import */ var _utils_within_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/within.js */ "./node_modules/@popperjs/core/lib/utils/within.js");
  1792. /* harmony import */ var _dom_utils_getLayoutRect_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../dom-utils/getLayoutRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js");
  1793. /* harmony import */ var _dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../dom-utils/getOffsetParent.js */ "./node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js");
  1794. /* harmony import */ var _utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/detectOverflow.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1795. /* harmony import */ var _utils_getVariation_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/getVariation.js */ "./node_modules/@popperjs/core/lib/utils/getVariation.js");
  1796. /* harmony import */ var _utils_getFreshSideObject_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/getFreshSideObject.js */ "./node_modules/@popperjs/core/lib/utils/getFreshSideObject.js");
  1797. /* harmony import */ var _utils_math_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  1798. function preventOverflow(_ref) {
  1799. var state = _ref.state,
  1800. options = _ref.options,
  1801. name = _ref.name;
  1802. var _options$mainAxis = options.mainAxis,
  1803. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  1804. _options$altAxis = options.altAxis,
  1805. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  1806. boundary = options.boundary,
  1807. rootBoundary = options.rootBoundary,
  1808. altBoundary = options.altBoundary,
  1809. padding = options.padding,
  1810. _options$tether = options.tether,
  1811. tether = _options$tether === void 0 ? true : _options$tether,
  1812. _options$tetherOffset = options.tetherOffset,
  1813. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  1814. var overflow = (0,_utils_detectOverflow_js__WEBPACK_IMPORTED_MODULE_0__["default"])(state, {
  1815. boundary: boundary,
  1816. rootBoundary: rootBoundary,
  1817. padding: padding,
  1818. altBoundary: altBoundary
  1819. });
  1820. var basePlacement = (0,_utils_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_1__["default"])(state.placement);
  1821. var variation = (0,_utils_getVariation_js__WEBPACK_IMPORTED_MODULE_2__["default"])(state.placement);
  1822. var isBasePlacement = !variation;
  1823. var mainAxis = (0,_utils_getMainAxisFromPlacement_js__WEBPACK_IMPORTED_MODULE_3__["default"])(basePlacement);
  1824. var altAxis = (0,_utils_getAltAxis_js__WEBPACK_IMPORTED_MODULE_4__["default"])(mainAxis);
  1825. var popperOffsets = state.modifiersData.popperOffsets;
  1826. var referenceRect = state.rects.reference;
  1827. var popperRect = state.rects.popper;
  1828. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  1829. placement: state.placement
  1830. })) : tetherOffset;
  1831. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  1832. mainAxis: tetherOffsetValue,
  1833. altAxis: tetherOffsetValue
  1834. } : Object.assign({
  1835. mainAxis: 0,
  1836. altAxis: 0
  1837. }, tetherOffsetValue);
  1838. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  1839. var data = {
  1840. x: 0,
  1841. y: 0
  1842. };
  1843. if (!popperOffsets) {
  1844. return;
  1845. }
  1846. if (checkMainAxis) {
  1847. var _offsetModifierState$;
  1848. var mainSide = mainAxis === 'y' ? _enums_js__WEBPACK_IMPORTED_MODULE_5__.top : _enums_js__WEBPACK_IMPORTED_MODULE_5__.left;
  1849. var altSide = mainAxis === 'y' ? _enums_js__WEBPACK_IMPORTED_MODULE_5__.bottom : _enums_js__WEBPACK_IMPORTED_MODULE_5__.right;
  1850. var len = mainAxis === 'y' ? 'height' : 'width';
  1851. var offset = popperOffsets[mainAxis];
  1852. var min = offset + overflow[mainSide];
  1853. var max = offset - overflow[altSide];
  1854. var additive = tether ? -popperRect[len] / 2 : 0;
  1855. var minLen = variation === _enums_js__WEBPACK_IMPORTED_MODULE_5__.start ? referenceRect[len] : popperRect[len];
  1856. var maxLen = variation === _enums_js__WEBPACK_IMPORTED_MODULE_5__.start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  1857. // outside the reference bounds
  1858. var arrowElement = state.elements.arrow;
  1859. var arrowRect = tether && arrowElement ? (0,_dom_utils_getLayoutRect_js__WEBPACK_IMPORTED_MODULE_6__["default"])(arrowElement) : {
  1860. width: 0,
  1861. height: 0
  1862. };
  1863. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : (0,_utils_getFreshSideObject_js__WEBPACK_IMPORTED_MODULE_7__["default"])();
  1864. var arrowPaddingMin = arrowPaddingObject[mainSide];
  1865. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  1866. // to include its full size in the calculation. If the reference is small
  1867. // and near the edge of a boundary, the popper can overflow even if the
  1868. // reference is not overflowing as well (e.g. virtual elements with no
  1869. // width or height)
  1870. var arrowLen = (0,_utils_within_js__WEBPACK_IMPORTED_MODULE_8__.within)(0, referenceRect[len], arrowRect[len]);
  1871. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  1872. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  1873. var arrowOffsetParent = state.elements.arrow && (0,_dom_utils_getOffsetParent_js__WEBPACK_IMPORTED_MODULE_9__["default"])(state.elements.arrow);
  1874. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  1875. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  1876. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  1877. var tetherMax = offset + maxOffset - offsetModifierValue;
  1878. var preventedOffset = (0,_utils_within_js__WEBPACK_IMPORTED_MODULE_8__.within)(tether ? (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_10__.min)(min, tetherMin) : min, offset, tether ? (0,_utils_math_js__WEBPACK_IMPORTED_MODULE_10__.max)(max, tetherMax) : max);
  1879. popperOffsets[mainAxis] = preventedOffset;
  1880. data[mainAxis] = preventedOffset - offset;
  1881. }
  1882. if (checkAltAxis) {
  1883. var _offsetModifierState$2;
  1884. var _mainSide = mainAxis === 'x' ? _enums_js__WEBPACK_IMPORTED_MODULE_5__.top : _enums_js__WEBPACK_IMPORTED_MODULE_5__.left;
  1885. var _altSide = mainAxis === 'x' ? _enums_js__WEBPACK_IMPORTED_MODULE_5__.bottom : _enums_js__WEBPACK_IMPORTED_MODULE_5__.right;
  1886. var _offset = popperOffsets[altAxis];
  1887. var _len = altAxis === 'y' ? 'height' : 'width';
  1888. var _min = _offset + overflow[_mainSide];
  1889. var _max = _offset - overflow[_altSide];
  1890. var isOriginSide = [_enums_js__WEBPACK_IMPORTED_MODULE_5__.top, _enums_js__WEBPACK_IMPORTED_MODULE_5__.left].indexOf(basePlacement) !== -1;
  1891. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  1892. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  1893. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  1894. var _preventedOffset = tether && isOriginSide ? (0,_utils_within_js__WEBPACK_IMPORTED_MODULE_8__.withinMaxClamp)(_tetherMin, _offset, _tetherMax) : (0,_utils_within_js__WEBPACK_IMPORTED_MODULE_8__.within)(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  1895. popperOffsets[altAxis] = _preventedOffset;
  1896. data[altAxis] = _preventedOffset - _offset;
  1897. }
  1898. state.modifiersData[name] = data;
  1899. } // eslint-disable-next-line import/no-unused-modules
  1900. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  1901. name: 'preventOverflow',
  1902. enabled: true,
  1903. phase: 'main',
  1904. fn: preventOverflow,
  1905. requiresIfExists: ['offset']
  1906. });
  1907. /***/ }),
  1908. /***/ "./node_modules/@popperjs/core/lib/popper-lite.js":
  1909. /*!********************************************************!*\
  1910. !*** ./node_modules/@popperjs/core/lib/popper-lite.js ***!
  1911. \********************************************************/
  1912. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1913. "use strict";
  1914. __webpack_require__.r(__webpack_exports__);
  1915. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1916. /* harmony export */ createPopper: () => (/* binding */ createPopper),
  1917. /* harmony export */ defaultModifiers: () => (/* binding */ defaultModifiers),
  1918. /* harmony export */ detectOverflow: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_5__["default"]),
  1919. /* harmony export */ popperGenerator: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_4__.popperGenerator)
  1920. /* harmony export */ });
  1921. /* harmony import */ var _createPopper_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createPopper.js */ "./node_modules/@popperjs/core/lib/createPopper.js");
  1922. /* harmony import */ var _createPopper_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./createPopper.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1923. /* harmony import */ var _modifiers_eventListeners_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modifiers/eventListeners.js */ "./node_modules/@popperjs/core/lib/modifiers/eventListeners.js");
  1924. /* harmony import */ var _modifiers_popperOffsets_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modifiers/popperOffsets.js */ "./node_modules/@popperjs/core/lib/modifiers/popperOffsets.js");
  1925. /* harmony import */ var _modifiers_computeStyles_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modifiers/computeStyles.js */ "./node_modules/@popperjs/core/lib/modifiers/computeStyles.js");
  1926. /* harmony import */ var _modifiers_applyStyles_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modifiers/applyStyles.js */ "./node_modules/@popperjs/core/lib/modifiers/applyStyles.js");
  1927. var defaultModifiers = [_modifiers_eventListeners_js__WEBPACK_IMPORTED_MODULE_0__["default"], _modifiers_popperOffsets_js__WEBPACK_IMPORTED_MODULE_1__["default"], _modifiers_computeStyles_js__WEBPACK_IMPORTED_MODULE_2__["default"], _modifiers_applyStyles_js__WEBPACK_IMPORTED_MODULE_3__["default"]];
  1928. var createPopper = /*#__PURE__*/(0,_createPopper_js__WEBPACK_IMPORTED_MODULE_4__.popperGenerator)({
  1929. defaultModifiers: defaultModifiers
  1930. }); // eslint-disable-next-line import/no-unused-modules
  1931. /***/ }),
  1932. /***/ "./node_modules/@popperjs/core/lib/popper.js":
  1933. /*!***************************************************!*\
  1934. !*** ./node_modules/@popperjs/core/lib/popper.js ***!
  1935. \***************************************************/
  1936. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1937. "use strict";
  1938. __webpack_require__.r(__webpack_exports__);
  1939. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1940. /* harmony export */ applyStyles: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.applyStyles),
  1941. /* harmony export */ arrow: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.arrow),
  1942. /* harmony export */ computeStyles: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.computeStyles),
  1943. /* harmony export */ createPopper: () => (/* binding */ createPopper),
  1944. /* harmony export */ createPopperLite: () => (/* reexport safe */ _popper_lite_js__WEBPACK_IMPORTED_MODULE_11__.createPopper),
  1945. /* harmony export */ defaultModifiers: () => (/* binding */ defaultModifiers),
  1946. /* harmony export */ detectOverflow: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_10__["default"]),
  1947. /* harmony export */ eventListeners: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.eventListeners),
  1948. /* harmony export */ flip: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.flip),
  1949. /* harmony export */ hide: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.hide),
  1950. /* harmony export */ offset: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.offset),
  1951. /* harmony export */ popperGenerator: () => (/* reexport safe */ _createPopper_js__WEBPACK_IMPORTED_MODULE_9__.popperGenerator),
  1952. /* harmony export */ popperOffsets: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.popperOffsets),
  1953. /* harmony export */ preventOverflow: () => (/* reexport safe */ _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__.preventOverflow)
  1954. /* harmony export */ });
  1955. /* harmony import */ var _createPopper_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./createPopper.js */ "./node_modules/@popperjs/core/lib/createPopper.js");
  1956. /* harmony import */ var _createPopper_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./createPopper.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1957. /* harmony import */ var _modifiers_eventListeners_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modifiers/eventListeners.js */ "./node_modules/@popperjs/core/lib/modifiers/eventListeners.js");
  1958. /* harmony import */ var _modifiers_popperOffsets_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modifiers/popperOffsets.js */ "./node_modules/@popperjs/core/lib/modifiers/popperOffsets.js");
  1959. /* harmony import */ var _modifiers_computeStyles_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modifiers/computeStyles.js */ "./node_modules/@popperjs/core/lib/modifiers/computeStyles.js");
  1960. /* harmony import */ var _modifiers_applyStyles_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modifiers/applyStyles.js */ "./node_modules/@popperjs/core/lib/modifiers/applyStyles.js");
  1961. /* harmony import */ var _modifiers_offset_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./modifiers/offset.js */ "./node_modules/@popperjs/core/lib/modifiers/offset.js");
  1962. /* harmony import */ var _modifiers_flip_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./modifiers/flip.js */ "./node_modules/@popperjs/core/lib/modifiers/flip.js");
  1963. /* harmony import */ var _modifiers_preventOverflow_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./modifiers/preventOverflow.js */ "./node_modules/@popperjs/core/lib/modifiers/preventOverflow.js");
  1964. /* harmony import */ var _modifiers_arrow_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./modifiers/arrow.js */ "./node_modules/@popperjs/core/lib/modifiers/arrow.js");
  1965. /* harmony import */ var _modifiers_hide_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./modifiers/hide.js */ "./node_modules/@popperjs/core/lib/modifiers/hide.js");
  1966. /* harmony import */ var _popper_lite_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./popper-lite.js */ "./node_modules/@popperjs/core/lib/popper-lite.js");
  1967. /* harmony import */ var _modifiers_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./modifiers/index.js */ "./node_modules/@popperjs/core/lib/modifiers/index.js");
  1968. var defaultModifiers = [_modifiers_eventListeners_js__WEBPACK_IMPORTED_MODULE_0__["default"], _modifiers_popperOffsets_js__WEBPACK_IMPORTED_MODULE_1__["default"], _modifiers_computeStyles_js__WEBPACK_IMPORTED_MODULE_2__["default"], _modifiers_applyStyles_js__WEBPACK_IMPORTED_MODULE_3__["default"], _modifiers_offset_js__WEBPACK_IMPORTED_MODULE_4__["default"], _modifiers_flip_js__WEBPACK_IMPORTED_MODULE_5__["default"], _modifiers_preventOverflow_js__WEBPACK_IMPORTED_MODULE_6__["default"], _modifiers_arrow_js__WEBPACK_IMPORTED_MODULE_7__["default"], _modifiers_hide_js__WEBPACK_IMPORTED_MODULE_8__["default"]];
  1969. var createPopper = /*#__PURE__*/(0,_createPopper_js__WEBPACK_IMPORTED_MODULE_9__.popperGenerator)({
  1970. defaultModifiers: defaultModifiers
  1971. }); // eslint-disable-next-line import/no-unused-modules
  1972. // eslint-disable-next-line import/no-unused-modules
  1973. // eslint-disable-next-line import/no-unused-modules
  1974. /***/ }),
  1975. /***/ "./node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js":
  1976. /*!***********************************************************************!*\
  1977. !*** ./node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js ***!
  1978. \***********************************************************************/
  1979. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1980. "use strict";
  1981. __webpack_require__.r(__webpack_exports__);
  1982. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1983. /* harmony export */ "default": () => (/* binding */ computeAutoPlacement)
  1984. /* harmony export */ });
  1985. /* harmony import */ var _getVariation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getVariation.js */ "./node_modules/@popperjs/core/lib/utils/getVariation.js");
  1986. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  1987. /* harmony import */ var _detectOverflow_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./detectOverflow.js */ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js");
  1988. /* harmony import */ var _getBasePlacement_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  1989. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  1990. function computeAutoPlacement(state, options) {
  1991. if (options === void 0) {
  1992. options = {};
  1993. }
  1994. var _options = options,
  1995. placement = _options.placement,
  1996. boundary = _options.boundary,
  1997. rootBoundary = _options.rootBoundary,
  1998. padding = _options.padding,
  1999. flipVariations = _options.flipVariations,
  2000. _options$allowedAutoP = _options.allowedAutoPlacements,
  2001. allowedAutoPlacements = _options$allowedAutoP === void 0 ? _enums_js__WEBPACK_IMPORTED_MODULE_0__.placements : _options$allowedAutoP;
  2002. var variation = (0,_getVariation_js__WEBPACK_IMPORTED_MODULE_1__["default"])(placement);
  2003. var placements = variation ? flipVariations ? _enums_js__WEBPACK_IMPORTED_MODULE_0__.variationPlacements : _enums_js__WEBPACK_IMPORTED_MODULE_0__.variationPlacements.filter(function (placement) {
  2004. return (0,_getVariation_js__WEBPACK_IMPORTED_MODULE_1__["default"])(placement) === variation;
  2005. }) : _enums_js__WEBPACK_IMPORTED_MODULE_0__.basePlacements;
  2006. var allowedPlacements = placements.filter(function (placement) {
  2007. return allowedAutoPlacements.indexOf(placement) >= 0;
  2008. });
  2009. if (allowedPlacements.length === 0) {
  2010. allowedPlacements = placements;
  2011. if (true) {
  2012. console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
  2013. }
  2014. } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
  2015. var overflows = allowedPlacements.reduce(function (acc, placement) {
  2016. acc[placement] = (0,_detectOverflow_js__WEBPACK_IMPORTED_MODULE_2__["default"])(state, {
  2017. placement: placement,
  2018. boundary: boundary,
  2019. rootBoundary: rootBoundary,
  2020. padding: padding
  2021. })[(0,_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_3__["default"])(placement)];
  2022. return acc;
  2023. }, {});
  2024. return Object.keys(overflows).sort(function (a, b) {
  2025. return overflows[a] - overflows[b];
  2026. });
  2027. }
  2028. /***/ }),
  2029. /***/ "./node_modules/@popperjs/core/lib/utils/computeOffsets.js":
  2030. /*!*****************************************************************!*\
  2031. !*** ./node_modules/@popperjs/core/lib/utils/computeOffsets.js ***!
  2032. \*****************************************************************/
  2033. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2034. "use strict";
  2035. __webpack_require__.r(__webpack_exports__);
  2036. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2037. /* harmony export */ "default": () => (/* binding */ computeOffsets)
  2038. /* harmony export */ });
  2039. /* harmony import */ var _getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getBasePlacement.js */ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js");
  2040. /* harmony import */ var _getVariation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./getVariation.js */ "./node_modules/@popperjs/core/lib/utils/getVariation.js");
  2041. /* harmony import */ var _getMainAxisFromPlacement_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./getMainAxisFromPlacement.js */ "./node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js");
  2042. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  2043. function computeOffsets(_ref) {
  2044. var reference = _ref.reference,
  2045. element = _ref.element,
  2046. placement = _ref.placement;
  2047. var basePlacement = placement ? (0,_getBasePlacement_js__WEBPACK_IMPORTED_MODULE_0__["default"])(placement) : null;
  2048. var variation = placement ? (0,_getVariation_js__WEBPACK_IMPORTED_MODULE_1__["default"])(placement) : null;
  2049. var commonX = reference.x + reference.width / 2 - element.width / 2;
  2050. var commonY = reference.y + reference.height / 2 - element.height / 2;
  2051. var offsets;
  2052. switch (basePlacement) {
  2053. case _enums_js__WEBPACK_IMPORTED_MODULE_2__.top:
  2054. offsets = {
  2055. x: commonX,
  2056. y: reference.y - element.height
  2057. };
  2058. break;
  2059. case _enums_js__WEBPACK_IMPORTED_MODULE_2__.bottom:
  2060. offsets = {
  2061. x: commonX,
  2062. y: reference.y + reference.height
  2063. };
  2064. break;
  2065. case _enums_js__WEBPACK_IMPORTED_MODULE_2__.right:
  2066. offsets = {
  2067. x: reference.x + reference.width,
  2068. y: commonY
  2069. };
  2070. break;
  2071. case _enums_js__WEBPACK_IMPORTED_MODULE_2__.left:
  2072. offsets = {
  2073. x: reference.x - element.width,
  2074. y: commonY
  2075. };
  2076. break;
  2077. default:
  2078. offsets = {
  2079. x: reference.x,
  2080. y: reference.y
  2081. };
  2082. }
  2083. var mainAxis = basePlacement ? (0,_getMainAxisFromPlacement_js__WEBPACK_IMPORTED_MODULE_3__["default"])(basePlacement) : null;
  2084. if (mainAxis != null) {
  2085. var len = mainAxis === 'y' ? 'height' : 'width';
  2086. switch (variation) {
  2087. case _enums_js__WEBPACK_IMPORTED_MODULE_2__.start:
  2088. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  2089. break;
  2090. case _enums_js__WEBPACK_IMPORTED_MODULE_2__.end:
  2091. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  2092. break;
  2093. default:
  2094. }
  2095. }
  2096. return offsets;
  2097. }
  2098. /***/ }),
  2099. /***/ "./node_modules/@popperjs/core/lib/utils/debounce.js":
  2100. /*!***********************************************************!*\
  2101. !*** ./node_modules/@popperjs/core/lib/utils/debounce.js ***!
  2102. \***********************************************************/
  2103. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2104. "use strict";
  2105. __webpack_require__.r(__webpack_exports__);
  2106. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2107. /* harmony export */ "default": () => (/* binding */ debounce)
  2108. /* harmony export */ });
  2109. function debounce(fn) {
  2110. var pending;
  2111. return function () {
  2112. if (!pending) {
  2113. pending = new Promise(function (resolve) {
  2114. Promise.resolve().then(function () {
  2115. pending = undefined;
  2116. resolve(fn());
  2117. });
  2118. });
  2119. }
  2120. return pending;
  2121. };
  2122. }
  2123. /***/ }),
  2124. /***/ "./node_modules/@popperjs/core/lib/utils/detectOverflow.js":
  2125. /*!*****************************************************************!*\
  2126. !*** ./node_modules/@popperjs/core/lib/utils/detectOverflow.js ***!
  2127. \*****************************************************************/
  2128. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2129. "use strict";
  2130. __webpack_require__.r(__webpack_exports__);
  2131. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2132. /* harmony export */ "default": () => (/* binding */ detectOverflow)
  2133. /* harmony export */ });
  2134. /* harmony import */ var _dom_utils_getClippingRect_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../dom-utils/getClippingRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js");
  2135. /* harmony import */ var _dom_utils_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../dom-utils/getDocumentElement.js */ "./node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js");
  2136. /* harmony import */ var _dom_utils_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../dom-utils/getBoundingClientRect.js */ "./node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js");
  2137. /* harmony import */ var _computeOffsets_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./computeOffsets.js */ "./node_modules/@popperjs/core/lib/utils/computeOffsets.js");
  2138. /* harmony import */ var _rectToClientRect_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./rectToClientRect.js */ "./node_modules/@popperjs/core/lib/utils/rectToClientRect.js");
  2139. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  2140. /* harmony import */ var _dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../dom-utils/instanceOf.js */ "./node_modules/@popperjs/core/lib/dom-utils/instanceOf.js");
  2141. /* harmony import */ var _mergePaddingObject_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mergePaddingObject.js */ "./node_modules/@popperjs/core/lib/utils/mergePaddingObject.js");
  2142. /* harmony import */ var _expandToHashMap_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./expandToHashMap.js */ "./node_modules/@popperjs/core/lib/utils/expandToHashMap.js");
  2143. // eslint-disable-next-line import/no-unused-modules
  2144. function detectOverflow(state, options) {
  2145. if (options === void 0) {
  2146. options = {};
  2147. }
  2148. var _options = options,
  2149. _options$placement = _options.placement,
  2150. placement = _options$placement === void 0 ? state.placement : _options$placement,
  2151. _options$strategy = _options.strategy,
  2152. strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
  2153. _options$boundary = _options.boundary,
  2154. boundary = _options$boundary === void 0 ? _enums_js__WEBPACK_IMPORTED_MODULE_0__.clippingParents : _options$boundary,
  2155. _options$rootBoundary = _options.rootBoundary,
  2156. rootBoundary = _options$rootBoundary === void 0 ? _enums_js__WEBPACK_IMPORTED_MODULE_0__.viewport : _options$rootBoundary,
  2157. _options$elementConte = _options.elementContext,
  2158. elementContext = _options$elementConte === void 0 ? _enums_js__WEBPACK_IMPORTED_MODULE_0__.popper : _options$elementConte,
  2159. _options$altBoundary = _options.altBoundary,
  2160. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  2161. _options$padding = _options.padding,
  2162. padding = _options$padding === void 0 ? 0 : _options$padding;
  2163. var paddingObject = (0,_mergePaddingObject_js__WEBPACK_IMPORTED_MODULE_1__["default"])(typeof padding !== 'number' ? padding : (0,_expandToHashMap_js__WEBPACK_IMPORTED_MODULE_2__["default"])(padding, _enums_js__WEBPACK_IMPORTED_MODULE_0__.basePlacements));
  2164. var altContext = elementContext === _enums_js__WEBPACK_IMPORTED_MODULE_0__.popper ? _enums_js__WEBPACK_IMPORTED_MODULE_0__.reference : _enums_js__WEBPACK_IMPORTED_MODULE_0__.popper;
  2165. var popperRect = state.rects.popper;
  2166. var element = state.elements[altBoundary ? altContext : elementContext];
  2167. var clippingClientRect = (0,_dom_utils_getClippingRect_js__WEBPACK_IMPORTED_MODULE_3__["default"])((0,_dom_utils_instanceOf_js__WEBPACK_IMPORTED_MODULE_4__.isElement)(element) ? element : element.contextElement || (0,_dom_utils_getDocumentElement_js__WEBPACK_IMPORTED_MODULE_5__["default"])(state.elements.popper), boundary, rootBoundary, strategy);
  2168. var referenceClientRect = (0,_dom_utils_getBoundingClientRect_js__WEBPACK_IMPORTED_MODULE_6__["default"])(state.elements.reference);
  2169. var popperOffsets = (0,_computeOffsets_js__WEBPACK_IMPORTED_MODULE_7__["default"])({
  2170. reference: referenceClientRect,
  2171. element: popperRect,
  2172. strategy: 'absolute',
  2173. placement: placement
  2174. });
  2175. var popperClientRect = (0,_rectToClientRect_js__WEBPACK_IMPORTED_MODULE_8__["default"])(Object.assign({}, popperRect, popperOffsets));
  2176. var elementClientRect = elementContext === _enums_js__WEBPACK_IMPORTED_MODULE_0__.popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
  2177. // 0 or negative = within the clipping rect
  2178. var overflowOffsets = {
  2179. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  2180. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  2181. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  2182. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  2183. };
  2184. var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
  2185. if (elementContext === _enums_js__WEBPACK_IMPORTED_MODULE_0__.popper && offsetData) {
  2186. var offset = offsetData[placement];
  2187. Object.keys(overflowOffsets).forEach(function (key) {
  2188. var multiply = [_enums_js__WEBPACK_IMPORTED_MODULE_0__.right, _enums_js__WEBPACK_IMPORTED_MODULE_0__.bottom].indexOf(key) >= 0 ? 1 : -1;
  2189. var axis = [_enums_js__WEBPACK_IMPORTED_MODULE_0__.top, _enums_js__WEBPACK_IMPORTED_MODULE_0__.bottom].indexOf(key) >= 0 ? 'y' : 'x';
  2190. overflowOffsets[key] += offset[axis] * multiply;
  2191. });
  2192. }
  2193. return overflowOffsets;
  2194. }
  2195. /***/ }),
  2196. /***/ "./node_modules/@popperjs/core/lib/utils/expandToHashMap.js":
  2197. /*!******************************************************************!*\
  2198. !*** ./node_modules/@popperjs/core/lib/utils/expandToHashMap.js ***!
  2199. \******************************************************************/
  2200. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2201. "use strict";
  2202. __webpack_require__.r(__webpack_exports__);
  2203. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2204. /* harmony export */ "default": () => (/* binding */ expandToHashMap)
  2205. /* harmony export */ });
  2206. function expandToHashMap(value, keys) {
  2207. return keys.reduce(function (hashMap, key) {
  2208. hashMap[key] = value;
  2209. return hashMap;
  2210. }, {});
  2211. }
  2212. /***/ }),
  2213. /***/ "./node_modules/@popperjs/core/lib/utils/format.js":
  2214. /*!*********************************************************!*\
  2215. !*** ./node_modules/@popperjs/core/lib/utils/format.js ***!
  2216. \*********************************************************/
  2217. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2218. "use strict";
  2219. __webpack_require__.r(__webpack_exports__);
  2220. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2221. /* harmony export */ "default": () => (/* binding */ format)
  2222. /* harmony export */ });
  2223. function format(str) {
  2224. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  2225. args[_key - 1] = arguments[_key];
  2226. }
  2227. return [].concat(args).reduce(function (p, c) {
  2228. return p.replace(/%s/, c);
  2229. }, str);
  2230. }
  2231. /***/ }),
  2232. /***/ "./node_modules/@popperjs/core/lib/utils/getAltAxis.js":
  2233. /*!*************************************************************!*\
  2234. !*** ./node_modules/@popperjs/core/lib/utils/getAltAxis.js ***!
  2235. \*************************************************************/
  2236. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2237. "use strict";
  2238. __webpack_require__.r(__webpack_exports__);
  2239. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2240. /* harmony export */ "default": () => (/* binding */ getAltAxis)
  2241. /* harmony export */ });
  2242. function getAltAxis(axis) {
  2243. return axis === 'x' ? 'y' : 'x';
  2244. }
  2245. /***/ }),
  2246. /***/ "./node_modules/@popperjs/core/lib/utils/getBasePlacement.js":
  2247. /*!*******************************************************************!*\
  2248. !*** ./node_modules/@popperjs/core/lib/utils/getBasePlacement.js ***!
  2249. \*******************************************************************/
  2250. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2251. "use strict";
  2252. __webpack_require__.r(__webpack_exports__);
  2253. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2254. /* harmony export */ "default": () => (/* binding */ getBasePlacement)
  2255. /* harmony export */ });
  2256. function getBasePlacement(placement) {
  2257. return placement.split('-')[0];
  2258. }
  2259. /***/ }),
  2260. /***/ "./node_modules/@popperjs/core/lib/utils/getFreshSideObject.js":
  2261. /*!*********************************************************************!*\
  2262. !*** ./node_modules/@popperjs/core/lib/utils/getFreshSideObject.js ***!
  2263. \*********************************************************************/
  2264. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2265. "use strict";
  2266. __webpack_require__.r(__webpack_exports__);
  2267. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2268. /* harmony export */ "default": () => (/* binding */ getFreshSideObject)
  2269. /* harmony export */ });
  2270. function getFreshSideObject() {
  2271. return {
  2272. top: 0,
  2273. right: 0,
  2274. bottom: 0,
  2275. left: 0
  2276. };
  2277. }
  2278. /***/ }),
  2279. /***/ "./node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js":
  2280. /*!***************************************************************************!*\
  2281. !*** ./node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js ***!
  2282. \***************************************************************************/
  2283. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2284. "use strict";
  2285. __webpack_require__.r(__webpack_exports__);
  2286. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2287. /* harmony export */ "default": () => (/* binding */ getMainAxisFromPlacement)
  2288. /* harmony export */ });
  2289. function getMainAxisFromPlacement(placement) {
  2290. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  2291. }
  2292. /***/ }),
  2293. /***/ "./node_modules/@popperjs/core/lib/utils/getOppositePlacement.js":
  2294. /*!***********************************************************************!*\
  2295. !*** ./node_modules/@popperjs/core/lib/utils/getOppositePlacement.js ***!
  2296. \***********************************************************************/
  2297. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2298. "use strict";
  2299. __webpack_require__.r(__webpack_exports__);
  2300. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2301. /* harmony export */ "default": () => (/* binding */ getOppositePlacement)
  2302. /* harmony export */ });
  2303. var hash = {
  2304. left: 'right',
  2305. right: 'left',
  2306. bottom: 'top',
  2307. top: 'bottom'
  2308. };
  2309. function getOppositePlacement(placement) {
  2310. return placement.replace(/left|right|bottom|top/g, function (matched) {
  2311. return hash[matched];
  2312. });
  2313. }
  2314. /***/ }),
  2315. /***/ "./node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js":
  2316. /*!********************************************************************************!*\
  2317. !*** ./node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js ***!
  2318. \********************************************************************************/
  2319. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2320. "use strict";
  2321. __webpack_require__.r(__webpack_exports__);
  2322. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2323. /* harmony export */ "default": () => (/* binding */ getOppositeVariationPlacement)
  2324. /* harmony export */ });
  2325. var hash = {
  2326. start: 'end',
  2327. end: 'start'
  2328. };
  2329. function getOppositeVariationPlacement(placement) {
  2330. return placement.replace(/start|end/g, function (matched) {
  2331. return hash[matched];
  2332. });
  2333. }
  2334. /***/ }),
  2335. /***/ "./node_modules/@popperjs/core/lib/utils/getVariation.js":
  2336. /*!***************************************************************!*\
  2337. !*** ./node_modules/@popperjs/core/lib/utils/getVariation.js ***!
  2338. \***************************************************************/
  2339. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2340. "use strict";
  2341. __webpack_require__.r(__webpack_exports__);
  2342. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2343. /* harmony export */ "default": () => (/* binding */ getVariation)
  2344. /* harmony export */ });
  2345. function getVariation(placement) {
  2346. return placement.split('-')[1];
  2347. }
  2348. /***/ }),
  2349. /***/ "./node_modules/@popperjs/core/lib/utils/math.js":
  2350. /*!*******************************************************!*\
  2351. !*** ./node_modules/@popperjs/core/lib/utils/math.js ***!
  2352. \*******************************************************/
  2353. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2354. "use strict";
  2355. __webpack_require__.r(__webpack_exports__);
  2356. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2357. /* harmony export */ max: () => (/* binding */ max),
  2358. /* harmony export */ min: () => (/* binding */ min),
  2359. /* harmony export */ round: () => (/* binding */ round)
  2360. /* harmony export */ });
  2361. var max = Math.max;
  2362. var min = Math.min;
  2363. var round = Math.round;
  2364. /***/ }),
  2365. /***/ "./node_modules/@popperjs/core/lib/utils/mergeByName.js":
  2366. /*!**************************************************************!*\
  2367. !*** ./node_modules/@popperjs/core/lib/utils/mergeByName.js ***!
  2368. \**************************************************************/
  2369. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2370. "use strict";
  2371. __webpack_require__.r(__webpack_exports__);
  2372. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2373. /* harmony export */ "default": () => (/* binding */ mergeByName)
  2374. /* harmony export */ });
  2375. function mergeByName(modifiers) {
  2376. var merged = modifiers.reduce(function (merged, current) {
  2377. var existing = merged[current.name];
  2378. merged[current.name] = existing ? Object.assign({}, existing, current, {
  2379. options: Object.assign({}, existing.options, current.options),
  2380. data: Object.assign({}, existing.data, current.data)
  2381. }) : current;
  2382. return merged;
  2383. }, {}); // IE11 does not support Object.values
  2384. return Object.keys(merged).map(function (key) {
  2385. return merged[key];
  2386. });
  2387. }
  2388. /***/ }),
  2389. /***/ "./node_modules/@popperjs/core/lib/utils/mergePaddingObject.js":
  2390. /*!*********************************************************************!*\
  2391. !*** ./node_modules/@popperjs/core/lib/utils/mergePaddingObject.js ***!
  2392. \*********************************************************************/
  2393. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2394. "use strict";
  2395. __webpack_require__.r(__webpack_exports__);
  2396. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2397. /* harmony export */ "default": () => (/* binding */ mergePaddingObject)
  2398. /* harmony export */ });
  2399. /* harmony import */ var _getFreshSideObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getFreshSideObject.js */ "./node_modules/@popperjs/core/lib/utils/getFreshSideObject.js");
  2400. function mergePaddingObject(paddingObject) {
  2401. return Object.assign({}, (0,_getFreshSideObject_js__WEBPACK_IMPORTED_MODULE_0__["default"])(), paddingObject);
  2402. }
  2403. /***/ }),
  2404. /***/ "./node_modules/@popperjs/core/lib/utils/orderModifiers.js":
  2405. /*!*****************************************************************!*\
  2406. !*** ./node_modules/@popperjs/core/lib/utils/orderModifiers.js ***!
  2407. \*****************************************************************/
  2408. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2409. "use strict";
  2410. __webpack_require__.r(__webpack_exports__);
  2411. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2412. /* harmony export */ "default": () => (/* binding */ orderModifiers)
  2413. /* harmony export */ });
  2414. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  2415. // source: https://stackoverflow.com/questions/49875255
  2416. function order(modifiers) {
  2417. var map = new Map();
  2418. var visited = new Set();
  2419. var result = [];
  2420. modifiers.forEach(function (modifier) {
  2421. map.set(modifier.name, modifier);
  2422. }); // On visiting object, check for its dependencies and visit them recursively
  2423. function sort(modifier) {
  2424. visited.add(modifier.name);
  2425. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  2426. requires.forEach(function (dep) {
  2427. if (!visited.has(dep)) {
  2428. var depModifier = map.get(dep);
  2429. if (depModifier) {
  2430. sort(depModifier);
  2431. }
  2432. }
  2433. });
  2434. result.push(modifier);
  2435. }
  2436. modifiers.forEach(function (modifier) {
  2437. if (!visited.has(modifier.name)) {
  2438. // check for visited object
  2439. sort(modifier);
  2440. }
  2441. });
  2442. return result;
  2443. }
  2444. function orderModifiers(modifiers) {
  2445. // order based on dependencies
  2446. var orderedModifiers = order(modifiers); // order based on phase
  2447. return _enums_js__WEBPACK_IMPORTED_MODULE_0__.modifierPhases.reduce(function (acc, phase) {
  2448. return acc.concat(orderedModifiers.filter(function (modifier) {
  2449. return modifier.phase === phase;
  2450. }));
  2451. }, []);
  2452. }
  2453. /***/ }),
  2454. /***/ "./node_modules/@popperjs/core/lib/utils/rectToClientRect.js":
  2455. /*!*******************************************************************!*\
  2456. !*** ./node_modules/@popperjs/core/lib/utils/rectToClientRect.js ***!
  2457. \*******************************************************************/
  2458. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2459. "use strict";
  2460. __webpack_require__.r(__webpack_exports__);
  2461. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2462. /* harmony export */ "default": () => (/* binding */ rectToClientRect)
  2463. /* harmony export */ });
  2464. function rectToClientRect(rect) {
  2465. return Object.assign({}, rect, {
  2466. left: rect.x,
  2467. top: rect.y,
  2468. right: rect.x + rect.width,
  2469. bottom: rect.y + rect.height
  2470. });
  2471. }
  2472. /***/ }),
  2473. /***/ "./node_modules/@popperjs/core/lib/utils/uniqueBy.js":
  2474. /*!***********************************************************!*\
  2475. !*** ./node_modules/@popperjs/core/lib/utils/uniqueBy.js ***!
  2476. \***********************************************************/
  2477. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2478. "use strict";
  2479. __webpack_require__.r(__webpack_exports__);
  2480. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2481. /* harmony export */ "default": () => (/* binding */ uniqueBy)
  2482. /* harmony export */ });
  2483. function uniqueBy(arr, fn) {
  2484. var identifiers = new Set();
  2485. return arr.filter(function (item) {
  2486. var identifier = fn(item);
  2487. if (!identifiers.has(identifier)) {
  2488. identifiers.add(identifier);
  2489. return true;
  2490. }
  2491. });
  2492. }
  2493. /***/ }),
  2494. /***/ "./node_modules/@popperjs/core/lib/utils/userAgent.js":
  2495. /*!************************************************************!*\
  2496. !*** ./node_modules/@popperjs/core/lib/utils/userAgent.js ***!
  2497. \************************************************************/
  2498. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2499. "use strict";
  2500. __webpack_require__.r(__webpack_exports__);
  2501. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2502. /* harmony export */ "default": () => (/* binding */ getUAString)
  2503. /* harmony export */ });
  2504. function getUAString() {
  2505. var uaData = navigator.userAgentData;
  2506. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  2507. return uaData.brands.map(function (item) {
  2508. return item.brand + "/" + item.version;
  2509. }).join(' ');
  2510. }
  2511. return navigator.userAgent;
  2512. }
  2513. /***/ }),
  2514. /***/ "./node_modules/@popperjs/core/lib/utils/validateModifiers.js":
  2515. /*!********************************************************************!*\
  2516. !*** ./node_modules/@popperjs/core/lib/utils/validateModifiers.js ***!
  2517. \********************************************************************/
  2518. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2519. "use strict";
  2520. __webpack_require__.r(__webpack_exports__);
  2521. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2522. /* harmony export */ "default": () => (/* binding */ validateModifiers)
  2523. /* harmony export */ });
  2524. /* harmony import */ var _format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./format.js */ "./node_modules/@popperjs/core/lib/utils/format.js");
  2525. /* harmony import */ var _enums_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../enums.js */ "./node_modules/@popperjs/core/lib/enums.js");
  2526. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  2527. var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
  2528. var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
  2529. var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
  2530. function validateModifiers(modifiers) {
  2531. modifiers.forEach(function (modifier) {
  2532. [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
  2533. .filter(function (value, index, self) {
  2534. return self.indexOf(value) === index;
  2535. }).forEach(function (key) {
  2536. switch (key) {
  2537. case 'name':
  2538. if (typeof modifier.name !== 'string') {
  2539. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
  2540. }
  2541. break;
  2542. case 'enabled':
  2543. if (typeof modifier.enabled !== 'boolean') {
  2544. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
  2545. }
  2546. break;
  2547. case 'phase':
  2548. if (_enums_js__WEBPACK_IMPORTED_MODULE_1__.modifierPhases.indexOf(modifier.phase) < 0) {
  2549. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + _enums_js__WEBPACK_IMPORTED_MODULE_1__.modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
  2550. }
  2551. break;
  2552. case 'fn':
  2553. if (typeof modifier.fn !== 'function') {
  2554. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
  2555. }
  2556. break;
  2557. case 'effect':
  2558. if (modifier.effect != null && typeof modifier.effect !== 'function') {
  2559. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
  2560. }
  2561. break;
  2562. case 'requires':
  2563. if (modifier.requires != null && !Array.isArray(modifier.requires)) {
  2564. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
  2565. }
  2566. break;
  2567. case 'requiresIfExists':
  2568. if (!Array.isArray(modifier.requiresIfExists)) {
  2569. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
  2570. }
  2571. break;
  2572. case 'options':
  2573. case 'data':
  2574. break;
  2575. default:
  2576. console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
  2577. return "\"" + s + "\"";
  2578. }).join(', ') + "; but \"" + key + "\" was provided.");
  2579. }
  2580. modifier.requires && modifier.requires.forEach(function (requirement) {
  2581. if (modifiers.find(function (mod) {
  2582. return mod.name === requirement;
  2583. }) == null) {
  2584. console.error((0,_format_js__WEBPACK_IMPORTED_MODULE_0__["default"])(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
  2585. }
  2586. });
  2587. });
  2588. });
  2589. }
  2590. /***/ }),
  2591. /***/ "./node_modules/@popperjs/core/lib/utils/within.js":
  2592. /*!*********************************************************!*\
  2593. !*** ./node_modules/@popperjs/core/lib/utils/within.js ***!
  2594. \*********************************************************/
  2595. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2596. "use strict";
  2597. __webpack_require__.r(__webpack_exports__);
  2598. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2599. /* harmony export */ within: () => (/* binding */ within),
  2600. /* harmony export */ withinMaxClamp: () => (/* binding */ withinMaxClamp)
  2601. /* harmony export */ });
  2602. /* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.js */ "./node_modules/@popperjs/core/lib/utils/math.js");
  2603. function within(min, value, max) {
  2604. return (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.max)(min, (0,_math_js__WEBPACK_IMPORTED_MODULE_0__.min)(value, max));
  2605. }
  2606. function withinMaxClamp(min, value, max) {
  2607. var v = within(min, value, max);
  2608. return v > max ? max : v;
  2609. }
  2610. /***/ }),
  2611. /***/ "./node_modules/asn1.js/lib/asn1.js":
  2612. /*!******************************************!*\
  2613. !*** ./node_modules/asn1.js/lib/asn1.js ***!
  2614. \******************************************/
  2615. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2616. "use strict";
  2617. const asn1 = exports;
  2618. asn1.bignum = __webpack_require__(/*! bn.js */ "./node_modules/asn1.js/node_modules/bn.js/lib/bn.js");
  2619. asn1.define = (__webpack_require__(/*! ./asn1/api */ "./node_modules/asn1.js/lib/asn1/api.js").define);
  2620. asn1.base = __webpack_require__(/*! ./asn1/base */ "./node_modules/asn1.js/lib/asn1/base/index.js");
  2621. asn1.constants = __webpack_require__(/*! ./asn1/constants */ "./node_modules/asn1.js/lib/asn1/constants/index.js");
  2622. asn1.decoders = __webpack_require__(/*! ./asn1/decoders */ "./node_modules/asn1.js/lib/asn1/decoders/index.js");
  2623. asn1.encoders = __webpack_require__(/*! ./asn1/encoders */ "./node_modules/asn1.js/lib/asn1/encoders/index.js");
  2624. /***/ }),
  2625. /***/ "./node_modules/asn1.js/lib/asn1/api.js":
  2626. /*!**********************************************!*\
  2627. !*** ./node_modules/asn1.js/lib/asn1/api.js ***!
  2628. \**********************************************/
  2629. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2630. "use strict";
  2631. const encoders = __webpack_require__(/*! ./encoders */ "./node_modules/asn1.js/lib/asn1/encoders/index.js");
  2632. const decoders = __webpack_require__(/*! ./decoders */ "./node_modules/asn1.js/lib/asn1/decoders/index.js");
  2633. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  2634. const api = exports;
  2635. api.define = function define(name, body) {
  2636. return new Entity(name, body);
  2637. };
  2638. function Entity(name, body) {
  2639. this.name = name;
  2640. this.body = body;
  2641. this.decoders = {};
  2642. this.encoders = {};
  2643. }
  2644. Entity.prototype._createNamed = function createNamed(Base) {
  2645. const name = this.name;
  2646. function Generated(entity) {
  2647. this._initNamed(entity, name);
  2648. }
  2649. inherits(Generated, Base);
  2650. Generated.prototype._initNamed = function _initNamed(entity, name) {
  2651. Base.call(this, entity, name);
  2652. };
  2653. return new Generated(this);
  2654. };
  2655. Entity.prototype._getDecoder = function _getDecoder(enc) {
  2656. enc = enc || 'der';
  2657. // Lazily create decoder
  2658. if (!this.decoders.hasOwnProperty(enc))
  2659. this.decoders[enc] = this._createNamed(decoders[enc]);
  2660. return this.decoders[enc];
  2661. };
  2662. Entity.prototype.decode = function decode(data, enc, options) {
  2663. return this._getDecoder(enc).decode(data, options);
  2664. };
  2665. Entity.prototype._getEncoder = function _getEncoder(enc) {
  2666. enc = enc || 'der';
  2667. // Lazily create encoder
  2668. if (!this.encoders.hasOwnProperty(enc))
  2669. this.encoders[enc] = this._createNamed(encoders[enc]);
  2670. return this.encoders[enc];
  2671. };
  2672. Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
  2673. return this._getEncoder(enc).encode(data, reporter);
  2674. };
  2675. /***/ }),
  2676. /***/ "./node_modules/asn1.js/lib/asn1/base/buffer.js":
  2677. /*!******************************************************!*\
  2678. !*** ./node_modules/asn1.js/lib/asn1/base/buffer.js ***!
  2679. \******************************************************/
  2680. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2681. "use strict";
  2682. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  2683. const Reporter = (__webpack_require__(/*! ../base/reporter */ "./node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter);
  2684. const Buffer = (__webpack_require__(/*! safer-buffer */ "./node_modules/safer-buffer/safer.js").Buffer);
  2685. function DecoderBuffer(base, options) {
  2686. Reporter.call(this, options);
  2687. if (!Buffer.isBuffer(base)) {
  2688. this.error('Input not Buffer');
  2689. return;
  2690. }
  2691. this.base = base;
  2692. this.offset = 0;
  2693. this.length = base.length;
  2694. }
  2695. inherits(DecoderBuffer, Reporter);
  2696. exports.DecoderBuffer = DecoderBuffer;
  2697. DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {
  2698. if (data instanceof DecoderBuffer) {
  2699. return true;
  2700. }
  2701. // Or accept compatible API
  2702. const isCompatible = typeof data === 'object' &&
  2703. Buffer.isBuffer(data.base) &&
  2704. data.constructor.name === 'DecoderBuffer' &&
  2705. typeof data.offset === 'number' &&
  2706. typeof data.length === 'number' &&
  2707. typeof data.save === 'function' &&
  2708. typeof data.restore === 'function' &&
  2709. typeof data.isEmpty === 'function' &&
  2710. typeof data.readUInt8 === 'function' &&
  2711. typeof data.skip === 'function' &&
  2712. typeof data.raw === 'function';
  2713. return isCompatible;
  2714. };
  2715. DecoderBuffer.prototype.save = function save() {
  2716. return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
  2717. };
  2718. DecoderBuffer.prototype.restore = function restore(save) {
  2719. // Return skipped data
  2720. const res = new DecoderBuffer(this.base);
  2721. res.offset = save.offset;
  2722. res.length = this.offset;
  2723. this.offset = save.offset;
  2724. Reporter.prototype.restore.call(this, save.reporter);
  2725. return res;
  2726. };
  2727. DecoderBuffer.prototype.isEmpty = function isEmpty() {
  2728. return this.offset === this.length;
  2729. };
  2730. DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
  2731. if (this.offset + 1 <= this.length)
  2732. return this.base.readUInt8(this.offset++, true);
  2733. else
  2734. return this.error(fail || 'DecoderBuffer overrun');
  2735. };
  2736. DecoderBuffer.prototype.skip = function skip(bytes, fail) {
  2737. if (!(this.offset + bytes <= this.length))
  2738. return this.error(fail || 'DecoderBuffer overrun');
  2739. const res = new DecoderBuffer(this.base);
  2740. // Share reporter state
  2741. res._reporterState = this._reporterState;
  2742. res.offset = this.offset;
  2743. res.length = this.offset + bytes;
  2744. this.offset += bytes;
  2745. return res;
  2746. };
  2747. DecoderBuffer.prototype.raw = function raw(save) {
  2748. return this.base.slice(save ? save.offset : this.offset, this.length);
  2749. };
  2750. function EncoderBuffer(value, reporter) {
  2751. if (Array.isArray(value)) {
  2752. this.length = 0;
  2753. this.value = value.map(function(item) {
  2754. if (!EncoderBuffer.isEncoderBuffer(item))
  2755. item = new EncoderBuffer(item, reporter);
  2756. this.length += item.length;
  2757. return item;
  2758. }, this);
  2759. } else if (typeof value === 'number') {
  2760. if (!(0 <= value && value <= 0xff))
  2761. return reporter.error('non-byte EncoderBuffer value');
  2762. this.value = value;
  2763. this.length = 1;
  2764. } else if (typeof value === 'string') {
  2765. this.value = value;
  2766. this.length = Buffer.byteLength(value);
  2767. } else if (Buffer.isBuffer(value)) {
  2768. this.value = value;
  2769. this.length = value.length;
  2770. } else {
  2771. return reporter.error('Unsupported type: ' + typeof value);
  2772. }
  2773. }
  2774. exports.EncoderBuffer = EncoderBuffer;
  2775. EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {
  2776. if (data instanceof EncoderBuffer) {
  2777. return true;
  2778. }
  2779. // Or accept compatible API
  2780. const isCompatible = typeof data === 'object' &&
  2781. data.constructor.name === 'EncoderBuffer' &&
  2782. typeof data.length === 'number' &&
  2783. typeof data.join === 'function';
  2784. return isCompatible;
  2785. };
  2786. EncoderBuffer.prototype.join = function join(out, offset) {
  2787. if (!out)
  2788. out = Buffer.alloc(this.length);
  2789. if (!offset)
  2790. offset = 0;
  2791. if (this.length === 0)
  2792. return out;
  2793. if (Array.isArray(this.value)) {
  2794. this.value.forEach(function(item) {
  2795. item.join(out, offset);
  2796. offset += item.length;
  2797. });
  2798. } else {
  2799. if (typeof this.value === 'number')
  2800. out[offset] = this.value;
  2801. else if (typeof this.value === 'string')
  2802. out.write(this.value, offset);
  2803. else if (Buffer.isBuffer(this.value))
  2804. this.value.copy(out, offset);
  2805. offset += this.length;
  2806. }
  2807. return out;
  2808. };
  2809. /***/ }),
  2810. /***/ "./node_modules/asn1.js/lib/asn1/base/index.js":
  2811. /*!*****************************************************!*\
  2812. !*** ./node_modules/asn1.js/lib/asn1/base/index.js ***!
  2813. \*****************************************************/
  2814. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2815. "use strict";
  2816. const base = exports;
  2817. base.Reporter = (__webpack_require__(/*! ./reporter */ "./node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter);
  2818. base.DecoderBuffer = (__webpack_require__(/*! ./buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer);
  2819. base.EncoderBuffer = (__webpack_require__(/*! ./buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").EncoderBuffer);
  2820. base.Node = __webpack_require__(/*! ./node */ "./node_modules/asn1.js/lib/asn1/base/node.js");
  2821. /***/ }),
  2822. /***/ "./node_modules/asn1.js/lib/asn1/base/node.js":
  2823. /*!****************************************************!*\
  2824. !*** ./node_modules/asn1.js/lib/asn1/base/node.js ***!
  2825. \****************************************************/
  2826. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2827. "use strict";
  2828. const Reporter = (__webpack_require__(/*! ../base/reporter */ "./node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter);
  2829. const EncoderBuffer = (__webpack_require__(/*! ../base/buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").EncoderBuffer);
  2830. const DecoderBuffer = (__webpack_require__(/*! ../base/buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer);
  2831. const assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  2832. // Supported tags
  2833. const tags = [
  2834. 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
  2835. 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
  2836. 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
  2837. 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
  2838. ];
  2839. // Public methods list
  2840. const methods = [
  2841. 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
  2842. 'any', 'contains'
  2843. ].concat(tags);
  2844. // Overrided methods list
  2845. const overrided = [
  2846. '_peekTag', '_decodeTag', '_use',
  2847. '_decodeStr', '_decodeObjid', '_decodeTime',
  2848. '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
  2849. '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
  2850. '_encodeNull', '_encodeInt', '_encodeBool'
  2851. ];
  2852. function Node(enc, parent, name) {
  2853. const state = {};
  2854. this._baseState = state;
  2855. state.name = name;
  2856. state.enc = enc;
  2857. state.parent = parent || null;
  2858. state.children = null;
  2859. // State
  2860. state.tag = null;
  2861. state.args = null;
  2862. state.reverseArgs = null;
  2863. state.choice = null;
  2864. state.optional = false;
  2865. state.any = false;
  2866. state.obj = false;
  2867. state.use = null;
  2868. state.useDecoder = null;
  2869. state.key = null;
  2870. state['default'] = null;
  2871. state.explicit = null;
  2872. state.implicit = null;
  2873. state.contains = null;
  2874. // Should create new instance on each method
  2875. if (!state.parent) {
  2876. state.children = [];
  2877. this._wrap();
  2878. }
  2879. }
  2880. module.exports = Node;
  2881. const stateProps = [
  2882. 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
  2883. 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
  2884. 'implicit', 'contains'
  2885. ];
  2886. Node.prototype.clone = function clone() {
  2887. const state = this._baseState;
  2888. const cstate = {};
  2889. stateProps.forEach(function(prop) {
  2890. cstate[prop] = state[prop];
  2891. });
  2892. const res = new this.constructor(cstate.parent);
  2893. res._baseState = cstate;
  2894. return res;
  2895. };
  2896. Node.prototype._wrap = function wrap() {
  2897. const state = this._baseState;
  2898. methods.forEach(function(method) {
  2899. this[method] = function _wrappedMethod() {
  2900. const clone = new this.constructor(this);
  2901. state.children.push(clone);
  2902. return clone[method].apply(clone, arguments);
  2903. };
  2904. }, this);
  2905. };
  2906. Node.prototype._init = function init(body) {
  2907. const state = this._baseState;
  2908. assert(state.parent === null);
  2909. body.call(this);
  2910. // Filter children
  2911. state.children = state.children.filter(function(child) {
  2912. return child._baseState.parent === this;
  2913. }, this);
  2914. assert.equal(state.children.length, 1, 'Root node can have only one child');
  2915. };
  2916. Node.prototype._useArgs = function useArgs(args) {
  2917. const state = this._baseState;
  2918. // Filter children and args
  2919. const children = args.filter(function(arg) {
  2920. return arg instanceof this.constructor;
  2921. }, this);
  2922. args = args.filter(function(arg) {
  2923. return !(arg instanceof this.constructor);
  2924. }, this);
  2925. if (children.length !== 0) {
  2926. assert(state.children === null);
  2927. state.children = children;
  2928. // Replace parent to maintain backward link
  2929. children.forEach(function(child) {
  2930. child._baseState.parent = this;
  2931. }, this);
  2932. }
  2933. if (args.length !== 0) {
  2934. assert(state.args === null);
  2935. state.args = args;
  2936. state.reverseArgs = args.map(function(arg) {
  2937. if (typeof arg !== 'object' || arg.constructor !== Object)
  2938. return arg;
  2939. const res = {};
  2940. Object.keys(arg).forEach(function(key) {
  2941. if (key == (key | 0))
  2942. key |= 0;
  2943. const value = arg[key];
  2944. res[value] = key;
  2945. });
  2946. return res;
  2947. });
  2948. }
  2949. };
  2950. //
  2951. // Overrided methods
  2952. //
  2953. overrided.forEach(function(method) {
  2954. Node.prototype[method] = function _overrided() {
  2955. const state = this._baseState;
  2956. throw new Error(method + ' not implemented for encoding: ' + state.enc);
  2957. };
  2958. });
  2959. //
  2960. // Public methods
  2961. //
  2962. tags.forEach(function(tag) {
  2963. Node.prototype[tag] = function _tagMethod() {
  2964. const state = this._baseState;
  2965. const args = Array.prototype.slice.call(arguments);
  2966. assert(state.tag === null);
  2967. state.tag = tag;
  2968. this._useArgs(args);
  2969. return this;
  2970. };
  2971. });
  2972. Node.prototype.use = function use(item) {
  2973. assert(item);
  2974. const state = this._baseState;
  2975. assert(state.use === null);
  2976. state.use = item;
  2977. return this;
  2978. };
  2979. Node.prototype.optional = function optional() {
  2980. const state = this._baseState;
  2981. state.optional = true;
  2982. return this;
  2983. };
  2984. Node.prototype.def = function def(val) {
  2985. const state = this._baseState;
  2986. assert(state['default'] === null);
  2987. state['default'] = val;
  2988. state.optional = true;
  2989. return this;
  2990. };
  2991. Node.prototype.explicit = function explicit(num) {
  2992. const state = this._baseState;
  2993. assert(state.explicit === null && state.implicit === null);
  2994. state.explicit = num;
  2995. return this;
  2996. };
  2997. Node.prototype.implicit = function implicit(num) {
  2998. const state = this._baseState;
  2999. assert(state.explicit === null && state.implicit === null);
  3000. state.implicit = num;
  3001. return this;
  3002. };
  3003. Node.prototype.obj = function obj() {
  3004. const state = this._baseState;
  3005. const args = Array.prototype.slice.call(arguments);
  3006. state.obj = true;
  3007. if (args.length !== 0)
  3008. this._useArgs(args);
  3009. return this;
  3010. };
  3011. Node.prototype.key = function key(newKey) {
  3012. const state = this._baseState;
  3013. assert(state.key === null);
  3014. state.key = newKey;
  3015. return this;
  3016. };
  3017. Node.prototype.any = function any() {
  3018. const state = this._baseState;
  3019. state.any = true;
  3020. return this;
  3021. };
  3022. Node.prototype.choice = function choice(obj) {
  3023. const state = this._baseState;
  3024. assert(state.choice === null);
  3025. state.choice = obj;
  3026. this._useArgs(Object.keys(obj).map(function(key) {
  3027. return obj[key];
  3028. }));
  3029. return this;
  3030. };
  3031. Node.prototype.contains = function contains(item) {
  3032. const state = this._baseState;
  3033. assert(state.use === null);
  3034. state.contains = item;
  3035. return this;
  3036. };
  3037. //
  3038. // Decoding
  3039. //
  3040. Node.prototype._decode = function decode(input, options) {
  3041. const state = this._baseState;
  3042. // Decode root node
  3043. if (state.parent === null)
  3044. return input.wrapResult(state.children[0]._decode(input, options));
  3045. let result = state['default'];
  3046. let present = true;
  3047. let prevKey = null;
  3048. if (state.key !== null)
  3049. prevKey = input.enterKey(state.key);
  3050. // Check if tag is there
  3051. if (state.optional) {
  3052. let tag = null;
  3053. if (state.explicit !== null)
  3054. tag = state.explicit;
  3055. else if (state.implicit !== null)
  3056. tag = state.implicit;
  3057. else if (state.tag !== null)
  3058. tag = state.tag;
  3059. if (tag === null && !state.any) {
  3060. // Trial and Error
  3061. const save = input.save();
  3062. try {
  3063. if (state.choice === null)
  3064. this._decodeGeneric(state.tag, input, options);
  3065. else
  3066. this._decodeChoice(input, options);
  3067. present = true;
  3068. } catch (e) {
  3069. present = false;
  3070. }
  3071. input.restore(save);
  3072. } else {
  3073. present = this._peekTag(input, tag, state.any);
  3074. if (input.isError(present))
  3075. return present;
  3076. }
  3077. }
  3078. // Push object on stack
  3079. let prevObj;
  3080. if (state.obj && present)
  3081. prevObj = input.enterObject();
  3082. if (present) {
  3083. // Unwrap explicit values
  3084. if (state.explicit !== null) {
  3085. const explicit = this._decodeTag(input, state.explicit);
  3086. if (input.isError(explicit))
  3087. return explicit;
  3088. input = explicit;
  3089. }
  3090. const start = input.offset;
  3091. // Unwrap implicit and normal values
  3092. if (state.use === null && state.choice === null) {
  3093. let save;
  3094. if (state.any)
  3095. save = input.save();
  3096. const body = this._decodeTag(
  3097. input,
  3098. state.implicit !== null ? state.implicit : state.tag,
  3099. state.any
  3100. );
  3101. if (input.isError(body))
  3102. return body;
  3103. if (state.any)
  3104. result = input.raw(save);
  3105. else
  3106. input = body;
  3107. }
  3108. if (options && options.track && state.tag !== null)
  3109. options.track(input.path(), start, input.length, 'tagged');
  3110. if (options && options.track && state.tag !== null)
  3111. options.track(input.path(), input.offset, input.length, 'content');
  3112. // Select proper method for tag
  3113. if (state.any) {
  3114. // no-op
  3115. } else if (state.choice === null) {
  3116. result = this._decodeGeneric(state.tag, input, options);
  3117. } else {
  3118. result = this._decodeChoice(input, options);
  3119. }
  3120. if (input.isError(result))
  3121. return result;
  3122. // Decode children
  3123. if (!state.any && state.choice === null && state.children !== null) {
  3124. state.children.forEach(function decodeChildren(child) {
  3125. // NOTE: We are ignoring errors here, to let parser continue with other
  3126. // parts of encoded data
  3127. child._decode(input, options);
  3128. });
  3129. }
  3130. // Decode contained/encoded by schema, only in bit or octet strings
  3131. if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
  3132. const data = new DecoderBuffer(result);
  3133. result = this._getUse(state.contains, input._reporterState.obj)
  3134. ._decode(data, options);
  3135. }
  3136. }
  3137. // Pop object
  3138. if (state.obj && present)
  3139. result = input.leaveObject(prevObj);
  3140. // Set key
  3141. if (state.key !== null && (result !== null || present === true))
  3142. input.leaveKey(prevKey, state.key, result);
  3143. else if (prevKey !== null)
  3144. input.exitKey(prevKey);
  3145. return result;
  3146. };
  3147. Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
  3148. const state = this._baseState;
  3149. if (tag === 'seq' || tag === 'set')
  3150. return null;
  3151. if (tag === 'seqof' || tag === 'setof')
  3152. return this._decodeList(input, tag, state.args[0], options);
  3153. else if (/str$/.test(tag))
  3154. return this._decodeStr(input, tag, options);
  3155. else if (tag === 'objid' && state.args)
  3156. return this._decodeObjid(input, state.args[0], state.args[1], options);
  3157. else if (tag === 'objid')
  3158. return this._decodeObjid(input, null, null, options);
  3159. else if (tag === 'gentime' || tag === 'utctime')
  3160. return this._decodeTime(input, tag, options);
  3161. else if (tag === 'null_')
  3162. return this._decodeNull(input, options);
  3163. else if (tag === 'bool')
  3164. return this._decodeBool(input, options);
  3165. else if (tag === 'objDesc')
  3166. return this._decodeStr(input, tag, options);
  3167. else if (tag === 'int' || tag === 'enum')
  3168. return this._decodeInt(input, state.args && state.args[0], options);
  3169. if (state.use !== null) {
  3170. return this._getUse(state.use, input._reporterState.obj)
  3171. ._decode(input, options);
  3172. } else {
  3173. return input.error('unknown tag: ' + tag);
  3174. }
  3175. };
  3176. Node.prototype._getUse = function _getUse(entity, obj) {
  3177. const state = this._baseState;
  3178. // Create altered use decoder if implicit is set
  3179. state.useDecoder = this._use(entity, obj);
  3180. assert(state.useDecoder._baseState.parent === null);
  3181. state.useDecoder = state.useDecoder._baseState.children[0];
  3182. if (state.implicit !== state.useDecoder._baseState.implicit) {
  3183. state.useDecoder = state.useDecoder.clone();
  3184. state.useDecoder._baseState.implicit = state.implicit;
  3185. }
  3186. return state.useDecoder;
  3187. };
  3188. Node.prototype._decodeChoice = function decodeChoice(input, options) {
  3189. const state = this._baseState;
  3190. let result = null;
  3191. let match = false;
  3192. Object.keys(state.choice).some(function(key) {
  3193. const save = input.save();
  3194. const node = state.choice[key];
  3195. try {
  3196. const value = node._decode(input, options);
  3197. if (input.isError(value))
  3198. return false;
  3199. result = { type: key, value: value };
  3200. match = true;
  3201. } catch (e) {
  3202. input.restore(save);
  3203. return false;
  3204. }
  3205. return true;
  3206. }, this);
  3207. if (!match)
  3208. return input.error('Choice not matched');
  3209. return result;
  3210. };
  3211. //
  3212. // Encoding
  3213. //
  3214. Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
  3215. return new EncoderBuffer(data, this.reporter);
  3216. };
  3217. Node.prototype._encode = function encode(data, reporter, parent) {
  3218. const state = this._baseState;
  3219. if (state['default'] !== null && state['default'] === data)
  3220. return;
  3221. const result = this._encodeValue(data, reporter, parent);
  3222. if (result === undefined)
  3223. return;
  3224. if (this._skipDefault(result, reporter, parent))
  3225. return;
  3226. return result;
  3227. };
  3228. Node.prototype._encodeValue = function encode(data, reporter, parent) {
  3229. const state = this._baseState;
  3230. // Decode root node
  3231. if (state.parent === null)
  3232. return state.children[0]._encode(data, reporter || new Reporter());
  3233. let result = null;
  3234. // Set reporter to share it with a child class
  3235. this.reporter = reporter;
  3236. // Check if data is there
  3237. if (state.optional && data === undefined) {
  3238. if (state['default'] !== null)
  3239. data = state['default'];
  3240. else
  3241. return;
  3242. }
  3243. // Encode children first
  3244. let content = null;
  3245. let primitive = false;
  3246. if (state.any) {
  3247. // Anything that was given is translated to buffer
  3248. result = this._createEncoderBuffer(data);
  3249. } else if (state.choice) {
  3250. result = this._encodeChoice(data, reporter);
  3251. } else if (state.contains) {
  3252. content = this._getUse(state.contains, parent)._encode(data, reporter);
  3253. primitive = true;
  3254. } else if (state.children) {
  3255. content = state.children.map(function(child) {
  3256. if (child._baseState.tag === 'null_')
  3257. return child._encode(null, reporter, data);
  3258. if (child._baseState.key === null)
  3259. return reporter.error('Child should have a key');
  3260. const prevKey = reporter.enterKey(child._baseState.key);
  3261. if (typeof data !== 'object')
  3262. return reporter.error('Child expected, but input is not object');
  3263. const res = child._encode(data[child._baseState.key], reporter, data);
  3264. reporter.leaveKey(prevKey);
  3265. return res;
  3266. }, this).filter(function(child) {
  3267. return child;
  3268. });
  3269. content = this._createEncoderBuffer(content);
  3270. } else {
  3271. if (state.tag === 'seqof' || state.tag === 'setof') {
  3272. // TODO(indutny): this should be thrown on DSL level
  3273. if (!(state.args && state.args.length === 1))
  3274. return reporter.error('Too many args for : ' + state.tag);
  3275. if (!Array.isArray(data))
  3276. return reporter.error('seqof/setof, but data is not Array');
  3277. const child = this.clone();
  3278. child._baseState.implicit = null;
  3279. content = this._createEncoderBuffer(data.map(function(item) {
  3280. const state = this._baseState;
  3281. return this._getUse(state.args[0], data)._encode(item, reporter);
  3282. }, child));
  3283. } else if (state.use !== null) {
  3284. result = this._getUse(state.use, parent)._encode(data, reporter);
  3285. } else {
  3286. content = this._encodePrimitive(state.tag, data);
  3287. primitive = true;
  3288. }
  3289. }
  3290. // Encode data itself
  3291. if (!state.any && state.choice === null) {
  3292. const tag = state.implicit !== null ? state.implicit : state.tag;
  3293. const cls = state.implicit === null ? 'universal' : 'context';
  3294. if (tag === null) {
  3295. if (state.use === null)
  3296. reporter.error('Tag could be omitted only for .use()');
  3297. } else {
  3298. if (state.use === null)
  3299. result = this._encodeComposite(tag, primitive, cls, content);
  3300. }
  3301. }
  3302. // Wrap in explicit
  3303. if (state.explicit !== null)
  3304. result = this._encodeComposite(state.explicit, false, 'context', result);
  3305. return result;
  3306. };
  3307. Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
  3308. const state = this._baseState;
  3309. const node = state.choice[data.type];
  3310. if (!node) {
  3311. assert(
  3312. false,
  3313. data.type + ' not found in ' +
  3314. JSON.stringify(Object.keys(state.choice)));
  3315. }
  3316. return node._encode(data.value, reporter);
  3317. };
  3318. Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
  3319. const state = this._baseState;
  3320. if (/str$/.test(tag))
  3321. return this._encodeStr(data, tag);
  3322. else if (tag === 'objid' && state.args)
  3323. return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
  3324. else if (tag === 'objid')
  3325. return this._encodeObjid(data, null, null);
  3326. else if (tag === 'gentime' || tag === 'utctime')
  3327. return this._encodeTime(data, tag);
  3328. else if (tag === 'null_')
  3329. return this._encodeNull();
  3330. else if (tag === 'int' || tag === 'enum')
  3331. return this._encodeInt(data, state.args && state.reverseArgs[0]);
  3332. else if (tag === 'bool')
  3333. return this._encodeBool(data);
  3334. else if (tag === 'objDesc')
  3335. return this._encodeStr(data, tag);
  3336. else
  3337. throw new Error('Unsupported tag: ' + tag);
  3338. };
  3339. Node.prototype._isNumstr = function isNumstr(str) {
  3340. return /^[0-9 ]*$/.test(str);
  3341. };
  3342. Node.prototype._isPrintstr = function isPrintstr(str) {
  3343. return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);
  3344. };
  3345. /***/ }),
  3346. /***/ "./node_modules/asn1.js/lib/asn1/base/reporter.js":
  3347. /*!********************************************************!*\
  3348. !*** ./node_modules/asn1.js/lib/asn1/base/reporter.js ***!
  3349. \********************************************************/
  3350. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3351. "use strict";
  3352. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  3353. function Reporter(options) {
  3354. this._reporterState = {
  3355. obj: null,
  3356. path: [],
  3357. options: options || {},
  3358. errors: []
  3359. };
  3360. }
  3361. exports.Reporter = Reporter;
  3362. Reporter.prototype.isError = function isError(obj) {
  3363. return obj instanceof ReporterError;
  3364. };
  3365. Reporter.prototype.save = function save() {
  3366. const state = this._reporterState;
  3367. return { obj: state.obj, pathLen: state.path.length };
  3368. };
  3369. Reporter.prototype.restore = function restore(data) {
  3370. const state = this._reporterState;
  3371. state.obj = data.obj;
  3372. state.path = state.path.slice(0, data.pathLen);
  3373. };
  3374. Reporter.prototype.enterKey = function enterKey(key) {
  3375. return this._reporterState.path.push(key);
  3376. };
  3377. Reporter.prototype.exitKey = function exitKey(index) {
  3378. const state = this._reporterState;
  3379. state.path = state.path.slice(0, index - 1);
  3380. };
  3381. Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
  3382. const state = this._reporterState;
  3383. this.exitKey(index);
  3384. if (state.obj !== null)
  3385. state.obj[key] = value;
  3386. };
  3387. Reporter.prototype.path = function path() {
  3388. return this._reporterState.path.join('/');
  3389. };
  3390. Reporter.prototype.enterObject = function enterObject() {
  3391. const state = this._reporterState;
  3392. const prev = state.obj;
  3393. state.obj = {};
  3394. return prev;
  3395. };
  3396. Reporter.prototype.leaveObject = function leaveObject(prev) {
  3397. const state = this._reporterState;
  3398. const now = state.obj;
  3399. state.obj = prev;
  3400. return now;
  3401. };
  3402. Reporter.prototype.error = function error(msg) {
  3403. let err;
  3404. const state = this._reporterState;
  3405. const inherited = msg instanceof ReporterError;
  3406. if (inherited) {
  3407. err = msg;
  3408. } else {
  3409. err = new ReporterError(state.path.map(function(elem) {
  3410. return '[' + JSON.stringify(elem) + ']';
  3411. }).join(''), msg.message || msg, msg.stack);
  3412. }
  3413. if (!state.options.partial)
  3414. throw err;
  3415. if (!inherited)
  3416. state.errors.push(err);
  3417. return err;
  3418. };
  3419. Reporter.prototype.wrapResult = function wrapResult(result) {
  3420. const state = this._reporterState;
  3421. if (!state.options.partial)
  3422. return result;
  3423. return {
  3424. result: this.isError(result) ? null : result,
  3425. errors: state.errors
  3426. };
  3427. };
  3428. function ReporterError(path, msg) {
  3429. this.path = path;
  3430. this.rethrow(msg);
  3431. }
  3432. inherits(ReporterError, Error);
  3433. ReporterError.prototype.rethrow = function rethrow(msg) {
  3434. this.message = msg + ' at: ' + (this.path || '(shallow)');
  3435. if (Error.captureStackTrace)
  3436. Error.captureStackTrace(this, ReporterError);
  3437. if (!this.stack) {
  3438. try {
  3439. // IE only adds stack when thrown
  3440. throw new Error(this.message);
  3441. } catch (e) {
  3442. this.stack = e.stack;
  3443. }
  3444. }
  3445. return this;
  3446. };
  3447. /***/ }),
  3448. /***/ "./node_modules/asn1.js/lib/asn1/constants/der.js":
  3449. /*!********************************************************!*\
  3450. !*** ./node_modules/asn1.js/lib/asn1/constants/der.js ***!
  3451. \********************************************************/
  3452. /***/ ((__unused_webpack_module, exports) => {
  3453. "use strict";
  3454. // Helper
  3455. function reverse(map) {
  3456. const res = {};
  3457. Object.keys(map).forEach(function(key) {
  3458. // Convert key to integer if it is stringified
  3459. if ((key | 0) == key)
  3460. key = key | 0;
  3461. const value = map[key];
  3462. res[value] = key;
  3463. });
  3464. return res;
  3465. }
  3466. exports.tagClass = {
  3467. 0: 'universal',
  3468. 1: 'application',
  3469. 2: 'context',
  3470. 3: 'private'
  3471. };
  3472. exports.tagClassByName = reverse(exports.tagClass);
  3473. exports.tag = {
  3474. 0x00: 'end',
  3475. 0x01: 'bool',
  3476. 0x02: 'int',
  3477. 0x03: 'bitstr',
  3478. 0x04: 'octstr',
  3479. 0x05: 'null_',
  3480. 0x06: 'objid',
  3481. 0x07: 'objDesc',
  3482. 0x08: 'external',
  3483. 0x09: 'real',
  3484. 0x0a: 'enum',
  3485. 0x0b: 'embed',
  3486. 0x0c: 'utf8str',
  3487. 0x0d: 'relativeOid',
  3488. 0x10: 'seq',
  3489. 0x11: 'set',
  3490. 0x12: 'numstr',
  3491. 0x13: 'printstr',
  3492. 0x14: 't61str',
  3493. 0x15: 'videostr',
  3494. 0x16: 'ia5str',
  3495. 0x17: 'utctime',
  3496. 0x18: 'gentime',
  3497. 0x19: 'graphstr',
  3498. 0x1a: 'iso646str',
  3499. 0x1b: 'genstr',
  3500. 0x1c: 'unistr',
  3501. 0x1d: 'charstr',
  3502. 0x1e: 'bmpstr'
  3503. };
  3504. exports.tagByName = reverse(exports.tag);
  3505. /***/ }),
  3506. /***/ "./node_modules/asn1.js/lib/asn1/constants/index.js":
  3507. /*!**********************************************************!*\
  3508. !*** ./node_modules/asn1.js/lib/asn1/constants/index.js ***!
  3509. \**********************************************************/
  3510. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3511. "use strict";
  3512. const constants = exports;
  3513. // Helper
  3514. constants._reverse = function reverse(map) {
  3515. const res = {};
  3516. Object.keys(map).forEach(function(key) {
  3517. // Convert key to integer if it is stringified
  3518. if ((key | 0) == key)
  3519. key = key | 0;
  3520. const value = map[key];
  3521. res[value] = key;
  3522. });
  3523. return res;
  3524. };
  3525. constants.der = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/constants/der.js");
  3526. /***/ }),
  3527. /***/ "./node_modules/asn1.js/lib/asn1/decoders/der.js":
  3528. /*!*******************************************************!*\
  3529. !*** ./node_modules/asn1.js/lib/asn1/decoders/der.js ***!
  3530. \*******************************************************/
  3531. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3532. "use strict";
  3533. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  3534. const bignum = __webpack_require__(/*! bn.js */ "./node_modules/asn1.js/node_modules/bn.js/lib/bn.js");
  3535. const DecoderBuffer = (__webpack_require__(/*! ../base/buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer);
  3536. const Node = __webpack_require__(/*! ../base/node */ "./node_modules/asn1.js/lib/asn1/base/node.js");
  3537. // Import DER constants
  3538. const der = __webpack_require__(/*! ../constants/der */ "./node_modules/asn1.js/lib/asn1/constants/der.js");
  3539. function DERDecoder(entity) {
  3540. this.enc = 'der';
  3541. this.name = entity.name;
  3542. this.entity = entity;
  3543. // Construct base tree
  3544. this.tree = new DERNode();
  3545. this.tree._init(entity.body);
  3546. }
  3547. module.exports = DERDecoder;
  3548. DERDecoder.prototype.decode = function decode(data, options) {
  3549. if (!DecoderBuffer.isDecoderBuffer(data)) {
  3550. data = new DecoderBuffer(data, options);
  3551. }
  3552. return this.tree._decode(data, options);
  3553. };
  3554. // Tree methods
  3555. function DERNode(parent) {
  3556. Node.call(this, 'der', parent);
  3557. }
  3558. inherits(DERNode, Node);
  3559. DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
  3560. if (buffer.isEmpty())
  3561. return false;
  3562. const state = buffer.save();
  3563. const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
  3564. if (buffer.isError(decodedTag))
  3565. return decodedTag;
  3566. buffer.restore(state);
  3567. return decodedTag.tag === tag || decodedTag.tagStr === tag ||
  3568. (decodedTag.tagStr + 'of') === tag || any;
  3569. };
  3570. DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
  3571. const decodedTag = derDecodeTag(buffer,
  3572. 'Failed to decode tag of "' + tag + '"');
  3573. if (buffer.isError(decodedTag))
  3574. return decodedTag;
  3575. let len = derDecodeLen(buffer,
  3576. decodedTag.primitive,
  3577. 'Failed to get length of "' + tag + '"');
  3578. // Failure
  3579. if (buffer.isError(len))
  3580. return len;
  3581. if (!any &&
  3582. decodedTag.tag !== tag &&
  3583. decodedTag.tagStr !== tag &&
  3584. decodedTag.tagStr + 'of' !== tag) {
  3585. return buffer.error('Failed to match tag: "' + tag + '"');
  3586. }
  3587. if (decodedTag.primitive || len !== null)
  3588. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  3589. // Indefinite length... find END tag
  3590. const state = buffer.save();
  3591. const res = this._skipUntilEnd(
  3592. buffer,
  3593. 'Failed to skip indefinite length body: "' + this.tag + '"');
  3594. if (buffer.isError(res))
  3595. return res;
  3596. len = buffer.offset - state.offset;
  3597. buffer.restore(state);
  3598. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  3599. };
  3600. DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
  3601. for (;;) {
  3602. const tag = derDecodeTag(buffer, fail);
  3603. if (buffer.isError(tag))
  3604. return tag;
  3605. const len = derDecodeLen(buffer, tag.primitive, fail);
  3606. if (buffer.isError(len))
  3607. return len;
  3608. let res;
  3609. if (tag.primitive || len !== null)
  3610. res = buffer.skip(len);
  3611. else
  3612. res = this._skipUntilEnd(buffer, fail);
  3613. // Failure
  3614. if (buffer.isError(res))
  3615. return res;
  3616. if (tag.tagStr === 'end')
  3617. break;
  3618. }
  3619. };
  3620. DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
  3621. options) {
  3622. const result = [];
  3623. while (!buffer.isEmpty()) {
  3624. const possibleEnd = this._peekTag(buffer, 'end');
  3625. if (buffer.isError(possibleEnd))
  3626. return possibleEnd;
  3627. const res = decoder.decode(buffer, 'der', options);
  3628. if (buffer.isError(res) && possibleEnd)
  3629. break;
  3630. result.push(res);
  3631. }
  3632. return result;
  3633. };
  3634. DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
  3635. if (tag === 'bitstr') {
  3636. const unused = buffer.readUInt8();
  3637. if (buffer.isError(unused))
  3638. return unused;
  3639. return { unused: unused, data: buffer.raw() };
  3640. } else if (tag === 'bmpstr') {
  3641. const raw = buffer.raw();
  3642. if (raw.length % 2 === 1)
  3643. return buffer.error('Decoding of string type: bmpstr length mismatch');
  3644. let str = '';
  3645. for (let i = 0; i < raw.length / 2; i++) {
  3646. str += String.fromCharCode(raw.readUInt16BE(i * 2));
  3647. }
  3648. return str;
  3649. } else if (tag === 'numstr') {
  3650. const numstr = buffer.raw().toString('ascii');
  3651. if (!this._isNumstr(numstr)) {
  3652. return buffer.error('Decoding of string type: ' +
  3653. 'numstr unsupported characters');
  3654. }
  3655. return numstr;
  3656. } else if (tag === 'octstr') {
  3657. return buffer.raw();
  3658. } else if (tag === 'objDesc') {
  3659. return buffer.raw();
  3660. } else if (tag === 'printstr') {
  3661. const printstr = buffer.raw().toString('ascii');
  3662. if (!this._isPrintstr(printstr)) {
  3663. return buffer.error('Decoding of string type: ' +
  3664. 'printstr unsupported characters');
  3665. }
  3666. return printstr;
  3667. } else if (/str$/.test(tag)) {
  3668. return buffer.raw().toString();
  3669. } else {
  3670. return buffer.error('Decoding of string type: ' + tag + ' unsupported');
  3671. }
  3672. };
  3673. DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
  3674. let result;
  3675. const identifiers = [];
  3676. let ident = 0;
  3677. let subident = 0;
  3678. while (!buffer.isEmpty()) {
  3679. subident = buffer.readUInt8();
  3680. ident <<= 7;
  3681. ident |= subident & 0x7f;
  3682. if ((subident & 0x80) === 0) {
  3683. identifiers.push(ident);
  3684. ident = 0;
  3685. }
  3686. }
  3687. if (subident & 0x80)
  3688. identifiers.push(ident);
  3689. const first = (identifiers[0] / 40) | 0;
  3690. const second = identifiers[0] % 40;
  3691. if (relative)
  3692. result = identifiers;
  3693. else
  3694. result = [first, second].concat(identifiers.slice(1));
  3695. if (values) {
  3696. let tmp = values[result.join(' ')];
  3697. if (tmp === undefined)
  3698. tmp = values[result.join('.')];
  3699. if (tmp !== undefined)
  3700. result = tmp;
  3701. }
  3702. return result;
  3703. };
  3704. DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
  3705. const str = buffer.raw().toString();
  3706. let year;
  3707. let mon;
  3708. let day;
  3709. let hour;
  3710. let min;
  3711. let sec;
  3712. if (tag === 'gentime') {
  3713. year = str.slice(0, 4) | 0;
  3714. mon = str.slice(4, 6) | 0;
  3715. day = str.slice(6, 8) | 0;
  3716. hour = str.slice(8, 10) | 0;
  3717. min = str.slice(10, 12) | 0;
  3718. sec = str.slice(12, 14) | 0;
  3719. } else if (tag === 'utctime') {
  3720. year = str.slice(0, 2) | 0;
  3721. mon = str.slice(2, 4) | 0;
  3722. day = str.slice(4, 6) | 0;
  3723. hour = str.slice(6, 8) | 0;
  3724. min = str.slice(8, 10) | 0;
  3725. sec = str.slice(10, 12) | 0;
  3726. if (year < 70)
  3727. year = 2000 + year;
  3728. else
  3729. year = 1900 + year;
  3730. } else {
  3731. return buffer.error('Decoding ' + tag + ' time is not supported yet');
  3732. }
  3733. return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
  3734. };
  3735. DERNode.prototype._decodeNull = function decodeNull() {
  3736. return null;
  3737. };
  3738. DERNode.prototype._decodeBool = function decodeBool(buffer) {
  3739. const res = buffer.readUInt8();
  3740. if (buffer.isError(res))
  3741. return res;
  3742. else
  3743. return res !== 0;
  3744. };
  3745. DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
  3746. // Bigint, return as it is (assume big endian)
  3747. const raw = buffer.raw();
  3748. let res = new bignum(raw);
  3749. if (values)
  3750. res = values[res.toString(10)] || res;
  3751. return res;
  3752. };
  3753. DERNode.prototype._use = function use(entity, obj) {
  3754. if (typeof entity === 'function')
  3755. entity = entity(obj);
  3756. return entity._getDecoder('der').tree;
  3757. };
  3758. // Utility methods
  3759. function derDecodeTag(buf, fail) {
  3760. let tag = buf.readUInt8(fail);
  3761. if (buf.isError(tag))
  3762. return tag;
  3763. const cls = der.tagClass[tag >> 6];
  3764. const primitive = (tag & 0x20) === 0;
  3765. // Multi-octet tag - load
  3766. if ((tag & 0x1f) === 0x1f) {
  3767. let oct = tag;
  3768. tag = 0;
  3769. while ((oct & 0x80) === 0x80) {
  3770. oct = buf.readUInt8(fail);
  3771. if (buf.isError(oct))
  3772. return oct;
  3773. tag <<= 7;
  3774. tag |= oct & 0x7f;
  3775. }
  3776. } else {
  3777. tag &= 0x1f;
  3778. }
  3779. const tagStr = der.tag[tag];
  3780. return {
  3781. cls: cls,
  3782. primitive: primitive,
  3783. tag: tag,
  3784. tagStr: tagStr
  3785. };
  3786. }
  3787. function derDecodeLen(buf, primitive, fail) {
  3788. let len = buf.readUInt8(fail);
  3789. if (buf.isError(len))
  3790. return len;
  3791. // Indefinite form
  3792. if (!primitive && len === 0x80)
  3793. return null;
  3794. // Definite form
  3795. if ((len & 0x80) === 0) {
  3796. // Short form
  3797. return len;
  3798. }
  3799. // Long form
  3800. const num = len & 0x7f;
  3801. if (num > 4)
  3802. return buf.error('length octect is too long');
  3803. len = 0;
  3804. for (let i = 0; i < num; i++) {
  3805. len <<= 8;
  3806. const j = buf.readUInt8(fail);
  3807. if (buf.isError(j))
  3808. return j;
  3809. len |= j;
  3810. }
  3811. return len;
  3812. }
  3813. /***/ }),
  3814. /***/ "./node_modules/asn1.js/lib/asn1/decoders/index.js":
  3815. /*!*********************************************************!*\
  3816. !*** ./node_modules/asn1.js/lib/asn1/decoders/index.js ***!
  3817. \*********************************************************/
  3818. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3819. "use strict";
  3820. const decoders = exports;
  3821. decoders.der = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/decoders/der.js");
  3822. decoders.pem = __webpack_require__(/*! ./pem */ "./node_modules/asn1.js/lib/asn1/decoders/pem.js");
  3823. /***/ }),
  3824. /***/ "./node_modules/asn1.js/lib/asn1/decoders/pem.js":
  3825. /*!*******************************************************!*\
  3826. !*** ./node_modules/asn1.js/lib/asn1/decoders/pem.js ***!
  3827. \*******************************************************/
  3828. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3829. "use strict";
  3830. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  3831. const Buffer = (__webpack_require__(/*! safer-buffer */ "./node_modules/safer-buffer/safer.js").Buffer);
  3832. const DERDecoder = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/decoders/der.js");
  3833. function PEMDecoder(entity) {
  3834. DERDecoder.call(this, entity);
  3835. this.enc = 'pem';
  3836. }
  3837. inherits(PEMDecoder, DERDecoder);
  3838. module.exports = PEMDecoder;
  3839. PEMDecoder.prototype.decode = function decode(data, options) {
  3840. const lines = data.toString().split(/[\r\n]+/g);
  3841. const label = options.label.toUpperCase();
  3842. const re = /^-----(BEGIN|END) ([^-]+)-----$/;
  3843. let start = -1;
  3844. let end = -1;
  3845. for (let i = 0; i < lines.length; i++) {
  3846. const match = lines[i].match(re);
  3847. if (match === null)
  3848. continue;
  3849. if (match[2] !== label)
  3850. continue;
  3851. if (start === -1) {
  3852. if (match[1] !== 'BEGIN')
  3853. break;
  3854. start = i;
  3855. } else {
  3856. if (match[1] !== 'END')
  3857. break;
  3858. end = i;
  3859. break;
  3860. }
  3861. }
  3862. if (start === -1 || end === -1)
  3863. throw new Error('PEM section not found for: ' + label);
  3864. const base64 = lines.slice(start + 1, end).join('');
  3865. // Remove excessive symbols
  3866. base64.replace(/[^a-z0-9+/=]+/gi, '');
  3867. const input = Buffer.from(base64, 'base64');
  3868. return DERDecoder.prototype.decode.call(this, input, options);
  3869. };
  3870. /***/ }),
  3871. /***/ "./node_modules/asn1.js/lib/asn1/encoders/der.js":
  3872. /*!*******************************************************!*\
  3873. !*** ./node_modules/asn1.js/lib/asn1/encoders/der.js ***!
  3874. \*******************************************************/
  3875. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3876. "use strict";
  3877. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  3878. const Buffer = (__webpack_require__(/*! safer-buffer */ "./node_modules/safer-buffer/safer.js").Buffer);
  3879. const Node = __webpack_require__(/*! ../base/node */ "./node_modules/asn1.js/lib/asn1/base/node.js");
  3880. // Import DER constants
  3881. const der = __webpack_require__(/*! ../constants/der */ "./node_modules/asn1.js/lib/asn1/constants/der.js");
  3882. function DEREncoder(entity) {
  3883. this.enc = 'der';
  3884. this.name = entity.name;
  3885. this.entity = entity;
  3886. // Construct base tree
  3887. this.tree = new DERNode();
  3888. this.tree._init(entity.body);
  3889. }
  3890. module.exports = DEREncoder;
  3891. DEREncoder.prototype.encode = function encode(data, reporter) {
  3892. return this.tree._encode(data, reporter).join();
  3893. };
  3894. // Tree methods
  3895. function DERNode(parent) {
  3896. Node.call(this, 'der', parent);
  3897. }
  3898. inherits(DERNode, Node);
  3899. DERNode.prototype._encodeComposite = function encodeComposite(tag,
  3900. primitive,
  3901. cls,
  3902. content) {
  3903. const encodedTag = encodeTag(tag, primitive, cls, this.reporter);
  3904. // Short form
  3905. if (content.length < 0x80) {
  3906. const header = Buffer.alloc(2);
  3907. header[0] = encodedTag;
  3908. header[1] = content.length;
  3909. return this._createEncoderBuffer([ header, content ]);
  3910. }
  3911. // Long form
  3912. // Count octets required to store length
  3913. let lenOctets = 1;
  3914. for (let i = content.length; i >= 0x100; i >>= 8)
  3915. lenOctets++;
  3916. const header = Buffer.alloc(1 + 1 + lenOctets);
  3917. header[0] = encodedTag;
  3918. header[1] = 0x80 | lenOctets;
  3919. for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
  3920. header[i] = j & 0xff;
  3921. return this._createEncoderBuffer([ header, content ]);
  3922. };
  3923. DERNode.prototype._encodeStr = function encodeStr(str, tag) {
  3924. if (tag === 'bitstr') {
  3925. return this._createEncoderBuffer([ str.unused | 0, str.data ]);
  3926. } else if (tag === 'bmpstr') {
  3927. const buf = Buffer.alloc(str.length * 2);
  3928. for (let i = 0; i < str.length; i++) {
  3929. buf.writeUInt16BE(str.charCodeAt(i), i * 2);
  3930. }
  3931. return this._createEncoderBuffer(buf);
  3932. } else if (tag === 'numstr') {
  3933. if (!this._isNumstr(str)) {
  3934. return this.reporter.error('Encoding of string type: numstr supports ' +
  3935. 'only digits and space');
  3936. }
  3937. return this._createEncoderBuffer(str);
  3938. } else if (tag === 'printstr') {
  3939. if (!this._isPrintstr(str)) {
  3940. return this.reporter.error('Encoding of string type: printstr supports ' +
  3941. 'only latin upper and lower case letters, ' +
  3942. 'digits, space, apostrophe, left and rigth ' +
  3943. 'parenthesis, plus sign, comma, hyphen, ' +
  3944. 'dot, slash, colon, equal sign, ' +
  3945. 'question mark');
  3946. }
  3947. return this._createEncoderBuffer(str);
  3948. } else if (/str$/.test(tag)) {
  3949. return this._createEncoderBuffer(str);
  3950. } else if (tag === 'objDesc') {
  3951. return this._createEncoderBuffer(str);
  3952. } else {
  3953. return this.reporter.error('Encoding of string type: ' + tag +
  3954. ' unsupported');
  3955. }
  3956. };
  3957. DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
  3958. if (typeof id === 'string') {
  3959. if (!values)
  3960. return this.reporter.error('string objid given, but no values map found');
  3961. if (!values.hasOwnProperty(id))
  3962. return this.reporter.error('objid not found in values map');
  3963. id = values[id].split(/[\s.]+/g);
  3964. for (let i = 0; i < id.length; i++)
  3965. id[i] |= 0;
  3966. } else if (Array.isArray(id)) {
  3967. id = id.slice();
  3968. for (let i = 0; i < id.length; i++)
  3969. id[i] |= 0;
  3970. }
  3971. if (!Array.isArray(id)) {
  3972. return this.reporter.error('objid() should be either array or string, ' +
  3973. 'got: ' + JSON.stringify(id));
  3974. }
  3975. if (!relative) {
  3976. if (id[1] >= 40)
  3977. return this.reporter.error('Second objid identifier OOB');
  3978. id.splice(0, 2, id[0] * 40 + id[1]);
  3979. }
  3980. // Count number of octets
  3981. let size = 0;
  3982. for (let i = 0; i < id.length; i++) {
  3983. let ident = id[i];
  3984. for (size++; ident >= 0x80; ident >>= 7)
  3985. size++;
  3986. }
  3987. const objid = Buffer.alloc(size);
  3988. let offset = objid.length - 1;
  3989. for (let i = id.length - 1; i >= 0; i--) {
  3990. let ident = id[i];
  3991. objid[offset--] = ident & 0x7f;
  3992. while ((ident >>= 7) > 0)
  3993. objid[offset--] = 0x80 | (ident & 0x7f);
  3994. }
  3995. return this._createEncoderBuffer(objid);
  3996. };
  3997. function two(num) {
  3998. if (num < 10)
  3999. return '0' + num;
  4000. else
  4001. return num;
  4002. }
  4003. DERNode.prototype._encodeTime = function encodeTime(time, tag) {
  4004. let str;
  4005. const date = new Date(time);
  4006. if (tag === 'gentime') {
  4007. str = [
  4008. two(date.getUTCFullYear()),
  4009. two(date.getUTCMonth() + 1),
  4010. two(date.getUTCDate()),
  4011. two(date.getUTCHours()),
  4012. two(date.getUTCMinutes()),
  4013. two(date.getUTCSeconds()),
  4014. 'Z'
  4015. ].join('');
  4016. } else if (tag === 'utctime') {
  4017. str = [
  4018. two(date.getUTCFullYear() % 100),
  4019. two(date.getUTCMonth() + 1),
  4020. two(date.getUTCDate()),
  4021. two(date.getUTCHours()),
  4022. two(date.getUTCMinutes()),
  4023. two(date.getUTCSeconds()),
  4024. 'Z'
  4025. ].join('');
  4026. } else {
  4027. this.reporter.error('Encoding ' + tag + ' time is not supported yet');
  4028. }
  4029. return this._encodeStr(str, 'octstr');
  4030. };
  4031. DERNode.prototype._encodeNull = function encodeNull() {
  4032. return this._createEncoderBuffer('');
  4033. };
  4034. DERNode.prototype._encodeInt = function encodeInt(num, values) {
  4035. if (typeof num === 'string') {
  4036. if (!values)
  4037. return this.reporter.error('String int or enum given, but no values map');
  4038. if (!values.hasOwnProperty(num)) {
  4039. return this.reporter.error('Values map doesn\'t contain: ' +
  4040. JSON.stringify(num));
  4041. }
  4042. num = values[num];
  4043. }
  4044. // Bignum, assume big endian
  4045. if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
  4046. const numArray = num.toArray();
  4047. if (!num.sign && numArray[0] & 0x80) {
  4048. numArray.unshift(0);
  4049. }
  4050. num = Buffer.from(numArray);
  4051. }
  4052. if (Buffer.isBuffer(num)) {
  4053. let size = num.length;
  4054. if (num.length === 0)
  4055. size++;
  4056. const out = Buffer.alloc(size);
  4057. num.copy(out);
  4058. if (num.length === 0)
  4059. out[0] = 0;
  4060. return this._createEncoderBuffer(out);
  4061. }
  4062. if (num < 0x80)
  4063. return this._createEncoderBuffer(num);
  4064. if (num < 0x100)
  4065. return this._createEncoderBuffer([0, num]);
  4066. let size = 1;
  4067. for (let i = num; i >= 0x100; i >>= 8)
  4068. size++;
  4069. const out = new Array(size);
  4070. for (let i = out.length - 1; i >= 0; i--) {
  4071. out[i] = num & 0xff;
  4072. num >>= 8;
  4073. }
  4074. if(out[0] & 0x80) {
  4075. out.unshift(0);
  4076. }
  4077. return this._createEncoderBuffer(Buffer.from(out));
  4078. };
  4079. DERNode.prototype._encodeBool = function encodeBool(value) {
  4080. return this._createEncoderBuffer(value ? 0xff : 0);
  4081. };
  4082. DERNode.prototype._use = function use(entity, obj) {
  4083. if (typeof entity === 'function')
  4084. entity = entity(obj);
  4085. return entity._getEncoder('der').tree;
  4086. };
  4087. DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
  4088. const state = this._baseState;
  4089. let i;
  4090. if (state['default'] === null)
  4091. return false;
  4092. const data = dataBuffer.join();
  4093. if (state.defaultBuffer === undefined)
  4094. state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
  4095. if (data.length !== state.defaultBuffer.length)
  4096. return false;
  4097. for (i=0; i < data.length; i++)
  4098. if (data[i] !== state.defaultBuffer[i])
  4099. return false;
  4100. return true;
  4101. };
  4102. // Utility methods
  4103. function encodeTag(tag, primitive, cls, reporter) {
  4104. let res;
  4105. if (tag === 'seqof')
  4106. tag = 'seq';
  4107. else if (tag === 'setof')
  4108. tag = 'set';
  4109. if (der.tagByName.hasOwnProperty(tag))
  4110. res = der.tagByName[tag];
  4111. else if (typeof tag === 'number' && (tag | 0) === tag)
  4112. res = tag;
  4113. else
  4114. return reporter.error('Unknown tag: ' + tag);
  4115. if (res >= 0x1f)
  4116. return reporter.error('Multi-octet tag encoding unsupported');
  4117. if (!primitive)
  4118. res |= 0x20;
  4119. res |= (der.tagClassByName[cls || 'universal'] << 6);
  4120. return res;
  4121. }
  4122. /***/ }),
  4123. /***/ "./node_modules/asn1.js/lib/asn1/encoders/index.js":
  4124. /*!*********************************************************!*\
  4125. !*** ./node_modules/asn1.js/lib/asn1/encoders/index.js ***!
  4126. \*********************************************************/
  4127. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4128. "use strict";
  4129. const encoders = exports;
  4130. encoders.der = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/encoders/der.js");
  4131. encoders.pem = __webpack_require__(/*! ./pem */ "./node_modules/asn1.js/lib/asn1/encoders/pem.js");
  4132. /***/ }),
  4133. /***/ "./node_modules/asn1.js/lib/asn1/encoders/pem.js":
  4134. /*!*******************************************************!*\
  4135. !*** ./node_modules/asn1.js/lib/asn1/encoders/pem.js ***!
  4136. \*******************************************************/
  4137. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  4138. "use strict";
  4139. const inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  4140. const DEREncoder = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/encoders/der.js");
  4141. function PEMEncoder(entity) {
  4142. DEREncoder.call(this, entity);
  4143. this.enc = 'pem';
  4144. }
  4145. inherits(PEMEncoder, DEREncoder);
  4146. module.exports = PEMEncoder;
  4147. PEMEncoder.prototype.encode = function encode(data, options) {
  4148. const buf = DEREncoder.prototype.encode.call(this, data);
  4149. const p = buf.toString('base64');
  4150. const out = [ '-----BEGIN ' + options.label + '-----' ];
  4151. for (let i = 0; i < p.length; i += 64)
  4152. out.push(p.slice(i, i + 64));
  4153. out.push('-----END ' + options.label + '-----');
  4154. return out.join('\n');
  4155. };
  4156. /***/ }),
  4157. /***/ "./node_modules/asn1.js/node_modules/bn.js/lib/bn.js":
  4158. /*!***********************************************************!*\
  4159. !*** ./node_modules/asn1.js/node_modules/bn.js/lib/bn.js ***!
  4160. \***********************************************************/
  4161. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  4162. /* module decorator */ module = __webpack_require__.nmd(module);
  4163. (function (module, exports) {
  4164. 'use strict';
  4165. // Utils
  4166. function assert (val, msg) {
  4167. if (!val) throw new Error(msg || 'Assertion failed');
  4168. }
  4169. // Could use `inherits` module, but don't want to move from single file
  4170. // architecture yet.
  4171. function inherits (ctor, superCtor) {
  4172. ctor.super_ = superCtor;
  4173. var TempCtor = function () {};
  4174. TempCtor.prototype = superCtor.prototype;
  4175. ctor.prototype = new TempCtor();
  4176. ctor.prototype.constructor = ctor;
  4177. }
  4178. // BN
  4179. function BN (number, base, endian) {
  4180. if (BN.isBN(number)) {
  4181. return number;
  4182. }
  4183. this.negative = 0;
  4184. this.words = null;
  4185. this.length = 0;
  4186. // Reduction context
  4187. this.red = null;
  4188. if (number !== null) {
  4189. if (base === 'le' || base === 'be') {
  4190. endian = base;
  4191. base = 10;
  4192. }
  4193. this._init(number || 0, base || 10, endian || 'be');
  4194. }
  4195. }
  4196. if (typeof module === 'object') {
  4197. module.exports = BN;
  4198. } else {
  4199. exports.BN = BN;
  4200. }
  4201. BN.BN = BN;
  4202. BN.wordSize = 26;
  4203. var Buffer;
  4204. try {
  4205. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  4206. Buffer = window.Buffer;
  4207. } else {
  4208. Buffer = (__webpack_require__(/*! buffer */ "?248e").Buffer);
  4209. }
  4210. } catch (e) {
  4211. }
  4212. BN.isBN = function isBN (num) {
  4213. if (num instanceof BN) {
  4214. return true;
  4215. }
  4216. return num !== null && typeof num === 'object' &&
  4217. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  4218. };
  4219. BN.max = function max (left, right) {
  4220. if (left.cmp(right) > 0) return left;
  4221. return right;
  4222. };
  4223. BN.min = function min (left, right) {
  4224. if (left.cmp(right) < 0) return left;
  4225. return right;
  4226. };
  4227. BN.prototype._init = function init (number, base, endian) {
  4228. if (typeof number === 'number') {
  4229. return this._initNumber(number, base, endian);
  4230. }
  4231. if (typeof number === 'object') {
  4232. return this._initArray(number, base, endian);
  4233. }
  4234. if (base === 'hex') {
  4235. base = 16;
  4236. }
  4237. assert(base === (base | 0) && base >= 2 && base <= 36);
  4238. number = number.toString().replace(/\s+/g, '');
  4239. var start = 0;
  4240. if (number[0] === '-') {
  4241. start++;
  4242. this.negative = 1;
  4243. }
  4244. if (start < number.length) {
  4245. if (base === 16) {
  4246. this._parseHex(number, start, endian);
  4247. } else {
  4248. this._parseBase(number, base, start);
  4249. if (endian === 'le') {
  4250. this._initArray(this.toArray(), base, endian);
  4251. }
  4252. }
  4253. }
  4254. };
  4255. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  4256. if (number < 0) {
  4257. this.negative = 1;
  4258. number = -number;
  4259. }
  4260. if (number < 0x4000000) {
  4261. this.words = [ number & 0x3ffffff ];
  4262. this.length = 1;
  4263. } else if (number < 0x10000000000000) {
  4264. this.words = [
  4265. number & 0x3ffffff,
  4266. (number / 0x4000000) & 0x3ffffff
  4267. ];
  4268. this.length = 2;
  4269. } else {
  4270. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  4271. this.words = [
  4272. number & 0x3ffffff,
  4273. (number / 0x4000000) & 0x3ffffff,
  4274. 1
  4275. ];
  4276. this.length = 3;
  4277. }
  4278. if (endian !== 'le') return;
  4279. // Reverse the bytes
  4280. this._initArray(this.toArray(), base, endian);
  4281. };
  4282. BN.prototype._initArray = function _initArray (number, base, endian) {
  4283. // Perhaps a Uint8Array
  4284. assert(typeof number.length === 'number');
  4285. if (number.length <= 0) {
  4286. this.words = [ 0 ];
  4287. this.length = 1;
  4288. return this;
  4289. }
  4290. this.length = Math.ceil(number.length / 3);
  4291. this.words = new Array(this.length);
  4292. for (var i = 0; i < this.length; i++) {
  4293. this.words[i] = 0;
  4294. }
  4295. var j, w;
  4296. var off = 0;
  4297. if (endian === 'be') {
  4298. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  4299. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  4300. this.words[j] |= (w << off) & 0x3ffffff;
  4301. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  4302. off += 24;
  4303. if (off >= 26) {
  4304. off -= 26;
  4305. j++;
  4306. }
  4307. }
  4308. } else if (endian === 'le') {
  4309. for (i = 0, j = 0; i < number.length; i += 3) {
  4310. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  4311. this.words[j] |= (w << off) & 0x3ffffff;
  4312. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  4313. off += 24;
  4314. if (off >= 26) {
  4315. off -= 26;
  4316. j++;
  4317. }
  4318. }
  4319. }
  4320. return this.strip();
  4321. };
  4322. function parseHex4Bits (string, index) {
  4323. var c = string.charCodeAt(index);
  4324. // 'A' - 'F'
  4325. if (c >= 65 && c <= 70) {
  4326. return c - 55;
  4327. // 'a' - 'f'
  4328. } else if (c >= 97 && c <= 102) {
  4329. return c - 87;
  4330. // '0' - '9'
  4331. } else {
  4332. return (c - 48) & 0xf;
  4333. }
  4334. }
  4335. function parseHexByte (string, lowerBound, index) {
  4336. var r = parseHex4Bits(string, index);
  4337. if (index - 1 >= lowerBound) {
  4338. r |= parseHex4Bits(string, index - 1) << 4;
  4339. }
  4340. return r;
  4341. }
  4342. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  4343. // Create possibly bigger array to ensure that it fits the number
  4344. this.length = Math.ceil((number.length - start) / 6);
  4345. this.words = new Array(this.length);
  4346. for (var i = 0; i < this.length; i++) {
  4347. this.words[i] = 0;
  4348. }
  4349. // 24-bits chunks
  4350. var off = 0;
  4351. var j = 0;
  4352. var w;
  4353. if (endian === 'be') {
  4354. for (i = number.length - 1; i >= start; i -= 2) {
  4355. w = parseHexByte(number, start, i) << off;
  4356. this.words[j] |= w & 0x3ffffff;
  4357. if (off >= 18) {
  4358. off -= 18;
  4359. j += 1;
  4360. this.words[j] |= w >>> 26;
  4361. } else {
  4362. off += 8;
  4363. }
  4364. }
  4365. } else {
  4366. var parseLength = number.length - start;
  4367. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  4368. w = parseHexByte(number, start, i) << off;
  4369. this.words[j] |= w & 0x3ffffff;
  4370. if (off >= 18) {
  4371. off -= 18;
  4372. j += 1;
  4373. this.words[j] |= w >>> 26;
  4374. } else {
  4375. off += 8;
  4376. }
  4377. }
  4378. }
  4379. this.strip();
  4380. };
  4381. function parseBase (str, start, end, mul) {
  4382. var r = 0;
  4383. var len = Math.min(str.length, end);
  4384. for (var i = start; i < len; i++) {
  4385. var c = str.charCodeAt(i) - 48;
  4386. r *= mul;
  4387. // 'a'
  4388. if (c >= 49) {
  4389. r += c - 49 + 0xa;
  4390. // 'A'
  4391. } else if (c >= 17) {
  4392. r += c - 17 + 0xa;
  4393. // '0' - '9'
  4394. } else {
  4395. r += c;
  4396. }
  4397. }
  4398. return r;
  4399. }
  4400. BN.prototype._parseBase = function _parseBase (number, base, start) {
  4401. // Initialize as zero
  4402. this.words = [ 0 ];
  4403. this.length = 1;
  4404. // Find length of limb in base
  4405. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  4406. limbLen++;
  4407. }
  4408. limbLen--;
  4409. limbPow = (limbPow / base) | 0;
  4410. var total = number.length - start;
  4411. var mod = total % limbLen;
  4412. var end = Math.min(total, total - mod) + start;
  4413. var word = 0;
  4414. for (var i = start; i < end; i += limbLen) {
  4415. word = parseBase(number, i, i + limbLen, base);
  4416. this.imuln(limbPow);
  4417. if (this.words[0] + word < 0x4000000) {
  4418. this.words[0] += word;
  4419. } else {
  4420. this._iaddn(word);
  4421. }
  4422. }
  4423. if (mod !== 0) {
  4424. var pow = 1;
  4425. word = parseBase(number, i, number.length, base);
  4426. for (i = 0; i < mod; i++) {
  4427. pow *= base;
  4428. }
  4429. this.imuln(pow);
  4430. if (this.words[0] + word < 0x4000000) {
  4431. this.words[0] += word;
  4432. } else {
  4433. this._iaddn(word);
  4434. }
  4435. }
  4436. this.strip();
  4437. };
  4438. BN.prototype.copy = function copy (dest) {
  4439. dest.words = new Array(this.length);
  4440. for (var i = 0; i < this.length; i++) {
  4441. dest.words[i] = this.words[i];
  4442. }
  4443. dest.length = this.length;
  4444. dest.negative = this.negative;
  4445. dest.red = this.red;
  4446. };
  4447. BN.prototype.clone = function clone () {
  4448. var r = new BN(null);
  4449. this.copy(r);
  4450. return r;
  4451. };
  4452. BN.prototype._expand = function _expand (size) {
  4453. while (this.length < size) {
  4454. this.words[this.length++] = 0;
  4455. }
  4456. return this;
  4457. };
  4458. // Remove leading `0` from `this`
  4459. BN.prototype.strip = function strip () {
  4460. while (this.length > 1 && this.words[this.length - 1] === 0) {
  4461. this.length--;
  4462. }
  4463. return this._normSign();
  4464. };
  4465. BN.prototype._normSign = function _normSign () {
  4466. // -0 = 0
  4467. if (this.length === 1 && this.words[0] === 0) {
  4468. this.negative = 0;
  4469. }
  4470. return this;
  4471. };
  4472. BN.prototype.inspect = function inspect () {
  4473. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  4474. };
  4475. /*
  4476. var zeros = [];
  4477. var groupSizes = [];
  4478. var groupBases = [];
  4479. var s = '';
  4480. var i = -1;
  4481. while (++i < BN.wordSize) {
  4482. zeros[i] = s;
  4483. s += '0';
  4484. }
  4485. groupSizes[0] = 0;
  4486. groupSizes[1] = 0;
  4487. groupBases[0] = 0;
  4488. groupBases[1] = 0;
  4489. var base = 2 - 1;
  4490. while (++base < 36 + 1) {
  4491. var groupSize = 0;
  4492. var groupBase = 1;
  4493. while (groupBase < (1 << BN.wordSize) / base) {
  4494. groupBase *= base;
  4495. groupSize += 1;
  4496. }
  4497. groupSizes[base] = groupSize;
  4498. groupBases[base] = groupBase;
  4499. }
  4500. */
  4501. var zeros = [
  4502. '',
  4503. '0',
  4504. '00',
  4505. '000',
  4506. '0000',
  4507. '00000',
  4508. '000000',
  4509. '0000000',
  4510. '00000000',
  4511. '000000000',
  4512. '0000000000',
  4513. '00000000000',
  4514. '000000000000',
  4515. '0000000000000',
  4516. '00000000000000',
  4517. '000000000000000',
  4518. '0000000000000000',
  4519. '00000000000000000',
  4520. '000000000000000000',
  4521. '0000000000000000000',
  4522. '00000000000000000000',
  4523. '000000000000000000000',
  4524. '0000000000000000000000',
  4525. '00000000000000000000000',
  4526. '000000000000000000000000',
  4527. '0000000000000000000000000'
  4528. ];
  4529. var groupSizes = [
  4530. 0, 0,
  4531. 25, 16, 12, 11, 10, 9, 8,
  4532. 8, 7, 7, 7, 7, 6, 6,
  4533. 6, 6, 6, 6, 6, 5, 5,
  4534. 5, 5, 5, 5, 5, 5, 5,
  4535. 5, 5, 5, 5, 5, 5, 5
  4536. ];
  4537. var groupBases = [
  4538. 0, 0,
  4539. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  4540. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  4541. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  4542. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  4543. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  4544. ];
  4545. BN.prototype.toString = function toString (base, padding) {
  4546. base = base || 10;
  4547. padding = padding | 0 || 1;
  4548. var out;
  4549. if (base === 16 || base === 'hex') {
  4550. out = '';
  4551. var off = 0;
  4552. var carry = 0;
  4553. for (var i = 0; i < this.length; i++) {
  4554. var w = this.words[i];
  4555. var word = (((w << off) | carry) & 0xffffff).toString(16);
  4556. carry = (w >>> (24 - off)) & 0xffffff;
  4557. if (carry !== 0 || i !== this.length - 1) {
  4558. out = zeros[6 - word.length] + word + out;
  4559. } else {
  4560. out = word + out;
  4561. }
  4562. off += 2;
  4563. if (off >= 26) {
  4564. off -= 26;
  4565. i--;
  4566. }
  4567. }
  4568. if (carry !== 0) {
  4569. out = carry.toString(16) + out;
  4570. }
  4571. while (out.length % padding !== 0) {
  4572. out = '0' + out;
  4573. }
  4574. if (this.negative !== 0) {
  4575. out = '-' + out;
  4576. }
  4577. return out;
  4578. }
  4579. if (base === (base | 0) && base >= 2 && base <= 36) {
  4580. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  4581. var groupSize = groupSizes[base];
  4582. // var groupBase = Math.pow(base, groupSize);
  4583. var groupBase = groupBases[base];
  4584. out = '';
  4585. var c = this.clone();
  4586. c.negative = 0;
  4587. while (!c.isZero()) {
  4588. var r = c.modn(groupBase).toString(base);
  4589. c = c.idivn(groupBase);
  4590. if (!c.isZero()) {
  4591. out = zeros[groupSize - r.length] + r + out;
  4592. } else {
  4593. out = r + out;
  4594. }
  4595. }
  4596. if (this.isZero()) {
  4597. out = '0' + out;
  4598. }
  4599. while (out.length % padding !== 0) {
  4600. out = '0' + out;
  4601. }
  4602. if (this.negative !== 0) {
  4603. out = '-' + out;
  4604. }
  4605. return out;
  4606. }
  4607. assert(false, 'Base should be between 2 and 36');
  4608. };
  4609. BN.prototype.toNumber = function toNumber () {
  4610. var ret = this.words[0];
  4611. if (this.length === 2) {
  4612. ret += this.words[1] * 0x4000000;
  4613. } else if (this.length === 3 && this.words[2] === 0x01) {
  4614. // NOTE: at this stage it is known that the top bit is set
  4615. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  4616. } else if (this.length > 2) {
  4617. assert(false, 'Number can only safely store up to 53 bits');
  4618. }
  4619. return (this.negative !== 0) ? -ret : ret;
  4620. };
  4621. BN.prototype.toJSON = function toJSON () {
  4622. return this.toString(16);
  4623. };
  4624. BN.prototype.toBuffer = function toBuffer (endian, length) {
  4625. assert(typeof Buffer !== 'undefined');
  4626. return this.toArrayLike(Buffer, endian, length);
  4627. };
  4628. BN.prototype.toArray = function toArray (endian, length) {
  4629. return this.toArrayLike(Array, endian, length);
  4630. };
  4631. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  4632. var byteLength = this.byteLength();
  4633. var reqLength = length || Math.max(1, byteLength);
  4634. assert(byteLength <= reqLength, 'byte array longer than desired length');
  4635. assert(reqLength > 0, 'Requested array length <= 0');
  4636. this.strip();
  4637. var littleEndian = endian === 'le';
  4638. var res = new ArrayType(reqLength);
  4639. var b, i;
  4640. var q = this.clone();
  4641. if (!littleEndian) {
  4642. // Assume big-endian
  4643. for (i = 0; i < reqLength - byteLength; i++) {
  4644. res[i] = 0;
  4645. }
  4646. for (i = 0; !q.isZero(); i++) {
  4647. b = q.andln(0xff);
  4648. q.iushrn(8);
  4649. res[reqLength - i - 1] = b;
  4650. }
  4651. } else {
  4652. for (i = 0; !q.isZero(); i++) {
  4653. b = q.andln(0xff);
  4654. q.iushrn(8);
  4655. res[i] = b;
  4656. }
  4657. for (; i < reqLength; i++) {
  4658. res[i] = 0;
  4659. }
  4660. }
  4661. return res;
  4662. };
  4663. if (Math.clz32) {
  4664. BN.prototype._countBits = function _countBits (w) {
  4665. return 32 - Math.clz32(w);
  4666. };
  4667. } else {
  4668. BN.prototype._countBits = function _countBits (w) {
  4669. var t = w;
  4670. var r = 0;
  4671. if (t >= 0x1000) {
  4672. r += 13;
  4673. t >>>= 13;
  4674. }
  4675. if (t >= 0x40) {
  4676. r += 7;
  4677. t >>>= 7;
  4678. }
  4679. if (t >= 0x8) {
  4680. r += 4;
  4681. t >>>= 4;
  4682. }
  4683. if (t >= 0x02) {
  4684. r += 2;
  4685. t >>>= 2;
  4686. }
  4687. return r + t;
  4688. };
  4689. }
  4690. BN.prototype._zeroBits = function _zeroBits (w) {
  4691. // Short-cut
  4692. if (w === 0) return 26;
  4693. var t = w;
  4694. var r = 0;
  4695. if ((t & 0x1fff) === 0) {
  4696. r += 13;
  4697. t >>>= 13;
  4698. }
  4699. if ((t & 0x7f) === 0) {
  4700. r += 7;
  4701. t >>>= 7;
  4702. }
  4703. if ((t & 0xf) === 0) {
  4704. r += 4;
  4705. t >>>= 4;
  4706. }
  4707. if ((t & 0x3) === 0) {
  4708. r += 2;
  4709. t >>>= 2;
  4710. }
  4711. if ((t & 0x1) === 0) {
  4712. r++;
  4713. }
  4714. return r;
  4715. };
  4716. // Return number of used bits in a BN
  4717. BN.prototype.bitLength = function bitLength () {
  4718. var w = this.words[this.length - 1];
  4719. var hi = this._countBits(w);
  4720. return (this.length - 1) * 26 + hi;
  4721. };
  4722. function toBitArray (num) {
  4723. var w = new Array(num.bitLength());
  4724. for (var bit = 0; bit < w.length; bit++) {
  4725. var off = (bit / 26) | 0;
  4726. var wbit = bit % 26;
  4727. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  4728. }
  4729. return w;
  4730. }
  4731. // Number of trailing zero bits
  4732. BN.prototype.zeroBits = function zeroBits () {
  4733. if (this.isZero()) return 0;
  4734. var r = 0;
  4735. for (var i = 0; i < this.length; i++) {
  4736. var b = this._zeroBits(this.words[i]);
  4737. r += b;
  4738. if (b !== 26) break;
  4739. }
  4740. return r;
  4741. };
  4742. BN.prototype.byteLength = function byteLength () {
  4743. return Math.ceil(this.bitLength() / 8);
  4744. };
  4745. BN.prototype.toTwos = function toTwos (width) {
  4746. if (this.negative !== 0) {
  4747. return this.abs().inotn(width).iaddn(1);
  4748. }
  4749. return this.clone();
  4750. };
  4751. BN.prototype.fromTwos = function fromTwos (width) {
  4752. if (this.testn(width - 1)) {
  4753. return this.notn(width).iaddn(1).ineg();
  4754. }
  4755. return this.clone();
  4756. };
  4757. BN.prototype.isNeg = function isNeg () {
  4758. return this.negative !== 0;
  4759. };
  4760. // Return negative clone of `this`
  4761. BN.prototype.neg = function neg () {
  4762. return this.clone().ineg();
  4763. };
  4764. BN.prototype.ineg = function ineg () {
  4765. if (!this.isZero()) {
  4766. this.negative ^= 1;
  4767. }
  4768. return this;
  4769. };
  4770. // Or `num` with `this` in-place
  4771. BN.prototype.iuor = function iuor (num) {
  4772. while (this.length < num.length) {
  4773. this.words[this.length++] = 0;
  4774. }
  4775. for (var i = 0; i < num.length; i++) {
  4776. this.words[i] = this.words[i] | num.words[i];
  4777. }
  4778. return this.strip();
  4779. };
  4780. BN.prototype.ior = function ior (num) {
  4781. assert((this.negative | num.negative) === 0);
  4782. return this.iuor(num);
  4783. };
  4784. // Or `num` with `this`
  4785. BN.prototype.or = function or (num) {
  4786. if (this.length > num.length) return this.clone().ior(num);
  4787. return num.clone().ior(this);
  4788. };
  4789. BN.prototype.uor = function uor (num) {
  4790. if (this.length > num.length) return this.clone().iuor(num);
  4791. return num.clone().iuor(this);
  4792. };
  4793. // And `num` with `this` in-place
  4794. BN.prototype.iuand = function iuand (num) {
  4795. // b = min-length(num, this)
  4796. var b;
  4797. if (this.length > num.length) {
  4798. b = num;
  4799. } else {
  4800. b = this;
  4801. }
  4802. for (var i = 0; i < b.length; i++) {
  4803. this.words[i] = this.words[i] & num.words[i];
  4804. }
  4805. this.length = b.length;
  4806. return this.strip();
  4807. };
  4808. BN.prototype.iand = function iand (num) {
  4809. assert((this.negative | num.negative) === 0);
  4810. return this.iuand(num);
  4811. };
  4812. // And `num` with `this`
  4813. BN.prototype.and = function and (num) {
  4814. if (this.length > num.length) return this.clone().iand(num);
  4815. return num.clone().iand(this);
  4816. };
  4817. BN.prototype.uand = function uand (num) {
  4818. if (this.length > num.length) return this.clone().iuand(num);
  4819. return num.clone().iuand(this);
  4820. };
  4821. // Xor `num` with `this` in-place
  4822. BN.prototype.iuxor = function iuxor (num) {
  4823. // a.length > b.length
  4824. var a;
  4825. var b;
  4826. if (this.length > num.length) {
  4827. a = this;
  4828. b = num;
  4829. } else {
  4830. a = num;
  4831. b = this;
  4832. }
  4833. for (var i = 0; i < b.length; i++) {
  4834. this.words[i] = a.words[i] ^ b.words[i];
  4835. }
  4836. if (this !== a) {
  4837. for (; i < a.length; i++) {
  4838. this.words[i] = a.words[i];
  4839. }
  4840. }
  4841. this.length = a.length;
  4842. return this.strip();
  4843. };
  4844. BN.prototype.ixor = function ixor (num) {
  4845. assert((this.negative | num.negative) === 0);
  4846. return this.iuxor(num);
  4847. };
  4848. // Xor `num` with `this`
  4849. BN.prototype.xor = function xor (num) {
  4850. if (this.length > num.length) return this.clone().ixor(num);
  4851. return num.clone().ixor(this);
  4852. };
  4853. BN.prototype.uxor = function uxor (num) {
  4854. if (this.length > num.length) return this.clone().iuxor(num);
  4855. return num.clone().iuxor(this);
  4856. };
  4857. // Not ``this`` with ``width`` bitwidth
  4858. BN.prototype.inotn = function inotn (width) {
  4859. assert(typeof width === 'number' && width >= 0);
  4860. var bytesNeeded = Math.ceil(width / 26) | 0;
  4861. var bitsLeft = width % 26;
  4862. // Extend the buffer with leading zeroes
  4863. this._expand(bytesNeeded);
  4864. if (bitsLeft > 0) {
  4865. bytesNeeded--;
  4866. }
  4867. // Handle complete words
  4868. for (var i = 0; i < bytesNeeded; i++) {
  4869. this.words[i] = ~this.words[i] & 0x3ffffff;
  4870. }
  4871. // Handle the residue
  4872. if (bitsLeft > 0) {
  4873. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  4874. }
  4875. // And remove leading zeroes
  4876. return this.strip();
  4877. };
  4878. BN.prototype.notn = function notn (width) {
  4879. return this.clone().inotn(width);
  4880. };
  4881. // Set `bit` of `this`
  4882. BN.prototype.setn = function setn (bit, val) {
  4883. assert(typeof bit === 'number' && bit >= 0);
  4884. var off = (bit / 26) | 0;
  4885. var wbit = bit % 26;
  4886. this._expand(off + 1);
  4887. if (val) {
  4888. this.words[off] = this.words[off] | (1 << wbit);
  4889. } else {
  4890. this.words[off] = this.words[off] & ~(1 << wbit);
  4891. }
  4892. return this.strip();
  4893. };
  4894. // Add `num` to `this` in-place
  4895. BN.prototype.iadd = function iadd (num) {
  4896. var r;
  4897. // negative + positive
  4898. if (this.negative !== 0 && num.negative === 0) {
  4899. this.negative = 0;
  4900. r = this.isub(num);
  4901. this.negative ^= 1;
  4902. return this._normSign();
  4903. // positive + negative
  4904. } else if (this.negative === 0 && num.negative !== 0) {
  4905. num.negative = 0;
  4906. r = this.isub(num);
  4907. num.negative = 1;
  4908. return r._normSign();
  4909. }
  4910. // a.length > b.length
  4911. var a, b;
  4912. if (this.length > num.length) {
  4913. a = this;
  4914. b = num;
  4915. } else {
  4916. a = num;
  4917. b = this;
  4918. }
  4919. var carry = 0;
  4920. for (var i = 0; i < b.length; i++) {
  4921. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  4922. this.words[i] = r & 0x3ffffff;
  4923. carry = r >>> 26;
  4924. }
  4925. for (; carry !== 0 && i < a.length; i++) {
  4926. r = (a.words[i] | 0) + carry;
  4927. this.words[i] = r & 0x3ffffff;
  4928. carry = r >>> 26;
  4929. }
  4930. this.length = a.length;
  4931. if (carry !== 0) {
  4932. this.words[this.length] = carry;
  4933. this.length++;
  4934. // Copy the rest of the words
  4935. } else if (a !== this) {
  4936. for (; i < a.length; i++) {
  4937. this.words[i] = a.words[i];
  4938. }
  4939. }
  4940. return this;
  4941. };
  4942. // Add `num` to `this`
  4943. BN.prototype.add = function add (num) {
  4944. var res;
  4945. if (num.negative !== 0 && this.negative === 0) {
  4946. num.negative = 0;
  4947. res = this.sub(num);
  4948. num.negative ^= 1;
  4949. return res;
  4950. } else if (num.negative === 0 && this.negative !== 0) {
  4951. this.negative = 0;
  4952. res = num.sub(this);
  4953. this.negative = 1;
  4954. return res;
  4955. }
  4956. if (this.length > num.length) return this.clone().iadd(num);
  4957. return num.clone().iadd(this);
  4958. };
  4959. // Subtract `num` from `this` in-place
  4960. BN.prototype.isub = function isub (num) {
  4961. // this - (-num) = this + num
  4962. if (num.negative !== 0) {
  4963. num.negative = 0;
  4964. var r = this.iadd(num);
  4965. num.negative = 1;
  4966. return r._normSign();
  4967. // -this - num = -(this + num)
  4968. } else if (this.negative !== 0) {
  4969. this.negative = 0;
  4970. this.iadd(num);
  4971. this.negative = 1;
  4972. return this._normSign();
  4973. }
  4974. // At this point both numbers are positive
  4975. var cmp = this.cmp(num);
  4976. // Optimization - zeroify
  4977. if (cmp === 0) {
  4978. this.negative = 0;
  4979. this.length = 1;
  4980. this.words[0] = 0;
  4981. return this;
  4982. }
  4983. // a > b
  4984. var a, b;
  4985. if (cmp > 0) {
  4986. a = this;
  4987. b = num;
  4988. } else {
  4989. a = num;
  4990. b = this;
  4991. }
  4992. var carry = 0;
  4993. for (var i = 0; i < b.length; i++) {
  4994. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  4995. carry = r >> 26;
  4996. this.words[i] = r & 0x3ffffff;
  4997. }
  4998. for (; carry !== 0 && i < a.length; i++) {
  4999. r = (a.words[i] | 0) + carry;
  5000. carry = r >> 26;
  5001. this.words[i] = r & 0x3ffffff;
  5002. }
  5003. // Copy rest of the words
  5004. if (carry === 0 && i < a.length && a !== this) {
  5005. for (; i < a.length; i++) {
  5006. this.words[i] = a.words[i];
  5007. }
  5008. }
  5009. this.length = Math.max(this.length, i);
  5010. if (a !== this) {
  5011. this.negative = 1;
  5012. }
  5013. return this.strip();
  5014. };
  5015. // Subtract `num` from `this`
  5016. BN.prototype.sub = function sub (num) {
  5017. return this.clone().isub(num);
  5018. };
  5019. function smallMulTo (self, num, out) {
  5020. out.negative = num.negative ^ self.negative;
  5021. var len = (self.length + num.length) | 0;
  5022. out.length = len;
  5023. len = (len - 1) | 0;
  5024. // Peel one iteration (compiler can't do it, because of code complexity)
  5025. var a = self.words[0] | 0;
  5026. var b = num.words[0] | 0;
  5027. var r = a * b;
  5028. var lo = r & 0x3ffffff;
  5029. var carry = (r / 0x4000000) | 0;
  5030. out.words[0] = lo;
  5031. for (var k = 1; k < len; k++) {
  5032. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  5033. // note that ncarry could be >= 0x3ffffff
  5034. var ncarry = carry >>> 26;
  5035. var rword = carry & 0x3ffffff;
  5036. var maxJ = Math.min(k, num.length - 1);
  5037. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  5038. var i = (k - j) | 0;
  5039. a = self.words[i] | 0;
  5040. b = num.words[j] | 0;
  5041. r = a * b + rword;
  5042. ncarry += (r / 0x4000000) | 0;
  5043. rword = r & 0x3ffffff;
  5044. }
  5045. out.words[k] = rword | 0;
  5046. carry = ncarry | 0;
  5047. }
  5048. if (carry !== 0) {
  5049. out.words[k] = carry | 0;
  5050. } else {
  5051. out.length--;
  5052. }
  5053. return out.strip();
  5054. }
  5055. // TODO(indutny): it may be reasonable to omit it for users who don't need
  5056. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  5057. // multiplication (like elliptic secp256k1).
  5058. var comb10MulTo = function comb10MulTo (self, num, out) {
  5059. var a = self.words;
  5060. var b = num.words;
  5061. var o = out.words;
  5062. var c = 0;
  5063. var lo;
  5064. var mid;
  5065. var hi;
  5066. var a0 = a[0] | 0;
  5067. var al0 = a0 & 0x1fff;
  5068. var ah0 = a0 >>> 13;
  5069. var a1 = a[1] | 0;
  5070. var al1 = a1 & 0x1fff;
  5071. var ah1 = a1 >>> 13;
  5072. var a2 = a[2] | 0;
  5073. var al2 = a2 & 0x1fff;
  5074. var ah2 = a2 >>> 13;
  5075. var a3 = a[3] | 0;
  5076. var al3 = a3 & 0x1fff;
  5077. var ah3 = a3 >>> 13;
  5078. var a4 = a[4] | 0;
  5079. var al4 = a4 & 0x1fff;
  5080. var ah4 = a4 >>> 13;
  5081. var a5 = a[5] | 0;
  5082. var al5 = a5 & 0x1fff;
  5083. var ah5 = a5 >>> 13;
  5084. var a6 = a[6] | 0;
  5085. var al6 = a6 & 0x1fff;
  5086. var ah6 = a6 >>> 13;
  5087. var a7 = a[7] | 0;
  5088. var al7 = a7 & 0x1fff;
  5089. var ah7 = a7 >>> 13;
  5090. var a8 = a[8] | 0;
  5091. var al8 = a8 & 0x1fff;
  5092. var ah8 = a8 >>> 13;
  5093. var a9 = a[9] | 0;
  5094. var al9 = a9 & 0x1fff;
  5095. var ah9 = a9 >>> 13;
  5096. var b0 = b[0] | 0;
  5097. var bl0 = b0 & 0x1fff;
  5098. var bh0 = b0 >>> 13;
  5099. var b1 = b[1] | 0;
  5100. var bl1 = b1 & 0x1fff;
  5101. var bh1 = b1 >>> 13;
  5102. var b2 = b[2] | 0;
  5103. var bl2 = b2 & 0x1fff;
  5104. var bh2 = b2 >>> 13;
  5105. var b3 = b[3] | 0;
  5106. var bl3 = b3 & 0x1fff;
  5107. var bh3 = b3 >>> 13;
  5108. var b4 = b[4] | 0;
  5109. var bl4 = b4 & 0x1fff;
  5110. var bh4 = b4 >>> 13;
  5111. var b5 = b[5] | 0;
  5112. var bl5 = b5 & 0x1fff;
  5113. var bh5 = b5 >>> 13;
  5114. var b6 = b[6] | 0;
  5115. var bl6 = b6 & 0x1fff;
  5116. var bh6 = b6 >>> 13;
  5117. var b7 = b[7] | 0;
  5118. var bl7 = b7 & 0x1fff;
  5119. var bh7 = b7 >>> 13;
  5120. var b8 = b[8] | 0;
  5121. var bl8 = b8 & 0x1fff;
  5122. var bh8 = b8 >>> 13;
  5123. var b9 = b[9] | 0;
  5124. var bl9 = b9 & 0x1fff;
  5125. var bh9 = b9 >>> 13;
  5126. out.negative = self.negative ^ num.negative;
  5127. out.length = 19;
  5128. /* k = 0 */
  5129. lo = Math.imul(al0, bl0);
  5130. mid = Math.imul(al0, bh0);
  5131. mid = (mid + Math.imul(ah0, bl0)) | 0;
  5132. hi = Math.imul(ah0, bh0);
  5133. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5134. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  5135. w0 &= 0x3ffffff;
  5136. /* k = 1 */
  5137. lo = Math.imul(al1, bl0);
  5138. mid = Math.imul(al1, bh0);
  5139. mid = (mid + Math.imul(ah1, bl0)) | 0;
  5140. hi = Math.imul(ah1, bh0);
  5141. lo = (lo + Math.imul(al0, bl1)) | 0;
  5142. mid = (mid + Math.imul(al0, bh1)) | 0;
  5143. mid = (mid + Math.imul(ah0, bl1)) | 0;
  5144. hi = (hi + Math.imul(ah0, bh1)) | 0;
  5145. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5146. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  5147. w1 &= 0x3ffffff;
  5148. /* k = 2 */
  5149. lo = Math.imul(al2, bl0);
  5150. mid = Math.imul(al2, bh0);
  5151. mid = (mid + Math.imul(ah2, bl0)) | 0;
  5152. hi = Math.imul(ah2, bh0);
  5153. lo = (lo + Math.imul(al1, bl1)) | 0;
  5154. mid = (mid + Math.imul(al1, bh1)) | 0;
  5155. mid = (mid + Math.imul(ah1, bl1)) | 0;
  5156. hi = (hi + Math.imul(ah1, bh1)) | 0;
  5157. lo = (lo + Math.imul(al0, bl2)) | 0;
  5158. mid = (mid + Math.imul(al0, bh2)) | 0;
  5159. mid = (mid + Math.imul(ah0, bl2)) | 0;
  5160. hi = (hi + Math.imul(ah0, bh2)) | 0;
  5161. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5162. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  5163. w2 &= 0x3ffffff;
  5164. /* k = 3 */
  5165. lo = Math.imul(al3, bl0);
  5166. mid = Math.imul(al3, bh0);
  5167. mid = (mid + Math.imul(ah3, bl0)) | 0;
  5168. hi = Math.imul(ah3, bh0);
  5169. lo = (lo + Math.imul(al2, bl1)) | 0;
  5170. mid = (mid + Math.imul(al2, bh1)) | 0;
  5171. mid = (mid + Math.imul(ah2, bl1)) | 0;
  5172. hi = (hi + Math.imul(ah2, bh1)) | 0;
  5173. lo = (lo + Math.imul(al1, bl2)) | 0;
  5174. mid = (mid + Math.imul(al1, bh2)) | 0;
  5175. mid = (mid + Math.imul(ah1, bl2)) | 0;
  5176. hi = (hi + Math.imul(ah1, bh2)) | 0;
  5177. lo = (lo + Math.imul(al0, bl3)) | 0;
  5178. mid = (mid + Math.imul(al0, bh3)) | 0;
  5179. mid = (mid + Math.imul(ah0, bl3)) | 0;
  5180. hi = (hi + Math.imul(ah0, bh3)) | 0;
  5181. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5182. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  5183. w3 &= 0x3ffffff;
  5184. /* k = 4 */
  5185. lo = Math.imul(al4, bl0);
  5186. mid = Math.imul(al4, bh0);
  5187. mid = (mid + Math.imul(ah4, bl0)) | 0;
  5188. hi = Math.imul(ah4, bh0);
  5189. lo = (lo + Math.imul(al3, bl1)) | 0;
  5190. mid = (mid + Math.imul(al3, bh1)) | 0;
  5191. mid = (mid + Math.imul(ah3, bl1)) | 0;
  5192. hi = (hi + Math.imul(ah3, bh1)) | 0;
  5193. lo = (lo + Math.imul(al2, bl2)) | 0;
  5194. mid = (mid + Math.imul(al2, bh2)) | 0;
  5195. mid = (mid + Math.imul(ah2, bl2)) | 0;
  5196. hi = (hi + Math.imul(ah2, bh2)) | 0;
  5197. lo = (lo + Math.imul(al1, bl3)) | 0;
  5198. mid = (mid + Math.imul(al1, bh3)) | 0;
  5199. mid = (mid + Math.imul(ah1, bl3)) | 0;
  5200. hi = (hi + Math.imul(ah1, bh3)) | 0;
  5201. lo = (lo + Math.imul(al0, bl4)) | 0;
  5202. mid = (mid + Math.imul(al0, bh4)) | 0;
  5203. mid = (mid + Math.imul(ah0, bl4)) | 0;
  5204. hi = (hi + Math.imul(ah0, bh4)) | 0;
  5205. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5206. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  5207. w4 &= 0x3ffffff;
  5208. /* k = 5 */
  5209. lo = Math.imul(al5, bl0);
  5210. mid = Math.imul(al5, bh0);
  5211. mid = (mid + Math.imul(ah5, bl0)) | 0;
  5212. hi = Math.imul(ah5, bh0);
  5213. lo = (lo + Math.imul(al4, bl1)) | 0;
  5214. mid = (mid + Math.imul(al4, bh1)) | 0;
  5215. mid = (mid + Math.imul(ah4, bl1)) | 0;
  5216. hi = (hi + Math.imul(ah4, bh1)) | 0;
  5217. lo = (lo + Math.imul(al3, bl2)) | 0;
  5218. mid = (mid + Math.imul(al3, bh2)) | 0;
  5219. mid = (mid + Math.imul(ah3, bl2)) | 0;
  5220. hi = (hi + Math.imul(ah3, bh2)) | 0;
  5221. lo = (lo + Math.imul(al2, bl3)) | 0;
  5222. mid = (mid + Math.imul(al2, bh3)) | 0;
  5223. mid = (mid + Math.imul(ah2, bl3)) | 0;
  5224. hi = (hi + Math.imul(ah2, bh3)) | 0;
  5225. lo = (lo + Math.imul(al1, bl4)) | 0;
  5226. mid = (mid + Math.imul(al1, bh4)) | 0;
  5227. mid = (mid + Math.imul(ah1, bl4)) | 0;
  5228. hi = (hi + Math.imul(ah1, bh4)) | 0;
  5229. lo = (lo + Math.imul(al0, bl5)) | 0;
  5230. mid = (mid + Math.imul(al0, bh5)) | 0;
  5231. mid = (mid + Math.imul(ah0, bl5)) | 0;
  5232. hi = (hi + Math.imul(ah0, bh5)) | 0;
  5233. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5234. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  5235. w5 &= 0x3ffffff;
  5236. /* k = 6 */
  5237. lo = Math.imul(al6, bl0);
  5238. mid = Math.imul(al6, bh0);
  5239. mid = (mid + Math.imul(ah6, bl0)) | 0;
  5240. hi = Math.imul(ah6, bh0);
  5241. lo = (lo + Math.imul(al5, bl1)) | 0;
  5242. mid = (mid + Math.imul(al5, bh1)) | 0;
  5243. mid = (mid + Math.imul(ah5, bl1)) | 0;
  5244. hi = (hi + Math.imul(ah5, bh1)) | 0;
  5245. lo = (lo + Math.imul(al4, bl2)) | 0;
  5246. mid = (mid + Math.imul(al4, bh2)) | 0;
  5247. mid = (mid + Math.imul(ah4, bl2)) | 0;
  5248. hi = (hi + Math.imul(ah4, bh2)) | 0;
  5249. lo = (lo + Math.imul(al3, bl3)) | 0;
  5250. mid = (mid + Math.imul(al3, bh3)) | 0;
  5251. mid = (mid + Math.imul(ah3, bl3)) | 0;
  5252. hi = (hi + Math.imul(ah3, bh3)) | 0;
  5253. lo = (lo + Math.imul(al2, bl4)) | 0;
  5254. mid = (mid + Math.imul(al2, bh4)) | 0;
  5255. mid = (mid + Math.imul(ah2, bl4)) | 0;
  5256. hi = (hi + Math.imul(ah2, bh4)) | 0;
  5257. lo = (lo + Math.imul(al1, bl5)) | 0;
  5258. mid = (mid + Math.imul(al1, bh5)) | 0;
  5259. mid = (mid + Math.imul(ah1, bl5)) | 0;
  5260. hi = (hi + Math.imul(ah1, bh5)) | 0;
  5261. lo = (lo + Math.imul(al0, bl6)) | 0;
  5262. mid = (mid + Math.imul(al0, bh6)) | 0;
  5263. mid = (mid + Math.imul(ah0, bl6)) | 0;
  5264. hi = (hi + Math.imul(ah0, bh6)) | 0;
  5265. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5266. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  5267. w6 &= 0x3ffffff;
  5268. /* k = 7 */
  5269. lo = Math.imul(al7, bl0);
  5270. mid = Math.imul(al7, bh0);
  5271. mid = (mid + Math.imul(ah7, bl0)) | 0;
  5272. hi = Math.imul(ah7, bh0);
  5273. lo = (lo + Math.imul(al6, bl1)) | 0;
  5274. mid = (mid + Math.imul(al6, bh1)) | 0;
  5275. mid = (mid + Math.imul(ah6, bl1)) | 0;
  5276. hi = (hi + Math.imul(ah6, bh1)) | 0;
  5277. lo = (lo + Math.imul(al5, bl2)) | 0;
  5278. mid = (mid + Math.imul(al5, bh2)) | 0;
  5279. mid = (mid + Math.imul(ah5, bl2)) | 0;
  5280. hi = (hi + Math.imul(ah5, bh2)) | 0;
  5281. lo = (lo + Math.imul(al4, bl3)) | 0;
  5282. mid = (mid + Math.imul(al4, bh3)) | 0;
  5283. mid = (mid + Math.imul(ah4, bl3)) | 0;
  5284. hi = (hi + Math.imul(ah4, bh3)) | 0;
  5285. lo = (lo + Math.imul(al3, bl4)) | 0;
  5286. mid = (mid + Math.imul(al3, bh4)) | 0;
  5287. mid = (mid + Math.imul(ah3, bl4)) | 0;
  5288. hi = (hi + Math.imul(ah3, bh4)) | 0;
  5289. lo = (lo + Math.imul(al2, bl5)) | 0;
  5290. mid = (mid + Math.imul(al2, bh5)) | 0;
  5291. mid = (mid + Math.imul(ah2, bl5)) | 0;
  5292. hi = (hi + Math.imul(ah2, bh5)) | 0;
  5293. lo = (lo + Math.imul(al1, bl6)) | 0;
  5294. mid = (mid + Math.imul(al1, bh6)) | 0;
  5295. mid = (mid + Math.imul(ah1, bl6)) | 0;
  5296. hi = (hi + Math.imul(ah1, bh6)) | 0;
  5297. lo = (lo + Math.imul(al0, bl7)) | 0;
  5298. mid = (mid + Math.imul(al0, bh7)) | 0;
  5299. mid = (mid + Math.imul(ah0, bl7)) | 0;
  5300. hi = (hi + Math.imul(ah0, bh7)) | 0;
  5301. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5302. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  5303. w7 &= 0x3ffffff;
  5304. /* k = 8 */
  5305. lo = Math.imul(al8, bl0);
  5306. mid = Math.imul(al8, bh0);
  5307. mid = (mid + Math.imul(ah8, bl0)) | 0;
  5308. hi = Math.imul(ah8, bh0);
  5309. lo = (lo + Math.imul(al7, bl1)) | 0;
  5310. mid = (mid + Math.imul(al7, bh1)) | 0;
  5311. mid = (mid + Math.imul(ah7, bl1)) | 0;
  5312. hi = (hi + Math.imul(ah7, bh1)) | 0;
  5313. lo = (lo + Math.imul(al6, bl2)) | 0;
  5314. mid = (mid + Math.imul(al6, bh2)) | 0;
  5315. mid = (mid + Math.imul(ah6, bl2)) | 0;
  5316. hi = (hi + Math.imul(ah6, bh2)) | 0;
  5317. lo = (lo + Math.imul(al5, bl3)) | 0;
  5318. mid = (mid + Math.imul(al5, bh3)) | 0;
  5319. mid = (mid + Math.imul(ah5, bl3)) | 0;
  5320. hi = (hi + Math.imul(ah5, bh3)) | 0;
  5321. lo = (lo + Math.imul(al4, bl4)) | 0;
  5322. mid = (mid + Math.imul(al4, bh4)) | 0;
  5323. mid = (mid + Math.imul(ah4, bl4)) | 0;
  5324. hi = (hi + Math.imul(ah4, bh4)) | 0;
  5325. lo = (lo + Math.imul(al3, bl5)) | 0;
  5326. mid = (mid + Math.imul(al3, bh5)) | 0;
  5327. mid = (mid + Math.imul(ah3, bl5)) | 0;
  5328. hi = (hi + Math.imul(ah3, bh5)) | 0;
  5329. lo = (lo + Math.imul(al2, bl6)) | 0;
  5330. mid = (mid + Math.imul(al2, bh6)) | 0;
  5331. mid = (mid + Math.imul(ah2, bl6)) | 0;
  5332. hi = (hi + Math.imul(ah2, bh6)) | 0;
  5333. lo = (lo + Math.imul(al1, bl7)) | 0;
  5334. mid = (mid + Math.imul(al1, bh7)) | 0;
  5335. mid = (mid + Math.imul(ah1, bl7)) | 0;
  5336. hi = (hi + Math.imul(ah1, bh7)) | 0;
  5337. lo = (lo + Math.imul(al0, bl8)) | 0;
  5338. mid = (mid + Math.imul(al0, bh8)) | 0;
  5339. mid = (mid + Math.imul(ah0, bl8)) | 0;
  5340. hi = (hi + Math.imul(ah0, bh8)) | 0;
  5341. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5342. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  5343. w8 &= 0x3ffffff;
  5344. /* k = 9 */
  5345. lo = Math.imul(al9, bl0);
  5346. mid = Math.imul(al9, bh0);
  5347. mid = (mid + Math.imul(ah9, bl0)) | 0;
  5348. hi = Math.imul(ah9, bh0);
  5349. lo = (lo + Math.imul(al8, bl1)) | 0;
  5350. mid = (mid + Math.imul(al8, bh1)) | 0;
  5351. mid = (mid + Math.imul(ah8, bl1)) | 0;
  5352. hi = (hi + Math.imul(ah8, bh1)) | 0;
  5353. lo = (lo + Math.imul(al7, bl2)) | 0;
  5354. mid = (mid + Math.imul(al7, bh2)) | 0;
  5355. mid = (mid + Math.imul(ah7, bl2)) | 0;
  5356. hi = (hi + Math.imul(ah7, bh2)) | 0;
  5357. lo = (lo + Math.imul(al6, bl3)) | 0;
  5358. mid = (mid + Math.imul(al6, bh3)) | 0;
  5359. mid = (mid + Math.imul(ah6, bl3)) | 0;
  5360. hi = (hi + Math.imul(ah6, bh3)) | 0;
  5361. lo = (lo + Math.imul(al5, bl4)) | 0;
  5362. mid = (mid + Math.imul(al5, bh4)) | 0;
  5363. mid = (mid + Math.imul(ah5, bl4)) | 0;
  5364. hi = (hi + Math.imul(ah5, bh4)) | 0;
  5365. lo = (lo + Math.imul(al4, bl5)) | 0;
  5366. mid = (mid + Math.imul(al4, bh5)) | 0;
  5367. mid = (mid + Math.imul(ah4, bl5)) | 0;
  5368. hi = (hi + Math.imul(ah4, bh5)) | 0;
  5369. lo = (lo + Math.imul(al3, bl6)) | 0;
  5370. mid = (mid + Math.imul(al3, bh6)) | 0;
  5371. mid = (mid + Math.imul(ah3, bl6)) | 0;
  5372. hi = (hi + Math.imul(ah3, bh6)) | 0;
  5373. lo = (lo + Math.imul(al2, bl7)) | 0;
  5374. mid = (mid + Math.imul(al2, bh7)) | 0;
  5375. mid = (mid + Math.imul(ah2, bl7)) | 0;
  5376. hi = (hi + Math.imul(ah2, bh7)) | 0;
  5377. lo = (lo + Math.imul(al1, bl8)) | 0;
  5378. mid = (mid + Math.imul(al1, bh8)) | 0;
  5379. mid = (mid + Math.imul(ah1, bl8)) | 0;
  5380. hi = (hi + Math.imul(ah1, bh8)) | 0;
  5381. lo = (lo + Math.imul(al0, bl9)) | 0;
  5382. mid = (mid + Math.imul(al0, bh9)) | 0;
  5383. mid = (mid + Math.imul(ah0, bl9)) | 0;
  5384. hi = (hi + Math.imul(ah0, bh9)) | 0;
  5385. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5386. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  5387. w9 &= 0x3ffffff;
  5388. /* k = 10 */
  5389. lo = Math.imul(al9, bl1);
  5390. mid = Math.imul(al9, bh1);
  5391. mid = (mid + Math.imul(ah9, bl1)) | 0;
  5392. hi = Math.imul(ah9, bh1);
  5393. lo = (lo + Math.imul(al8, bl2)) | 0;
  5394. mid = (mid + Math.imul(al8, bh2)) | 0;
  5395. mid = (mid + Math.imul(ah8, bl2)) | 0;
  5396. hi = (hi + Math.imul(ah8, bh2)) | 0;
  5397. lo = (lo + Math.imul(al7, bl3)) | 0;
  5398. mid = (mid + Math.imul(al7, bh3)) | 0;
  5399. mid = (mid + Math.imul(ah7, bl3)) | 0;
  5400. hi = (hi + Math.imul(ah7, bh3)) | 0;
  5401. lo = (lo + Math.imul(al6, bl4)) | 0;
  5402. mid = (mid + Math.imul(al6, bh4)) | 0;
  5403. mid = (mid + Math.imul(ah6, bl4)) | 0;
  5404. hi = (hi + Math.imul(ah6, bh4)) | 0;
  5405. lo = (lo + Math.imul(al5, bl5)) | 0;
  5406. mid = (mid + Math.imul(al5, bh5)) | 0;
  5407. mid = (mid + Math.imul(ah5, bl5)) | 0;
  5408. hi = (hi + Math.imul(ah5, bh5)) | 0;
  5409. lo = (lo + Math.imul(al4, bl6)) | 0;
  5410. mid = (mid + Math.imul(al4, bh6)) | 0;
  5411. mid = (mid + Math.imul(ah4, bl6)) | 0;
  5412. hi = (hi + Math.imul(ah4, bh6)) | 0;
  5413. lo = (lo + Math.imul(al3, bl7)) | 0;
  5414. mid = (mid + Math.imul(al3, bh7)) | 0;
  5415. mid = (mid + Math.imul(ah3, bl7)) | 0;
  5416. hi = (hi + Math.imul(ah3, bh7)) | 0;
  5417. lo = (lo + Math.imul(al2, bl8)) | 0;
  5418. mid = (mid + Math.imul(al2, bh8)) | 0;
  5419. mid = (mid + Math.imul(ah2, bl8)) | 0;
  5420. hi = (hi + Math.imul(ah2, bh8)) | 0;
  5421. lo = (lo + Math.imul(al1, bl9)) | 0;
  5422. mid = (mid + Math.imul(al1, bh9)) | 0;
  5423. mid = (mid + Math.imul(ah1, bl9)) | 0;
  5424. hi = (hi + Math.imul(ah1, bh9)) | 0;
  5425. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5426. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  5427. w10 &= 0x3ffffff;
  5428. /* k = 11 */
  5429. lo = Math.imul(al9, bl2);
  5430. mid = Math.imul(al9, bh2);
  5431. mid = (mid + Math.imul(ah9, bl2)) | 0;
  5432. hi = Math.imul(ah9, bh2);
  5433. lo = (lo + Math.imul(al8, bl3)) | 0;
  5434. mid = (mid + Math.imul(al8, bh3)) | 0;
  5435. mid = (mid + Math.imul(ah8, bl3)) | 0;
  5436. hi = (hi + Math.imul(ah8, bh3)) | 0;
  5437. lo = (lo + Math.imul(al7, bl4)) | 0;
  5438. mid = (mid + Math.imul(al7, bh4)) | 0;
  5439. mid = (mid + Math.imul(ah7, bl4)) | 0;
  5440. hi = (hi + Math.imul(ah7, bh4)) | 0;
  5441. lo = (lo + Math.imul(al6, bl5)) | 0;
  5442. mid = (mid + Math.imul(al6, bh5)) | 0;
  5443. mid = (mid + Math.imul(ah6, bl5)) | 0;
  5444. hi = (hi + Math.imul(ah6, bh5)) | 0;
  5445. lo = (lo + Math.imul(al5, bl6)) | 0;
  5446. mid = (mid + Math.imul(al5, bh6)) | 0;
  5447. mid = (mid + Math.imul(ah5, bl6)) | 0;
  5448. hi = (hi + Math.imul(ah5, bh6)) | 0;
  5449. lo = (lo + Math.imul(al4, bl7)) | 0;
  5450. mid = (mid + Math.imul(al4, bh7)) | 0;
  5451. mid = (mid + Math.imul(ah4, bl7)) | 0;
  5452. hi = (hi + Math.imul(ah4, bh7)) | 0;
  5453. lo = (lo + Math.imul(al3, bl8)) | 0;
  5454. mid = (mid + Math.imul(al3, bh8)) | 0;
  5455. mid = (mid + Math.imul(ah3, bl8)) | 0;
  5456. hi = (hi + Math.imul(ah3, bh8)) | 0;
  5457. lo = (lo + Math.imul(al2, bl9)) | 0;
  5458. mid = (mid + Math.imul(al2, bh9)) | 0;
  5459. mid = (mid + Math.imul(ah2, bl9)) | 0;
  5460. hi = (hi + Math.imul(ah2, bh9)) | 0;
  5461. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5462. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  5463. w11 &= 0x3ffffff;
  5464. /* k = 12 */
  5465. lo = Math.imul(al9, bl3);
  5466. mid = Math.imul(al9, bh3);
  5467. mid = (mid + Math.imul(ah9, bl3)) | 0;
  5468. hi = Math.imul(ah9, bh3);
  5469. lo = (lo + Math.imul(al8, bl4)) | 0;
  5470. mid = (mid + Math.imul(al8, bh4)) | 0;
  5471. mid = (mid + Math.imul(ah8, bl4)) | 0;
  5472. hi = (hi + Math.imul(ah8, bh4)) | 0;
  5473. lo = (lo + Math.imul(al7, bl5)) | 0;
  5474. mid = (mid + Math.imul(al7, bh5)) | 0;
  5475. mid = (mid + Math.imul(ah7, bl5)) | 0;
  5476. hi = (hi + Math.imul(ah7, bh5)) | 0;
  5477. lo = (lo + Math.imul(al6, bl6)) | 0;
  5478. mid = (mid + Math.imul(al6, bh6)) | 0;
  5479. mid = (mid + Math.imul(ah6, bl6)) | 0;
  5480. hi = (hi + Math.imul(ah6, bh6)) | 0;
  5481. lo = (lo + Math.imul(al5, bl7)) | 0;
  5482. mid = (mid + Math.imul(al5, bh7)) | 0;
  5483. mid = (mid + Math.imul(ah5, bl7)) | 0;
  5484. hi = (hi + Math.imul(ah5, bh7)) | 0;
  5485. lo = (lo + Math.imul(al4, bl8)) | 0;
  5486. mid = (mid + Math.imul(al4, bh8)) | 0;
  5487. mid = (mid + Math.imul(ah4, bl8)) | 0;
  5488. hi = (hi + Math.imul(ah4, bh8)) | 0;
  5489. lo = (lo + Math.imul(al3, bl9)) | 0;
  5490. mid = (mid + Math.imul(al3, bh9)) | 0;
  5491. mid = (mid + Math.imul(ah3, bl9)) | 0;
  5492. hi = (hi + Math.imul(ah3, bh9)) | 0;
  5493. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5494. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  5495. w12 &= 0x3ffffff;
  5496. /* k = 13 */
  5497. lo = Math.imul(al9, bl4);
  5498. mid = Math.imul(al9, bh4);
  5499. mid = (mid + Math.imul(ah9, bl4)) | 0;
  5500. hi = Math.imul(ah9, bh4);
  5501. lo = (lo + Math.imul(al8, bl5)) | 0;
  5502. mid = (mid + Math.imul(al8, bh5)) | 0;
  5503. mid = (mid + Math.imul(ah8, bl5)) | 0;
  5504. hi = (hi + Math.imul(ah8, bh5)) | 0;
  5505. lo = (lo + Math.imul(al7, bl6)) | 0;
  5506. mid = (mid + Math.imul(al7, bh6)) | 0;
  5507. mid = (mid + Math.imul(ah7, bl6)) | 0;
  5508. hi = (hi + Math.imul(ah7, bh6)) | 0;
  5509. lo = (lo + Math.imul(al6, bl7)) | 0;
  5510. mid = (mid + Math.imul(al6, bh7)) | 0;
  5511. mid = (mid + Math.imul(ah6, bl7)) | 0;
  5512. hi = (hi + Math.imul(ah6, bh7)) | 0;
  5513. lo = (lo + Math.imul(al5, bl8)) | 0;
  5514. mid = (mid + Math.imul(al5, bh8)) | 0;
  5515. mid = (mid + Math.imul(ah5, bl8)) | 0;
  5516. hi = (hi + Math.imul(ah5, bh8)) | 0;
  5517. lo = (lo + Math.imul(al4, bl9)) | 0;
  5518. mid = (mid + Math.imul(al4, bh9)) | 0;
  5519. mid = (mid + Math.imul(ah4, bl9)) | 0;
  5520. hi = (hi + Math.imul(ah4, bh9)) | 0;
  5521. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5522. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  5523. w13 &= 0x3ffffff;
  5524. /* k = 14 */
  5525. lo = Math.imul(al9, bl5);
  5526. mid = Math.imul(al9, bh5);
  5527. mid = (mid + Math.imul(ah9, bl5)) | 0;
  5528. hi = Math.imul(ah9, bh5);
  5529. lo = (lo + Math.imul(al8, bl6)) | 0;
  5530. mid = (mid + Math.imul(al8, bh6)) | 0;
  5531. mid = (mid + Math.imul(ah8, bl6)) | 0;
  5532. hi = (hi + Math.imul(ah8, bh6)) | 0;
  5533. lo = (lo + Math.imul(al7, bl7)) | 0;
  5534. mid = (mid + Math.imul(al7, bh7)) | 0;
  5535. mid = (mid + Math.imul(ah7, bl7)) | 0;
  5536. hi = (hi + Math.imul(ah7, bh7)) | 0;
  5537. lo = (lo + Math.imul(al6, bl8)) | 0;
  5538. mid = (mid + Math.imul(al6, bh8)) | 0;
  5539. mid = (mid + Math.imul(ah6, bl8)) | 0;
  5540. hi = (hi + Math.imul(ah6, bh8)) | 0;
  5541. lo = (lo + Math.imul(al5, bl9)) | 0;
  5542. mid = (mid + Math.imul(al5, bh9)) | 0;
  5543. mid = (mid + Math.imul(ah5, bl9)) | 0;
  5544. hi = (hi + Math.imul(ah5, bh9)) | 0;
  5545. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5546. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  5547. w14 &= 0x3ffffff;
  5548. /* k = 15 */
  5549. lo = Math.imul(al9, bl6);
  5550. mid = Math.imul(al9, bh6);
  5551. mid = (mid + Math.imul(ah9, bl6)) | 0;
  5552. hi = Math.imul(ah9, bh6);
  5553. lo = (lo + Math.imul(al8, bl7)) | 0;
  5554. mid = (mid + Math.imul(al8, bh7)) | 0;
  5555. mid = (mid + Math.imul(ah8, bl7)) | 0;
  5556. hi = (hi + Math.imul(ah8, bh7)) | 0;
  5557. lo = (lo + Math.imul(al7, bl8)) | 0;
  5558. mid = (mid + Math.imul(al7, bh8)) | 0;
  5559. mid = (mid + Math.imul(ah7, bl8)) | 0;
  5560. hi = (hi + Math.imul(ah7, bh8)) | 0;
  5561. lo = (lo + Math.imul(al6, bl9)) | 0;
  5562. mid = (mid + Math.imul(al6, bh9)) | 0;
  5563. mid = (mid + Math.imul(ah6, bl9)) | 0;
  5564. hi = (hi + Math.imul(ah6, bh9)) | 0;
  5565. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5566. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  5567. w15 &= 0x3ffffff;
  5568. /* k = 16 */
  5569. lo = Math.imul(al9, bl7);
  5570. mid = Math.imul(al9, bh7);
  5571. mid = (mid + Math.imul(ah9, bl7)) | 0;
  5572. hi = Math.imul(ah9, bh7);
  5573. lo = (lo + Math.imul(al8, bl8)) | 0;
  5574. mid = (mid + Math.imul(al8, bh8)) | 0;
  5575. mid = (mid + Math.imul(ah8, bl8)) | 0;
  5576. hi = (hi + Math.imul(ah8, bh8)) | 0;
  5577. lo = (lo + Math.imul(al7, bl9)) | 0;
  5578. mid = (mid + Math.imul(al7, bh9)) | 0;
  5579. mid = (mid + Math.imul(ah7, bl9)) | 0;
  5580. hi = (hi + Math.imul(ah7, bh9)) | 0;
  5581. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5582. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  5583. w16 &= 0x3ffffff;
  5584. /* k = 17 */
  5585. lo = Math.imul(al9, bl8);
  5586. mid = Math.imul(al9, bh8);
  5587. mid = (mid + Math.imul(ah9, bl8)) | 0;
  5588. hi = Math.imul(ah9, bh8);
  5589. lo = (lo + Math.imul(al8, bl9)) | 0;
  5590. mid = (mid + Math.imul(al8, bh9)) | 0;
  5591. mid = (mid + Math.imul(ah8, bl9)) | 0;
  5592. hi = (hi + Math.imul(ah8, bh9)) | 0;
  5593. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5594. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  5595. w17 &= 0x3ffffff;
  5596. /* k = 18 */
  5597. lo = Math.imul(al9, bl9);
  5598. mid = Math.imul(al9, bh9);
  5599. mid = (mid + Math.imul(ah9, bl9)) | 0;
  5600. hi = Math.imul(ah9, bh9);
  5601. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  5602. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  5603. w18 &= 0x3ffffff;
  5604. o[0] = w0;
  5605. o[1] = w1;
  5606. o[2] = w2;
  5607. o[3] = w3;
  5608. o[4] = w4;
  5609. o[5] = w5;
  5610. o[6] = w6;
  5611. o[7] = w7;
  5612. o[8] = w8;
  5613. o[9] = w9;
  5614. o[10] = w10;
  5615. o[11] = w11;
  5616. o[12] = w12;
  5617. o[13] = w13;
  5618. o[14] = w14;
  5619. o[15] = w15;
  5620. o[16] = w16;
  5621. o[17] = w17;
  5622. o[18] = w18;
  5623. if (c !== 0) {
  5624. o[19] = c;
  5625. out.length++;
  5626. }
  5627. return out;
  5628. };
  5629. // Polyfill comb
  5630. if (!Math.imul) {
  5631. comb10MulTo = smallMulTo;
  5632. }
  5633. function bigMulTo (self, num, out) {
  5634. out.negative = num.negative ^ self.negative;
  5635. out.length = self.length + num.length;
  5636. var carry = 0;
  5637. var hncarry = 0;
  5638. for (var k = 0; k < out.length - 1; k++) {
  5639. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  5640. // note that ncarry could be >= 0x3ffffff
  5641. var ncarry = hncarry;
  5642. hncarry = 0;
  5643. var rword = carry & 0x3ffffff;
  5644. var maxJ = Math.min(k, num.length - 1);
  5645. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  5646. var i = k - j;
  5647. var a = self.words[i] | 0;
  5648. var b = num.words[j] | 0;
  5649. var r = a * b;
  5650. var lo = r & 0x3ffffff;
  5651. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  5652. lo = (lo + rword) | 0;
  5653. rword = lo & 0x3ffffff;
  5654. ncarry = (ncarry + (lo >>> 26)) | 0;
  5655. hncarry += ncarry >>> 26;
  5656. ncarry &= 0x3ffffff;
  5657. }
  5658. out.words[k] = rword;
  5659. carry = ncarry;
  5660. ncarry = hncarry;
  5661. }
  5662. if (carry !== 0) {
  5663. out.words[k] = carry;
  5664. } else {
  5665. out.length--;
  5666. }
  5667. return out.strip();
  5668. }
  5669. function jumboMulTo (self, num, out) {
  5670. var fftm = new FFTM();
  5671. return fftm.mulp(self, num, out);
  5672. }
  5673. BN.prototype.mulTo = function mulTo (num, out) {
  5674. var res;
  5675. var len = this.length + num.length;
  5676. if (this.length === 10 && num.length === 10) {
  5677. res = comb10MulTo(this, num, out);
  5678. } else if (len < 63) {
  5679. res = smallMulTo(this, num, out);
  5680. } else if (len < 1024) {
  5681. res = bigMulTo(this, num, out);
  5682. } else {
  5683. res = jumboMulTo(this, num, out);
  5684. }
  5685. return res;
  5686. };
  5687. // Cooley-Tukey algorithm for FFT
  5688. // slightly revisited to rely on looping instead of recursion
  5689. function FFTM (x, y) {
  5690. this.x = x;
  5691. this.y = y;
  5692. }
  5693. FFTM.prototype.makeRBT = function makeRBT (N) {
  5694. var t = new Array(N);
  5695. var l = BN.prototype._countBits(N) - 1;
  5696. for (var i = 0; i < N; i++) {
  5697. t[i] = this.revBin(i, l, N);
  5698. }
  5699. return t;
  5700. };
  5701. // Returns binary-reversed representation of `x`
  5702. FFTM.prototype.revBin = function revBin (x, l, N) {
  5703. if (x === 0 || x === N - 1) return x;
  5704. var rb = 0;
  5705. for (var i = 0; i < l; i++) {
  5706. rb |= (x & 1) << (l - i - 1);
  5707. x >>= 1;
  5708. }
  5709. return rb;
  5710. };
  5711. // Performs "tweedling" phase, therefore 'emulating'
  5712. // behaviour of the recursive algorithm
  5713. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  5714. for (var i = 0; i < N; i++) {
  5715. rtws[i] = rws[rbt[i]];
  5716. itws[i] = iws[rbt[i]];
  5717. }
  5718. };
  5719. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  5720. this.permute(rbt, rws, iws, rtws, itws, N);
  5721. for (var s = 1; s < N; s <<= 1) {
  5722. var l = s << 1;
  5723. var rtwdf = Math.cos(2 * Math.PI / l);
  5724. var itwdf = Math.sin(2 * Math.PI / l);
  5725. for (var p = 0; p < N; p += l) {
  5726. var rtwdf_ = rtwdf;
  5727. var itwdf_ = itwdf;
  5728. for (var j = 0; j < s; j++) {
  5729. var re = rtws[p + j];
  5730. var ie = itws[p + j];
  5731. var ro = rtws[p + j + s];
  5732. var io = itws[p + j + s];
  5733. var rx = rtwdf_ * ro - itwdf_ * io;
  5734. io = rtwdf_ * io + itwdf_ * ro;
  5735. ro = rx;
  5736. rtws[p + j] = re + ro;
  5737. itws[p + j] = ie + io;
  5738. rtws[p + j + s] = re - ro;
  5739. itws[p + j + s] = ie - io;
  5740. /* jshint maxdepth : false */
  5741. if (j !== l) {
  5742. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  5743. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  5744. rtwdf_ = rx;
  5745. }
  5746. }
  5747. }
  5748. }
  5749. };
  5750. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  5751. var N = Math.max(m, n) | 1;
  5752. var odd = N & 1;
  5753. var i = 0;
  5754. for (N = N / 2 | 0; N; N = N >>> 1) {
  5755. i++;
  5756. }
  5757. return 1 << i + 1 + odd;
  5758. };
  5759. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  5760. if (N <= 1) return;
  5761. for (var i = 0; i < N / 2; i++) {
  5762. var t = rws[i];
  5763. rws[i] = rws[N - i - 1];
  5764. rws[N - i - 1] = t;
  5765. t = iws[i];
  5766. iws[i] = -iws[N - i - 1];
  5767. iws[N - i - 1] = -t;
  5768. }
  5769. };
  5770. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  5771. var carry = 0;
  5772. for (var i = 0; i < N / 2; i++) {
  5773. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  5774. Math.round(ws[2 * i] / N) +
  5775. carry;
  5776. ws[i] = w & 0x3ffffff;
  5777. if (w < 0x4000000) {
  5778. carry = 0;
  5779. } else {
  5780. carry = w / 0x4000000 | 0;
  5781. }
  5782. }
  5783. return ws;
  5784. };
  5785. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  5786. var carry = 0;
  5787. for (var i = 0; i < len; i++) {
  5788. carry = carry + (ws[i] | 0);
  5789. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  5790. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  5791. }
  5792. // Pad with zeroes
  5793. for (i = 2 * len; i < N; ++i) {
  5794. rws[i] = 0;
  5795. }
  5796. assert(carry === 0);
  5797. assert((carry & ~0x1fff) === 0);
  5798. };
  5799. FFTM.prototype.stub = function stub (N) {
  5800. var ph = new Array(N);
  5801. for (var i = 0; i < N; i++) {
  5802. ph[i] = 0;
  5803. }
  5804. return ph;
  5805. };
  5806. FFTM.prototype.mulp = function mulp (x, y, out) {
  5807. var N = 2 * this.guessLen13b(x.length, y.length);
  5808. var rbt = this.makeRBT(N);
  5809. var _ = this.stub(N);
  5810. var rws = new Array(N);
  5811. var rwst = new Array(N);
  5812. var iwst = new Array(N);
  5813. var nrws = new Array(N);
  5814. var nrwst = new Array(N);
  5815. var niwst = new Array(N);
  5816. var rmws = out.words;
  5817. rmws.length = N;
  5818. this.convert13b(x.words, x.length, rws, N);
  5819. this.convert13b(y.words, y.length, nrws, N);
  5820. this.transform(rws, _, rwst, iwst, N, rbt);
  5821. this.transform(nrws, _, nrwst, niwst, N, rbt);
  5822. for (var i = 0; i < N; i++) {
  5823. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  5824. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  5825. rwst[i] = rx;
  5826. }
  5827. this.conjugate(rwst, iwst, N);
  5828. this.transform(rwst, iwst, rmws, _, N, rbt);
  5829. this.conjugate(rmws, _, N);
  5830. this.normalize13b(rmws, N);
  5831. out.negative = x.negative ^ y.negative;
  5832. out.length = x.length + y.length;
  5833. return out.strip();
  5834. };
  5835. // Multiply `this` by `num`
  5836. BN.prototype.mul = function mul (num) {
  5837. var out = new BN(null);
  5838. out.words = new Array(this.length + num.length);
  5839. return this.mulTo(num, out);
  5840. };
  5841. // Multiply employing FFT
  5842. BN.prototype.mulf = function mulf (num) {
  5843. var out = new BN(null);
  5844. out.words = new Array(this.length + num.length);
  5845. return jumboMulTo(this, num, out);
  5846. };
  5847. // In-place Multiplication
  5848. BN.prototype.imul = function imul (num) {
  5849. return this.clone().mulTo(num, this);
  5850. };
  5851. BN.prototype.imuln = function imuln (num) {
  5852. assert(typeof num === 'number');
  5853. assert(num < 0x4000000);
  5854. // Carry
  5855. var carry = 0;
  5856. for (var i = 0; i < this.length; i++) {
  5857. var w = (this.words[i] | 0) * num;
  5858. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  5859. carry >>= 26;
  5860. carry += (w / 0x4000000) | 0;
  5861. // NOTE: lo is 27bit maximum
  5862. carry += lo >>> 26;
  5863. this.words[i] = lo & 0x3ffffff;
  5864. }
  5865. if (carry !== 0) {
  5866. this.words[i] = carry;
  5867. this.length++;
  5868. }
  5869. return this;
  5870. };
  5871. BN.prototype.muln = function muln (num) {
  5872. return this.clone().imuln(num);
  5873. };
  5874. // `this` * `this`
  5875. BN.prototype.sqr = function sqr () {
  5876. return this.mul(this);
  5877. };
  5878. // `this` * `this` in-place
  5879. BN.prototype.isqr = function isqr () {
  5880. return this.imul(this.clone());
  5881. };
  5882. // Math.pow(`this`, `num`)
  5883. BN.prototype.pow = function pow (num) {
  5884. var w = toBitArray(num);
  5885. if (w.length === 0) return new BN(1);
  5886. // Skip leading zeroes
  5887. var res = this;
  5888. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  5889. if (w[i] !== 0) break;
  5890. }
  5891. if (++i < w.length) {
  5892. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  5893. if (w[i] === 0) continue;
  5894. res = res.mul(q);
  5895. }
  5896. }
  5897. return res;
  5898. };
  5899. // Shift-left in-place
  5900. BN.prototype.iushln = function iushln (bits) {
  5901. assert(typeof bits === 'number' && bits >= 0);
  5902. var r = bits % 26;
  5903. var s = (bits - r) / 26;
  5904. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  5905. var i;
  5906. if (r !== 0) {
  5907. var carry = 0;
  5908. for (i = 0; i < this.length; i++) {
  5909. var newCarry = this.words[i] & carryMask;
  5910. var c = ((this.words[i] | 0) - newCarry) << r;
  5911. this.words[i] = c | carry;
  5912. carry = newCarry >>> (26 - r);
  5913. }
  5914. if (carry) {
  5915. this.words[i] = carry;
  5916. this.length++;
  5917. }
  5918. }
  5919. if (s !== 0) {
  5920. for (i = this.length - 1; i >= 0; i--) {
  5921. this.words[i + s] = this.words[i];
  5922. }
  5923. for (i = 0; i < s; i++) {
  5924. this.words[i] = 0;
  5925. }
  5926. this.length += s;
  5927. }
  5928. return this.strip();
  5929. };
  5930. BN.prototype.ishln = function ishln (bits) {
  5931. // TODO(indutny): implement me
  5932. assert(this.negative === 0);
  5933. return this.iushln(bits);
  5934. };
  5935. // Shift-right in-place
  5936. // NOTE: `hint` is a lowest bit before trailing zeroes
  5937. // NOTE: if `extended` is present - it will be filled with destroyed bits
  5938. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  5939. assert(typeof bits === 'number' && bits >= 0);
  5940. var h;
  5941. if (hint) {
  5942. h = (hint - (hint % 26)) / 26;
  5943. } else {
  5944. h = 0;
  5945. }
  5946. var r = bits % 26;
  5947. var s = Math.min((bits - r) / 26, this.length);
  5948. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  5949. var maskedWords = extended;
  5950. h -= s;
  5951. h = Math.max(0, h);
  5952. // Extended mode, copy masked part
  5953. if (maskedWords) {
  5954. for (var i = 0; i < s; i++) {
  5955. maskedWords.words[i] = this.words[i];
  5956. }
  5957. maskedWords.length = s;
  5958. }
  5959. if (s === 0) {
  5960. // No-op, we should not move anything at all
  5961. } else if (this.length > s) {
  5962. this.length -= s;
  5963. for (i = 0; i < this.length; i++) {
  5964. this.words[i] = this.words[i + s];
  5965. }
  5966. } else {
  5967. this.words[0] = 0;
  5968. this.length = 1;
  5969. }
  5970. var carry = 0;
  5971. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  5972. var word = this.words[i] | 0;
  5973. this.words[i] = (carry << (26 - r)) | (word >>> r);
  5974. carry = word & mask;
  5975. }
  5976. // Push carried bits as a mask
  5977. if (maskedWords && carry !== 0) {
  5978. maskedWords.words[maskedWords.length++] = carry;
  5979. }
  5980. if (this.length === 0) {
  5981. this.words[0] = 0;
  5982. this.length = 1;
  5983. }
  5984. return this.strip();
  5985. };
  5986. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  5987. // TODO(indutny): implement me
  5988. assert(this.negative === 0);
  5989. return this.iushrn(bits, hint, extended);
  5990. };
  5991. // Shift-left
  5992. BN.prototype.shln = function shln (bits) {
  5993. return this.clone().ishln(bits);
  5994. };
  5995. BN.prototype.ushln = function ushln (bits) {
  5996. return this.clone().iushln(bits);
  5997. };
  5998. // Shift-right
  5999. BN.prototype.shrn = function shrn (bits) {
  6000. return this.clone().ishrn(bits);
  6001. };
  6002. BN.prototype.ushrn = function ushrn (bits) {
  6003. return this.clone().iushrn(bits);
  6004. };
  6005. // Test if n bit is set
  6006. BN.prototype.testn = function testn (bit) {
  6007. assert(typeof bit === 'number' && bit >= 0);
  6008. var r = bit % 26;
  6009. var s = (bit - r) / 26;
  6010. var q = 1 << r;
  6011. // Fast case: bit is much higher than all existing words
  6012. if (this.length <= s) return false;
  6013. // Check bit and return
  6014. var w = this.words[s];
  6015. return !!(w & q);
  6016. };
  6017. // Return only lowers bits of number (in-place)
  6018. BN.prototype.imaskn = function imaskn (bits) {
  6019. assert(typeof bits === 'number' && bits >= 0);
  6020. var r = bits % 26;
  6021. var s = (bits - r) / 26;
  6022. assert(this.negative === 0, 'imaskn works only with positive numbers');
  6023. if (this.length <= s) {
  6024. return this;
  6025. }
  6026. if (r !== 0) {
  6027. s++;
  6028. }
  6029. this.length = Math.min(s, this.length);
  6030. if (r !== 0) {
  6031. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  6032. this.words[this.length - 1] &= mask;
  6033. }
  6034. return this.strip();
  6035. };
  6036. // Return only lowers bits of number
  6037. BN.prototype.maskn = function maskn (bits) {
  6038. return this.clone().imaskn(bits);
  6039. };
  6040. // Add plain number `num` to `this`
  6041. BN.prototype.iaddn = function iaddn (num) {
  6042. assert(typeof num === 'number');
  6043. assert(num < 0x4000000);
  6044. if (num < 0) return this.isubn(-num);
  6045. // Possible sign change
  6046. if (this.negative !== 0) {
  6047. if (this.length === 1 && (this.words[0] | 0) < num) {
  6048. this.words[0] = num - (this.words[0] | 0);
  6049. this.negative = 0;
  6050. return this;
  6051. }
  6052. this.negative = 0;
  6053. this.isubn(num);
  6054. this.negative = 1;
  6055. return this;
  6056. }
  6057. // Add without checks
  6058. return this._iaddn(num);
  6059. };
  6060. BN.prototype._iaddn = function _iaddn (num) {
  6061. this.words[0] += num;
  6062. // Carry
  6063. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  6064. this.words[i] -= 0x4000000;
  6065. if (i === this.length - 1) {
  6066. this.words[i + 1] = 1;
  6067. } else {
  6068. this.words[i + 1]++;
  6069. }
  6070. }
  6071. this.length = Math.max(this.length, i + 1);
  6072. return this;
  6073. };
  6074. // Subtract plain number `num` from `this`
  6075. BN.prototype.isubn = function isubn (num) {
  6076. assert(typeof num === 'number');
  6077. assert(num < 0x4000000);
  6078. if (num < 0) return this.iaddn(-num);
  6079. if (this.negative !== 0) {
  6080. this.negative = 0;
  6081. this.iaddn(num);
  6082. this.negative = 1;
  6083. return this;
  6084. }
  6085. this.words[0] -= num;
  6086. if (this.length === 1 && this.words[0] < 0) {
  6087. this.words[0] = -this.words[0];
  6088. this.negative = 1;
  6089. } else {
  6090. // Carry
  6091. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  6092. this.words[i] += 0x4000000;
  6093. this.words[i + 1] -= 1;
  6094. }
  6095. }
  6096. return this.strip();
  6097. };
  6098. BN.prototype.addn = function addn (num) {
  6099. return this.clone().iaddn(num);
  6100. };
  6101. BN.prototype.subn = function subn (num) {
  6102. return this.clone().isubn(num);
  6103. };
  6104. BN.prototype.iabs = function iabs () {
  6105. this.negative = 0;
  6106. return this;
  6107. };
  6108. BN.prototype.abs = function abs () {
  6109. return this.clone().iabs();
  6110. };
  6111. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  6112. var len = num.length + shift;
  6113. var i;
  6114. this._expand(len);
  6115. var w;
  6116. var carry = 0;
  6117. for (i = 0; i < num.length; i++) {
  6118. w = (this.words[i + shift] | 0) + carry;
  6119. var right = (num.words[i] | 0) * mul;
  6120. w -= right & 0x3ffffff;
  6121. carry = (w >> 26) - ((right / 0x4000000) | 0);
  6122. this.words[i + shift] = w & 0x3ffffff;
  6123. }
  6124. for (; i < this.length - shift; i++) {
  6125. w = (this.words[i + shift] | 0) + carry;
  6126. carry = w >> 26;
  6127. this.words[i + shift] = w & 0x3ffffff;
  6128. }
  6129. if (carry === 0) return this.strip();
  6130. // Subtraction overflow
  6131. assert(carry === -1);
  6132. carry = 0;
  6133. for (i = 0; i < this.length; i++) {
  6134. w = -(this.words[i] | 0) + carry;
  6135. carry = w >> 26;
  6136. this.words[i] = w & 0x3ffffff;
  6137. }
  6138. this.negative = 1;
  6139. return this.strip();
  6140. };
  6141. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  6142. var shift = this.length - num.length;
  6143. var a = this.clone();
  6144. var b = num;
  6145. // Normalize
  6146. var bhi = b.words[b.length - 1] | 0;
  6147. var bhiBits = this._countBits(bhi);
  6148. shift = 26 - bhiBits;
  6149. if (shift !== 0) {
  6150. b = b.ushln(shift);
  6151. a.iushln(shift);
  6152. bhi = b.words[b.length - 1] | 0;
  6153. }
  6154. // Initialize quotient
  6155. var m = a.length - b.length;
  6156. var q;
  6157. if (mode !== 'mod') {
  6158. q = new BN(null);
  6159. q.length = m + 1;
  6160. q.words = new Array(q.length);
  6161. for (var i = 0; i < q.length; i++) {
  6162. q.words[i] = 0;
  6163. }
  6164. }
  6165. var diff = a.clone()._ishlnsubmul(b, 1, m);
  6166. if (diff.negative === 0) {
  6167. a = diff;
  6168. if (q) {
  6169. q.words[m] = 1;
  6170. }
  6171. }
  6172. for (var j = m - 1; j >= 0; j--) {
  6173. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  6174. (a.words[b.length + j - 1] | 0);
  6175. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  6176. // (0x7ffffff)
  6177. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  6178. a._ishlnsubmul(b, qj, j);
  6179. while (a.negative !== 0) {
  6180. qj--;
  6181. a.negative = 0;
  6182. a._ishlnsubmul(b, 1, j);
  6183. if (!a.isZero()) {
  6184. a.negative ^= 1;
  6185. }
  6186. }
  6187. if (q) {
  6188. q.words[j] = qj;
  6189. }
  6190. }
  6191. if (q) {
  6192. q.strip();
  6193. }
  6194. a.strip();
  6195. // Denormalize
  6196. if (mode !== 'div' && shift !== 0) {
  6197. a.iushrn(shift);
  6198. }
  6199. return {
  6200. div: q || null,
  6201. mod: a
  6202. };
  6203. };
  6204. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  6205. // to `div` to request div only, or be absent to
  6206. // request both div & mod
  6207. // 2) `positive` is true if unsigned mod is requested
  6208. BN.prototype.divmod = function divmod (num, mode, positive) {
  6209. assert(!num.isZero());
  6210. if (this.isZero()) {
  6211. return {
  6212. div: new BN(0),
  6213. mod: new BN(0)
  6214. };
  6215. }
  6216. var div, mod, res;
  6217. if (this.negative !== 0 && num.negative === 0) {
  6218. res = this.neg().divmod(num, mode);
  6219. if (mode !== 'mod') {
  6220. div = res.div.neg();
  6221. }
  6222. if (mode !== 'div') {
  6223. mod = res.mod.neg();
  6224. if (positive && mod.negative !== 0) {
  6225. mod.iadd(num);
  6226. }
  6227. }
  6228. return {
  6229. div: div,
  6230. mod: mod
  6231. };
  6232. }
  6233. if (this.negative === 0 && num.negative !== 0) {
  6234. res = this.divmod(num.neg(), mode);
  6235. if (mode !== 'mod') {
  6236. div = res.div.neg();
  6237. }
  6238. return {
  6239. div: div,
  6240. mod: res.mod
  6241. };
  6242. }
  6243. if ((this.negative & num.negative) !== 0) {
  6244. res = this.neg().divmod(num.neg(), mode);
  6245. if (mode !== 'div') {
  6246. mod = res.mod.neg();
  6247. if (positive && mod.negative !== 0) {
  6248. mod.isub(num);
  6249. }
  6250. }
  6251. return {
  6252. div: res.div,
  6253. mod: mod
  6254. };
  6255. }
  6256. // Both numbers are positive at this point
  6257. // Strip both numbers to approximate shift value
  6258. if (num.length > this.length || this.cmp(num) < 0) {
  6259. return {
  6260. div: new BN(0),
  6261. mod: this
  6262. };
  6263. }
  6264. // Very short reduction
  6265. if (num.length === 1) {
  6266. if (mode === 'div') {
  6267. return {
  6268. div: this.divn(num.words[0]),
  6269. mod: null
  6270. };
  6271. }
  6272. if (mode === 'mod') {
  6273. return {
  6274. div: null,
  6275. mod: new BN(this.modn(num.words[0]))
  6276. };
  6277. }
  6278. return {
  6279. div: this.divn(num.words[0]),
  6280. mod: new BN(this.modn(num.words[0]))
  6281. };
  6282. }
  6283. return this._wordDiv(num, mode);
  6284. };
  6285. // Find `this` / `num`
  6286. BN.prototype.div = function div (num) {
  6287. return this.divmod(num, 'div', false).div;
  6288. };
  6289. // Find `this` % `num`
  6290. BN.prototype.mod = function mod (num) {
  6291. return this.divmod(num, 'mod', false).mod;
  6292. };
  6293. BN.prototype.umod = function umod (num) {
  6294. return this.divmod(num, 'mod', true).mod;
  6295. };
  6296. // Find Round(`this` / `num`)
  6297. BN.prototype.divRound = function divRound (num) {
  6298. var dm = this.divmod(num);
  6299. // Fast case - exact division
  6300. if (dm.mod.isZero()) return dm.div;
  6301. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  6302. var half = num.ushrn(1);
  6303. var r2 = num.andln(1);
  6304. var cmp = mod.cmp(half);
  6305. // Round down
  6306. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  6307. // Round up
  6308. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  6309. };
  6310. BN.prototype.modn = function modn (num) {
  6311. assert(num <= 0x3ffffff);
  6312. var p = (1 << 26) % num;
  6313. var acc = 0;
  6314. for (var i = this.length - 1; i >= 0; i--) {
  6315. acc = (p * acc + (this.words[i] | 0)) % num;
  6316. }
  6317. return acc;
  6318. };
  6319. // In-place division by number
  6320. BN.prototype.idivn = function idivn (num) {
  6321. assert(num <= 0x3ffffff);
  6322. var carry = 0;
  6323. for (var i = this.length - 1; i >= 0; i--) {
  6324. var w = (this.words[i] | 0) + carry * 0x4000000;
  6325. this.words[i] = (w / num) | 0;
  6326. carry = w % num;
  6327. }
  6328. return this.strip();
  6329. };
  6330. BN.prototype.divn = function divn (num) {
  6331. return this.clone().idivn(num);
  6332. };
  6333. BN.prototype.egcd = function egcd (p) {
  6334. assert(p.negative === 0);
  6335. assert(!p.isZero());
  6336. var x = this;
  6337. var y = p.clone();
  6338. if (x.negative !== 0) {
  6339. x = x.umod(p);
  6340. } else {
  6341. x = x.clone();
  6342. }
  6343. // A * x + B * y = x
  6344. var A = new BN(1);
  6345. var B = new BN(0);
  6346. // C * x + D * y = y
  6347. var C = new BN(0);
  6348. var D = new BN(1);
  6349. var g = 0;
  6350. while (x.isEven() && y.isEven()) {
  6351. x.iushrn(1);
  6352. y.iushrn(1);
  6353. ++g;
  6354. }
  6355. var yp = y.clone();
  6356. var xp = x.clone();
  6357. while (!x.isZero()) {
  6358. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  6359. if (i > 0) {
  6360. x.iushrn(i);
  6361. while (i-- > 0) {
  6362. if (A.isOdd() || B.isOdd()) {
  6363. A.iadd(yp);
  6364. B.isub(xp);
  6365. }
  6366. A.iushrn(1);
  6367. B.iushrn(1);
  6368. }
  6369. }
  6370. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  6371. if (j > 0) {
  6372. y.iushrn(j);
  6373. while (j-- > 0) {
  6374. if (C.isOdd() || D.isOdd()) {
  6375. C.iadd(yp);
  6376. D.isub(xp);
  6377. }
  6378. C.iushrn(1);
  6379. D.iushrn(1);
  6380. }
  6381. }
  6382. if (x.cmp(y) >= 0) {
  6383. x.isub(y);
  6384. A.isub(C);
  6385. B.isub(D);
  6386. } else {
  6387. y.isub(x);
  6388. C.isub(A);
  6389. D.isub(B);
  6390. }
  6391. }
  6392. return {
  6393. a: C,
  6394. b: D,
  6395. gcd: y.iushln(g)
  6396. };
  6397. };
  6398. // This is reduced incarnation of the binary EEA
  6399. // above, designated to invert members of the
  6400. // _prime_ fields F(p) at a maximal speed
  6401. BN.prototype._invmp = function _invmp (p) {
  6402. assert(p.negative === 0);
  6403. assert(!p.isZero());
  6404. var a = this;
  6405. var b = p.clone();
  6406. if (a.negative !== 0) {
  6407. a = a.umod(p);
  6408. } else {
  6409. a = a.clone();
  6410. }
  6411. var x1 = new BN(1);
  6412. var x2 = new BN(0);
  6413. var delta = b.clone();
  6414. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  6415. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  6416. if (i > 0) {
  6417. a.iushrn(i);
  6418. while (i-- > 0) {
  6419. if (x1.isOdd()) {
  6420. x1.iadd(delta);
  6421. }
  6422. x1.iushrn(1);
  6423. }
  6424. }
  6425. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  6426. if (j > 0) {
  6427. b.iushrn(j);
  6428. while (j-- > 0) {
  6429. if (x2.isOdd()) {
  6430. x2.iadd(delta);
  6431. }
  6432. x2.iushrn(1);
  6433. }
  6434. }
  6435. if (a.cmp(b) >= 0) {
  6436. a.isub(b);
  6437. x1.isub(x2);
  6438. } else {
  6439. b.isub(a);
  6440. x2.isub(x1);
  6441. }
  6442. }
  6443. var res;
  6444. if (a.cmpn(1) === 0) {
  6445. res = x1;
  6446. } else {
  6447. res = x2;
  6448. }
  6449. if (res.cmpn(0) < 0) {
  6450. res.iadd(p);
  6451. }
  6452. return res;
  6453. };
  6454. BN.prototype.gcd = function gcd (num) {
  6455. if (this.isZero()) return num.abs();
  6456. if (num.isZero()) return this.abs();
  6457. var a = this.clone();
  6458. var b = num.clone();
  6459. a.negative = 0;
  6460. b.negative = 0;
  6461. // Remove common factor of two
  6462. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  6463. a.iushrn(1);
  6464. b.iushrn(1);
  6465. }
  6466. do {
  6467. while (a.isEven()) {
  6468. a.iushrn(1);
  6469. }
  6470. while (b.isEven()) {
  6471. b.iushrn(1);
  6472. }
  6473. var r = a.cmp(b);
  6474. if (r < 0) {
  6475. // Swap `a` and `b` to make `a` always bigger than `b`
  6476. var t = a;
  6477. a = b;
  6478. b = t;
  6479. } else if (r === 0 || b.cmpn(1) === 0) {
  6480. break;
  6481. }
  6482. a.isub(b);
  6483. } while (true);
  6484. return b.iushln(shift);
  6485. };
  6486. // Invert number in the field F(num)
  6487. BN.prototype.invm = function invm (num) {
  6488. return this.egcd(num).a.umod(num);
  6489. };
  6490. BN.prototype.isEven = function isEven () {
  6491. return (this.words[0] & 1) === 0;
  6492. };
  6493. BN.prototype.isOdd = function isOdd () {
  6494. return (this.words[0] & 1) === 1;
  6495. };
  6496. // And first word and num
  6497. BN.prototype.andln = function andln (num) {
  6498. return this.words[0] & num;
  6499. };
  6500. // Increment at the bit position in-line
  6501. BN.prototype.bincn = function bincn (bit) {
  6502. assert(typeof bit === 'number');
  6503. var r = bit % 26;
  6504. var s = (bit - r) / 26;
  6505. var q = 1 << r;
  6506. // Fast case: bit is much higher than all existing words
  6507. if (this.length <= s) {
  6508. this._expand(s + 1);
  6509. this.words[s] |= q;
  6510. return this;
  6511. }
  6512. // Add bit and propagate, if needed
  6513. var carry = q;
  6514. for (var i = s; carry !== 0 && i < this.length; i++) {
  6515. var w = this.words[i] | 0;
  6516. w += carry;
  6517. carry = w >>> 26;
  6518. w &= 0x3ffffff;
  6519. this.words[i] = w;
  6520. }
  6521. if (carry !== 0) {
  6522. this.words[i] = carry;
  6523. this.length++;
  6524. }
  6525. return this;
  6526. };
  6527. BN.prototype.isZero = function isZero () {
  6528. return this.length === 1 && this.words[0] === 0;
  6529. };
  6530. BN.prototype.cmpn = function cmpn (num) {
  6531. var negative = num < 0;
  6532. if (this.negative !== 0 && !negative) return -1;
  6533. if (this.negative === 0 && negative) return 1;
  6534. this.strip();
  6535. var res;
  6536. if (this.length > 1) {
  6537. res = 1;
  6538. } else {
  6539. if (negative) {
  6540. num = -num;
  6541. }
  6542. assert(num <= 0x3ffffff, 'Number is too big');
  6543. var w = this.words[0] | 0;
  6544. res = w === num ? 0 : w < num ? -1 : 1;
  6545. }
  6546. if (this.negative !== 0) return -res | 0;
  6547. return res;
  6548. };
  6549. // Compare two numbers and return:
  6550. // 1 - if `this` > `num`
  6551. // 0 - if `this` == `num`
  6552. // -1 - if `this` < `num`
  6553. BN.prototype.cmp = function cmp (num) {
  6554. if (this.negative !== 0 && num.negative === 0) return -1;
  6555. if (this.negative === 0 && num.negative !== 0) return 1;
  6556. var res = this.ucmp(num);
  6557. if (this.negative !== 0) return -res | 0;
  6558. return res;
  6559. };
  6560. // Unsigned comparison
  6561. BN.prototype.ucmp = function ucmp (num) {
  6562. // At this point both numbers have the same sign
  6563. if (this.length > num.length) return 1;
  6564. if (this.length < num.length) return -1;
  6565. var res = 0;
  6566. for (var i = this.length - 1; i >= 0; i--) {
  6567. var a = this.words[i] | 0;
  6568. var b = num.words[i] | 0;
  6569. if (a === b) continue;
  6570. if (a < b) {
  6571. res = -1;
  6572. } else if (a > b) {
  6573. res = 1;
  6574. }
  6575. break;
  6576. }
  6577. return res;
  6578. };
  6579. BN.prototype.gtn = function gtn (num) {
  6580. return this.cmpn(num) === 1;
  6581. };
  6582. BN.prototype.gt = function gt (num) {
  6583. return this.cmp(num) === 1;
  6584. };
  6585. BN.prototype.gten = function gten (num) {
  6586. return this.cmpn(num) >= 0;
  6587. };
  6588. BN.prototype.gte = function gte (num) {
  6589. return this.cmp(num) >= 0;
  6590. };
  6591. BN.prototype.ltn = function ltn (num) {
  6592. return this.cmpn(num) === -1;
  6593. };
  6594. BN.prototype.lt = function lt (num) {
  6595. return this.cmp(num) === -1;
  6596. };
  6597. BN.prototype.lten = function lten (num) {
  6598. return this.cmpn(num) <= 0;
  6599. };
  6600. BN.prototype.lte = function lte (num) {
  6601. return this.cmp(num) <= 0;
  6602. };
  6603. BN.prototype.eqn = function eqn (num) {
  6604. return this.cmpn(num) === 0;
  6605. };
  6606. BN.prototype.eq = function eq (num) {
  6607. return this.cmp(num) === 0;
  6608. };
  6609. //
  6610. // A reduce context, could be using montgomery or something better, depending
  6611. // on the `m` itself.
  6612. //
  6613. BN.red = function red (num) {
  6614. return new Red(num);
  6615. };
  6616. BN.prototype.toRed = function toRed (ctx) {
  6617. assert(!this.red, 'Already a number in reduction context');
  6618. assert(this.negative === 0, 'red works only with positives');
  6619. return ctx.convertTo(this)._forceRed(ctx);
  6620. };
  6621. BN.prototype.fromRed = function fromRed () {
  6622. assert(this.red, 'fromRed works only with numbers in reduction context');
  6623. return this.red.convertFrom(this);
  6624. };
  6625. BN.prototype._forceRed = function _forceRed (ctx) {
  6626. this.red = ctx;
  6627. return this;
  6628. };
  6629. BN.prototype.forceRed = function forceRed (ctx) {
  6630. assert(!this.red, 'Already a number in reduction context');
  6631. return this._forceRed(ctx);
  6632. };
  6633. BN.prototype.redAdd = function redAdd (num) {
  6634. assert(this.red, 'redAdd works only with red numbers');
  6635. return this.red.add(this, num);
  6636. };
  6637. BN.prototype.redIAdd = function redIAdd (num) {
  6638. assert(this.red, 'redIAdd works only with red numbers');
  6639. return this.red.iadd(this, num);
  6640. };
  6641. BN.prototype.redSub = function redSub (num) {
  6642. assert(this.red, 'redSub works only with red numbers');
  6643. return this.red.sub(this, num);
  6644. };
  6645. BN.prototype.redISub = function redISub (num) {
  6646. assert(this.red, 'redISub works only with red numbers');
  6647. return this.red.isub(this, num);
  6648. };
  6649. BN.prototype.redShl = function redShl (num) {
  6650. assert(this.red, 'redShl works only with red numbers');
  6651. return this.red.shl(this, num);
  6652. };
  6653. BN.prototype.redMul = function redMul (num) {
  6654. assert(this.red, 'redMul works only with red numbers');
  6655. this.red._verify2(this, num);
  6656. return this.red.mul(this, num);
  6657. };
  6658. BN.prototype.redIMul = function redIMul (num) {
  6659. assert(this.red, 'redMul works only with red numbers');
  6660. this.red._verify2(this, num);
  6661. return this.red.imul(this, num);
  6662. };
  6663. BN.prototype.redSqr = function redSqr () {
  6664. assert(this.red, 'redSqr works only with red numbers');
  6665. this.red._verify1(this);
  6666. return this.red.sqr(this);
  6667. };
  6668. BN.prototype.redISqr = function redISqr () {
  6669. assert(this.red, 'redISqr works only with red numbers');
  6670. this.red._verify1(this);
  6671. return this.red.isqr(this);
  6672. };
  6673. // Square root over p
  6674. BN.prototype.redSqrt = function redSqrt () {
  6675. assert(this.red, 'redSqrt works only with red numbers');
  6676. this.red._verify1(this);
  6677. return this.red.sqrt(this);
  6678. };
  6679. BN.prototype.redInvm = function redInvm () {
  6680. assert(this.red, 'redInvm works only with red numbers');
  6681. this.red._verify1(this);
  6682. return this.red.invm(this);
  6683. };
  6684. // Return negative clone of `this` % `red modulo`
  6685. BN.prototype.redNeg = function redNeg () {
  6686. assert(this.red, 'redNeg works only with red numbers');
  6687. this.red._verify1(this);
  6688. return this.red.neg(this);
  6689. };
  6690. BN.prototype.redPow = function redPow (num) {
  6691. assert(this.red && !num.red, 'redPow(normalNum)');
  6692. this.red._verify1(this);
  6693. return this.red.pow(this, num);
  6694. };
  6695. // Prime numbers with efficient reduction
  6696. var primes = {
  6697. k256: null,
  6698. p224: null,
  6699. p192: null,
  6700. p25519: null
  6701. };
  6702. // Pseudo-Mersenne prime
  6703. function MPrime (name, p) {
  6704. // P = 2 ^ N - K
  6705. this.name = name;
  6706. this.p = new BN(p, 16);
  6707. this.n = this.p.bitLength();
  6708. this.k = new BN(1).iushln(this.n).isub(this.p);
  6709. this.tmp = this._tmp();
  6710. }
  6711. MPrime.prototype._tmp = function _tmp () {
  6712. var tmp = new BN(null);
  6713. tmp.words = new Array(Math.ceil(this.n / 13));
  6714. return tmp;
  6715. };
  6716. MPrime.prototype.ireduce = function ireduce (num) {
  6717. // Assumes that `num` is less than `P^2`
  6718. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  6719. var r = num;
  6720. var rlen;
  6721. do {
  6722. this.split(r, this.tmp);
  6723. r = this.imulK(r);
  6724. r = r.iadd(this.tmp);
  6725. rlen = r.bitLength();
  6726. } while (rlen > this.n);
  6727. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  6728. if (cmp === 0) {
  6729. r.words[0] = 0;
  6730. r.length = 1;
  6731. } else if (cmp > 0) {
  6732. r.isub(this.p);
  6733. } else {
  6734. if (r.strip !== undefined) {
  6735. // r is BN v4 instance
  6736. r.strip();
  6737. } else {
  6738. // r is BN v5 instance
  6739. r._strip();
  6740. }
  6741. }
  6742. return r;
  6743. };
  6744. MPrime.prototype.split = function split (input, out) {
  6745. input.iushrn(this.n, 0, out);
  6746. };
  6747. MPrime.prototype.imulK = function imulK (num) {
  6748. return num.imul(this.k);
  6749. };
  6750. function K256 () {
  6751. MPrime.call(
  6752. this,
  6753. 'k256',
  6754. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  6755. }
  6756. inherits(K256, MPrime);
  6757. K256.prototype.split = function split (input, output) {
  6758. // 256 = 9 * 26 + 22
  6759. var mask = 0x3fffff;
  6760. var outLen = Math.min(input.length, 9);
  6761. for (var i = 0; i < outLen; i++) {
  6762. output.words[i] = input.words[i];
  6763. }
  6764. output.length = outLen;
  6765. if (input.length <= 9) {
  6766. input.words[0] = 0;
  6767. input.length = 1;
  6768. return;
  6769. }
  6770. // Shift by 9 limbs
  6771. var prev = input.words[9];
  6772. output.words[output.length++] = prev & mask;
  6773. for (i = 10; i < input.length; i++) {
  6774. var next = input.words[i] | 0;
  6775. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  6776. prev = next;
  6777. }
  6778. prev >>>= 22;
  6779. input.words[i - 10] = prev;
  6780. if (prev === 0 && input.length > 10) {
  6781. input.length -= 10;
  6782. } else {
  6783. input.length -= 9;
  6784. }
  6785. };
  6786. K256.prototype.imulK = function imulK (num) {
  6787. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  6788. num.words[num.length] = 0;
  6789. num.words[num.length + 1] = 0;
  6790. num.length += 2;
  6791. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  6792. var lo = 0;
  6793. for (var i = 0; i < num.length; i++) {
  6794. var w = num.words[i] | 0;
  6795. lo += w * 0x3d1;
  6796. num.words[i] = lo & 0x3ffffff;
  6797. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  6798. }
  6799. // Fast length reduction
  6800. if (num.words[num.length - 1] === 0) {
  6801. num.length--;
  6802. if (num.words[num.length - 1] === 0) {
  6803. num.length--;
  6804. }
  6805. }
  6806. return num;
  6807. };
  6808. function P224 () {
  6809. MPrime.call(
  6810. this,
  6811. 'p224',
  6812. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  6813. }
  6814. inherits(P224, MPrime);
  6815. function P192 () {
  6816. MPrime.call(
  6817. this,
  6818. 'p192',
  6819. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  6820. }
  6821. inherits(P192, MPrime);
  6822. function P25519 () {
  6823. // 2 ^ 255 - 19
  6824. MPrime.call(
  6825. this,
  6826. '25519',
  6827. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  6828. }
  6829. inherits(P25519, MPrime);
  6830. P25519.prototype.imulK = function imulK (num) {
  6831. // K = 0x13
  6832. var carry = 0;
  6833. for (var i = 0; i < num.length; i++) {
  6834. var hi = (num.words[i] | 0) * 0x13 + carry;
  6835. var lo = hi & 0x3ffffff;
  6836. hi >>>= 26;
  6837. num.words[i] = lo;
  6838. carry = hi;
  6839. }
  6840. if (carry !== 0) {
  6841. num.words[num.length++] = carry;
  6842. }
  6843. return num;
  6844. };
  6845. // Exported mostly for testing purposes, use plain name instead
  6846. BN._prime = function prime (name) {
  6847. // Cached version of prime
  6848. if (primes[name]) return primes[name];
  6849. var prime;
  6850. if (name === 'k256') {
  6851. prime = new K256();
  6852. } else if (name === 'p224') {
  6853. prime = new P224();
  6854. } else if (name === 'p192') {
  6855. prime = new P192();
  6856. } else if (name === 'p25519') {
  6857. prime = new P25519();
  6858. } else {
  6859. throw new Error('Unknown prime ' + name);
  6860. }
  6861. primes[name] = prime;
  6862. return prime;
  6863. };
  6864. //
  6865. // Base reduction engine
  6866. //
  6867. function Red (m) {
  6868. if (typeof m === 'string') {
  6869. var prime = BN._prime(m);
  6870. this.m = prime.p;
  6871. this.prime = prime;
  6872. } else {
  6873. assert(m.gtn(1), 'modulus must be greater than 1');
  6874. this.m = m;
  6875. this.prime = null;
  6876. }
  6877. }
  6878. Red.prototype._verify1 = function _verify1 (a) {
  6879. assert(a.negative === 0, 'red works only with positives');
  6880. assert(a.red, 'red works only with red numbers');
  6881. };
  6882. Red.prototype._verify2 = function _verify2 (a, b) {
  6883. assert((a.negative | b.negative) === 0, 'red works only with positives');
  6884. assert(a.red && a.red === b.red,
  6885. 'red works only with red numbers');
  6886. };
  6887. Red.prototype.imod = function imod (a) {
  6888. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  6889. return a.umod(this.m)._forceRed(this);
  6890. };
  6891. Red.prototype.neg = function neg (a) {
  6892. if (a.isZero()) {
  6893. return a.clone();
  6894. }
  6895. return this.m.sub(a)._forceRed(this);
  6896. };
  6897. Red.prototype.add = function add (a, b) {
  6898. this._verify2(a, b);
  6899. var res = a.add(b);
  6900. if (res.cmp(this.m) >= 0) {
  6901. res.isub(this.m);
  6902. }
  6903. return res._forceRed(this);
  6904. };
  6905. Red.prototype.iadd = function iadd (a, b) {
  6906. this._verify2(a, b);
  6907. var res = a.iadd(b);
  6908. if (res.cmp(this.m) >= 0) {
  6909. res.isub(this.m);
  6910. }
  6911. return res;
  6912. };
  6913. Red.prototype.sub = function sub (a, b) {
  6914. this._verify2(a, b);
  6915. var res = a.sub(b);
  6916. if (res.cmpn(0) < 0) {
  6917. res.iadd(this.m);
  6918. }
  6919. return res._forceRed(this);
  6920. };
  6921. Red.prototype.isub = function isub (a, b) {
  6922. this._verify2(a, b);
  6923. var res = a.isub(b);
  6924. if (res.cmpn(0) < 0) {
  6925. res.iadd(this.m);
  6926. }
  6927. return res;
  6928. };
  6929. Red.prototype.shl = function shl (a, num) {
  6930. this._verify1(a);
  6931. return this.imod(a.ushln(num));
  6932. };
  6933. Red.prototype.imul = function imul (a, b) {
  6934. this._verify2(a, b);
  6935. return this.imod(a.imul(b));
  6936. };
  6937. Red.prototype.mul = function mul (a, b) {
  6938. this._verify2(a, b);
  6939. return this.imod(a.mul(b));
  6940. };
  6941. Red.prototype.isqr = function isqr (a) {
  6942. return this.imul(a, a.clone());
  6943. };
  6944. Red.prototype.sqr = function sqr (a) {
  6945. return this.mul(a, a);
  6946. };
  6947. Red.prototype.sqrt = function sqrt (a) {
  6948. if (a.isZero()) return a.clone();
  6949. var mod3 = this.m.andln(3);
  6950. assert(mod3 % 2 === 1);
  6951. // Fast case
  6952. if (mod3 === 3) {
  6953. var pow = this.m.add(new BN(1)).iushrn(2);
  6954. return this.pow(a, pow);
  6955. }
  6956. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  6957. //
  6958. // Find Q and S, that Q * 2 ^ S = (P - 1)
  6959. var q = this.m.subn(1);
  6960. var s = 0;
  6961. while (!q.isZero() && q.andln(1) === 0) {
  6962. s++;
  6963. q.iushrn(1);
  6964. }
  6965. assert(!q.isZero());
  6966. var one = new BN(1).toRed(this);
  6967. var nOne = one.redNeg();
  6968. // Find quadratic non-residue
  6969. // NOTE: Max is such because of generalized Riemann hypothesis.
  6970. var lpow = this.m.subn(1).iushrn(1);
  6971. var z = this.m.bitLength();
  6972. z = new BN(2 * z * z).toRed(this);
  6973. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  6974. z.redIAdd(nOne);
  6975. }
  6976. var c = this.pow(z, q);
  6977. var r = this.pow(a, q.addn(1).iushrn(1));
  6978. var t = this.pow(a, q);
  6979. var m = s;
  6980. while (t.cmp(one) !== 0) {
  6981. var tmp = t;
  6982. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  6983. tmp = tmp.redSqr();
  6984. }
  6985. assert(i < m);
  6986. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  6987. r = r.redMul(b);
  6988. c = b.redSqr();
  6989. t = t.redMul(c);
  6990. m = i;
  6991. }
  6992. return r;
  6993. };
  6994. Red.prototype.invm = function invm (a) {
  6995. var inv = a._invmp(this.m);
  6996. if (inv.negative !== 0) {
  6997. inv.negative = 0;
  6998. return this.imod(inv).redNeg();
  6999. } else {
  7000. return this.imod(inv);
  7001. }
  7002. };
  7003. Red.prototype.pow = function pow (a, num) {
  7004. if (num.isZero()) return new BN(1).toRed(this);
  7005. if (num.cmpn(1) === 0) return a.clone();
  7006. var windowSize = 4;
  7007. var wnd = new Array(1 << windowSize);
  7008. wnd[0] = new BN(1).toRed(this);
  7009. wnd[1] = a;
  7010. for (var i = 2; i < wnd.length; i++) {
  7011. wnd[i] = this.mul(wnd[i - 1], a);
  7012. }
  7013. var res = wnd[0];
  7014. var current = 0;
  7015. var currentLen = 0;
  7016. var start = num.bitLength() % 26;
  7017. if (start === 0) {
  7018. start = 26;
  7019. }
  7020. for (i = num.length - 1; i >= 0; i--) {
  7021. var word = num.words[i];
  7022. for (var j = start - 1; j >= 0; j--) {
  7023. var bit = (word >> j) & 1;
  7024. if (res !== wnd[0]) {
  7025. res = this.sqr(res);
  7026. }
  7027. if (bit === 0 && current === 0) {
  7028. currentLen = 0;
  7029. continue;
  7030. }
  7031. current <<= 1;
  7032. current |= bit;
  7033. currentLen++;
  7034. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  7035. res = this.mul(res, wnd[current]);
  7036. currentLen = 0;
  7037. current = 0;
  7038. }
  7039. start = 26;
  7040. }
  7041. return res;
  7042. };
  7043. Red.prototype.convertTo = function convertTo (num) {
  7044. var r = num.umod(this.m);
  7045. return r === num ? r.clone() : r;
  7046. };
  7047. Red.prototype.convertFrom = function convertFrom (num) {
  7048. var res = num.clone();
  7049. res.red = null;
  7050. return res;
  7051. };
  7052. //
  7053. // Montgomery method engine
  7054. //
  7055. BN.mont = function mont (num) {
  7056. return new Mont(num);
  7057. };
  7058. function Mont (m) {
  7059. Red.call(this, m);
  7060. this.shift = this.m.bitLength();
  7061. if (this.shift % 26 !== 0) {
  7062. this.shift += 26 - (this.shift % 26);
  7063. }
  7064. this.r = new BN(1).iushln(this.shift);
  7065. this.r2 = this.imod(this.r.sqr());
  7066. this.rinv = this.r._invmp(this.m);
  7067. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  7068. this.minv = this.minv.umod(this.r);
  7069. this.minv = this.r.sub(this.minv);
  7070. }
  7071. inherits(Mont, Red);
  7072. Mont.prototype.convertTo = function convertTo (num) {
  7073. return this.imod(num.ushln(this.shift));
  7074. };
  7075. Mont.prototype.convertFrom = function convertFrom (num) {
  7076. var r = this.imod(num.mul(this.rinv));
  7077. r.red = null;
  7078. return r;
  7079. };
  7080. Mont.prototype.imul = function imul (a, b) {
  7081. if (a.isZero() || b.isZero()) {
  7082. a.words[0] = 0;
  7083. a.length = 1;
  7084. return a;
  7085. }
  7086. var t = a.imul(b);
  7087. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  7088. var u = t.isub(c).iushrn(this.shift);
  7089. var res = u;
  7090. if (u.cmp(this.m) >= 0) {
  7091. res = u.isub(this.m);
  7092. } else if (u.cmpn(0) < 0) {
  7093. res = u.iadd(this.m);
  7094. }
  7095. return res._forceRed(this);
  7096. };
  7097. Mont.prototype.mul = function mul (a, b) {
  7098. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  7099. var t = a.mul(b);
  7100. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  7101. var u = t.isub(c).iushrn(this.shift);
  7102. var res = u;
  7103. if (u.cmp(this.m) >= 0) {
  7104. res = u.isub(this.m);
  7105. } else if (u.cmpn(0) < 0) {
  7106. res = u.iadd(this.m);
  7107. }
  7108. return res._forceRed(this);
  7109. };
  7110. Mont.prototype.invm = function invm (a) {
  7111. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  7112. var res = this.imod(a._invmp(this.m).mul(this.r2));
  7113. return res._forceRed(this);
  7114. };
  7115. })( false || module, this);
  7116. /***/ }),
  7117. /***/ "./node_modules/assert/assert.js":
  7118. /*!***************************************!*\
  7119. !*** ./node_modules/assert/assert.js ***!
  7120. \***************************************/
  7121. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  7122. "use strict";
  7123. var objectAssign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js");
  7124. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  7125. // original notice:
  7126. /*!
  7127. * The buffer module from node.js, for the browser.
  7128. *
  7129. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  7130. * @license MIT
  7131. */
  7132. function compare(a, b) {
  7133. if (a === b) {
  7134. return 0;
  7135. }
  7136. var x = a.length;
  7137. var y = b.length;
  7138. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  7139. if (a[i] !== b[i]) {
  7140. x = a[i];
  7141. y = b[i];
  7142. break;
  7143. }
  7144. }
  7145. if (x < y) {
  7146. return -1;
  7147. }
  7148. if (y < x) {
  7149. return 1;
  7150. }
  7151. return 0;
  7152. }
  7153. function isBuffer(b) {
  7154. if (__webpack_require__.g.Buffer && typeof __webpack_require__.g.Buffer.isBuffer === 'function') {
  7155. return __webpack_require__.g.Buffer.isBuffer(b);
  7156. }
  7157. return !!(b != null && b._isBuffer);
  7158. }
  7159. // based on node assert, original notice:
  7160. // NB: The URL to the CommonJS spec is kept just for tradition.
  7161. // node-assert has evolved a lot since then, both in API and behavior.
  7162. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  7163. //
  7164. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  7165. //
  7166. // Originally from narwhal.js (http://narwhaljs.org)
  7167. // Copyright (c) 2009 Thomas Robinson <280north.com>
  7168. //
  7169. // Permission is hereby granted, free of charge, to any person obtaining a copy
  7170. // of this software and associated documentation files (the 'Software'), to
  7171. // deal in the Software without restriction, including without limitation the
  7172. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  7173. // sell copies of the Software, and to permit persons to whom the Software is
  7174. // furnished to do so, subject to the following conditions:
  7175. //
  7176. // The above copyright notice and this permission notice shall be included in
  7177. // all copies or substantial portions of the Software.
  7178. //
  7179. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7180. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7181. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7182. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  7183. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  7184. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  7185. var util = __webpack_require__(/*! util/ */ "./node_modules/assert/node_modules/util/util.js");
  7186. var hasOwn = Object.prototype.hasOwnProperty;
  7187. var pSlice = Array.prototype.slice;
  7188. var functionsHaveNames = (function () {
  7189. return function foo() {}.name === 'foo';
  7190. }());
  7191. function pToString (obj) {
  7192. return Object.prototype.toString.call(obj);
  7193. }
  7194. function isView(arrbuf) {
  7195. if (isBuffer(arrbuf)) {
  7196. return false;
  7197. }
  7198. if (typeof __webpack_require__.g.ArrayBuffer !== 'function') {
  7199. return false;
  7200. }
  7201. if (typeof ArrayBuffer.isView === 'function') {
  7202. return ArrayBuffer.isView(arrbuf);
  7203. }
  7204. if (!arrbuf) {
  7205. return false;
  7206. }
  7207. if (arrbuf instanceof DataView) {
  7208. return true;
  7209. }
  7210. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  7211. return true;
  7212. }
  7213. return false;
  7214. }
  7215. // 1. The assert module provides functions that throw
  7216. // AssertionError's when particular conditions are not met. The
  7217. // assert module must conform to the following interface.
  7218. var assert = module.exports = ok;
  7219. // 2. The AssertionError is defined in assert.
  7220. // new assert.AssertionError({ message: message,
  7221. // actual: actual,
  7222. // expected: expected })
  7223. var regex = /\s*function\s+([^\(\s]*)\s*/;
  7224. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  7225. function getName(func) {
  7226. if (!util.isFunction(func)) {
  7227. return;
  7228. }
  7229. if (functionsHaveNames) {
  7230. return func.name;
  7231. }
  7232. var str = func.toString();
  7233. var match = str.match(regex);
  7234. return match && match[1];
  7235. }
  7236. assert.AssertionError = function AssertionError(options) {
  7237. this.name = 'AssertionError';
  7238. this.actual = options.actual;
  7239. this.expected = options.expected;
  7240. this.operator = options.operator;
  7241. if (options.message) {
  7242. this.message = options.message;
  7243. this.generatedMessage = false;
  7244. } else {
  7245. this.message = getMessage(this);
  7246. this.generatedMessage = true;
  7247. }
  7248. var stackStartFunction = options.stackStartFunction || fail;
  7249. if (Error.captureStackTrace) {
  7250. Error.captureStackTrace(this, stackStartFunction);
  7251. } else {
  7252. // non v8 browsers so we can have a stacktrace
  7253. var err = new Error();
  7254. if (err.stack) {
  7255. var out = err.stack;
  7256. // try to strip useless frames
  7257. var fn_name = getName(stackStartFunction);
  7258. var idx = out.indexOf('\n' + fn_name);
  7259. if (idx >= 0) {
  7260. // once we have located the function frame
  7261. // we need to strip out everything before it (and its line)
  7262. var next_line = out.indexOf('\n', idx + 1);
  7263. out = out.substring(next_line + 1);
  7264. }
  7265. this.stack = out;
  7266. }
  7267. }
  7268. };
  7269. // assert.AssertionError instanceof Error
  7270. util.inherits(assert.AssertionError, Error);
  7271. function truncate(s, n) {
  7272. if (typeof s === 'string') {
  7273. return s.length < n ? s : s.slice(0, n);
  7274. } else {
  7275. return s;
  7276. }
  7277. }
  7278. function inspect(something) {
  7279. if (functionsHaveNames || !util.isFunction(something)) {
  7280. return util.inspect(something);
  7281. }
  7282. var rawname = getName(something);
  7283. var name = rawname ? ': ' + rawname : '';
  7284. return '[Function' + name + ']';
  7285. }
  7286. function getMessage(self) {
  7287. return truncate(inspect(self.actual), 128) + ' ' +
  7288. self.operator + ' ' +
  7289. truncate(inspect(self.expected), 128);
  7290. }
  7291. // At present only the three keys mentioned above are used and
  7292. // understood by the spec. Implementations or sub modules can pass
  7293. // other keys to the AssertionError's constructor - they will be
  7294. // ignored.
  7295. // 3. All of the following functions must throw an AssertionError
  7296. // when a corresponding condition is not met, with a message that
  7297. // may be undefined if not provided. All assertion methods provide
  7298. // both the actual and expected values to the assertion error for
  7299. // display purposes.
  7300. function fail(actual, expected, message, operator, stackStartFunction) {
  7301. throw new assert.AssertionError({
  7302. message: message,
  7303. actual: actual,
  7304. expected: expected,
  7305. operator: operator,
  7306. stackStartFunction: stackStartFunction
  7307. });
  7308. }
  7309. // EXTENSION! allows for well behaved errors defined elsewhere.
  7310. assert.fail = fail;
  7311. // 4. Pure assertion tests whether a value is truthy, as determined
  7312. // by !!guard.
  7313. // assert.ok(guard, message_opt);
  7314. // This statement is equivalent to assert.equal(true, !!guard,
  7315. // message_opt);. To test strictly for the value true, use
  7316. // assert.strictEqual(true, guard, message_opt);.
  7317. function ok(value, message) {
  7318. if (!value) fail(value, true, message, '==', assert.ok);
  7319. }
  7320. assert.ok = ok;
  7321. // 5. The equality assertion tests shallow, coercive equality with
  7322. // ==.
  7323. // assert.equal(actual, expected, message_opt);
  7324. assert.equal = function equal(actual, expected, message) {
  7325. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  7326. };
  7327. // 6. The non-equality assertion tests for whether two objects are not equal
  7328. // with != assert.notEqual(actual, expected, message_opt);
  7329. assert.notEqual = function notEqual(actual, expected, message) {
  7330. if (actual == expected) {
  7331. fail(actual, expected, message, '!=', assert.notEqual);
  7332. }
  7333. };
  7334. // 7. The equivalence assertion tests a deep equality relation.
  7335. // assert.deepEqual(actual, expected, message_opt);
  7336. assert.deepEqual = function deepEqual(actual, expected, message) {
  7337. if (!_deepEqual(actual, expected, false)) {
  7338. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  7339. }
  7340. };
  7341. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  7342. if (!_deepEqual(actual, expected, true)) {
  7343. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  7344. }
  7345. };
  7346. function _deepEqual(actual, expected, strict, memos) {
  7347. // 7.1. All identical values are equivalent, as determined by ===.
  7348. if (actual === expected) {
  7349. return true;
  7350. } else if (isBuffer(actual) && isBuffer(expected)) {
  7351. return compare(actual, expected) === 0;
  7352. // 7.2. If the expected value is a Date object, the actual value is
  7353. // equivalent if it is also a Date object that refers to the same time.
  7354. } else if (util.isDate(actual) && util.isDate(expected)) {
  7355. return actual.getTime() === expected.getTime();
  7356. // 7.3 If the expected value is a RegExp object, the actual value is
  7357. // equivalent if it is also a RegExp object with the same source and
  7358. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  7359. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  7360. return actual.source === expected.source &&
  7361. actual.global === expected.global &&
  7362. actual.multiline === expected.multiline &&
  7363. actual.lastIndex === expected.lastIndex &&
  7364. actual.ignoreCase === expected.ignoreCase;
  7365. // 7.4. Other pairs that do not both pass typeof value == 'object',
  7366. // equivalence is determined by ==.
  7367. } else if ((actual === null || typeof actual !== 'object') &&
  7368. (expected === null || typeof expected !== 'object')) {
  7369. return strict ? actual === expected : actual == expected;
  7370. // If both values are instances of typed arrays, wrap their underlying
  7371. // ArrayBuffers in a Buffer each to increase performance
  7372. // This optimization requires the arrays to have the same type as checked by
  7373. // Object.prototype.toString (aka pToString). Never perform binary
  7374. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  7375. // bit patterns are not identical.
  7376. } else if (isView(actual) && isView(expected) &&
  7377. pToString(actual) === pToString(expected) &&
  7378. !(actual instanceof Float32Array ||
  7379. actual instanceof Float64Array)) {
  7380. return compare(new Uint8Array(actual.buffer),
  7381. new Uint8Array(expected.buffer)) === 0;
  7382. // 7.5 For all other Object pairs, including Array objects, equivalence is
  7383. // determined by having the same number of owned properties (as verified
  7384. // with Object.prototype.hasOwnProperty.call), the same set of keys
  7385. // (although not necessarily the same order), equivalent values for every
  7386. // corresponding key, and an identical 'prototype' property. Note: this
  7387. // accounts for both named and indexed properties on Arrays.
  7388. } else if (isBuffer(actual) !== isBuffer(expected)) {
  7389. return false;
  7390. } else {
  7391. memos = memos || {actual: [], expected: []};
  7392. var actualIndex = memos.actual.indexOf(actual);
  7393. if (actualIndex !== -1) {
  7394. if (actualIndex === memos.expected.indexOf(expected)) {
  7395. return true;
  7396. }
  7397. }
  7398. memos.actual.push(actual);
  7399. memos.expected.push(expected);
  7400. return objEquiv(actual, expected, strict, memos);
  7401. }
  7402. }
  7403. function isArguments(object) {
  7404. return Object.prototype.toString.call(object) == '[object Arguments]';
  7405. }
  7406. function objEquiv(a, b, strict, actualVisitedObjects) {
  7407. if (a === null || a === undefined || b === null || b === undefined)
  7408. return false;
  7409. // if one is a primitive, the other must be same
  7410. if (util.isPrimitive(a) || util.isPrimitive(b))
  7411. return a === b;
  7412. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  7413. return false;
  7414. var aIsArgs = isArguments(a);
  7415. var bIsArgs = isArguments(b);
  7416. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  7417. return false;
  7418. if (aIsArgs) {
  7419. a = pSlice.call(a);
  7420. b = pSlice.call(b);
  7421. return _deepEqual(a, b, strict);
  7422. }
  7423. var ka = objectKeys(a);
  7424. var kb = objectKeys(b);
  7425. var key, i;
  7426. // having the same number of owned properties (keys incorporates
  7427. // hasOwnProperty)
  7428. if (ka.length !== kb.length)
  7429. return false;
  7430. //the same set of keys (although not necessarily the same order),
  7431. ka.sort();
  7432. kb.sort();
  7433. //~~~cheap key test
  7434. for (i = ka.length - 1; i >= 0; i--) {
  7435. if (ka[i] !== kb[i])
  7436. return false;
  7437. }
  7438. //equivalent values for every corresponding key, and
  7439. //~~~possibly expensive deep test
  7440. for (i = ka.length - 1; i >= 0; i--) {
  7441. key = ka[i];
  7442. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  7443. return false;
  7444. }
  7445. return true;
  7446. }
  7447. // 8. The non-equivalence assertion tests for any deep inequality.
  7448. // assert.notDeepEqual(actual, expected, message_opt);
  7449. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  7450. if (_deepEqual(actual, expected, false)) {
  7451. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  7452. }
  7453. };
  7454. assert.notDeepStrictEqual = notDeepStrictEqual;
  7455. function notDeepStrictEqual(actual, expected, message) {
  7456. if (_deepEqual(actual, expected, true)) {
  7457. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  7458. }
  7459. }
  7460. // 9. The strict equality assertion tests strict equality, as determined by ===.
  7461. // assert.strictEqual(actual, expected, message_opt);
  7462. assert.strictEqual = function strictEqual(actual, expected, message) {
  7463. if (actual !== expected) {
  7464. fail(actual, expected, message, '===', assert.strictEqual);
  7465. }
  7466. };
  7467. // 10. The strict non-equality assertion tests for strict inequality, as
  7468. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  7469. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  7470. if (actual === expected) {
  7471. fail(actual, expected, message, '!==', assert.notStrictEqual);
  7472. }
  7473. };
  7474. function expectedException(actual, expected) {
  7475. if (!actual || !expected) {
  7476. return false;
  7477. }
  7478. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  7479. return expected.test(actual);
  7480. }
  7481. try {
  7482. if (actual instanceof expected) {
  7483. return true;
  7484. }
  7485. } catch (e) {
  7486. // Ignore. The instanceof check doesn't work for arrow functions.
  7487. }
  7488. if (Error.isPrototypeOf(expected)) {
  7489. return false;
  7490. }
  7491. return expected.call({}, actual) === true;
  7492. }
  7493. function _tryBlock(block) {
  7494. var error;
  7495. try {
  7496. block();
  7497. } catch (e) {
  7498. error = e;
  7499. }
  7500. return error;
  7501. }
  7502. function _throws(shouldThrow, block, expected, message) {
  7503. var actual;
  7504. if (typeof block !== 'function') {
  7505. throw new TypeError('"block" argument must be a function');
  7506. }
  7507. if (typeof expected === 'string') {
  7508. message = expected;
  7509. expected = null;
  7510. }
  7511. actual = _tryBlock(block);
  7512. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  7513. (message ? ' ' + message : '.');
  7514. if (shouldThrow && !actual) {
  7515. fail(actual, expected, 'Missing expected exception' + message);
  7516. }
  7517. var userProvidedMessage = typeof message === 'string';
  7518. var isUnwantedException = !shouldThrow && util.isError(actual);
  7519. var isUnexpectedException = !shouldThrow && actual && !expected;
  7520. if ((isUnwantedException &&
  7521. userProvidedMessage &&
  7522. expectedException(actual, expected)) ||
  7523. isUnexpectedException) {
  7524. fail(actual, expected, 'Got unwanted exception' + message);
  7525. }
  7526. if ((shouldThrow && actual && expected &&
  7527. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  7528. throw actual;
  7529. }
  7530. }
  7531. // 11. Expected to throw an error:
  7532. // assert.throws(block, Error_opt, message_opt);
  7533. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  7534. _throws(true, block, error, message);
  7535. };
  7536. // EXTENSION! This is annoying to write outside this module.
  7537. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  7538. _throws(false, block, error, message);
  7539. };
  7540. assert.ifError = function(err) { if (err) throw err; };
  7541. // Expose a strict only variant of assert
  7542. function strict(value, message) {
  7543. if (!value) fail(value, true, message, '==', strict);
  7544. }
  7545. assert.strict = objectAssign(strict, assert, {
  7546. equal: assert.strictEqual,
  7547. deepEqual: assert.deepStrictEqual,
  7548. notEqual: assert.notStrictEqual,
  7549. notDeepEqual: assert.notDeepStrictEqual
  7550. });
  7551. assert.strict.strict = assert.strict;
  7552. var objectKeys = Object.keys || function (obj) {
  7553. var keys = [];
  7554. for (var key in obj) {
  7555. if (hasOwn.call(obj, key)) keys.push(key);
  7556. }
  7557. return keys;
  7558. };
  7559. /***/ }),
  7560. /***/ "./node_modules/assert/node_modules/inherits/inherits_browser.js":
  7561. /*!***********************************************************************!*\
  7562. !*** ./node_modules/assert/node_modules/inherits/inherits_browser.js ***!
  7563. \***********************************************************************/
  7564. /***/ ((module) => {
  7565. if (typeof Object.create === 'function') {
  7566. // implementation from standard node.js 'util' module
  7567. module.exports = function inherits(ctor, superCtor) {
  7568. ctor.super_ = superCtor
  7569. ctor.prototype = Object.create(superCtor.prototype, {
  7570. constructor: {
  7571. value: ctor,
  7572. enumerable: false,
  7573. writable: true,
  7574. configurable: true
  7575. }
  7576. });
  7577. };
  7578. } else {
  7579. // old school shim for old browsers
  7580. module.exports = function inherits(ctor, superCtor) {
  7581. ctor.super_ = superCtor
  7582. var TempCtor = function () {}
  7583. TempCtor.prototype = superCtor.prototype
  7584. ctor.prototype = new TempCtor()
  7585. ctor.prototype.constructor = ctor
  7586. }
  7587. }
  7588. /***/ }),
  7589. /***/ "./node_modules/assert/node_modules/util/support/isBufferBrowser.js":
  7590. /*!**************************************************************************!*\
  7591. !*** ./node_modules/assert/node_modules/util/support/isBufferBrowser.js ***!
  7592. \**************************************************************************/
  7593. /***/ ((module) => {
  7594. module.exports = function isBuffer(arg) {
  7595. return arg && typeof arg === 'object'
  7596. && typeof arg.copy === 'function'
  7597. && typeof arg.fill === 'function'
  7598. && typeof arg.readUInt8 === 'function';
  7599. }
  7600. /***/ }),
  7601. /***/ "./node_modules/assert/node_modules/util/util.js":
  7602. /*!*******************************************************!*\
  7603. !*** ./node_modules/assert/node_modules/util/util.js ***!
  7604. \*******************************************************/
  7605. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7606. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  7607. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  7608. // Copyright Joyent, Inc. and other Node contributors.
  7609. //
  7610. // Permission is hereby granted, free of charge, to any person obtaining a
  7611. // copy of this software and associated documentation files (the
  7612. // "Software"), to deal in the Software without restriction, including
  7613. // without limitation the rights to use, copy, modify, merge, publish,
  7614. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7615. // persons to whom the Software is furnished to do so, subject to the
  7616. // following conditions:
  7617. //
  7618. // The above copyright notice and this permission notice shall be included
  7619. // in all copies or substantial portions of the Software.
  7620. //
  7621. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7622. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7623. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7624. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7625. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7626. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7627. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7628. var formatRegExp = /%[sdj%]/g;
  7629. exports.format = function(f) {
  7630. if (!isString(f)) {
  7631. var objects = [];
  7632. for (var i = 0; i < arguments.length; i++) {
  7633. objects.push(inspect(arguments[i]));
  7634. }
  7635. return objects.join(' ');
  7636. }
  7637. var i = 1;
  7638. var args = arguments;
  7639. var len = args.length;
  7640. var str = String(f).replace(formatRegExp, function(x) {
  7641. if (x === '%%') return '%';
  7642. if (i >= len) return x;
  7643. switch (x) {
  7644. case '%s': return String(args[i++]);
  7645. case '%d': return Number(args[i++]);
  7646. case '%j':
  7647. try {
  7648. return JSON.stringify(args[i++]);
  7649. } catch (_) {
  7650. return '[Circular]';
  7651. }
  7652. default:
  7653. return x;
  7654. }
  7655. });
  7656. for (var x = args[i]; i < len; x = args[++i]) {
  7657. if (isNull(x) || !isObject(x)) {
  7658. str += ' ' + x;
  7659. } else {
  7660. str += ' ' + inspect(x);
  7661. }
  7662. }
  7663. return str;
  7664. };
  7665. // Mark that a method should not be used.
  7666. // Returns a modified function which warns once by default.
  7667. // If --no-deprecation is set, then it is a no-op.
  7668. exports.deprecate = function(fn, msg) {
  7669. // Allow for deprecating things in the process of starting up.
  7670. if (isUndefined(__webpack_require__.g.process)) {
  7671. return function() {
  7672. return exports.deprecate(fn, msg).apply(this, arguments);
  7673. };
  7674. }
  7675. if (process.noDeprecation === true) {
  7676. return fn;
  7677. }
  7678. var warned = false;
  7679. function deprecated() {
  7680. if (!warned) {
  7681. if (process.throwDeprecation) {
  7682. throw new Error(msg);
  7683. } else if (process.traceDeprecation) {
  7684. console.trace(msg);
  7685. } else {
  7686. console.error(msg);
  7687. }
  7688. warned = true;
  7689. }
  7690. return fn.apply(this, arguments);
  7691. }
  7692. return deprecated;
  7693. };
  7694. var debugs = {};
  7695. var debugEnviron;
  7696. exports.debuglog = function(set) {
  7697. if (isUndefined(debugEnviron))
  7698. debugEnviron = process.env.NODE_DEBUG || '';
  7699. set = set.toUpperCase();
  7700. if (!debugs[set]) {
  7701. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  7702. var pid = process.pid;
  7703. debugs[set] = function() {
  7704. var msg = exports.format.apply(exports, arguments);
  7705. console.error('%s %d: %s', set, pid, msg);
  7706. };
  7707. } else {
  7708. debugs[set] = function() {};
  7709. }
  7710. }
  7711. return debugs[set];
  7712. };
  7713. /**
  7714. * Echos the value of a value. Trys to print the value out
  7715. * in the best way possible given the different types.
  7716. *
  7717. * @param {Object} obj The object to print out.
  7718. * @param {Object} opts Optional options object that alters the output.
  7719. */
  7720. /* legacy: obj, showHidden, depth, colors*/
  7721. function inspect(obj, opts) {
  7722. // default options
  7723. var ctx = {
  7724. seen: [],
  7725. stylize: stylizeNoColor
  7726. };
  7727. // legacy...
  7728. if (arguments.length >= 3) ctx.depth = arguments[2];
  7729. if (arguments.length >= 4) ctx.colors = arguments[3];
  7730. if (isBoolean(opts)) {
  7731. // legacy...
  7732. ctx.showHidden = opts;
  7733. } else if (opts) {
  7734. // got an "options" object
  7735. exports._extend(ctx, opts);
  7736. }
  7737. // set default options
  7738. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  7739. if (isUndefined(ctx.depth)) ctx.depth = 2;
  7740. if (isUndefined(ctx.colors)) ctx.colors = false;
  7741. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  7742. if (ctx.colors) ctx.stylize = stylizeWithColor;
  7743. return formatValue(ctx, obj, ctx.depth);
  7744. }
  7745. exports.inspect = inspect;
  7746. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  7747. inspect.colors = {
  7748. 'bold' : [1, 22],
  7749. 'italic' : [3, 23],
  7750. 'underline' : [4, 24],
  7751. 'inverse' : [7, 27],
  7752. 'white' : [37, 39],
  7753. 'grey' : [90, 39],
  7754. 'black' : [30, 39],
  7755. 'blue' : [34, 39],
  7756. 'cyan' : [36, 39],
  7757. 'green' : [32, 39],
  7758. 'magenta' : [35, 39],
  7759. 'red' : [31, 39],
  7760. 'yellow' : [33, 39]
  7761. };
  7762. // Don't use 'blue' not visible on cmd.exe
  7763. inspect.styles = {
  7764. 'special': 'cyan',
  7765. 'number': 'yellow',
  7766. 'boolean': 'yellow',
  7767. 'undefined': 'grey',
  7768. 'null': 'bold',
  7769. 'string': 'green',
  7770. 'date': 'magenta',
  7771. // "name": intentionally not styling
  7772. 'regexp': 'red'
  7773. };
  7774. function stylizeWithColor(str, styleType) {
  7775. var style = inspect.styles[styleType];
  7776. if (style) {
  7777. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  7778. '\u001b[' + inspect.colors[style][1] + 'm';
  7779. } else {
  7780. return str;
  7781. }
  7782. }
  7783. function stylizeNoColor(str, styleType) {
  7784. return str;
  7785. }
  7786. function arrayToHash(array) {
  7787. var hash = {};
  7788. array.forEach(function(val, idx) {
  7789. hash[val] = true;
  7790. });
  7791. return hash;
  7792. }
  7793. function formatValue(ctx, value, recurseTimes) {
  7794. // Provide a hook for user-specified inspect functions.
  7795. // Check that value is an object with an inspect function on it
  7796. if (ctx.customInspect &&
  7797. value &&
  7798. isFunction(value.inspect) &&
  7799. // Filter out the util module, it's inspect function is special
  7800. value.inspect !== exports.inspect &&
  7801. // Also filter out any prototype objects using the circular check.
  7802. !(value.constructor && value.constructor.prototype === value)) {
  7803. var ret = value.inspect(recurseTimes, ctx);
  7804. if (!isString(ret)) {
  7805. ret = formatValue(ctx, ret, recurseTimes);
  7806. }
  7807. return ret;
  7808. }
  7809. // Primitive types cannot have properties
  7810. var primitive = formatPrimitive(ctx, value);
  7811. if (primitive) {
  7812. return primitive;
  7813. }
  7814. // Look up the keys of the object.
  7815. var keys = Object.keys(value);
  7816. var visibleKeys = arrayToHash(keys);
  7817. if (ctx.showHidden) {
  7818. keys = Object.getOwnPropertyNames(value);
  7819. }
  7820. // IE doesn't make error fields non-enumerable
  7821. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  7822. if (isError(value)
  7823. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  7824. return formatError(value);
  7825. }
  7826. // Some type of object without properties can be shortcutted.
  7827. if (keys.length === 0) {
  7828. if (isFunction(value)) {
  7829. var name = value.name ? ': ' + value.name : '';
  7830. return ctx.stylize('[Function' + name + ']', 'special');
  7831. }
  7832. if (isRegExp(value)) {
  7833. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  7834. }
  7835. if (isDate(value)) {
  7836. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  7837. }
  7838. if (isError(value)) {
  7839. return formatError(value);
  7840. }
  7841. }
  7842. var base = '', array = false, braces = ['{', '}'];
  7843. // Make Array say that they are Array
  7844. if (isArray(value)) {
  7845. array = true;
  7846. braces = ['[', ']'];
  7847. }
  7848. // Make functions say that they are functions
  7849. if (isFunction(value)) {
  7850. var n = value.name ? ': ' + value.name : '';
  7851. base = ' [Function' + n + ']';
  7852. }
  7853. // Make RegExps say that they are RegExps
  7854. if (isRegExp(value)) {
  7855. base = ' ' + RegExp.prototype.toString.call(value);
  7856. }
  7857. // Make dates with properties first say the date
  7858. if (isDate(value)) {
  7859. base = ' ' + Date.prototype.toUTCString.call(value);
  7860. }
  7861. // Make error with message first say the error
  7862. if (isError(value)) {
  7863. base = ' ' + formatError(value);
  7864. }
  7865. if (keys.length === 0 && (!array || value.length == 0)) {
  7866. return braces[0] + base + braces[1];
  7867. }
  7868. if (recurseTimes < 0) {
  7869. if (isRegExp(value)) {
  7870. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  7871. } else {
  7872. return ctx.stylize('[Object]', 'special');
  7873. }
  7874. }
  7875. ctx.seen.push(value);
  7876. var output;
  7877. if (array) {
  7878. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  7879. } else {
  7880. output = keys.map(function(key) {
  7881. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  7882. });
  7883. }
  7884. ctx.seen.pop();
  7885. return reduceToSingleString(output, base, braces);
  7886. }
  7887. function formatPrimitive(ctx, value) {
  7888. if (isUndefined(value))
  7889. return ctx.stylize('undefined', 'undefined');
  7890. if (isString(value)) {
  7891. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  7892. .replace(/'/g, "\\'")
  7893. .replace(/\\"/g, '"') + '\'';
  7894. return ctx.stylize(simple, 'string');
  7895. }
  7896. if (isNumber(value))
  7897. return ctx.stylize('' + value, 'number');
  7898. if (isBoolean(value))
  7899. return ctx.stylize('' + value, 'boolean');
  7900. // For some reason typeof null is "object", so special case here.
  7901. if (isNull(value))
  7902. return ctx.stylize('null', 'null');
  7903. }
  7904. function formatError(value) {
  7905. return '[' + Error.prototype.toString.call(value) + ']';
  7906. }
  7907. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  7908. var output = [];
  7909. for (var i = 0, l = value.length; i < l; ++i) {
  7910. if (hasOwnProperty(value, String(i))) {
  7911. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  7912. String(i), true));
  7913. } else {
  7914. output.push('');
  7915. }
  7916. }
  7917. keys.forEach(function(key) {
  7918. if (!key.match(/^\d+$/)) {
  7919. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  7920. key, true));
  7921. }
  7922. });
  7923. return output;
  7924. }
  7925. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  7926. var name, str, desc;
  7927. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  7928. if (desc.get) {
  7929. if (desc.set) {
  7930. str = ctx.stylize('[Getter/Setter]', 'special');
  7931. } else {
  7932. str = ctx.stylize('[Getter]', 'special');
  7933. }
  7934. } else {
  7935. if (desc.set) {
  7936. str = ctx.stylize('[Setter]', 'special');
  7937. }
  7938. }
  7939. if (!hasOwnProperty(visibleKeys, key)) {
  7940. name = '[' + key + ']';
  7941. }
  7942. if (!str) {
  7943. if (ctx.seen.indexOf(desc.value) < 0) {
  7944. if (isNull(recurseTimes)) {
  7945. str = formatValue(ctx, desc.value, null);
  7946. } else {
  7947. str = formatValue(ctx, desc.value, recurseTimes - 1);
  7948. }
  7949. if (str.indexOf('\n') > -1) {
  7950. if (array) {
  7951. str = str.split('\n').map(function(line) {
  7952. return ' ' + line;
  7953. }).join('\n').substr(2);
  7954. } else {
  7955. str = '\n' + str.split('\n').map(function(line) {
  7956. return ' ' + line;
  7957. }).join('\n');
  7958. }
  7959. }
  7960. } else {
  7961. str = ctx.stylize('[Circular]', 'special');
  7962. }
  7963. }
  7964. if (isUndefined(name)) {
  7965. if (array && key.match(/^\d+$/)) {
  7966. return str;
  7967. }
  7968. name = JSON.stringify('' + key);
  7969. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  7970. name = name.substr(1, name.length - 2);
  7971. name = ctx.stylize(name, 'name');
  7972. } else {
  7973. name = name.replace(/'/g, "\\'")
  7974. .replace(/\\"/g, '"')
  7975. .replace(/(^"|"$)/g, "'");
  7976. name = ctx.stylize(name, 'string');
  7977. }
  7978. }
  7979. return name + ': ' + str;
  7980. }
  7981. function reduceToSingleString(output, base, braces) {
  7982. var numLinesEst = 0;
  7983. var length = output.reduce(function(prev, cur) {
  7984. numLinesEst++;
  7985. if (cur.indexOf('\n') >= 0) numLinesEst++;
  7986. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  7987. }, 0);
  7988. if (length > 60) {
  7989. return braces[0] +
  7990. (base === '' ? '' : base + '\n ') +
  7991. ' ' +
  7992. output.join(',\n ') +
  7993. ' ' +
  7994. braces[1];
  7995. }
  7996. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  7997. }
  7998. // NOTE: These type checking functions intentionally don't use `instanceof`
  7999. // because it is fragile and can be easily faked with `Object.create()`.
  8000. function isArray(ar) {
  8001. return Array.isArray(ar);
  8002. }
  8003. exports.isArray = isArray;
  8004. function isBoolean(arg) {
  8005. return typeof arg === 'boolean';
  8006. }
  8007. exports.isBoolean = isBoolean;
  8008. function isNull(arg) {
  8009. return arg === null;
  8010. }
  8011. exports.isNull = isNull;
  8012. function isNullOrUndefined(arg) {
  8013. return arg == null;
  8014. }
  8015. exports.isNullOrUndefined = isNullOrUndefined;
  8016. function isNumber(arg) {
  8017. return typeof arg === 'number';
  8018. }
  8019. exports.isNumber = isNumber;
  8020. function isString(arg) {
  8021. return typeof arg === 'string';
  8022. }
  8023. exports.isString = isString;
  8024. function isSymbol(arg) {
  8025. return typeof arg === 'symbol';
  8026. }
  8027. exports.isSymbol = isSymbol;
  8028. function isUndefined(arg) {
  8029. return arg === void 0;
  8030. }
  8031. exports.isUndefined = isUndefined;
  8032. function isRegExp(re) {
  8033. return isObject(re) && objectToString(re) === '[object RegExp]';
  8034. }
  8035. exports.isRegExp = isRegExp;
  8036. function isObject(arg) {
  8037. return typeof arg === 'object' && arg !== null;
  8038. }
  8039. exports.isObject = isObject;
  8040. function isDate(d) {
  8041. return isObject(d) && objectToString(d) === '[object Date]';
  8042. }
  8043. exports.isDate = isDate;
  8044. function isError(e) {
  8045. return isObject(e) &&
  8046. (objectToString(e) === '[object Error]' || e instanceof Error);
  8047. }
  8048. exports.isError = isError;
  8049. function isFunction(arg) {
  8050. return typeof arg === 'function';
  8051. }
  8052. exports.isFunction = isFunction;
  8053. function isPrimitive(arg) {
  8054. return arg === null ||
  8055. typeof arg === 'boolean' ||
  8056. typeof arg === 'number' ||
  8057. typeof arg === 'string' ||
  8058. typeof arg === 'symbol' || // ES6 symbol
  8059. typeof arg === 'undefined';
  8060. }
  8061. exports.isPrimitive = isPrimitive;
  8062. exports.isBuffer = __webpack_require__(/*! ./support/isBuffer */ "./node_modules/assert/node_modules/util/support/isBufferBrowser.js");
  8063. function objectToString(o) {
  8064. return Object.prototype.toString.call(o);
  8065. }
  8066. function pad(n) {
  8067. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  8068. }
  8069. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  8070. 'Oct', 'Nov', 'Dec'];
  8071. // 26 Feb 16:19:34
  8072. function timestamp() {
  8073. var d = new Date();
  8074. var time = [pad(d.getHours()),
  8075. pad(d.getMinutes()),
  8076. pad(d.getSeconds())].join(':');
  8077. return [d.getDate(), months[d.getMonth()], time].join(' ');
  8078. }
  8079. // log is just a thin wrapper to console.log that prepends a timestamp
  8080. exports.log = function() {
  8081. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  8082. };
  8083. /**
  8084. * Inherit the prototype methods from one constructor into another.
  8085. *
  8086. * The Function.prototype.inherits from lang.js rewritten as a standalone
  8087. * function (not on Function.prototype). NOTE: If this file is to be loaded
  8088. * during bootstrapping this function needs to be rewritten using some native
  8089. * functions as prototype setup using normal JavaScript does not work as
  8090. * expected during bootstrapping (see mirror.js in r114903).
  8091. *
  8092. * @param {function} ctor Constructor function which needs to inherit the
  8093. * prototype.
  8094. * @param {function} superCtor Constructor function to inherit prototype from.
  8095. */
  8096. exports.inherits = __webpack_require__(/*! inherits */ "./node_modules/assert/node_modules/inherits/inherits_browser.js");
  8097. exports._extend = function(origin, add) {
  8098. // Don't do anything if add isn't an object
  8099. if (!add || !isObject(add)) return origin;
  8100. var keys = Object.keys(add);
  8101. var i = keys.length;
  8102. while (i--) {
  8103. origin[keys[i]] = add[keys[i]];
  8104. }
  8105. return origin;
  8106. };
  8107. function hasOwnProperty(obj, prop) {
  8108. return Object.prototype.hasOwnProperty.call(obj, prop);
  8109. }
  8110. /***/ }),
  8111. /***/ "./node_modules/axios/index.js":
  8112. /*!*************************************!*\
  8113. !*** ./node_modules/axios/index.js ***!
  8114. \*************************************/
  8115. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8116. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  8117. /***/ }),
  8118. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  8119. /*!************************************************!*\
  8120. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  8121. \************************************************/
  8122. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8123. "use strict";
  8124. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  8125. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  8126. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  8127. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  8128. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  8129. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  8130. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  8131. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  8132. module.exports = function xhrAdapter(config) {
  8133. return new Promise(function dispatchXhrRequest(resolve, reject) {
  8134. var requestData = config.data;
  8135. var requestHeaders = config.headers;
  8136. var responseType = config.responseType;
  8137. if (utils.isFormData(requestData)) {
  8138. delete requestHeaders['Content-Type']; // Let the browser set it
  8139. }
  8140. var request = new XMLHttpRequest();
  8141. // HTTP basic authentication
  8142. if (config.auth) {
  8143. var username = config.auth.username || '';
  8144. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  8145. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  8146. }
  8147. var fullPath = buildFullPath(config.baseURL, config.url);
  8148. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  8149. // Set the request timeout in MS
  8150. request.timeout = config.timeout;
  8151. function onloadend() {
  8152. if (!request) {
  8153. return;
  8154. }
  8155. // Prepare the response
  8156. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  8157. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  8158. request.responseText : request.response;
  8159. var response = {
  8160. data: responseData,
  8161. status: request.status,
  8162. statusText: request.statusText,
  8163. headers: responseHeaders,
  8164. config: config,
  8165. request: request
  8166. };
  8167. settle(resolve, reject, response);
  8168. // Clean up request
  8169. request = null;
  8170. }
  8171. if ('onloadend' in request) {
  8172. // Use onloadend if available
  8173. request.onloadend = onloadend;
  8174. } else {
  8175. // Listen for ready state to emulate onloadend
  8176. request.onreadystatechange = function handleLoad() {
  8177. if (!request || request.readyState !== 4) {
  8178. return;
  8179. }
  8180. // The request errored out and we didn't get a response, this will be
  8181. // handled by onerror instead
  8182. // With one exception: request that using file: protocol, most browsers
  8183. // will return status as 0 even though it's a successful request
  8184. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  8185. return;
  8186. }
  8187. // readystate handler is calling before onerror or ontimeout handlers,
  8188. // so we should call onloadend on the next 'tick'
  8189. setTimeout(onloadend);
  8190. };
  8191. }
  8192. // Handle browser request cancellation (as opposed to a manual cancellation)
  8193. request.onabort = function handleAbort() {
  8194. if (!request) {
  8195. return;
  8196. }
  8197. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  8198. // Clean up request
  8199. request = null;
  8200. };
  8201. // Handle low level network errors
  8202. request.onerror = function handleError() {
  8203. // Real errors are hidden from us by the browser
  8204. // onerror should only fire if it's a network error
  8205. reject(createError('Network Error', config, null, request));
  8206. // Clean up request
  8207. request = null;
  8208. };
  8209. // Handle timeout
  8210. request.ontimeout = function handleTimeout() {
  8211. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  8212. if (config.timeoutErrorMessage) {
  8213. timeoutErrorMessage = config.timeoutErrorMessage;
  8214. }
  8215. reject(createError(
  8216. timeoutErrorMessage,
  8217. config,
  8218. config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  8219. request));
  8220. // Clean up request
  8221. request = null;
  8222. };
  8223. // Add xsrf header
  8224. // This is only done if running in a standard browser environment.
  8225. // Specifically not if we're in a web worker, or react-native.
  8226. if (utils.isStandardBrowserEnv()) {
  8227. // Add xsrf header
  8228. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  8229. cookies.read(config.xsrfCookieName) :
  8230. undefined;
  8231. if (xsrfValue) {
  8232. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  8233. }
  8234. }
  8235. // Add headers to the request
  8236. if ('setRequestHeader' in request) {
  8237. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  8238. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  8239. // Remove Content-Type if data is undefined
  8240. delete requestHeaders[key];
  8241. } else {
  8242. // Otherwise add header to the request
  8243. request.setRequestHeader(key, val);
  8244. }
  8245. });
  8246. }
  8247. // Add withCredentials to request if needed
  8248. if (!utils.isUndefined(config.withCredentials)) {
  8249. request.withCredentials = !!config.withCredentials;
  8250. }
  8251. // Add responseType to request if needed
  8252. if (responseType && responseType !== 'json') {
  8253. request.responseType = config.responseType;
  8254. }
  8255. // Handle progress if needed
  8256. if (typeof config.onDownloadProgress === 'function') {
  8257. request.addEventListener('progress', config.onDownloadProgress);
  8258. }
  8259. // Not all browsers support upload events
  8260. if (typeof config.onUploadProgress === 'function' && request.upload) {
  8261. request.upload.addEventListener('progress', config.onUploadProgress);
  8262. }
  8263. if (config.cancelToken) {
  8264. // Handle cancellation
  8265. config.cancelToken.promise.then(function onCanceled(cancel) {
  8266. if (!request) {
  8267. return;
  8268. }
  8269. request.abort();
  8270. reject(cancel);
  8271. // Clean up request
  8272. request = null;
  8273. });
  8274. }
  8275. if (!requestData) {
  8276. requestData = null;
  8277. }
  8278. // Send the request
  8279. request.send(requestData);
  8280. });
  8281. };
  8282. /***/ }),
  8283. /***/ "./node_modules/axios/lib/axios.js":
  8284. /*!*****************************************!*\
  8285. !*** ./node_modules/axios/lib/axios.js ***!
  8286. \*****************************************/
  8287. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8288. "use strict";
  8289. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  8290. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  8291. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  8292. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  8293. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  8294. /**
  8295. * Create an instance of Axios
  8296. *
  8297. * @param {Object} defaultConfig The default config for the instance
  8298. * @return {Axios} A new instance of Axios
  8299. */
  8300. function createInstance(defaultConfig) {
  8301. var context = new Axios(defaultConfig);
  8302. var instance = bind(Axios.prototype.request, context);
  8303. // Copy axios.prototype to instance
  8304. utils.extend(instance, Axios.prototype, context);
  8305. // Copy context to instance
  8306. utils.extend(instance, context);
  8307. return instance;
  8308. }
  8309. // Create the default instance to be exported
  8310. var axios = createInstance(defaults);
  8311. // Expose Axios class to allow class inheritance
  8312. axios.Axios = Axios;
  8313. // Factory for creating new instances
  8314. axios.create = function create(instanceConfig) {
  8315. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  8316. };
  8317. // Expose Cancel & CancelToken
  8318. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  8319. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  8320. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  8321. // Expose all/spread
  8322. axios.all = function all(promises) {
  8323. return Promise.all(promises);
  8324. };
  8325. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  8326. // Expose isAxiosError
  8327. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  8328. module.exports = axios;
  8329. // Allow use of default import syntax in TypeScript
  8330. module.exports["default"] = axios;
  8331. /***/ }),
  8332. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  8333. /*!*************************************************!*\
  8334. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  8335. \*************************************************/
  8336. /***/ ((module) => {
  8337. "use strict";
  8338. /**
  8339. * A `Cancel` is an object that is thrown when an operation is canceled.
  8340. *
  8341. * @class
  8342. * @param {string=} message The message.
  8343. */
  8344. function Cancel(message) {
  8345. this.message = message;
  8346. }
  8347. Cancel.prototype.toString = function toString() {
  8348. return 'Cancel' + (this.message ? ': ' + this.message : '');
  8349. };
  8350. Cancel.prototype.__CANCEL__ = true;
  8351. module.exports = Cancel;
  8352. /***/ }),
  8353. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  8354. /*!******************************************************!*\
  8355. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  8356. \******************************************************/
  8357. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8358. "use strict";
  8359. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  8360. /**
  8361. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  8362. *
  8363. * @class
  8364. * @param {Function} executor The executor function.
  8365. */
  8366. function CancelToken(executor) {
  8367. if (typeof executor !== 'function') {
  8368. throw new TypeError('executor must be a function.');
  8369. }
  8370. var resolvePromise;
  8371. this.promise = new Promise(function promiseExecutor(resolve) {
  8372. resolvePromise = resolve;
  8373. });
  8374. var token = this;
  8375. executor(function cancel(message) {
  8376. if (token.reason) {
  8377. // Cancellation has already been requested
  8378. return;
  8379. }
  8380. token.reason = new Cancel(message);
  8381. resolvePromise(token.reason);
  8382. });
  8383. }
  8384. /**
  8385. * Throws a `Cancel` if cancellation has been requested.
  8386. */
  8387. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  8388. if (this.reason) {
  8389. throw this.reason;
  8390. }
  8391. };
  8392. /**
  8393. * Returns an object that contains a new `CancelToken` and a function that, when called,
  8394. * cancels the `CancelToken`.
  8395. */
  8396. CancelToken.source = function source() {
  8397. var cancel;
  8398. var token = new CancelToken(function executor(c) {
  8399. cancel = c;
  8400. });
  8401. return {
  8402. token: token,
  8403. cancel: cancel
  8404. };
  8405. };
  8406. module.exports = CancelToken;
  8407. /***/ }),
  8408. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  8409. /*!***************************************************!*\
  8410. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  8411. \***************************************************/
  8412. /***/ ((module) => {
  8413. "use strict";
  8414. module.exports = function isCancel(value) {
  8415. return !!(value && value.__CANCEL__);
  8416. };
  8417. /***/ }),
  8418. /***/ "./node_modules/axios/lib/core/Axios.js":
  8419. /*!**********************************************!*\
  8420. !*** ./node_modules/axios/lib/core/Axios.js ***!
  8421. \**********************************************/
  8422. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8423. "use strict";
  8424. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  8425. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  8426. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  8427. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  8428. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  8429. var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js");
  8430. var validators = validator.validators;
  8431. /**
  8432. * Create a new instance of Axios
  8433. *
  8434. * @param {Object} instanceConfig The default config for the instance
  8435. */
  8436. function Axios(instanceConfig) {
  8437. this.defaults = instanceConfig;
  8438. this.interceptors = {
  8439. request: new InterceptorManager(),
  8440. response: new InterceptorManager()
  8441. };
  8442. }
  8443. /**
  8444. * Dispatch a request
  8445. *
  8446. * @param {Object} config The config specific for this request (merged with this.defaults)
  8447. */
  8448. Axios.prototype.request = function request(config) {
  8449. /*eslint no-param-reassign:0*/
  8450. // Allow for axios('example/url'[, config]) a la fetch API
  8451. if (typeof config === 'string') {
  8452. config = arguments[1] || {};
  8453. config.url = arguments[0];
  8454. } else {
  8455. config = config || {};
  8456. }
  8457. config = mergeConfig(this.defaults, config);
  8458. // Set config.method
  8459. if (config.method) {
  8460. config.method = config.method.toLowerCase();
  8461. } else if (this.defaults.method) {
  8462. config.method = this.defaults.method.toLowerCase();
  8463. } else {
  8464. config.method = 'get';
  8465. }
  8466. var transitional = config.transitional;
  8467. if (transitional !== undefined) {
  8468. validator.assertOptions(transitional, {
  8469. silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  8470. forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  8471. clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
  8472. }, false);
  8473. }
  8474. // filter out skipped interceptors
  8475. var requestInterceptorChain = [];
  8476. var synchronousRequestInterceptors = true;
  8477. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  8478. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  8479. return;
  8480. }
  8481. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  8482. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  8483. });
  8484. var responseInterceptorChain = [];
  8485. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  8486. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  8487. });
  8488. var promise;
  8489. if (!synchronousRequestInterceptors) {
  8490. var chain = [dispatchRequest, undefined];
  8491. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  8492. chain = chain.concat(responseInterceptorChain);
  8493. promise = Promise.resolve(config);
  8494. while (chain.length) {
  8495. promise = promise.then(chain.shift(), chain.shift());
  8496. }
  8497. return promise;
  8498. }
  8499. var newConfig = config;
  8500. while (requestInterceptorChain.length) {
  8501. var onFulfilled = requestInterceptorChain.shift();
  8502. var onRejected = requestInterceptorChain.shift();
  8503. try {
  8504. newConfig = onFulfilled(newConfig);
  8505. } catch (error) {
  8506. onRejected(error);
  8507. break;
  8508. }
  8509. }
  8510. try {
  8511. promise = dispatchRequest(newConfig);
  8512. } catch (error) {
  8513. return Promise.reject(error);
  8514. }
  8515. while (responseInterceptorChain.length) {
  8516. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  8517. }
  8518. return promise;
  8519. };
  8520. Axios.prototype.getUri = function getUri(config) {
  8521. config = mergeConfig(this.defaults, config);
  8522. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  8523. };
  8524. // Provide aliases for supported request methods
  8525. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  8526. /*eslint func-names:0*/
  8527. Axios.prototype[method] = function(url, config) {
  8528. return this.request(mergeConfig(config || {}, {
  8529. method: method,
  8530. url: url,
  8531. data: (config || {}).data
  8532. }));
  8533. };
  8534. });
  8535. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  8536. /*eslint func-names:0*/
  8537. Axios.prototype[method] = function(url, data, config) {
  8538. return this.request(mergeConfig(config || {}, {
  8539. method: method,
  8540. url: url,
  8541. data: data
  8542. }));
  8543. };
  8544. });
  8545. module.exports = Axios;
  8546. /***/ }),
  8547. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  8548. /*!***********************************************************!*\
  8549. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  8550. \***********************************************************/
  8551. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8552. "use strict";
  8553. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  8554. function InterceptorManager() {
  8555. this.handlers = [];
  8556. }
  8557. /**
  8558. * Add a new interceptor to the stack
  8559. *
  8560. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  8561. * @param {Function} rejected The function to handle `reject` for a `Promise`
  8562. *
  8563. * @return {Number} An ID used to remove interceptor later
  8564. */
  8565. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  8566. this.handlers.push({
  8567. fulfilled: fulfilled,
  8568. rejected: rejected,
  8569. synchronous: options ? options.synchronous : false,
  8570. runWhen: options ? options.runWhen : null
  8571. });
  8572. return this.handlers.length - 1;
  8573. };
  8574. /**
  8575. * Remove an interceptor from the stack
  8576. *
  8577. * @param {Number} id The ID that was returned by `use`
  8578. */
  8579. InterceptorManager.prototype.eject = function eject(id) {
  8580. if (this.handlers[id]) {
  8581. this.handlers[id] = null;
  8582. }
  8583. };
  8584. /**
  8585. * Iterate over all the registered interceptors
  8586. *
  8587. * This method is particularly useful for skipping over any
  8588. * interceptors that may have become `null` calling `eject`.
  8589. *
  8590. * @param {Function} fn The function to call for each interceptor
  8591. */
  8592. InterceptorManager.prototype.forEach = function forEach(fn) {
  8593. utils.forEach(this.handlers, function forEachHandler(h) {
  8594. if (h !== null) {
  8595. fn(h);
  8596. }
  8597. });
  8598. };
  8599. module.exports = InterceptorManager;
  8600. /***/ }),
  8601. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  8602. /*!******************************************************!*\
  8603. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  8604. \******************************************************/
  8605. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8606. "use strict";
  8607. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  8608. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  8609. /**
  8610. * Creates a new URL by combining the baseURL with the requestedURL,
  8611. * only when the requestedURL is not already an absolute URL.
  8612. * If the requestURL is absolute, this function returns the requestedURL untouched.
  8613. *
  8614. * @param {string} baseURL The base URL
  8615. * @param {string} requestedURL Absolute or relative URL to combine
  8616. * @returns {string} The combined full path
  8617. */
  8618. module.exports = function buildFullPath(baseURL, requestedURL) {
  8619. if (baseURL && !isAbsoluteURL(requestedURL)) {
  8620. return combineURLs(baseURL, requestedURL);
  8621. }
  8622. return requestedURL;
  8623. };
  8624. /***/ }),
  8625. /***/ "./node_modules/axios/lib/core/createError.js":
  8626. /*!****************************************************!*\
  8627. !*** ./node_modules/axios/lib/core/createError.js ***!
  8628. \****************************************************/
  8629. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8630. "use strict";
  8631. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  8632. /**
  8633. * Create an Error with the specified message, config, error code, request and response.
  8634. *
  8635. * @param {string} message The error message.
  8636. * @param {Object} config The config.
  8637. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  8638. * @param {Object} [request] The request.
  8639. * @param {Object} [response] The response.
  8640. * @returns {Error} The created error.
  8641. */
  8642. module.exports = function createError(message, config, code, request, response) {
  8643. var error = new Error(message);
  8644. return enhanceError(error, config, code, request, response);
  8645. };
  8646. /***/ }),
  8647. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  8648. /*!********************************************************!*\
  8649. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  8650. \********************************************************/
  8651. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8652. "use strict";
  8653. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  8654. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  8655. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  8656. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  8657. /**
  8658. * Throws a `Cancel` if cancellation has been requested.
  8659. */
  8660. function throwIfCancellationRequested(config) {
  8661. if (config.cancelToken) {
  8662. config.cancelToken.throwIfRequested();
  8663. }
  8664. }
  8665. /**
  8666. * Dispatch a request to the server using the configured adapter.
  8667. *
  8668. * @param {object} config The config that is to be used for the request
  8669. * @returns {Promise} The Promise to be fulfilled
  8670. */
  8671. module.exports = function dispatchRequest(config) {
  8672. throwIfCancellationRequested(config);
  8673. // Ensure headers exist
  8674. config.headers = config.headers || {};
  8675. // Transform request data
  8676. config.data = transformData.call(
  8677. config,
  8678. config.data,
  8679. config.headers,
  8680. config.transformRequest
  8681. );
  8682. // Flatten headers
  8683. config.headers = utils.merge(
  8684. config.headers.common || {},
  8685. config.headers[config.method] || {},
  8686. config.headers
  8687. );
  8688. utils.forEach(
  8689. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  8690. function cleanHeaderConfig(method) {
  8691. delete config.headers[method];
  8692. }
  8693. );
  8694. var adapter = config.adapter || defaults.adapter;
  8695. return adapter(config).then(function onAdapterResolution(response) {
  8696. throwIfCancellationRequested(config);
  8697. // Transform response data
  8698. response.data = transformData.call(
  8699. config,
  8700. response.data,
  8701. response.headers,
  8702. config.transformResponse
  8703. );
  8704. return response;
  8705. }, function onAdapterRejection(reason) {
  8706. if (!isCancel(reason)) {
  8707. throwIfCancellationRequested(config);
  8708. // Transform response data
  8709. if (reason && reason.response) {
  8710. reason.response.data = transformData.call(
  8711. config,
  8712. reason.response.data,
  8713. reason.response.headers,
  8714. config.transformResponse
  8715. );
  8716. }
  8717. }
  8718. return Promise.reject(reason);
  8719. });
  8720. };
  8721. /***/ }),
  8722. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  8723. /*!*****************************************************!*\
  8724. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  8725. \*****************************************************/
  8726. /***/ ((module) => {
  8727. "use strict";
  8728. /**
  8729. * Update an Error with the specified config, error code, and response.
  8730. *
  8731. * @param {Error} error The error to update.
  8732. * @param {Object} config The config.
  8733. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  8734. * @param {Object} [request] The request.
  8735. * @param {Object} [response] The response.
  8736. * @returns {Error} The error.
  8737. */
  8738. module.exports = function enhanceError(error, config, code, request, response) {
  8739. error.config = config;
  8740. if (code) {
  8741. error.code = code;
  8742. }
  8743. error.request = request;
  8744. error.response = response;
  8745. error.isAxiosError = true;
  8746. error.toJSON = function toJSON() {
  8747. return {
  8748. // Standard
  8749. message: this.message,
  8750. name: this.name,
  8751. // Microsoft
  8752. description: this.description,
  8753. number: this.number,
  8754. // Mozilla
  8755. fileName: this.fileName,
  8756. lineNumber: this.lineNumber,
  8757. columnNumber: this.columnNumber,
  8758. stack: this.stack,
  8759. // Axios
  8760. config: this.config,
  8761. code: this.code
  8762. };
  8763. };
  8764. return error;
  8765. };
  8766. /***/ }),
  8767. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  8768. /*!****************************************************!*\
  8769. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  8770. \****************************************************/
  8771. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8772. "use strict";
  8773. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  8774. /**
  8775. * Config-specific merge-function which creates a new config-object
  8776. * by merging two configuration objects together.
  8777. *
  8778. * @param {Object} config1
  8779. * @param {Object} config2
  8780. * @returns {Object} New object resulting from merging config2 to config1
  8781. */
  8782. module.exports = function mergeConfig(config1, config2) {
  8783. // eslint-disable-next-line no-param-reassign
  8784. config2 = config2 || {};
  8785. var config = {};
  8786. var valueFromConfig2Keys = ['url', 'method', 'data'];
  8787. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  8788. var defaultToConfig2Keys = [
  8789. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  8790. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  8791. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  8792. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  8793. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  8794. ];
  8795. var directMergeKeys = ['validateStatus'];
  8796. function getMergedValue(target, source) {
  8797. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  8798. return utils.merge(target, source);
  8799. } else if (utils.isPlainObject(source)) {
  8800. return utils.merge({}, source);
  8801. } else if (utils.isArray(source)) {
  8802. return source.slice();
  8803. }
  8804. return source;
  8805. }
  8806. function mergeDeepProperties(prop) {
  8807. if (!utils.isUndefined(config2[prop])) {
  8808. config[prop] = getMergedValue(config1[prop], config2[prop]);
  8809. } else if (!utils.isUndefined(config1[prop])) {
  8810. config[prop] = getMergedValue(undefined, config1[prop]);
  8811. }
  8812. }
  8813. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  8814. if (!utils.isUndefined(config2[prop])) {
  8815. config[prop] = getMergedValue(undefined, config2[prop]);
  8816. }
  8817. });
  8818. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  8819. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  8820. if (!utils.isUndefined(config2[prop])) {
  8821. config[prop] = getMergedValue(undefined, config2[prop]);
  8822. } else if (!utils.isUndefined(config1[prop])) {
  8823. config[prop] = getMergedValue(undefined, config1[prop]);
  8824. }
  8825. });
  8826. utils.forEach(directMergeKeys, function merge(prop) {
  8827. if (prop in config2) {
  8828. config[prop] = getMergedValue(config1[prop], config2[prop]);
  8829. } else if (prop in config1) {
  8830. config[prop] = getMergedValue(undefined, config1[prop]);
  8831. }
  8832. });
  8833. var axiosKeys = valueFromConfig2Keys
  8834. .concat(mergeDeepPropertiesKeys)
  8835. .concat(defaultToConfig2Keys)
  8836. .concat(directMergeKeys);
  8837. var otherKeys = Object
  8838. .keys(config1)
  8839. .concat(Object.keys(config2))
  8840. .filter(function filterAxiosKeys(key) {
  8841. return axiosKeys.indexOf(key) === -1;
  8842. });
  8843. utils.forEach(otherKeys, mergeDeepProperties);
  8844. return config;
  8845. };
  8846. /***/ }),
  8847. /***/ "./node_modules/axios/lib/core/settle.js":
  8848. /*!***********************************************!*\
  8849. !*** ./node_modules/axios/lib/core/settle.js ***!
  8850. \***********************************************/
  8851. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8852. "use strict";
  8853. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  8854. /**
  8855. * Resolve or reject a Promise based on response status.
  8856. *
  8857. * @param {Function} resolve A function that resolves the promise.
  8858. * @param {Function} reject A function that rejects the promise.
  8859. * @param {object} response The response.
  8860. */
  8861. module.exports = function settle(resolve, reject, response) {
  8862. var validateStatus = response.config.validateStatus;
  8863. if (!response.status || !validateStatus || validateStatus(response.status)) {
  8864. resolve(response);
  8865. } else {
  8866. reject(createError(
  8867. 'Request failed with status code ' + response.status,
  8868. response.config,
  8869. null,
  8870. response.request,
  8871. response
  8872. ));
  8873. }
  8874. };
  8875. /***/ }),
  8876. /***/ "./node_modules/axios/lib/core/transformData.js":
  8877. /*!******************************************************!*\
  8878. !*** ./node_modules/axios/lib/core/transformData.js ***!
  8879. \******************************************************/
  8880. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8881. "use strict";
  8882. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  8883. var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js");
  8884. /**
  8885. * Transform the data for a request or a response
  8886. *
  8887. * @param {Object|String} data The data to be transformed
  8888. * @param {Array} headers The headers for the request or response
  8889. * @param {Array|Function} fns A single function or Array of functions
  8890. * @returns {*} The resulting transformed data
  8891. */
  8892. module.exports = function transformData(data, headers, fns) {
  8893. var context = this || defaults;
  8894. /*eslint no-param-reassign:0*/
  8895. utils.forEach(fns, function transform(fn) {
  8896. data = fn.call(context, data, headers);
  8897. });
  8898. return data;
  8899. };
  8900. /***/ }),
  8901. /***/ "./node_modules/axios/lib/defaults.js":
  8902. /*!********************************************!*\
  8903. !*** ./node_modules/axios/lib/defaults.js ***!
  8904. \********************************************/
  8905. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8906. "use strict";
  8907. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  8908. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  8909. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  8910. var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  8911. var DEFAULT_CONTENT_TYPE = {
  8912. 'Content-Type': 'application/x-www-form-urlencoded'
  8913. };
  8914. function setContentTypeIfUnset(headers, value) {
  8915. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  8916. headers['Content-Type'] = value;
  8917. }
  8918. }
  8919. function getDefaultAdapter() {
  8920. var adapter;
  8921. if (typeof XMLHttpRequest !== 'undefined') {
  8922. // For browsers use XHR adapter
  8923. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  8924. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  8925. // For node use HTTP adapter
  8926. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  8927. }
  8928. return adapter;
  8929. }
  8930. function stringifySafely(rawValue, parser, encoder) {
  8931. if (utils.isString(rawValue)) {
  8932. try {
  8933. (parser || JSON.parse)(rawValue);
  8934. return utils.trim(rawValue);
  8935. } catch (e) {
  8936. if (e.name !== 'SyntaxError') {
  8937. throw e;
  8938. }
  8939. }
  8940. }
  8941. return (encoder || JSON.stringify)(rawValue);
  8942. }
  8943. var defaults = {
  8944. transitional: {
  8945. silentJSONParsing: true,
  8946. forcedJSONParsing: true,
  8947. clarifyTimeoutError: false
  8948. },
  8949. adapter: getDefaultAdapter(),
  8950. transformRequest: [function transformRequest(data, headers) {
  8951. normalizeHeaderName(headers, 'Accept');
  8952. normalizeHeaderName(headers, 'Content-Type');
  8953. if (utils.isFormData(data) ||
  8954. utils.isArrayBuffer(data) ||
  8955. utils.isBuffer(data) ||
  8956. utils.isStream(data) ||
  8957. utils.isFile(data) ||
  8958. utils.isBlob(data)
  8959. ) {
  8960. return data;
  8961. }
  8962. if (utils.isArrayBufferView(data)) {
  8963. return data.buffer;
  8964. }
  8965. if (utils.isURLSearchParams(data)) {
  8966. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  8967. return data.toString();
  8968. }
  8969. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  8970. setContentTypeIfUnset(headers, 'application/json');
  8971. return stringifySafely(data);
  8972. }
  8973. return data;
  8974. }],
  8975. transformResponse: [function transformResponse(data) {
  8976. var transitional = this.transitional;
  8977. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  8978. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  8979. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  8980. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  8981. try {
  8982. return JSON.parse(data);
  8983. } catch (e) {
  8984. if (strictJSONParsing) {
  8985. if (e.name === 'SyntaxError') {
  8986. throw enhanceError(e, this, 'E_JSON_PARSE');
  8987. }
  8988. throw e;
  8989. }
  8990. }
  8991. }
  8992. return data;
  8993. }],
  8994. /**
  8995. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  8996. * timeout is not created.
  8997. */
  8998. timeout: 0,
  8999. xsrfCookieName: 'XSRF-TOKEN',
  9000. xsrfHeaderName: 'X-XSRF-TOKEN',
  9001. maxContentLength: -1,
  9002. maxBodyLength: -1,
  9003. validateStatus: function validateStatus(status) {
  9004. return status >= 200 && status < 300;
  9005. }
  9006. };
  9007. defaults.headers = {
  9008. common: {
  9009. 'Accept': 'application/json, text/plain, */*'
  9010. }
  9011. };
  9012. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  9013. defaults.headers[method] = {};
  9014. });
  9015. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  9016. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  9017. });
  9018. module.exports = defaults;
  9019. /***/ }),
  9020. /***/ "./node_modules/axios/lib/helpers/bind.js":
  9021. /*!************************************************!*\
  9022. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  9023. \************************************************/
  9024. /***/ ((module) => {
  9025. "use strict";
  9026. module.exports = function bind(fn, thisArg) {
  9027. return function wrap() {
  9028. var args = new Array(arguments.length);
  9029. for (var i = 0; i < args.length; i++) {
  9030. args[i] = arguments[i];
  9031. }
  9032. return fn.apply(thisArg, args);
  9033. };
  9034. };
  9035. /***/ }),
  9036. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  9037. /*!****************************************************!*\
  9038. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  9039. \****************************************************/
  9040. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9041. "use strict";
  9042. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  9043. function encode(val) {
  9044. return encodeURIComponent(val).
  9045. replace(/%3A/gi, ':').
  9046. replace(/%24/g, '$').
  9047. replace(/%2C/gi, ',').
  9048. replace(/%20/g, '+').
  9049. replace(/%5B/gi, '[').
  9050. replace(/%5D/gi, ']');
  9051. }
  9052. /**
  9053. * Build a URL by appending params to the end
  9054. *
  9055. * @param {string} url The base of the url (e.g., http://www.google.com)
  9056. * @param {object} [params] The params to be appended
  9057. * @returns {string} The formatted url
  9058. */
  9059. module.exports = function buildURL(url, params, paramsSerializer) {
  9060. /*eslint no-param-reassign:0*/
  9061. if (!params) {
  9062. return url;
  9063. }
  9064. var serializedParams;
  9065. if (paramsSerializer) {
  9066. serializedParams = paramsSerializer(params);
  9067. } else if (utils.isURLSearchParams(params)) {
  9068. serializedParams = params.toString();
  9069. } else {
  9070. var parts = [];
  9071. utils.forEach(params, function serialize(val, key) {
  9072. if (val === null || typeof val === 'undefined') {
  9073. return;
  9074. }
  9075. if (utils.isArray(val)) {
  9076. key = key + '[]';
  9077. } else {
  9078. val = [val];
  9079. }
  9080. utils.forEach(val, function parseValue(v) {
  9081. if (utils.isDate(v)) {
  9082. v = v.toISOString();
  9083. } else if (utils.isObject(v)) {
  9084. v = JSON.stringify(v);
  9085. }
  9086. parts.push(encode(key) + '=' + encode(v));
  9087. });
  9088. });
  9089. serializedParams = parts.join('&');
  9090. }
  9091. if (serializedParams) {
  9092. var hashmarkIndex = url.indexOf('#');
  9093. if (hashmarkIndex !== -1) {
  9094. url = url.slice(0, hashmarkIndex);
  9095. }
  9096. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  9097. }
  9098. return url;
  9099. };
  9100. /***/ }),
  9101. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  9102. /*!*******************************************************!*\
  9103. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  9104. \*******************************************************/
  9105. /***/ ((module) => {
  9106. "use strict";
  9107. /**
  9108. * Creates a new URL by combining the specified URLs
  9109. *
  9110. * @param {string} baseURL The base URL
  9111. * @param {string} relativeURL The relative URL
  9112. * @returns {string} The combined URL
  9113. */
  9114. module.exports = function combineURLs(baseURL, relativeURL) {
  9115. return relativeURL
  9116. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  9117. : baseURL;
  9118. };
  9119. /***/ }),
  9120. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  9121. /*!***************************************************!*\
  9122. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  9123. \***************************************************/
  9124. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9125. "use strict";
  9126. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  9127. module.exports = (
  9128. utils.isStandardBrowserEnv() ?
  9129. // Standard browser envs support document.cookie
  9130. (function standardBrowserEnv() {
  9131. return {
  9132. write: function write(name, value, expires, path, domain, secure) {
  9133. var cookie = [];
  9134. cookie.push(name + '=' + encodeURIComponent(value));
  9135. if (utils.isNumber(expires)) {
  9136. cookie.push('expires=' + new Date(expires).toGMTString());
  9137. }
  9138. if (utils.isString(path)) {
  9139. cookie.push('path=' + path);
  9140. }
  9141. if (utils.isString(domain)) {
  9142. cookie.push('domain=' + domain);
  9143. }
  9144. if (secure === true) {
  9145. cookie.push('secure');
  9146. }
  9147. document.cookie = cookie.join('; ');
  9148. },
  9149. read: function read(name) {
  9150. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  9151. return (match ? decodeURIComponent(match[3]) : null);
  9152. },
  9153. remove: function remove(name) {
  9154. this.write(name, '', Date.now() - 86400000);
  9155. }
  9156. };
  9157. })() :
  9158. // Non standard browser env (web workers, react-native) lack needed support.
  9159. (function nonStandardBrowserEnv() {
  9160. return {
  9161. write: function write() {},
  9162. read: function read() { return null; },
  9163. remove: function remove() {}
  9164. };
  9165. })()
  9166. );
  9167. /***/ }),
  9168. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  9169. /*!*********************************************************!*\
  9170. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  9171. \*********************************************************/
  9172. /***/ ((module) => {
  9173. "use strict";
  9174. /**
  9175. * Determines whether the specified URL is absolute
  9176. *
  9177. * @param {string} url The URL to test
  9178. * @returns {boolean} True if the specified URL is absolute, otherwise false
  9179. */
  9180. module.exports = function isAbsoluteURL(url) {
  9181. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  9182. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  9183. // by any combination of letters, digits, plus, period, or hyphen.
  9184. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  9185. };
  9186. /***/ }),
  9187. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  9188. /*!********************************************************!*\
  9189. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  9190. \********************************************************/
  9191. /***/ ((module) => {
  9192. "use strict";
  9193. /**
  9194. * Determines whether the payload is an error thrown by Axios
  9195. *
  9196. * @param {*} payload The value to test
  9197. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  9198. */
  9199. module.exports = function isAxiosError(payload) {
  9200. return (typeof payload === 'object') && (payload.isAxiosError === true);
  9201. };
  9202. /***/ }),
  9203. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  9204. /*!***********************************************************!*\
  9205. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  9206. \***********************************************************/
  9207. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9208. "use strict";
  9209. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  9210. module.exports = (
  9211. utils.isStandardBrowserEnv() ?
  9212. // Standard browser envs have full support of the APIs needed to test
  9213. // whether the request URL is of the same origin as current location.
  9214. (function standardBrowserEnv() {
  9215. var msie = /(msie|trident)/i.test(navigator.userAgent);
  9216. var urlParsingNode = document.createElement('a');
  9217. var originURL;
  9218. /**
  9219. * Parse a URL to discover it's components
  9220. *
  9221. * @param {String} url The URL to be parsed
  9222. * @returns {Object}
  9223. */
  9224. function resolveURL(url) {
  9225. var href = url;
  9226. if (msie) {
  9227. // IE needs attribute set twice to normalize properties
  9228. urlParsingNode.setAttribute('href', href);
  9229. href = urlParsingNode.href;
  9230. }
  9231. urlParsingNode.setAttribute('href', href);
  9232. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  9233. return {
  9234. href: urlParsingNode.href,
  9235. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  9236. host: urlParsingNode.host,
  9237. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  9238. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  9239. hostname: urlParsingNode.hostname,
  9240. port: urlParsingNode.port,
  9241. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  9242. urlParsingNode.pathname :
  9243. '/' + urlParsingNode.pathname
  9244. };
  9245. }
  9246. originURL = resolveURL(window.location.href);
  9247. /**
  9248. * Determine if a URL shares the same origin as the current location
  9249. *
  9250. * @param {String} requestURL The URL to test
  9251. * @returns {boolean} True if URL shares the same origin, otherwise false
  9252. */
  9253. return function isURLSameOrigin(requestURL) {
  9254. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  9255. return (parsed.protocol === originURL.protocol &&
  9256. parsed.host === originURL.host);
  9257. };
  9258. })() :
  9259. // Non standard browser envs (web workers, react-native) lack needed support.
  9260. (function nonStandardBrowserEnv() {
  9261. return function isURLSameOrigin() {
  9262. return true;
  9263. };
  9264. })()
  9265. );
  9266. /***/ }),
  9267. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  9268. /*!***************************************************************!*\
  9269. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  9270. \***************************************************************/
  9271. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9272. "use strict";
  9273. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  9274. module.exports = function normalizeHeaderName(headers, normalizedName) {
  9275. utils.forEach(headers, function processHeader(value, name) {
  9276. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  9277. headers[normalizedName] = value;
  9278. delete headers[name];
  9279. }
  9280. });
  9281. };
  9282. /***/ }),
  9283. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  9284. /*!********************************************************!*\
  9285. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  9286. \********************************************************/
  9287. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9288. "use strict";
  9289. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  9290. // Headers whose duplicates are ignored by node
  9291. // c.f. https://nodejs.org/api/http.html#http_message_headers
  9292. var ignoreDuplicateOf = [
  9293. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  9294. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  9295. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  9296. 'referer', 'retry-after', 'user-agent'
  9297. ];
  9298. /**
  9299. * Parse headers into an object
  9300. *
  9301. * ```
  9302. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  9303. * Content-Type: application/json
  9304. * Connection: keep-alive
  9305. * Transfer-Encoding: chunked
  9306. * ```
  9307. *
  9308. * @param {String} headers Headers needing to be parsed
  9309. * @returns {Object} Headers parsed into an object
  9310. */
  9311. module.exports = function parseHeaders(headers) {
  9312. var parsed = {};
  9313. var key;
  9314. var val;
  9315. var i;
  9316. if (!headers) { return parsed; }
  9317. utils.forEach(headers.split('\n'), function parser(line) {
  9318. i = line.indexOf(':');
  9319. key = utils.trim(line.substr(0, i)).toLowerCase();
  9320. val = utils.trim(line.substr(i + 1));
  9321. if (key) {
  9322. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  9323. return;
  9324. }
  9325. if (key === 'set-cookie') {
  9326. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  9327. } else {
  9328. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  9329. }
  9330. }
  9331. });
  9332. return parsed;
  9333. };
  9334. /***/ }),
  9335. /***/ "./node_modules/axios/lib/helpers/spread.js":
  9336. /*!**************************************************!*\
  9337. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  9338. \**************************************************/
  9339. /***/ ((module) => {
  9340. "use strict";
  9341. /**
  9342. * Syntactic sugar for invoking a function and expanding an array for arguments.
  9343. *
  9344. * Common use case would be to use `Function.prototype.apply`.
  9345. *
  9346. * ```js
  9347. * function f(x, y, z) {}
  9348. * var args = [1, 2, 3];
  9349. * f.apply(null, args);
  9350. * ```
  9351. *
  9352. * With `spread` this example can be re-written.
  9353. *
  9354. * ```js
  9355. * spread(function(x, y, z) {})([1, 2, 3]);
  9356. * ```
  9357. *
  9358. * @param {Function} callback
  9359. * @returns {Function}
  9360. */
  9361. module.exports = function spread(callback) {
  9362. return function wrap(arr) {
  9363. return callback.apply(null, arr);
  9364. };
  9365. };
  9366. /***/ }),
  9367. /***/ "./node_modules/axios/lib/helpers/validator.js":
  9368. /*!*****************************************************!*\
  9369. !*** ./node_modules/axios/lib/helpers/validator.js ***!
  9370. \*****************************************************/
  9371. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9372. "use strict";
  9373. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  9374. var pkg = __webpack_require__(/*! ./../../package.json */ "./node_modules/axios/package.json");
  9375. var validators = {};
  9376. // eslint-disable-next-line func-names
  9377. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  9378. validators[type] = function validator(thing) {
  9379. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  9380. };
  9381. });
  9382. var deprecatedWarnings = {};
  9383. var currentVerArr = pkg.version.split('.');
  9384. /**
  9385. * Compare package versions
  9386. * @param {string} version
  9387. * @param {string?} thanVersion
  9388. * @returns {boolean}
  9389. */
  9390. function isOlderVersion(version, thanVersion) {
  9391. var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
  9392. var destVer = version.split('.');
  9393. for (var i = 0; i < 3; i++) {
  9394. if (pkgVersionArr[i] > destVer[i]) {
  9395. return true;
  9396. } else if (pkgVersionArr[i] < destVer[i]) {
  9397. return false;
  9398. }
  9399. }
  9400. return false;
  9401. }
  9402. /**
  9403. * Transitional option validator
  9404. * @param {function|boolean?} validator
  9405. * @param {string?} version
  9406. * @param {string} message
  9407. * @returns {function}
  9408. */
  9409. validators.transitional = function transitional(validator, version, message) {
  9410. var isDeprecated = version && isOlderVersion(version);
  9411. function formatMessage(opt, desc) {
  9412. return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  9413. }
  9414. // eslint-disable-next-line func-names
  9415. return function(value, opt, opts) {
  9416. if (validator === false) {
  9417. throw new Error(formatMessage(opt, ' has been removed in ' + version));
  9418. }
  9419. if (isDeprecated && !deprecatedWarnings[opt]) {
  9420. deprecatedWarnings[opt] = true;
  9421. // eslint-disable-next-line no-console
  9422. console.warn(
  9423. formatMessage(
  9424. opt,
  9425. ' has been deprecated since v' + version + ' and will be removed in the near future'
  9426. )
  9427. );
  9428. }
  9429. return validator ? validator(value, opt, opts) : true;
  9430. };
  9431. };
  9432. /**
  9433. * Assert object's properties type
  9434. * @param {object} options
  9435. * @param {object} schema
  9436. * @param {boolean?} allowUnknown
  9437. */
  9438. function assertOptions(options, schema, allowUnknown) {
  9439. if (typeof options !== 'object') {
  9440. throw new TypeError('options must be an object');
  9441. }
  9442. var keys = Object.keys(options);
  9443. var i = keys.length;
  9444. while (i-- > 0) {
  9445. var opt = keys[i];
  9446. var validator = schema[opt];
  9447. if (validator) {
  9448. var value = options[opt];
  9449. var result = value === undefined || validator(value, opt, options);
  9450. if (result !== true) {
  9451. throw new TypeError('option ' + opt + ' must be ' + result);
  9452. }
  9453. continue;
  9454. }
  9455. if (allowUnknown !== true) {
  9456. throw Error('Unknown option ' + opt);
  9457. }
  9458. }
  9459. }
  9460. module.exports = {
  9461. isOlderVersion: isOlderVersion,
  9462. assertOptions: assertOptions,
  9463. validators: validators
  9464. };
  9465. /***/ }),
  9466. /***/ "./node_modules/axios/lib/utils.js":
  9467. /*!*****************************************!*\
  9468. !*** ./node_modules/axios/lib/utils.js ***!
  9469. \*****************************************/
  9470. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  9471. "use strict";
  9472. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  9473. // utils is a library of generic helper functions non-specific to axios
  9474. var toString = Object.prototype.toString;
  9475. /**
  9476. * Determine if a value is an Array
  9477. *
  9478. * @param {Object} val The value to test
  9479. * @returns {boolean} True if value is an Array, otherwise false
  9480. */
  9481. function isArray(val) {
  9482. return toString.call(val) === '[object Array]';
  9483. }
  9484. /**
  9485. * Determine if a value is undefined
  9486. *
  9487. * @param {Object} val The value to test
  9488. * @returns {boolean} True if the value is undefined, otherwise false
  9489. */
  9490. function isUndefined(val) {
  9491. return typeof val === 'undefined';
  9492. }
  9493. /**
  9494. * Determine if a value is a Buffer
  9495. *
  9496. * @param {Object} val The value to test
  9497. * @returns {boolean} True if value is a Buffer, otherwise false
  9498. */
  9499. function isBuffer(val) {
  9500. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  9501. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  9502. }
  9503. /**
  9504. * Determine if a value is an ArrayBuffer
  9505. *
  9506. * @param {Object} val The value to test
  9507. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  9508. */
  9509. function isArrayBuffer(val) {
  9510. return toString.call(val) === '[object ArrayBuffer]';
  9511. }
  9512. /**
  9513. * Determine if a value is a FormData
  9514. *
  9515. * @param {Object} val The value to test
  9516. * @returns {boolean} True if value is an FormData, otherwise false
  9517. */
  9518. function isFormData(val) {
  9519. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  9520. }
  9521. /**
  9522. * Determine if a value is a view on an ArrayBuffer
  9523. *
  9524. * @param {Object} val The value to test
  9525. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  9526. */
  9527. function isArrayBufferView(val) {
  9528. var result;
  9529. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  9530. result = ArrayBuffer.isView(val);
  9531. } else {
  9532. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  9533. }
  9534. return result;
  9535. }
  9536. /**
  9537. * Determine if a value is a String
  9538. *
  9539. * @param {Object} val The value to test
  9540. * @returns {boolean} True if value is a String, otherwise false
  9541. */
  9542. function isString(val) {
  9543. return typeof val === 'string';
  9544. }
  9545. /**
  9546. * Determine if a value is a Number
  9547. *
  9548. * @param {Object} val The value to test
  9549. * @returns {boolean} True if value is a Number, otherwise false
  9550. */
  9551. function isNumber(val) {
  9552. return typeof val === 'number';
  9553. }
  9554. /**
  9555. * Determine if a value is an Object
  9556. *
  9557. * @param {Object} val The value to test
  9558. * @returns {boolean} True if value is an Object, otherwise false
  9559. */
  9560. function isObject(val) {
  9561. return val !== null && typeof val === 'object';
  9562. }
  9563. /**
  9564. * Determine if a value is a plain Object
  9565. *
  9566. * @param {Object} val The value to test
  9567. * @return {boolean} True if value is a plain Object, otherwise false
  9568. */
  9569. function isPlainObject(val) {
  9570. if (toString.call(val) !== '[object Object]') {
  9571. return false;
  9572. }
  9573. var prototype = Object.getPrototypeOf(val);
  9574. return prototype === null || prototype === Object.prototype;
  9575. }
  9576. /**
  9577. * Determine if a value is a Date
  9578. *
  9579. * @param {Object} val The value to test
  9580. * @returns {boolean} True if value is a Date, otherwise false
  9581. */
  9582. function isDate(val) {
  9583. return toString.call(val) === '[object Date]';
  9584. }
  9585. /**
  9586. * Determine if a value is a File
  9587. *
  9588. * @param {Object} val The value to test
  9589. * @returns {boolean} True if value is a File, otherwise false
  9590. */
  9591. function isFile(val) {
  9592. return toString.call(val) === '[object File]';
  9593. }
  9594. /**
  9595. * Determine if a value is a Blob
  9596. *
  9597. * @param {Object} val The value to test
  9598. * @returns {boolean} True if value is a Blob, otherwise false
  9599. */
  9600. function isBlob(val) {
  9601. return toString.call(val) === '[object Blob]';
  9602. }
  9603. /**
  9604. * Determine if a value is a Function
  9605. *
  9606. * @param {Object} val The value to test
  9607. * @returns {boolean} True if value is a Function, otherwise false
  9608. */
  9609. function isFunction(val) {
  9610. return toString.call(val) === '[object Function]';
  9611. }
  9612. /**
  9613. * Determine if a value is a Stream
  9614. *
  9615. * @param {Object} val The value to test
  9616. * @returns {boolean} True if value is a Stream, otherwise false
  9617. */
  9618. function isStream(val) {
  9619. return isObject(val) && isFunction(val.pipe);
  9620. }
  9621. /**
  9622. * Determine if a value is a URLSearchParams object
  9623. *
  9624. * @param {Object} val The value to test
  9625. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  9626. */
  9627. function isURLSearchParams(val) {
  9628. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  9629. }
  9630. /**
  9631. * Trim excess whitespace off the beginning and end of a string
  9632. *
  9633. * @param {String} str The String to trim
  9634. * @returns {String} The String freed of excess whitespace
  9635. */
  9636. function trim(str) {
  9637. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  9638. }
  9639. /**
  9640. * Determine if we're running in a standard browser environment
  9641. *
  9642. * This allows axios to run in a web worker, and react-native.
  9643. * Both environments support XMLHttpRequest, but not fully standard globals.
  9644. *
  9645. * web workers:
  9646. * typeof window -> undefined
  9647. * typeof document -> undefined
  9648. *
  9649. * react-native:
  9650. * navigator.product -> 'ReactNative'
  9651. * nativescript
  9652. * navigator.product -> 'NativeScript' or 'NS'
  9653. */
  9654. function isStandardBrowserEnv() {
  9655. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  9656. navigator.product === 'NativeScript' ||
  9657. navigator.product === 'NS')) {
  9658. return false;
  9659. }
  9660. return (
  9661. typeof window !== 'undefined' &&
  9662. typeof document !== 'undefined'
  9663. );
  9664. }
  9665. /**
  9666. * Iterate over an Array or an Object invoking a function for each item.
  9667. *
  9668. * If `obj` is an Array callback will be called passing
  9669. * the value, index, and complete array for each item.
  9670. *
  9671. * If 'obj' is an Object callback will be called passing
  9672. * the value, key, and complete object for each property.
  9673. *
  9674. * @param {Object|Array} obj The object to iterate
  9675. * @param {Function} fn The callback to invoke for each item
  9676. */
  9677. function forEach(obj, fn) {
  9678. // Don't bother if no value provided
  9679. if (obj === null || typeof obj === 'undefined') {
  9680. return;
  9681. }
  9682. // Force an array if not already something iterable
  9683. if (typeof obj !== 'object') {
  9684. /*eslint no-param-reassign:0*/
  9685. obj = [obj];
  9686. }
  9687. if (isArray(obj)) {
  9688. // Iterate over array values
  9689. for (var i = 0, l = obj.length; i < l; i++) {
  9690. fn.call(null, obj[i], i, obj);
  9691. }
  9692. } else {
  9693. // Iterate over object keys
  9694. for (var key in obj) {
  9695. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  9696. fn.call(null, obj[key], key, obj);
  9697. }
  9698. }
  9699. }
  9700. }
  9701. /**
  9702. * Accepts varargs expecting each argument to be an object, then
  9703. * immutably merges the properties of each object and returns result.
  9704. *
  9705. * When multiple objects contain the same key the later object in
  9706. * the arguments list will take precedence.
  9707. *
  9708. * Example:
  9709. *
  9710. * ```js
  9711. * var result = merge({foo: 123}, {foo: 456});
  9712. * console.log(result.foo); // outputs 456
  9713. * ```
  9714. *
  9715. * @param {Object} obj1 Object to merge
  9716. * @returns {Object} Result of all merge properties
  9717. */
  9718. function merge(/* obj1, obj2, obj3, ... */) {
  9719. var result = {};
  9720. function assignValue(val, key) {
  9721. if (isPlainObject(result[key]) && isPlainObject(val)) {
  9722. result[key] = merge(result[key], val);
  9723. } else if (isPlainObject(val)) {
  9724. result[key] = merge({}, val);
  9725. } else if (isArray(val)) {
  9726. result[key] = val.slice();
  9727. } else {
  9728. result[key] = val;
  9729. }
  9730. }
  9731. for (var i = 0, l = arguments.length; i < l; i++) {
  9732. forEach(arguments[i], assignValue);
  9733. }
  9734. return result;
  9735. }
  9736. /**
  9737. * Extends object a by mutably adding to it the properties of object b.
  9738. *
  9739. * @param {Object} a The object to be extended
  9740. * @param {Object} b The object to copy properties from
  9741. * @param {Object} thisArg The object to bind function to
  9742. * @return {Object} The resulting value of object a
  9743. */
  9744. function extend(a, b, thisArg) {
  9745. forEach(b, function assignValue(val, key) {
  9746. if (thisArg && typeof val === 'function') {
  9747. a[key] = bind(val, thisArg);
  9748. } else {
  9749. a[key] = val;
  9750. }
  9751. });
  9752. return a;
  9753. }
  9754. /**
  9755. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  9756. *
  9757. * @param {string} content with BOM
  9758. * @return {string} content value without BOM
  9759. */
  9760. function stripBOM(content) {
  9761. if (content.charCodeAt(0) === 0xFEFF) {
  9762. content = content.slice(1);
  9763. }
  9764. return content;
  9765. }
  9766. module.exports = {
  9767. isArray: isArray,
  9768. isArrayBuffer: isArrayBuffer,
  9769. isBuffer: isBuffer,
  9770. isFormData: isFormData,
  9771. isArrayBufferView: isArrayBufferView,
  9772. isString: isString,
  9773. isNumber: isNumber,
  9774. isObject: isObject,
  9775. isPlainObject: isPlainObject,
  9776. isUndefined: isUndefined,
  9777. isDate: isDate,
  9778. isFile: isFile,
  9779. isBlob: isBlob,
  9780. isFunction: isFunction,
  9781. isStream: isStream,
  9782. isURLSearchParams: isURLSearchParams,
  9783. isStandardBrowserEnv: isStandardBrowserEnv,
  9784. forEach: forEach,
  9785. merge: merge,
  9786. extend: extend,
  9787. trim: trim,
  9788. stripBOM: stripBOM
  9789. };
  9790. /***/ }),
  9791. /***/ "./resources/js/app.js":
  9792. /*!*****************************!*\
  9793. !*** ./resources/js/app.js ***!
  9794. \*****************************/
  9795. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  9796. "use strict";
  9797. __webpack_require__.r(__webpack_exports__);
  9798. /* harmony import */ var crypto_random_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto-random-string */ "./node_modules/crypto-random-string/index.js");
  9799. /* harmony import */ var change_case__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! change-case */ "./node_modules/camel-case/dist.es2015/index.js");
  9800. /* harmony import */ var change_case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! change-case */ "./node_modules/capital-case/dist.es2015/index.js");
  9801. /* harmony import */ var change_case__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! change-case */ "./node_modules/constant-case/dist.es2015/index.js");
  9802. /* harmony import */ var change_case__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! change-case */ "./node_modules/snake-case/dist.es2015/index.js");
  9803. /* harmony import */ var change_case__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! change-case */ "./node_modules/dot-case/dist.es2015/index.js");
  9804. /* harmony import */ var change_case__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! change-case */ "./node_modules/param-case/dist.es2015/index.js");
  9805. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  9806. __webpack_require__(/*! izitoast/dist/css/iziToast.min.css */ "./node_modules/izitoast/dist/css/iziToast.min.css");
  9807. window.iziToast = __webpack_require__(/*! izitoast */ "./node_modules/izitoast/dist/js/iziToast.js");
  9808. window.jsonToPivotjson = __webpack_require__(/*! json-to-pivot-json */ "./node_modules/json-to-pivot-json/index.js");
  9809. window.cryptoRandomString = crypto_random_string__WEBPACK_IMPORTED_MODULE_0__["default"];
  9810. window.Clusterize = __webpack_require__(/*! clusterize.js */ "./node_modules/clusterize.js/clusterize.js");
  9811. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  9812. window.camelCase = change_case__WEBPACK_IMPORTED_MODULE_1__.camelCase;
  9813. window.capitalCase = change_case__WEBPACK_IMPORTED_MODULE_2__.capitalCase;
  9814. window.constantCase = change_case__WEBPACK_IMPORTED_MODULE_3__.constantCase;
  9815. window.snakeCase = change_case__WEBPACK_IMPORTED_MODULE_4__.snakeCase;
  9816. window.dotCase = change_case__WEBPACK_IMPORTED_MODULE_5__.dotCase;
  9817. window.paramCase = change_case__WEBPACK_IMPORTED_MODULE_6__.paramCase;
  9818. iziToast.settings({
  9819. titleSize: '22',
  9820. messageSize: '17',
  9821. transitionIn: 'flipInX',
  9822. transitionOut: 'flipOutX',
  9823. timeout: 5000,
  9824. onOpen: function onOpen() {
  9825. // console.log('callback abriu!');
  9826. },
  9827. onClose: function onClose() {
  9828. // console.log("callback fechou!");
  9829. }
  9830. });
  9831. window.pagination = __webpack_require__(/*! vuejs-uib-pagination */ "./node_modules/vuejs-uib-pagination/dist/vuejs-uib-pagination.js");
  9832. window.masonry = __webpack_require__(/*! vue-masonry-css */ "./node_modules/vue-masonry-css/dist/vue-masonry.es2015.js");
  9833. /***/ }),
  9834. /***/ "./resources/js/bootstrap.js":
  9835. /*!***********************************!*\
  9836. !*** ./resources/js/bootstrap.js ***!
  9837. \***********************************/
  9838. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  9839. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  9840. try {
  9841. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.esm.js");
  9842. } catch (e) {}
  9843. /**
  9844. * We'll load the axios HTTP library which allows us to easily issue requests
  9845. * to our Laravel back-end. This library automatically handles sending the
  9846. * CSRF token as a header based on the value of the "XSRF" token cookie.
  9847. */
  9848. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  9849. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  9850. /**
  9851. * Echo exposes an expressive API for subscribing to channels and listening
  9852. * for events that are broadcast by Laravel. Echo and event broadcasting
  9853. * allows your team to easily build robust real-time web applications.
  9854. */
  9855. // import Echo from 'laravel-echo';
  9856. // window.Pusher = require('pusher-js');
  9857. // window.Echo = new Echo({
  9858. // broadcaster: 'pusher',
  9859. // key: process.env.MIX_PUSHER_APP_KEY,
  9860. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  9861. // forceTLS: true
  9862. // });
  9863. /***/ }),
  9864. /***/ "./node_modules/base64-js/index.js":
  9865. /*!*****************************************!*\
  9866. !*** ./node_modules/base64-js/index.js ***!
  9867. \*****************************************/
  9868. /***/ ((__unused_webpack_module, exports) => {
  9869. "use strict";
  9870. exports.byteLength = byteLength
  9871. exports.toByteArray = toByteArray
  9872. exports.fromByteArray = fromByteArray
  9873. var lookup = []
  9874. var revLookup = []
  9875. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  9876. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  9877. for (var i = 0, len = code.length; i < len; ++i) {
  9878. lookup[i] = code[i]
  9879. revLookup[code.charCodeAt(i)] = i
  9880. }
  9881. // Support decoding URL-safe base64 strings, as Node.js does.
  9882. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  9883. revLookup['-'.charCodeAt(0)] = 62
  9884. revLookup['_'.charCodeAt(0)] = 63
  9885. function getLens (b64) {
  9886. var len = b64.length
  9887. if (len % 4 > 0) {
  9888. throw new Error('Invalid string. Length must be a multiple of 4')
  9889. }
  9890. // Trim off extra bytes after placeholder bytes are found
  9891. // See: https://github.com/beatgammit/base64-js/issues/42
  9892. var validLen = b64.indexOf('=')
  9893. if (validLen === -1) validLen = len
  9894. var placeHoldersLen = validLen === len
  9895. ? 0
  9896. : 4 - (validLen % 4)
  9897. return [validLen, placeHoldersLen]
  9898. }
  9899. // base64 is 4/3 + up to two characters of the original data
  9900. function byteLength (b64) {
  9901. var lens = getLens(b64)
  9902. var validLen = lens[0]
  9903. var placeHoldersLen = lens[1]
  9904. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  9905. }
  9906. function _byteLength (b64, validLen, placeHoldersLen) {
  9907. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  9908. }
  9909. function toByteArray (b64) {
  9910. var tmp
  9911. var lens = getLens(b64)
  9912. var validLen = lens[0]
  9913. var placeHoldersLen = lens[1]
  9914. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  9915. var curByte = 0
  9916. // if there are placeholders, only get up to the last complete 4 chars
  9917. var len = placeHoldersLen > 0
  9918. ? validLen - 4
  9919. : validLen
  9920. var i
  9921. for (i = 0; i < len; i += 4) {
  9922. tmp =
  9923. (revLookup[b64.charCodeAt(i)] << 18) |
  9924. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  9925. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  9926. revLookup[b64.charCodeAt(i + 3)]
  9927. arr[curByte++] = (tmp >> 16) & 0xFF
  9928. arr[curByte++] = (tmp >> 8) & 0xFF
  9929. arr[curByte++] = tmp & 0xFF
  9930. }
  9931. if (placeHoldersLen === 2) {
  9932. tmp =
  9933. (revLookup[b64.charCodeAt(i)] << 2) |
  9934. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  9935. arr[curByte++] = tmp & 0xFF
  9936. }
  9937. if (placeHoldersLen === 1) {
  9938. tmp =
  9939. (revLookup[b64.charCodeAt(i)] << 10) |
  9940. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  9941. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  9942. arr[curByte++] = (tmp >> 8) & 0xFF
  9943. arr[curByte++] = tmp & 0xFF
  9944. }
  9945. return arr
  9946. }
  9947. function tripletToBase64 (num) {
  9948. return lookup[num >> 18 & 0x3F] +
  9949. lookup[num >> 12 & 0x3F] +
  9950. lookup[num >> 6 & 0x3F] +
  9951. lookup[num & 0x3F]
  9952. }
  9953. function encodeChunk (uint8, start, end) {
  9954. var tmp
  9955. var output = []
  9956. for (var i = start; i < end; i += 3) {
  9957. tmp =
  9958. ((uint8[i] << 16) & 0xFF0000) +
  9959. ((uint8[i + 1] << 8) & 0xFF00) +
  9960. (uint8[i + 2] & 0xFF)
  9961. output.push(tripletToBase64(tmp))
  9962. }
  9963. return output.join('')
  9964. }
  9965. function fromByteArray (uint8) {
  9966. var tmp
  9967. var len = uint8.length
  9968. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  9969. var parts = []
  9970. var maxChunkLength = 16383 // must be multiple of 3
  9971. // go through the array every three bytes, we'll deal with trailing stuff later
  9972. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  9973. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  9974. }
  9975. // pad the end with zeros, but make sure to not forget the extra bytes
  9976. if (extraBytes === 1) {
  9977. tmp = uint8[len - 1]
  9978. parts.push(
  9979. lookup[tmp >> 2] +
  9980. lookup[(tmp << 4) & 0x3F] +
  9981. '=='
  9982. )
  9983. } else if (extraBytes === 2) {
  9984. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  9985. parts.push(
  9986. lookup[tmp >> 10] +
  9987. lookup[(tmp >> 4) & 0x3F] +
  9988. lookup[(tmp << 2) & 0x3F] +
  9989. '='
  9990. )
  9991. }
  9992. return parts.join('')
  9993. }
  9994. /***/ }),
  9995. /***/ "./node_modules/bn.js/lib/bn.js":
  9996. /*!**************************************!*\
  9997. !*** ./node_modules/bn.js/lib/bn.js ***!
  9998. \**************************************/
  9999. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  10000. /* module decorator */ module = __webpack_require__.nmd(module);
  10001. (function (module, exports) {
  10002. 'use strict';
  10003. // Utils
  10004. function assert (val, msg) {
  10005. if (!val) throw new Error(msg || 'Assertion failed');
  10006. }
  10007. // Could use `inherits` module, but don't want to move from single file
  10008. // architecture yet.
  10009. function inherits (ctor, superCtor) {
  10010. ctor.super_ = superCtor;
  10011. var TempCtor = function () {};
  10012. TempCtor.prototype = superCtor.prototype;
  10013. ctor.prototype = new TempCtor();
  10014. ctor.prototype.constructor = ctor;
  10015. }
  10016. // BN
  10017. function BN (number, base, endian) {
  10018. if (BN.isBN(number)) {
  10019. return number;
  10020. }
  10021. this.negative = 0;
  10022. this.words = null;
  10023. this.length = 0;
  10024. // Reduction context
  10025. this.red = null;
  10026. if (number !== null) {
  10027. if (base === 'le' || base === 'be') {
  10028. endian = base;
  10029. base = 10;
  10030. }
  10031. this._init(number || 0, base || 10, endian || 'be');
  10032. }
  10033. }
  10034. if (typeof module === 'object') {
  10035. module.exports = BN;
  10036. } else {
  10037. exports.BN = BN;
  10038. }
  10039. BN.BN = BN;
  10040. BN.wordSize = 26;
  10041. var Buffer;
  10042. try {
  10043. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  10044. Buffer = window.Buffer;
  10045. } else {
  10046. Buffer = (__webpack_require__(/*! buffer */ "?f4e8").Buffer);
  10047. }
  10048. } catch (e) {
  10049. }
  10050. BN.isBN = function isBN (num) {
  10051. if (num instanceof BN) {
  10052. return true;
  10053. }
  10054. return num !== null && typeof num === 'object' &&
  10055. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  10056. };
  10057. BN.max = function max (left, right) {
  10058. if (left.cmp(right) > 0) return left;
  10059. return right;
  10060. };
  10061. BN.min = function min (left, right) {
  10062. if (left.cmp(right) < 0) return left;
  10063. return right;
  10064. };
  10065. BN.prototype._init = function init (number, base, endian) {
  10066. if (typeof number === 'number') {
  10067. return this._initNumber(number, base, endian);
  10068. }
  10069. if (typeof number === 'object') {
  10070. return this._initArray(number, base, endian);
  10071. }
  10072. if (base === 'hex') {
  10073. base = 16;
  10074. }
  10075. assert(base === (base | 0) && base >= 2 && base <= 36);
  10076. number = number.toString().replace(/\s+/g, '');
  10077. var start = 0;
  10078. if (number[0] === '-') {
  10079. start++;
  10080. this.negative = 1;
  10081. }
  10082. if (start < number.length) {
  10083. if (base === 16) {
  10084. this._parseHex(number, start, endian);
  10085. } else {
  10086. this._parseBase(number, base, start);
  10087. if (endian === 'le') {
  10088. this._initArray(this.toArray(), base, endian);
  10089. }
  10090. }
  10091. }
  10092. };
  10093. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  10094. if (number < 0) {
  10095. this.negative = 1;
  10096. number = -number;
  10097. }
  10098. if (number < 0x4000000) {
  10099. this.words = [number & 0x3ffffff];
  10100. this.length = 1;
  10101. } else if (number < 0x10000000000000) {
  10102. this.words = [
  10103. number & 0x3ffffff,
  10104. (number / 0x4000000) & 0x3ffffff
  10105. ];
  10106. this.length = 2;
  10107. } else {
  10108. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  10109. this.words = [
  10110. number & 0x3ffffff,
  10111. (number / 0x4000000) & 0x3ffffff,
  10112. 1
  10113. ];
  10114. this.length = 3;
  10115. }
  10116. if (endian !== 'le') return;
  10117. // Reverse the bytes
  10118. this._initArray(this.toArray(), base, endian);
  10119. };
  10120. BN.prototype._initArray = function _initArray (number, base, endian) {
  10121. // Perhaps a Uint8Array
  10122. assert(typeof number.length === 'number');
  10123. if (number.length <= 0) {
  10124. this.words = [0];
  10125. this.length = 1;
  10126. return this;
  10127. }
  10128. this.length = Math.ceil(number.length / 3);
  10129. this.words = new Array(this.length);
  10130. for (var i = 0; i < this.length; i++) {
  10131. this.words[i] = 0;
  10132. }
  10133. var j, w;
  10134. var off = 0;
  10135. if (endian === 'be') {
  10136. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  10137. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  10138. this.words[j] |= (w << off) & 0x3ffffff;
  10139. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  10140. off += 24;
  10141. if (off >= 26) {
  10142. off -= 26;
  10143. j++;
  10144. }
  10145. }
  10146. } else if (endian === 'le') {
  10147. for (i = 0, j = 0; i < number.length; i += 3) {
  10148. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  10149. this.words[j] |= (w << off) & 0x3ffffff;
  10150. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  10151. off += 24;
  10152. if (off >= 26) {
  10153. off -= 26;
  10154. j++;
  10155. }
  10156. }
  10157. }
  10158. return this._strip();
  10159. };
  10160. function parseHex4Bits (string, index) {
  10161. var c = string.charCodeAt(index);
  10162. // '0' - '9'
  10163. if (c >= 48 && c <= 57) {
  10164. return c - 48;
  10165. // 'A' - 'F'
  10166. } else if (c >= 65 && c <= 70) {
  10167. return c - 55;
  10168. // 'a' - 'f'
  10169. } else if (c >= 97 && c <= 102) {
  10170. return c - 87;
  10171. } else {
  10172. assert(false, 'Invalid character in ' + string);
  10173. }
  10174. }
  10175. function parseHexByte (string, lowerBound, index) {
  10176. var r = parseHex4Bits(string, index);
  10177. if (index - 1 >= lowerBound) {
  10178. r |= parseHex4Bits(string, index - 1) << 4;
  10179. }
  10180. return r;
  10181. }
  10182. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  10183. // Create possibly bigger array to ensure that it fits the number
  10184. this.length = Math.ceil((number.length - start) / 6);
  10185. this.words = new Array(this.length);
  10186. for (var i = 0; i < this.length; i++) {
  10187. this.words[i] = 0;
  10188. }
  10189. // 24-bits chunks
  10190. var off = 0;
  10191. var j = 0;
  10192. var w;
  10193. if (endian === 'be') {
  10194. for (i = number.length - 1; i >= start; i -= 2) {
  10195. w = parseHexByte(number, start, i) << off;
  10196. this.words[j] |= w & 0x3ffffff;
  10197. if (off >= 18) {
  10198. off -= 18;
  10199. j += 1;
  10200. this.words[j] |= w >>> 26;
  10201. } else {
  10202. off += 8;
  10203. }
  10204. }
  10205. } else {
  10206. var parseLength = number.length - start;
  10207. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  10208. w = parseHexByte(number, start, i) << off;
  10209. this.words[j] |= w & 0x3ffffff;
  10210. if (off >= 18) {
  10211. off -= 18;
  10212. j += 1;
  10213. this.words[j] |= w >>> 26;
  10214. } else {
  10215. off += 8;
  10216. }
  10217. }
  10218. }
  10219. this._strip();
  10220. };
  10221. function parseBase (str, start, end, mul) {
  10222. var r = 0;
  10223. var b = 0;
  10224. var len = Math.min(str.length, end);
  10225. for (var i = start; i < len; i++) {
  10226. var c = str.charCodeAt(i) - 48;
  10227. r *= mul;
  10228. // 'a'
  10229. if (c >= 49) {
  10230. b = c - 49 + 0xa;
  10231. // 'A'
  10232. } else if (c >= 17) {
  10233. b = c - 17 + 0xa;
  10234. // '0' - '9'
  10235. } else {
  10236. b = c;
  10237. }
  10238. assert(c >= 0 && b < mul, 'Invalid character');
  10239. r += b;
  10240. }
  10241. return r;
  10242. }
  10243. BN.prototype._parseBase = function _parseBase (number, base, start) {
  10244. // Initialize as zero
  10245. this.words = [0];
  10246. this.length = 1;
  10247. // Find length of limb in base
  10248. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  10249. limbLen++;
  10250. }
  10251. limbLen--;
  10252. limbPow = (limbPow / base) | 0;
  10253. var total = number.length - start;
  10254. var mod = total % limbLen;
  10255. var end = Math.min(total, total - mod) + start;
  10256. var word = 0;
  10257. for (var i = start; i < end; i += limbLen) {
  10258. word = parseBase(number, i, i + limbLen, base);
  10259. this.imuln(limbPow);
  10260. if (this.words[0] + word < 0x4000000) {
  10261. this.words[0] += word;
  10262. } else {
  10263. this._iaddn(word);
  10264. }
  10265. }
  10266. if (mod !== 0) {
  10267. var pow = 1;
  10268. word = parseBase(number, i, number.length, base);
  10269. for (i = 0; i < mod; i++) {
  10270. pow *= base;
  10271. }
  10272. this.imuln(pow);
  10273. if (this.words[0] + word < 0x4000000) {
  10274. this.words[0] += word;
  10275. } else {
  10276. this._iaddn(word);
  10277. }
  10278. }
  10279. this._strip();
  10280. };
  10281. BN.prototype.copy = function copy (dest) {
  10282. dest.words = new Array(this.length);
  10283. for (var i = 0; i < this.length; i++) {
  10284. dest.words[i] = this.words[i];
  10285. }
  10286. dest.length = this.length;
  10287. dest.negative = this.negative;
  10288. dest.red = this.red;
  10289. };
  10290. function move (dest, src) {
  10291. dest.words = src.words;
  10292. dest.length = src.length;
  10293. dest.negative = src.negative;
  10294. dest.red = src.red;
  10295. }
  10296. BN.prototype._move = function _move (dest) {
  10297. move(dest, this);
  10298. };
  10299. BN.prototype.clone = function clone () {
  10300. var r = new BN(null);
  10301. this.copy(r);
  10302. return r;
  10303. };
  10304. BN.prototype._expand = function _expand (size) {
  10305. while (this.length < size) {
  10306. this.words[this.length++] = 0;
  10307. }
  10308. return this;
  10309. };
  10310. // Remove leading `0` from `this`
  10311. BN.prototype._strip = function strip () {
  10312. while (this.length > 1 && this.words[this.length - 1] === 0) {
  10313. this.length--;
  10314. }
  10315. return this._normSign();
  10316. };
  10317. BN.prototype._normSign = function _normSign () {
  10318. // -0 = 0
  10319. if (this.length === 1 && this.words[0] === 0) {
  10320. this.negative = 0;
  10321. }
  10322. return this;
  10323. };
  10324. // Check Symbol.for because not everywhere where Symbol defined
  10325. // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility
  10326. if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {
  10327. try {
  10328. BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;
  10329. } catch (e) {
  10330. BN.prototype.inspect = inspect;
  10331. }
  10332. } else {
  10333. BN.prototype.inspect = inspect;
  10334. }
  10335. function inspect () {
  10336. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  10337. }
  10338. /*
  10339. var zeros = [];
  10340. var groupSizes = [];
  10341. var groupBases = [];
  10342. var s = '';
  10343. var i = -1;
  10344. while (++i < BN.wordSize) {
  10345. zeros[i] = s;
  10346. s += '0';
  10347. }
  10348. groupSizes[0] = 0;
  10349. groupSizes[1] = 0;
  10350. groupBases[0] = 0;
  10351. groupBases[1] = 0;
  10352. var base = 2 - 1;
  10353. while (++base < 36 + 1) {
  10354. var groupSize = 0;
  10355. var groupBase = 1;
  10356. while (groupBase < (1 << BN.wordSize) / base) {
  10357. groupBase *= base;
  10358. groupSize += 1;
  10359. }
  10360. groupSizes[base] = groupSize;
  10361. groupBases[base] = groupBase;
  10362. }
  10363. */
  10364. var zeros = [
  10365. '',
  10366. '0',
  10367. '00',
  10368. '000',
  10369. '0000',
  10370. '00000',
  10371. '000000',
  10372. '0000000',
  10373. '00000000',
  10374. '000000000',
  10375. '0000000000',
  10376. '00000000000',
  10377. '000000000000',
  10378. '0000000000000',
  10379. '00000000000000',
  10380. '000000000000000',
  10381. '0000000000000000',
  10382. '00000000000000000',
  10383. '000000000000000000',
  10384. '0000000000000000000',
  10385. '00000000000000000000',
  10386. '000000000000000000000',
  10387. '0000000000000000000000',
  10388. '00000000000000000000000',
  10389. '000000000000000000000000',
  10390. '0000000000000000000000000'
  10391. ];
  10392. var groupSizes = [
  10393. 0, 0,
  10394. 25, 16, 12, 11, 10, 9, 8,
  10395. 8, 7, 7, 7, 7, 6, 6,
  10396. 6, 6, 6, 6, 6, 5, 5,
  10397. 5, 5, 5, 5, 5, 5, 5,
  10398. 5, 5, 5, 5, 5, 5, 5
  10399. ];
  10400. var groupBases = [
  10401. 0, 0,
  10402. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  10403. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  10404. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  10405. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  10406. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  10407. ];
  10408. BN.prototype.toString = function toString (base, padding) {
  10409. base = base || 10;
  10410. padding = padding | 0 || 1;
  10411. var out;
  10412. if (base === 16 || base === 'hex') {
  10413. out = '';
  10414. var off = 0;
  10415. var carry = 0;
  10416. for (var i = 0; i < this.length; i++) {
  10417. var w = this.words[i];
  10418. var word = (((w << off) | carry) & 0xffffff).toString(16);
  10419. carry = (w >>> (24 - off)) & 0xffffff;
  10420. if (carry !== 0 || i !== this.length - 1) {
  10421. out = zeros[6 - word.length] + word + out;
  10422. } else {
  10423. out = word + out;
  10424. }
  10425. off += 2;
  10426. if (off >= 26) {
  10427. off -= 26;
  10428. i--;
  10429. }
  10430. }
  10431. if (carry !== 0) {
  10432. out = carry.toString(16) + out;
  10433. }
  10434. while (out.length % padding !== 0) {
  10435. out = '0' + out;
  10436. }
  10437. if (this.negative !== 0) {
  10438. out = '-' + out;
  10439. }
  10440. return out;
  10441. }
  10442. if (base === (base | 0) && base >= 2 && base <= 36) {
  10443. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  10444. var groupSize = groupSizes[base];
  10445. // var groupBase = Math.pow(base, groupSize);
  10446. var groupBase = groupBases[base];
  10447. out = '';
  10448. var c = this.clone();
  10449. c.negative = 0;
  10450. while (!c.isZero()) {
  10451. var r = c.modrn(groupBase).toString(base);
  10452. c = c.idivn(groupBase);
  10453. if (!c.isZero()) {
  10454. out = zeros[groupSize - r.length] + r + out;
  10455. } else {
  10456. out = r + out;
  10457. }
  10458. }
  10459. if (this.isZero()) {
  10460. out = '0' + out;
  10461. }
  10462. while (out.length % padding !== 0) {
  10463. out = '0' + out;
  10464. }
  10465. if (this.negative !== 0) {
  10466. out = '-' + out;
  10467. }
  10468. return out;
  10469. }
  10470. assert(false, 'Base should be between 2 and 36');
  10471. };
  10472. BN.prototype.toNumber = function toNumber () {
  10473. var ret = this.words[0];
  10474. if (this.length === 2) {
  10475. ret += this.words[1] * 0x4000000;
  10476. } else if (this.length === 3 && this.words[2] === 0x01) {
  10477. // NOTE: at this stage it is known that the top bit is set
  10478. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  10479. } else if (this.length > 2) {
  10480. assert(false, 'Number can only safely store up to 53 bits');
  10481. }
  10482. return (this.negative !== 0) ? -ret : ret;
  10483. };
  10484. BN.prototype.toJSON = function toJSON () {
  10485. return this.toString(16, 2);
  10486. };
  10487. if (Buffer) {
  10488. BN.prototype.toBuffer = function toBuffer (endian, length) {
  10489. return this.toArrayLike(Buffer, endian, length);
  10490. };
  10491. }
  10492. BN.prototype.toArray = function toArray (endian, length) {
  10493. return this.toArrayLike(Array, endian, length);
  10494. };
  10495. var allocate = function allocate (ArrayType, size) {
  10496. if (ArrayType.allocUnsafe) {
  10497. return ArrayType.allocUnsafe(size);
  10498. }
  10499. return new ArrayType(size);
  10500. };
  10501. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  10502. this._strip();
  10503. var byteLength = this.byteLength();
  10504. var reqLength = length || Math.max(1, byteLength);
  10505. assert(byteLength <= reqLength, 'byte array longer than desired length');
  10506. assert(reqLength > 0, 'Requested array length <= 0');
  10507. var res = allocate(ArrayType, reqLength);
  10508. var postfix = endian === 'le' ? 'LE' : 'BE';
  10509. this['_toArrayLike' + postfix](res, byteLength);
  10510. return res;
  10511. };
  10512. BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) {
  10513. var position = 0;
  10514. var carry = 0;
  10515. for (var i = 0, shift = 0; i < this.length; i++) {
  10516. var word = (this.words[i] << shift) | carry;
  10517. res[position++] = word & 0xff;
  10518. if (position < res.length) {
  10519. res[position++] = (word >> 8) & 0xff;
  10520. }
  10521. if (position < res.length) {
  10522. res[position++] = (word >> 16) & 0xff;
  10523. }
  10524. if (shift === 6) {
  10525. if (position < res.length) {
  10526. res[position++] = (word >> 24) & 0xff;
  10527. }
  10528. carry = 0;
  10529. shift = 0;
  10530. } else {
  10531. carry = word >>> 24;
  10532. shift += 2;
  10533. }
  10534. }
  10535. if (position < res.length) {
  10536. res[position++] = carry;
  10537. while (position < res.length) {
  10538. res[position++] = 0;
  10539. }
  10540. }
  10541. };
  10542. BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) {
  10543. var position = res.length - 1;
  10544. var carry = 0;
  10545. for (var i = 0, shift = 0; i < this.length; i++) {
  10546. var word = (this.words[i] << shift) | carry;
  10547. res[position--] = word & 0xff;
  10548. if (position >= 0) {
  10549. res[position--] = (word >> 8) & 0xff;
  10550. }
  10551. if (position >= 0) {
  10552. res[position--] = (word >> 16) & 0xff;
  10553. }
  10554. if (shift === 6) {
  10555. if (position >= 0) {
  10556. res[position--] = (word >> 24) & 0xff;
  10557. }
  10558. carry = 0;
  10559. shift = 0;
  10560. } else {
  10561. carry = word >>> 24;
  10562. shift += 2;
  10563. }
  10564. }
  10565. if (position >= 0) {
  10566. res[position--] = carry;
  10567. while (position >= 0) {
  10568. res[position--] = 0;
  10569. }
  10570. }
  10571. };
  10572. if (Math.clz32) {
  10573. BN.prototype._countBits = function _countBits (w) {
  10574. return 32 - Math.clz32(w);
  10575. };
  10576. } else {
  10577. BN.prototype._countBits = function _countBits (w) {
  10578. var t = w;
  10579. var r = 0;
  10580. if (t >= 0x1000) {
  10581. r += 13;
  10582. t >>>= 13;
  10583. }
  10584. if (t >= 0x40) {
  10585. r += 7;
  10586. t >>>= 7;
  10587. }
  10588. if (t >= 0x8) {
  10589. r += 4;
  10590. t >>>= 4;
  10591. }
  10592. if (t >= 0x02) {
  10593. r += 2;
  10594. t >>>= 2;
  10595. }
  10596. return r + t;
  10597. };
  10598. }
  10599. BN.prototype._zeroBits = function _zeroBits (w) {
  10600. // Short-cut
  10601. if (w === 0) return 26;
  10602. var t = w;
  10603. var r = 0;
  10604. if ((t & 0x1fff) === 0) {
  10605. r += 13;
  10606. t >>>= 13;
  10607. }
  10608. if ((t & 0x7f) === 0) {
  10609. r += 7;
  10610. t >>>= 7;
  10611. }
  10612. if ((t & 0xf) === 0) {
  10613. r += 4;
  10614. t >>>= 4;
  10615. }
  10616. if ((t & 0x3) === 0) {
  10617. r += 2;
  10618. t >>>= 2;
  10619. }
  10620. if ((t & 0x1) === 0) {
  10621. r++;
  10622. }
  10623. return r;
  10624. };
  10625. // Return number of used bits in a BN
  10626. BN.prototype.bitLength = function bitLength () {
  10627. var w = this.words[this.length - 1];
  10628. var hi = this._countBits(w);
  10629. return (this.length - 1) * 26 + hi;
  10630. };
  10631. function toBitArray (num) {
  10632. var w = new Array(num.bitLength());
  10633. for (var bit = 0; bit < w.length; bit++) {
  10634. var off = (bit / 26) | 0;
  10635. var wbit = bit % 26;
  10636. w[bit] = (num.words[off] >>> wbit) & 0x01;
  10637. }
  10638. return w;
  10639. }
  10640. // Number of trailing zero bits
  10641. BN.prototype.zeroBits = function zeroBits () {
  10642. if (this.isZero()) return 0;
  10643. var r = 0;
  10644. for (var i = 0; i < this.length; i++) {
  10645. var b = this._zeroBits(this.words[i]);
  10646. r += b;
  10647. if (b !== 26) break;
  10648. }
  10649. return r;
  10650. };
  10651. BN.prototype.byteLength = function byteLength () {
  10652. return Math.ceil(this.bitLength() / 8);
  10653. };
  10654. BN.prototype.toTwos = function toTwos (width) {
  10655. if (this.negative !== 0) {
  10656. return this.abs().inotn(width).iaddn(1);
  10657. }
  10658. return this.clone();
  10659. };
  10660. BN.prototype.fromTwos = function fromTwos (width) {
  10661. if (this.testn(width - 1)) {
  10662. return this.notn(width).iaddn(1).ineg();
  10663. }
  10664. return this.clone();
  10665. };
  10666. BN.prototype.isNeg = function isNeg () {
  10667. return this.negative !== 0;
  10668. };
  10669. // Return negative clone of `this`
  10670. BN.prototype.neg = function neg () {
  10671. return this.clone().ineg();
  10672. };
  10673. BN.prototype.ineg = function ineg () {
  10674. if (!this.isZero()) {
  10675. this.negative ^= 1;
  10676. }
  10677. return this;
  10678. };
  10679. // Or `num` with `this` in-place
  10680. BN.prototype.iuor = function iuor (num) {
  10681. while (this.length < num.length) {
  10682. this.words[this.length++] = 0;
  10683. }
  10684. for (var i = 0; i < num.length; i++) {
  10685. this.words[i] = this.words[i] | num.words[i];
  10686. }
  10687. return this._strip();
  10688. };
  10689. BN.prototype.ior = function ior (num) {
  10690. assert((this.negative | num.negative) === 0);
  10691. return this.iuor(num);
  10692. };
  10693. // Or `num` with `this`
  10694. BN.prototype.or = function or (num) {
  10695. if (this.length > num.length) return this.clone().ior(num);
  10696. return num.clone().ior(this);
  10697. };
  10698. BN.prototype.uor = function uor (num) {
  10699. if (this.length > num.length) return this.clone().iuor(num);
  10700. return num.clone().iuor(this);
  10701. };
  10702. // And `num` with `this` in-place
  10703. BN.prototype.iuand = function iuand (num) {
  10704. // b = min-length(num, this)
  10705. var b;
  10706. if (this.length > num.length) {
  10707. b = num;
  10708. } else {
  10709. b = this;
  10710. }
  10711. for (var i = 0; i < b.length; i++) {
  10712. this.words[i] = this.words[i] & num.words[i];
  10713. }
  10714. this.length = b.length;
  10715. return this._strip();
  10716. };
  10717. BN.prototype.iand = function iand (num) {
  10718. assert((this.negative | num.negative) === 0);
  10719. return this.iuand(num);
  10720. };
  10721. // And `num` with `this`
  10722. BN.prototype.and = function and (num) {
  10723. if (this.length > num.length) return this.clone().iand(num);
  10724. return num.clone().iand(this);
  10725. };
  10726. BN.prototype.uand = function uand (num) {
  10727. if (this.length > num.length) return this.clone().iuand(num);
  10728. return num.clone().iuand(this);
  10729. };
  10730. // Xor `num` with `this` in-place
  10731. BN.prototype.iuxor = function iuxor (num) {
  10732. // a.length > b.length
  10733. var a;
  10734. var b;
  10735. if (this.length > num.length) {
  10736. a = this;
  10737. b = num;
  10738. } else {
  10739. a = num;
  10740. b = this;
  10741. }
  10742. for (var i = 0; i < b.length; i++) {
  10743. this.words[i] = a.words[i] ^ b.words[i];
  10744. }
  10745. if (this !== a) {
  10746. for (; i < a.length; i++) {
  10747. this.words[i] = a.words[i];
  10748. }
  10749. }
  10750. this.length = a.length;
  10751. return this._strip();
  10752. };
  10753. BN.prototype.ixor = function ixor (num) {
  10754. assert((this.negative | num.negative) === 0);
  10755. return this.iuxor(num);
  10756. };
  10757. // Xor `num` with `this`
  10758. BN.prototype.xor = function xor (num) {
  10759. if (this.length > num.length) return this.clone().ixor(num);
  10760. return num.clone().ixor(this);
  10761. };
  10762. BN.prototype.uxor = function uxor (num) {
  10763. if (this.length > num.length) return this.clone().iuxor(num);
  10764. return num.clone().iuxor(this);
  10765. };
  10766. // Not ``this`` with ``width`` bitwidth
  10767. BN.prototype.inotn = function inotn (width) {
  10768. assert(typeof width === 'number' && width >= 0);
  10769. var bytesNeeded = Math.ceil(width / 26) | 0;
  10770. var bitsLeft = width % 26;
  10771. // Extend the buffer with leading zeroes
  10772. this._expand(bytesNeeded);
  10773. if (bitsLeft > 0) {
  10774. bytesNeeded--;
  10775. }
  10776. // Handle complete words
  10777. for (var i = 0; i < bytesNeeded; i++) {
  10778. this.words[i] = ~this.words[i] & 0x3ffffff;
  10779. }
  10780. // Handle the residue
  10781. if (bitsLeft > 0) {
  10782. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  10783. }
  10784. // And remove leading zeroes
  10785. return this._strip();
  10786. };
  10787. BN.prototype.notn = function notn (width) {
  10788. return this.clone().inotn(width);
  10789. };
  10790. // Set `bit` of `this`
  10791. BN.prototype.setn = function setn (bit, val) {
  10792. assert(typeof bit === 'number' && bit >= 0);
  10793. var off = (bit / 26) | 0;
  10794. var wbit = bit % 26;
  10795. this._expand(off + 1);
  10796. if (val) {
  10797. this.words[off] = this.words[off] | (1 << wbit);
  10798. } else {
  10799. this.words[off] = this.words[off] & ~(1 << wbit);
  10800. }
  10801. return this._strip();
  10802. };
  10803. // Add `num` to `this` in-place
  10804. BN.prototype.iadd = function iadd (num) {
  10805. var r;
  10806. // negative + positive
  10807. if (this.negative !== 0 && num.negative === 0) {
  10808. this.negative = 0;
  10809. r = this.isub(num);
  10810. this.negative ^= 1;
  10811. return this._normSign();
  10812. // positive + negative
  10813. } else if (this.negative === 0 && num.negative !== 0) {
  10814. num.negative = 0;
  10815. r = this.isub(num);
  10816. num.negative = 1;
  10817. return r._normSign();
  10818. }
  10819. // a.length > b.length
  10820. var a, b;
  10821. if (this.length > num.length) {
  10822. a = this;
  10823. b = num;
  10824. } else {
  10825. a = num;
  10826. b = this;
  10827. }
  10828. var carry = 0;
  10829. for (var i = 0; i < b.length; i++) {
  10830. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  10831. this.words[i] = r & 0x3ffffff;
  10832. carry = r >>> 26;
  10833. }
  10834. for (; carry !== 0 && i < a.length; i++) {
  10835. r = (a.words[i] | 0) + carry;
  10836. this.words[i] = r & 0x3ffffff;
  10837. carry = r >>> 26;
  10838. }
  10839. this.length = a.length;
  10840. if (carry !== 0) {
  10841. this.words[this.length] = carry;
  10842. this.length++;
  10843. // Copy the rest of the words
  10844. } else if (a !== this) {
  10845. for (; i < a.length; i++) {
  10846. this.words[i] = a.words[i];
  10847. }
  10848. }
  10849. return this;
  10850. };
  10851. // Add `num` to `this`
  10852. BN.prototype.add = function add (num) {
  10853. var res;
  10854. if (num.negative !== 0 && this.negative === 0) {
  10855. num.negative = 0;
  10856. res = this.sub(num);
  10857. num.negative ^= 1;
  10858. return res;
  10859. } else if (num.negative === 0 && this.negative !== 0) {
  10860. this.negative = 0;
  10861. res = num.sub(this);
  10862. this.negative = 1;
  10863. return res;
  10864. }
  10865. if (this.length > num.length) return this.clone().iadd(num);
  10866. return num.clone().iadd(this);
  10867. };
  10868. // Subtract `num` from `this` in-place
  10869. BN.prototype.isub = function isub (num) {
  10870. // this - (-num) = this + num
  10871. if (num.negative !== 0) {
  10872. num.negative = 0;
  10873. var r = this.iadd(num);
  10874. num.negative = 1;
  10875. return r._normSign();
  10876. // -this - num = -(this + num)
  10877. } else if (this.negative !== 0) {
  10878. this.negative = 0;
  10879. this.iadd(num);
  10880. this.negative = 1;
  10881. return this._normSign();
  10882. }
  10883. // At this point both numbers are positive
  10884. var cmp = this.cmp(num);
  10885. // Optimization - zeroify
  10886. if (cmp === 0) {
  10887. this.negative = 0;
  10888. this.length = 1;
  10889. this.words[0] = 0;
  10890. return this;
  10891. }
  10892. // a > b
  10893. var a, b;
  10894. if (cmp > 0) {
  10895. a = this;
  10896. b = num;
  10897. } else {
  10898. a = num;
  10899. b = this;
  10900. }
  10901. var carry = 0;
  10902. for (var i = 0; i < b.length; i++) {
  10903. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  10904. carry = r >> 26;
  10905. this.words[i] = r & 0x3ffffff;
  10906. }
  10907. for (; carry !== 0 && i < a.length; i++) {
  10908. r = (a.words[i] | 0) + carry;
  10909. carry = r >> 26;
  10910. this.words[i] = r & 0x3ffffff;
  10911. }
  10912. // Copy rest of the words
  10913. if (carry === 0 && i < a.length && a !== this) {
  10914. for (; i < a.length; i++) {
  10915. this.words[i] = a.words[i];
  10916. }
  10917. }
  10918. this.length = Math.max(this.length, i);
  10919. if (a !== this) {
  10920. this.negative = 1;
  10921. }
  10922. return this._strip();
  10923. };
  10924. // Subtract `num` from `this`
  10925. BN.prototype.sub = function sub (num) {
  10926. return this.clone().isub(num);
  10927. };
  10928. function smallMulTo (self, num, out) {
  10929. out.negative = num.negative ^ self.negative;
  10930. var len = (self.length + num.length) | 0;
  10931. out.length = len;
  10932. len = (len - 1) | 0;
  10933. // Peel one iteration (compiler can't do it, because of code complexity)
  10934. var a = self.words[0] | 0;
  10935. var b = num.words[0] | 0;
  10936. var r = a * b;
  10937. var lo = r & 0x3ffffff;
  10938. var carry = (r / 0x4000000) | 0;
  10939. out.words[0] = lo;
  10940. for (var k = 1; k < len; k++) {
  10941. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  10942. // note that ncarry could be >= 0x3ffffff
  10943. var ncarry = carry >>> 26;
  10944. var rword = carry & 0x3ffffff;
  10945. var maxJ = Math.min(k, num.length - 1);
  10946. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  10947. var i = (k - j) | 0;
  10948. a = self.words[i] | 0;
  10949. b = num.words[j] | 0;
  10950. r = a * b + rword;
  10951. ncarry += (r / 0x4000000) | 0;
  10952. rword = r & 0x3ffffff;
  10953. }
  10954. out.words[k] = rword | 0;
  10955. carry = ncarry | 0;
  10956. }
  10957. if (carry !== 0) {
  10958. out.words[k] = carry | 0;
  10959. } else {
  10960. out.length--;
  10961. }
  10962. return out._strip();
  10963. }
  10964. // TODO(indutny): it may be reasonable to omit it for users who don't need
  10965. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  10966. // multiplication (like elliptic secp256k1).
  10967. var comb10MulTo = function comb10MulTo (self, num, out) {
  10968. var a = self.words;
  10969. var b = num.words;
  10970. var o = out.words;
  10971. var c = 0;
  10972. var lo;
  10973. var mid;
  10974. var hi;
  10975. var a0 = a[0] | 0;
  10976. var al0 = a0 & 0x1fff;
  10977. var ah0 = a0 >>> 13;
  10978. var a1 = a[1] | 0;
  10979. var al1 = a1 & 0x1fff;
  10980. var ah1 = a1 >>> 13;
  10981. var a2 = a[2] | 0;
  10982. var al2 = a2 & 0x1fff;
  10983. var ah2 = a2 >>> 13;
  10984. var a3 = a[3] | 0;
  10985. var al3 = a3 & 0x1fff;
  10986. var ah3 = a3 >>> 13;
  10987. var a4 = a[4] | 0;
  10988. var al4 = a4 & 0x1fff;
  10989. var ah4 = a4 >>> 13;
  10990. var a5 = a[5] | 0;
  10991. var al5 = a5 & 0x1fff;
  10992. var ah5 = a5 >>> 13;
  10993. var a6 = a[6] | 0;
  10994. var al6 = a6 & 0x1fff;
  10995. var ah6 = a6 >>> 13;
  10996. var a7 = a[7] | 0;
  10997. var al7 = a7 & 0x1fff;
  10998. var ah7 = a7 >>> 13;
  10999. var a8 = a[8] | 0;
  11000. var al8 = a8 & 0x1fff;
  11001. var ah8 = a8 >>> 13;
  11002. var a9 = a[9] | 0;
  11003. var al9 = a9 & 0x1fff;
  11004. var ah9 = a9 >>> 13;
  11005. var b0 = b[0] | 0;
  11006. var bl0 = b0 & 0x1fff;
  11007. var bh0 = b0 >>> 13;
  11008. var b1 = b[1] | 0;
  11009. var bl1 = b1 & 0x1fff;
  11010. var bh1 = b1 >>> 13;
  11011. var b2 = b[2] | 0;
  11012. var bl2 = b2 & 0x1fff;
  11013. var bh2 = b2 >>> 13;
  11014. var b3 = b[3] | 0;
  11015. var bl3 = b3 & 0x1fff;
  11016. var bh3 = b3 >>> 13;
  11017. var b4 = b[4] | 0;
  11018. var bl4 = b4 & 0x1fff;
  11019. var bh4 = b4 >>> 13;
  11020. var b5 = b[5] | 0;
  11021. var bl5 = b5 & 0x1fff;
  11022. var bh5 = b5 >>> 13;
  11023. var b6 = b[6] | 0;
  11024. var bl6 = b6 & 0x1fff;
  11025. var bh6 = b6 >>> 13;
  11026. var b7 = b[7] | 0;
  11027. var bl7 = b7 & 0x1fff;
  11028. var bh7 = b7 >>> 13;
  11029. var b8 = b[8] | 0;
  11030. var bl8 = b8 & 0x1fff;
  11031. var bh8 = b8 >>> 13;
  11032. var b9 = b[9] | 0;
  11033. var bl9 = b9 & 0x1fff;
  11034. var bh9 = b9 >>> 13;
  11035. out.negative = self.negative ^ num.negative;
  11036. out.length = 19;
  11037. /* k = 0 */
  11038. lo = Math.imul(al0, bl0);
  11039. mid = Math.imul(al0, bh0);
  11040. mid = (mid + Math.imul(ah0, bl0)) | 0;
  11041. hi = Math.imul(ah0, bh0);
  11042. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11043. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  11044. w0 &= 0x3ffffff;
  11045. /* k = 1 */
  11046. lo = Math.imul(al1, bl0);
  11047. mid = Math.imul(al1, bh0);
  11048. mid = (mid + Math.imul(ah1, bl0)) | 0;
  11049. hi = Math.imul(ah1, bh0);
  11050. lo = (lo + Math.imul(al0, bl1)) | 0;
  11051. mid = (mid + Math.imul(al0, bh1)) | 0;
  11052. mid = (mid + Math.imul(ah0, bl1)) | 0;
  11053. hi = (hi + Math.imul(ah0, bh1)) | 0;
  11054. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11055. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  11056. w1 &= 0x3ffffff;
  11057. /* k = 2 */
  11058. lo = Math.imul(al2, bl0);
  11059. mid = Math.imul(al2, bh0);
  11060. mid = (mid + Math.imul(ah2, bl0)) | 0;
  11061. hi = Math.imul(ah2, bh0);
  11062. lo = (lo + Math.imul(al1, bl1)) | 0;
  11063. mid = (mid + Math.imul(al1, bh1)) | 0;
  11064. mid = (mid + Math.imul(ah1, bl1)) | 0;
  11065. hi = (hi + Math.imul(ah1, bh1)) | 0;
  11066. lo = (lo + Math.imul(al0, bl2)) | 0;
  11067. mid = (mid + Math.imul(al0, bh2)) | 0;
  11068. mid = (mid + Math.imul(ah0, bl2)) | 0;
  11069. hi = (hi + Math.imul(ah0, bh2)) | 0;
  11070. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11071. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  11072. w2 &= 0x3ffffff;
  11073. /* k = 3 */
  11074. lo = Math.imul(al3, bl0);
  11075. mid = Math.imul(al3, bh0);
  11076. mid = (mid + Math.imul(ah3, bl0)) | 0;
  11077. hi = Math.imul(ah3, bh0);
  11078. lo = (lo + Math.imul(al2, bl1)) | 0;
  11079. mid = (mid + Math.imul(al2, bh1)) | 0;
  11080. mid = (mid + Math.imul(ah2, bl1)) | 0;
  11081. hi = (hi + Math.imul(ah2, bh1)) | 0;
  11082. lo = (lo + Math.imul(al1, bl2)) | 0;
  11083. mid = (mid + Math.imul(al1, bh2)) | 0;
  11084. mid = (mid + Math.imul(ah1, bl2)) | 0;
  11085. hi = (hi + Math.imul(ah1, bh2)) | 0;
  11086. lo = (lo + Math.imul(al0, bl3)) | 0;
  11087. mid = (mid + Math.imul(al0, bh3)) | 0;
  11088. mid = (mid + Math.imul(ah0, bl3)) | 0;
  11089. hi = (hi + Math.imul(ah0, bh3)) | 0;
  11090. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11091. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  11092. w3 &= 0x3ffffff;
  11093. /* k = 4 */
  11094. lo = Math.imul(al4, bl0);
  11095. mid = Math.imul(al4, bh0);
  11096. mid = (mid + Math.imul(ah4, bl0)) | 0;
  11097. hi = Math.imul(ah4, bh0);
  11098. lo = (lo + Math.imul(al3, bl1)) | 0;
  11099. mid = (mid + Math.imul(al3, bh1)) | 0;
  11100. mid = (mid + Math.imul(ah3, bl1)) | 0;
  11101. hi = (hi + Math.imul(ah3, bh1)) | 0;
  11102. lo = (lo + Math.imul(al2, bl2)) | 0;
  11103. mid = (mid + Math.imul(al2, bh2)) | 0;
  11104. mid = (mid + Math.imul(ah2, bl2)) | 0;
  11105. hi = (hi + Math.imul(ah2, bh2)) | 0;
  11106. lo = (lo + Math.imul(al1, bl3)) | 0;
  11107. mid = (mid + Math.imul(al1, bh3)) | 0;
  11108. mid = (mid + Math.imul(ah1, bl3)) | 0;
  11109. hi = (hi + Math.imul(ah1, bh3)) | 0;
  11110. lo = (lo + Math.imul(al0, bl4)) | 0;
  11111. mid = (mid + Math.imul(al0, bh4)) | 0;
  11112. mid = (mid + Math.imul(ah0, bl4)) | 0;
  11113. hi = (hi + Math.imul(ah0, bh4)) | 0;
  11114. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11115. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  11116. w4 &= 0x3ffffff;
  11117. /* k = 5 */
  11118. lo = Math.imul(al5, bl0);
  11119. mid = Math.imul(al5, bh0);
  11120. mid = (mid + Math.imul(ah5, bl0)) | 0;
  11121. hi = Math.imul(ah5, bh0);
  11122. lo = (lo + Math.imul(al4, bl1)) | 0;
  11123. mid = (mid + Math.imul(al4, bh1)) | 0;
  11124. mid = (mid + Math.imul(ah4, bl1)) | 0;
  11125. hi = (hi + Math.imul(ah4, bh1)) | 0;
  11126. lo = (lo + Math.imul(al3, bl2)) | 0;
  11127. mid = (mid + Math.imul(al3, bh2)) | 0;
  11128. mid = (mid + Math.imul(ah3, bl2)) | 0;
  11129. hi = (hi + Math.imul(ah3, bh2)) | 0;
  11130. lo = (lo + Math.imul(al2, bl3)) | 0;
  11131. mid = (mid + Math.imul(al2, bh3)) | 0;
  11132. mid = (mid + Math.imul(ah2, bl3)) | 0;
  11133. hi = (hi + Math.imul(ah2, bh3)) | 0;
  11134. lo = (lo + Math.imul(al1, bl4)) | 0;
  11135. mid = (mid + Math.imul(al1, bh4)) | 0;
  11136. mid = (mid + Math.imul(ah1, bl4)) | 0;
  11137. hi = (hi + Math.imul(ah1, bh4)) | 0;
  11138. lo = (lo + Math.imul(al0, bl5)) | 0;
  11139. mid = (mid + Math.imul(al0, bh5)) | 0;
  11140. mid = (mid + Math.imul(ah0, bl5)) | 0;
  11141. hi = (hi + Math.imul(ah0, bh5)) | 0;
  11142. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11143. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  11144. w5 &= 0x3ffffff;
  11145. /* k = 6 */
  11146. lo = Math.imul(al6, bl0);
  11147. mid = Math.imul(al6, bh0);
  11148. mid = (mid + Math.imul(ah6, bl0)) | 0;
  11149. hi = Math.imul(ah6, bh0);
  11150. lo = (lo + Math.imul(al5, bl1)) | 0;
  11151. mid = (mid + Math.imul(al5, bh1)) | 0;
  11152. mid = (mid + Math.imul(ah5, bl1)) | 0;
  11153. hi = (hi + Math.imul(ah5, bh1)) | 0;
  11154. lo = (lo + Math.imul(al4, bl2)) | 0;
  11155. mid = (mid + Math.imul(al4, bh2)) | 0;
  11156. mid = (mid + Math.imul(ah4, bl2)) | 0;
  11157. hi = (hi + Math.imul(ah4, bh2)) | 0;
  11158. lo = (lo + Math.imul(al3, bl3)) | 0;
  11159. mid = (mid + Math.imul(al3, bh3)) | 0;
  11160. mid = (mid + Math.imul(ah3, bl3)) | 0;
  11161. hi = (hi + Math.imul(ah3, bh3)) | 0;
  11162. lo = (lo + Math.imul(al2, bl4)) | 0;
  11163. mid = (mid + Math.imul(al2, bh4)) | 0;
  11164. mid = (mid + Math.imul(ah2, bl4)) | 0;
  11165. hi = (hi + Math.imul(ah2, bh4)) | 0;
  11166. lo = (lo + Math.imul(al1, bl5)) | 0;
  11167. mid = (mid + Math.imul(al1, bh5)) | 0;
  11168. mid = (mid + Math.imul(ah1, bl5)) | 0;
  11169. hi = (hi + Math.imul(ah1, bh5)) | 0;
  11170. lo = (lo + Math.imul(al0, bl6)) | 0;
  11171. mid = (mid + Math.imul(al0, bh6)) | 0;
  11172. mid = (mid + Math.imul(ah0, bl6)) | 0;
  11173. hi = (hi + Math.imul(ah0, bh6)) | 0;
  11174. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11175. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  11176. w6 &= 0x3ffffff;
  11177. /* k = 7 */
  11178. lo = Math.imul(al7, bl0);
  11179. mid = Math.imul(al7, bh0);
  11180. mid = (mid + Math.imul(ah7, bl0)) | 0;
  11181. hi = Math.imul(ah7, bh0);
  11182. lo = (lo + Math.imul(al6, bl1)) | 0;
  11183. mid = (mid + Math.imul(al6, bh1)) | 0;
  11184. mid = (mid + Math.imul(ah6, bl1)) | 0;
  11185. hi = (hi + Math.imul(ah6, bh1)) | 0;
  11186. lo = (lo + Math.imul(al5, bl2)) | 0;
  11187. mid = (mid + Math.imul(al5, bh2)) | 0;
  11188. mid = (mid + Math.imul(ah5, bl2)) | 0;
  11189. hi = (hi + Math.imul(ah5, bh2)) | 0;
  11190. lo = (lo + Math.imul(al4, bl3)) | 0;
  11191. mid = (mid + Math.imul(al4, bh3)) | 0;
  11192. mid = (mid + Math.imul(ah4, bl3)) | 0;
  11193. hi = (hi + Math.imul(ah4, bh3)) | 0;
  11194. lo = (lo + Math.imul(al3, bl4)) | 0;
  11195. mid = (mid + Math.imul(al3, bh4)) | 0;
  11196. mid = (mid + Math.imul(ah3, bl4)) | 0;
  11197. hi = (hi + Math.imul(ah3, bh4)) | 0;
  11198. lo = (lo + Math.imul(al2, bl5)) | 0;
  11199. mid = (mid + Math.imul(al2, bh5)) | 0;
  11200. mid = (mid + Math.imul(ah2, bl5)) | 0;
  11201. hi = (hi + Math.imul(ah2, bh5)) | 0;
  11202. lo = (lo + Math.imul(al1, bl6)) | 0;
  11203. mid = (mid + Math.imul(al1, bh6)) | 0;
  11204. mid = (mid + Math.imul(ah1, bl6)) | 0;
  11205. hi = (hi + Math.imul(ah1, bh6)) | 0;
  11206. lo = (lo + Math.imul(al0, bl7)) | 0;
  11207. mid = (mid + Math.imul(al0, bh7)) | 0;
  11208. mid = (mid + Math.imul(ah0, bl7)) | 0;
  11209. hi = (hi + Math.imul(ah0, bh7)) | 0;
  11210. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11211. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  11212. w7 &= 0x3ffffff;
  11213. /* k = 8 */
  11214. lo = Math.imul(al8, bl0);
  11215. mid = Math.imul(al8, bh0);
  11216. mid = (mid + Math.imul(ah8, bl0)) | 0;
  11217. hi = Math.imul(ah8, bh0);
  11218. lo = (lo + Math.imul(al7, bl1)) | 0;
  11219. mid = (mid + Math.imul(al7, bh1)) | 0;
  11220. mid = (mid + Math.imul(ah7, bl1)) | 0;
  11221. hi = (hi + Math.imul(ah7, bh1)) | 0;
  11222. lo = (lo + Math.imul(al6, bl2)) | 0;
  11223. mid = (mid + Math.imul(al6, bh2)) | 0;
  11224. mid = (mid + Math.imul(ah6, bl2)) | 0;
  11225. hi = (hi + Math.imul(ah6, bh2)) | 0;
  11226. lo = (lo + Math.imul(al5, bl3)) | 0;
  11227. mid = (mid + Math.imul(al5, bh3)) | 0;
  11228. mid = (mid + Math.imul(ah5, bl3)) | 0;
  11229. hi = (hi + Math.imul(ah5, bh3)) | 0;
  11230. lo = (lo + Math.imul(al4, bl4)) | 0;
  11231. mid = (mid + Math.imul(al4, bh4)) | 0;
  11232. mid = (mid + Math.imul(ah4, bl4)) | 0;
  11233. hi = (hi + Math.imul(ah4, bh4)) | 0;
  11234. lo = (lo + Math.imul(al3, bl5)) | 0;
  11235. mid = (mid + Math.imul(al3, bh5)) | 0;
  11236. mid = (mid + Math.imul(ah3, bl5)) | 0;
  11237. hi = (hi + Math.imul(ah3, bh5)) | 0;
  11238. lo = (lo + Math.imul(al2, bl6)) | 0;
  11239. mid = (mid + Math.imul(al2, bh6)) | 0;
  11240. mid = (mid + Math.imul(ah2, bl6)) | 0;
  11241. hi = (hi + Math.imul(ah2, bh6)) | 0;
  11242. lo = (lo + Math.imul(al1, bl7)) | 0;
  11243. mid = (mid + Math.imul(al1, bh7)) | 0;
  11244. mid = (mid + Math.imul(ah1, bl7)) | 0;
  11245. hi = (hi + Math.imul(ah1, bh7)) | 0;
  11246. lo = (lo + Math.imul(al0, bl8)) | 0;
  11247. mid = (mid + Math.imul(al0, bh8)) | 0;
  11248. mid = (mid + Math.imul(ah0, bl8)) | 0;
  11249. hi = (hi + Math.imul(ah0, bh8)) | 0;
  11250. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11251. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  11252. w8 &= 0x3ffffff;
  11253. /* k = 9 */
  11254. lo = Math.imul(al9, bl0);
  11255. mid = Math.imul(al9, bh0);
  11256. mid = (mid + Math.imul(ah9, bl0)) | 0;
  11257. hi = Math.imul(ah9, bh0);
  11258. lo = (lo + Math.imul(al8, bl1)) | 0;
  11259. mid = (mid + Math.imul(al8, bh1)) | 0;
  11260. mid = (mid + Math.imul(ah8, bl1)) | 0;
  11261. hi = (hi + Math.imul(ah8, bh1)) | 0;
  11262. lo = (lo + Math.imul(al7, bl2)) | 0;
  11263. mid = (mid + Math.imul(al7, bh2)) | 0;
  11264. mid = (mid + Math.imul(ah7, bl2)) | 0;
  11265. hi = (hi + Math.imul(ah7, bh2)) | 0;
  11266. lo = (lo + Math.imul(al6, bl3)) | 0;
  11267. mid = (mid + Math.imul(al6, bh3)) | 0;
  11268. mid = (mid + Math.imul(ah6, bl3)) | 0;
  11269. hi = (hi + Math.imul(ah6, bh3)) | 0;
  11270. lo = (lo + Math.imul(al5, bl4)) | 0;
  11271. mid = (mid + Math.imul(al5, bh4)) | 0;
  11272. mid = (mid + Math.imul(ah5, bl4)) | 0;
  11273. hi = (hi + Math.imul(ah5, bh4)) | 0;
  11274. lo = (lo + Math.imul(al4, bl5)) | 0;
  11275. mid = (mid + Math.imul(al4, bh5)) | 0;
  11276. mid = (mid + Math.imul(ah4, bl5)) | 0;
  11277. hi = (hi + Math.imul(ah4, bh5)) | 0;
  11278. lo = (lo + Math.imul(al3, bl6)) | 0;
  11279. mid = (mid + Math.imul(al3, bh6)) | 0;
  11280. mid = (mid + Math.imul(ah3, bl6)) | 0;
  11281. hi = (hi + Math.imul(ah3, bh6)) | 0;
  11282. lo = (lo + Math.imul(al2, bl7)) | 0;
  11283. mid = (mid + Math.imul(al2, bh7)) | 0;
  11284. mid = (mid + Math.imul(ah2, bl7)) | 0;
  11285. hi = (hi + Math.imul(ah2, bh7)) | 0;
  11286. lo = (lo + Math.imul(al1, bl8)) | 0;
  11287. mid = (mid + Math.imul(al1, bh8)) | 0;
  11288. mid = (mid + Math.imul(ah1, bl8)) | 0;
  11289. hi = (hi + Math.imul(ah1, bh8)) | 0;
  11290. lo = (lo + Math.imul(al0, bl9)) | 0;
  11291. mid = (mid + Math.imul(al0, bh9)) | 0;
  11292. mid = (mid + Math.imul(ah0, bl9)) | 0;
  11293. hi = (hi + Math.imul(ah0, bh9)) | 0;
  11294. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11295. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  11296. w9 &= 0x3ffffff;
  11297. /* k = 10 */
  11298. lo = Math.imul(al9, bl1);
  11299. mid = Math.imul(al9, bh1);
  11300. mid = (mid + Math.imul(ah9, bl1)) | 0;
  11301. hi = Math.imul(ah9, bh1);
  11302. lo = (lo + Math.imul(al8, bl2)) | 0;
  11303. mid = (mid + Math.imul(al8, bh2)) | 0;
  11304. mid = (mid + Math.imul(ah8, bl2)) | 0;
  11305. hi = (hi + Math.imul(ah8, bh2)) | 0;
  11306. lo = (lo + Math.imul(al7, bl3)) | 0;
  11307. mid = (mid + Math.imul(al7, bh3)) | 0;
  11308. mid = (mid + Math.imul(ah7, bl3)) | 0;
  11309. hi = (hi + Math.imul(ah7, bh3)) | 0;
  11310. lo = (lo + Math.imul(al6, bl4)) | 0;
  11311. mid = (mid + Math.imul(al6, bh4)) | 0;
  11312. mid = (mid + Math.imul(ah6, bl4)) | 0;
  11313. hi = (hi + Math.imul(ah6, bh4)) | 0;
  11314. lo = (lo + Math.imul(al5, bl5)) | 0;
  11315. mid = (mid + Math.imul(al5, bh5)) | 0;
  11316. mid = (mid + Math.imul(ah5, bl5)) | 0;
  11317. hi = (hi + Math.imul(ah5, bh5)) | 0;
  11318. lo = (lo + Math.imul(al4, bl6)) | 0;
  11319. mid = (mid + Math.imul(al4, bh6)) | 0;
  11320. mid = (mid + Math.imul(ah4, bl6)) | 0;
  11321. hi = (hi + Math.imul(ah4, bh6)) | 0;
  11322. lo = (lo + Math.imul(al3, bl7)) | 0;
  11323. mid = (mid + Math.imul(al3, bh7)) | 0;
  11324. mid = (mid + Math.imul(ah3, bl7)) | 0;
  11325. hi = (hi + Math.imul(ah3, bh7)) | 0;
  11326. lo = (lo + Math.imul(al2, bl8)) | 0;
  11327. mid = (mid + Math.imul(al2, bh8)) | 0;
  11328. mid = (mid + Math.imul(ah2, bl8)) | 0;
  11329. hi = (hi + Math.imul(ah2, bh8)) | 0;
  11330. lo = (lo + Math.imul(al1, bl9)) | 0;
  11331. mid = (mid + Math.imul(al1, bh9)) | 0;
  11332. mid = (mid + Math.imul(ah1, bl9)) | 0;
  11333. hi = (hi + Math.imul(ah1, bh9)) | 0;
  11334. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11335. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  11336. w10 &= 0x3ffffff;
  11337. /* k = 11 */
  11338. lo = Math.imul(al9, bl2);
  11339. mid = Math.imul(al9, bh2);
  11340. mid = (mid + Math.imul(ah9, bl2)) | 0;
  11341. hi = Math.imul(ah9, bh2);
  11342. lo = (lo + Math.imul(al8, bl3)) | 0;
  11343. mid = (mid + Math.imul(al8, bh3)) | 0;
  11344. mid = (mid + Math.imul(ah8, bl3)) | 0;
  11345. hi = (hi + Math.imul(ah8, bh3)) | 0;
  11346. lo = (lo + Math.imul(al7, bl4)) | 0;
  11347. mid = (mid + Math.imul(al7, bh4)) | 0;
  11348. mid = (mid + Math.imul(ah7, bl4)) | 0;
  11349. hi = (hi + Math.imul(ah7, bh4)) | 0;
  11350. lo = (lo + Math.imul(al6, bl5)) | 0;
  11351. mid = (mid + Math.imul(al6, bh5)) | 0;
  11352. mid = (mid + Math.imul(ah6, bl5)) | 0;
  11353. hi = (hi + Math.imul(ah6, bh5)) | 0;
  11354. lo = (lo + Math.imul(al5, bl6)) | 0;
  11355. mid = (mid + Math.imul(al5, bh6)) | 0;
  11356. mid = (mid + Math.imul(ah5, bl6)) | 0;
  11357. hi = (hi + Math.imul(ah5, bh6)) | 0;
  11358. lo = (lo + Math.imul(al4, bl7)) | 0;
  11359. mid = (mid + Math.imul(al4, bh7)) | 0;
  11360. mid = (mid + Math.imul(ah4, bl7)) | 0;
  11361. hi = (hi + Math.imul(ah4, bh7)) | 0;
  11362. lo = (lo + Math.imul(al3, bl8)) | 0;
  11363. mid = (mid + Math.imul(al3, bh8)) | 0;
  11364. mid = (mid + Math.imul(ah3, bl8)) | 0;
  11365. hi = (hi + Math.imul(ah3, bh8)) | 0;
  11366. lo = (lo + Math.imul(al2, bl9)) | 0;
  11367. mid = (mid + Math.imul(al2, bh9)) | 0;
  11368. mid = (mid + Math.imul(ah2, bl9)) | 0;
  11369. hi = (hi + Math.imul(ah2, bh9)) | 0;
  11370. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11371. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  11372. w11 &= 0x3ffffff;
  11373. /* k = 12 */
  11374. lo = Math.imul(al9, bl3);
  11375. mid = Math.imul(al9, bh3);
  11376. mid = (mid + Math.imul(ah9, bl3)) | 0;
  11377. hi = Math.imul(ah9, bh3);
  11378. lo = (lo + Math.imul(al8, bl4)) | 0;
  11379. mid = (mid + Math.imul(al8, bh4)) | 0;
  11380. mid = (mid + Math.imul(ah8, bl4)) | 0;
  11381. hi = (hi + Math.imul(ah8, bh4)) | 0;
  11382. lo = (lo + Math.imul(al7, bl5)) | 0;
  11383. mid = (mid + Math.imul(al7, bh5)) | 0;
  11384. mid = (mid + Math.imul(ah7, bl5)) | 0;
  11385. hi = (hi + Math.imul(ah7, bh5)) | 0;
  11386. lo = (lo + Math.imul(al6, bl6)) | 0;
  11387. mid = (mid + Math.imul(al6, bh6)) | 0;
  11388. mid = (mid + Math.imul(ah6, bl6)) | 0;
  11389. hi = (hi + Math.imul(ah6, bh6)) | 0;
  11390. lo = (lo + Math.imul(al5, bl7)) | 0;
  11391. mid = (mid + Math.imul(al5, bh7)) | 0;
  11392. mid = (mid + Math.imul(ah5, bl7)) | 0;
  11393. hi = (hi + Math.imul(ah5, bh7)) | 0;
  11394. lo = (lo + Math.imul(al4, bl8)) | 0;
  11395. mid = (mid + Math.imul(al4, bh8)) | 0;
  11396. mid = (mid + Math.imul(ah4, bl8)) | 0;
  11397. hi = (hi + Math.imul(ah4, bh8)) | 0;
  11398. lo = (lo + Math.imul(al3, bl9)) | 0;
  11399. mid = (mid + Math.imul(al3, bh9)) | 0;
  11400. mid = (mid + Math.imul(ah3, bl9)) | 0;
  11401. hi = (hi + Math.imul(ah3, bh9)) | 0;
  11402. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11403. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  11404. w12 &= 0x3ffffff;
  11405. /* k = 13 */
  11406. lo = Math.imul(al9, bl4);
  11407. mid = Math.imul(al9, bh4);
  11408. mid = (mid + Math.imul(ah9, bl4)) | 0;
  11409. hi = Math.imul(ah9, bh4);
  11410. lo = (lo + Math.imul(al8, bl5)) | 0;
  11411. mid = (mid + Math.imul(al8, bh5)) | 0;
  11412. mid = (mid + Math.imul(ah8, bl5)) | 0;
  11413. hi = (hi + Math.imul(ah8, bh5)) | 0;
  11414. lo = (lo + Math.imul(al7, bl6)) | 0;
  11415. mid = (mid + Math.imul(al7, bh6)) | 0;
  11416. mid = (mid + Math.imul(ah7, bl6)) | 0;
  11417. hi = (hi + Math.imul(ah7, bh6)) | 0;
  11418. lo = (lo + Math.imul(al6, bl7)) | 0;
  11419. mid = (mid + Math.imul(al6, bh7)) | 0;
  11420. mid = (mid + Math.imul(ah6, bl7)) | 0;
  11421. hi = (hi + Math.imul(ah6, bh7)) | 0;
  11422. lo = (lo + Math.imul(al5, bl8)) | 0;
  11423. mid = (mid + Math.imul(al5, bh8)) | 0;
  11424. mid = (mid + Math.imul(ah5, bl8)) | 0;
  11425. hi = (hi + Math.imul(ah5, bh8)) | 0;
  11426. lo = (lo + Math.imul(al4, bl9)) | 0;
  11427. mid = (mid + Math.imul(al4, bh9)) | 0;
  11428. mid = (mid + Math.imul(ah4, bl9)) | 0;
  11429. hi = (hi + Math.imul(ah4, bh9)) | 0;
  11430. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11431. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  11432. w13 &= 0x3ffffff;
  11433. /* k = 14 */
  11434. lo = Math.imul(al9, bl5);
  11435. mid = Math.imul(al9, bh5);
  11436. mid = (mid + Math.imul(ah9, bl5)) | 0;
  11437. hi = Math.imul(ah9, bh5);
  11438. lo = (lo + Math.imul(al8, bl6)) | 0;
  11439. mid = (mid + Math.imul(al8, bh6)) | 0;
  11440. mid = (mid + Math.imul(ah8, bl6)) | 0;
  11441. hi = (hi + Math.imul(ah8, bh6)) | 0;
  11442. lo = (lo + Math.imul(al7, bl7)) | 0;
  11443. mid = (mid + Math.imul(al7, bh7)) | 0;
  11444. mid = (mid + Math.imul(ah7, bl7)) | 0;
  11445. hi = (hi + Math.imul(ah7, bh7)) | 0;
  11446. lo = (lo + Math.imul(al6, bl8)) | 0;
  11447. mid = (mid + Math.imul(al6, bh8)) | 0;
  11448. mid = (mid + Math.imul(ah6, bl8)) | 0;
  11449. hi = (hi + Math.imul(ah6, bh8)) | 0;
  11450. lo = (lo + Math.imul(al5, bl9)) | 0;
  11451. mid = (mid + Math.imul(al5, bh9)) | 0;
  11452. mid = (mid + Math.imul(ah5, bl9)) | 0;
  11453. hi = (hi + Math.imul(ah5, bh9)) | 0;
  11454. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11455. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  11456. w14 &= 0x3ffffff;
  11457. /* k = 15 */
  11458. lo = Math.imul(al9, bl6);
  11459. mid = Math.imul(al9, bh6);
  11460. mid = (mid + Math.imul(ah9, bl6)) | 0;
  11461. hi = Math.imul(ah9, bh6);
  11462. lo = (lo + Math.imul(al8, bl7)) | 0;
  11463. mid = (mid + Math.imul(al8, bh7)) | 0;
  11464. mid = (mid + Math.imul(ah8, bl7)) | 0;
  11465. hi = (hi + Math.imul(ah8, bh7)) | 0;
  11466. lo = (lo + Math.imul(al7, bl8)) | 0;
  11467. mid = (mid + Math.imul(al7, bh8)) | 0;
  11468. mid = (mid + Math.imul(ah7, bl8)) | 0;
  11469. hi = (hi + Math.imul(ah7, bh8)) | 0;
  11470. lo = (lo + Math.imul(al6, bl9)) | 0;
  11471. mid = (mid + Math.imul(al6, bh9)) | 0;
  11472. mid = (mid + Math.imul(ah6, bl9)) | 0;
  11473. hi = (hi + Math.imul(ah6, bh9)) | 0;
  11474. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11475. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  11476. w15 &= 0x3ffffff;
  11477. /* k = 16 */
  11478. lo = Math.imul(al9, bl7);
  11479. mid = Math.imul(al9, bh7);
  11480. mid = (mid + Math.imul(ah9, bl7)) | 0;
  11481. hi = Math.imul(ah9, bh7);
  11482. lo = (lo + Math.imul(al8, bl8)) | 0;
  11483. mid = (mid + Math.imul(al8, bh8)) | 0;
  11484. mid = (mid + Math.imul(ah8, bl8)) | 0;
  11485. hi = (hi + Math.imul(ah8, bh8)) | 0;
  11486. lo = (lo + Math.imul(al7, bl9)) | 0;
  11487. mid = (mid + Math.imul(al7, bh9)) | 0;
  11488. mid = (mid + Math.imul(ah7, bl9)) | 0;
  11489. hi = (hi + Math.imul(ah7, bh9)) | 0;
  11490. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11491. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  11492. w16 &= 0x3ffffff;
  11493. /* k = 17 */
  11494. lo = Math.imul(al9, bl8);
  11495. mid = Math.imul(al9, bh8);
  11496. mid = (mid + Math.imul(ah9, bl8)) | 0;
  11497. hi = Math.imul(ah9, bh8);
  11498. lo = (lo + Math.imul(al8, bl9)) | 0;
  11499. mid = (mid + Math.imul(al8, bh9)) | 0;
  11500. mid = (mid + Math.imul(ah8, bl9)) | 0;
  11501. hi = (hi + Math.imul(ah8, bh9)) | 0;
  11502. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11503. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  11504. w17 &= 0x3ffffff;
  11505. /* k = 18 */
  11506. lo = Math.imul(al9, bl9);
  11507. mid = Math.imul(al9, bh9);
  11508. mid = (mid + Math.imul(ah9, bl9)) | 0;
  11509. hi = Math.imul(ah9, bh9);
  11510. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  11511. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  11512. w18 &= 0x3ffffff;
  11513. o[0] = w0;
  11514. o[1] = w1;
  11515. o[2] = w2;
  11516. o[3] = w3;
  11517. o[4] = w4;
  11518. o[5] = w5;
  11519. o[6] = w6;
  11520. o[7] = w7;
  11521. o[8] = w8;
  11522. o[9] = w9;
  11523. o[10] = w10;
  11524. o[11] = w11;
  11525. o[12] = w12;
  11526. o[13] = w13;
  11527. o[14] = w14;
  11528. o[15] = w15;
  11529. o[16] = w16;
  11530. o[17] = w17;
  11531. o[18] = w18;
  11532. if (c !== 0) {
  11533. o[19] = c;
  11534. out.length++;
  11535. }
  11536. return out;
  11537. };
  11538. // Polyfill comb
  11539. if (!Math.imul) {
  11540. comb10MulTo = smallMulTo;
  11541. }
  11542. function bigMulTo (self, num, out) {
  11543. out.negative = num.negative ^ self.negative;
  11544. out.length = self.length + num.length;
  11545. var carry = 0;
  11546. var hncarry = 0;
  11547. for (var k = 0; k < out.length - 1; k++) {
  11548. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  11549. // note that ncarry could be >= 0x3ffffff
  11550. var ncarry = hncarry;
  11551. hncarry = 0;
  11552. var rword = carry & 0x3ffffff;
  11553. var maxJ = Math.min(k, num.length - 1);
  11554. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  11555. var i = k - j;
  11556. var a = self.words[i] | 0;
  11557. var b = num.words[j] | 0;
  11558. var r = a * b;
  11559. var lo = r & 0x3ffffff;
  11560. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  11561. lo = (lo + rword) | 0;
  11562. rword = lo & 0x3ffffff;
  11563. ncarry = (ncarry + (lo >>> 26)) | 0;
  11564. hncarry += ncarry >>> 26;
  11565. ncarry &= 0x3ffffff;
  11566. }
  11567. out.words[k] = rword;
  11568. carry = ncarry;
  11569. ncarry = hncarry;
  11570. }
  11571. if (carry !== 0) {
  11572. out.words[k] = carry;
  11573. } else {
  11574. out.length--;
  11575. }
  11576. return out._strip();
  11577. }
  11578. function jumboMulTo (self, num, out) {
  11579. // Temporary disable, see https://github.com/indutny/bn.js/issues/211
  11580. // var fftm = new FFTM();
  11581. // return fftm.mulp(self, num, out);
  11582. return bigMulTo(self, num, out);
  11583. }
  11584. BN.prototype.mulTo = function mulTo (num, out) {
  11585. var res;
  11586. var len = this.length + num.length;
  11587. if (this.length === 10 && num.length === 10) {
  11588. res = comb10MulTo(this, num, out);
  11589. } else if (len < 63) {
  11590. res = smallMulTo(this, num, out);
  11591. } else if (len < 1024) {
  11592. res = bigMulTo(this, num, out);
  11593. } else {
  11594. res = jumboMulTo(this, num, out);
  11595. }
  11596. return res;
  11597. };
  11598. // Cooley-Tukey algorithm for FFT
  11599. // slightly revisited to rely on looping instead of recursion
  11600. function FFTM (x, y) {
  11601. this.x = x;
  11602. this.y = y;
  11603. }
  11604. FFTM.prototype.makeRBT = function makeRBT (N) {
  11605. var t = new Array(N);
  11606. var l = BN.prototype._countBits(N) - 1;
  11607. for (var i = 0; i < N; i++) {
  11608. t[i] = this.revBin(i, l, N);
  11609. }
  11610. return t;
  11611. };
  11612. // Returns binary-reversed representation of `x`
  11613. FFTM.prototype.revBin = function revBin (x, l, N) {
  11614. if (x === 0 || x === N - 1) return x;
  11615. var rb = 0;
  11616. for (var i = 0; i < l; i++) {
  11617. rb |= (x & 1) << (l - i - 1);
  11618. x >>= 1;
  11619. }
  11620. return rb;
  11621. };
  11622. // Performs "tweedling" phase, therefore 'emulating'
  11623. // behaviour of the recursive algorithm
  11624. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  11625. for (var i = 0; i < N; i++) {
  11626. rtws[i] = rws[rbt[i]];
  11627. itws[i] = iws[rbt[i]];
  11628. }
  11629. };
  11630. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  11631. this.permute(rbt, rws, iws, rtws, itws, N);
  11632. for (var s = 1; s < N; s <<= 1) {
  11633. var l = s << 1;
  11634. var rtwdf = Math.cos(2 * Math.PI / l);
  11635. var itwdf = Math.sin(2 * Math.PI / l);
  11636. for (var p = 0; p < N; p += l) {
  11637. var rtwdf_ = rtwdf;
  11638. var itwdf_ = itwdf;
  11639. for (var j = 0; j < s; j++) {
  11640. var re = rtws[p + j];
  11641. var ie = itws[p + j];
  11642. var ro = rtws[p + j + s];
  11643. var io = itws[p + j + s];
  11644. var rx = rtwdf_ * ro - itwdf_ * io;
  11645. io = rtwdf_ * io + itwdf_ * ro;
  11646. ro = rx;
  11647. rtws[p + j] = re + ro;
  11648. itws[p + j] = ie + io;
  11649. rtws[p + j + s] = re - ro;
  11650. itws[p + j + s] = ie - io;
  11651. /* jshint maxdepth : false */
  11652. if (j !== l) {
  11653. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  11654. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  11655. rtwdf_ = rx;
  11656. }
  11657. }
  11658. }
  11659. }
  11660. };
  11661. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  11662. var N = Math.max(m, n) | 1;
  11663. var odd = N & 1;
  11664. var i = 0;
  11665. for (N = N / 2 | 0; N; N = N >>> 1) {
  11666. i++;
  11667. }
  11668. return 1 << i + 1 + odd;
  11669. };
  11670. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  11671. if (N <= 1) return;
  11672. for (var i = 0; i < N / 2; i++) {
  11673. var t = rws[i];
  11674. rws[i] = rws[N - i - 1];
  11675. rws[N - i - 1] = t;
  11676. t = iws[i];
  11677. iws[i] = -iws[N - i - 1];
  11678. iws[N - i - 1] = -t;
  11679. }
  11680. };
  11681. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  11682. var carry = 0;
  11683. for (var i = 0; i < N / 2; i++) {
  11684. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  11685. Math.round(ws[2 * i] / N) +
  11686. carry;
  11687. ws[i] = w & 0x3ffffff;
  11688. if (w < 0x4000000) {
  11689. carry = 0;
  11690. } else {
  11691. carry = w / 0x4000000 | 0;
  11692. }
  11693. }
  11694. return ws;
  11695. };
  11696. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  11697. var carry = 0;
  11698. for (var i = 0; i < len; i++) {
  11699. carry = carry + (ws[i] | 0);
  11700. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  11701. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  11702. }
  11703. // Pad with zeroes
  11704. for (i = 2 * len; i < N; ++i) {
  11705. rws[i] = 0;
  11706. }
  11707. assert(carry === 0);
  11708. assert((carry & ~0x1fff) === 0);
  11709. };
  11710. FFTM.prototype.stub = function stub (N) {
  11711. var ph = new Array(N);
  11712. for (var i = 0; i < N; i++) {
  11713. ph[i] = 0;
  11714. }
  11715. return ph;
  11716. };
  11717. FFTM.prototype.mulp = function mulp (x, y, out) {
  11718. var N = 2 * this.guessLen13b(x.length, y.length);
  11719. var rbt = this.makeRBT(N);
  11720. var _ = this.stub(N);
  11721. var rws = new Array(N);
  11722. var rwst = new Array(N);
  11723. var iwst = new Array(N);
  11724. var nrws = new Array(N);
  11725. var nrwst = new Array(N);
  11726. var niwst = new Array(N);
  11727. var rmws = out.words;
  11728. rmws.length = N;
  11729. this.convert13b(x.words, x.length, rws, N);
  11730. this.convert13b(y.words, y.length, nrws, N);
  11731. this.transform(rws, _, rwst, iwst, N, rbt);
  11732. this.transform(nrws, _, nrwst, niwst, N, rbt);
  11733. for (var i = 0; i < N; i++) {
  11734. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  11735. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  11736. rwst[i] = rx;
  11737. }
  11738. this.conjugate(rwst, iwst, N);
  11739. this.transform(rwst, iwst, rmws, _, N, rbt);
  11740. this.conjugate(rmws, _, N);
  11741. this.normalize13b(rmws, N);
  11742. out.negative = x.negative ^ y.negative;
  11743. out.length = x.length + y.length;
  11744. return out._strip();
  11745. };
  11746. // Multiply `this` by `num`
  11747. BN.prototype.mul = function mul (num) {
  11748. var out = new BN(null);
  11749. out.words = new Array(this.length + num.length);
  11750. return this.mulTo(num, out);
  11751. };
  11752. // Multiply employing FFT
  11753. BN.prototype.mulf = function mulf (num) {
  11754. var out = new BN(null);
  11755. out.words = new Array(this.length + num.length);
  11756. return jumboMulTo(this, num, out);
  11757. };
  11758. // In-place Multiplication
  11759. BN.prototype.imul = function imul (num) {
  11760. return this.clone().mulTo(num, this);
  11761. };
  11762. BN.prototype.imuln = function imuln (num) {
  11763. var isNegNum = num < 0;
  11764. if (isNegNum) num = -num;
  11765. assert(typeof num === 'number');
  11766. assert(num < 0x4000000);
  11767. // Carry
  11768. var carry = 0;
  11769. for (var i = 0; i < this.length; i++) {
  11770. var w = (this.words[i] | 0) * num;
  11771. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  11772. carry >>= 26;
  11773. carry += (w / 0x4000000) | 0;
  11774. // NOTE: lo is 27bit maximum
  11775. carry += lo >>> 26;
  11776. this.words[i] = lo & 0x3ffffff;
  11777. }
  11778. if (carry !== 0) {
  11779. this.words[i] = carry;
  11780. this.length++;
  11781. }
  11782. return isNegNum ? this.ineg() : this;
  11783. };
  11784. BN.prototype.muln = function muln (num) {
  11785. return this.clone().imuln(num);
  11786. };
  11787. // `this` * `this`
  11788. BN.prototype.sqr = function sqr () {
  11789. return this.mul(this);
  11790. };
  11791. // `this` * `this` in-place
  11792. BN.prototype.isqr = function isqr () {
  11793. return this.imul(this.clone());
  11794. };
  11795. // Math.pow(`this`, `num`)
  11796. BN.prototype.pow = function pow (num) {
  11797. var w = toBitArray(num);
  11798. if (w.length === 0) return new BN(1);
  11799. // Skip leading zeroes
  11800. var res = this;
  11801. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  11802. if (w[i] !== 0) break;
  11803. }
  11804. if (++i < w.length) {
  11805. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  11806. if (w[i] === 0) continue;
  11807. res = res.mul(q);
  11808. }
  11809. }
  11810. return res;
  11811. };
  11812. // Shift-left in-place
  11813. BN.prototype.iushln = function iushln (bits) {
  11814. assert(typeof bits === 'number' && bits >= 0);
  11815. var r = bits % 26;
  11816. var s = (bits - r) / 26;
  11817. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  11818. var i;
  11819. if (r !== 0) {
  11820. var carry = 0;
  11821. for (i = 0; i < this.length; i++) {
  11822. var newCarry = this.words[i] & carryMask;
  11823. var c = ((this.words[i] | 0) - newCarry) << r;
  11824. this.words[i] = c | carry;
  11825. carry = newCarry >>> (26 - r);
  11826. }
  11827. if (carry) {
  11828. this.words[i] = carry;
  11829. this.length++;
  11830. }
  11831. }
  11832. if (s !== 0) {
  11833. for (i = this.length - 1; i >= 0; i--) {
  11834. this.words[i + s] = this.words[i];
  11835. }
  11836. for (i = 0; i < s; i++) {
  11837. this.words[i] = 0;
  11838. }
  11839. this.length += s;
  11840. }
  11841. return this._strip();
  11842. };
  11843. BN.prototype.ishln = function ishln (bits) {
  11844. // TODO(indutny): implement me
  11845. assert(this.negative === 0);
  11846. return this.iushln(bits);
  11847. };
  11848. // Shift-right in-place
  11849. // NOTE: `hint` is a lowest bit before trailing zeroes
  11850. // NOTE: if `extended` is present - it will be filled with destroyed bits
  11851. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  11852. assert(typeof bits === 'number' && bits >= 0);
  11853. var h;
  11854. if (hint) {
  11855. h = (hint - (hint % 26)) / 26;
  11856. } else {
  11857. h = 0;
  11858. }
  11859. var r = bits % 26;
  11860. var s = Math.min((bits - r) / 26, this.length);
  11861. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  11862. var maskedWords = extended;
  11863. h -= s;
  11864. h = Math.max(0, h);
  11865. // Extended mode, copy masked part
  11866. if (maskedWords) {
  11867. for (var i = 0; i < s; i++) {
  11868. maskedWords.words[i] = this.words[i];
  11869. }
  11870. maskedWords.length = s;
  11871. }
  11872. if (s === 0) {
  11873. // No-op, we should not move anything at all
  11874. } else if (this.length > s) {
  11875. this.length -= s;
  11876. for (i = 0; i < this.length; i++) {
  11877. this.words[i] = this.words[i + s];
  11878. }
  11879. } else {
  11880. this.words[0] = 0;
  11881. this.length = 1;
  11882. }
  11883. var carry = 0;
  11884. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  11885. var word = this.words[i] | 0;
  11886. this.words[i] = (carry << (26 - r)) | (word >>> r);
  11887. carry = word & mask;
  11888. }
  11889. // Push carried bits as a mask
  11890. if (maskedWords && carry !== 0) {
  11891. maskedWords.words[maskedWords.length++] = carry;
  11892. }
  11893. if (this.length === 0) {
  11894. this.words[0] = 0;
  11895. this.length = 1;
  11896. }
  11897. return this._strip();
  11898. };
  11899. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  11900. // TODO(indutny): implement me
  11901. assert(this.negative === 0);
  11902. return this.iushrn(bits, hint, extended);
  11903. };
  11904. // Shift-left
  11905. BN.prototype.shln = function shln (bits) {
  11906. return this.clone().ishln(bits);
  11907. };
  11908. BN.prototype.ushln = function ushln (bits) {
  11909. return this.clone().iushln(bits);
  11910. };
  11911. // Shift-right
  11912. BN.prototype.shrn = function shrn (bits) {
  11913. return this.clone().ishrn(bits);
  11914. };
  11915. BN.prototype.ushrn = function ushrn (bits) {
  11916. return this.clone().iushrn(bits);
  11917. };
  11918. // Test if n bit is set
  11919. BN.prototype.testn = function testn (bit) {
  11920. assert(typeof bit === 'number' && bit >= 0);
  11921. var r = bit % 26;
  11922. var s = (bit - r) / 26;
  11923. var q = 1 << r;
  11924. // Fast case: bit is much higher than all existing words
  11925. if (this.length <= s) return false;
  11926. // Check bit and return
  11927. var w = this.words[s];
  11928. return !!(w & q);
  11929. };
  11930. // Return only lowers bits of number (in-place)
  11931. BN.prototype.imaskn = function imaskn (bits) {
  11932. assert(typeof bits === 'number' && bits >= 0);
  11933. var r = bits % 26;
  11934. var s = (bits - r) / 26;
  11935. assert(this.negative === 0, 'imaskn works only with positive numbers');
  11936. if (this.length <= s) {
  11937. return this;
  11938. }
  11939. if (r !== 0) {
  11940. s++;
  11941. }
  11942. this.length = Math.min(s, this.length);
  11943. if (r !== 0) {
  11944. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  11945. this.words[this.length - 1] &= mask;
  11946. }
  11947. return this._strip();
  11948. };
  11949. // Return only lowers bits of number
  11950. BN.prototype.maskn = function maskn (bits) {
  11951. return this.clone().imaskn(bits);
  11952. };
  11953. // Add plain number `num` to `this`
  11954. BN.prototype.iaddn = function iaddn (num) {
  11955. assert(typeof num === 'number');
  11956. assert(num < 0x4000000);
  11957. if (num < 0) return this.isubn(-num);
  11958. // Possible sign change
  11959. if (this.negative !== 0) {
  11960. if (this.length === 1 && (this.words[0] | 0) <= num) {
  11961. this.words[0] = num - (this.words[0] | 0);
  11962. this.negative = 0;
  11963. return this;
  11964. }
  11965. this.negative = 0;
  11966. this.isubn(num);
  11967. this.negative = 1;
  11968. return this;
  11969. }
  11970. // Add without checks
  11971. return this._iaddn(num);
  11972. };
  11973. BN.prototype._iaddn = function _iaddn (num) {
  11974. this.words[0] += num;
  11975. // Carry
  11976. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  11977. this.words[i] -= 0x4000000;
  11978. if (i === this.length - 1) {
  11979. this.words[i + 1] = 1;
  11980. } else {
  11981. this.words[i + 1]++;
  11982. }
  11983. }
  11984. this.length = Math.max(this.length, i + 1);
  11985. return this;
  11986. };
  11987. // Subtract plain number `num` from `this`
  11988. BN.prototype.isubn = function isubn (num) {
  11989. assert(typeof num === 'number');
  11990. assert(num < 0x4000000);
  11991. if (num < 0) return this.iaddn(-num);
  11992. if (this.negative !== 0) {
  11993. this.negative = 0;
  11994. this.iaddn(num);
  11995. this.negative = 1;
  11996. return this;
  11997. }
  11998. this.words[0] -= num;
  11999. if (this.length === 1 && this.words[0] < 0) {
  12000. this.words[0] = -this.words[0];
  12001. this.negative = 1;
  12002. } else {
  12003. // Carry
  12004. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  12005. this.words[i] += 0x4000000;
  12006. this.words[i + 1] -= 1;
  12007. }
  12008. }
  12009. return this._strip();
  12010. };
  12011. BN.prototype.addn = function addn (num) {
  12012. return this.clone().iaddn(num);
  12013. };
  12014. BN.prototype.subn = function subn (num) {
  12015. return this.clone().isubn(num);
  12016. };
  12017. BN.prototype.iabs = function iabs () {
  12018. this.negative = 0;
  12019. return this;
  12020. };
  12021. BN.prototype.abs = function abs () {
  12022. return this.clone().iabs();
  12023. };
  12024. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  12025. var len = num.length + shift;
  12026. var i;
  12027. this._expand(len);
  12028. var w;
  12029. var carry = 0;
  12030. for (i = 0; i < num.length; i++) {
  12031. w = (this.words[i + shift] | 0) + carry;
  12032. var right = (num.words[i] | 0) * mul;
  12033. w -= right & 0x3ffffff;
  12034. carry = (w >> 26) - ((right / 0x4000000) | 0);
  12035. this.words[i + shift] = w & 0x3ffffff;
  12036. }
  12037. for (; i < this.length - shift; i++) {
  12038. w = (this.words[i + shift] | 0) + carry;
  12039. carry = w >> 26;
  12040. this.words[i + shift] = w & 0x3ffffff;
  12041. }
  12042. if (carry === 0) return this._strip();
  12043. // Subtraction overflow
  12044. assert(carry === -1);
  12045. carry = 0;
  12046. for (i = 0; i < this.length; i++) {
  12047. w = -(this.words[i] | 0) + carry;
  12048. carry = w >> 26;
  12049. this.words[i] = w & 0x3ffffff;
  12050. }
  12051. this.negative = 1;
  12052. return this._strip();
  12053. };
  12054. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  12055. var shift = this.length - num.length;
  12056. var a = this.clone();
  12057. var b = num;
  12058. // Normalize
  12059. var bhi = b.words[b.length - 1] | 0;
  12060. var bhiBits = this._countBits(bhi);
  12061. shift = 26 - bhiBits;
  12062. if (shift !== 0) {
  12063. b = b.ushln(shift);
  12064. a.iushln(shift);
  12065. bhi = b.words[b.length - 1] | 0;
  12066. }
  12067. // Initialize quotient
  12068. var m = a.length - b.length;
  12069. var q;
  12070. if (mode !== 'mod') {
  12071. q = new BN(null);
  12072. q.length = m + 1;
  12073. q.words = new Array(q.length);
  12074. for (var i = 0; i < q.length; i++) {
  12075. q.words[i] = 0;
  12076. }
  12077. }
  12078. var diff = a.clone()._ishlnsubmul(b, 1, m);
  12079. if (diff.negative === 0) {
  12080. a = diff;
  12081. if (q) {
  12082. q.words[m] = 1;
  12083. }
  12084. }
  12085. for (var j = m - 1; j >= 0; j--) {
  12086. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  12087. (a.words[b.length + j - 1] | 0);
  12088. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  12089. // (0x7ffffff)
  12090. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  12091. a._ishlnsubmul(b, qj, j);
  12092. while (a.negative !== 0) {
  12093. qj--;
  12094. a.negative = 0;
  12095. a._ishlnsubmul(b, 1, j);
  12096. if (!a.isZero()) {
  12097. a.negative ^= 1;
  12098. }
  12099. }
  12100. if (q) {
  12101. q.words[j] = qj;
  12102. }
  12103. }
  12104. if (q) {
  12105. q._strip();
  12106. }
  12107. a._strip();
  12108. // Denormalize
  12109. if (mode !== 'div' && shift !== 0) {
  12110. a.iushrn(shift);
  12111. }
  12112. return {
  12113. div: q || null,
  12114. mod: a
  12115. };
  12116. };
  12117. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  12118. // to `div` to request div only, or be absent to
  12119. // request both div & mod
  12120. // 2) `positive` is true if unsigned mod is requested
  12121. BN.prototype.divmod = function divmod (num, mode, positive) {
  12122. assert(!num.isZero());
  12123. if (this.isZero()) {
  12124. return {
  12125. div: new BN(0),
  12126. mod: new BN(0)
  12127. };
  12128. }
  12129. var div, mod, res;
  12130. if (this.negative !== 0 && num.negative === 0) {
  12131. res = this.neg().divmod(num, mode);
  12132. if (mode !== 'mod') {
  12133. div = res.div.neg();
  12134. }
  12135. if (mode !== 'div') {
  12136. mod = res.mod.neg();
  12137. if (positive && mod.negative !== 0) {
  12138. mod.iadd(num);
  12139. }
  12140. }
  12141. return {
  12142. div: div,
  12143. mod: mod
  12144. };
  12145. }
  12146. if (this.negative === 0 && num.negative !== 0) {
  12147. res = this.divmod(num.neg(), mode);
  12148. if (mode !== 'mod') {
  12149. div = res.div.neg();
  12150. }
  12151. return {
  12152. div: div,
  12153. mod: res.mod
  12154. };
  12155. }
  12156. if ((this.negative & num.negative) !== 0) {
  12157. res = this.neg().divmod(num.neg(), mode);
  12158. if (mode !== 'div') {
  12159. mod = res.mod.neg();
  12160. if (positive && mod.negative !== 0) {
  12161. mod.isub(num);
  12162. }
  12163. }
  12164. return {
  12165. div: res.div,
  12166. mod: mod
  12167. };
  12168. }
  12169. // Both numbers are positive at this point
  12170. // Strip both numbers to approximate shift value
  12171. if (num.length > this.length || this.cmp(num) < 0) {
  12172. return {
  12173. div: new BN(0),
  12174. mod: this
  12175. };
  12176. }
  12177. // Very short reduction
  12178. if (num.length === 1) {
  12179. if (mode === 'div') {
  12180. return {
  12181. div: this.divn(num.words[0]),
  12182. mod: null
  12183. };
  12184. }
  12185. if (mode === 'mod') {
  12186. return {
  12187. div: null,
  12188. mod: new BN(this.modrn(num.words[0]))
  12189. };
  12190. }
  12191. return {
  12192. div: this.divn(num.words[0]),
  12193. mod: new BN(this.modrn(num.words[0]))
  12194. };
  12195. }
  12196. return this._wordDiv(num, mode);
  12197. };
  12198. // Find `this` / `num`
  12199. BN.prototype.div = function div (num) {
  12200. return this.divmod(num, 'div', false).div;
  12201. };
  12202. // Find `this` % `num`
  12203. BN.prototype.mod = function mod (num) {
  12204. return this.divmod(num, 'mod', false).mod;
  12205. };
  12206. BN.prototype.umod = function umod (num) {
  12207. return this.divmod(num, 'mod', true).mod;
  12208. };
  12209. // Find Round(`this` / `num`)
  12210. BN.prototype.divRound = function divRound (num) {
  12211. var dm = this.divmod(num);
  12212. // Fast case - exact division
  12213. if (dm.mod.isZero()) return dm.div;
  12214. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  12215. var half = num.ushrn(1);
  12216. var r2 = num.andln(1);
  12217. var cmp = mod.cmp(half);
  12218. // Round down
  12219. if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div;
  12220. // Round up
  12221. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  12222. };
  12223. BN.prototype.modrn = function modrn (num) {
  12224. var isNegNum = num < 0;
  12225. if (isNegNum) num = -num;
  12226. assert(num <= 0x3ffffff);
  12227. var p = (1 << 26) % num;
  12228. var acc = 0;
  12229. for (var i = this.length - 1; i >= 0; i--) {
  12230. acc = (p * acc + (this.words[i] | 0)) % num;
  12231. }
  12232. return isNegNum ? -acc : acc;
  12233. };
  12234. // WARNING: DEPRECATED
  12235. BN.prototype.modn = function modn (num) {
  12236. return this.modrn(num);
  12237. };
  12238. // In-place division by number
  12239. BN.prototype.idivn = function idivn (num) {
  12240. var isNegNum = num < 0;
  12241. if (isNegNum) num = -num;
  12242. assert(num <= 0x3ffffff);
  12243. var carry = 0;
  12244. for (var i = this.length - 1; i >= 0; i--) {
  12245. var w = (this.words[i] | 0) + carry * 0x4000000;
  12246. this.words[i] = (w / num) | 0;
  12247. carry = w % num;
  12248. }
  12249. this._strip();
  12250. return isNegNum ? this.ineg() : this;
  12251. };
  12252. BN.prototype.divn = function divn (num) {
  12253. return this.clone().idivn(num);
  12254. };
  12255. BN.prototype.egcd = function egcd (p) {
  12256. assert(p.negative === 0);
  12257. assert(!p.isZero());
  12258. var x = this;
  12259. var y = p.clone();
  12260. if (x.negative !== 0) {
  12261. x = x.umod(p);
  12262. } else {
  12263. x = x.clone();
  12264. }
  12265. // A * x + B * y = x
  12266. var A = new BN(1);
  12267. var B = new BN(0);
  12268. // C * x + D * y = y
  12269. var C = new BN(0);
  12270. var D = new BN(1);
  12271. var g = 0;
  12272. while (x.isEven() && y.isEven()) {
  12273. x.iushrn(1);
  12274. y.iushrn(1);
  12275. ++g;
  12276. }
  12277. var yp = y.clone();
  12278. var xp = x.clone();
  12279. while (!x.isZero()) {
  12280. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  12281. if (i > 0) {
  12282. x.iushrn(i);
  12283. while (i-- > 0) {
  12284. if (A.isOdd() || B.isOdd()) {
  12285. A.iadd(yp);
  12286. B.isub(xp);
  12287. }
  12288. A.iushrn(1);
  12289. B.iushrn(1);
  12290. }
  12291. }
  12292. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  12293. if (j > 0) {
  12294. y.iushrn(j);
  12295. while (j-- > 0) {
  12296. if (C.isOdd() || D.isOdd()) {
  12297. C.iadd(yp);
  12298. D.isub(xp);
  12299. }
  12300. C.iushrn(1);
  12301. D.iushrn(1);
  12302. }
  12303. }
  12304. if (x.cmp(y) >= 0) {
  12305. x.isub(y);
  12306. A.isub(C);
  12307. B.isub(D);
  12308. } else {
  12309. y.isub(x);
  12310. C.isub(A);
  12311. D.isub(B);
  12312. }
  12313. }
  12314. return {
  12315. a: C,
  12316. b: D,
  12317. gcd: y.iushln(g)
  12318. };
  12319. };
  12320. // This is reduced incarnation of the binary EEA
  12321. // above, designated to invert members of the
  12322. // _prime_ fields F(p) at a maximal speed
  12323. BN.prototype._invmp = function _invmp (p) {
  12324. assert(p.negative === 0);
  12325. assert(!p.isZero());
  12326. var a = this;
  12327. var b = p.clone();
  12328. if (a.negative !== 0) {
  12329. a = a.umod(p);
  12330. } else {
  12331. a = a.clone();
  12332. }
  12333. var x1 = new BN(1);
  12334. var x2 = new BN(0);
  12335. var delta = b.clone();
  12336. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  12337. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  12338. if (i > 0) {
  12339. a.iushrn(i);
  12340. while (i-- > 0) {
  12341. if (x1.isOdd()) {
  12342. x1.iadd(delta);
  12343. }
  12344. x1.iushrn(1);
  12345. }
  12346. }
  12347. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  12348. if (j > 0) {
  12349. b.iushrn(j);
  12350. while (j-- > 0) {
  12351. if (x2.isOdd()) {
  12352. x2.iadd(delta);
  12353. }
  12354. x2.iushrn(1);
  12355. }
  12356. }
  12357. if (a.cmp(b) >= 0) {
  12358. a.isub(b);
  12359. x1.isub(x2);
  12360. } else {
  12361. b.isub(a);
  12362. x2.isub(x1);
  12363. }
  12364. }
  12365. var res;
  12366. if (a.cmpn(1) === 0) {
  12367. res = x1;
  12368. } else {
  12369. res = x2;
  12370. }
  12371. if (res.cmpn(0) < 0) {
  12372. res.iadd(p);
  12373. }
  12374. return res;
  12375. };
  12376. BN.prototype.gcd = function gcd (num) {
  12377. if (this.isZero()) return num.abs();
  12378. if (num.isZero()) return this.abs();
  12379. var a = this.clone();
  12380. var b = num.clone();
  12381. a.negative = 0;
  12382. b.negative = 0;
  12383. // Remove common factor of two
  12384. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  12385. a.iushrn(1);
  12386. b.iushrn(1);
  12387. }
  12388. do {
  12389. while (a.isEven()) {
  12390. a.iushrn(1);
  12391. }
  12392. while (b.isEven()) {
  12393. b.iushrn(1);
  12394. }
  12395. var r = a.cmp(b);
  12396. if (r < 0) {
  12397. // Swap `a` and `b` to make `a` always bigger than `b`
  12398. var t = a;
  12399. a = b;
  12400. b = t;
  12401. } else if (r === 0 || b.cmpn(1) === 0) {
  12402. break;
  12403. }
  12404. a.isub(b);
  12405. } while (true);
  12406. return b.iushln(shift);
  12407. };
  12408. // Invert number in the field F(num)
  12409. BN.prototype.invm = function invm (num) {
  12410. return this.egcd(num).a.umod(num);
  12411. };
  12412. BN.prototype.isEven = function isEven () {
  12413. return (this.words[0] & 1) === 0;
  12414. };
  12415. BN.prototype.isOdd = function isOdd () {
  12416. return (this.words[0] & 1) === 1;
  12417. };
  12418. // And first word and num
  12419. BN.prototype.andln = function andln (num) {
  12420. return this.words[0] & num;
  12421. };
  12422. // Increment at the bit position in-line
  12423. BN.prototype.bincn = function bincn (bit) {
  12424. assert(typeof bit === 'number');
  12425. var r = bit % 26;
  12426. var s = (bit - r) / 26;
  12427. var q = 1 << r;
  12428. // Fast case: bit is much higher than all existing words
  12429. if (this.length <= s) {
  12430. this._expand(s + 1);
  12431. this.words[s] |= q;
  12432. return this;
  12433. }
  12434. // Add bit and propagate, if needed
  12435. var carry = q;
  12436. for (var i = s; carry !== 0 && i < this.length; i++) {
  12437. var w = this.words[i] | 0;
  12438. w += carry;
  12439. carry = w >>> 26;
  12440. w &= 0x3ffffff;
  12441. this.words[i] = w;
  12442. }
  12443. if (carry !== 0) {
  12444. this.words[i] = carry;
  12445. this.length++;
  12446. }
  12447. return this;
  12448. };
  12449. BN.prototype.isZero = function isZero () {
  12450. return this.length === 1 && this.words[0] === 0;
  12451. };
  12452. BN.prototype.cmpn = function cmpn (num) {
  12453. var negative = num < 0;
  12454. if (this.negative !== 0 && !negative) return -1;
  12455. if (this.negative === 0 && negative) return 1;
  12456. this._strip();
  12457. var res;
  12458. if (this.length > 1) {
  12459. res = 1;
  12460. } else {
  12461. if (negative) {
  12462. num = -num;
  12463. }
  12464. assert(num <= 0x3ffffff, 'Number is too big');
  12465. var w = this.words[0] | 0;
  12466. res = w === num ? 0 : w < num ? -1 : 1;
  12467. }
  12468. if (this.negative !== 0) return -res | 0;
  12469. return res;
  12470. };
  12471. // Compare two numbers and return:
  12472. // 1 - if `this` > `num`
  12473. // 0 - if `this` == `num`
  12474. // -1 - if `this` < `num`
  12475. BN.prototype.cmp = function cmp (num) {
  12476. if (this.negative !== 0 && num.negative === 0) return -1;
  12477. if (this.negative === 0 && num.negative !== 0) return 1;
  12478. var res = this.ucmp(num);
  12479. if (this.negative !== 0) return -res | 0;
  12480. return res;
  12481. };
  12482. // Unsigned comparison
  12483. BN.prototype.ucmp = function ucmp (num) {
  12484. // At this point both numbers have the same sign
  12485. if (this.length > num.length) return 1;
  12486. if (this.length < num.length) return -1;
  12487. var res = 0;
  12488. for (var i = this.length - 1; i >= 0; i--) {
  12489. var a = this.words[i] | 0;
  12490. var b = num.words[i] | 0;
  12491. if (a === b) continue;
  12492. if (a < b) {
  12493. res = -1;
  12494. } else if (a > b) {
  12495. res = 1;
  12496. }
  12497. break;
  12498. }
  12499. return res;
  12500. };
  12501. BN.prototype.gtn = function gtn (num) {
  12502. return this.cmpn(num) === 1;
  12503. };
  12504. BN.prototype.gt = function gt (num) {
  12505. return this.cmp(num) === 1;
  12506. };
  12507. BN.prototype.gten = function gten (num) {
  12508. return this.cmpn(num) >= 0;
  12509. };
  12510. BN.prototype.gte = function gte (num) {
  12511. return this.cmp(num) >= 0;
  12512. };
  12513. BN.prototype.ltn = function ltn (num) {
  12514. return this.cmpn(num) === -1;
  12515. };
  12516. BN.prototype.lt = function lt (num) {
  12517. return this.cmp(num) === -1;
  12518. };
  12519. BN.prototype.lten = function lten (num) {
  12520. return this.cmpn(num) <= 0;
  12521. };
  12522. BN.prototype.lte = function lte (num) {
  12523. return this.cmp(num) <= 0;
  12524. };
  12525. BN.prototype.eqn = function eqn (num) {
  12526. return this.cmpn(num) === 0;
  12527. };
  12528. BN.prototype.eq = function eq (num) {
  12529. return this.cmp(num) === 0;
  12530. };
  12531. //
  12532. // A reduce context, could be using montgomery or something better, depending
  12533. // on the `m` itself.
  12534. //
  12535. BN.red = function red (num) {
  12536. return new Red(num);
  12537. };
  12538. BN.prototype.toRed = function toRed (ctx) {
  12539. assert(!this.red, 'Already a number in reduction context');
  12540. assert(this.negative === 0, 'red works only with positives');
  12541. return ctx.convertTo(this)._forceRed(ctx);
  12542. };
  12543. BN.prototype.fromRed = function fromRed () {
  12544. assert(this.red, 'fromRed works only with numbers in reduction context');
  12545. return this.red.convertFrom(this);
  12546. };
  12547. BN.prototype._forceRed = function _forceRed (ctx) {
  12548. this.red = ctx;
  12549. return this;
  12550. };
  12551. BN.prototype.forceRed = function forceRed (ctx) {
  12552. assert(!this.red, 'Already a number in reduction context');
  12553. return this._forceRed(ctx);
  12554. };
  12555. BN.prototype.redAdd = function redAdd (num) {
  12556. assert(this.red, 'redAdd works only with red numbers');
  12557. return this.red.add(this, num);
  12558. };
  12559. BN.prototype.redIAdd = function redIAdd (num) {
  12560. assert(this.red, 'redIAdd works only with red numbers');
  12561. return this.red.iadd(this, num);
  12562. };
  12563. BN.prototype.redSub = function redSub (num) {
  12564. assert(this.red, 'redSub works only with red numbers');
  12565. return this.red.sub(this, num);
  12566. };
  12567. BN.prototype.redISub = function redISub (num) {
  12568. assert(this.red, 'redISub works only with red numbers');
  12569. return this.red.isub(this, num);
  12570. };
  12571. BN.prototype.redShl = function redShl (num) {
  12572. assert(this.red, 'redShl works only with red numbers');
  12573. return this.red.shl(this, num);
  12574. };
  12575. BN.prototype.redMul = function redMul (num) {
  12576. assert(this.red, 'redMul works only with red numbers');
  12577. this.red._verify2(this, num);
  12578. return this.red.mul(this, num);
  12579. };
  12580. BN.prototype.redIMul = function redIMul (num) {
  12581. assert(this.red, 'redMul works only with red numbers');
  12582. this.red._verify2(this, num);
  12583. return this.red.imul(this, num);
  12584. };
  12585. BN.prototype.redSqr = function redSqr () {
  12586. assert(this.red, 'redSqr works only with red numbers');
  12587. this.red._verify1(this);
  12588. return this.red.sqr(this);
  12589. };
  12590. BN.prototype.redISqr = function redISqr () {
  12591. assert(this.red, 'redISqr works only with red numbers');
  12592. this.red._verify1(this);
  12593. return this.red.isqr(this);
  12594. };
  12595. // Square root over p
  12596. BN.prototype.redSqrt = function redSqrt () {
  12597. assert(this.red, 'redSqrt works only with red numbers');
  12598. this.red._verify1(this);
  12599. return this.red.sqrt(this);
  12600. };
  12601. BN.prototype.redInvm = function redInvm () {
  12602. assert(this.red, 'redInvm works only with red numbers');
  12603. this.red._verify1(this);
  12604. return this.red.invm(this);
  12605. };
  12606. // Return negative clone of `this` % `red modulo`
  12607. BN.prototype.redNeg = function redNeg () {
  12608. assert(this.red, 'redNeg works only with red numbers');
  12609. this.red._verify1(this);
  12610. return this.red.neg(this);
  12611. };
  12612. BN.prototype.redPow = function redPow (num) {
  12613. assert(this.red && !num.red, 'redPow(normalNum)');
  12614. this.red._verify1(this);
  12615. return this.red.pow(this, num);
  12616. };
  12617. // Prime numbers with efficient reduction
  12618. var primes = {
  12619. k256: null,
  12620. p224: null,
  12621. p192: null,
  12622. p25519: null
  12623. };
  12624. // Pseudo-Mersenne prime
  12625. function MPrime (name, p) {
  12626. // P = 2 ^ N - K
  12627. this.name = name;
  12628. this.p = new BN(p, 16);
  12629. this.n = this.p.bitLength();
  12630. this.k = new BN(1).iushln(this.n).isub(this.p);
  12631. this.tmp = this._tmp();
  12632. }
  12633. MPrime.prototype._tmp = function _tmp () {
  12634. var tmp = new BN(null);
  12635. tmp.words = new Array(Math.ceil(this.n / 13));
  12636. return tmp;
  12637. };
  12638. MPrime.prototype.ireduce = function ireduce (num) {
  12639. // Assumes that `num` is less than `P^2`
  12640. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  12641. var r = num;
  12642. var rlen;
  12643. do {
  12644. this.split(r, this.tmp);
  12645. r = this.imulK(r);
  12646. r = r.iadd(this.tmp);
  12647. rlen = r.bitLength();
  12648. } while (rlen > this.n);
  12649. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  12650. if (cmp === 0) {
  12651. r.words[0] = 0;
  12652. r.length = 1;
  12653. } else if (cmp > 0) {
  12654. r.isub(this.p);
  12655. } else {
  12656. if (r.strip !== undefined) {
  12657. // r is a BN v4 instance
  12658. r.strip();
  12659. } else {
  12660. // r is a BN v5 instance
  12661. r._strip();
  12662. }
  12663. }
  12664. return r;
  12665. };
  12666. MPrime.prototype.split = function split (input, out) {
  12667. input.iushrn(this.n, 0, out);
  12668. };
  12669. MPrime.prototype.imulK = function imulK (num) {
  12670. return num.imul(this.k);
  12671. };
  12672. function K256 () {
  12673. MPrime.call(
  12674. this,
  12675. 'k256',
  12676. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  12677. }
  12678. inherits(K256, MPrime);
  12679. K256.prototype.split = function split (input, output) {
  12680. // 256 = 9 * 26 + 22
  12681. var mask = 0x3fffff;
  12682. var outLen = Math.min(input.length, 9);
  12683. for (var i = 0; i < outLen; i++) {
  12684. output.words[i] = input.words[i];
  12685. }
  12686. output.length = outLen;
  12687. if (input.length <= 9) {
  12688. input.words[0] = 0;
  12689. input.length = 1;
  12690. return;
  12691. }
  12692. // Shift by 9 limbs
  12693. var prev = input.words[9];
  12694. output.words[output.length++] = prev & mask;
  12695. for (i = 10; i < input.length; i++) {
  12696. var next = input.words[i] | 0;
  12697. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  12698. prev = next;
  12699. }
  12700. prev >>>= 22;
  12701. input.words[i - 10] = prev;
  12702. if (prev === 0 && input.length > 10) {
  12703. input.length -= 10;
  12704. } else {
  12705. input.length -= 9;
  12706. }
  12707. };
  12708. K256.prototype.imulK = function imulK (num) {
  12709. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  12710. num.words[num.length] = 0;
  12711. num.words[num.length + 1] = 0;
  12712. num.length += 2;
  12713. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  12714. var lo = 0;
  12715. for (var i = 0; i < num.length; i++) {
  12716. var w = num.words[i] | 0;
  12717. lo += w * 0x3d1;
  12718. num.words[i] = lo & 0x3ffffff;
  12719. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  12720. }
  12721. // Fast length reduction
  12722. if (num.words[num.length - 1] === 0) {
  12723. num.length--;
  12724. if (num.words[num.length - 1] === 0) {
  12725. num.length--;
  12726. }
  12727. }
  12728. return num;
  12729. };
  12730. function P224 () {
  12731. MPrime.call(
  12732. this,
  12733. 'p224',
  12734. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  12735. }
  12736. inherits(P224, MPrime);
  12737. function P192 () {
  12738. MPrime.call(
  12739. this,
  12740. 'p192',
  12741. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  12742. }
  12743. inherits(P192, MPrime);
  12744. function P25519 () {
  12745. // 2 ^ 255 - 19
  12746. MPrime.call(
  12747. this,
  12748. '25519',
  12749. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  12750. }
  12751. inherits(P25519, MPrime);
  12752. P25519.prototype.imulK = function imulK (num) {
  12753. // K = 0x13
  12754. var carry = 0;
  12755. for (var i = 0; i < num.length; i++) {
  12756. var hi = (num.words[i] | 0) * 0x13 + carry;
  12757. var lo = hi & 0x3ffffff;
  12758. hi >>>= 26;
  12759. num.words[i] = lo;
  12760. carry = hi;
  12761. }
  12762. if (carry !== 0) {
  12763. num.words[num.length++] = carry;
  12764. }
  12765. return num;
  12766. };
  12767. // Exported mostly for testing purposes, use plain name instead
  12768. BN._prime = function prime (name) {
  12769. // Cached version of prime
  12770. if (primes[name]) return primes[name];
  12771. var prime;
  12772. if (name === 'k256') {
  12773. prime = new K256();
  12774. } else if (name === 'p224') {
  12775. prime = new P224();
  12776. } else if (name === 'p192') {
  12777. prime = new P192();
  12778. } else if (name === 'p25519') {
  12779. prime = new P25519();
  12780. } else {
  12781. throw new Error('Unknown prime ' + name);
  12782. }
  12783. primes[name] = prime;
  12784. return prime;
  12785. };
  12786. //
  12787. // Base reduction engine
  12788. //
  12789. function Red (m) {
  12790. if (typeof m === 'string') {
  12791. var prime = BN._prime(m);
  12792. this.m = prime.p;
  12793. this.prime = prime;
  12794. } else {
  12795. assert(m.gtn(1), 'modulus must be greater than 1');
  12796. this.m = m;
  12797. this.prime = null;
  12798. }
  12799. }
  12800. Red.prototype._verify1 = function _verify1 (a) {
  12801. assert(a.negative === 0, 'red works only with positives');
  12802. assert(a.red, 'red works only with red numbers');
  12803. };
  12804. Red.prototype._verify2 = function _verify2 (a, b) {
  12805. assert((a.negative | b.negative) === 0, 'red works only with positives');
  12806. assert(a.red && a.red === b.red,
  12807. 'red works only with red numbers');
  12808. };
  12809. Red.prototype.imod = function imod (a) {
  12810. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  12811. move(a, a.umod(this.m)._forceRed(this));
  12812. return a;
  12813. };
  12814. Red.prototype.neg = function neg (a) {
  12815. if (a.isZero()) {
  12816. return a.clone();
  12817. }
  12818. return this.m.sub(a)._forceRed(this);
  12819. };
  12820. Red.prototype.add = function add (a, b) {
  12821. this._verify2(a, b);
  12822. var res = a.add(b);
  12823. if (res.cmp(this.m) >= 0) {
  12824. res.isub(this.m);
  12825. }
  12826. return res._forceRed(this);
  12827. };
  12828. Red.prototype.iadd = function iadd (a, b) {
  12829. this._verify2(a, b);
  12830. var res = a.iadd(b);
  12831. if (res.cmp(this.m) >= 0) {
  12832. res.isub(this.m);
  12833. }
  12834. return res;
  12835. };
  12836. Red.prototype.sub = function sub (a, b) {
  12837. this._verify2(a, b);
  12838. var res = a.sub(b);
  12839. if (res.cmpn(0) < 0) {
  12840. res.iadd(this.m);
  12841. }
  12842. return res._forceRed(this);
  12843. };
  12844. Red.prototype.isub = function isub (a, b) {
  12845. this._verify2(a, b);
  12846. var res = a.isub(b);
  12847. if (res.cmpn(0) < 0) {
  12848. res.iadd(this.m);
  12849. }
  12850. return res;
  12851. };
  12852. Red.prototype.shl = function shl (a, num) {
  12853. this._verify1(a);
  12854. return this.imod(a.ushln(num));
  12855. };
  12856. Red.prototype.imul = function imul (a, b) {
  12857. this._verify2(a, b);
  12858. return this.imod(a.imul(b));
  12859. };
  12860. Red.prototype.mul = function mul (a, b) {
  12861. this._verify2(a, b);
  12862. return this.imod(a.mul(b));
  12863. };
  12864. Red.prototype.isqr = function isqr (a) {
  12865. return this.imul(a, a.clone());
  12866. };
  12867. Red.prototype.sqr = function sqr (a) {
  12868. return this.mul(a, a);
  12869. };
  12870. Red.prototype.sqrt = function sqrt (a) {
  12871. if (a.isZero()) return a.clone();
  12872. var mod3 = this.m.andln(3);
  12873. assert(mod3 % 2 === 1);
  12874. // Fast case
  12875. if (mod3 === 3) {
  12876. var pow = this.m.add(new BN(1)).iushrn(2);
  12877. return this.pow(a, pow);
  12878. }
  12879. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  12880. //
  12881. // Find Q and S, that Q * 2 ^ S = (P - 1)
  12882. var q = this.m.subn(1);
  12883. var s = 0;
  12884. while (!q.isZero() && q.andln(1) === 0) {
  12885. s++;
  12886. q.iushrn(1);
  12887. }
  12888. assert(!q.isZero());
  12889. var one = new BN(1).toRed(this);
  12890. var nOne = one.redNeg();
  12891. // Find quadratic non-residue
  12892. // NOTE: Max is such because of generalized Riemann hypothesis.
  12893. var lpow = this.m.subn(1).iushrn(1);
  12894. var z = this.m.bitLength();
  12895. z = new BN(2 * z * z).toRed(this);
  12896. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  12897. z.redIAdd(nOne);
  12898. }
  12899. var c = this.pow(z, q);
  12900. var r = this.pow(a, q.addn(1).iushrn(1));
  12901. var t = this.pow(a, q);
  12902. var m = s;
  12903. while (t.cmp(one) !== 0) {
  12904. var tmp = t;
  12905. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  12906. tmp = tmp.redSqr();
  12907. }
  12908. assert(i < m);
  12909. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  12910. r = r.redMul(b);
  12911. c = b.redSqr();
  12912. t = t.redMul(c);
  12913. m = i;
  12914. }
  12915. return r;
  12916. };
  12917. Red.prototype.invm = function invm (a) {
  12918. var inv = a._invmp(this.m);
  12919. if (inv.negative !== 0) {
  12920. inv.negative = 0;
  12921. return this.imod(inv).redNeg();
  12922. } else {
  12923. return this.imod(inv);
  12924. }
  12925. };
  12926. Red.prototype.pow = function pow (a, num) {
  12927. if (num.isZero()) return new BN(1).toRed(this);
  12928. if (num.cmpn(1) === 0) return a.clone();
  12929. var windowSize = 4;
  12930. var wnd = new Array(1 << windowSize);
  12931. wnd[0] = new BN(1).toRed(this);
  12932. wnd[1] = a;
  12933. for (var i = 2; i < wnd.length; i++) {
  12934. wnd[i] = this.mul(wnd[i - 1], a);
  12935. }
  12936. var res = wnd[0];
  12937. var current = 0;
  12938. var currentLen = 0;
  12939. var start = num.bitLength() % 26;
  12940. if (start === 0) {
  12941. start = 26;
  12942. }
  12943. for (i = num.length - 1; i >= 0; i--) {
  12944. var word = num.words[i];
  12945. for (var j = start - 1; j >= 0; j--) {
  12946. var bit = (word >> j) & 1;
  12947. if (res !== wnd[0]) {
  12948. res = this.sqr(res);
  12949. }
  12950. if (bit === 0 && current === 0) {
  12951. currentLen = 0;
  12952. continue;
  12953. }
  12954. current <<= 1;
  12955. current |= bit;
  12956. currentLen++;
  12957. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  12958. res = this.mul(res, wnd[current]);
  12959. currentLen = 0;
  12960. current = 0;
  12961. }
  12962. start = 26;
  12963. }
  12964. return res;
  12965. };
  12966. Red.prototype.convertTo = function convertTo (num) {
  12967. var r = num.umod(this.m);
  12968. return r === num ? r.clone() : r;
  12969. };
  12970. Red.prototype.convertFrom = function convertFrom (num) {
  12971. var res = num.clone();
  12972. res.red = null;
  12973. return res;
  12974. };
  12975. //
  12976. // Montgomery method engine
  12977. //
  12978. BN.mont = function mont (num) {
  12979. return new Mont(num);
  12980. };
  12981. function Mont (m) {
  12982. Red.call(this, m);
  12983. this.shift = this.m.bitLength();
  12984. if (this.shift % 26 !== 0) {
  12985. this.shift += 26 - (this.shift % 26);
  12986. }
  12987. this.r = new BN(1).iushln(this.shift);
  12988. this.r2 = this.imod(this.r.sqr());
  12989. this.rinv = this.r._invmp(this.m);
  12990. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  12991. this.minv = this.minv.umod(this.r);
  12992. this.minv = this.r.sub(this.minv);
  12993. }
  12994. inherits(Mont, Red);
  12995. Mont.prototype.convertTo = function convertTo (num) {
  12996. return this.imod(num.ushln(this.shift));
  12997. };
  12998. Mont.prototype.convertFrom = function convertFrom (num) {
  12999. var r = this.imod(num.mul(this.rinv));
  13000. r.red = null;
  13001. return r;
  13002. };
  13003. Mont.prototype.imul = function imul (a, b) {
  13004. if (a.isZero() || b.isZero()) {
  13005. a.words[0] = 0;
  13006. a.length = 1;
  13007. return a;
  13008. }
  13009. var t = a.imul(b);
  13010. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  13011. var u = t.isub(c).iushrn(this.shift);
  13012. var res = u;
  13013. if (u.cmp(this.m) >= 0) {
  13014. res = u.isub(this.m);
  13015. } else if (u.cmpn(0) < 0) {
  13016. res = u.iadd(this.m);
  13017. }
  13018. return res._forceRed(this);
  13019. };
  13020. Mont.prototype.mul = function mul (a, b) {
  13021. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  13022. var t = a.mul(b);
  13023. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  13024. var u = t.isub(c).iushrn(this.shift);
  13025. var res = u;
  13026. if (u.cmp(this.m) >= 0) {
  13027. res = u.isub(this.m);
  13028. } else if (u.cmpn(0) < 0) {
  13029. res = u.iadd(this.m);
  13030. }
  13031. return res._forceRed(this);
  13032. };
  13033. Mont.prototype.invm = function invm (a) {
  13034. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  13035. var res = this.imod(a._invmp(this.m).mul(this.r2));
  13036. return res._forceRed(this);
  13037. };
  13038. })( false || module, this);
  13039. /***/ }),
  13040. /***/ "./node_modules/bootstrap/dist/js/bootstrap.esm.js":
  13041. /*!*********************************************************!*\
  13042. !*** ./node_modules/bootstrap/dist/js/bootstrap.esm.js ***!
  13043. \*********************************************************/
  13044. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  13045. "use strict";
  13046. __webpack_require__.r(__webpack_exports__);
  13047. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  13048. /* harmony export */ Alert: () => (/* binding */ Alert),
  13049. /* harmony export */ Button: () => (/* binding */ Button),
  13050. /* harmony export */ Carousel: () => (/* binding */ Carousel),
  13051. /* harmony export */ Collapse: () => (/* binding */ Collapse),
  13052. /* harmony export */ Dropdown: () => (/* binding */ Dropdown),
  13053. /* harmony export */ Modal: () => (/* binding */ Modal),
  13054. /* harmony export */ Offcanvas: () => (/* binding */ Offcanvas),
  13055. /* harmony export */ Popover: () => (/* binding */ Popover),
  13056. /* harmony export */ ScrollSpy: () => (/* binding */ ScrollSpy),
  13057. /* harmony export */ Tab: () => (/* binding */ Tab),
  13058. /* harmony export */ Toast: () => (/* binding */ Toast),
  13059. /* harmony export */ Tooltip: () => (/* binding */ Tooltip)
  13060. /* harmony export */ });
  13061. /* harmony import */ var _popperjs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @popperjs/core */ "./node_modules/@popperjs/core/lib/index.js");
  13062. /* harmony import */ var _popperjs_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @popperjs/core */ "./node_modules/@popperjs/core/lib/popper.js");
  13063. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  13064. /*!
  13065. * Bootstrap v5.2.3 (https://getbootstrap.com/)
  13066. * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  13067. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13068. */
  13069. /**
  13070. * --------------------------------------------------------------------------
  13071. * Bootstrap (v5.2.3): util/index.js
  13072. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13073. * --------------------------------------------------------------------------
  13074. */
  13075. const MAX_UID = 1000000;
  13076. const MILLISECONDS_MULTIPLIER = 1000;
  13077. const TRANSITION_END = 'transitionend'; // Shout-out Angus Croll (https://goo.gl/pxwQGp)
  13078. const toType = object => {
  13079. if (object === null || object === undefined) {
  13080. return `${object}`;
  13081. }
  13082. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  13083. };
  13084. /**
  13085. * Public Util API
  13086. */
  13087. const getUID = prefix => {
  13088. do {
  13089. prefix += Math.floor(Math.random() * MAX_UID);
  13090. } while (document.getElementById(prefix));
  13091. return prefix;
  13092. };
  13093. const getSelector = element => {
  13094. let selector = element.getAttribute('data-bs-target');
  13095. if (!selector || selector === '#') {
  13096. let hrefAttribute = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
  13097. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  13098. // `document.querySelector` will rightfully complain it is invalid.
  13099. // See https://github.com/twbs/bootstrap/issues/32273
  13100. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  13101. return null;
  13102. } // Just in case some CMS puts out a full URL with the anchor appended
  13103. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  13104. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  13105. }
  13106. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  13107. }
  13108. return selector;
  13109. };
  13110. const getSelectorFromElement = element => {
  13111. const selector = getSelector(element);
  13112. if (selector) {
  13113. return document.querySelector(selector) ? selector : null;
  13114. }
  13115. return null;
  13116. };
  13117. const getElementFromSelector = element => {
  13118. const selector = getSelector(element);
  13119. return selector ? document.querySelector(selector) : null;
  13120. };
  13121. const getTransitionDurationFromElement = element => {
  13122. if (!element) {
  13123. return 0;
  13124. } // Get transition-duration of the element
  13125. let {
  13126. transitionDuration,
  13127. transitionDelay
  13128. } = window.getComputedStyle(element);
  13129. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  13130. const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  13131. if (!floatTransitionDuration && !floatTransitionDelay) {
  13132. return 0;
  13133. } // If multiple durations are defined, take the first
  13134. transitionDuration = transitionDuration.split(',')[0];
  13135. transitionDelay = transitionDelay.split(',')[0];
  13136. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  13137. };
  13138. const triggerTransitionEnd = element => {
  13139. element.dispatchEvent(new Event(TRANSITION_END));
  13140. };
  13141. const isElement = object => {
  13142. if (!object || typeof object !== 'object') {
  13143. return false;
  13144. }
  13145. if (typeof object.jquery !== 'undefined') {
  13146. object = object[0];
  13147. }
  13148. return typeof object.nodeType !== 'undefined';
  13149. };
  13150. const getElement = object => {
  13151. // it's a jQuery object or a node element
  13152. if (isElement(object)) {
  13153. return object.jquery ? object[0] : object;
  13154. }
  13155. if (typeof object === 'string' && object.length > 0) {
  13156. return document.querySelector(object);
  13157. }
  13158. return null;
  13159. };
  13160. const isVisible = element => {
  13161. if (!isElement(element) || element.getClientRects().length === 0) {
  13162. return false;
  13163. }
  13164. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible'; // Handle `details` element as its content may falsie appear visible when it is closed
  13165. const closedDetails = element.closest('details:not([open])');
  13166. if (!closedDetails) {
  13167. return elementIsVisible;
  13168. }
  13169. if (closedDetails !== element) {
  13170. const summary = element.closest('summary');
  13171. if (summary && summary.parentNode !== closedDetails) {
  13172. return false;
  13173. }
  13174. if (summary === null) {
  13175. return false;
  13176. }
  13177. }
  13178. return elementIsVisible;
  13179. };
  13180. const isDisabled = element => {
  13181. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  13182. return true;
  13183. }
  13184. if (element.classList.contains('disabled')) {
  13185. return true;
  13186. }
  13187. if (typeof element.disabled !== 'undefined') {
  13188. return element.disabled;
  13189. }
  13190. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  13191. };
  13192. const findShadowRoot = element => {
  13193. if (!document.documentElement.attachShadow) {
  13194. return null;
  13195. } // Can find the shadow root otherwise it'll return the document
  13196. if (typeof element.getRootNode === 'function') {
  13197. const root = element.getRootNode();
  13198. return root instanceof ShadowRoot ? root : null;
  13199. }
  13200. if (element instanceof ShadowRoot) {
  13201. return element;
  13202. } // when we don't find a shadow root
  13203. if (!element.parentNode) {
  13204. return null;
  13205. }
  13206. return findShadowRoot(element.parentNode);
  13207. };
  13208. const noop = () => {};
  13209. /**
  13210. * Trick to restart an element's animation
  13211. *
  13212. * @param {HTMLElement} element
  13213. * @return void
  13214. *
  13215. * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
  13216. */
  13217. const reflow = element => {
  13218. element.offsetHeight; // eslint-disable-line no-unused-expressions
  13219. };
  13220. const getjQuery = () => {
  13221. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  13222. return window.jQuery;
  13223. }
  13224. return null;
  13225. };
  13226. const DOMContentLoadedCallbacks = [];
  13227. const onDOMContentLoaded = callback => {
  13228. if (document.readyState === 'loading') {
  13229. // add listener on the first call when the document is in loading state
  13230. if (!DOMContentLoadedCallbacks.length) {
  13231. document.addEventListener('DOMContentLoaded', () => {
  13232. for (const callback of DOMContentLoadedCallbacks) {
  13233. callback();
  13234. }
  13235. });
  13236. }
  13237. DOMContentLoadedCallbacks.push(callback);
  13238. } else {
  13239. callback();
  13240. }
  13241. };
  13242. const isRTL = () => document.documentElement.dir === 'rtl';
  13243. const defineJQueryPlugin = plugin => {
  13244. onDOMContentLoaded(() => {
  13245. const $ = getjQuery();
  13246. /* istanbul ignore if */
  13247. if ($) {
  13248. const name = plugin.NAME;
  13249. const JQUERY_NO_CONFLICT = $.fn[name];
  13250. $.fn[name] = plugin.jQueryInterface;
  13251. $.fn[name].Constructor = plugin;
  13252. $.fn[name].noConflict = () => {
  13253. $.fn[name] = JQUERY_NO_CONFLICT;
  13254. return plugin.jQueryInterface;
  13255. };
  13256. }
  13257. });
  13258. };
  13259. const execute = callback => {
  13260. if (typeof callback === 'function') {
  13261. callback();
  13262. }
  13263. };
  13264. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  13265. if (!waitForTransition) {
  13266. execute(callback);
  13267. return;
  13268. }
  13269. const durationPadding = 5;
  13270. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  13271. let called = false;
  13272. const handler = ({
  13273. target
  13274. }) => {
  13275. if (target !== transitionElement) {
  13276. return;
  13277. }
  13278. called = true;
  13279. transitionElement.removeEventListener(TRANSITION_END, handler);
  13280. execute(callback);
  13281. };
  13282. transitionElement.addEventListener(TRANSITION_END, handler);
  13283. setTimeout(() => {
  13284. if (!called) {
  13285. triggerTransitionEnd(transitionElement);
  13286. }
  13287. }, emulatedDuration);
  13288. };
  13289. /**
  13290. * Return the previous/next element of a list.
  13291. *
  13292. * @param {array} list The list of elements
  13293. * @param activeElement The active element
  13294. * @param shouldGetNext Choose to get next or previous element
  13295. * @param isCycleAllowed
  13296. * @return {Element|elem} The proper element
  13297. */
  13298. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  13299. const listLength = list.length;
  13300. let index = list.indexOf(activeElement); // if the element does not exist in the list return an element
  13301. // depending on the direction and if cycle is allowed
  13302. if (index === -1) {
  13303. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  13304. }
  13305. index += shouldGetNext ? 1 : -1;
  13306. if (isCycleAllowed) {
  13307. index = (index + listLength) % listLength;
  13308. }
  13309. return list[Math.max(0, Math.min(index, listLength - 1))];
  13310. };
  13311. /**
  13312. * --------------------------------------------------------------------------
  13313. * Bootstrap (v5.2.3): dom/event-handler.js
  13314. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13315. * --------------------------------------------------------------------------
  13316. */
  13317. /**
  13318. * Constants
  13319. */
  13320. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  13321. const stripNameRegex = /\..*/;
  13322. const stripUidRegex = /::\d+$/;
  13323. const eventRegistry = {}; // Events storage
  13324. let uidEvent = 1;
  13325. const customEvents = {
  13326. mouseenter: 'mouseover',
  13327. mouseleave: 'mouseout'
  13328. };
  13329. const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']);
  13330. /**
  13331. * Private methods
  13332. */
  13333. function makeEventUid(element, uid) {
  13334. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  13335. }
  13336. function getElementEvents(element) {
  13337. const uid = makeEventUid(element);
  13338. element.uidEvent = uid;
  13339. eventRegistry[uid] = eventRegistry[uid] || {};
  13340. return eventRegistry[uid];
  13341. }
  13342. function bootstrapHandler(element, fn) {
  13343. return function handler(event) {
  13344. hydrateObj(event, {
  13345. delegateTarget: element
  13346. });
  13347. if (handler.oneOff) {
  13348. EventHandler.off(element, event.type, fn);
  13349. }
  13350. return fn.apply(element, [event]);
  13351. };
  13352. }
  13353. function bootstrapDelegationHandler(element, selector, fn) {
  13354. return function handler(event) {
  13355. const domElements = element.querySelectorAll(selector);
  13356. for (let {
  13357. target
  13358. } = event; target && target !== this; target = target.parentNode) {
  13359. for (const domElement of domElements) {
  13360. if (domElement !== target) {
  13361. continue;
  13362. }
  13363. hydrateObj(event, {
  13364. delegateTarget: target
  13365. });
  13366. if (handler.oneOff) {
  13367. EventHandler.off(element, event.type, selector, fn);
  13368. }
  13369. return fn.apply(target, [event]);
  13370. }
  13371. }
  13372. };
  13373. }
  13374. function findHandler(events, callable, delegationSelector = null) {
  13375. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  13376. }
  13377. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  13378. const isDelegated = typeof handler === 'string'; // todo: tooltip passes `false` instead of selector, so we need to check
  13379. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  13380. let typeEvent = getTypeEvent(originalTypeEvent);
  13381. if (!nativeEvents.has(typeEvent)) {
  13382. typeEvent = originalTypeEvent;
  13383. }
  13384. return [isDelegated, callable, typeEvent];
  13385. }
  13386. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  13387. if (typeof originalTypeEvent !== 'string' || !element) {
  13388. return;
  13389. }
  13390. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction); // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
  13391. // this prevents the handler from being dispatched the same way as mouseover or mouseout does
  13392. if (originalTypeEvent in customEvents) {
  13393. const wrapFunction = fn => {
  13394. return function (event) {
  13395. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  13396. return fn.call(this, event);
  13397. }
  13398. };
  13399. };
  13400. callable = wrapFunction(callable);
  13401. }
  13402. const events = getElementEvents(element);
  13403. const handlers = events[typeEvent] || (events[typeEvent] = {});
  13404. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  13405. if (previousFunction) {
  13406. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  13407. return;
  13408. }
  13409. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  13410. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  13411. fn.delegationSelector = isDelegated ? handler : null;
  13412. fn.callable = callable;
  13413. fn.oneOff = oneOff;
  13414. fn.uidEvent = uid;
  13415. handlers[uid] = fn;
  13416. element.addEventListener(typeEvent, fn, isDelegated);
  13417. }
  13418. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  13419. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  13420. if (!fn) {
  13421. return;
  13422. }
  13423. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  13424. delete events[typeEvent][fn.uidEvent];
  13425. }
  13426. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  13427. const storeElementEvent = events[typeEvent] || {};
  13428. for (const handlerKey of Object.keys(storeElementEvent)) {
  13429. if (handlerKey.includes(namespace)) {
  13430. const event = storeElementEvent[handlerKey];
  13431. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  13432. }
  13433. }
  13434. }
  13435. function getTypeEvent(event) {
  13436. // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
  13437. event = event.replace(stripNameRegex, '');
  13438. return customEvents[event] || event;
  13439. }
  13440. const EventHandler = {
  13441. on(element, event, handler, delegationFunction) {
  13442. addHandler(element, event, handler, delegationFunction, false);
  13443. },
  13444. one(element, event, handler, delegationFunction) {
  13445. addHandler(element, event, handler, delegationFunction, true);
  13446. },
  13447. off(element, originalTypeEvent, handler, delegationFunction) {
  13448. if (typeof originalTypeEvent !== 'string' || !element) {
  13449. return;
  13450. }
  13451. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  13452. const inNamespace = typeEvent !== originalTypeEvent;
  13453. const events = getElementEvents(element);
  13454. const storeElementEvent = events[typeEvent] || {};
  13455. const isNamespace = originalTypeEvent.startsWith('.');
  13456. if (typeof callable !== 'undefined') {
  13457. // Simplest case: handler is passed, remove that listener ONLY.
  13458. if (!Object.keys(storeElementEvent).length) {
  13459. return;
  13460. }
  13461. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  13462. return;
  13463. }
  13464. if (isNamespace) {
  13465. for (const elementEvent of Object.keys(events)) {
  13466. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  13467. }
  13468. }
  13469. for (const keyHandlers of Object.keys(storeElementEvent)) {
  13470. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  13471. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  13472. const event = storeElementEvent[keyHandlers];
  13473. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  13474. }
  13475. }
  13476. },
  13477. trigger(element, event, args) {
  13478. if (typeof event !== 'string' || !element) {
  13479. return null;
  13480. }
  13481. const $ = getjQuery();
  13482. const typeEvent = getTypeEvent(event);
  13483. const inNamespace = event !== typeEvent;
  13484. let jQueryEvent = null;
  13485. let bubbles = true;
  13486. let nativeDispatch = true;
  13487. let defaultPrevented = false;
  13488. if (inNamespace && $) {
  13489. jQueryEvent = $.Event(event, args);
  13490. $(element).trigger(jQueryEvent);
  13491. bubbles = !jQueryEvent.isPropagationStopped();
  13492. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  13493. defaultPrevented = jQueryEvent.isDefaultPrevented();
  13494. }
  13495. let evt = new Event(event, {
  13496. bubbles,
  13497. cancelable: true
  13498. });
  13499. evt = hydrateObj(evt, args);
  13500. if (defaultPrevented) {
  13501. evt.preventDefault();
  13502. }
  13503. if (nativeDispatch) {
  13504. element.dispatchEvent(evt);
  13505. }
  13506. if (evt.defaultPrevented && jQueryEvent) {
  13507. jQueryEvent.preventDefault();
  13508. }
  13509. return evt;
  13510. }
  13511. };
  13512. function hydrateObj(obj, meta) {
  13513. for (const [key, value] of Object.entries(meta || {})) {
  13514. try {
  13515. obj[key] = value;
  13516. } catch (_unused) {
  13517. Object.defineProperty(obj, key, {
  13518. configurable: true,
  13519. get() {
  13520. return value;
  13521. }
  13522. });
  13523. }
  13524. }
  13525. return obj;
  13526. }
  13527. /**
  13528. * --------------------------------------------------------------------------
  13529. * Bootstrap (v5.2.3): dom/data.js
  13530. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13531. * --------------------------------------------------------------------------
  13532. */
  13533. /**
  13534. * Constants
  13535. */
  13536. const elementMap = new Map();
  13537. const Data = {
  13538. set(element, key, instance) {
  13539. if (!elementMap.has(element)) {
  13540. elementMap.set(element, new Map());
  13541. }
  13542. const instanceMap = elementMap.get(element); // make it clear we only want one instance per element
  13543. // can be removed later when multiple key/instances are fine to be used
  13544. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  13545. // eslint-disable-next-line no-console
  13546. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  13547. return;
  13548. }
  13549. instanceMap.set(key, instance);
  13550. },
  13551. get(element, key) {
  13552. if (elementMap.has(element)) {
  13553. return elementMap.get(element).get(key) || null;
  13554. }
  13555. return null;
  13556. },
  13557. remove(element, key) {
  13558. if (!elementMap.has(element)) {
  13559. return;
  13560. }
  13561. const instanceMap = elementMap.get(element);
  13562. instanceMap.delete(key); // free up element references if there are no instances left for an element
  13563. if (instanceMap.size === 0) {
  13564. elementMap.delete(element);
  13565. }
  13566. }
  13567. };
  13568. /**
  13569. * --------------------------------------------------------------------------
  13570. * Bootstrap (v5.2.3): dom/manipulator.js
  13571. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13572. * --------------------------------------------------------------------------
  13573. */
  13574. function normalizeData(value) {
  13575. if (value === 'true') {
  13576. return true;
  13577. }
  13578. if (value === 'false') {
  13579. return false;
  13580. }
  13581. if (value === Number(value).toString()) {
  13582. return Number(value);
  13583. }
  13584. if (value === '' || value === 'null') {
  13585. return null;
  13586. }
  13587. if (typeof value !== 'string') {
  13588. return value;
  13589. }
  13590. try {
  13591. return JSON.parse(decodeURIComponent(value));
  13592. } catch (_unused) {
  13593. return value;
  13594. }
  13595. }
  13596. function normalizeDataKey(key) {
  13597. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  13598. }
  13599. const Manipulator = {
  13600. setDataAttribute(element, key, value) {
  13601. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  13602. },
  13603. removeDataAttribute(element, key) {
  13604. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  13605. },
  13606. getDataAttributes(element) {
  13607. if (!element) {
  13608. return {};
  13609. }
  13610. const attributes = {};
  13611. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  13612. for (const key of bsKeys) {
  13613. let pureKey = key.replace(/^bs/, '');
  13614. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  13615. attributes[pureKey] = normalizeData(element.dataset[key]);
  13616. }
  13617. return attributes;
  13618. },
  13619. getDataAttribute(element, key) {
  13620. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  13621. }
  13622. };
  13623. /**
  13624. * --------------------------------------------------------------------------
  13625. * Bootstrap (v5.2.3): util/config.js
  13626. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13627. * --------------------------------------------------------------------------
  13628. */
  13629. /**
  13630. * Class definition
  13631. */
  13632. class Config {
  13633. // Getters
  13634. static get Default() {
  13635. return {};
  13636. }
  13637. static get DefaultType() {
  13638. return {};
  13639. }
  13640. static get NAME() {
  13641. throw new Error('You have to implement the static method "NAME", for each component!');
  13642. }
  13643. _getConfig(config) {
  13644. config = this._mergeConfigObj(config);
  13645. config = this._configAfterMerge(config);
  13646. this._typeCheckConfig(config);
  13647. return config;
  13648. }
  13649. _configAfterMerge(config) {
  13650. return config;
  13651. }
  13652. _mergeConfigObj(config, element) {
  13653. const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse
  13654. return { ...this.constructor.Default,
  13655. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  13656. ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
  13657. ...(typeof config === 'object' ? config : {})
  13658. };
  13659. }
  13660. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  13661. for (const property of Object.keys(configTypes)) {
  13662. const expectedTypes = configTypes[property];
  13663. const value = config[property];
  13664. const valueType = isElement(value) ? 'element' : toType(value);
  13665. if (!new RegExp(expectedTypes).test(valueType)) {
  13666. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  13667. }
  13668. }
  13669. }
  13670. }
  13671. /**
  13672. * --------------------------------------------------------------------------
  13673. * Bootstrap (v5.2.3): base-component.js
  13674. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13675. * --------------------------------------------------------------------------
  13676. */
  13677. /**
  13678. * Constants
  13679. */
  13680. const VERSION = '5.2.3';
  13681. /**
  13682. * Class definition
  13683. */
  13684. class BaseComponent extends Config {
  13685. constructor(element, config) {
  13686. super();
  13687. element = getElement(element);
  13688. if (!element) {
  13689. return;
  13690. }
  13691. this._element = element;
  13692. this._config = this._getConfig(config);
  13693. Data.set(this._element, this.constructor.DATA_KEY, this);
  13694. } // Public
  13695. dispose() {
  13696. Data.remove(this._element, this.constructor.DATA_KEY);
  13697. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  13698. for (const propertyName of Object.getOwnPropertyNames(this)) {
  13699. this[propertyName] = null;
  13700. }
  13701. }
  13702. _queueCallback(callback, element, isAnimated = true) {
  13703. executeAfterTransition(callback, element, isAnimated);
  13704. }
  13705. _getConfig(config) {
  13706. config = this._mergeConfigObj(config, this._element);
  13707. config = this._configAfterMerge(config);
  13708. this._typeCheckConfig(config);
  13709. return config;
  13710. } // Static
  13711. static getInstance(element) {
  13712. return Data.get(getElement(element), this.DATA_KEY);
  13713. }
  13714. static getOrCreateInstance(element, config = {}) {
  13715. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  13716. }
  13717. static get VERSION() {
  13718. return VERSION;
  13719. }
  13720. static get DATA_KEY() {
  13721. return `bs.${this.NAME}`;
  13722. }
  13723. static get EVENT_KEY() {
  13724. return `.${this.DATA_KEY}`;
  13725. }
  13726. static eventName(name) {
  13727. return `${name}${this.EVENT_KEY}`;
  13728. }
  13729. }
  13730. /**
  13731. * --------------------------------------------------------------------------
  13732. * Bootstrap (v5.2.3): util/component-functions.js
  13733. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13734. * --------------------------------------------------------------------------
  13735. */
  13736. const enableDismissTrigger = (component, method = 'hide') => {
  13737. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  13738. const name = component.NAME;
  13739. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  13740. if (['A', 'AREA'].includes(this.tagName)) {
  13741. event.preventDefault();
  13742. }
  13743. if (isDisabled(this)) {
  13744. return;
  13745. }
  13746. const target = getElementFromSelector(this) || this.closest(`.${name}`);
  13747. const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  13748. instance[method]();
  13749. });
  13750. };
  13751. /**
  13752. * --------------------------------------------------------------------------
  13753. * Bootstrap (v5.2.3): alert.js
  13754. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13755. * --------------------------------------------------------------------------
  13756. */
  13757. /**
  13758. * Constants
  13759. */
  13760. const NAME$f = 'alert';
  13761. const DATA_KEY$a = 'bs.alert';
  13762. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  13763. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  13764. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  13765. const CLASS_NAME_FADE$5 = 'fade';
  13766. const CLASS_NAME_SHOW$8 = 'show';
  13767. /**
  13768. * Class definition
  13769. */
  13770. class Alert extends BaseComponent {
  13771. // Getters
  13772. static get NAME() {
  13773. return NAME$f;
  13774. } // Public
  13775. close() {
  13776. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  13777. if (closeEvent.defaultPrevented) {
  13778. return;
  13779. }
  13780. this._element.classList.remove(CLASS_NAME_SHOW$8);
  13781. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  13782. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  13783. } // Private
  13784. _destroyElement() {
  13785. this._element.remove();
  13786. EventHandler.trigger(this._element, EVENT_CLOSED);
  13787. this.dispose();
  13788. } // Static
  13789. static jQueryInterface(config) {
  13790. return this.each(function () {
  13791. const data = Alert.getOrCreateInstance(this);
  13792. if (typeof config !== 'string') {
  13793. return;
  13794. }
  13795. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  13796. throw new TypeError(`No method named "${config}"`);
  13797. }
  13798. data[config](this);
  13799. });
  13800. }
  13801. }
  13802. /**
  13803. * Data API implementation
  13804. */
  13805. enableDismissTrigger(Alert, 'close');
  13806. /**
  13807. * jQuery
  13808. */
  13809. defineJQueryPlugin(Alert);
  13810. /**
  13811. * --------------------------------------------------------------------------
  13812. * Bootstrap (v5.2.3): button.js
  13813. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13814. * --------------------------------------------------------------------------
  13815. */
  13816. /**
  13817. * Constants
  13818. */
  13819. const NAME$e = 'button';
  13820. const DATA_KEY$9 = 'bs.button';
  13821. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  13822. const DATA_API_KEY$6 = '.data-api';
  13823. const CLASS_NAME_ACTIVE$3 = 'active';
  13824. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  13825. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  13826. /**
  13827. * Class definition
  13828. */
  13829. class Button extends BaseComponent {
  13830. // Getters
  13831. static get NAME() {
  13832. return NAME$e;
  13833. } // Public
  13834. toggle() {
  13835. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  13836. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  13837. } // Static
  13838. static jQueryInterface(config) {
  13839. return this.each(function () {
  13840. const data = Button.getOrCreateInstance(this);
  13841. if (config === 'toggle') {
  13842. data[config]();
  13843. }
  13844. });
  13845. }
  13846. }
  13847. /**
  13848. * Data API implementation
  13849. */
  13850. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  13851. event.preventDefault();
  13852. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  13853. const data = Button.getOrCreateInstance(button);
  13854. data.toggle();
  13855. });
  13856. /**
  13857. * jQuery
  13858. */
  13859. defineJQueryPlugin(Button);
  13860. /**
  13861. * --------------------------------------------------------------------------
  13862. * Bootstrap (v5.2.3): dom/selector-engine.js
  13863. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13864. * --------------------------------------------------------------------------
  13865. */
  13866. /**
  13867. * Constants
  13868. */
  13869. const SelectorEngine = {
  13870. find(selector, element = document.documentElement) {
  13871. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  13872. },
  13873. findOne(selector, element = document.documentElement) {
  13874. return Element.prototype.querySelector.call(element, selector);
  13875. },
  13876. children(element, selector) {
  13877. return [].concat(...element.children).filter(child => child.matches(selector));
  13878. },
  13879. parents(element, selector) {
  13880. const parents = [];
  13881. let ancestor = element.parentNode.closest(selector);
  13882. while (ancestor) {
  13883. parents.push(ancestor);
  13884. ancestor = ancestor.parentNode.closest(selector);
  13885. }
  13886. return parents;
  13887. },
  13888. prev(element, selector) {
  13889. let previous = element.previousElementSibling;
  13890. while (previous) {
  13891. if (previous.matches(selector)) {
  13892. return [previous];
  13893. }
  13894. previous = previous.previousElementSibling;
  13895. }
  13896. return [];
  13897. },
  13898. // TODO: this is now unused; remove later along with prev()
  13899. next(element, selector) {
  13900. let next = element.nextElementSibling;
  13901. while (next) {
  13902. if (next.matches(selector)) {
  13903. return [next];
  13904. }
  13905. next = next.nextElementSibling;
  13906. }
  13907. return [];
  13908. },
  13909. focusableChildren(element) {
  13910. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  13911. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  13912. }
  13913. };
  13914. /**
  13915. * --------------------------------------------------------------------------
  13916. * Bootstrap (v5.2.3): util/swipe.js
  13917. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  13918. * --------------------------------------------------------------------------
  13919. */
  13920. /**
  13921. * Constants
  13922. */
  13923. const NAME$d = 'swipe';
  13924. const EVENT_KEY$9 = '.bs.swipe';
  13925. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  13926. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  13927. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  13928. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  13929. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  13930. const POINTER_TYPE_TOUCH = 'touch';
  13931. const POINTER_TYPE_PEN = 'pen';
  13932. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  13933. const SWIPE_THRESHOLD = 40;
  13934. const Default$c = {
  13935. endCallback: null,
  13936. leftCallback: null,
  13937. rightCallback: null
  13938. };
  13939. const DefaultType$c = {
  13940. endCallback: '(function|null)',
  13941. leftCallback: '(function|null)',
  13942. rightCallback: '(function|null)'
  13943. };
  13944. /**
  13945. * Class definition
  13946. */
  13947. class Swipe extends Config {
  13948. constructor(element, config) {
  13949. super();
  13950. this._element = element;
  13951. if (!element || !Swipe.isSupported()) {
  13952. return;
  13953. }
  13954. this._config = this._getConfig(config);
  13955. this._deltaX = 0;
  13956. this._supportPointerEvents = Boolean(window.PointerEvent);
  13957. this._initEvents();
  13958. } // Getters
  13959. static get Default() {
  13960. return Default$c;
  13961. }
  13962. static get DefaultType() {
  13963. return DefaultType$c;
  13964. }
  13965. static get NAME() {
  13966. return NAME$d;
  13967. } // Public
  13968. dispose() {
  13969. EventHandler.off(this._element, EVENT_KEY$9);
  13970. } // Private
  13971. _start(event) {
  13972. if (!this._supportPointerEvents) {
  13973. this._deltaX = event.touches[0].clientX;
  13974. return;
  13975. }
  13976. if (this._eventIsPointerPenTouch(event)) {
  13977. this._deltaX = event.clientX;
  13978. }
  13979. }
  13980. _end(event) {
  13981. if (this._eventIsPointerPenTouch(event)) {
  13982. this._deltaX = event.clientX - this._deltaX;
  13983. }
  13984. this._handleSwipe();
  13985. execute(this._config.endCallback);
  13986. }
  13987. _move(event) {
  13988. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  13989. }
  13990. _handleSwipe() {
  13991. const absDeltaX = Math.abs(this._deltaX);
  13992. if (absDeltaX <= SWIPE_THRESHOLD) {
  13993. return;
  13994. }
  13995. const direction = absDeltaX / this._deltaX;
  13996. this._deltaX = 0;
  13997. if (!direction) {
  13998. return;
  13999. }
  14000. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  14001. }
  14002. _initEvents() {
  14003. if (this._supportPointerEvents) {
  14004. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  14005. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  14006. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  14007. } else {
  14008. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  14009. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  14010. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  14011. }
  14012. }
  14013. _eventIsPointerPenTouch(event) {
  14014. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  14015. } // Static
  14016. static isSupported() {
  14017. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  14018. }
  14019. }
  14020. /**
  14021. * --------------------------------------------------------------------------
  14022. * Bootstrap (v5.2.3): carousel.js
  14023. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  14024. * --------------------------------------------------------------------------
  14025. */
  14026. /**
  14027. * Constants
  14028. */
  14029. const NAME$c = 'carousel';
  14030. const DATA_KEY$8 = 'bs.carousel';
  14031. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  14032. const DATA_API_KEY$5 = '.data-api';
  14033. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  14034. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  14035. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  14036. const ORDER_NEXT = 'next';
  14037. const ORDER_PREV = 'prev';
  14038. const DIRECTION_LEFT = 'left';
  14039. const DIRECTION_RIGHT = 'right';
  14040. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  14041. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  14042. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  14043. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  14044. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  14045. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  14046. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  14047. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  14048. const CLASS_NAME_CAROUSEL = 'carousel';
  14049. const CLASS_NAME_ACTIVE$2 = 'active';
  14050. const CLASS_NAME_SLIDE = 'slide';
  14051. const CLASS_NAME_END = 'carousel-item-end';
  14052. const CLASS_NAME_START = 'carousel-item-start';
  14053. const CLASS_NAME_NEXT = 'carousel-item-next';
  14054. const CLASS_NAME_PREV = 'carousel-item-prev';
  14055. const SELECTOR_ACTIVE = '.active';
  14056. const SELECTOR_ITEM = '.carousel-item';
  14057. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  14058. const SELECTOR_ITEM_IMG = '.carousel-item img';
  14059. const SELECTOR_INDICATORS = '.carousel-indicators';
  14060. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  14061. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  14062. const KEY_TO_DIRECTION = {
  14063. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  14064. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  14065. };
  14066. const Default$b = {
  14067. interval: 5000,
  14068. keyboard: true,
  14069. pause: 'hover',
  14070. ride: false,
  14071. touch: true,
  14072. wrap: true
  14073. };
  14074. const DefaultType$b = {
  14075. interval: '(number|boolean)',
  14076. // TODO:v6 remove boolean support
  14077. keyboard: 'boolean',
  14078. pause: '(string|boolean)',
  14079. ride: '(boolean|string)',
  14080. touch: 'boolean',
  14081. wrap: 'boolean'
  14082. };
  14083. /**
  14084. * Class definition
  14085. */
  14086. class Carousel extends BaseComponent {
  14087. constructor(element, config) {
  14088. super(element, config);
  14089. this._interval = null;
  14090. this._activeElement = null;
  14091. this._isSliding = false;
  14092. this.touchTimeout = null;
  14093. this._swipeHelper = null;
  14094. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  14095. this._addEventListeners();
  14096. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  14097. this.cycle();
  14098. }
  14099. } // Getters
  14100. static get Default() {
  14101. return Default$b;
  14102. }
  14103. static get DefaultType() {
  14104. return DefaultType$b;
  14105. }
  14106. static get NAME() {
  14107. return NAME$c;
  14108. } // Public
  14109. next() {
  14110. this._slide(ORDER_NEXT);
  14111. }
  14112. nextWhenVisible() {
  14113. // FIXME TODO use `document.visibilityState`
  14114. // Don't call next when the page isn't visible
  14115. // or the carousel or its parent isn't visible
  14116. if (!document.hidden && isVisible(this._element)) {
  14117. this.next();
  14118. }
  14119. }
  14120. prev() {
  14121. this._slide(ORDER_PREV);
  14122. }
  14123. pause() {
  14124. if (this._isSliding) {
  14125. triggerTransitionEnd(this._element);
  14126. }
  14127. this._clearInterval();
  14128. }
  14129. cycle() {
  14130. this._clearInterval();
  14131. this._updateInterval();
  14132. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  14133. }
  14134. _maybeEnableCycle() {
  14135. if (!this._config.ride) {
  14136. return;
  14137. }
  14138. if (this._isSliding) {
  14139. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  14140. return;
  14141. }
  14142. this.cycle();
  14143. }
  14144. to(index) {
  14145. const items = this._getItems();
  14146. if (index > items.length - 1 || index < 0) {
  14147. return;
  14148. }
  14149. if (this._isSliding) {
  14150. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  14151. return;
  14152. }
  14153. const activeIndex = this._getItemIndex(this._getActive());
  14154. if (activeIndex === index) {
  14155. return;
  14156. }
  14157. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  14158. this._slide(order, items[index]);
  14159. }
  14160. dispose() {
  14161. if (this._swipeHelper) {
  14162. this._swipeHelper.dispose();
  14163. }
  14164. super.dispose();
  14165. } // Private
  14166. _configAfterMerge(config) {
  14167. config.defaultInterval = config.interval;
  14168. return config;
  14169. }
  14170. _addEventListeners() {
  14171. if (this._config.keyboard) {
  14172. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  14173. }
  14174. if (this._config.pause === 'hover') {
  14175. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  14176. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  14177. }
  14178. if (this._config.touch && Swipe.isSupported()) {
  14179. this._addTouchEventListeners();
  14180. }
  14181. }
  14182. _addTouchEventListeners() {
  14183. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  14184. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  14185. }
  14186. const endCallBack = () => {
  14187. if (this._config.pause !== 'hover') {
  14188. return;
  14189. } // If it's a touch-enabled device, mouseenter/leave are fired as
  14190. // part of the mouse compatibility events on first tap - the carousel
  14191. // would stop cycling until user tapped out of it;
  14192. // here, we listen for touchend, explicitly pause the carousel
  14193. // (as if it's the second time we tap on it, mouseenter compat event
  14194. // is NOT fired) and after a timeout (to allow for mouse compatibility
  14195. // events to fire) we explicitly restart cycling
  14196. this.pause();
  14197. if (this.touchTimeout) {
  14198. clearTimeout(this.touchTimeout);
  14199. }
  14200. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  14201. };
  14202. const swipeConfig = {
  14203. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  14204. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  14205. endCallback: endCallBack
  14206. };
  14207. this._swipeHelper = new Swipe(this._element, swipeConfig);
  14208. }
  14209. _keydown(event) {
  14210. if (/input|textarea/i.test(event.target.tagName)) {
  14211. return;
  14212. }
  14213. const direction = KEY_TO_DIRECTION[event.key];
  14214. if (direction) {
  14215. event.preventDefault();
  14216. this._slide(this._directionToOrder(direction));
  14217. }
  14218. }
  14219. _getItemIndex(element) {
  14220. return this._getItems().indexOf(element);
  14221. }
  14222. _setActiveIndicatorElement(index) {
  14223. if (!this._indicatorsElement) {
  14224. return;
  14225. }
  14226. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  14227. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  14228. activeIndicator.removeAttribute('aria-current');
  14229. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  14230. if (newActiveIndicator) {
  14231. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  14232. newActiveIndicator.setAttribute('aria-current', 'true');
  14233. }
  14234. }
  14235. _updateInterval() {
  14236. const element = this._activeElement || this._getActive();
  14237. if (!element) {
  14238. return;
  14239. }
  14240. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  14241. this._config.interval = elementInterval || this._config.defaultInterval;
  14242. }
  14243. _slide(order, element = null) {
  14244. if (this._isSliding) {
  14245. return;
  14246. }
  14247. const activeElement = this._getActive();
  14248. const isNext = order === ORDER_NEXT;
  14249. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  14250. if (nextElement === activeElement) {
  14251. return;
  14252. }
  14253. const nextElementIndex = this._getItemIndex(nextElement);
  14254. const triggerEvent = eventName => {
  14255. return EventHandler.trigger(this._element, eventName, {
  14256. relatedTarget: nextElement,
  14257. direction: this._orderToDirection(order),
  14258. from: this._getItemIndex(activeElement),
  14259. to: nextElementIndex
  14260. });
  14261. };
  14262. const slideEvent = triggerEvent(EVENT_SLIDE);
  14263. if (slideEvent.defaultPrevented) {
  14264. return;
  14265. }
  14266. if (!activeElement || !nextElement) {
  14267. // Some weirdness is happening, so we bail
  14268. // todo: change tests that use empty divs to avoid this check
  14269. return;
  14270. }
  14271. const isCycling = Boolean(this._interval);
  14272. this.pause();
  14273. this._isSliding = true;
  14274. this._setActiveIndicatorElement(nextElementIndex);
  14275. this._activeElement = nextElement;
  14276. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  14277. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  14278. nextElement.classList.add(orderClassName);
  14279. reflow(nextElement);
  14280. activeElement.classList.add(directionalClassName);
  14281. nextElement.classList.add(directionalClassName);
  14282. const completeCallBack = () => {
  14283. nextElement.classList.remove(directionalClassName, orderClassName);
  14284. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  14285. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  14286. this._isSliding = false;
  14287. triggerEvent(EVENT_SLID);
  14288. };
  14289. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  14290. if (isCycling) {
  14291. this.cycle();
  14292. }
  14293. }
  14294. _isAnimated() {
  14295. return this._element.classList.contains(CLASS_NAME_SLIDE);
  14296. }
  14297. _getActive() {
  14298. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  14299. }
  14300. _getItems() {
  14301. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  14302. }
  14303. _clearInterval() {
  14304. if (this._interval) {
  14305. clearInterval(this._interval);
  14306. this._interval = null;
  14307. }
  14308. }
  14309. _directionToOrder(direction) {
  14310. if (isRTL()) {
  14311. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  14312. }
  14313. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  14314. }
  14315. _orderToDirection(order) {
  14316. if (isRTL()) {
  14317. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  14318. }
  14319. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  14320. } // Static
  14321. static jQueryInterface(config) {
  14322. return this.each(function () {
  14323. const data = Carousel.getOrCreateInstance(this, config);
  14324. if (typeof config === 'number') {
  14325. data.to(config);
  14326. return;
  14327. }
  14328. if (typeof config === 'string') {
  14329. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  14330. throw new TypeError(`No method named "${config}"`);
  14331. }
  14332. data[config]();
  14333. }
  14334. });
  14335. }
  14336. }
  14337. /**
  14338. * Data API implementation
  14339. */
  14340. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  14341. const target = getElementFromSelector(this);
  14342. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  14343. return;
  14344. }
  14345. event.preventDefault();
  14346. const carousel = Carousel.getOrCreateInstance(target);
  14347. const slideIndex = this.getAttribute('data-bs-slide-to');
  14348. if (slideIndex) {
  14349. carousel.to(slideIndex);
  14350. carousel._maybeEnableCycle();
  14351. return;
  14352. }
  14353. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  14354. carousel.next();
  14355. carousel._maybeEnableCycle();
  14356. return;
  14357. }
  14358. carousel.prev();
  14359. carousel._maybeEnableCycle();
  14360. });
  14361. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  14362. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  14363. for (const carousel of carousels) {
  14364. Carousel.getOrCreateInstance(carousel);
  14365. }
  14366. });
  14367. /**
  14368. * jQuery
  14369. */
  14370. defineJQueryPlugin(Carousel);
  14371. /**
  14372. * --------------------------------------------------------------------------
  14373. * Bootstrap (v5.2.3): collapse.js
  14374. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  14375. * --------------------------------------------------------------------------
  14376. */
  14377. /**
  14378. * Constants
  14379. */
  14380. const NAME$b = 'collapse';
  14381. const DATA_KEY$7 = 'bs.collapse';
  14382. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  14383. const DATA_API_KEY$4 = '.data-api';
  14384. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  14385. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  14386. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  14387. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  14388. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  14389. const CLASS_NAME_SHOW$7 = 'show';
  14390. const CLASS_NAME_COLLAPSE = 'collapse';
  14391. const CLASS_NAME_COLLAPSING = 'collapsing';
  14392. const CLASS_NAME_COLLAPSED = 'collapsed';
  14393. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  14394. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  14395. const WIDTH = 'width';
  14396. const HEIGHT = 'height';
  14397. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  14398. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  14399. const Default$a = {
  14400. parent: null,
  14401. toggle: true
  14402. };
  14403. const DefaultType$a = {
  14404. parent: '(null|element)',
  14405. toggle: 'boolean'
  14406. };
  14407. /**
  14408. * Class definition
  14409. */
  14410. class Collapse extends BaseComponent {
  14411. constructor(element, config) {
  14412. super(element, config);
  14413. this._isTransitioning = false;
  14414. this._triggerArray = [];
  14415. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  14416. for (const elem of toggleList) {
  14417. const selector = getSelectorFromElement(elem);
  14418. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  14419. if (selector !== null && filterElement.length) {
  14420. this._triggerArray.push(elem);
  14421. }
  14422. }
  14423. this._initializeChildren();
  14424. if (!this._config.parent) {
  14425. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  14426. }
  14427. if (this._config.toggle) {
  14428. this.toggle();
  14429. }
  14430. } // Getters
  14431. static get Default() {
  14432. return Default$a;
  14433. }
  14434. static get DefaultType() {
  14435. return DefaultType$a;
  14436. }
  14437. static get NAME() {
  14438. return NAME$b;
  14439. } // Public
  14440. toggle() {
  14441. if (this._isShown()) {
  14442. this.hide();
  14443. } else {
  14444. this.show();
  14445. }
  14446. }
  14447. show() {
  14448. if (this._isTransitioning || this._isShown()) {
  14449. return;
  14450. }
  14451. let activeChildren = []; // find active children
  14452. if (this._config.parent) {
  14453. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  14454. toggle: false
  14455. }));
  14456. }
  14457. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  14458. return;
  14459. }
  14460. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  14461. if (startEvent.defaultPrevented) {
  14462. return;
  14463. }
  14464. for (const activeInstance of activeChildren) {
  14465. activeInstance.hide();
  14466. }
  14467. const dimension = this._getDimension();
  14468. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  14469. this._element.classList.add(CLASS_NAME_COLLAPSING);
  14470. this._element.style[dimension] = 0;
  14471. this._addAriaAndCollapsedClass(this._triggerArray, true);
  14472. this._isTransitioning = true;
  14473. const complete = () => {
  14474. this._isTransitioning = false;
  14475. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  14476. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  14477. this._element.style[dimension] = '';
  14478. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  14479. };
  14480. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  14481. const scrollSize = `scroll${capitalizedDimension}`;
  14482. this._queueCallback(complete, this._element, true);
  14483. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  14484. }
  14485. hide() {
  14486. if (this._isTransitioning || !this._isShown()) {
  14487. return;
  14488. }
  14489. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  14490. if (startEvent.defaultPrevented) {
  14491. return;
  14492. }
  14493. const dimension = this._getDimension();
  14494. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  14495. reflow(this._element);
  14496. this._element.classList.add(CLASS_NAME_COLLAPSING);
  14497. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  14498. for (const trigger of this._triggerArray) {
  14499. const element = getElementFromSelector(trigger);
  14500. if (element && !this._isShown(element)) {
  14501. this._addAriaAndCollapsedClass([trigger], false);
  14502. }
  14503. }
  14504. this._isTransitioning = true;
  14505. const complete = () => {
  14506. this._isTransitioning = false;
  14507. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  14508. this._element.classList.add(CLASS_NAME_COLLAPSE);
  14509. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  14510. };
  14511. this._element.style[dimension] = '';
  14512. this._queueCallback(complete, this._element, true);
  14513. }
  14514. _isShown(element = this._element) {
  14515. return element.classList.contains(CLASS_NAME_SHOW$7);
  14516. } // Private
  14517. _configAfterMerge(config) {
  14518. config.toggle = Boolean(config.toggle); // Coerce string values
  14519. config.parent = getElement(config.parent);
  14520. return config;
  14521. }
  14522. _getDimension() {
  14523. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  14524. }
  14525. _initializeChildren() {
  14526. if (!this._config.parent) {
  14527. return;
  14528. }
  14529. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  14530. for (const element of children) {
  14531. const selected = getElementFromSelector(element);
  14532. if (selected) {
  14533. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  14534. }
  14535. }
  14536. }
  14537. _getFirstLevelChildren(selector) {
  14538. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); // remove children if greater depth
  14539. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  14540. }
  14541. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  14542. if (!triggerArray.length) {
  14543. return;
  14544. }
  14545. for (const element of triggerArray) {
  14546. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  14547. element.setAttribute('aria-expanded', isOpen);
  14548. }
  14549. } // Static
  14550. static jQueryInterface(config) {
  14551. const _config = {};
  14552. if (typeof config === 'string' && /show|hide/.test(config)) {
  14553. _config.toggle = false;
  14554. }
  14555. return this.each(function () {
  14556. const data = Collapse.getOrCreateInstance(this, _config);
  14557. if (typeof config === 'string') {
  14558. if (typeof data[config] === 'undefined') {
  14559. throw new TypeError(`No method named "${config}"`);
  14560. }
  14561. data[config]();
  14562. }
  14563. });
  14564. }
  14565. }
  14566. /**
  14567. * Data API implementation
  14568. */
  14569. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  14570. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  14571. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  14572. event.preventDefault();
  14573. }
  14574. const selector = getSelectorFromElement(this);
  14575. const selectorElements = SelectorEngine.find(selector);
  14576. for (const element of selectorElements) {
  14577. Collapse.getOrCreateInstance(element, {
  14578. toggle: false
  14579. }).toggle();
  14580. }
  14581. });
  14582. /**
  14583. * jQuery
  14584. */
  14585. defineJQueryPlugin(Collapse);
  14586. /**
  14587. * --------------------------------------------------------------------------
  14588. * Bootstrap (v5.2.3): dropdown.js
  14589. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  14590. * --------------------------------------------------------------------------
  14591. */
  14592. /**
  14593. * Constants
  14594. */
  14595. const NAME$a = 'dropdown';
  14596. const DATA_KEY$6 = 'bs.dropdown';
  14597. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  14598. const DATA_API_KEY$3 = '.data-api';
  14599. const ESCAPE_KEY$2 = 'Escape';
  14600. const TAB_KEY$1 = 'Tab';
  14601. const ARROW_UP_KEY$1 = 'ArrowUp';
  14602. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  14603. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  14604. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  14605. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  14606. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  14607. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  14608. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  14609. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  14610. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  14611. const CLASS_NAME_SHOW$6 = 'show';
  14612. const CLASS_NAME_DROPUP = 'dropup';
  14613. const CLASS_NAME_DROPEND = 'dropend';
  14614. const CLASS_NAME_DROPSTART = 'dropstart';
  14615. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  14616. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  14617. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  14618. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  14619. const SELECTOR_MENU = '.dropdown-menu';
  14620. const SELECTOR_NAVBAR = '.navbar';
  14621. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  14622. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  14623. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  14624. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  14625. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  14626. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  14627. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  14628. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  14629. const PLACEMENT_TOPCENTER = 'top';
  14630. const PLACEMENT_BOTTOMCENTER = 'bottom';
  14631. const Default$9 = {
  14632. autoClose: true,
  14633. boundary: 'clippingParents',
  14634. display: 'dynamic',
  14635. offset: [0, 2],
  14636. popperConfig: null,
  14637. reference: 'toggle'
  14638. };
  14639. const DefaultType$9 = {
  14640. autoClose: '(boolean|string)',
  14641. boundary: '(string|element)',
  14642. display: 'string',
  14643. offset: '(array|string|function)',
  14644. popperConfig: '(null|object|function)',
  14645. reference: '(string|element|object)'
  14646. };
  14647. /**
  14648. * Class definition
  14649. */
  14650. class Dropdown extends BaseComponent {
  14651. constructor(element, config) {
  14652. super(element, config);
  14653. this._popper = null;
  14654. this._parent = this._element.parentNode; // dropdown wrapper
  14655. // todo: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.2/forms/input-group/
  14656. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  14657. this._inNavbar = this._detectNavbar();
  14658. } // Getters
  14659. static get Default() {
  14660. return Default$9;
  14661. }
  14662. static get DefaultType() {
  14663. return DefaultType$9;
  14664. }
  14665. static get NAME() {
  14666. return NAME$a;
  14667. } // Public
  14668. toggle() {
  14669. return this._isShown() ? this.hide() : this.show();
  14670. }
  14671. show() {
  14672. if (isDisabled(this._element) || this._isShown()) {
  14673. return;
  14674. }
  14675. const relatedTarget = {
  14676. relatedTarget: this._element
  14677. };
  14678. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  14679. if (showEvent.defaultPrevented) {
  14680. return;
  14681. }
  14682. this._createPopper(); // If this is a touch-enabled device we add extra
  14683. // empty mouseover listeners to the body's immediate children;
  14684. // only needed because of broken event delegation on iOS
  14685. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  14686. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  14687. for (const element of [].concat(...document.body.children)) {
  14688. EventHandler.on(element, 'mouseover', noop);
  14689. }
  14690. }
  14691. this._element.focus();
  14692. this._element.setAttribute('aria-expanded', true);
  14693. this._menu.classList.add(CLASS_NAME_SHOW$6);
  14694. this._element.classList.add(CLASS_NAME_SHOW$6);
  14695. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  14696. }
  14697. hide() {
  14698. if (isDisabled(this._element) || !this._isShown()) {
  14699. return;
  14700. }
  14701. const relatedTarget = {
  14702. relatedTarget: this._element
  14703. };
  14704. this._completeHide(relatedTarget);
  14705. }
  14706. dispose() {
  14707. if (this._popper) {
  14708. this._popper.destroy();
  14709. }
  14710. super.dispose();
  14711. }
  14712. update() {
  14713. this._inNavbar = this._detectNavbar();
  14714. if (this._popper) {
  14715. this._popper.update();
  14716. }
  14717. } // Private
  14718. _completeHide(relatedTarget) {
  14719. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  14720. if (hideEvent.defaultPrevented) {
  14721. return;
  14722. } // If this is a touch-enabled device we remove the extra
  14723. // empty mouseover listeners we added for iOS support
  14724. if ('ontouchstart' in document.documentElement) {
  14725. for (const element of [].concat(...document.body.children)) {
  14726. EventHandler.off(element, 'mouseover', noop);
  14727. }
  14728. }
  14729. if (this._popper) {
  14730. this._popper.destroy();
  14731. }
  14732. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  14733. this._element.classList.remove(CLASS_NAME_SHOW$6);
  14734. this._element.setAttribute('aria-expanded', 'false');
  14735. Manipulator.removeDataAttribute(this._menu, 'popper');
  14736. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  14737. }
  14738. _getConfig(config) {
  14739. config = super._getConfig(config);
  14740. if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  14741. // Popper virtual elements require a getBoundingClientRect method
  14742. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  14743. }
  14744. return config;
  14745. }
  14746. _createPopper() {
  14747. if (typeof _popperjs_core__WEBPACK_IMPORTED_MODULE_0__ === 'undefined') {
  14748. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  14749. }
  14750. let referenceElement = this._element;
  14751. if (this._config.reference === 'parent') {
  14752. referenceElement = this._parent;
  14753. } else if (isElement(this._config.reference)) {
  14754. referenceElement = getElement(this._config.reference);
  14755. } else if (typeof this._config.reference === 'object') {
  14756. referenceElement = this._config.reference;
  14757. }
  14758. const popperConfig = this._getPopperConfig();
  14759. this._popper = _popperjs_core__WEBPACK_IMPORTED_MODULE_1__.createPopper(referenceElement, this._menu, popperConfig);
  14760. }
  14761. _isShown() {
  14762. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  14763. }
  14764. _getPlacement() {
  14765. const parentDropdown = this._parent;
  14766. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  14767. return PLACEMENT_RIGHT;
  14768. }
  14769. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  14770. return PLACEMENT_LEFT;
  14771. }
  14772. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  14773. return PLACEMENT_TOPCENTER;
  14774. }
  14775. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  14776. return PLACEMENT_BOTTOMCENTER;
  14777. } // We need to trim the value because custom properties can also include spaces
  14778. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  14779. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  14780. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  14781. }
  14782. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  14783. }
  14784. _detectNavbar() {
  14785. return this._element.closest(SELECTOR_NAVBAR) !== null;
  14786. }
  14787. _getOffset() {
  14788. const {
  14789. offset
  14790. } = this._config;
  14791. if (typeof offset === 'string') {
  14792. return offset.split(',').map(value => Number.parseInt(value, 10));
  14793. }
  14794. if (typeof offset === 'function') {
  14795. return popperData => offset(popperData, this._element);
  14796. }
  14797. return offset;
  14798. }
  14799. _getPopperConfig() {
  14800. const defaultBsPopperConfig = {
  14801. placement: this._getPlacement(),
  14802. modifiers: [{
  14803. name: 'preventOverflow',
  14804. options: {
  14805. boundary: this._config.boundary
  14806. }
  14807. }, {
  14808. name: 'offset',
  14809. options: {
  14810. offset: this._getOffset()
  14811. }
  14812. }]
  14813. }; // Disable Popper if we have a static display or Dropdown is in Navbar
  14814. if (this._inNavbar || this._config.display === 'static') {
  14815. Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // todo:v6 remove
  14816. defaultBsPopperConfig.modifiers = [{
  14817. name: 'applyStyles',
  14818. enabled: false
  14819. }];
  14820. }
  14821. return { ...defaultBsPopperConfig,
  14822. ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
  14823. };
  14824. }
  14825. _selectMenuItem({
  14826. key,
  14827. target
  14828. }) {
  14829. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  14830. if (!items.length) {
  14831. return;
  14832. } // if target isn't included in items (e.g. when expanding the dropdown)
  14833. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  14834. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  14835. } // Static
  14836. static jQueryInterface(config) {
  14837. return this.each(function () {
  14838. const data = Dropdown.getOrCreateInstance(this, config);
  14839. if (typeof config !== 'string') {
  14840. return;
  14841. }
  14842. if (typeof data[config] === 'undefined') {
  14843. throw new TypeError(`No method named "${config}"`);
  14844. }
  14845. data[config]();
  14846. });
  14847. }
  14848. static clearMenus(event) {
  14849. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  14850. return;
  14851. }
  14852. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  14853. for (const toggle of openToggles) {
  14854. const context = Dropdown.getInstance(toggle);
  14855. if (!context || context._config.autoClose === false) {
  14856. continue;
  14857. }
  14858. const composedPath = event.composedPath();
  14859. const isMenuTarget = composedPath.includes(context._menu);
  14860. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  14861. continue;
  14862. } // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  14863. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  14864. continue;
  14865. }
  14866. const relatedTarget = {
  14867. relatedTarget: context._element
  14868. };
  14869. if (event.type === 'click') {
  14870. relatedTarget.clickEvent = event;
  14871. }
  14872. context._completeHide(relatedTarget);
  14873. }
  14874. }
  14875. static dataApiKeydownHandler(event) {
  14876. // If not an UP | DOWN | ESCAPE key => not a dropdown command
  14877. // If input/textarea && if key is other than ESCAPE => not a dropdown command
  14878. const isInput = /input|textarea/i.test(event.target.tagName);
  14879. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  14880. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  14881. if (!isUpOrDownEvent && !isEscapeEvent) {
  14882. return;
  14883. }
  14884. if (isInput && !isEscapeEvent) {
  14885. return;
  14886. }
  14887. event.preventDefault(); // todo: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.2/forms/input-group/
  14888. const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3, event.delegateTarget.parentNode);
  14889. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  14890. if (isUpOrDownEvent) {
  14891. event.stopPropagation();
  14892. instance.show();
  14893. instance._selectMenuItem(event);
  14894. return;
  14895. }
  14896. if (instance._isShown()) {
  14897. // else is escape and we check if it is shown
  14898. event.stopPropagation();
  14899. instance.hide();
  14900. getToggleButton.focus();
  14901. }
  14902. }
  14903. }
  14904. /**
  14905. * Data API implementation
  14906. */
  14907. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  14908. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  14909. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  14910. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  14911. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  14912. event.preventDefault();
  14913. Dropdown.getOrCreateInstance(this).toggle();
  14914. });
  14915. /**
  14916. * jQuery
  14917. */
  14918. defineJQueryPlugin(Dropdown);
  14919. /**
  14920. * --------------------------------------------------------------------------
  14921. * Bootstrap (v5.2.3): util/scrollBar.js
  14922. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  14923. * --------------------------------------------------------------------------
  14924. */
  14925. /**
  14926. * Constants
  14927. */
  14928. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  14929. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  14930. const PROPERTY_PADDING = 'padding-right';
  14931. const PROPERTY_MARGIN = 'margin-right';
  14932. /**
  14933. * Class definition
  14934. */
  14935. class ScrollBarHelper {
  14936. constructor() {
  14937. this._element = document.body;
  14938. } // Public
  14939. getWidth() {
  14940. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  14941. const documentWidth = document.documentElement.clientWidth;
  14942. return Math.abs(window.innerWidth - documentWidth);
  14943. }
  14944. hide() {
  14945. const width = this.getWidth();
  14946. this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width
  14947. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  14948. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  14949. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  14950. }
  14951. reset() {
  14952. this._resetElementAttributes(this._element, 'overflow');
  14953. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  14954. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  14955. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  14956. }
  14957. isOverflowing() {
  14958. return this.getWidth() > 0;
  14959. } // Private
  14960. _disableOverFlow() {
  14961. this._saveInitialAttribute(this._element, 'overflow');
  14962. this._element.style.overflow = 'hidden';
  14963. }
  14964. _setElementAttributes(selector, styleProperty, callback) {
  14965. const scrollbarWidth = this.getWidth();
  14966. const manipulationCallBack = element => {
  14967. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  14968. return;
  14969. }
  14970. this._saveInitialAttribute(element, styleProperty);
  14971. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  14972. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  14973. };
  14974. this._applyManipulationCallback(selector, manipulationCallBack);
  14975. }
  14976. _saveInitialAttribute(element, styleProperty) {
  14977. const actualValue = element.style.getPropertyValue(styleProperty);
  14978. if (actualValue) {
  14979. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  14980. }
  14981. }
  14982. _resetElementAttributes(selector, styleProperty) {
  14983. const manipulationCallBack = element => {
  14984. const value = Manipulator.getDataAttribute(element, styleProperty); // We only want to remove the property if the value is `null`; the value can also be zero
  14985. if (value === null) {
  14986. element.style.removeProperty(styleProperty);
  14987. return;
  14988. }
  14989. Manipulator.removeDataAttribute(element, styleProperty);
  14990. element.style.setProperty(styleProperty, value);
  14991. };
  14992. this._applyManipulationCallback(selector, manipulationCallBack);
  14993. }
  14994. _applyManipulationCallback(selector, callBack) {
  14995. if (isElement(selector)) {
  14996. callBack(selector);
  14997. return;
  14998. }
  14999. for (const sel of SelectorEngine.find(selector, this._element)) {
  15000. callBack(sel);
  15001. }
  15002. }
  15003. }
  15004. /**
  15005. * --------------------------------------------------------------------------
  15006. * Bootstrap (v5.2.3): util/backdrop.js
  15007. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15008. * --------------------------------------------------------------------------
  15009. */
  15010. /**
  15011. * Constants
  15012. */
  15013. const NAME$9 = 'backdrop';
  15014. const CLASS_NAME_FADE$4 = 'fade';
  15015. const CLASS_NAME_SHOW$5 = 'show';
  15016. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  15017. const Default$8 = {
  15018. className: 'modal-backdrop',
  15019. clickCallback: null,
  15020. isAnimated: false,
  15021. isVisible: true,
  15022. // if false, we use the backdrop helper without adding any element to the dom
  15023. rootElement: 'body' // give the choice to place backdrop under different elements
  15024. };
  15025. const DefaultType$8 = {
  15026. className: 'string',
  15027. clickCallback: '(function|null)',
  15028. isAnimated: 'boolean',
  15029. isVisible: 'boolean',
  15030. rootElement: '(element|string)'
  15031. };
  15032. /**
  15033. * Class definition
  15034. */
  15035. class Backdrop extends Config {
  15036. constructor(config) {
  15037. super();
  15038. this._config = this._getConfig(config);
  15039. this._isAppended = false;
  15040. this._element = null;
  15041. } // Getters
  15042. static get Default() {
  15043. return Default$8;
  15044. }
  15045. static get DefaultType() {
  15046. return DefaultType$8;
  15047. }
  15048. static get NAME() {
  15049. return NAME$9;
  15050. } // Public
  15051. show(callback) {
  15052. if (!this._config.isVisible) {
  15053. execute(callback);
  15054. return;
  15055. }
  15056. this._append();
  15057. const element = this._getElement();
  15058. if (this._config.isAnimated) {
  15059. reflow(element);
  15060. }
  15061. element.classList.add(CLASS_NAME_SHOW$5);
  15062. this._emulateAnimation(() => {
  15063. execute(callback);
  15064. });
  15065. }
  15066. hide(callback) {
  15067. if (!this._config.isVisible) {
  15068. execute(callback);
  15069. return;
  15070. }
  15071. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  15072. this._emulateAnimation(() => {
  15073. this.dispose();
  15074. execute(callback);
  15075. });
  15076. }
  15077. dispose() {
  15078. if (!this._isAppended) {
  15079. return;
  15080. }
  15081. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  15082. this._element.remove();
  15083. this._isAppended = false;
  15084. } // Private
  15085. _getElement() {
  15086. if (!this._element) {
  15087. const backdrop = document.createElement('div');
  15088. backdrop.className = this._config.className;
  15089. if (this._config.isAnimated) {
  15090. backdrop.classList.add(CLASS_NAME_FADE$4);
  15091. }
  15092. this._element = backdrop;
  15093. }
  15094. return this._element;
  15095. }
  15096. _configAfterMerge(config) {
  15097. // use getElement() with the default "body" to get a fresh Element on each instantiation
  15098. config.rootElement = getElement(config.rootElement);
  15099. return config;
  15100. }
  15101. _append() {
  15102. if (this._isAppended) {
  15103. return;
  15104. }
  15105. const element = this._getElement();
  15106. this._config.rootElement.append(element);
  15107. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  15108. execute(this._config.clickCallback);
  15109. });
  15110. this._isAppended = true;
  15111. }
  15112. _emulateAnimation(callback) {
  15113. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  15114. }
  15115. }
  15116. /**
  15117. * --------------------------------------------------------------------------
  15118. * Bootstrap (v5.2.3): util/focustrap.js
  15119. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15120. * --------------------------------------------------------------------------
  15121. */
  15122. /**
  15123. * Constants
  15124. */
  15125. const NAME$8 = 'focustrap';
  15126. const DATA_KEY$5 = 'bs.focustrap';
  15127. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  15128. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  15129. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  15130. const TAB_KEY = 'Tab';
  15131. const TAB_NAV_FORWARD = 'forward';
  15132. const TAB_NAV_BACKWARD = 'backward';
  15133. const Default$7 = {
  15134. autofocus: true,
  15135. trapElement: null // The element to trap focus inside of
  15136. };
  15137. const DefaultType$7 = {
  15138. autofocus: 'boolean',
  15139. trapElement: 'element'
  15140. };
  15141. /**
  15142. * Class definition
  15143. */
  15144. class FocusTrap extends Config {
  15145. constructor(config) {
  15146. super();
  15147. this._config = this._getConfig(config);
  15148. this._isActive = false;
  15149. this._lastTabNavDirection = null;
  15150. } // Getters
  15151. static get Default() {
  15152. return Default$7;
  15153. }
  15154. static get DefaultType() {
  15155. return DefaultType$7;
  15156. }
  15157. static get NAME() {
  15158. return NAME$8;
  15159. } // Public
  15160. activate() {
  15161. if (this._isActive) {
  15162. return;
  15163. }
  15164. if (this._config.autofocus) {
  15165. this._config.trapElement.focus();
  15166. }
  15167. EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop
  15168. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  15169. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  15170. this._isActive = true;
  15171. }
  15172. deactivate() {
  15173. if (!this._isActive) {
  15174. return;
  15175. }
  15176. this._isActive = false;
  15177. EventHandler.off(document, EVENT_KEY$5);
  15178. } // Private
  15179. _handleFocusin(event) {
  15180. const {
  15181. trapElement
  15182. } = this._config;
  15183. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  15184. return;
  15185. }
  15186. const elements = SelectorEngine.focusableChildren(trapElement);
  15187. if (elements.length === 0) {
  15188. trapElement.focus();
  15189. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  15190. elements[elements.length - 1].focus();
  15191. } else {
  15192. elements[0].focus();
  15193. }
  15194. }
  15195. _handleKeydown(event) {
  15196. if (event.key !== TAB_KEY) {
  15197. return;
  15198. }
  15199. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  15200. }
  15201. }
  15202. /**
  15203. * --------------------------------------------------------------------------
  15204. * Bootstrap (v5.2.3): modal.js
  15205. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15206. * --------------------------------------------------------------------------
  15207. */
  15208. /**
  15209. * Constants
  15210. */
  15211. const NAME$7 = 'modal';
  15212. const DATA_KEY$4 = 'bs.modal';
  15213. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  15214. const DATA_API_KEY$2 = '.data-api';
  15215. const ESCAPE_KEY$1 = 'Escape';
  15216. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  15217. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  15218. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  15219. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  15220. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  15221. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  15222. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  15223. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  15224. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  15225. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  15226. const CLASS_NAME_OPEN = 'modal-open';
  15227. const CLASS_NAME_FADE$3 = 'fade';
  15228. const CLASS_NAME_SHOW$4 = 'show';
  15229. const CLASS_NAME_STATIC = 'modal-static';
  15230. const OPEN_SELECTOR$1 = '.modal.show';
  15231. const SELECTOR_DIALOG = '.modal-dialog';
  15232. const SELECTOR_MODAL_BODY = '.modal-body';
  15233. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  15234. const Default$6 = {
  15235. backdrop: true,
  15236. focus: true,
  15237. keyboard: true
  15238. };
  15239. const DefaultType$6 = {
  15240. backdrop: '(boolean|string)',
  15241. focus: 'boolean',
  15242. keyboard: 'boolean'
  15243. };
  15244. /**
  15245. * Class definition
  15246. */
  15247. class Modal extends BaseComponent {
  15248. constructor(element, config) {
  15249. super(element, config);
  15250. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  15251. this._backdrop = this._initializeBackDrop();
  15252. this._focustrap = this._initializeFocusTrap();
  15253. this._isShown = false;
  15254. this._isTransitioning = false;
  15255. this._scrollBar = new ScrollBarHelper();
  15256. this._addEventListeners();
  15257. } // Getters
  15258. static get Default() {
  15259. return Default$6;
  15260. }
  15261. static get DefaultType() {
  15262. return DefaultType$6;
  15263. }
  15264. static get NAME() {
  15265. return NAME$7;
  15266. } // Public
  15267. toggle(relatedTarget) {
  15268. return this._isShown ? this.hide() : this.show(relatedTarget);
  15269. }
  15270. show(relatedTarget) {
  15271. if (this._isShown || this._isTransitioning) {
  15272. return;
  15273. }
  15274. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  15275. relatedTarget
  15276. });
  15277. if (showEvent.defaultPrevented) {
  15278. return;
  15279. }
  15280. this._isShown = true;
  15281. this._isTransitioning = true;
  15282. this._scrollBar.hide();
  15283. document.body.classList.add(CLASS_NAME_OPEN);
  15284. this._adjustDialog();
  15285. this._backdrop.show(() => this._showElement(relatedTarget));
  15286. }
  15287. hide() {
  15288. if (!this._isShown || this._isTransitioning) {
  15289. return;
  15290. }
  15291. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  15292. if (hideEvent.defaultPrevented) {
  15293. return;
  15294. }
  15295. this._isShown = false;
  15296. this._isTransitioning = true;
  15297. this._focustrap.deactivate();
  15298. this._element.classList.remove(CLASS_NAME_SHOW$4);
  15299. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  15300. }
  15301. dispose() {
  15302. for (const htmlElement of [window, this._dialog]) {
  15303. EventHandler.off(htmlElement, EVENT_KEY$4);
  15304. }
  15305. this._backdrop.dispose();
  15306. this._focustrap.deactivate();
  15307. super.dispose();
  15308. }
  15309. handleUpdate() {
  15310. this._adjustDialog();
  15311. } // Private
  15312. _initializeBackDrop() {
  15313. return new Backdrop({
  15314. isVisible: Boolean(this._config.backdrop),
  15315. // 'static' option will be translated to true, and booleans will keep their value,
  15316. isAnimated: this._isAnimated()
  15317. });
  15318. }
  15319. _initializeFocusTrap() {
  15320. return new FocusTrap({
  15321. trapElement: this._element
  15322. });
  15323. }
  15324. _showElement(relatedTarget) {
  15325. // try to append dynamic modal
  15326. if (!document.body.contains(this._element)) {
  15327. document.body.append(this._element);
  15328. }
  15329. this._element.style.display = 'block';
  15330. this._element.removeAttribute('aria-hidden');
  15331. this._element.setAttribute('aria-modal', true);
  15332. this._element.setAttribute('role', 'dialog');
  15333. this._element.scrollTop = 0;
  15334. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  15335. if (modalBody) {
  15336. modalBody.scrollTop = 0;
  15337. }
  15338. reflow(this._element);
  15339. this._element.classList.add(CLASS_NAME_SHOW$4);
  15340. const transitionComplete = () => {
  15341. if (this._config.focus) {
  15342. this._focustrap.activate();
  15343. }
  15344. this._isTransitioning = false;
  15345. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  15346. relatedTarget
  15347. });
  15348. };
  15349. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  15350. }
  15351. _addEventListeners() {
  15352. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  15353. if (event.key !== ESCAPE_KEY$1) {
  15354. return;
  15355. }
  15356. if (this._config.keyboard) {
  15357. event.preventDefault();
  15358. this.hide();
  15359. return;
  15360. }
  15361. this._triggerBackdropTransition();
  15362. });
  15363. EventHandler.on(window, EVENT_RESIZE$1, () => {
  15364. if (this._isShown && !this._isTransitioning) {
  15365. this._adjustDialog();
  15366. }
  15367. });
  15368. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  15369. // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
  15370. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  15371. if (this._element !== event.target || this._element !== event2.target) {
  15372. return;
  15373. }
  15374. if (this._config.backdrop === 'static') {
  15375. this._triggerBackdropTransition();
  15376. return;
  15377. }
  15378. if (this._config.backdrop) {
  15379. this.hide();
  15380. }
  15381. });
  15382. });
  15383. }
  15384. _hideModal() {
  15385. this._element.style.display = 'none';
  15386. this._element.setAttribute('aria-hidden', true);
  15387. this._element.removeAttribute('aria-modal');
  15388. this._element.removeAttribute('role');
  15389. this._isTransitioning = false;
  15390. this._backdrop.hide(() => {
  15391. document.body.classList.remove(CLASS_NAME_OPEN);
  15392. this._resetAdjustments();
  15393. this._scrollBar.reset();
  15394. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  15395. });
  15396. }
  15397. _isAnimated() {
  15398. return this._element.classList.contains(CLASS_NAME_FADE$3);
  15399. }
  15400. _triggerBackdropTransition() {
  15401. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  15402. if (hideEvent.defaultPrevented) {
  15403. return;
  15404. }
  15405. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  15406. const initialOverflowY = this._element.style.overflowY; // return if the following background transition hasn't yet completed
  15407. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  15408. return;
  15409. }
  15410. if (!isModalOverflowing) {
  15411. this._element.style.overflowY = 'hidden';
  15412. }
  15413. this._element.classList.add(CLASS_NAME_STATIC);
  15414. this._queueCallback(() => {
  15415. this._element.classList.remove(CLASS_NAME_STATIC);
  15416. this._queueCallback(() => {
  15417. this._element.style.overflowY = initialOverflowY;
  15418. }, this._dialog);
  15419. }, this._dialog);
  15420. this._element.focus();
  15421. }
  15422. /**
  15423. * The following methods are used to handle overflowing modals
  15424. */
  15425. _adjustDialog() {
  15426. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  15427. const scrollbarWidth = this._scrollBar.getWidth();
  15428. const isBodyOverflowing = scrollbarWidth > 0;
  15429. if (isBodyOverflowing && !isModalOverflowing) {
  15430. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  15431. this._element.style[property] = `${scrollbarWidth}px`;
  15432. }
  15433. if (!isBodyOverflowing && isModalOverflowing) {
  15434. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  15435. this._element.style[property] = `${scrollbarWidth}px`;
  15436. }
  15437. }
  15438. _resetAdjustments() {
  15439. this._element.style.paddingLeft = '';
  15440. this._element.style.paddingRight = '';
  15441. } // Static
  15442. static jQueryInterface(config, relatedTarget) {
  15443. return this.each(function () {
  15444. const data = Modal.getOrCreateInstance(this, config);
  15445. if (typeof config !== 'string') {
  15446. return;
  15447. }
  15448. if (typeof data[config] === 'undefined') {
  15449. throw new TypeError(`No method named "${config}"`);
  15450. }
  15451. data[config](relatedTarget);
  15452. });
  15453. }
  15454. }
  15455. /**
  15456. * Data API implementation
  15457. */
  15458. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  15459. const target = getElementFromSelector(this);
  15460. if (['A', 'AREA'].includes(this.tagName)) {
  15461. event.preventDefault();
  15462. }
  15463. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  15464. if (showEvent.defaultPrevented) {
  15465. // only register focus restorer if modal will actually get shown
  15466. return;
  15467. }
  15468. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  15469. if (isVisible(this)) {
  15470. this.focus();
  15471. }
  15472. });
  15473. }); // avoid conflict when clicking modal toggler while another one is open
  15474. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  15475. if (alreadyOpen) {
  15476. Modal.getInstance(alreadyOpen).hide();
  15477. }
  15478. const data = Modal.getOrCreateInstance(target);
  15479. data.toggle(this);
  15480. });
  15481. enableDismissTrigger(Modal);
  15482. /**
  15483. * jQuery
  15484. */
  15485. defineJQueryPlugin(Modal);
  15486. /**
  15487. * --------------------------------------------------------------------------
  15488. * Bootstrap (v5.2.3): offcanvas.js
  15489. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15490. * --------------------------------------------------------------------------
  15491. */
  15492. /**
  15493. * Constants
  15494. */
  15495. const NAME$6 = 'offcanvas';
  15496. const DATA_KEY$3 = 'bs.offcanvas';
  15497. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  15498. const DATA_API_KEY$1 = '.data-api';
  15499. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  15500. const ESCAPE_KEY = 'Escape';
  15501. const CLASS_NAME_SHOW$3 = 'show';
  15502. const CLASS_NAME_SHOWING$1 = 'showing';
  15503. const CLASS_NAME_HIDING = 'hiding';
  15504. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  15505. const OPEN_SELECTOR = '.offcanvas.show';
  15506. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  15507. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  15508. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  15509. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  15510. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  15511. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  15512. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  15513. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  15514. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  15515. const Default$5 = {
  15516. backdrop: true,
  15517. keyboard: true,
  15518. scroll: false
  15519. };
  15520. const DefaultType$5 = {
  15521. backdrop: '(boolean|string)',
  15522. keyboard: 'boolean',
  15523. scroll: 'boolean'
  15524. };
  15525. /**
  15526. * Class definition
  15527. */
  15528. class Offcanvas extends BaseComponent {
  15529. constructor(element, config) {
  15530. super(element, config);
  15531. this._isShown = false;
  15532. this._backdrop = this._initializeBackDrop();
  15533. this._focustrap = this._initializeFocusTrap();
  15534. this._addEventListeners();
  15535. } // Getters
  15536. static get Default() {
  15537. return Default$5;
  15538. }
  15539. static get DefaultType() {
  15540. return DefaultType$5;
  15541. }
  15542. static get NAME() {
  15543. return NAME$6;
  15544. } // Public
  15545. toggle(relatedTarget) {
  15546. return this._isShown ? this.hide() : this.show(relatedTarget);
  15547. }
  15548. show(relatedTarget) {
  15549. if (this._isShown) {
  15550. return;
  15551. }
  15552. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  15553. relatedTarget
  15554. });
  15555. if (showEvent.defaultPrevented) {
  15556. return;
  15557. }
  15558. this._isShown = true;
  15559. this._backdrop.show();
  15560. if (!this._config.scroll) {
  15561. new ScrollBarHelper().hide();
  15562. }
  15563. this._element.setAttribute('aria-modal', true);
  15564. this._element.setAttribute('role', 'dialog');
  15565. this._element.classList.add(CLASS_NAME_SHOWING$1);
  15566. const completeCallBack = () => {
  15567. if (!this._config.scroll || this._config.backdrop) {
  15568. this._focustrap.activate();
  15569. }
  15570. this._element.classList.add(CLASS_NAME_SHOW$3);
  15571. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  15572. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  15573. relatedTarget
  15574. });
  15575. };
  15576. this._queueCallback(completeCallBack, this._element, true);
  15577. }
  15578. hide() {
  15579. if (!this._isShown) {
  15580. return;
  15581. }
  15582. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  15583. if (hideEvent.defaultPrevented) {
  15584. return;
  15585. }
  15586. this._focustrap.deactivate();
  15587. this._element.blur();
  15588. this._isShown = false;
  15589. this._element.classList.add(CLASS_NAME_HIDING);
  15590. this._backdrop.hide();
  15591. const completeCallback = () => {
  15592. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  15593. this._element.removeAttribute('aria-modal');
  15594. this._element.removeAttribute('role');
  15595. if (!this._config.scroll) {
  15596. new ScrollBarHelper().reset();
  15597. }
  15598. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  15599. };
  15600. this._queueCallback(completeCallback, this._element, true);
  15601. }
  15602. dispose() {
  15603. this._backdrop.dispose();
  15604. this._focustrap.deactivate();
  15605. super.dispose();
  15606. } // Private
  15607. _initializeBackDrop() {
  15608. const clickCallback = () => {
  15609. if (this._config.backdrop === 'static') {
  15610. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  15611. return;
  15612. }
  15613. this.hide();
  15614. }; // 'static' option will be translated to true, and booleans will keep their value
  15615. const isVisible = Boolean(this._config.backdrop);
  15616. return new Backdrop({
  15617. className: CLASS_NAME_BACKDROP,
  15618. isVisible,
  15619. isAnimated: true,
  15620. rootElement: this._element.parentNode,
  15621. clickCallback: isVisible ? clickCallback : null
  15622. });
  15623. }
  15624. _initializeFocusTrap() {
  15625. return new FocusTrap({
  15626. trapElement: this._element
  15627. });
  15628. }
  15629. _addEventListeners() {
  15630. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  15631. if (event.key !== ESCAPE_KEY) {
  15632. return;
  15633. }
  15634. if (!this._config.keyboard) {
  15635. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  15636. return;
  15637. }
  15638. this.hide();
  15639. });
  15640. } // Static
  15641. static jQueryInterface(config) {
  15642. return this.each(function () {
  15643. const data = Offcanvas.getOrCreateInstance(this, config);
  15644. if (typeof config !== 'string') {
  15645. return;
  15646. }
  15647. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  15648. throw new TypeError(`No method named "${config}"`);
  15649. }
  15650. data[config](this);
  15651. });
  15652. }
  15653. }
  15654. /**
  15655. * Data API implementation
  15656. */
  15657. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  15658. const target = getElementFromSelector(this);
  15659. if (['A', 'AREA'].includes(this.tagName)) {
  15660. event.preventDefault();
  15661. }
  15662. if (isDisabled(this)) {
  15663. return;
  15664. }
  15665. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  15666. // focus on trigger when it is closed
  15667. if (isVisible(this)) {
  15668. this.focus();
  15669. }
  15670. }); // avoid conflict when clicking a toggler of an offcanvas, while another is open
  15671. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  15672. if (alreadyOpen && alreadyOpen !== target) {
  15673. Offcanvas.getInstance(alreadyOpen).hide();
  15674. }
  15675. const data = Offcanvas.getOrCreateInstance(target);
  15676. data.toggle(this);
  15677. });
  15678. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  15679. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  15680. Offcanvas.getOrCreateInstance(selector).show();
  15681. }
  15682. });
  15683. EventHandler.on(window, EVENT_RESIZE, () => {
  15684. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  15685. if (getComputedStyle(element).position !== 'fixed') {
  15686. Offcanvas.getOrCreateInstance(element).hide();
  15687. }
  15688. }
  15689. });
  15690. enableDismissTrigger(Offcanvas);
  15691. /**
  15692. * jQuery
  15693. */
  15694. defineJQueryPlugin(Offcanvas);
  15695. /**
  15696. * --------------------------------------------------------------------------
  15697. * Bootstrap (v5.2.3): util/sanitizer.js
  15698. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15699. * --------------------------------------------------------------------------
  15700. */
  15701. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  15702. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  15703. /**
  15704. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  15705. *
  15706. * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
  15707. */
  15708. const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
  15709. /**
  15710. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  15711. *
  15712. * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
  15713. */
  15714. const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
  15715. const allowedAttribute = (attribute, allowedAttributeList) => {
  15716. const attributeName = attribute.nodeName.toLowerCase();
  15717. if (allowedAttributeList.includes(attributeName)) {
  15718. if (uriAttributes.has(attributeName)) {
  15719. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
  15720. }
  15721. return true;
  15722. } // Check if a regular expression validates the attribute.
  15723. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  15724. };
  15725. const DefaultAllowlist = {
  15726. // Global attributes allowed on any supplied element below.
  15727. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  15728. a: ['target', 'href', 'title', 'rel'],
  15729. area: [],
  15730. b: [],
  15731. br: [],
  15732. col: [],
  15733. code: [],
  15734. div: [],
  15735. em: [],
  15736. hr: [],
  15737. h1: [],
  15738. h2: [],
  15739. h3: [],
  15740. h4: [],
  15741. h5: [],
  15742. h6: [],
  15743. i: [],
  15744. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  15745. li: [],
  15746. ol: [],
  15747. p: [],
  15748. pre: [],
  15749. s: [],
  15750. small: [],
  15751. span: [],
  15752. sub: [],
  15753. sup: [],
  15754. strong: [],
  15755. u: [],
  15756. ul: []
  15757. };
  15758. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  15759. if (!unsafeHtml.length) {
  15760. return unsafeHtml;
  15761. }
  15762. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  15763. return sanitizeFunction(unsafeHtml);
  15764. }
  15765. const domParser = new window.DOMParser();
  15766. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  15767. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  15768. for (const element of elements) {
  15769. const elementName = element.nodeName.toLowerCase();
  15770. if (!Object.keys(allowList).includes(elementName)) {
  15771. element.remove();
  15772. continue;
  15773. }
  15774. const attributeList = [].concat(...element.attributes);
  15775. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  15776. for (const attribute of attributeList) {
  15777. if (!allowedAttribute(attribute, allowedAttributes)) {
  15778. element.removeAttribute(attribute.nodeName);
  15779. }
  15780. }
  15781. }
  15782. return createdDocument.body.innerHTML;
  15783. }
  15784. /**
  15785. * --------------------------------------------------------------------------
  15786. * Bootstrap (v5.2.3): util/template-factory.js
  15787. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15788. * --------------------------------------------------------------------------
  15789. */
  15790. /**
  15791. * Constants
  15792. */
  15793. const NAME$5 = 'TemplateFactory';
  15794. const Default$4 = {
  15795. allowList: DefaultAllowlist,
  15796. content: {},
  15797. // { selector : text , selector2 : text2 , }
  15798. extraClass: '',
  15799. html: false,
  15800. sanitize: true,
  15801. sanitizeFn: null,
  15802. template: '<div></div>'
  15803. };
  15804. const DefaultType$4 = {
  15805. allowList: 'object',
  15806. content: 'object',
  15807. extraClass: '(string|function)',
  15808. html: 'boolean',
  15809. sanitize: 'boolean',
  15810. sanitizeFn: '(null|function)',
  15811. template: 'string'
  15812. };
  15813. const DefaultContentType = {
  15814. entry: '(string|element|function|null)',
  15815. selector: '(string|element)'
  15816. };
  15817. /**
  15818. * Class definition
  15819. */
  15820. class TemplateFactory extends Config {
  15821. constructor(config) {
  15822. super();
  15823. this._config = this._getConfig(config);
  15824. } // Getters
  15825. static get Default() {
  15826. return Default$4;
  15827. }
  15828. static get DefaultType() {
  15829. return DefaultType$4;
  15830. }
  15831. static get NAME() {
  15832. return NAME$5;
  15833. } // Public
  15834. getContent() {
  15835. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  15836. }
  15837. hasContent() {
  15838. return this.getContent().length > 0;
  15839. }
  15840. changeContent(content) {
  15841. this._checkContent(content);
  15842. this._config.content = { ...this._config.content,
  15843. ...content
  15844. };
  15845. return this;
  15846. }
  15847. toHtml() {
  15848. const templateWrapper = document.createElement('div');
  15849. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  15850. for (const [selector, text] of Object.entries(this._config.content)) {
  15851. this._setContent(templateWrapper, text, selector);
  15852. }
  15853. const template = templateWrapper.children[0];
  15854. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  15855. if (extraClass) {
  15856. template.classList.add(...extraClass.split(' '));
  15857. }
  15858. return template;
  15859. } // Private
  15860. _typeCheckConfig(config) {
  15861. super._typeCheckConfig(config);
  15862. this._checkContent(config.content);
  15863. }
  15864. _checkContent(arg) {
  15865. for (const [selector, content] of Object.entries(arg)) {
  15866. super._typeCheckConfig({
  15867. selector,
  15868. entry: content
  15869. }, DefaultContentType);
  15870. }
  15871. }
  15872. _setContent(template, content, selector) {
  15873. const templateElement = SelectorEngine.findOne(selector, template);
  15874. if (!templateElement) {
  15875. return;
  15876. }
  15877. content = this._resolvePossibleFunction(content);
  15878. if (!content) {
  15879. templateElement.remove();
  15880. return;
  15881. }
  15882. if (isElement(content)) {
  15883. this._putElementInTemplate(getElement(content), templateElement);
  15884. return;
  15885. }
  15886. if (this._config.html) {
  15887. templateElement.innerHTML = this._maybeSanitize(content);
  15888. return;
  15889. }
  15890. templateElement.textContent = content;
  15891. }
  15892. _maybeSanitize(arg) {
  15893. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  15894. }
  15895. _resolvePossibleFunction(arg) {
  15896. return typeof arg === 'function' ? arg(this) : arg;
  15897. }
  15898. _putElementInTemplate(element, templateElement) {
  15899. if (this._config.html) {
  15900. templateElement.innerHTML = '';
  15901. templateElement.append(element);
  15902. return;
  15903. }
  15904. templateElement.textContent = element.textContent;
  15905. }
  15906. }
  15907. /**
  15908. * --------------------------------------------------------------------------
  15909. * Bootstrap (v5.2.3): tooltip.js
  15910. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15911. * --------------------------------------------------------------------------
  15912. */
  15913. /**
  15914. * Constants
  15915. */
  15916. const NAME$4 = 'tooltip';
  15917. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  15918. const CLASS_NAME_FADE$2 = 'fade';
  15919. const CLASS_NAME_MODAL = 'modal';
  15920. const CLASS_NAME_SHOW$2 = 'show';
  15921. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  15922. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  15923. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  15924. const TRIGGER_HOVER = 'hover';
  15925. const TRIGGER_FOCUS = 'focus';
  15926. const TRIGGER_CLICK = 'click';
  15927. const TRIGGER_MANUAL = 'manual';
  15928. const EVENT_HIDE$2 = 'hide';
  15929. const EVENT_HIDDEN$2 = 'hidden';
  15930. const EVENT_SHOW$2 = 'show';
  15931. const EVENT_SHOWN$2 = 'shown';
  15932. const EVENT_INSERTED = 'inserted';
  15933. const EVENT_CLICK$1 = 'click';
  15934. const EVENT_FOCUSIN$1 = 'focusin';
  15935. const EVENT_FOCUSOUT$1 = 'focusout';
  15936. const EVENT_MOUSEENTER = 'mouseenter';
  15937. const EVENT_MOUSELEAVE = 'mouseleave';
  15938. const AttachmentMap = {
  15939. AUTO: 'auto',
  15940. TOP: 'top',
  15941. RIGHT: isRTL() ? 'left' : 'right',
  15942. BOTTOM: 'bottom',
  15943. LEFT: isRTL() ? 'right' : 'left'
  15944. };
  15945. const Default$3 = {
  15946. allowList: DefaultAllowlist,
  15947. animation: true,
  15948. boundary: 'clippingParents',
  15949. container: false,
  15950. customClass: '',
  15951. delay: 0,
  15952. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  15953. html: false,
  15954. offset: [0, 0],
  15955. placement: 'top',
  15956. popperConfig: null,
  15957. sanitize: true,
  15958. sanitizeFn: null,
  15959. selector: false,
  15960. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  15961. title: '',
  15962. trigger: 'hover focus'
  15963. };
  15964. const DefaultType$3 = {
  15965. allowList: 'object',
  15966. animation: 'boolean',
  15967. boundary: '(string|element)',
  15968. container: '(string|element|boolean)',
  15969. customClass: '(string|function)',
  15970. delay: '(number|object)',
  15971. fallbackPlacements: 'array',
  15972. html: 'boolean',
  15973. offset: '(array|string|function)',
  15974. placement: '(string|function)',
  15975. popperConfig: '(null|object|function)',
  15976. sanitize: 'boolean',
  15977. sanitizeFn: '(null|function)',
  15978. selector: '(string|boolean)',
  15979. template: 'string',
  15980. title: '(string|element|function)',
  15981. trigger: 'string'
  15982. };
  15983. /**
  15984. * Class definition
  15985. */
  15986. class Tooltip extends BaseComponent {
  15987. constructor(element, config) {
  15988. if (typeof _popperjs_core__WEBPACK_IMPORTED_MODULE_0__ === 'undefined') {
  15989. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  15990. }
  15991. super(element, config); // Private
  15992. this._isEnabled = true;
  15993. this._timeout = 0;
  15994. this._isHovered = null;
  15995. this._activeTrigger = {};
  15996. this._popper = null;
  15997. this._templateFactory = null;
  15998. this._newContent = null; // Protected
  15999. this.tip = null;
  16000. this._setListeners();
  16001. if (!this._config.selector) {
  16002. this._fixTitle();
  16003. }
  16004. } // Getters
  16005. static get Default() {
  16006. return Default$3;
  16007. }
  16008. static get DefaultType() {
  16009. return DefaultType$3;
  16010. }
  16011. static get NAME() {
  16012. return NAME$4;
  16013. } // Public
  16014. enable() {
  16015. this._isEnabled = true;
  16016. }
  16017. disable() {
  16018. this._isEnabled = false;
  16019. }
  16020. toggleEnabled() {
  16021. this._isEnabled = !this._isEnabled;
  16022. }
  16023. toggle() {
  16024. if (!this._isEnabled) {
  16025. return;
  16026. }
  16027. this._activeTrigger.click = !this._activeTrigger.click;
  16028. if (this._isShown()) {
  16029. this._leave();
  16030. return;
  16031. }
  16032. this._enter();
  16033. }
  16034. dispose() {
  16035. clearTimeout(this._timeout);
  16036. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  16037. if (this._element.getAttribute('data-bs-original-title')) {
  16038. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  16039. }
  16040. this._disposePopper();
  16041. super.dispose();
  16042. }
  16043. show() {
  16044. if (this._element.style.display === 'none') {
  16045. throw new Error('Please use show on visible elements');
  16046. }
  16047. if (!(this._isWithContent() && this._isEnabled)) {
  16048. return;
  16049. }
  16050. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  16051. const shadowRoot = findShadowRoot(this._element);
  16052. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  16053. if (showEvent.defaultPrevented || !isInTheDom) {
  16054. return;
  16055. } // todo v6 remove this OR make it optional
  16056. this._disposePopper();
  16057. const tip = this._getTipElement();
  16058. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  16059. const {
  16060. container
  16061. } = this._config;
  16062. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  16063. container.append(tip);
  16064. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  16065. }
  16066. this._popper = this._createPopper(tip);
  16067. tip.classList.add(CLASS_NAME_SHOW$2); // If this is a touch-enabled device we add extra
  16068. // empty mouseover listeners to the body's immediate children;
  16069. // only needed because of broken event delegation on iOS
  16070. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  16071. if ('ontouchstart' in document.documentElement) {
  16072. for (const element of [].concat(...document.body.children)) {
  16073. EventHandler.on(element, 'mouseover', noop);
  16074. }
  16075. }
  16076. const complete = () => {
  16077. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  16078. if (this._isHovered === false) {
  16079. this._leave();
  16080. }
  16081. this._isHovered = false;
  16082. };
  16083. this._queueCallback(complete, this.tip, this._isAnimated());
  16084. }
  16085. hide() {
  16086. if (!this._isShown()) {
  16087. return;
  16088. }
  16089. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  16090. if (hideEvent.defaultPrevented) {
  16091. return;
  16092. }
  16093. const tip = this._getTipElement();
  16094. tip.classList.remove(CLASS_NAME_SHOW$2); // If this is a touch-enabled device we remove the extra
  16095. // empty mouseover listeners we added for iOS support
  16096. if ('ontouchstart' in document.documentElement) {
  16097. for (const element of [].concat(...document.body.children)) {
  16098. EventHandler.off(element, 'mouseover', noop);
  16099. }
  16100. }
  16101. this._activeTrigger[TRIGGER_CLICK] = false;
  16102. this._activeTrigger[TRIGGER_FOCUS] = false;
  16103. this._activeTrigger[TRIGGER_HOVER] = false;
  16104. this._isHovered = null; // it is a trick to support manual triggering
  16105. const complete = () => {
  16106. if (this._isWithActiveTrigger()) {
  16107. return;
  16108. }
  16109. if (!this._isHovered) {
  16110. this._disposePopper();
  16111. }
  16112. this._element.removeAttribute('aria-describedby');
  16113. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  16114. };
  16115. this._queueCallback(complete, this.tip, this._isAnimated());
  16116. }
  16117. update() {
  16118. if (this._popper) {
  16119. this._popper.update();
  16120. }
  16121. } // Protected
  16122. _isWithContent() {
  16123. return Boolean(this._getTitle());
  16124. }
  16125. _getTipElement() {
  16126. if (!this.tip) {
  16127. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  16128. }
  16129. return this.tip;
  16130. }
  16131. _createTipElement(content) {
  16132. const tip = this._getTemplateFactory(content).toHtml(); // todo: remove this check on v6
  16133. if (!tip) {
  16134. return null;
  16135. }
  16136. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); // todo: on v6 the following can be achieved with CSS only
  16137. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  16138. const tipId = getUID(this.constructor.NAME).toString();
  16139. tip.setAttribute('id', tipId);
  16140. if (this._isAnimated()) {
  16141. tip.classList.add(CLASS_NAME_FADE$2);
  16142. }
  16143. return tip;
  16144. }
  16145. setContent(content) {
  16146. this._newContent = content;
  16147. if (this._isShown()) {
  16148. this._disposePopper();
  16149. this.show();
  16150. }
  16151. }
  16152. _getTemplateFactory(content) {
  16153. if (this._templateFactory) {
  16154. this._templateFactory.changeContent(content);
  16155. } else {
  16156. this._templateFactory = new TemplateFactory({ ...this._config,
  16157. // the `content` var has to be after `this._config`
  16158. // to override config.content in case of popover
  16159. content,
  16160. extraClass: this._resolvePossibleFunction(this._config.customClass)
  16161. });
  16162. }
  16163. return this._templateFactory;
  16164. }
  16165. _getContentForTemplate() {
  16166. return {
  16167. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  16168. };
  16169. }
  16170. _getTitle() {
  16171. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  16172. } // Private
  16173. _initializeOnDelegatedTarget(event) {
  16174. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  16175. }
  16176. _isAnimated() {
  16177. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  16178. }
  16179. _isShown() {
  16180. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  16181. }
  16182. _createPopper(tip) {
  16183. const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement;
  16184. const attachment = AttachmentMap[placement.toUpperCase()];
  16185. return _popperjs_core__WEBPACK_IMPORTED_MODULE_1__.createPopper(this._element, tip, this._getPopperConfig(attachment));
  16186. }
  16187. _getOffset() {
  16188. const {
  16189. offset
  16190. } = this._config;
  16191. if (typeof offset === 'string') {
  16192. return offset.split(',').map(value => Number.parseInt(value, 10));
  16193. }
  16194. if (typeof offset === 'function') {
  16195. return popperData => offset(popperData, this._element);
  16196. }
  16197. return offset;
  16198. }
  16199. _resolvePossibleFunction(arg) {
  16200. return typeof arg === 'function' ? arg.call(this._element) : arg;
  16201. }
  16202. _getPopperConfig(attachment) {
  16203. const defaultBsPopperConfig = {
  16204. placement: attachment,
  16205. modifiers: [{
  16206. name: 'flip',
  16207. options: {
  16208. fallbackPlacements: this._config.fallbackPlacements
  16209. }
  16210. }, {
  16211. name: 'offset',
  16212. options: {
  16213. offset: this._getOffset()
  16214. }
  16215. }, {
  16216. name: 'preventOverflow',
  16217. options: {
  16218. boundary: this._config.boundary
  16219. }
  16220. }, {
  16221. name: 'arrow',
  16222. options: {
  16223. element: `.${this.constructor.NAME}-arrow`
  16224. }
  16225. }, {
  16226. name: 'preSetPlacement',
  16227. enabled: true,
  16228. phase: 'beforeMain',
  16229. fn: data => {
  16230. // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
  16231. // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
  16232. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  16233. }
  16234. }]
  16235. };
  16236. return { ...defaultBsPopperConfig,
  16237. ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
  16238. };
  16239. }
  16240. _setListeners() {
  16241. const triggers = this._config.trigger.split(' ');
  16242. for (const trigger of triggers) {
  16243. if (trigger === 'click') {
  16244. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  16245. const context = this._initializeOnDelegatedTarget(event);
  16246. context.toggle();
  16247. });
  16248. } else if (trigger !== TRIGGER_MANUAL) {
  16249. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  16250. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  16251. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  16252. const context = this._initializeOnDelegatedTarget(event);
  16253. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  16254. context._enter();
  16255. });
  16256. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  16257. const context = this._initializeOnDelegatedTarget(event);
  16258. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  16259. context._leave();
  16260. });
  16261. }
  16262. }
  16263. this._hideModalHandler = () => {
  16264. if (this._element) {
  16265. this.hide();
  16266. }
  16267. };
  16268. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  16269. }
  16270. _fixTitle() {
  16271. const title = this._element.getAttribute('title');
  16272. if (!title) {
  16273. return;
  16274. }
  16275. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  16276. this._element.setAttribute('aria-label', title);
  16277. }
  16278. this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
  16279. this._element.removeAttribute('title');
  16280. }
  16281. _enter() {
  16282. if (this._isShown() || this._isHovered) {
  16283. this._isHovered = true;
  16284. return;
  16285. }
  16286. this._isHovered = true;
  16287. this._setTimeout(() => {
  16288. if (this._isHovered) {
  16289. this.show();
  16290. }
  16291. }, this._config.delay.show);
  16292. }
  16293. _leave() {
  16294. if (this._isWithActiveTrigger()) {
  16295. return;
  16296. }
  16297. this._isHovered = false;
  16298. this._setTimeout(() => {
  16299. if (!this._isHovered) {
  16300. this.hide();
  16301. }
  16302. }, this._config.delay.hide);
  16303. }
  16304. _setTimeout(handler, timeout) {
  16305. clearTimeout(this._timeout);
  16306. this._timeout = setTimeout(handler, timeout);
  16307. }
  16308. _isWithActiveTrigger() {
  16309. return Object.values(this._activeTrigger).includes(true);
  16310. }
  16311. _getConfig(config) {
  16312. const dataAttributes = Manipulator.getDataAttributes(this._element);
  16313. for (const dataAttribute of Object.keys(dataAttributes)) {
  16314. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  16315. delete dataAttributes[dataAttribute];
  16316. }
  16317. }
  16318. config = { ...dataAttributes,
  16319. ...(typeof config === 'object' && config ? config : {})
  16320. };
  16321. config = this._mergeConfigObj(config);
  16322. config = this._configAfterMerge(config);
  16323. this._typeCheckConfig(config);
  16324. return config;
  16325. }
  16326. _configAfterMerge(config) {
  16327. config.container = config.container === false ? document.body : getElement(config.container);
  16328. if (typeof config.delay === 'number') {
  16329. config.delay = {
  16330. show: config.delay,
  16331. hide: config.delay
  16332. };
  16333. }
  16334. if (typeof config.title === 'number') {
  16335. config.title = config.title.toString();
  16336. }
  16337. if (typeof config.content === 'number') {
  16338. config.content = config.content.toString();
  16339. }
  16340. return config;
  16341. }
  16342. _getDelegateConfig() {
  16343. const config = {};
  16344. for (const key in this._config) {
  16345. if (this.constructor.Default[key] !== this._config[key]) {
  16346. config[key] = this._config[key];
  16347. }
  16348. }
  16349. config.selector = false;
  16350. config.trigger = 'manual'; // In the future can be replaced with:
  16351. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  16352. // `Object.fromEntries(keysWithDifferentValues)`
  16353. return config;
  16354. }
  16355. _disposePopper() {
  16356. if (this._popper) {
  16357. this._popper.destroy();
  16358. this._popper = null;
  16359. }
  16360. if (this.tip) {
  16361. this.tip.remove();
  16362. this.tip = null;
  16363. }
  16364. } // Static
  16365. static jQueryInterface(config) {
  16366. return this.each(function () {
  16367. const data = Tooltip.getOrCreateInstance(this, config);
  16368. if (typeof config !== 'string') {
  16369. return;
  16370. }
  16371. if (typeof data[config] === 'undefined') {
  16372. throw new TypeError(`No method named "${config}"`);
  16373. }
  16374. data[config]();
  16375. });
  16376. }
  16377. }
  16378. /**
  16379. * jQuery
  16380. */
  16381. defineJQueryPlugin(Tooltip);
  16382. /**
  16383. * --------------------------------------------------------------------------
  16384. * Bootstrap (v5.2.3): popover.js
  16385. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  16386. * --------------------------------------------------------------------------
  16387. */
  16388. /**
  16389. * Constants
  16390. */
  16391. const NAME$3 = 'popover';
  16392. const SELECTOR_TITLE = '.popover-header';
  16393. const SELECTOR_CONTENT = '.popover-body';
  16394. const Default$2 = { ...Tooltip.Default,
  16395. content: '',
  16396. offset: [0, 8],
  16397. placement: 'right',
  16398. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  16399. trigger: 'click'
  16400. };
  16401. const DefaultType$2 = { ...Tooltip.DefaultType,
  16402. content: '(null|string|element|function)'
  16403. };
  16404. /**
  16405. * Class definition
  16406. */
  16407. class Popover extends Tooltip {
  16408. // Getters
  16409. static get Default() {
  16410. return Default$2;
  16411. }
  16412. static get DefaultType() {
  16413. return DefaultType$2;
  16414. }
  16415. static get NAME() {
  16416. return NAME$3;
  16417. } // Overrides
  16418. _isWithContent() {
  16419. return this._getTitle() || this._getContent();
  16420. } // Private
  16421. _getContentForTemplate() {
  16422. return {
  16423. [SELECTOR_TITLE]: this._getTitle(),
  16424. [SELECTOR_CONTENT]: this._getContent()
  16425. };
  16426. }
  16427. _getContent() {
  16428. return this._resolvePossibleFunction(this._config.content);
  16429. } // Static
  16430. static jQueryInterface(config) {
  16431. return this.each(function () {
  16432. const data = Popover.getOrCreateInstance(this, config);
  16433. if (typeof config !== 'string') {
  16434. return;
  16435. }
  16436. if (typeof data[config] === 'undefined') {
  16437. throw new TypeError(`No method named "${config}"`);
  16438. }
  16439. data[config]();
  16440. });
  16441. }
  16442. }
  16443. /**
  16444. * jQuery
  16445. */
  16446. defineJQueryPlugin(Popover);
  16447. /**
  16448. * --------------------------------------------------------------------------
  16449. * Bootstrap (v5.2.3): scrollspy.js
  16450. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  16451. * --------------------------------------------------------------------------
  16452. */
  16453. /**
  16454. * Constants
  16455. */
  16456. const NAME$2 = 'scrollspy';
  16457. const DATA_KEY$2 = 'bs.scrollspy';
  16458. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  16459. const DATA_API_KEY = '.data-api';
  16460. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  16461. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  16462. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  16463. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  16464. const CLASS_NAME_ACTIVE$1 = 'active';
  16465. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  16466. const SELECTOR_TARGET_LINKS = '[href]';
  16467. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  16468. const SELECTOR_NAV_LINKS = '.nav-link';
  16469. const SELECTOR_NAV_ITEMS = '.nav-item';
  16470. const SELECTOR_LIST_ITEMS = '.list-group-item';
  16471. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  16472. const SELECTOR_DROPDOWN = '.dropdown';
  16473. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  16474. const Default$1 = {
  16475. offset: null,
  16476. // TODO: v6 @deprecated, keep it for backwards compatibility reasons
  16477. rootMargin: '0px 0px -25%',
  16478. smoothScroll: false,
  16479. target: null,
  16480. threshold: [0.1, 0.5, 1]
  16481. };
  16482. const DefaultType$1 = {
  16483. offset: '(number|null)',
  16484. // TODO v6 @deprecated, keep it for backwards compatibility reasons
  16485. rootMargin: 'string',
  16486. smoothScroll: 'boolean',
  16487. target: 'element',
  16488. threshold: 'array'
  16489. };
  16490. /**
  16491. * Class definition
  16492. */
  16493. class ScrollSpy extends BaseComponent {
  16494. constructor(element, config) {
  16495. super(element, config); // this._element is the observablesContainer and config.target the menu links wrapper
  16496. this._targetLinks = new Map();
  16497. this._observableSections = new Map();
  16498. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  16499. this._activeTarget = null;
  16500. this._observer = null;
  16501. this._previousScrollData = {
  16502. visibleEntryTop: 0,
  16503. parentScrollTop: 0
  16504. };
  16505. this.refresh(); // initialize
  16506. } // Getters
  16507. static get Default() {
  16508. return Default$1;
  16509. }
  16510. static get DefaultType() {
  16511. return DefaultType$1;
  16512. }
  16513. static get NAME() {
  16514. return NAME$2;
  16515. } // Public
  16516. refresh() {
  16517. this._initializeTargetsAndObservables();
  16518. this._maybeEnableSmoothScroll();
  16519. if (this._observer) {
  16520. this._observer.disconnect();
  16521. } else {
  16522. this._observer = this._getNewObserver();
  16523. }
  16524. for (const section of this._observableSections.values()) {
  16525. this._observer.observe(section);
  16526. }
  16527. }
  16528. dispose() {
  16529. this._observer.disconnect();
  16530. super.dispose();
  16531. } // Private
  16532. _configAfterMerge(config) {
  16533. // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
  16534. config.target = getElement(config.target) || document.body; // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
  16535. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  16536. if (typeof config.threshold === 'string') {
  16537. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  16538. }
  16539. return config;
  16540. }
  16541. _maybeEnableSmoothScroll() {
  16542. if (!this._config.smoothScroll) {
  16543. return;
  16544. } // unregister any previous listeners
  16545. EventHandler.off(this._config.target, EVENT_CLICK);
  16546. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  16547. const observableSection = this._observableSections.get(event.target.hash);
  16548. if (observableSection) {
  16549. event.preventDefault();
  16550. const root = this._rootElement || window;
  16551. const height = observableSection.offsetTop - this._element.offsetTop;
  16552. if (root.scrollTo) {
  16553. root.scrollTo({
  16554. top: height,
  16555. behavior: 'smooth'
  16556. });
  16557. return;
  16558. } // Chrome 60 doesn't support `scrollTo`
  16559. root.scrollTop = height;
  16560. }
  16561. });
  16562. }
  16563. _getNewObserver() {
  16564. const options = {
  16565. root: this._rootElement,
  16566. threshold: this._config.threshold,
  16567. rootMargin: this._config.rootMargin
  16568. };
  16569. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  16570. } // The logic of selection
  16571. _observerCallback(entries) {
  16572. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  16573. const activate = entry => {
  16574. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  16575. this._process(targetElement(entry));
  16576. };
  16577. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  16578. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  16579. this._previousScrollData.parentScrollTop = parentScrollTop;
  16580. for (const entry of entries) {
  16581. if (!entry.isIntersecting) {
  16582. this._activeTarget = null;
  16583. this._clearActiveClass(targetElement(entry));
  16584. continue;
  16585. }
  16586. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop; // if we are scrolling down, pick the bigger offsetTop
  16587. if (userScrollsDown && entryIsLowerThanPrevious) {
  16588. activate(entry); // if parent isn't scrolled, let's keep the first visible item, breaking the iteration
  16589. if (!parentScrollTop) {
  16590. return;
  16591. }
  16592. continue;
  16593. } // if we are scrolling up, pick the smallest offsetTop
  16594. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  16595. activate(entry);
  16596. }
  16597. }
  16598. }
  16599. _initializeTargetsAndObservables() {
  16600. this._targetLinks = new Map();
  16601. this._observableSections = new Map();
  16602. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  16603. for (const anchor of targetLinks) {
  16604. // ensure that the anchor has an id and is not disabled
  16605. if (!anchor.hash || isDisabled(anchor)) {
  16606. continue;
  16607. }
  16608. const observableSection = SelectorEngine.findOne(anchor.hash, this._element); // ensure that the observableSection exists & is visible
  16609. if (isVisible(observableSection)) {
  16610. this._targetLinks.set(anchor.hash, anchor);
  16611. this._observableSections.set(anchor.hash, observableSection);
  16612. }
  16613. }
  16614. }
  16615. _process(target) {
  16616. if (this._activeTarget === target) {
  16617. return;
  16618. }
  16619. this._clearActiveClass(this._config.target);
  16620. this._activeTarget = target;
  16621. target.classList.add(CLASS_NAME_ACTIVE$1);
  16622. this._activateParents(target);
  16623. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  16624. relatedTarget: target
  16625. });
  16626. }
  16627. _activateParents(target) {
  16628. // Activate dropdown parents
  16629. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  16630. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  16631. return;
  16632. }
  16633. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  16634. // Set triggered links parents as active
  16635. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  16636. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  16637. item.classList.add(CLASS_NAME_ACTIVE$1);
  16638. }
  16639. }
  16640. }
  16641. _clearActiveClass(parent) {
  16642. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  16643. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  16644. for (const node of activeNodes) {
  16645. node.classList.remove(CLASS_NAME_ACTIVE$1);
  16646. }
  16647. } // Static
  16648. static jQueryInterface(config) {
  16649. return this.each(function () {
  16650. const data = ScrollSpy.getOrCreateInstance(this, config);
  16651. if (typeof config !== 'string') {
  16652. return;
  16653. }
  16654. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  16655. throw new TypeError(`No method named "${config}"`);
  16656. }
  16657. data[config]();
  16658. });
  16659. }
  16660. }
  16661. /**
  16662. * Data API implementation
  16663. */
  16664. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  16665. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  16666. ScrollSpy.getOrCreateInstance(spy);
  16667. }
  16668. });
  16669. /**
  16670. * jQuery
  16671. */
  16672. defineJQueryPlugin(ScrollSpy);
  16673. /**
  16674. * --------------------------------------------------------------------------
  16675. * Bootstrap (v5.2.3): tab.js
  16676. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  16677. * --------------------------------------------------------------------------
  16678. */
  16679. /**
  16680. * Constants
  16681. */
  16682. const NAME$1 = 'tab';
  16683. const DATA_KEY$1 = 'bs.tab';
  16684. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  16685. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  16686. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  16687. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  16688. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  16689. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  16690. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  16691. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  16692. const ARROW_LEFT_KEY = 'ArrowLeft';
  16693. const ARROW_RIGHT_KEY = 'ArrowRight';
  16694. const ARROW_UP_KEY = 'ArrowUp';
  16695. const ARROW_DOWN_KEY = 'ArrowDown';
  16696. const CLASS_NAME_ACTIVE = 'active';
  16697. const CLASS_NAME_FADE$1 = 'fade';
  16698. const CLASS_NAME_SHOW$1 = 'show';
  16699. const CLASS_DROPDOWN = 'dropdown';
  16700. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  16701. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  16702. const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)';
  16703. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  16704. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  16705. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  16706. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // todo:v6: could be only `tab`
  16707. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  16708. const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
  16709. /**
  16710. * Class definition
  16711. */
  16712. class Tab extends BaseComponent {
  16713. constructor(element) {
  16714. super(element);
  16715. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  16716. if (!this._parent) {
  16717. return; // todo: should Throw exception on v6
  16718. // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
  16719. } // Set up initial aria attributes
  16720. this._setInitialAttributes(this._parent, this._getChildren());
  16721. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  16722. } // Getters
  16723. static get NAME() {
  16724. return NAME$1;
  16725. } // Public
  16726. show() {
  16727. // Shows this elem and deactivate the active sibling if exists
  16728. const innerElem = this._element;
  16729. if (this._elemIsActive(innerElem)) {
  16730. return;
  16731. } // Search for active tab on same parent to deactivate it
  16732. const active = this._getActiveElem();
  16733. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  16734. relatedTarget: innerElem
  16735. }) : null;
  16736. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  16737. relatedTarget: active
  16738. });
  16739. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  16740. return;
  16741. }
  16742. this._deactivate(active, innerElem);
  16743. this._activate(innerElem, active);
  16744. } // Private
  16745. _activate(element, relatedElem) {
  16746. if (!element) {
  16747. return;
  16748. }
  16749. element.classList.add(CLASS_NAME_ACTIVE);
  16750. this._activate(getElementFromSelector(element)); // Search and activate/show the proper section
  16751. const complete = () => {
  16752. if (element.getAttribute('role') !== 'tab') {
  16753. element.classList.add(CLASS_NAME_SHOW$1);
  16754. return;
  16755. }
  16756. element.removeAttribute('tabindex');
  16757. element.setAttribute('aria-selected', true);
  16758. this._toggleDropDown(element, true);
  16759. EventHandler.trigger(element, EVENT_SHOWN$1, {
  16760. relatedTarget: relatedElem
  16761. });
  16762. };
  16763. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  16764. }
  16765. _deactivate(element, relatedElem) {
  16766. if (!element) {
  16767. return;
  16768. }
  16769. element.classList.remove(CLASS_NAME_ACTIVE);
  16770. element.blur();
  16771. this._deactivate(getElementFromSelector(element)); // Search and deactivate the shown section too
  16772. const complete = () => {
  16773. if (element.getAttribute('role') !== 'tab') {
  16774. element.classList.remove(CLASS_NAME_SHOW$1);
  16775. return;
  16776. }
  16777. element.setAttribute('aria-selected', false);
  16778. element.setAttribute('tabindex', '-1');
  16779. this._toggleDropDown(element, false);
  16780. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  16781. relatedTarget: relatedElem
  16782. });
  16783. };
  16784. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  16785. }
  16786. _keydown(event) {
  16787. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) {
  16788. return;
  16789. }
  16790. event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
  16791. event.preventDefault();
  16792. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  16793. const nextActiveElement = getNextActiveElement(this._getChildren().filter(element => !isDisabled(element)), event.target, isNext, true);
  16794. if (nextActiveElement) {
  16795. nextActiveElement.focus({
  16796. preventScroll: true
  16797. });
  16798. Tab.getOrCreateInstance(nextActiveElement).show();
  16799. }
  16800. }
  16801. _getChildren() {
  16802. // collection of inner elements
  16803. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  16804. }
  16805. _getActiveElem() {
  16806. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  16807. }
  16808. _setInitialAttributes(parent, children) {
  16809. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  16810. for (const child of children) {
  16811. this._setInitialAttributesOnChild(child);
  16812. }
  16813. }
  16814. _setInitialAttributesOnChild(child) {
  16815. child = this._getInnerElement(child);
  16816. const isActive = this._elemIsActive(child);
  16817. const outerElem = this._getOuterElement(child);
  16818. child.setAttribute('aria-selected', isActive);
  16819. if (outerElem !== child) {
  16820. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  16821. }
  16822. if (!isActive) {
  16823. child.setAttribute('tabindex', '-1');
  16824. }
  16825. this._setAttributeIfNotExists(child, 'role', 'tab'); // set attributes to the related panel too
  16826. this._setInitialAttributesOnTargetPanel(child);
  16827. }
  16828. _setInitialAttributesOnTargetPanel(child) {
  16829. const target = getElementFromSelector(child);
  16830. if (!target) {
  16831. return;
  16832. }
  16833. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  16834. if (child.id) {
  16835. this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`);
  16836. }
  16837. }
  16838. _toggleDropDown(element, open) {
  16839. const outerElem = this._getOuterElement(element);
  16840. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  16841. return;
  16842. }
  16843. const toggle = (selector, className) => {
  16844. const element = SelectorEngine.findOne(selector, outerElem);
  16845. if (element) {
  16846. element.classList.toggle(className, open);
  16847. }
  16848. };
  16849. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  16850. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  16851. outerElem.setAttribute('aria-expanded', open);
  16852. }
  16853. _setAttributeIfNotExists(element, attribute, value) {
  16854. if (!element.hasAttribute(attribute)) {
  16855. element.setAttribute(attribute, value);
  16856. }
  16857. }
  16858. _elemIsActive(elem) {
  16859. return elem.classList.contains(CLASS_NAME_ACTIVE);
  16860. } // Try to get the inner element (usually the .nav-link)
  16861. _getInnerElement(elem) {
  16862. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  16863. } // Try to get the outer element (usually the .nav-item)
  16864. _getOuterElement(elem) {
  16865. return elem.closest(SELECTOR_OUTER) || elem;
  16866. } // Static
  16867. static jQueryInterface(config) {
  16868. return this.each(function () {
  16869. const data = Tab.getOrCreateInstance(this);
  16870. if (typeof config !== 'string') {
  16871. return;
  16872. }
  16873. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  16874. throw new TypeError(`No method named "${config}"`);
  16875. }
  16876. data[config]();
  16877. });
  16878. }
  16879. }
  16880. /**
  16881. * Data API implementation
  16882. */
  16883. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  16884. if (['A', 'AREA'].includes(this.tagName)) {
  16885. event.preventDefault();
  16886. }
  16887. if (isDisabled(this)) {
  16888. return;
  16889. }
  16890. Tab.getOrCreateInstance(this).show();
  16891. });
  16892. /**
  16893. * Initialize on focus
  16894. */
  16895. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  16896. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  16897. Tab.getOrCreateInstance(element);
  16898. }
  16899. });
  16900. /**
  16901. * jQuery
  16902. */
  16903. defineJQueryPlugin(Tab);
  16904. /**
  16905. * --------------------------------------------------------------------------
  16906. * Bootstrap (v5.2.3): toast.js
  16907. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  16908. * --------------------------------------------------------------------------
  16909. */
  16910. /**
  16911. * Constants
  16912. */
  16913. const NAME = 'toast';
  16914. const DATA_KEY = 'bs.toast';
  16915. const EVENT_KEY = `.${DATA_KEY}`;
  16916. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  16917. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  16918. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  16919. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  16920. const EVENT_HIDE = `hide${EVENT_KEY}`;
  16921. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  16922. const EVENT_SHOW = `show${EVENT_KEY}`;
  16923. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  16924. const CLASS_NAME_FADE = 'fade';
  16925. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  16926. const CLASS_NAME_SHOW = 'show';
  16927. const CLASS_NAME_SHOWING = 'showing';
  16928. const DefaultType = {
  16929. animation: 'boolean',
  16930. autohide: 'boolean',
  16931. delay: 'number'
  16932. };
  16933. const Default = {
  16934. animation: true,
  16935. autohide: true,
  16936. delay: 5000
  16937. };
  16938. /**
  16939. * Class definition
  16940. */
  16941. class Toast extends BaseComponent {
  16942. constructor(element, config) {
  16943. super(element, config);
  16944. this._timeout = null;
  16945. this._hasMouseInteraction = false;
  16946. this._hasKeyboardInteraction = false;
  16947. this._setListeners();
  16948. } // Getters
  16949. static get Default() {
  16950. return Default;
  16951. }
  16952. static get DefaultType() {
  16953. return DefaultType;
  16954. }
  16955. static get NAME() {
  16956. return NAME;
  16957. } // Public
  16958. show() {
  16959. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  16960. if (showEvent.defaultPrevented) {
  16961. return;
  16962. }
  16963. this._clearTimeout();
  16964. if (this._config.animation) {
  16965. this._element.classList.add(CLASS_NAME_FADE);
  16966. }
  16967. const complete = () => {
  16968. this._element.classList.remove(CLASS_NAME_SHOWING);
  16969. EventHandler.trigger(this._element, EVENT_SHOWN);
  16970. this._maybeScheduleHide();
  16971. };
  16972. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  16973. reflow(this._element);
  16974. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  16975. this._queueCallback(complete, this._element, this._config.animation);
  16976. }
  16977. hide() {
  16978. if (!this.isShown()) {
  16979. return;
  16980. }
  16981. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  16982. if (hideEvent.defaultPrevented) {
  16983. return;
  16984. }
  16985. const complete = () => {
  16986. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  16987. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  16988. EventHandler.trigger(this._element, EVENT_HIDDEN);
  16989. };
  16990. this._element.classList.add(CLASS_NAME_SHOWING);
  16991. this._queueCallback(complete, this._element, this._config.animation);
  16992. }
  16993. dispose() {
  16994. this._clearTimeout();
  16995. if (this.isShown()) {
  16996. this._element.classList.remove(CLASS_NAME_SHOW);
  16997. }
  16998. super.dispose();
  16999. }
  17000. isShown() {
  17001. return this._element.classList.contains(CLASS_NAME_SHOW);
  17002. } // Private
  17003. _maybeScheduleHide() {
  17004. if (!this._config.autohide) {
  17005. return;
  17006. }
  17007. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  17008. return;
  17009. }
  17010. this._timeout = setTimeout(() => {
  17011. this.hide();
  17012. }, this._config.delay);
  17013. }
  17014. _onInteraction(event, isInteracting) {
  17015. switch (event.type) {
  17016. case 'mouseover':
  17017. case 'mouseout':
  17018. {
  17019. this._hasMouseInteraction = isInteracting;
  17020. break;
  17021. }
  17022. case 'focusin':
  17023. case 'focusout':
  17024. {
  17025. this._hasKeyboardInteraction = isInteracting;
  17026. break;
  17027. }
  17028. }
  17029. if (isInteracting) {
  17030. this._clearTimeout();
  17031. return;
  17032. }
  17033. const nextElement = event.relatedTarget;
  17034. if (this._element === nextElement || this._element.contains(nextElement)) {
  17035. return;
  17036. }
  17037. this._maybeScheduleHide();
  17038. }
  17039. _setListeners() {
  17040. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  17041. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  17042. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  17043. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  17044. }
  17045. _clearTimeout() {
  17046. clearTimeout(this._timeout);
  17047. this._timeout = null;
  17048. } // Static
  17049. static jQueryInterface(config) {
  17050. return this.each(function () {
  17051. const data = Toast.getOrCreateInstance(this, config);
  17052. if (typeof config === 'string') {
  17053. if (typeof data[config] === 'undefined') {
  17054. throw new TypeError(`No method named "${config}"`);
  17055. }
  17056. data[config](this);
  17057. }
  17058. });
  17059. }
  17060. }
  17061. /**
  17062. * Data API implementation
  17063. */
  17064. enableDismissTrigger(Toast);
  17065. /**
  17066. * jQuery
  17067. */
  17068. defineJQueryPlugin(Toast);
  17069. //# sourceMappingURL=bootstrap.esm.js.map
  17070. /***/ }),
  17071. /***/ "./node_modules/brorand/index.js":
  17072. /*!***************************************!*\
  17073. !*** ./node_modules/brorand/index.js ***!
  17074. \***************************************/
  17075. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  17076. var r;
  17077. module.exports = function rand(len) {
  17078. if (!r)
  17079. r = new Rand(null);
  17080. return r.generate(len);
  17081. };
  17082. function Rand(rand) {
  17083. this.rand = rand;
  17084. }
  17085. module.exports.Rand = Rand;
  17086. Rand.prototype.generate = function generate(len) {
  17087. return this._rand(len);
  17088. };
  17089. // Emulate crypto API using randy
  17090. Rand.prototype._rand = function _rand(n) {
  17091. if (this.rand.getBytes)
  17092. return this.rand.getBytes(n);
  17093. var res = new Uint8Array(n);
  17094. for (var i = 0; i < res.length; i++)
  17095. res[i] = this.rand.getByte();
  17096. return res;
  17097. };
  17098. if (typeof self === 'object') {
  17099. if (self.crypto && self.crypto.getRandomValues) {
  17100. // Modern browsers
  17101. Rand.prototype._rand = function _rand(n) {
  17102. var arr = new Uint8Array(n);
  17103. self.crypto.getRandomValues(arr);
  17104. return arr;
  17105. };
  17106. } else if (self.msCrypto && self.msCrypto.getRandomValues) {
  17107. // IE
  17108. Rand.prototype._rand = function _rand(n) {
  17109. var arr = new Uint8Array(n);
  17110. self.msCrypto.getRandomValues(arr);
  17111. return arr;
  17112. };
  17113. // Safari's WebWorkers do not have `crypto`
  17114. } else if (typeof window === 'object') {
  17115. // Old junk
  17116. Rand.prototype._rand = function() {
  17117. throw new Error('Not implemented yet');
  17118. };
  17119. }
  17120. } else {
  17121. // Node.js or Web worker with no crypto support
  17122. try {
  17123. var crypto = __webpack_require__(/*! crypto */ "?8d7a");
  17124. if (typeof crypto.randomBytes !== 'function')
  17125. throw new Error('Not supported');
  17126. Rand.prototype._rand = function _rand(n) {
  17127. return crypto.randomBytes(n);
  17128. };
  17129. } catch (e) {
  17130. }
  17131. }
  17132. /***/ }),
  17133. /***/ "./node_modules/browserify-aes/aes.js":
  17134. /*!********************************************!*\
  17135. !*** ./node_modules/browserify-aes/aes.js ***!
  17136. \********************************************/
  17137. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  17138. // based on the aes implimentation in triple sec
  17139. // https://github.com/keybase/triplesec
  17140. // which is in turn based on the one from crypto-js
  17141. // https://code.google.com/p/crypto-js/
  17142. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17143. function asUInt32Array (buf) {
  17144. if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
  17145. var len = (buf.length / 4) | 0
  17146. var out = new Array(len)
  17147. for (var i = 0; i < len; i++) {
  17148. out[i] = buf.readUInt32BE(i * 4)
  17149. }
  17150. return out
  17151. }
  17152. function scrubVec (v) {
  17153. for (var i = 0; i < v.length; v++) {
  17154. v[i] = 0
  17155. }
  17156. }
  17157. function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
  17158. var SUB_MIX0 = SUB_MIX[0]
  17159. var SUB_MIX1 = SUB_MIX[1]
  17160. var SUB_MIX2 = SUB_MIX[2]
  17161. var SUB_MIX3 = SUB_MIX[3]
  17162. var s0 = M[0] ^ keySchedule[0]
  17163. var s1 = M[1] ^ keySchedule[1]
  17164. var s2 = M[2] ^ keySchedule[2]
  17165. var s3 = M[3] ^ keySchedule[3]
  17166. var t0, t1, t2, t3
  17167. var ksRow = 4
  17168. for (var round = 1; round < nRounds; round++) {
  17169. t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
  17170. t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
  17171. t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
  17172. t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
  17173. s0 = t0
  17174. s1 = t1
  17175. s2 = t2
  17176. s3 = t3
  17177. }
  17178. t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
  17179. t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
  17180. t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
  17181. t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
  17182. t0 = t0 >>> 0
  17183. t1 = t1 >>> 0
  17184. t2 = t2 >>> 0
  17185. t3 = t3 >>> 0
  17186. return [t0, t1, t2, t3]
  17187. }
  17188. // AES constants
  17189. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
  17190. var G = (function () {
  17191. // Compute double table
  17192. var d = new Array(256)
  17193. for (var j = 0; j < 256; j++) {
  17194. if (j < 128) {
  17195. d[j] = j << 1
  17196. } else {
  17197. d[j] = (j << 1) ^ 0x11b
  17198. }
  17199. }
  17200. var SBOX = []
  17201. var INV_SBOX = []
  17202. var SUB_MIX = [[], [], [], []]
  17203. var INV_SUB_MIX = [[], [], [], []]
  17204. // Walk GF(2^8)
  17205. var x = 0
  17206. var xi = 0
  17207. for (var i = 0; i < 256; ++i) {
  17208. // Compute sbox
  17209. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
  17210. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
  17211. SBOX[x] = sx
  17212. INV_SBOX[sx] = x
  17213. // Compute multiplication
  17214. var x2 = d[x]
  17215. var x4 = d[x2]
  17216. var x8 = d[x4]
  17217. // Compute sub bytes, mix columns tables
  17218. var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
  17219. SUB_MIX[0][x] = (t << 24) | (t >>> 8)
  17220. SUB_MIX[1][x] = (t << 16) | (t >>> 16)
  17221. SUB_MIX[2][x] = (t << 8) | (t >>> 24)
  17222. SUB_MIX[3][x] = t
  17223. // Compute inv sub bytes, inv mix columns tables
  17224. t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
  17225. INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
  17226. INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
  17227. INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
  17228. INV_SUB_MIX[3][sx] = t
  17229. if (x === 0) {
  17230. x = xi = 1
  17231. } else {
  17232. x = x2 ^ d[d[d[x8 ^ x2]]]
  17233. xi ^= d[d[xi]]
  17234. }
  17235. }
  17236. return {
  17237. SBOX: SBOX,
  17238. INV_SBOX: INV_SBOX,
  17239. SUB_MIX: SUB_MIX,
  17240. INV_SUB_MIX: INV_SUB_MIX
  17241. }
  17242. })()
  17243. function AES (key) {
  17244. this._key = asUInt32Array(key)
  17245. this._reset()
  17246. }
  17247. AES.blockSize = 4 * 4
  17248. AES.keySize = 256 / 8
  17249. AES.prototype.blockSize = AES.blockSize
  17250. AES.prototype.keySize = AES.keySize
  17251. AES.prototype._reset = function () {
  17252. var keyWords = this._key
  17253. var keySize = keyWords.length
  17254. var nRounds = keySize + 6
  17255. var ksRows = (nRounds + 1) * 4
  17256. var keySchedule = []
  17257. for (var k = 0; k < keySize; k++) {
  17258. keySchedule[k] = keyWords[k]
  17259. }
  17260. for (k = keySize; k < ksRows; k++) {
  17261. var t = keySchedule[k - 1]
  17262. if (k % keySize === 0) {
  17263. t = (t << 8) | (t >>> 24)
  17264. t =
  17265. (G.SBOX[t >>> 24] << 24) |
  17266. (G.SBOX[(t >>> 16) & 0xff] << 16) |
  17267. (G.SBOX[(t >>> 8) & 0xff] << 8) |
  17268. (G.SBOX[t & 0xff])
  17269. t ^= RCON[(k / keySize) | 0] << 24
  17270. } else if (keySize > 6 && k % keySize === 4) {
  17271. t =
  17272. (G.SBOX[t >>> 24] << 24) |
  17273. (G.SBOX[(t >>> 16) & 0xff] << 16) |
  17274. (G.SBOX[(t >>> 8) & 0xff] << 8) |
  17275. (G.SBOX[t & 0xff])
  17276. }
  17277. keySchedule[k] = keySchedule[k - keySize] ^ t
  17278. }
  17279. var invKeySchedule = []
  17280. for (var ik = 0; ik < ksRows; ik++) {
  17281. var ksR = ksRows - ik
  17282. var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
  17283. if (ik < 4 || ksR <= 4) {
  17284. invKeySchedule[ik] = tt
  17285. } else {
  17286. invKeySchedule[ik] =
  17287. G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
  17288. G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
  17289. G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
  17290. G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
  17291. }
  17292. }
  17293. this._nRounds = nRounds
  17294. this._keySchedule = keySchedule
  17295. this._invKeySchedule = invKeySchedule
  17296. }
  17297. AES.prototype.encryptBlockRaw = function (M) {
  17298. M = asUInt32Array(M)
  17299. return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
  17300. }
  17301. AES.prototype.encryptBlock = function (M) {
  17302. var out = this.encryptBlockRaw(M)
  17303. var buf = Buffer.allocUnsafe(16)
  17304. buf.writeUInt32BE(out[0], 0)
  17305. buf.writeUInt32BE(out[1], 4)
  17306. buf.writeUInt32BE(out[2], 8)
  17307. buf.writeUInt32BE(out[3], 12)
  17308. return buf
  17309. }
  17310. AES.prototype.decryptBlock = function (M) {
  17311. M = asUInt32Array(M)
  17312. // swap
  17313. var m1 = M[1]
  17314. M[1] = M[3]
  17315. M[3] = m1
  17316. var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
  17317. var buf = Buffer.allocUnsafe(16)
  17318. buf.writeUInt32BE(out[0], 0)
  17319. buf.writeUInt32BE(out[3], 4)
  17320. buf.writeUInt32BE(out[2], 8)
  17321. buf.writeUInt32BE(out[1], 12)
  17322. return buf
  17323. }
  17324. AES.prototype.scrub = function () {
  17325. scrubVec(this._keySchedule)
  17326. scrubVec(this._invKeySchedule)
  17327. scrubVec(this._key)
  17328. }
  17329. module.exports.AES = AES
  17330. /***/ }),
  17331. /***/ "./node_modules/browserify-aes/authCipher.js":
  17332. /*!***************************************************!*\
  17333. !*** ./node_modules/browserify-aes/authCipher.js ***!
  17334. \***************************************************/
  17335. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  17336. var aes = __webpack_require__(/*! ./aes */ "./node_modules/browserify-aes/aes.js")
  17337. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17338. var Transform = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  17339. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  17340. var GHASH = __webpack_require__(/*! ./ghash */ "./node_modules/browserify-aes/ghash.js")
  17341. var xor = __webpack_require__(/*! buffer-xor */ "./node_modules/buffer-xor/index.js")
  17342. var incr32 = __webpack_require__(/*! ./incr32 */ "./node_modules/browserify-aes/incr32.js")
  17343. function xorTest (a, b) {
  17344. var out = 0
  17345. if (a.length !== b.length) out++
  17346. var len = Math.min(a.length, b.length)
  17347. for (var i = 0; i < len; ++i) {
  17348. out += (a[i] ^ b[i])
  17349. }
  17350. return out
  17351. }
  17352. function calcIv (self, iv, ck) {
  17353. if (iv.length === 12) {
  17354. self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
  17355. return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
  17356. }
  17357. var ghash = new GHASH(ck)
  17358. var len = iv.length
  17359. var toPad = len % 16
  17360. ghash.update(iv)
  17361. if (toPad) {
  17362. toPad = 16 - toPad
  17363. ghash.update(Buffer.alloc(toPad, 0))
  17364. }
  17365. ghash.update(Buffer.alloc(8, 0))
  17366. var ivBits = len * 8
  17367. var tail = Buffer.alloc(8)
  17368. tail.writeUIntBE(ivBits, 0, 8)
  17369. ghash.update(tail)
  17370. self._finID = ghash.state
  17371. var out = Buffer.from(self._finID)
  17372. incr32(out)
  17373. return out
  17374. }
  17375. function StreamCipher (mode, key, iv, decrypt) {
  17376. Transform.call(this)
  17377. var h = Buffer.alloc(4, 0)
  17378. this._cipher = new aes.AES(key)
  17379. var ck = this._cipher.encryptBlock(h)
  17380. this._ghash = new GHASH(ck)
  17381. iv = calcIv(this, iv, ck)
  17382. this._prev = Buffer.from(iv)
  17383. this._cache = Buffer.allocUnsafe(0)
  17384. this._secCache = Buffer.allocUnsafe(0)
  17385. this._decrypt = decrypt
  17386. this._alen = 0
  17387. this._len = 0
  17388. this._mode = mode
  17389. this._authTag = null
  17390. this._called = false
  17391. }
  17392. inherits(StreamCipher, Transform)
  17393. StreamCipher.prototype._update = function (chunk) {
  17394. if (!this._called && this._alen) {
  17395. var rump = 16 - (this._alen % 16)
  17396. if (rump < 16) {
  17397. rump = Buffer.alloc(rump, 0)
  17398. this._ghash.update(rump)
  17399. }
  17400. }
  17401. this._called = true
  17402. var out = this._mode.encrypt(this, chunk)
  17403. if (this._decrypt) {
  17404. this._ghash.update(chunk)
  17405. } else {
  17406. this._ghash.update(out)
  17407. }
  17408. this._len += chunk.length
  17409. return out
  17410. }
  17411. StreamCipher.prototype._final = function () {
  17412. if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
  17413. var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
  17414. if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
  17415. this._authTag = tag
  17416. this._cipher.scrub()
  17417. }
  17418. StreamCipher.prototype.getAuthTag = function getAuthTag () {
  17419. if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
  17420. return this._authTag
  17421. }
  17422. StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
  17423. if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
  17424. this._authTag = tag
  17425. }
  17426. StreamCipher.prototype.setAAD = function setAAD (buf) {
  17427. if (this._called) throw new Error('Attempting to set AAD in unsupported state')
  17428. this._ghash.update(buf)
  17429. this._alen += buf.length
  17430. }
  17431. module.exports = StreamCipher
  17432. /***/ }),
  17433. /***/ "./node_modules/browserify-aes/browser.js":
  17434. /*!************************************************!*\
  17435. !*** ./node_modules/browserify-aes/browser.js ***!
  17436. \************************************************/
  17437. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17438. var ciphers = __webpack_require__(/*! ./encrypter */ "./node_modules/browserify-aes/encrypter.js")
  17439. var deciphers = __webpack_require__(/*! ./decrypter */ "./node_modules/browserify-aes/decrypter.js")
  17440. var modes = __webpack_require__(/*! ./modes/list.json */ "./node_modules/browserify-aes/modes/list.json")
  17441. function getCiphers () {
  17442. return Object.keys(modes)
  17443. }
  17444. exports.createCipher = exports.Cipher = ciphers.createCipher
  17445. exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
  17446. exports.createDecipher = exports.Decipher = deciphers.createDecipher
  17447. exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
  17448. exports.listCiphers = exports.getCiphers = getCiphers
  17449. /***/ }),
  17450. /***/ "./node_modules/browserify-aes/decrypter.js":
  17451. /*!**************************************************!*\
  17452. !*** ./node_modules/browserify-aes/decrypter.js ***!
  17453. \**************************************************/
  17454. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17455. var AuthCipher = __webpack_require__(/*! ./authCipher */ "./node_modules/browserify-aes/authCipher.js")
  17456. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17457. var MODES = __webpack_require__(/*! ./modes */ "./node_modules/browserify-aes/modes/index.js")
  17458. var StreamCipher = __webpack_require__(/*! ./streamCipher */ "./node_modules/browserify-aes/streamCipher.js")
  17459. var Transform = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  17460. var aes = __webpack_require__(/*! ./aes */ "./node_modules/browserify-aes/aes.js")
  17461. var ebtk = __webpack_require__(/*! evp_bytestokey */ "./node_modules/evp_bytestokey/index.js")
  17462. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  17463. function Decipher (mode, key, iv) {
  17464. Transform.call(this)
  17465. this._cache = new Splitter()
  17466. this._last = void 0
  17467. this._cipher = new aes.AES(key)
  17468. this._prev = Buffer.from(iv)
  17469. this._mode = mode
  17470. this._autopadding = true
  17471. }
  17472. inherits(Decipher, Transform)
  17473. Decipher.prototype._update = function (data) {
  17474. this._cache.add(data)
  17475. var chunk
  17476. var thing
  17477. var out = []
  17478. while ((chunk = this._cache.get(this._autopadding))) {
  17479. thing = this._mode.decrypt(this, chunk)
  17480. out.push(thing)
  17481. }
  17482. return Buffer.concat(out)
  17483. }
  17484. Decipher.prototype._final = function () {
  17485. var chunk = this._cache.flush()
  17486. if (this._autopadding) {
  17487. return unpad(this._mode.decrypt(this, chunk))
  17488. } else if (chunk) {
  17489. throw new Error('data not multiple of block length')
  17490. }
  17491. }
  17492. Decipher.prototype.setAutoPadding = function (setTo) {
  17493. this._autopadding = !!setTo
  17494. return this
  17495. }
  17496. function Splitter () {
  17497. this.cache = Buffer.allocUnsafe(0)
  17498. }
  17499. Splitter.prototype.add = function (data) {
  17500. this.cache = Buffer.concat([this.cache, data])
  17501. }
  17502. Splitter.prototype.get = function (autoPadding) {
  17503. var out
  17504. if (autoPadding) {
  17505. if (this.cache.length > 16) {
  17506. out = this.cache.slice(0, 16)
  17507. this.cache = this.cache.slice(16)
  17508. return out
  17509. }
  17510. } else {
  17511. if (this.cache.length >= 16) {
  17512. out = this.cache.slice(0, 16)
  17513. this.cache = this.cache.slice(16)
  17514. return out
  17515. }
  17516. }
  17517. return null
  17518. }
  17519. Splitter.prototype.flush = function () {
  17520. if (this.cache.length) return this.cache
  17521. }
  17522. function unpad (last) {
  17523. var padded = last[15]
  17524. if (padded < 1 || padded > 16) {
  17525. throw new Error('unable to decrypt data')
  17526. }
  17527. var i = -1
  17528. while (++i < padded) {
  17529. if (last[(i + (16 - padded))] !== padded) {
  17530. throw new Error('unable to decrypt data')
  17531. }
  17532. }
  17533. if (padded === 16) return
  17534. return last.slice(0, 16 - padded)
  17535. }
  17536. function createDecipheriv (suite, password, iv) {
  17537. var config = MODES[suite.toLowerCase()]
  17538. if (!config) throw new TypeError('invalid suite type')
  17539. if (typeof iv === 'string') iv = Buffer.from(iv)
  17540. if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
  17541. if (typeof password === 'string') password = Buffer.from(password)
  17542. if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
  17543. if (config.type === 'stream') {
  17544. return new StreamCipher(config.module, password, iv, true)
  17545. } else if (config.type === 'auth') {
  17546. return new AuthCipher(config.module, password, iv, true)
  17547. }
  17548. return new Decipher(config.module, password, iv)
  17549. }
  17550. function createDecipher (suite, password) {
  17551. var config = MODES[suite.toLowerCase()]
  17552. if (!config) throw new TypeError('invalid suite type')
  17553. var keys = ebtk(password, false, config.key, config.iv)
  17554. return createDecipheriv(suite, keys.key, keys.iv)
  17555. }
  17556. exports.createDecipher = createDecipher
  17557. exports.createDecipheriv = createDecipheriv
  17558. /***/ }),
  17559. /***/ "./node_modules/browserify-aes/encrypter.js":
  17560. /*!**************************************************!*\
  17561. !*** ./node_modules/browserify-aes/encrypter.js ***!
  17562. \**************************************************/
  17563. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17564. var MODES = __webpack_require__(/*! ./modes */ "./node_modules/browserify-aes/modes/index.js")
  17565. var AuthCipher = __webpack_require__(/*! ./authCipher */ "./node_modules/browserify-aes/authCipher.js")
  17566. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17567. var StreamCipher = __webpack_require__(/*! ./streamCipher */ "./node_modules/browserify-aes/streamCipher.js")
  17568. var Transform = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  17569. var aes = __webpack_require__(/*! ./aes */ "./node_modules/browserify-aes/aes.js")
  17570. var ebtk = __webpack_require__(/*! evp_bytestokey */ "./node_modules/evp_bytestokey/index.js")
  17571. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  17572. function Cipher (mode, key, iv) {
  17573. Transform.call(this)
  17574. this._cache = new Splitter()
  17575. this._cipher = new aes.AES(key)
  17576. this._prev = Buffer.from(iv)
  17577. this._mode = mode
  17578. this._autopadding = true
  17579. }
  17580. inherits(Cipher, Transform)
  17581. Cipher.prototype._update = function (data) {
  17582. this._cache.add(data)
  17583. var chunk
  17584. var thing
  17585. var out = []
  17586. while ((chunk = this._cache.get())) {
  17587. thing = this._mode.encrypt(this, chunk)
  17588. out.push(thing)
  17589. }
  17590. return Buffer.concat(out)
  17591. }
  17592. var PADDING = Buffer.alloc(16, 0x10)
  17593. Cipher.prototype._final = function () {
  17594. var chunk = this._cache.flush()
  17595. if (this._autopadding) {
  17596. chunk = this._mode.encrypt(this, chunk)
  17597. this._cipher.scrub()
  17598. return chunk
  17599. }
  17600. if (!chunk.equals(PADDING)) {
  17601. this._cipher.scrub()
  17602. throw new Error('data not multiple of block length')
  17603. }
  17604. }
  17605. Cipher.prototype.setAutoPadding = function (setTo) {
  17606. this._autopadding = !!setTo
  17607. return this
  17608. }
  17609. function Splitter () {
  17610. this.cache = Buffer.allocUnsafe(0)
  17611. }
  17612. Splitter.prototype.add = function (data) {
  17613. this.cache = Buffer.concat([this.cache, data])
  17614. }
  17615. Splitter.prototype.get = function () {
  17616. if (this.cache.length > 15) {
  17617. var out = this.cache.slice(0, 16)
  17618. this.cache = this.cache.slice(16)
  17619. return out
  17620. }
  17621. return null
  17622. }
  17623. Splitter.prototype.flush = function () {
  17624. var len = 16 - this.cache.length
  17625. var padBuff = Buffer.allocUnsafe(len)
  17626. var i = -1
  17627. while (++i < len) {
  17628. padBuff.writeUInt8(len, i)
  17629. }
  17630. return Buffer.concat([this.cache, padBuff])
  17631. }
  17632. function createCipheriv (suite, password, iv) {
  17633. var config = MODES[suite.toLowerCase()]
  17634. if (!config) throw new TypeError('invalid suite type')
  17635. if (typeof password === 'string') password = Buffer.from(password)
  17636. if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
  17637. if (typeof iv === 'string') iv = Buffer.from(iv)
  17638. if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
  17639. if (config.type === 'stream') {
  17640. return new StreamCipher(config.module, password, iv)
  17641. } else if (config.type === 'auth') {
  17642. return new AuthCipher(config.module, password, iv)
  17643. }
  17644. return new Cipher(config.module, password, iv)
  17645. }
  17646. function createCipher (suite, password) {
  17647. var config = MODES[suite.toLowerCase()]
  17648. if (!config) throw new TypeError('invalid suite type')
  17649. var keys = ebtk(password, false, config.key, config.iv)
  17650. return createCipheriv(suite, keys.key, keys.iv)
  17651. }
  17652. exports.createCipheriv = createCipheriv
  17653. exports.createCipher = createCipher
  17654. /***/ }),
  17655. /***/ "./node_modules/browserify-aes/ghash.js":
  17656. /*!**********************************************!*\
  17657. !*** ./node_modules/browserify-aes/ghash.js ***!
  17658. \**********************************************/
  17659. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  17660. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17661. var ZEROES = Buffer.alloc(16, 0)
  17662. function toArray (buf) {
  17663. return [
  17664. buf.readUInt32BE(0),
  17665. buf.readUInt32BE(4),
  17666. buf.readUInt32BE(8),
  17667. buf.readUInt32BE(12)
  17668. ]
  17669. }
  17670. function fromArray (out) {
  17671. var buf = Buffer.allocUnsafe(16)
  17672. buf.writeUInt32BE(out[0] >>> 0, 0)
  17673. buf.writeUInt32BE(out[1] >>> 0, 4)
  17674. buf.writeUInt32BE(out[2] >>> 0, 8)
  17675. buf.writeUInt32BE(out[3] >>> 0, 12)
  17676. return buf
  17677. }
  17678. function GHASH (key) {
  17679. this.h = key
  17680. this.state = Buffer.alloc(16, 0)
  17681. this.cache = Buffer.allocUnsafe(0)
  17682. }
  17683. // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
  17684. // by Juho Vähä-Herttua
  17685. GHASH.prototype.ghash = function (block) {
  17686. var i = -1
  17687. while (++i < block.length) {
  17688. this.state[i] ^= block[i]
  17689. }
  17690. this._multiply()
  17691. }
  17692. GHASH.prototype._multiply = function () {
  17693. var Vi = toArray(this.h)
  17694. var Zi = [0, 0, 0, 0]
  17695. var j, xi, lsbVi
  17696. var i = -1
  17697. while (++i < 128) {
  17698. xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
  17699. if (xi) {
  17700. // Z_i+1 = Z_i ^ V_i
  17701. Zi[0] ^= Vi[0]
  17702. Zi[1] ^= Vi[1]
  17703. Zi[2] ^= Vi[2]
  17704. Zi[3] ^= Vi[3]
  17705. }
  17706. // Store the value of LSB(V_i)
  17707. lsbVi = (Vi[3] & 1) !== 0
  17708. // V_i+1 = V_i >> 1
  17709. for (j = 3; j > 0; j--) {
  17710. Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
  17711. }
  17712. Vi[0] = Vi[0] >>> 1
  17713. // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
  17714. if (lsbVi) {
  17715. Vi[0] = Vi[0] ^ (0xe1 << 24)
  17716. }
  17717. }
  17718. this.state = fromArray(Zi)
  17719. }
  17720. GHASH.prototype.update = function (buf) {
  17721. this.cache = Buffer.concat([this.cache, buf])
  17722. var chunk
  17723. while (this.cache.length >= 16) {
  17724. chunk = this.cache.slice(0, 16)
  17725. this.cache = this.cache.slice(16)
  17726. this.ghash(chunk)
  17727. }
  17728. }
  17729. GHASH.prototype.final = function (abl, bl) {
  17730. if (this.cache.length) {
  17731. this.ghash(Buffer.concat([this.cache, ZEROES], 16))
  17732. }
  17733. this.ghash(fromArray([0, abl, 0, bl]))
  17734. return this.state
  17735. }
  17736. module.exports = GHASH
  17737. /***/ }),
  17738. /***/ "./node_modules/browserify-aes/incr32.js":
  17739. /*!***********************************************!*\
  17740. !*** ./node_modules/browserify-aes/incr32.js ***!
  17741. \***********************************************/
  17742. /***/ ((module) => {
  17743. function incr32 (iv) {
  17744. var len = iv.length
  17745. var item
  17746. while (len--) {
  17747. item = iv.readUInt8(len)
  17748. if (item === 255) {
  17749. iv.writeUInt8(0, len)
  17750. } else {
  17751. item++
  17752. iv.writeUInt8(item, len)
  17753. break
  17754. }
  17755. }
  17756. }
  17757. module.exports = incr32
  17758. /***/ }),
  17759. /***/ "./node_modules/browserify-aes/modes/cbc.js":
  17760. /*!**************************************************!*\
  17761. !*** ./node_modules/browserify-aes/modes/cbc.js ***!
  17762. \**************************************************/
  17763. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17764. var xor = __webpack_require__(/*! buffer-xor */ "./node_modules/buffer-xor/index.js")
  17765. exports.encrypt = function (self, block) {
  17766. var data = xor(block, self._prev)
  17767. self._prev = self._cipher.encryptBlock(data)
  17768. return self._prev
  17769. }
  17770. exports.decrypt = function (self, block) {
  17771. var pad = self._prev
  17772. self._prev = block
  17773. var out = self._cipher.decryptBlock(block)
  17774. return xor(out, pad)
  17775. }
  17776. /***/ }),
  17777. /***/ "./node_modules/browserify-aes/modes/cfb.js":
  17778. /*!**************************************************!*\
  17779. !*** ./node_modules/browserify-aes/modes/cfb.js ***!
  17780. \**************************************************/
  17781. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17782. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17783. var xor = __webpack_require__(/*! buffer-xor */ "./node_modules/buffer-xor/index.js")
  17784. function encryptStart (self, data, decrypt) {
  17785. var len = data.length
  17786. var out = xor(data, self._cache)
  17787. self._cache = self._cache.slice(len)
  17788. self._prev = Buffer.concat([self._prev, decrypt ? data : out])
  17789. return out
  17790. }
  17791. exports.encrypt = function (self, data, decrypt) {
  17792. var out = Buffer.allocUnsafe(0)
  17793. var len
  17794. while (data.length) {
  17795. if (self._cache.length === 0) {
  17796. self._cache = self._cipher.encryptBlock(self._prev)
  17797. self._prev = Buffer.allocUnsafe(0)
  17798. }
  17799. if (self._cache.length <= data.length) {
  17800. len = self._cache.length
  17801. out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
  17802. data = data.slice(len)
  17803. } else {
  17804. out = Buffer.concat([out, encryptStart(self, data, decrypt)])
  17805. break
  17806. }
  17807. }
  17808. return out
  17809. }
  17810. /***/ }),
  17811. /***/ "./node_modules/browserify-aes/modes/cfb1.js":
  17812. /*!***************************************************!*\
  17813. !*** ./node_modules/browserify-aes/modes/cfb1.js ***!
  17814. \***************************************************/
  17815. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17816. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17817. function encryptByte (self, byteParam, decrypt) {
  17818. var pad
  17819. var i = -1
  17820. var len = 8
  17821. var out = 0
  17822. var bit, value
  17823. while (++i < len) {
  17824. pad = self._cipher.encryptBlock(self._prev)
  17825. bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
  17826. value = pad[0] ^ bit
  17827. out += ((value & 0x80) >> (i % 8))
  17828. self._prev = shiftIn(self._prev, decrypt ? bit : value)
  17829. }
  17830. return out
  17831. }
  17832. function shiftIn (buffer, value) {
  17833. var len = buffer.length
  17834. var i = -1
  17835. var out = Buffer.allocUnsafe(buffer.length)
  17836. buffer = Buffer.concat([buffer, Buffer.from([value])])
  17837. while (++i < len) {
  17838. out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
  17839. }
  17840. return out
  17841. }
  17842. exports.encrypt = function (self, chunk, decrypt) {
  17843. var len = chunk.length
  17844. var out = Buffer.allocUnsafe(len)
  17845. var i = -1
  17846. while (++i < len) {
  17847. out[i] = encryptByte(self, chunk[i], decrypt)
  17848. }
  17849. return out
  17850. }
  17851. /***/ }),
  17852. /***/ "./node_modules/browserify-aes/modes/cfb8.js":
  17853. /*!***************************************************!*\
  17854. !*** ./node_modules/browserify-aes/modes/cfb8.js ***!
  17855. \***************************************************/
  17856. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17857. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17858. function encryptByte (self, byteParam, decrypt) {
  17859. var pad = self._cipher.encryptBlock(self._prev)
  17860. var out = pad[0] ^ byteParam
  17861. self._prev = Buffer.concat([
  17862. self._prev.slice(1),
  17863. Buffer.from([decrypt ? byteParam : out])
  17864. ])
  17865. return out
  17866. }
  17867. exports.encrypt = function (self, chunk, decrypt) {
  17868. var len = chunk.length
  17869. var out = Buffer.allocUnsafe(len)
  17870. var i = -1
  17871. while (++i < len) {
  17872. out[i] = encryptByte(self, chunk[i], decrypt)
  17873. }
  17874. return out
  17875. }
  17876. /***/ }),
  17877. /***/ "./node_modules/browserify-aes/modes/ctr.js":
  17878. /*!**************************************************!*\
  17879. !*** ./node_modules/browserify-aes/modes/ctr.js ***!
  17880. \**************************************************/
  17881. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17882. var xor = __webpack_require__(/*! buffer-xor */ "./node_modules/buffer-xor/index.js")
  17883. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17884. var incr32 = __webpack_require__(/*! ../incr32 */ "./node_modules/browserify-aes/incr32.js")
  17885. function getBlock (self) {
  17886. var out = self._cipher.encryptBlockRaw(self._prev)
  17887. incr32(self._prev)
  17888. return out
  17889. }
  17890. var blockSize = 16
  17891. exports.encrypt = function (self, chunk) {
  17892. var chunkNum = Math.ceil(chunk.length / blockSize)
  17893. var start = self._cache.length
  17894. self._cache = Buffer.concat([
  17895. self._cache,
  17896. Buffer.allocUnsafe(chunkNum * blockSize)
  17897. ])
  17898. for (var i = 0; i < chunkNum; i++) {
  17899. var out = getBlock(self)
  17900. var offset = start + i * blockSize
  17901. self._cache.writeUInt32BE(out[0], offset + 0)
  17902. self._cache.writeUInt32BE(out[1], offset + 4)
  17903. self._cache.writeUInt32BE(out[2], offset + 8)
  17904. self._cache.writeUInt32BE(out[3], offset + 12)
  17905. }
  17906. var pad = self._cache.slice(0, chunk.length)
  17907. self._cache = self._cache.slice(chunk.length)
  17908. return xor(chunk, pad)
  17909. }
  17910. /***/ }),
  17911. /***/ "./node_modules/browserify-aes/modes/ecb.js":
  17912. /*!**************************************************!*\
  17913. !*** ./node_modules/browserify-aes/modes/ecb.js ***!
  17914. \**************************************************/
  17915. /***/ ((__unused_webpack_module, exports) => {
  17916. exports.encrypt = function (self, block) {
  17917. return self._cipher.encryptBlock(block)
  17918. }
  17919. exports.decrypt = function (self, block) {
  17920. return self._cipher.decryptBlock(block)
  17921. }
  17922. /***/ }),
  17923. /***/ "./node_modules/browserify-aes/modes/index.js":
  17924. /*!****************************************************!*\
  17925. !*** ./node_modules/browserify-aes/modes/index.js ***!
  17926. \****************************************************/
  17927. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  17928. var modeModules = {
  17929. ECB: __webpack_require__(/*! ./ecb */ "./node_modules/browserify-aes/modes/ecb.js"),
  17930. CBC: __webpack_require__(/*! ./cbc */ "./node_modules/browserify-aes/modes/cbc.js"),
  17931. CFB: __webpack_require__(/*! ./cfb */ "./node_modules/browserify-aes/modes/cfb.js"),
  17932. CFB8: __webpack_require__(/*! ./cfb8 */ "./node_modules/browserify-aes/modes/cfb8.js"),
  17933. CFB1: __webpack_require__(/*! ./cfb1 */ "./node_modules/browserify-aes/modes/cfb1.js"),
  17934. OFB: __webpack_require__(/*! ./ofb */ "./node_modules/browserify-aes/modes/ofb.js"),
  17935. CTR: __webpack_require__(/*! ./ctr */ "./node_modules/browserify-aes/modes/ctr.js"),
  17936. GCM: __webpack_require__(/*! ./ctr */ "./node_modules/browserify-aes/modes/ctr.js")
  17937. }
  17938. var modes = __webpack_require__(/*! ./list.json */ "./node_modules/browserify-aes/modes/list.json")
  17939. for (var key in modes) {
  17940. modes[key].module = modeModules[modes[key].mode]
  17941. }
  17942. module.exports = modes
  17943. /***/ }),
  17944. /***/ "./node_modules/browserify-aes/modes/ofb.js":
  17945. /*!**************************************************!*\
  17946. !*** ./node_modules/browserify-aes/modes/ofb.js ***!
  17947. \**************************************************/
  17948. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17949. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
  17950. var xor = __webpack_require__(/*! buffer-xor */ "./node_modules/buffer-xor/index.js")
  17951. function getBlock (self) {
  17952. self._prev = self._cipher.encryptBlock(self._prev)
  17953. return self._prev
  17954. }
  17955. exports.encrypt = function (self, chunk) {
  17956. while (self._cache.length < chunk.length) {
  17957. self._cache = Buffer.concat([self._cache, getBlock(self)])
  17958. }
  17959. var pad = self._cache.slice(0, chunk.length)
  17960. self._cache = self._cache.slice(chunk.length)
  17961. return xor(chunk, pad)
  17962. }
  17963. /***/ }),
  17964. /***/ "./node_modules/browserify-aes/streamCipher.js":
  17965. /*!*****************************************************!*\
  17966. !*** ./node_modules/browserify-aes/streamCipher.js ***!
  17967. \*****************************************************/
  17968. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  17969. var aes = __webpack_require__(/*! ./aes */ "./node_modules/browserify-aes/aes.js")
  17970. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  17971. var Transform = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  17972. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  17973. function StreamCipher (mode, key, iv, decrypt) {
  17974. Transform.call(this)
  17975. this._cipher = new aes.AES(key)
  17976. this._prev = Buffer.from(iv)
  17977. this._cache = Buffer.allocUnsafe(0)
  17978. this._secCache = Buffer.allocUnsafe(0)
  17979. this._decrypt = decrypt
  17980. this._mode = mode
  17981. }
  17982. inherits(StreamCipher, Transform)
  17983. StreamCipher.prototype._update = function (chunk) {
  17984. return this._mode.encrypt(this, chunk, this._decrypt)
  17985. }
  17986. StreamCipher.prototype._final = function () {
  17987. this._cipher.scrub()
  17988. }
  17989. module.exports = StreamCipher
  17990. /***/ }),
  17991. /***/ "./node_modules/browserify-cipher/browser.js":
  17992. /*!***************************************************!*\
  17993. !*** ./node_modules/browserify-cipher/browser.js ***!
  17994. \***************************************************/
  17995. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  17996. var DES = __webpack_require__(/*! browserify-des */ "./node_modules/browserify-des/index.js")
  17997. var aes = __webpack_require__(/*! browserify-aes/browser */ "./node_modules/browserify-aes/browser.js")
  17998. var aesModes = __webpack_require__(/*! browserify-aes/modes */ "./node_modules/browserify-aes/modes/index.js")
  17999. var desModes = __webpack_require__(/*! browserify-des/modes */ "./node_modules/browserify-des/modes.js")
  18000. var ebtk = __webpack_require__(/*! evp_bytestokey */ "./node_modules/evp_bytestokey/index.js")
  18001. function createCipher (suite, password) {
  18002. suite = suite.toLowerCase()
  18003. var keyLen, ivLen
  18004. if (aesModes[suite]) {
  18005. keyLen = aesModes[suite].key
  18006. ivLen = aesModes[suite].iv
  18007. } else if (desModes[suite]) {
  18008. keyLen = desModes[suite].key * 8
  18009. ivLen = desModes[suite].iv
  18010. } else {
  18011. throw new TypeError('invalid suite type')
  18012. }
  18013. var keys = ebtk(password, false, keyLen, ivLen)
  18014. return createCipheriv(suite, keys.key, keys.iv)
  18015. }
  18016. function createDecipher (suite, password) {
  18017. suite = suite.toLowerCase()
  18018. var keyLen, ivLen
  18019. if (aesModes[suite]) {
  18020. keyLen = aesModes[suite].key
  18021. ivLen = aesModes[suite].iv
  18022. } else if (desModes[suite]) {
  18023. keyLen = desModes[suite].key * 8
  18024. ivLen = desModes[suite].iv
  18025. } else {
  18026. throw new TypeError('invalid suite type')
  18027. }
  18028. var keys = ebtk(password, false, keyLen, ivLen)
  18029. return createDecipheriv(suite, keys.key, keys.iv)
  18030. }
  18031. function createCipheriv (suite, key, iv) {
  18032. suite = suite.toLowerCase()
  18033. if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)
  18034. if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })
  18035. throw new TypeError('invalid suite type')
  18036. }
  18037. function createDecipheriv (suite, key, iv) {
  18038. suite = suite.toLowerCase()
  18039. if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
  18040. if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
  18041. throw new TypeError('invalid suite type')
  18042. }
  18043. function getCiphers () {
  18044. return Object.keys(desModes).concat(aes.getCiphers())
  18045. }
  18046. exports.createCipher = exports.Cipher = createCipher
  18047. exports.createCipheriv = exports.Cipheriv = createCipheriv
  18048. exports.createDecipher = exports.Decipher = createDecipher
  18049. exports.createDecipheriv = exports.Decipheriv = createDecipheriv
  18050. exports.listCiphers = exports.getCiphers = getCiphers
  18051. /***/ }),
  18052. /***/ "./node_modules/browserify-des/index.js":
  18053. /*!**********************************************!*\
  18054. !*** ./node_modules/browserify-des/index.js ***!
  18055. \**********************************************/
  18056. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18057. var CipherBase = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  18058. var des = __webpack_require__(/*! des.js */ "./node_modules/des.js/lib/des.js")
  18059. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  18060. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  18061. var modes = {
  18062. 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
  18063. 'des-ede3': des.EDE,
  18064. 'des-ede-cbc': des.CBC.instantiate(des.EDE),
  18065. 'des-ede': des.EDE,
  18066. 'des-cbc': des.CBC.instantiate(des.DES),
  18067. 'des-ecb': des.DES
  18068. }
  18069. modes.des = modes['des-cbc']
  18070. modes.des3 = modes['des-ede3-cbc']
  18071. module.exports = DES
  18072. inherits(DES, CipherBase)
  18073. function DES (opts) {
  18074. CipherBase.call(this)
  18075. var modeName = opts.mode.toLowerCase()
  18076. var mode = modes[modeName]
  18077. var type
  18078. if (opts.decrypt) {
  18079. type = 'decrypt'
  18080. } else {
  18081. type = 'encrypt'
  18082. }
  18083. var key = opts.key
  18084. if (!Buffer.isBuffer(key)) {
  18085. key = Buffer.from(key)
  18086. }
  18087. if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
  18088. key = Buffer.concat([key, key.slice(0, 8)])
  18089. }
  18090. var iv = opts.iv
  18091. if (!Buffer.isBuffer(iv)) {
  18092. iv = Buffer.from(iv)
  18093. }
  18094. this._des = mode.create({
  18095. key: key,
  18096. iv: iv,
  18097. type: type
  18098. })
  18099. }
  18100. DES.prototype._update = function (data) {
  18101. return Buffer.from(this._des.update(data))
  18102. }
  18103. DES.prototype._final = function () {
  18104. return Buffer.from(this._des.final())
  18105. }
  18106. /***/ }),
  18107. /***/ "./node_modules/browserify-des/modes.js":
  18108. /*!**********************************************!*\
  18109. !*** ./node_modules/browserify-des/modes.js ***!
  18110. \**********************************************/
  18111. /***/ ((__unused_webpack_module, exports) => {
  18112. exports["des-ecb"] = {
  18113. key: 8,
  18114. iv: 0
  18115. }
  18116. exports["des-cbc"] = exports.des = {
  18117. key: 8,
  18118. iv: 8
  18119. }
  18120. exports["des-ede3-cbc"] = exports.des3 = {
  18121. key: 24,
  18122. iv: 8
  18123. }
  18124. exports["des-ede3"] = {
  18125. key: 24,
  18126. iv: 0
  18127. }
  18128. exports["des-ede-cbc"] = {
  18129. key: 16,
  18130. iv: 8
  18131. }
  18132. exports["des-ede"] = {
  18133. key: 16,
  18134. iv: 0
  18135. }
  18136. /***/ }),
  18137. /***/ "./node_modules/browserify-rsa/index.js":
  18138. /*!**********************************************!*\
  18139. !*** ./node_modules/browserify-rsa/index.js ***!
  18140. \**********************************************/
  18141. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18142. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
  18143. var BN = __webpack_require__(/*! bn.js */ "./node_modules/bn.js/lib/bn.js")
  18144. var randomBytes = __webpack_require__(/*! randombytes */ "./node_modules/randombytes/browser.js")
  18145. function blind (priv) {
  18146. var r = getr(priv)
  18147. var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed()
  18148. return { blinder: blinder, unblinder: r.invm(priv.modulus) }
  18149. }
  18150. function getr (priv) {
  18151. var len = priv.modulus.byteLength()
  18152. var r
  18153. do {
  18154. r = new BN(randomBytes(len))
  18155. } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2))
  18156. return r
  18157. }
  18158. function crt (msg, priv) {
  18159. var blinds = blind(priv)
  18160. var len = priv.modulus.byteLength()
  18161. var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus)
  18162. var c1 = blinded.toRed(BN.mont(priv.prime1))
  18163. var c2 = blinded.toRed(BN.mont(priv.prime2))
  18164. var qinv = priv.coefficient
  18165. var p = priv.prime1
  18166. var q = priv.prime2
  18167. var m1 = c1.redPow(priv.exponent1).fromRed()
  18168. var m2 = c2.redPow(priv.exponent2).fromRed()
  18169. var h = m1.isub(m2).imul(qinv).umod(p).imul(q)
  18170. return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len)
  18171. }
  18172. crt.getr = getr
  18173. module.exports = crt
  18174. /***/ }),
  18175. /***/ "./node_modules/browserify-sign/algos.js":
  18176. /*!***********************************************!*\
  18177. !*** ./node_modules/browserify-sign/algos.js ***!
  18178. \***********************************************/
  18179. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18180. module.exports = __webpack_require__(/*! ./browser/algorithms.json */ "./node_modules/browserify-sign/browser/algorithms.json")
  18181. /***/ }),
  18182. /***/ "./node_modules/browserify-sign/browser/index.js":
  18183. /*!*******************************************************!*\
  18184. !*** ./node_modules/browserify-sign/browser/index.js ***!
  18185. \*******************************************************/
  18186. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18187. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/browserify-sign/node_modules/safe-buffer/index.js").Buffer)
  18188. var createHash = __webpack_require__(/*! create-hash */ "./node_modules/create-hash/browser.js")
  18189. var stream = __webpack_require__(/*! readable-stream */ "./node_modules/browserify-sign/node_modules/readable-stream/readable-browser.js")
  18190. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  18191. var sign = __webpack_require__(/*! ./sign */ "./node_modules/browserify-sign/browser/sign.js")
  18192. var verify = __webpack_require__(/*! ./verify */ "./node_modules/browserify-sign/browser/verify.js")
  18193. var algorithms = __webpack_require__(/*! ./algorithms.json */ "./node_modules/browserify-sign/browser/algorithms.json")
  18194. Object.keys(algorithms).forEach(function (key) {
  18195. algorithms[key].id = Buffer.from(algorithms[key].id, 'hex')
  18196. algorithms[key.toLowerCase()] = algorithms[key]
  18197. })
  18198. function Sign (algorithm) {
  18199. stream.Writable.call(this)
  18200. var data = algorithms[algorithm]
  18201. if (!data) throw new Error('Unknown message digest')
  18202. this._hashType = data.hash
  18203. this._hash = createHash(data.hash)
  18204. this._tag = data.id
  18205. this._signType = data.sign
  18206. }
  18207. inherits(Sign, stream.Writable)
  18208. Sign.prototype._write = function _write (data, _, done) {
  18209. this._hash.update(data)
  18210. done()
  18211. }
  18212. Sign.prototype.update = function update (data, enc) {
  18213. if (typeof data === 'string') data = Buffer.from(data, enc)
  18214. this._hash.update(data)
  18215. return this
  18216. }
  18217. Sign.prototype.sign = function signMethod (key, enc) {
  18218. this.end()
  18219. var hash = this._hash.digest()
  18220. var sig = sign(hash, key, this._hashType, this._signType, this._tag)
  18221. return enc ? sig.toString(enc) : sig
  18222. }
  18223. function Verify (algorithm) {
  18224. stream.Writable.call(this)
  18225. var data = algorithms[algorithm]
  18226. if (!data) throw new Error('Unknown message digest')
  18227. this._hash = createHash(data.hash)
  18228. this._tag = data.id
  18229. this._signType = data.sign
  18230. }
  18231. inherits(Verify, stream.Writable)
  18232. Verify.prototype._write = function _write (data, _, done) {
  18233. this._hash.update(data)
  18234. done()
  18235. }
  18236. Verify.prototype.update = function update (data, enc) {
  18237. if (typeof data === 'string') data = Buffer.from(data, enc)
  18238. this._hash.update(data)
  18239. return this
  18240. }
  18241. Verify.prototype.verify = function verifyMethod (key, sig, enc) {
  18242. if (typeof sig === 'string') sig = Buffer.from(sig, enc)
  18243. this.end()
  18244. var hash = this._hash.digest()
  18245. return verify(sig, hash, key, this._signType, this._tag)
  18246. }
  18247. function createSign (algorithm) {
  18248. return new Sign(algorithm)
  18249. }
  18250. function createVerify (algorithm) {
  18251. return new Verify(algorithm)
  18252. }
  18253. module.exports = {
  18254. Sign: createSign,
  18255. Verify: createVerify,
  18256. createSign: createSign,
  18257. createVerify: createVerify
  18258. }
  18259. /***/ }),
  18260. /***/ "./node_modules/browserify-sign/browser/sign.js":
  18261. /*!******************************************************!*\
  18262. !*** ./node_modules/browserify-sign/browser/sign.js ***!
  18263. \******************************************************/
  18264. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18265. // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  18266. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/browserify-sign/node_modules/safe-buffer/index.js").Buffer)
  18267. var createHmac = __webpack_require__(/*! create-hmac */ "./node_modules/create-hmac/browser.js")
  18268. var crt = __webpack_require__(/*! browserify-rsa */ "./node_modules/browserify-rsa/index.js")
  18269. var EC = (__webpack_require__(/*! elliptic */ "./node_modules/elliptic/lib/elliptic.js").ec)
  18270. var BN = __webpack_require__(/*! bn.js */ "./node_modules/bn.js/lib/bn.js")
  18271. var parseKeys = __webpack_require__(/*! parse-asn1 */ "./node_modules/parse-asn1/index.js")
  18272. var curves = __webpack_require__(/*! ./curves.json */ "./node_modules/browserify-sign/browser/curves.json")
  18273. function sign (hash, key, hashType, signType, tag) {
  18274. var priv = parseKeys(key)
  18275. if (priv.curve) {
  18276. // rsa keys can be interpreted as ecdsa ones in openssl
  18277. if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
  18278. return ecSign(hash, priv)
  18279. } else if (priv.type === 'dsa') {
  18280. if (signType !== 'dsa') throw new Error('wrong private key type')
  18281. return dsaSign(hash, priv, hashType)
  18282. } else {
  18283. if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
  18284. }
  18285. hash = Buffer.concat([tag, hash])
  18286. var len = priv.modulus.byteLength()
  18287. var pad = [0, 1]
  18288. while (hash.length + pad.length + 1 < len) pad.push(0xff)
  18289. pad.push(0x00)
  18290. var i = -1
  18291. while (++i < hash.length) pad.push(hash[i])
  18292. var out = crt(pad, priv)
  18293. return out
  18294. }
  18295. function ecSign (hash, priv) {
  18296. var curveId = curves[priv.curve.join('.')]
  18297. if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
  18298. var curve = new EC(curveId)
  18299. var key = curve.keyFromPrivate(priv.privateKey)
  18300. var out = key.sign(hash)
  18301. return Buffer.from(out.toDER())
  18302. }
  18303. function dsaSign (hash, priv, algo) {
  18304. var x = priv.params.priv_key
  18305. var p = priv.params.p
  18306. var q = priv.params.q
  18307. var g = priv.params.g
  18308. var r = new BN(0)
  18309. var k
  18310. var H = bits2int(hash, q).mod(q)
  18311. var s = false
  18312. var kv = getKey(x, q, hash, algo)
  18313. while (s === false) {
  18314. k = makeKey(q, kv, algo)
  18315. r = makeR(g, k, p, q)
  18316. s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
  18317. if (s.cmpn(0) === 0) {
  18318. s = false
  18319. r = new BN(0)
  18320. }
  18321. }
  18322. return toDER(r, s)
  18323. }
  18324. function toDER (r, s) {
  18325. r = r.toArray()
  18326. s = s.toArray()
  18327. // Pad values
  18328. if (r[0] & 0x80) r = [0].concat(r)
  18329. if (s[0] & 0x80) s = [0].concat(s)
  18330. var total = r.length + s.length + 4
  18331. var res = [0x30, total, 0x02, r.length]
  18332. res = res.concat(r, [0x02, s.length], s)
  18333. return Buffer.from(res)
  18334. }
  18335. function getKey (x, q, hash, algo) {
  18336. x = Buffer.from(x.toArray())
  18337. if (x.length < q.byteLength()) {
  18338. var zeros = Buffer.alloc(q.byteLength() - x.length)
  18339. x = Buffer.concat([zeros, x])
  18340. }
  18341. var hlen = hash.length
  18342. var hbits = bits2octets(hash, q)
  18343. var v = Buffer.alloc(hlen)
  18344. v.fill(1)
  18345. var k = Buffer.alloc(hlen)
  18346. k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest()
  18347. v = createHmac(algo, k).update(v).digest()
  18348. k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest()
  18349. v = createHmac(algo, k).update(v).digest()
  18350. return { k: k, v: v }
  18351. }
  18352. function bits2int (obits, q) {
  18353. var bits = new BN(obits)
  18354. var shift = (obits.length << 3) - q.bitLength()
  18355. if (shift > 0) bits.ishrn(shift)
  18356. return bits
  18357. }
  18358. function bits2octets (bits, q) {
  18359. bits = bits2int(bits, q)
  18360. bits = bits.mod(q)
  18361. var out = Buffer.from(bits.toArray())
  18362. if (out.length < q.byteLength()) {
  18363. var zeros = Buffer.alloc(q.byteLength() - out.length)
  18364. out = Buffer.concat([zeros, out])
  18365. }
  18366. return out
  18367. }
  18368. function makeKey (q, kv, algo) {
  18369. var t
  18370. var k
  18371. do {
  18372. t = Buffer.alloc(0)
  18373. while (t.length * 8 < q.bitLength()) {
  18374. kv.v = createHmac(algo, kv.k).update(kv.v).digest()
  18375. t = Buffer.concat([t, kv.v])
  18376. }
  18377. k = bits2int(t, q)
  18378. kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest()
  18379. kv.v = createHmac(algo, kv.k).update(kv.v).digest()
  18380. } while (k.cmp(q) !== -1)
  18381. return k
  18382. }
  18383. function makeR (g, k, p, q) {
  18384. return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
  18385. }
  18386. module.exports = sign
  18387. module.exports.getKey = getKey
  18388. module.exports.makeKey = makeKey
  18389. /***/ }),
  18390. /***/ "./node_modules/browserify-sign/browser/verify.js":
  18391. /*!********************************************************!*\
  18392. !*** ./node_modules/browserify-sign/browser/verify.js ***!
  18393. \********************************************************/
  18394. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18395. // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  18396. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/browserify-sign/node_modules/safe-buffer/index.js").Buffer)
  18397. var BN = __webpack_require__(/*! bn.js */ "./node_modules/bn.js/lib/bn.js")
  18398. var EC = (__webpack_require__(/*! elliptic */ "./node_modules/elliptic/lib/elliptic.js").ec)
  18399. var parseKeys = __webpack_require__(/*! parse-asn1 */ "./node_modules/parse-asn1/index.js")
  18400. var curves = __webpack_require__(/*! ./curves.json */ "./node_modules/browserify-sign/browser/curves.json")
  18401. function verify (sig, hash, key, signType, tag) {
  18402. var pub = parseKeys(key)
  18403. if (pub.type === 'ec') {
  18404. // rsa keys can be interpreted as ecdsa ones in openssl
  18405. if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
  18406. return ecVerify(sig, hash, pub)
  18407. } else if (pub.type === 'dsa') {
  18408. if (signType !== 'dsa') throw new Error('wrong public key type')
  18409. return dsaVerify(sig, hash, pub)
  18410. } else {
  18411. if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
  18412. }
  18413. hash = Buffer.concat([tag, hash])
  18414. var len = pub.modulus.byteLength()
  18415. var pad = [1]
  18416. var padNum = 0
  18417. while (hash.length + pad.length + 2 < len) {
  18418. pad.push(0xff)
  18419. padNum++
  18420. }
  18421. pad.push(0x00)
  18422. var i = -1
  18423. while (++i < hash.length) {
  18424. pad.push(hash[i])
  18425. }
  18426. pad = Buffer.from(pad)
  18427. var red = BN.mont(pub.modulus)
  18428. sig = new BN(sig).toRed(red)
  18429. sig = sig.redPow(new BN(pub.publicExponent))
  18430. sig = Buffer.from(sig.fromRed().toArray())
  18431. var out = padNum < 8 ? 1 : 0
  18432. len = Math.min(sig.length, pad.length)
  18433. if (sig.length !== pad.length) out = 1
  18434. i = -1
  18435. while (++i < len) out |= sig[i] ^ pad[i]
  18436. return out === 0
  18437. }
  18438. function ecVerify (sig, hash, pub) {
  18439. var curveId = curves[pub.data.algorithm.curve.join('.')]
  18440. if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
  18441. var curve = new EC(curveId)
  18442. var pubkey = pub.data.subjectPrivateKey.data
  18443. return curve.verify(hash, sig, pubkey)
  18444. }
  18445. function dsaVerify (sig, hash, pub) {
  18446. var p = pub.data.p
  18447. var q = pub.data.q
  18448. var g = pub.data.g
  18449. var y = pub.data.pub_key
  18450. var unpacked = parseKeys.signature.decode(sig, 'der')
  18451. var s = unpacked.s
  18452. var r = unpacked.r
  18453. checkValue(s, q)
  18454. checkValue(r, q)
  18455. var montp = BN.mont(p)
  18456. var w = s.invm(q)
  18457. var v = g.toRed(montp)
  18458. .redPow(new BN(hash).mul(w).mod(q))
  18459. .fromRed()
  18460. .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
  18461. .mod(p)
  18462. .mod(q)
  18463. return v.cmp(r) === 0
  18464. }
  18465. function checkValue (b, q) {
  18466. if (b.cmpn(0) <= 0) throw new Error('invalid sig')
  18467. if (b.cmp(q) >= q) throw new Error('invalid sig')
  18468. }
  18469. module.exports = verify
  18470. /***/ }),
  18471. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js":
  18472. /*!*************************************************************************************!*\
  18473. !*** ./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js ***!
  18474. \*************************************************************************************/
  18475. /***/ ((module) => {
  18476. "use strict";
  18477. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  18478. var codes = {};
  18479. function createErrorType(code, message, Base) {
  18480. if (!Base) {
  18481. Base = Error;
  18482. }
  18483. function getMessage(arg1, arg2, arg3) {
  18484. if (typeof message === 'string') {
  18485. return message;
  18486. } else {
  18487. return message(arg1, arg2, arg3);
  18488. }
  18489. }
  18490. var NodeError =
  18491. /*#__PURE__*/
  18492. function (_Base) {
  18493. _inheritsLoose(NodeError, _Base);
  18494. function NodeError(arg1, arg2, arg3) {
  18495. return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
  18496. }
  18497. return NodeError;
  18498. }(Base);
  18499. NodeError.prototype.name = Base.name;
  18500. NodeError.prototype.code = code;
  18501. codes[code] = NodeError;
  18502. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  18503. function oneOf(expected, thing) {
  18504. if (Array.isArray(expected)) {
  18505. var len = expected.length;
  18506. expected = expected.map(function (i) {
  18507. return String(i);
  18508. });
  18509. if (len > 2) {
  18510. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  18511. } else if (len === 2) {
  18512. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  18513. } else {
  18514. return "of ".concat(thing, " ").concat(expected[0]);
  18515. }
  18516. } else {
  18517. return "of ".concat(thing, " ").concat(String(expected));
  18518. }
  18519. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  18520. function startsWith(str, search, pos) {
  18521. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  18522. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  18523. function endsWith(str, search, this_len) {
  18524. if (this_len === undefined || this_len > str.length) {
  18525. this_len = str.length;
  18526. }
  18527. return str.substring(this_len - search.length, this_len) === search;
  18528. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  18529. function includes(str, search, start) {
  18530. if (typeof start !== 'number') {
  18531. start = 0;
  18532. }
  18533. if (start + search.length > str.length) {
  18534. return false;
  18535. } else {
  18536. return str.indexOf(search, start) !== -1;
  18537. }
  18538. }
  18539. createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
  18540. return 'The value "' + value + '" is invalid for option "' + name + '"';
  18541. }, TypeError);
  18542. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  18543. // determiner: 'must be' or 'must not be'
  18544. var determiner;
  18545. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  18546. determiner = 'must not be';
  18547. expected = expected.replace(/^not /, '');
  18548. } else {
  18549. determiner = 'must be';
  18550. }
  18551. var msg;
  18552. if (endsWith(name, ' argument')) {
  18553. // For cases like 'first argument'
  18554. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  18555. } else {
  18556. var type = includes(name, '.') ? 'property' : 'argument';
  18557. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  18558. }
  18559. msg += ". Received type ".concat(typeof actual);
  18560. return msg;
  18561. }, TypeError);
  18562. createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
  18563. createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
  18564. return 'The ' + name + ' method is not implemented';
  18565. });
  18566. createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
  18567. createErrorType('ERR_STREAM_DESTROYED', function (name) {
  18568. return 'Cannot call ' + name + ' after a stream was destroyed';
  18569. });
  18570. createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
  18571. createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
  18572. createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
  18573. createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
  18574. createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
  18575. return 'Unknown encoding: ' + arg;
  18576. }, TypeError);
  18577. createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
  18578. module.exports.codes = codes;
  18579. /***/ }),
  18580. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js":
  18581. /*!*****************************************************************************************!*\
  18582. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js ***!
  18583. \*****************************************************************************************/
  18584. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18585. "use strict";
  18586. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  18587. // Copyright Joyent, Inc. and other Node contributors.
  18588. //
  18589. // Permission is hereby granted, free of charge, to any person obtaining a
  18590. // copy of this software and associated documentation files (the
  18591. // "Software"), to deal in the Software without restriction, including
  18592. // without limitation the rights to use, copy, modify, merge, publish,
  18593. // distribute, sublicense, and/or sell copies of the Software, and to permit
  18594. // persons to whom the Software is furnished to do so, subject to the
  18595. // following conditions:
  18596. //
  18597. // The above copyright notice and this permission notice shall be included
  18598. // in all copies or substantial portions of the Software.
  18599. //
  18600. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18601. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18602. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  18603. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18604. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18605. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  18606. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  18607. // a duplex stream is just a stream that is both readable and writable.
  18608. // Since JS doesn't have multiple prototypal inheritance, this class
  18609. // prototypally inherits from Readable, and then parasitically from
  18610. // Writable.
  18611. /*<replacement>*/
  18612. var objectKeys = Object.keys || function (obj) {
  18613. var keys = [];
  18614. for (var key in obj) {
  18615. keys.push(key);
  18616. }
  18617. return keys;
  18618. };
  18619. /*</replacement>*/
  18620. module.exports = Duplex;
  18621. var Readable = __webpack_require__(/*! ./_stream_readable */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js");
  18622. var Writable = __webpack_require__(/*! ./_stream_writable */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js");
  18623. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Duplex, Readable);
  18624. {
  18625. // Allow the keys array to be GC'ed.
  18626. var keys = objectKeys(Writable.prototype);
  18627. for (var v = 0; v < keys.length; v++) {
  18628. var method = keys[v];
  18629. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  18630. }
  18631. }
  18632. function Duplex(options) {
  18633. if (!(this instanceof Duplex)) return new Duplex(options);
  18634. Readable.call(this, options);
  18635. Writable.call(this, options);
  18636. this.allowHalfOpen = true;
  18637. if (options) {
  18638. if (options.readable === false) this.readable = false;
  18639. if (options.writable === false) this.writable = false;
  18640. if (options.allowHalfOpen === false) {
  18641. this.allowHalfOpen = false;
  18642. this.once('end', onend);
  18643. }
  18644. }
  18645. }
  18646. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  18647. // making it explicit this property is not enumerable
  18648. // because otherwise some prototype manipulation in
  18649. // userland will fail
  18650. enumerable: false,
  18651. get: function get() {
  18652. return this._writableState.highWaterMark;
  18653. }
  18654. });
  18655. Object.defineProperty(Duplex.prototype, 'writableBuffer', {
  18656. // making it explicit this property is not enumerable
  18657. // because otherwise some prototype manipulation in
  18658. // userland will fail
  18659. enumerable: false,
  18660. get: function get() {
  18661. return this._writableState && this._writableState.getBuffer();
  18662. }
  18663. });
  18664. Object.defineProperty(Duplex.prototype, 'writableLength', {
  18665. // making it explicit this property is not enumerable
  18666. // because otherwise some prototype manipulation in
  18667. // userland will fail
  18668. enumerable: false,
  18669. get: function get() {
  18670. return this._writableState.length;
  18671. }
  18672. }); // the no-half-open enforcer
  18673. function onend() {
  18674. // If the writable side ended, then we're ok.
  18675. if (this._writableState.ended) return; // no more data can be written.
  18676. // But allow more writes to happen in this tick.
  18677. process.nextTick(onEndNT, this);
  18678. }
  18679. function onEndNT(self) {
  18680. self.end();
  18681. }
  18682. Object.defineProperty(Duplex.prototype, 'destroyed', {
  18683. // making it explicit this property is not enumerable
  18684. // because otherwise some prototype manipulation in
  18685. // userland will fail
  18686. enumerable: false,
  18687. get: function get() {
  18688. if (this._readableState === undefined || this._writableState === undefined) {
  18689. return false;
  18690. }
  18691. return this._readableState.destroyed && this._writableState.destroyed;
  18692. },
  18693. set: function set(value) {
  18694. // we ignore the value if the stream
  18695. // has not been initialized yet
  18696. if (this._readableState === undefined || this._writableState === undefined) {
  18697. return;
  18698. } // backward compatibility, the user is explicitly
  18699. // managing destroyed
  18700. this._readableState.destroyed = value;
  18701. this._writableState.destroyed = value;
  18702. }
  18703. });
  18704. /***/ }),
  18705. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_passthrough.js":
  18706. /*!**********************************************************************************************!*\
  18707. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_passthrough.js ***!
  18708. \**********************************************************************************************/
  18709. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18710. "use strict";
  18711. // Copyright Joyent, Inc. and other Node contributors.
  18712. //
  18713. // Permission is hereby granted, free of charge, to any person obtaining a
  18714. // copy of this software and associated documentation files (the
  18715. // "Software"), to deal in the Software without restriction, including
  18716. // without limitation the rights to use, copy, modify, merge, publish,
  18717. // distribute, sublicense, and/or sell copies of the Software, and to permit
  18718. // persons to whom the Software is furnished to do so, subject to the
  18719. // following conditions:
  18720. //
  18721. // The above copyright notice and this permission notice shall be included
  18722. // in all copies or substantial portions of the Software.
  18723. //
  18724. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18725. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18726. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  18727. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18728. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18729. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  18730. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  18731. // a passthrough stream.
  18732. // basically just the most minimal sort of Transform stream.
  18733. // Every written chunk gets output as-is.
  18734. module.exports = PassThrough;
  18735. var Transform = __webpack_require__(/*! ./_stream_transform */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_transform.js");
  18736. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(PassThrough, Transform);
  18737. function PassThrough(options) {
  18738. if (!(this instanceof PassThrough)) return new PassThrough(options);
  18739. Transform.call(this, options);
  18740. }
  18741. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  18742. cb(null, chunk);
  18743. };
  18744. /***/ }),
  18745. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js":
  18746. /*!*******************************************************************************************!*\
  18747. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js ***!
  18748. \*******************************************************************************************/
  18749. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18750. "use strict";
  18751. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  18752. // Copyright Joyent, Inc. and other Node contributors.
  18753. //
  18754. // Permission is hereby granted, free of charge, to any person obtaining a
  18755. // copy of this software and associated documentation files (the
  18756. // "Software"), to deal in the Software without restriction, including
  18757. // without limitation the rights to use, copy, modify, merge, publish,
  18758. // distribute, sublicense, and/or sell copies of the Software, and to permit
  18759. // persons to whom the Software is furnished to do so, subject to the
  18760. // following conditions:
  18761. //
  18762. // The above copyright notice and this permission notice shall be included
  18763. // in all copies or substantial portions of the Software.
  18764. //
  18765. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18766. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18767. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  18768. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18769. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18770. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  18771. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  18772. module.exports = Readable;
  18773. /*<replacement>*/
  18774. var Duplex;
  18775. /*</replacement>*/
  18776. Readable.ReadableState = ReadableState;
  18777. /*<replacement>*/
  18778. var EE = (__webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter);
  18779. var EElistenerCount = function EElistenerCount(emitter, type) {
  18780. return emitter.listeners(type).length;
  18781. };
  18782. /*</replacement>*/
  18783. /*<replacement>*/
  18784. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  18785. /*</replacement>*/
  18786. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/buffer/index.js").Buffer);
  18787. var OurUint8Array = __webpack_require__.g.Uint8Array || function () {};
  18788. function _uint8ArrayToBuffer(chunk) {
  18789. return Buffer.from(chunk);
  18790. }
  18791. function _isUint8Array(obj) {
  18792. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  18793. }
  18794. /*<replacement>*/
  18795. var debugUtil = __webpack_require__(/*! util */ "?3897");
  18796. var debug;
  18797. if (debugUtil && debugUtil.debuglog) {
  18798. debug = debugUtil.debuglog('stream');
  18799. } else {
  18800. debug = function debug() {};
  18801. }
  18802. /*</replacement>*/
  18803. var BufferList = __webpack_require__(/*! ./internal/streams/buffer_list */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/buffer_list.js");
  18804. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/destroy.js");
  18805. var _require = __webpack_require__(/*! ./internal/streams/state */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/state.js"),
  18806. getHighWaterMark = _require.getHighWaterMark;
  18807. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js").codes),
  18808. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  18809. ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
  18810. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  18811. ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
  18812. var StringDecoder;
  18813. var createReadableStreamAsyncIterator;
  18814. var from;
  18815. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Readable, Stream);
  18816. var errorOrDestroy = destroyImpl.errorOrDestroy;
  18817. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  18818. function prependListener(emitter, event, fn) {
  18819. // Sadly this is not cacheable as some libraries bundle their own
  18820. // event emitter implementation with them.
  18821. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
  18822. // userland ones. NEVER DO THIS. This is here only because this code needs
  18823. // to continue to work with older versions of Node.js that do not include
  18824. // the prependListener() method. The goal is to eventually remove this hack.
  18825. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  18826. }
  18827. function ReadableState(options, stream, isDuplex) {
  18828. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js");
  18829. options = options || {}; // Duplex streams are both readable and writable, but share
  18830. // the same options object.
  18831. // However, some cases require setting options to different
  18832. // values for the readable and the writable sides of the duplex stream.
  18833. // These options can be provided separately as readableXXX and writableXXX.
  18834. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
  18835. // make all the buffer merging and length checks go away
  18836. this.objectMode = !!options.objectMode;
  18837. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
  18838. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  18839. this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the
  18840. // linked list can remove elements from the beginning faster than
  18841. // array.shift()
  18842. this.buffer = new BufferList();
  18843. this.length = 0;
  18844. this.pipes = null;
  18845. this.pipesCount = 0;
  18846. this.flowing = null;
  18847. this.ended = false;
  18848. this.endEmitted = false;
  18849. this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
  18850. // immediately, or on a later tick. We set this to true at first, because
  18851. // any actions that shouldn't happen until "later" should generally also
  18852. // not happen before the first read call.
  18853. this.sync = true; // whenever we return null, then we set a flag to say
  18854. // that we're awaiting a 'readable' event emission.
  18855. this.needReadable = false;
  18856. this.emittedReadable = false;
  18857. this.readableListening = false;
  18858. this.resumeScheduled = false;
  18859. this.paused = true; // Should close be emitted on destroy. Defaults to true.
  18860. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
  18861. this.autoDestroy = !!options.autoDestroy; // has it been destroyed
  18862. this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
  18863. // encoding is 'binary' so we have to make this configurable.
  18864. // Everything else in the universe uses 'utf8', though.
  18865. this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
  18866. this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
  18867. this.readingMore = false;
  18868. this.decoder = null;
  18869. this.encoding = null;
  18870. if (options.encoding) {
  18871. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  18872. this.decoder = new StringDecoder(options.encoding);
  18873. this.encoding = options.encoding;
  18874. }
  18875. }
  18876. function Readable(options) {
  18877. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js");
  18878. if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
  18879. // the ReadableState constructor, at least with V8 6.5
  18880. var isDuplex = this instanceof Duplex;
  18881. this._readableState = new ReadableState(options, this, isDuplex); // legacy
  18882. this.readable = true;
  18883. if (options) {
  18884. if (typeof options.read === 'function') this._read = options.read;
  18885. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  18886. }
  18887. Stream.call(this);
  18888. }
  18889. Object.defineProperty(Readable.prototype, 'destroyed', {
  18890. // making it explicit this property is not enumerable
  18891. // because otherwise some prototype manipulation in
  18892. // userland will fail
  18893. enumerable: false,
  18894. get: function get() {
  18895. if (this._readableState === undefined) {
  18896. return false;
  18897. }
  18898. return this._readableState.destroyed;
  18899. },
  18900. set: function set(value) {
  18901. // we ignore the value if the stream
  18902. // has not been initialized yet
  18903. if (!this._readableState) {
  18904. return;
  18905. } // backward compatibility, the user is explicitly
  18906. // managing destroyed
  18907. this._readableState.destroyed = value;
  18908. }
  18909. });
  18910. Readable.prototype.destroy = destroyImpl.destroy;
  18911. Readable.prototype._undestroy = destroyImpl.undestroy;
  18912. Readable.prototype._destroy = function (err, cb) {
  18913. cb(err);
  18914. }; // Manually shove something into the read() buffer.
  18915. // This returns true if the highWaterMark has not been hit yet,
  18916. // similar to how Writable.write() returns true if you should
  18917. // write() some more.
  18918. Readable.prototype.push = function (chunk, encoding) {
  18919. var state = this._readableState;
  18920. var skipChunkCheck;
  18921. if (!state.objectMode) {
  18922. if (typeof chunk === 'string') {
  18923. encoding = encoding || state.defaultEncoding;
  18924. if (encoding !== state.encoding) {
  18925. chunk = Buffer.from(chunk, encoding);
  18926. encoding = '';
  18927. }
  18928. skipChunkCheck = true;
  18929. }
  18930. } else {
  18931. skipChunkCheck = true;
  18932. }
  18933. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  18934. }; // Unshift should *always* be something directly out of read()
  18935. Readable.prototype.unshift = function (chunk) {
  18936. return readableAddChunk(this, chunk, null, true, false);
  18937. };
  18938. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  18939. debug('readableAddChunk', chunk);
  18940. var state = stream._readableState;
  18941. if (chunk === null) {
  18942. state.reading = false;
  18943. onEofChunk(stream, state);
  18944. } else {
  18945. var er;
  18946. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  18947. if (er) {
  18948. errorOrDestroy(stream, er);
  18949. } else if (state.objectMode || chunk && chunk.length > 0) {
  18950. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  18951. chunk = _uint8ArrayToBuffer(chunk);
  18952. }
  18953. if (addToFront) {
  18954. if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
  18955. } else if (state.ended) {
  18956. errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
  18957. } else if (state.destroyed) {
  18958. return false;
  18959. } else {
  18960. state.reading = false;
  18961. if (state.decoder && !encoding) {
  18962. chunk = state.decoder.write(chunk);
  18963. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  18964. } else {
  18965. addChunk(stream, state, chunk, false);
  18966. }
  18967. }
  18968. } else if (!addToFront) {
  18969. state.reading = false;
  18970. maybeReadMore(stream, state);
  18971. }
  18972. } // We can push more data if we are below the highWaterMark.
  18973. // Also, if we have no data yet, we can stand some more bytes.
  18974. // This is to work around cases where hwm=0, such as the repl.
  18975. return !state.ended && (state.length < state.highWaterMark || state.length === 0);
  18976. }
  18977. function addChunk(stream, state, chunk, addToFront) {
  18978. if (state.flowing && state.length === 0 && !state.sync) {
  18979. state.awaitDrain = 0;
  18980. stream.emit('data', chunk);
  18981. } else {
  18982. // update the buffer info.
  18983. state.length += state.objectMode ? 1 : chunk.length;
  18984. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  18985. if (state.needReadable) emitReadable(stream);
  18986. }
  18987. maybeReadMore(stream, state);
  18988. }
  18989. function chunkInvalid(state, chunk) {
  18990. var er;
  18991. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  18992. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
  18993. }
  18994. return er;
  18995. }
  18996. Readable.prototype.isPaused = function () {
  18997. return this._readableState.flowing === false;
  18998. }; // backwards compatibility.
  18999. Readable.prototype.setEncoding = function (enc) {
  19000. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  19001. var decoder = new StringDecoder(enc);
  19002. this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
  19003. this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
  19004. var p = this._readableState.buffer.head;
  19005. var content = '';
  19006. while (p !== null) {
  19007. content += decoder.write(p.data);
  19008. p = p.next;
  19009. }
  19010. this._readableState.buffer.clear();
  19011. if (content !== '') this._readableState.buffer.push(content);
  19012. this._readableState.length = content.length;
  19013. return this;
  19014. }; // Don't raise the hwm > 1GB
  19015. var MAX_HWM = 0x40000000;
  19016. function computeNewHighWaterMark(n) {
  19017. if (n >= MAX_HWM) {
  19018. // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
  19019. n = MAX_HWM;
  19020. } else {
  19021. // Get the next highest power of 2 to prevent increasing hwm excessively in
  19022. // tiny amounts
  19023. n--;
  19024. n |= n >>> 1;
  19025. n |= n >>> 2;
  19026. n |= n >>> 4;
  19027. n |= n >>> 8;
  19028. n |= n >>> 16;
  19029. n++;
  19030. }
  19031. return n;
  19032. } // This function is designed to be inlinable, so please take care when making
  19033. // changes to the function body.
  19034. function howMuchToRead(n, state) {
  19035. if (n <= 0 || state.length === 0 && state.ended) return 0;
  19036. if (state.objectMode) return 1;
  19037. if (n !== n) {
  19038. // Only flow one buffer at a time
  19039. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  19040. } // If we're asking for more than the current hwm, then raise the hwm.
  19041. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  19042. if (n <= state.length) return n; // Don't have enough
  19043. if (!state.ended) {
  19044. state.needReadable = true;
  19045. return 0;
  19046. }
  19047. return state.length;
  19048. } // you can override either this method, or the async _read(n) below.
  19049. Readable.prototype.read = function (n) {
  19050. debug('read', n);
  19051. n = parseInt(n, 10);
  19052. var state = this._readableState;
  19053. var nOrig = n;
  19054. if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
  19055. // already have a bunch of data in the buffer, then just trigger
  19056. // the 'readable' event and move on.
  19057. if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
  19058. debug('read: emitReadable', state.length, state.ended);
  19059. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  19060. return null;
  19061. }
  19062. n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
  19063. if (n === 0 && state.ended) {
  19064. if (state.length === 0) endReadable(this);
  19065. return null;
  19066. } // All the actual chunk generation logic needs to be
  19067. // *below* the call to _read. The reason is that in certain
  19068. // synthetic stream cases, such as passthrough streams, _read
  19069. // may be a completely synchronous operation which may change
  19070. // the state of the read buffer, providing enough data when
  19071. // before there was *not* enough.
  19072. //
  19073. // So, the steps are:
  19074. // 1. Figure out what the state of things will be after we do
  19075. // a read from the buffer.
  19076. //
  19077. // 2. If that resulting state will trigger a _read, then call _read.
  19078. // Note that this may be asynchronous, or synchronous. Yes, it is
  19079. // deeply ugly to write APIs this way, but that still doesn't mean
  19080. // that the Readable class should behave improperly, as streams are
  19081. // designed to be sync/async agnostic.
  19082. // Take note if the _read call is sync or async (ie, if the read call
  19083. // has returned yet), so that we know whether or not it's safe to emit
  19084. // 'readable' etc.
  19085. //
  19086. // 3. Actually pull the requested chunks out of the buffer and return.
  19087. // if we need a readable event, then we need to do some reading.
  19088. var doRead = state.needReadable;
  19089. debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
  19090. if (state.length === 0 || state.length - n < state.highWaterMark) {
  19091. doRead = true;
  19092. debug('length less than watermark', doRead);
  19093. } // however, if we've ended, then there's no point, and if we're already
  19094. // reading, then it's unnecessary.
  19095. if (state.ended || state.reading) {
  19096. doRead = false;
  19097. debug('reading or ended', doRead);
  19098. } else if (doRead) {
  19099. debug('do read');
  19100. state.reading = true;
  19101. state.sync = true; // if the length is currently zero, then we *need* a readable event.
  19102. if (state.length === 0) state.needReadable = true; // call internal read method
  19103. this._read(state.highWaterMark);
  19104. state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
  19105. // and we need to re-evaluate how much data we can return to the user.
  19106. if (!state.reading) n = howMuchToRead(nOrig, state);
  19107. }
  19108. var ret;
  19109. if (n > 0) ret = fromList(n, state);else ret = null;
  19110. if (ret === null) {
  19111. state.needReadable = state.length <= state.highWaterMark;
  19112. n = 0;
  19113. } else {
  19114. state.length -= n;
  19115. state.awaitDrain = 0;
  19116. }
  19117. if (state.length === 0) {
  19118. // If we have nothing in the buffer, then we want to know
  19119. // as soon as we *do* get something into the buffer.
  19120. if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
  19121. if (nOrig !== n && state.ended) endReadable(this);
  19122. }
  19123. if (ret !== null) this.emit('data', ret);
  19124. return ret;
  19125. };
  19126. function onEofChunk(stream, state) {
  19127. debug('onEofChunk');
  19128. if (state.ended) return;
  19129. if (state.decoder) {
  19130. var chunk = state.decoder.end();
  19131. if (chunk && chunk.length) {
  19132. state.buffer.push(chunk);
  19133. state.length += state.objectMode ? 1 : chunk.length;
  19134. }
  19135. }
  19136. state.ended = true;
  19137. if (state.sync) {
  19138. // if we are sync, wait until next tick to emit the data.
  19139. // Otherwise we risk emitting data in the flow()
  19140. // the readable code triggers during a read() call
  19141. emitReadable(stream);
  19142. } else {
  19143. // emit 'readable' now to make sure it gets picked up.
  19144. state.needReadable = false;
  19145. if (!state.emittedReadable) {
  19146. state.emittedReadable = true;
  19147. emitReadable_(stream);
  19148. }
  19149. }
  19150. } // Don't emit readable right away in sync mode, because this can trigger
  19151. // another read() call => stack overflow. This way, it might trigger
  19152. // a nextTick recursion warning, but that's not so bad.
  19153. function emitReadable(stream) {
  19154. var state = stream._readableState;
  19155. debug('emitReadable', state.needReadable, state.emittedReadable);
  19156. state.needReadable = false;
  19157. if (!state.emittedReadable) {
  19158. debug('emitReadable', state.flowing);
  19159. state.emittedReadable = true;
  19160. process.nextTick(emitReadable_, stream);
  19161. }
  19162. }
  19163. function emitReadable_(stream) {
  19164. var state = stream._readableState;
  19165. debug('emitReadable_', state.destroyed, state.length, state.ended);
  19166. if (!state.destroyed && (state.length || state.ended)) {
  19167. stream.emit('readable');
  19168. state.emittedReadable = false;
  19169. } // The stream needs another readable event if
  19170. // 1. It is not flowing, as the flow mechanism will take
  19171. // care of it.
  19172. // 2. It is not ended.
  19173. // 3. It is below the highWaterMark, so we can schedule
  19174. // another readable later.
  19175. state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
  19176. flow(stream);
  19177. } // at this point, the user has presumably seen the 'readable' event,
  19178. // and called read() to consume some data. that may have triggered
  19179. // in turn another _read(n) call, in which case reading = true if
  19180. // it's in progress.
  19181. // However, if we're not ended, or reading, and the length < hwm,
  19182. // then go ahead and try to read some more preemptively.
  19183. function maybeReadMore(stream, state) {
  19184. if (!state.readingMore) {
  19185. state.readingMore = true;
  19186. process.nextTick(maybeReadMore_, stream, state);
  19187. }
  19188. }
  19189. function maybeReadMore_(stream, state) {
  19190. // Attempt to read more data if we should.
  19191. //
  19192. // The conditions for reading more data are (one of):
  19193. // - Not enough data buffered (state.length < state.highWaterMark). The loop
  19194. // is responsible for filling the buffer with enough data if such data
  19195. // is available. If highWaterMark is 0 and we are not in the flowing mode
  19196. // we should _not_ attempt to buffer any extra data. We'll get more data
  19197. // when the stream consumer calls read() instead.
  19198. // - No data in the buffer, and the stream is in flowing mode. In this mode
  19199. // the loop below is responsible for ensuring read() is called. Failing to
  19200. // call read here would abort the flow and there's no other mechanism for
  19201. // continuing the flow if the stream consumer has just subscribed to the
  19202. // 'data' event.
  19203. //
  19204. // In addition to the above conditions to keep reading data, the following
  19205. // conditions prevent the data from being read:
  19206. // - The stream has ended (state.ended).
  19207. // - There is already a pending 'read' operation (state.reading). This is a
  19208. // case where the the stream has called the implementation defined _read()
  19209. // method, but they are processing the call asynchronously and have _not_
  19210. // called push() with new data. In this case we skip performing more
  19211. // read()s. The execution ends in this method again after the _read() ends
  19212. // up calling push() with more data.
  19213. while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
  19214. var len = state.length;
  19215. debug('maybeReadMore read 0');
  19216. stream.read(0);
  19217. if (len === state.length) // didn't get any data, stop spinning.
  19218. break;
  19219. }
  19220. state.readingMore = false;
  19221. } // abstract method. to be overridden in specific implementation classes.
  19222. // call cb(er, data) where data is <= n in length.
  19223. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  19224. // arbitrary, and perhaps not very meaningful.
  19225. Readable.prototype._read = function (n) {
  19226. errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
  19227. };
  19228. Readable.prototype.pipe = function (dest, pipeOpts) {
  19229. var src = this;
  19230. var state = this._readableState;
  19231. switch (state.pipesCount) {
  19232. case 0:
  19233. state.pipes = dest;
  19234. break;
  19235. case 1:
  19236. state.pipes = [state.pipes, dest];
  19237. break;
  19238. default:
  19239. state.pipes.push(dest);
  19240. break;
  19241. }
  19242. state.pipesCount += 1;
  19243. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  19244. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  19245. var endFn = doEnd ? onend : unpipe;
  19246. if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
  19247. dest.on('unpipe', onunpipe);
  19248. function onunpipe(readable, unpipeInfo) {
  19249. debug('onunpipe');
  19250. if (readable === src) {
  19251. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  19252. unpipeInfo.hasUnpiped = true;
  19253. cleanup();
  19254. }
  19255. }
  19256. }
  19257. function onend() {
  19258. debug('onend');
  19259. dest.end();
  19260. } // when the dest drains, it reduces the awaitDrain counter
  19261. // on the source. This would be more elegant with a .once()
  19262. // handler in flow(), but adding and removing repeatedly is
  19263. // too slow.
  19264. var ondrain = pipeOnDrain(src);
  19265. dest.on('drain', ondrain);
  19266. var cleanedUp = false;
  19267. function cleanup() {
  19268. debug('cleanup'); // cleanup event handlers once the pipe is broken
  19269. dest.removeListener('close', onclose);
  19270. dest.removeListener('finish', onfinish);
  19271. dest.removeListener('drain', ondrain);
  19272. dest.removeListener('error', onerror);
  19273. dest.removeListener('unpipe', onunpipe);
  19274. src.removeListener('end', onend);
  19275. src.removeListener('end', unpipe);
  19276. src.removeListener('data', ondata);
  19277. cleanedUp = true; // if the reader is waiting for a drain event from this
  19278. // specific writer, then it would cause it to never start
  19279. // flowing again.
  19280. // So, if this is awaiting a drain, then we just call it now.
  19281. // If we don't know, then assume that we are waiting for one.
  19282. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  19283. }
  19284. src.on('data', ondata);
  19285. function ondata(chunk) {
  19286. debug('ondata');
  19287. var ret = dest.write(chunk);
  19288. debug('dest.write', ret);
  19289. if (ret === false) {
  19290. // If the user unpiped during `dest.write()`, it is possible
  19291. // to get stuck in a permanently paused state if that write
  19292. // also returned false.
  19293. // => Check whether `dest` is still a piping destination.
  19294. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  19295. debug('false write response, pause', state.awaitDrain);
  19296. state.awaitDrain++;
  19297. }
  19298. src.pause();
  19299. }
  19300. } // if the dest has an error, then stop piping into it.
  19301. // however, don't suppress the throwing behavior for this.
  19302. function onerror(er) {
  19303. debug('onerror', er);
  19304. unpipe();
  19305. dest.removeListener('error', onerror);
  19306. if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
  19307. } // Make sure our error handler is attached before userland ones.
  19308. prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
  19309. function onclose() {
  19310. dest.removeListener('finish', onfinish);
  19311. unpipe();
  19312. }
  19313. dest.once('close', onclose);
  19314. function onfinish() {
  19315. debug('onfinish');
  19316. dest.removeListener('close', onclose);
  19317. unpipe();
  19318. }
  19319. dest.once('finish', onfinish);
  19320. function unpipe() {
  19321. debug('unpipe');
  19322. src.unpipe(dest);
  19323. } // tell the dest that it's being piped to
  19324. dest.emit('pipe', src); // start the flow if it hasn't been started already.
  19325. if (!state.flowing) {
  19326. debug('pipe resume');
  19327. src.resume();
  19328. }
  19329. return dest;
  19330. };
  19331. function pipeOnDrain(src) {
  19332. return function pipeOnDrainFunctionResult() {
  19333. var state = src._readableState;
  19334. debug('pipeOnDrain', state.awaitDrain);
  19335. if (state.awaitDrain) state.awaitDrain--;
  19336. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  19337. state.flowing = true;
  19338. flow(src);
  19339. }
  19340. };
  19341. }
  19342. Readable.prototype.unpipe = function (dest) {
  19343. var state = this._readableState;
  19344. var unpipeInfo = {
  19345. hasUnpiped: false
  19346. }; // if we're not piping anywhere, then do nothing.
  19347. if (state.pipesCount === 0) return this; // just one destination. most common case.
  19348. if (state.pipesCount === 1) {
  19349. // passed in one, but it's not the right one.
  19350. if (dest && dest !== state.pipes) return this;
  19351. if (!dest) dest = state.pipes; // got a match.
  19352. state.pipes = null;
  19353. state.pipesCount = 0;
  19354. state.flowing = false;
  19355. if (dest) dest.emit('unpipe', this, unpipeInfo);
  19356. return this;
  19357. } // slow case. multiple pipe destinations.
  19358. if (!dest) {
  19359. // remove all.
  19360. var dests = state.pipes;
  19361. var len = state.pipesCount;
  19362. state.pipes = null;
  19363. state.pipesCount = 0;
  19364. state.flowing = false;
  19365. for (var i = 0; i < len; i++) {
  19366. dests[i].emit('unpipe', this, {
  19367. hasUnpiped: false
  19368. });
  19369. }
  19370. return this;
  19371. } // try to find the right one.
  19372. var index = indexOf(state.pipes, dest);
  19373. if (index === -1) return this;
  19374. state.pipes.splice(index, 1);
  19375. state.pipesCount -= 1;
  19376. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  19377. dest.emit('unpipe', this, unpipeInfo);
  19378. return this;
  19379. }; // set up data events if they are asked for
  19380. // Ensure readable listeners eventually get something
  19381. Readable.prototype.on = function (ev, fn) {
  19382. var res = Stream.prototype.on.call(this, ev, fn);
  19383. var state = this._readableState;
  19384. if (ev === 'data') {
  19385. // update readableListening so that resume() may be a no-op
  19386. // a few lines down. This is needed to support once('readable').
  19387. state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused
  19388. if (state.flowing !== false) this.resume();
  19389. } else if (ev === 'readable') {
  19390. if (!state.endEmitted && !state.readableListening) {
  19391. state.readableListening = state.needReadable = true;
  19392. state.flowing = false;
  19393. state.emittedReadable = false;
  19394. debug('on readable', state.length, state.reading);
  19395. if (state.length) {
  19396. emitReadable(this);
  19397. } else if (!state.reading) {
  19398. process.nextTick(nReadingNextTick, this);
  19399. }
  19400. }
  19401. }
  19402. return res;
  19403. };
  19404. Readable.prototype.addListener = Readable.prototype.on;
  19405. Readable.prototype.removeListener = function (ev, fn) {
  19406. var res = Stream.prototype.removeListener.call(this, ev, fn);
  19407. if (ev === 'readable') {
  19408. // We need to check if there is someone still listening to
  19409. // readable and reset the state. However this needs to happen
  19410. // after readable has been emitted but before I/O (nextTick) to
  19411. // support once('readable', fn) cycles. This means that calling
  19412. // resume within the same tick will have no
  19413. // effect.
  19414. process.nextTick(updateReadableListening, this);
  19415. }
  19416. return res;
  19417. };
  19418. Readable.prototype.removeAllListeners = function (ev) {
  19419. var res = Stream.prototype.removeAllListeners.apply(this, arguments);
  19420. if (ev === 'readable' || ev === undefined) {
  19421. // We need to check if there is someone still listening to
  19422. // readable and reset the state. However this needs to happen
  19423. // after readable has been emitted but before I/O (nextTick) to
  19424. // support once('readable', fn) cycles. This means that calling
  19425. // resume within the same tick will have no
  19426. // effect.
  19427. process.nextTick(updateReadableListening, this);
  19428. }
  19429. return res;
  19430. };
  19431. function updateReadableListening(self) {
  19432. var state = self._readableState;
  19433. state.readableListening = self.listenerCount('readable') > 0;
  19434. if (state.resumeScheduled && !state.paused) {
  19435. // flowing needs to be set to true now, otherwise
  19436. // the upcoming resume will not flow.
  19437. state.flowing = true; // crude way to check if we should resume
  19438. } else if (self.listenerCount('data') > 0) {
  19439. self.resume();
  19440. }
  19441. }
  19442. function nReadingNextTick(self) {
  19443. debug('readable nexttick read 0');
  19444. self.read(0);
  19445. } // pause() and resume() are remnants of the legacy readable stream API
  19446. // If the user uses them, then switch into old mode.
  19447. Readable.prototype.resume = function () {
  19448. var state = this._readableState;
  19449. if (!state.flowing) {
  19450. debug('resume'); // we flow only if there is no one listening
  19451. // for readable, but we still have to call
  19452. // resume()
  19453. state.flowing = !state.readableListening;
  19454. resume(this, state);
  19455. }
  19456. state.paused = false;
  19457. return this;
  19458. };
  19459. function resume(stream, state) {
  19460. if (!state.resumeScheduled) {
  19461. state.resumeScheduled = true;
  19462. process.nextTick(resume_, stream, state);
  19463. }
  19464. }
  19465. function resume_(stream, state) {
  19466. debug('resume', state.reading);
  19467. if (!state.reading) {
  19468. stream.read(0);
  19469. }
  19470. state.resumeScheduled = false;
  19471. stream.emit('resume');
  19472. flow(stream);
  19473. if (state.flowing && !state.reading) stream.read(0);
  19474. }
  19475. Readable.prototype.pause = function () {
  19476. debug('call pause flowing=%j', this._readableState.flowing);
  19477. if (this._readableState.flowing !== false) {
  19478. debug('pause');
  19479. this._readableState.flowing = false;
  19480. this.emit('pause');
  19481. }
  19482. this._readableState.paused = true;
  19483. return this;
  19484. };
  19485. function flow(stream) {
  19486. var state = stream._readableState;
  19487. debug('flow', state.flowing);
  19488. while (state.flowing && stream.read() !== null) {
  19489. ;
  19490. }
  19491. } // wrap an old-style stream as the async data source.
  19492. // This is *not* part of the readable stream interface.
  19493. // It is an ugly unfortunate mess of history.
  19494. Readable.prototype.wrap = function (stream) {
  19495. var _this = this;
  19496. var state = this._readableState;
  19497. var paused = false;
  19498. stream.on('end', function () {
  19499. debug('wrapped end');
  19500. if (state.decoder && !state.ended) {
  19501. var chunk = state.decoder.end();
  19502. if (chunk && chunk.length) _this.push(chunk);
  19503. }
  19504. _this.push(null);
  19505. });
  19506. stream.on('data', function (chunk) {
  19507. debug('wrapped data');
  19508. if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
  19509. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  19510. var ret = _this.push(chunk);
  19511. if (!ret) {
  19512. paused = true;
  19513. stream.pause();
  19514. }
  19515. }); // proxy all the other methods.
  19516. // important when wrapping filters and duplexes.
  19517. for (var i in stream) {
  19518. if (this[i] === undefined && typeof stream[i] === 'function') {
  19519. this[i] = function methodWrap(method) {
  19520. return function methodWrapReturnFunction() {
  19521. return stream[method].apply(stream, arguments);
  19522. };
  19523. }(i);
  19524. }
  19525. } // proxy certain important events.
  19526. for (var n = 0; n < kProxyEvents.length; n++) {
  19527. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  19528. } // when we try to consume some more bytes, simply unpause the
  19529. // underlying stream.
  19530. this._read = function (n) {
  19531. debug('wrapped _read', n);
  19532. if (paused) {
  19533. paused = false;
  19534. stream.resume();
  19535. }
  19536. };
  19537. return this;
  19538. };
  19539. if (typeof Symbol === 'function') {
  19540. Readable.prototype[Symbol.asyncIterator] = function () {
  19541. if (createReadableStreamAsyncIterator === undefined) {
  19542. createReadableStreamAsyncIterator = __webpack_require__(/*! ./internal/streams/async_iterator */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/async_iterator.js");
  19543. }
  19544. return createReadableStreamAsyncIterator(this);
  19545. };
  19546. }
  19547. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  19548. // making it explicit this property is not enumerable
  19549. // because otherwise some prototype manipulation in
  19550. // userland will fail
  19551. enumerable: false,
  19552. get: function get() {
  19553. return this._readableState.highWaterMark;
  19554. }
  19555. });
  19556. Object.defineProperty(Readable.prototype, 'readableBuffer', {
  19557. // making it explicit this property is not enumerable
  19558. // because otherwise some prototype manipulation in
  19559. // userland will fail
  19560. enumerable: false,
  19561. get: function get() {
  19562. return this._readableState && this._readableState.buffer;
  19563. }
  19564. });
  19565. Object.defineProperty(Readable.prototype, 'readableFlowing', {
  19566. // making it explicit this property is not enumerable
  19567. // because otherwise some prototype manipulation in
  19568. // userland will fail
  19569. enumerable: false,
  19570. get: function get() {
  19571. return this._readableState.flowing;
  19572. },
  19573. set: function set(state) {
  19574. if (this._readableState) {
  19575. this._readableState.flowing = state;
  19576. }
  19577. }
  19578. }); // exposed for testing purposes only.
  19579. Readable._fromList = fromList;
  19580. Object.defineProperty(Readable.prototype, 'readableLength', {
  19581. // making it explicit this property is not enumerable
  19582. // because otherwise some prototype manipulation in
  19583. // userland will fail
  19584. enumerable: false,
  19585. get: function get() {
  19586. return this._readableState.length;
  19587. }
  19588. }); // Pluck off n bytes from an array of buffers.
  19589. // Length is the combined lengths of all the buffers in the list.
  19590. // This function is designed to be inlinable, so please take care when making
  19591. // changes to the function body.
  19592. function fromList(n, state) {
  19593. // nothing buffered
  19594. if (state.length === 0) return null;
  19595. var ret;
  19596. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  19597. // read it all, truncate the list
  19598. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
  19599. state.buffer.clear();
  19600. } else {
  19601. // read part of list
  19602. ret = state.buffer.consume(n, state.decoder);
  19603. }
  19604. return ret;
  19605. }
  19606. function endReadable(stream) {
  19607. var state = stream._readableState;
  19608. debug('endReadable', state.endEmitted);
  19609. if (!state.endEmitted) {
  19610. state.ended = true;
  19611. process.nextTick(endReadableNT, state, stream);
  19612. }
  19613. }
  19614. function endReadableNT(state, stream) {
  19615. debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.
  19616. if (!state.endEmitted && state.length === 0) {
  19617. state.endEmitted = true;
  19618. stream.readable = false;
  19619. stream.emit('end');
  19620. if (state.autoDestroy) {
  19621. // In case of duplex streams we need a way to detect
  19622. // if the writable side is ready for autoDestroy as well
  19623. var wState = stream._writableState;
  19624. if (!wState || wState.autoDestroy && wState.finished) {
  19625. stream.destroy();
  19626. }
  19627. }
  19628. }
  19629. }
  19630. if (typeof Symbol === 'function') {
  19631. Readable.from = function (iterable, opts) {
  19632. if (from === undefined) {
  19633. from = __webpack_require__(/*! ./internal/streams/from */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/from-browser.js");
  19634. }
  19635. return from(Readable, iterable, opts);
  19636. };
  19637. }
  19638. function indexOf(xs, x) {
  19639. for (var i = 0, l = xs.length; i < l; i++) {
  19640. if (xs[i] === x) return i;
  19641. }
  19642. return -1;
  19643. }
  19644. /***/ }),
  19645. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_transform.js":
  19646. /*!********************************************************************************************!*\
  19647. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_transform.js ***!
  19648. \********************************************************************************************/
  19649. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  19650. "use strict";
  19651. // Copyright Joyent, Inc. and other Node contributors.
  19652. //
  19653. // Permission is hereby granted, free of charge, to any person obtaining a
  19654. // copy of this software and associated documentation files (the
  19655. // "Software"), to deal in the Software without restriction, including
  19656. // without limitation the rights to use, copy, modify, merge, publish,
  19657. // distribute, sublicense, and/or sell copies of the Software, and to permit
  19658. // persons to whom the Software is furnished to do so, subject to the
  19659. // following conditions:
  19660. //
  19661. // The above copyright notice and this permission notice shall be included
  19662. // in all copies or substantial portions of the Software.
  19663. //
  19664. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19665. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19666. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  19667. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  19668. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19669. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19670. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  19671. // a transform stream is a readable/writable stream where you do
  19672. // something with the data. Sometimes it's called a "filter",
  19673. // but that's not a great name for it, since that implies a thing where
  19674. // some bits pass through, and others are simply ignored. (That would
  19675. // be a valid example of a transform, of course.)
  19676. //
  19677. // While the output is causally related to the input, it's not a
  19678. // necessarily symmetric or synchronous transformation. For example,
  19679. // a zlib stream might take multiple plain-text writes(), and then
  19680. // emit a single compressed chunk some time in the future.
  19681. //
  19682. // Here's how this works:
  19683. //
  19684. // The Transform stream has all the aspects of the readable and writable
  19685. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  19686. // internally, and returns false if there's a lot of pending writes
  19687. // buffered up. When you call read(), that calls _read(n) until
  19688. // there's enough pending readable data buffered up.
  19689. //
  19690. // In a transform stream, the written data is placed in a buffer. When
  19691. // _read(n) is called, it transforms the queued up data, calling the
  19692. // buffered _write cb's as it consumes chunks. If consuming a single
  19693. // written chunk would result in multiple output chunks, then the first
  19694. // outputted bit calls the readcb, and subsequent chunks just go into
  19695. // the read buffer, and will cause it to emit 'readable' if necessary.
  19696. //
  19697. // This way, back-pressure is actually determined by the reading side,
  19698. // since _read has to be called to start processing a new chunk. However,
  19699. // a pathological inflate type of transform can cause excessive buffering
  19700. // here. For example, imagine a stream where every byte of input is
  19701. // interpreted as an integer from 0-255, and then results in that many
  19702. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  19703. // 1kb of data being output. In this case, you could write a very small
  19704. // amount of input, and end up with a very large amount of output. In
  19705. // such a pathological inflating mechanism, there'd be no way to tell
  19706. // the system to stop doing the transform. A single 4MB write could
  19707. // cause the system to run out of memory.
  19708. //
  19709. // However, even in such a pathological case, only a single written chunk
  19710. // would be consumed, and then the rest would wait (un-transformed) until
  19711. // the results of the previous transformed chunk were consumed.
  19712. module.exports = Transform;
  19713. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js").codes),
  19714. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  19715. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  19716. ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
  19717. ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
  19718. var Duplex = __webpack_require__(/*! ./_stream_duplex */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js");
  19719. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Transform, Duplex);
  19720. function afterTransform(er, data) {
  19721. var ts = this._transformState;
  19722. ts.transforming = false;
  19723. var cb = ts.writecb;
  19724. if (cb === null) {
  19725. return this.emit('error', new ERR_MULTIPLE_CALLBACK());
  19726. }
  19727. ts.writechunk = null;
  19728. ts.writecb = null;
  19729. if (data != null) // single equals check for both `null` and `undefined`
  19730. this.push(data);
  19731. cb(er);
  19732. var rs = this._readableState;
  19733. rs.reading = false;
  19734. if (rs.needReadable || rs.length < rs.highWaterMark) {
  19735. this._read(rs.highWaterMark);
  19736. }
  19737. }
  19738. function Transform(options) {
  19739. if (!(this instanceof Transform)) return new Transform(options);
  19740. Duplex.call(this, options);
  19741. this._transformState = {
  19742. afterTransform: afterTransform.bind(this),
  19743. needTransform: false,
  19744. transforming: false,
  19745. writecb: null,
  19746. writechunk: null,
  19747. writeencoding: null
  19748. }; // start out asking for a readable event once data is transformed.
  19749. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
  19750. // that Readable wants before the first _read call, so unset the
  19751. // sync guard flag.
  19752. this._readableState.sync = false;
  19753. if (options) {
  19754. if (typeof options.transform === 'function') this._transform = options.transform;
  19755. if (typeof options.flush === 'function') this._flush = options.flush;
  19756. } // When the writable side finishes, then flush out anything remaining.
  19757. this.on('prefinish', prefinish);
  19758. }
  19759. function prefinish() {
  19760. var _this = this;
  19761. if (typeof this._flush === 'function' && !this._readableState.destroyed) {
  19762. this._flush(function (er, data) {
  19763. done(_this, er, data);
  19764. });
  19765. } else {
  19766. done(this, null, null);
  19767. }
  19768. }
  19769. Transform.prototype.push = function (chunk, encoding) {
  19770. this._transformState.needTransform = false;
  19771. return Duplex.prototype.push.call(this, chunk, encoding);
  19772. }; // This is the part where you do stuff!
  19773. // override this function in implementation classes.
  19774. // 'chunk' is an input chunk.
  19775. //
  19776. // Call `push(newChunk)` to pass along transformed output
  19777. // to the readable side. You may call 'push' zero or more times.
  19778. //
  19779. // Call `cb(err)` when you are done with this chunk. If you pass
  19780. // an error, then that'll put the hurt on the whole operation. If you
  19781. // never call cb(), then you'll never get another chunk.
  19782. Transform.prototype._transform = function (chunk, encoding, cb) {
  19783. cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
  19784. };
  19785. Transform.prototype._write = function (chunk, encoding, cb) {
  19786. var ts = this._transformState;
  19787. ts.writecb = cb;
  19788. ts.writechunk = chunk;
  19789. ts.writeencoding = encoding;
  19790. if (!ts.transforming) {
  19791. var rs = this._readableState;
  19792. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  19793. }
  19794. }; // Doesn't matter what the args are here.
  19795. // _transform does all the work.
  19796. // That we got here means that the readable side wants more data.
  19797. Transform.prototype._read = function (n) {
  19798. var ts = this._transformState;
  19799. if (ts.writechunk !== null && !ts.transforming) {
  19800. ts.transforming = true;
  19801. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  19802. } else {
  19803. // mark that we need a transform, so that any data that comes in
  19804. // will get processed, now that we've asked for it.
  19805. ts.needTransform = true;
  19806. }
  19807. };
  19808. Transform.prototype._destroy = function (err, cb) {
  19809. Duplex.prototype._destroy.call(this, err, function (err2) {
  19810. cb(err2);
  19811. });
  19812. };
  19813. function done(stream, er, data) {
  19814. if (er) return stream.emit('error', er);
  19815. if (data != null) // single equals check for both `null` and `undefined`
  19816. stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
  19817. // if there's nothing in the write buffer, then that means
  19818. // that nothing more will ever be provided
  19819. if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
  19820. if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
  19821. return stream.push(null);
  19822. }
  19823. /***/ }),
  19824. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js":
  19825. /*!*******************************************************************************************!*\
  19826. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js ***!
  19827. \*******************************************************************************************/
  19828. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  19829. "use strict";
  19830. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  19831. // Copyright Joyent, Inc. and other Node contributors.
  19832. //
  19833. // Permission is hereby granted, free of charge, to any person obtaining a
  19834. // copy of this software and associated documentation files (the
  19835. // "Software"), to deal in the Software without restriction, including
  19836. // without limitation the rights to use, copy, modify, merge, publish,
  19837. // distribute, sublicense, and/or sell copies of the Software, and to permit
  19838. // persons to whom the Software is furnished to do so, subject to the
  19839. // following conditions:
  19840. //
  19841. // The above copyright notice and this permission notice shall be included
  19842. // in all copies or substantial portions of the Software.
  19843. //
  19844. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19845. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19846. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  19847. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  19848. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19849. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19850. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  19851. // A bit simpler than readable streams.
  19852. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  19853. // the drain event emission and buffering.
  19854. module.exports = Writable;
  19855. /* <replacement> */
  19856. function WriteReq(chunk, encoding, cb) {
  19857. this.chunk = chunk;
  19858. this.encoding = encoding;
  19859. this.callback = cb;
  19860. this.next = null;
  19861. } // It seems a linked list but it is not
  19862. // there will be only 2 of these for each stream
  19863. function CorkedRequest(state) {
  19864. var _this = this;
  19865. this.next = null;
  19866. this.entry = null;
  19867. this.finish = function () {
  19868. onCorkedFinish(_this, state);
  19869. };
  19870. }
  19871. /* </replacement> */
  19872. /*<replacement>*/
  19873. var Duplex;
  19874. /*</replacement>*/
  19875. Writable.WritableState = WritableState;
  19876. /*<replacement>*/
  19877. var internalUtil = {
  19878. deprecate: __webpack_require__(/*! util-deprecate */ "./node_modules/util-deprecate/browser.js")
  19879. };
  19880. /*</replacement>*/
  19881. /*<replacement>*/
  19882. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  19883. /*</replacement>*/
  19884. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/buffer/index.js").Buffer);
  19885. var OurUint8Array = __webpack_require__.g.Uint8Array || function () {};
  19886. function _uint8ArrayToBuffer(chunk) {
  19887. return Buffer.from(chunk);
  19888. }
  19889. function _isUint8Array(obj) {
  19890. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  19891. }
  19892. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/destroy.js");
  19893. var _require = __webpack_require__(/*! ./internal/streams/state */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/state.js"),
  19894. getHighWaterMark = _require.getHighWaterMark;
  19895. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js").codes),
  19896. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  19897. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  19898. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  19899. ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
  19900. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
  19901. ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
  19902. ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
  19903. ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
  19904. var errorOrDestroy = destroyImpl.errorOrDestroy;
  19905. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Writable, Stream);
  19906. function nop() {}
  19907. function WritableState(options, stream, isDuplex) {
  19908. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js");
  19909. options = options || {}; // Duplex streams are both readable and writable, but share
  19910. // the same options object.
  19911. // However, some cases require setting options to different
  19912. // values for the readable and the writable sides of the duplex stream,
  19913. // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
  19914. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  19915. // contains buffers or objects.
  19916. this.objectMode = !!options.objectMode;
  19917. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  19918. // Note: 0 is a valid value, means that we always return false if
  19919. // the entire buffer is not flushed immediately on write()
  19920. this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
  19921. this.finalCalled = false; // drain event flag.
  19922. this.needDrain = false; // at the start of calling end()
  19923. this.ending = false; // when end() has been called, and returned
  19924. this.ended = false; // when 'finish' is emitted
  19925. this.finished = false; // has it been destroyed
  19926. this.destroyed = false; // should we decode strings into buffers before passing to _write?
  19927. // this is here so that some node-core streams can optimize string
  19928. // handling at a lower level.
  19929. var noDecode = options.decodeStrings === false;
  19930. this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
  19931. // encoding is 'binary' so we have to make this configurable.
  19932. // Everything else in the universe uses 'utf8', though.
  19933. this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  19934. // of how much we're waiting to get pushed to some underlying
  19935. // socket or file.
  19936. this.length = 0; // a flag to see when we're in the middle of a write.
  19937. this.writing = false; // when true all writes will be buffered until .uncork() call
  19938. this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  19939. // or on a later tick. We set this to true at first, because any
  19940. // actions that shouldn't happen until "later" should generally also
  19941. // not happen before the first write call.
  19942. this.sync = true; // a flag to know if we're processing previously buffered items, which
  19943. // may call the _write() callback in the same tick, so that we don't
  19944. // end up in an overlapped onwrite situation.
  19945. this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
  19946. this.onwrite = function (er) {
  19947. onwrite(stream, er);
  19948. }; // the callback that the user supplies to write(chunk,encoding,cb)
  19949. this.writecb = null; // the amount that is being written when _write is called.
  19950. this.writelen = 0;
  19951. this.bufferedRequest = null;
  19952. this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  19953. // this must be 0 before 'finish' can be emitted
  19954. this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  19955. // This is relevant for synchronous Transform streams
  19956. this.prefinished = false; // True if the error was already emitted and should not be thrown again
  19957. this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
  19958. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
  19959. this.autoDestroy = !!options.autoDestroy; // count buffered requests
  19960. this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  19961. // one allocated and free to use, and we maintain at most two
  19962. this.corkedRequestsFree = new CorkedRequest(this);
  19963. }
  19964. WritableState.prototype.getBuffer = function getBuffer() {
  19965. var current = this.bufferedRequest;
  19966. var out = [];
  19967. while (current) {
  19968. out.push(current);
  19969. current = current.next;
  19970. }
  19971. return out;
  19972. };
  19973. (function () {
  19974. try {
  19975. Object.defineProperty(WritableState.prototype, 'buffer', {
  19976. get: internalUtil.deprecate(function writableStateBufferGetter() {
  19977. return this.getBuffer();
  19978. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  19979. });
  19980. } catch (_) {}
  19981. })(); // Test _writableState for inheritance to account for Duplex streams,
  19982. // whose prototype chain only points to Readable.
  19983. var realHasInstance;
  19984. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  19985. realHasInstance = Function.prototype[Symbol.hasInstance];
  19986. Object.defineProperty(Writable, Symbol.hasInstance, {
  19987. value: function value(object) {
  19988. if (realHasInstance.call(this, object)) return true;
  19989. if (this !== Writable) return false;
  19990. return object && object._writableState instanceof WritableState;
  19991. }
  19992. });
  19993. } else {
  19994. realHasInstance = function realHasInstance(object) {
  19995. return object instanceof this;
  19996. };
  19997. }
  19998. function Writable(options) {
  19999. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js"); // Writable ctor is applied to Duplexes, too.
  20000. // `realHasInstance` is necessary because using plain `instanceof`
  20001. // would return false, as no `_writableState` property is attached.
  20002. // Trying to use the custom `instanceof` for Writable here will also break the
  20003. // Node.js LazyTransform implementation, which has a non-trivial getter for
  20004. // `_writableState` that would lead to infinite recursion.
  20005. // Checking for a Stream.Duplex instance is faster here instead of inside
  20006. // the WritableState constructor, at least with V8 6.5
  20007. var isDuplex = this instanceof Duplex;
  20008. if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  20009. this._writableState = new WritableState(options, this, isDuplex); // legacy.
  20010. this.writable = true;
  20011. if (options) {
  20012. if (typeof options.write === 'function') this._write = options.write;
  20013. if (typeof options.writev === 'function') this._writev = options.writev;
  20014. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  20015. if (typeof options.final === 'function') this._final = options.final;
  20016. }
  20017. Stream.call(this);
  20018. } // Otherwise people can pipe Writable streams, which is just wrong.
  20019. Writable.prototype.pipe = function () {
  20020. errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
  20021. };
  20022. function writeAfterEnd(stream, cb) {
  20023. var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
  20024. errorOrDestroy(stream, er);
  20025. process.nextTick(cb, er);
  20026. } // Checks that a user-supplied chunk is valid, especially for the particular
  20027. // mode the stream is in. Currently this means that `null` is never accepted
  20028. // and undefined/non-string values are only allowed in object mode.
  20029. function validChunk(stream, state, chunk, cb) {
  20030. var er;
  20031. if (chunk === null) {
  20032. er = new ERR_STREAM_NULL_VALUES();
  20033. } else if (typeof chunk !== 'string' && !state.objectMode) {
  20034. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  20035. }
  20036. if (er) {
  20037. errorOrDestroy(stream, er);
  20038. process.nextTick(cb, er);
  20039. return false;
  20040. }
  20041. return true;
  20042. }
  20043. Writable.prototype.write = function (chunk, encoding, cb) {
  20044. var state = this._writableState;
  20045. var ret = false;
  20046. var isBuf = !state.objectMode && _isUint8Array(chunk);
  20047. if (isBuf && !Buffer.isBuffer(chunk)) {
  20048. chunk = _uint8ArrayToBuffer(chunk);
  20049. }
  20050. if (typeof encoding === 'function') {
  20051. cb = encoding;
  20052. encoding = null;
  20053. }
  20054. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  20055. if (typeof cb !== 'function') cb = nop;
  20056. if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  20057. state.pendingcb++;
  20058. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  20059. }
  20060. return ret;
  20061. };
  20062. Writable.prototype.cork = function () {
  20063. this._writableState.corked++;
  20064. };
  20065. Writable.prototype.uncork = function () {
  20066. var state = this._writableState;
  20067. if (state.corked) {
  20068. state.corked--;
  20069. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  20070. }
  20071. };
  20072. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  20073. // node::ParseEncoding() requires lower case.
  20074. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  20075. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  20076. this._writableState.defaultEncoding = encoding;
  20077. return this;
  20078. };
  20079. Object.defineProperty(Writable.prototype, 'writableBuffer', {
  20080. // making it explicit this property is not enumerable
  20081. // because otherwise some prototype manipulation in
  20082. // userland will fail
  20083. enumerable: false,
  20084. get: function get() {
  20085. return this._writableState && this._writableState.getBuffer();
  20086. }
  20087. });
  20088. function decodeChunk(state, chunk, encoding) {
  20089. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  20090. chunk = Buffer.from(chunk, encoding);
  20091. }
  20092. return chunk;
  20093. }
  20094. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  20095. // making it explicit this property is not enumerable
  20096. // because otherwise some prototype manipulation in
  20097. // userland will fail
  20098. enumerable: false,
  20099. get: function get() {
  20100. return this._writableState.highWaterMark;
  20101. }
  20102. }); // if we're already writing something, then just put this
  20103. // in the queue, and wait our turn. Otherwise, call _write
  20104. // If we return false, then we need a drain event, so set that flag.
  20105. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  20106. if (!isBuf) {
  20107. var newChunk = decodeChunk(state, chunk, encoding);
  20108. if (chunk !== newChunk) {
  20109. isBuf = true;
  20110. encoding = 'buffer';
  20111. chunk = newChunk;
  20112. }
  20113. }
  20114. var len = state.objectMode ? 1 : chunk.length;
  20115. state.length += len;
  20116. var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
  20117. if (!ret) state.needDrain = true;
  20118. if (state.writing || state.corked) {
  20119. var last = state.lastBufferedRequest;
  20120. state.lastBufferedRequest = {
  20121. chunk: chunk,
  20122. encoding: encoding,
  20123. isBuf: isBuf,
  20124. callback: cb,
  20125. next: null
  20126. };
  20127. if (last) {
  20128. last.next = state.lastBufferedRequest;
  20129. } else {
  20130. state.bufferedRequest = state.lastBufferedRequest;
  20131. }
  20132. state.bufferedRequestCount += 1;
  20133. } else {
  20134. doWrite(stream, state, false, len, chunk, encoding, cb);
  20135. }
  20136. return ret;
  20137. }
  20138. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  20139. state.writelen = len;
  20140. state.writecb = cb;
  20141. state.writing = true;
  20142. state.sync = true;
  20143. if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  20144. state.sync = false;
  20145. }
  20146. function onwriteError(stream, state, sync, er, cb) {
  20147. --state.pendingcb;
  20148. if (sync) {
  20149. // defer the callback if we are being called synchronously
  20150. // to avoid piling up things on the stack
  20151. process.nextTick(cb, er); // this can emit finish, and it will always happen
  20152. // after error
  20153. process.nextTick(finishMaybe, stream, state);
  20154. stream._writableState.errorEmitted = true;
  20155. errorOrDestroy(stream, er);
  20156. } else {
  20157. // the caller expect this to happen before if
  20158. // it is async
  20159. cb(er);
  20160. stream._writableState.errorEmitted = true;
  20161. errorOrDestroy(stream, er); // this can emit finish, but finish must
  20162. // always follow error
  20163. finishMaybe(stream, state);
  20164. }
  20165. }
  20166. function onwriteStateUpdate(state) {
  20167. state.writing = false;
  20168. state.writecb = null;
  20169. state.length -= state.writelen;
  20170. state.writelen = 0;
  20171. }
  20172. function onwrite(stream, er) {
  20173. var state = stream._writableState;
  20174. var sync = state.sync;
  20175. var cb = state.writecb;
  20176. if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  20177. onwriteStateUpdate(state);
  20178. if (er) onwriteError(stream, state, sync, er, cb);else {
  20179. // Check if we're actually ready to finish, but don't emit yet
  20180. var finished = needFinish(state) || stream.destroyed;
  20181. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  20182. clearBuffer(stream, state);
  20183. }
  20184. if (sync) {
  20185. process.nextTick(afterWrite, stream, state, finished, cb);
  20186. } else {
  20187. afterWrite(stream, state, finished, cb);
  20188. }
  20189. }
  20190. }
  20191. function afterWrite(stream, state, finished, cb) {
  20192. if (!finished) onwriteDrain(stream, state);
  20193. state.pendingcb--;
  20194. cb();
  20195. finishMaybe(stream, state);
  20196. } // Must force callback to be called on nextTick, so that we don't
  20197. // emit 'drain' before the write() consumer gets the 'false' return
  20198. // value, and has a chance to attach a 'drain' listener.
  20199. function onwriteDrain(stream, state) {
  20200. if (state.length === 0 && state.needDrain) {
  20201. state.needDrain = false;
  20202. stream.emit('drain');
  20203. }
  20204. } // if there's something in the buffer waiting, then process it
  20205. function clearBuffer(stream, state) {
  20206. state.bufferProcessing = true;
  20207. var entry = state.bufferedRequest;
  20208. if (stream._writev && entry && entry.next) {
  20209. // Fast case, write everything using _writev()
  20210. var l = state.bufferedRequestCount;
  20211. var buffer = new Array(l);
  20212. var holder = state.corkedRequestsFree;
  20213. holder.entry = entry;
  20214. var count = 0;
  20215. var allBuffers = true;
  20216. while (entry) {
  20217. buffer[count] = entry;
  20218. if (!entry.isBuf) allBuffers = false;
  20219. entry = entry.next;
  20220. count += 1;
  20221. }
  20222. buffer.allBuffers = allBuffers;
  20223. doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
  20224. // as the hot path ends with doWrite
  20225. state.pendingcb++;
  20226. state.lastBufferedRequest = null;
  20227. if (holder.next) {
  20228. state.corkedRequestsFree = holder.next;
  20229. holder.next = null;
  20230. } else {
  20231. state.corkedRequestsFree = new CorkedRequest(state);
  20232. }
  20233. state.bufferedRequestCount = 0;
  20234. } else {
  20235. // Slow case, write chunks one-by-one
  20236. while (entry) {
  20237. var chunk = entry.chunk;
  20238. var encoding = entry.encoding;
  20239. var cb = entry.callback;
  20240. var len = state.objectMode ? 1 : chunk.length;
  20241. doWrite(stream, state, false, len, chunk, encoding, cb);
  20242. entry = entry.next;
  20243. state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
  20244. // it means that we need to wait until it does.
  20245. // also, that means that the chunk and cb are currently
  20246. // being processed, so move the buffer counter past them.
  20247. if (state.writing) {
  20248. break;
  20249. }
  20250. }
  20251. if (entry === null) state.lastBufferedRequest = null;
  20252. }
  20253. state.bufferedRequest = entry;
  20254. state.bufferProcessing = false;
  20255. }
  20256. Writable.prototype._write = function (chunk, encoding, cb) {
  20257. cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
  20258. };
  20259. Writable.prototype._writev = null;
  20260. Writable.prototype.end = function (chunk, encoding, cb) {
  20261. var state = this._writableState;
  20262. if (typeof chunk === 'function') {
  20263. cb = chunk;
  20264. chunk = null;
  20265. encoding = null;
  20266. } else if (typeof encoding === 'function') {
  20267. cb = encoding;
  20268. encoding = null;
  20269. }
  20270. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
  20271. if (state.corked) {
  20272. state.corked = 1;
  20273. this.uncork();
  20274. } // ignore unnecessary end() calls.
  20275. if (!state.ending) endWritable(this, state, cb);
  20276. return this;
  20277. };
  20278. Object.defineProperty(Writable.prototype, 'writableLength', {
  20279. // making it explicit this property is not enumerable
  20280. // because otherwise some prototype manipulation in
  20281. // userland will fail
  20282. enumerable: false,
  20283. get: function get() {
  20284. return this._writableState.length;
  20285. }
  20286. });
  20287. function needFinish(state) {
  20288. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  20289. }
  20290. function callFinal(stream, state) {
  20291. stream._final(function (err) {
  20292. state.pendingcb--;
  20293. if (err) {
  20294. errorOrDestroy(stream, err);
  20295. }
  20296. state.prefinished = true;
  20297. stream.emit('prefinish');
  20298. finishMaybe(stream, state);
  20299. });
  20300. }
  20301. function prefinish(stream, state) {
  20302. if (!state.prefinished && !state.finalCalled) {
  20303. if (typeof stream._final === 'function' && !state.destroyed) {
  20304. state.pendingcb++;
  20305. state.finalCalled = true;
  20306. process.nextTick(callFinal, stream, state);
  20307. } else {
  20308. state.prefinished = true;
  20309. stream.emit('prefinish');
  20310. }
  20311. }
  20312. }
  20313. function finishMaybe(stream, state) {
  20314. var need = needFinish(state);
  20315. if (need) {
  20316. prefinish(stream, state);
  20317. if (state.pendingcb === 0) {
  20318. state.finished = true;
  20319. stream.emit('finish');
  20320. if (state.autoDestroy) {
  20321. // In case of duplex streams we need a way to detect
  20322. // if the readable side is ready for autoDestroy as well
  20323. var rState = stream._readableState;
  20324. if (!rState || rState.autoDestroy && rState.endEmitted) {
  20325. stream.destroy();
  20326. }
  20327. }
  20328. }
  20329. }
  20330. return need;
  20331. }
  20332. function endWritable(stream, state, cb) {
  20333. state.ending = true;
  20334. finishMaybe(stream, state);
  20335. if (cb) {
  20336. if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
  20337. }
  20338. state.ended = true;
  20339. stream.writable = false;
  20340. }
  20341. function onCorkedFinish(corkReq, state, err) {
  20342. var entry = corkReq.entry;
  20343. corkReq.entry = null;
  20344. while (entry) {
  20345. var cb = entry.callback;
  20346. state.pendingcb--;
  20347. cb(err);
  20348. entry = entry.next;
  20349. } // reuse the free corkReq.
  20350. state.corkedRequestsFree.next = corkReq;
  20351. }
  20352. Object.defineProperty(Writable.prototype, 'destroyed', {
  20353. // making it explicit this property is not enumerable
  20354. // because otherwise some prototype manipulation in
  20355. // userland will fail
  20356. enumerable: false,
  20357. get: function get() {
  20358. if (this._writableState === undefined) {
  20359. return false;
  20360. }
  20361. return this._writableState.destroyed;
  20362. },
  20363. set: function set(value) {
  20364. // we ignore the value if the stream
  20365. // has not been initialized yet
  20366. if (!this._writableState) {
  20367. return;
  20368. } // backward compatibility, the user is explicitly
  20369. // managing destroyed
  20370. this._writableState.destroyed = value;
  20371. }
  20372. });
  20373. Writable.prototype.destroy = destroyImpl.destroy;
  20374. Writable.prototype._undestroy = destroyImpl.undestroy;
  20375. Writable.prototype._destroy = function (err, cb) {
  20376. cb(err);
  20377. };
  20378. /***/ }),
  20379. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/async_iterator.js":
  20380. /*!**********************************************************************************************************!*\
  20381. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/async_iterator.js ***!
  20382. \**********************************************************************************************************/
  20383. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20384. "use strict";
  20385. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  20386. var _Object$setPrototypeO;
  20387. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  20388. var finished = __webpack_require__(/*! ./end-of-stream */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  20389. var kLastResolve = Symbol('lastResolve');
  20390. var kLastReject = Symbol('lastReject');
  20391. var kError = Symbol('error');
  20392. var kEnded = Symbol('ended');
  20393. var kLastPromise = Symbol('lastPromise');
  20394. var kHandlePromise = Symbol('handlePromise');
  20395. var kStream = Symbol('stream');
  20396. function createIterResult(value, done) {
  20397. return {
  20398. value: value,
  20399. done: done
  20400. };
  20401. }
  20402. function readAndResolve(iter) {
  20403. var resolve = iter[kLastResolve];
  20404. if (resolve !== null) {
  20405. var data = iter[kStream].read(); // we defer if data is null
  20406. // we can be expecting either 'end' or
  20407. // 'error'
  20408. if (data !== null) {
  20409. iter[kLastPromise] = null;
  20410. iter[kLastResolve] = null;
  20411. iter[kLastReject] = null;
  20412. resolve(createIterResult(data, false));
  20413. }
  20414. }
  20415. }
  20416. function onReadable(iter) {
  20417. // we wait for the next tick, because it might
  20418. // emit an error with process.nextTick
  20419. process.nextTick(readAndResolve, iter);
  20420. }
  20421. function wrapForNext(lastPromise, iter) {
  20422. return function (resolve, reject) {
  20423. lastPromise.then(function () {
  20424. if (iter[kEnded]) {
  20425. resolve(createIterResult(undefined, true));
  20426. return;
  20427. }
  20428. iter[kHandlePromise](resolve, reject);
  20429. }, reject);
  20430. };
  20431. }
  20432. var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
  20433. var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
  20434. get stream() {
  20435. return this[kStream];
  20436. },
  20437. next: function next() {
  20438. var _this = this;
  20439. // if we have detected an error in the meanwhile
  20440. // reject straight away
  20441. var error = this[kError];
  20442. if (error !== null) {
  20443. return Promise.reject(error);
  20444. }
  20445. if (this[kEnded]) {
  20446. return Promise.resolve(createIterResult(undefined, true));
  20447. }
  20448. if (this[kStream].destroyed) {
  20449. // We need to defer via nextTick because if .destroy(err) is
  20450. // called, the error will be emitted via nextTick, and
  20451. // we cannot guarantee that there is no error lingering around
  20452. // waiting to be emitted.
  20453. return new Promise(function (resolve, reject) {
  20454. process.nextTick(function () {
  20455. if (_this[kError]) {
  20456. reject(_this[kError]);
  20457. } else {
  20458. resolve(createIterResult(undefined, true));
  20459. }
  20460. });
  20461. });
  20462. } // if we have multiple next() calls
  20463. // we will wait for the previous Promise to finish
  20464. // this logic is optimized to support for await loops,
  20465. // where next() is only called once at a time
  20466. var lastPromise = this[kLastPromise];
  20467. var promise;
  20468. if (lastPromise) {
  20469. promise = new Promise(wrapForNext(lastPromise, this));
  20470. } else {
  20471. // fast path needed to support multiple this.push()
  20472. // without triggering the next() queue
  20473. var data = this[kStream].read();
  20474. if (data !== null) {
  20475. return Promise.resolve(createIterResult(data, false));
  20476. }
  20477. promise = new Promise(this[kHandlePromise]);
  20478. }
  20479. this[kLastPromise] = promise;
  20480. return promise;
  20481. }
  20482. }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
  20483. return this;
  20484. }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
  20485. var _this2 = this;
  20486. // destroy(err, cb) is a private API
  20487. // we can guarantee we have that here, because we control the
  20488. // Readable class this is attached to
  20489. return new Promise(function (resolve, reject) {
  20490. _this2[kStream].destroy(null, function (err) {
  20491. if (err) {
  20492. reject(err);
  20493. return;
  20494. }
  20495. resolve(createIterResult(undefined, true));
  20496. });
  20497. });
  20498. }), _Object$setPrototypeO), AsyncIteratorPrototype);
  20499. var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
  20500. var _Object$create;
  20501. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
  20502. value: stream,
  20503. writable: true
  20504. }), _defineProperty(_Object$create, kLastResolve, {
  20505. value: null,
  20506. writable: true
  20507. }), _defineProperty(_Object$create, kLastReject, {
  20508. value: null,
  20509. writable: true
  20510. }), _defineProperty(_Object$create, kError, {
  20511. value: null,
  20512. writable: true
  20513. }), _defineProperty(_Object$create, kEnded, {
  20514. value: stream._readableState.endEmitted,
  20515. writable: true
  20516. }), _defineProperty(_Object$create, kHandlePromise, {
  20517. value: function value(resolve, reject) {
  20518. var data = iterator[kStream].read();
  20519. if (data) {
  20520. iterator[kLastPromise] = null;
  20521. iterator[kLastResolve] = null;
  20522. iterator[kLastReject] = null;
  20523. resolve(createIterResult(data, false));
  20524. } else {
  20525. iterator[kLastResolve] = resolve;
  20526. iterator[kLastReject] = reject;
  20527. }
  20528. },
  20529. writable: true
  20530. }), _Object$create));
  20531. iterator[kLastPromise] = null;
  20532. finished(stream, function (err) {
  20533. if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
  20534. var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
  20535. // returned by next() and store the error
  20536. if (reject !== null) {
  20537. iterator[kLastPromise] = null;
  20538. iterator[kLastResolve] = null;
  20539. iterator[kLastReject] = null;
  20540. reject(err);
  20541. }
  20542. iterator[kError] = err;
  20543. return;
  20544. }
  20545. var resolve = iterator[kLastResolve];
  20546. if (resolve !== null) {
  20547. iterator[kLastPromise] = null;
  20548. iterator[kLastResolve] = null;
  20549. iterator[kLastReject] = null;
  20550. resolve(createIterResult(undefined, true));
  20551. }
  20552. iterator[kEnded] = true;
  20553. });
  20554. stream.on('readable', onReadable.bind(null, iterator));
  20555. return iterator;
  20556. };
  20557. module.exports = createReadableStreamAsyncIterator;
  20558. /***/ }),
  20559. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/buffer_list.js":
  20560. /*!*******************************************************************************************************!*\
  20561. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/buffer_list.js ***!
  20562. \*******************************************************************************************************/
  20563. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20564. "use strict";
  20565. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  20566. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  20567. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  20568. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20569. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  20570. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20571. var _require = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"),
  20572. Buffer = _require.Buffer;
  20573. var _require2 = __webpack_require__(/*! util */ "?07b7"),
  20574. inspect = _require2.inspect;
  20575. var custom = inspect && inspect.custom || 'inspect';
  20576. function copyBuffer(src, target, offset) {
  20577. Buffer.prototype.copy.call(src, target, offset);
  20578. }
  20579. module.exports =
  20580. /*#__PURE__*/
  20581. function () {
  20582. function BufferList() {
  20583. _classCallCheck(this, BufferList);
  20584. this.head = null;
  20585. this.tail = null;
  20586. this.length = 0;
  20587. }
  20588. _createClass(BufferList, [{
  20589. key: "push",
  20590. value: function push(v) {
  20591. var entry = {
  20592. data: v,
  20593. next: null
  20594. };
  20595. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  20596. this.tail = entry;
  20597. ++this.length;
  20598. }
  20599. }, {
  20600. key: "unshift",
  20601. value: function unshift(v) {
  20602. var entry = {
  20603. data: v,
  20604. next: this.head
  20605. };
  20606. if (this.length === 0) this.tail = entry;
  20607. this.head = entry;
  20608. ++this.length;
  20609. }
  20610. }, {
  20611. key: "shift",
  20612. value: function shift() {
  20613. if (this.length === 0) return;
  20614. var ret = this.head.data;
  20615. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  20616. --this.length;
  20617. return ret;
  20618. }
  20619. }, {
  20620. key: "clear",
  20621. value: function clear() {
  20622. this.head = this.tail = null;
  20623. this.length = 0;
  20624. }
  20625. }, {
  20626. key: "join",
  20627. value: function join(s) {
  20628. if (this.length === 0) return '';
  20629. var p = this.head;
  20630. var ret = '' + p.data;
  20631. while (p = p.next) {
  20632. ret += s + p.data;
  20633. }
  20634. return ret;
  20635. }
  20636. }, {
  20637. key: "concat",
  20638. value: function concat(n) {
  20639. if (this.length === 0) return Buffer.alloc(0);
  20640. var ret = Buffer.allocUnsafe(n >>> 0);
  20641. var p = this.head;
  20642. var i = 0;
  20643. while (p) {
  20644. copyBuffer(p.data, ret, i);
  20645. i += p.data.length;
  20646. p = p.next;
  20647. }
  20648. return ret;
  20649. } // Consumes a specified amount of bytes or characters from the buffered data.
  20650. }, {
  20651. key: "consume",
  20652. value: function consume(n, hasStrings) {
  20653. var ret;
  20654. if (n < this.head.data.length) {
  20655. // `slice` is the same for buffers and strings.
  20656. ret = this.head.data.slice(0, n);
  20657. this.head.data = this.head.data.slice(n);
  20658. } else if (n === this.head.data.length) {
  20659. // First chunk is a perfect match.
  20660. ret = this.shift();
  20661. } else {
  20662. // Result spans more than one buffer.
  20663. ret = hasStrings ? this._getString(n) : this._getBuffer(n);
  20664. }
  20665. return ret;
  20666. }
  20667. }, {
  20668. key: "first",
  20669. value: function first() {
  20670. return this.head.data;
  20671. } // Consumes a specified amount of characters from the buffered data.
  20672. }, {
  20673. key: "_getString",
  20674. value: function _getString(n) {
  20675. var p = this.head;
  20676. var c = 1;
  20677. var ret = p.data;
  20678. n -= ret.length;
  20679. while (p = p.next) {
  20680. var str = p.data;
  20681. var nb = n > str.length ? str.length : n;
  20682. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  20683. n -= nb;
  20684. if (n === 0) {
  20685. if (nb === str.length) {
  20686. ++c;
  20687. if (p.next) this.head = p.next;else this.head = this.tail = null;
  20688. } else {
  20689. this.head = p;
  20690. p.data = str.slice(nb);
  20691. }
  20692. break;
  20693. }
  20694. ++c;
  20695. }
  20696. this.length -= c;
  20697. return ret;
  20698. } // Consumes a specified amount of bytes from the buffered data.
  20699. }, {
  20700. key: "_getBuffer",
  20701. value: function _getBuffer(n) {
  20702. var ret = Buffer.allocUnsafe(n);
  20703. var p = this.head;
  20704. var c = 1;
  20705. p.data.copy(ret);
  20706. n -= p.data.length;
  20707. while (p = p.next) {
  20708. var buf = p.data;
  20709. var nb = n > buf.length ? buf.length : n;
  20710. buf.copy(ret, ret.length - n, 0, nb);
  20711. n -= nb;
  20712. if (n === 0) {
  20713. if (nb === buf.length) {
  20714. ++c;
  20715. if (p.next) this.head = p.next;else this.head = this.tail = null;
  20716. } else {
  20717. this.head = p;
  20718. p.data = buf.slice(nb);
  20719. }
  20720. break;
  20721. }
  20722. ++c;
  20723. }
  20724. this.length -= c;
  20725. return ret;
  20726. } // Make sure the linked list only shows the minimal necessary information.
  20727. }, {
  20728. key: custom,
  20729. value: function value(_, options) {
  20730. return inspect(this, _objectSpread({}, options, {
  20731. // Only inspect one level.
  20732. depth: 0,
  20733. // It should not recurse.
  20734. customInspect: false
  20735. }));
  20736. }
  20737. }]);
  20738. return BufferList;
  20739. }();
  20740. /***/ }),
  20741. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/destroy.js":
  20742. /*!***************************************************************************************************!*\
  20743. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/destroy.js ***!
  20744. \***************************************************************************************************/
  20745. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20746. "use strict";
  20747. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  20748. // undocumented cb() API, needed for core, not for public API
  20749. function destroy(err, cb) {
  20750. var _this = this;
  20751. var readableDestroyed = this._readableState && this._readableState.destroyed;
  20752. var writableDestroyed = this._writableState && this._writableState.destroyed;
  20753. if (readableDestroyed || writableDestroyed) {
  20754. if (cb) {
  20755. cb(err);
  20756. } else if (err) {
  20757. if (!this._writableState) {
  20758. process.nextTick(emitErrorNT, this, err);
  20759. } else if (!this._writableState.errorEmitted) {
  20760. this._writableState.errorEmitted = true;
  20761. process.nextTick(emitErrorNT, this, err);
  20762. }
  20763. }
  20764. return this;
  20765. } // we set destroyed to true before firing error callbacks in order
  20766. // to make it re-entrance safe in case destroy() is called within callbacks
  20767. if (this._readableState) {
  20768. this._readableState.destroyed = true;
  20769. } // if this is a duplex stream mark the writable part as destroyed as well
  20770. if (this._writableState) {
  20771. this._writableState.destroyed = true;
  20772. }
  20773. this._destroy(err || null, function (err) {
  20774. if (!cb && err) {
  20775. if (!_this._writableState) {
  20776. process.nextTick(emitErrorAndCloseNT, _this, err);
  20777. } else if (!_this._writableState.errorEmitted) {
  20778. _this._writableState.errorEmitted = true;
  20779. process.nextTick(emitErrorAndCloseNT, _this, err);
  20780. } else {
  20781. process.nextTick(emitCloseNT, _this);
  20782. }
  20783. } else if (cb) {
  20784. process.nextTick(emitCloseNT, _this);
  20785. cb(err);
  20786. } else {
  20787. process.nextTick(emitCloseNT, _this);
  20788. }
  20789. });
  20790. return this;
  20791. }
  20792. function emitErrorAndCloseNT(self, err) {
  20793. emitErrorNT(self, err);
  20794. emitCloseNT(self);
  20795. }
  20796. function emitCloseNT(self) {
  20797. if (self._writableState && !self._writableState.emitClose) return;
  20798. if (self._readableState && !self._readableState.emitClose) return;
  20799. self.emit('close');
  20800. }
  20801. function undestroy() {
  20802. if (this._readableState) {
  20803. this._readableState.destroyed = false;
  20804. this._readableState.reading = false;
  20805. this._readableState.ended = false;
  20806. this._readableState.endEmitted = false;
  20807. }
  20808. if (this._writableState) {
  20809. this._writableState.destroyed = false;
  20810. this._writableState.ended = false;
  20811. this._writableState.ending = false;
  20812. this._writableState.finalCalled = false;
  20813. this._writableState.prefinished = false;
  20814. this._writableState.finished = false;
  20815. this._writableState.errorEmitted = false;
  20816. }
  20817. }
  20818. function emitErrorNT(self, err) {
  20819. self.emit('error', err);
  20820. }
  20821. function errorOrDestroy(stream, err) {
  20822. // We have tests that rely on errors being emitted
  20823. // in the same tick, so changing this is semver major.
  20824. // For now when you opt-in to autoDestroy we allow
  20825. // the error to be emitted nextTick. In a future
  20826. // semver major update we should change the default to this.
  20827. var rState = stream._readableState;
  20828. var wState = stream._writableState;
  20829. if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
  20830. }
  20831. module.exports = {
  20832. destroy: destroy,
  20833. undestroy: undestroy,
  20834. errorOrDestroy: errorOrDestroy
  20835. };
  20836. /***/ }),
  20837. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/end-of-stream.js":
  20838. /*!*********************************************************************************************************!*\
  20839. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/end-of-stream.js ***!
  20840. \*********************************************************************************************************/
  20841. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20842. "use strict";
  20843. // Ported from https://github.com/mafintosh/end-of-stream with
  20844. // permission from the author, Mathias Buus (@mafintosh).
  20845. var ERR_STREAM_PREMATURE_CLOSE = (__webpack_require__(/*! ../../../errors */ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js").codes.ERR_STREAM_PREMATURE_CLOSE);
  20846. function once(callback) {
  20847. var called = false;
  20848. return function () {
  20849. if (called) return;
  20850. called = true;
  20851. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  20852. args[_key] = arguments[_key];
  20853. }
  20854. callback.apply(this, args);
  20855. };
  20856. }
  20857. function noop() {}
  20858. function isRequest(stream) {
  20859. return stream.setHeader && typeof stream.abort === 'function';
  20860. }
  20861. function eos(stream, opts, callback) {
  20862. if (typeof opts === 'function') return eos(stream, null, opts);
  20863. if (!opts) opts = {};
  20864. callback = once(callback || noop);
  20865. var readable = opts.readable || opts.readable !== false && stream.readable;
  20866. var writable = opts.writable || opts.writable !== false && stream.writable;
  20867. var onlegacyfinish = function onlegacyfinish() {
  20868. if (!stream.writable) onfinish();
  20869. };
  20870. var writableEnded = stream._writableState && stream._writableState.finished;
  20871. var onfinish = function onfinish() {
  20872. writable = false;
  20873. writableEnded = true;
  20874. if (!readable) callback.call(stream);
  20875. };
  20876. var readableEnded = stream._readableState && stream._readableState.endEmitted;
  20877. var onend = function onend() {
  20878. readable = false;
  20879. readableEnded = true;
  20880. if (!writable) callback.call(stream);
  20881. };
  20882. var onerror = function onerror(err) {
  20883. callback.call(stream, err);
  20884. };
  20885. var onclose = function onclose() {
  20886. var err;
  20887. if (readable && !readableEnded) {
  20888. if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  20889. return callback.call(stream, err);
  20890. }
  20891. if (writable && !writableEnded) {
  20892. if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  20893. return callback.call(stream, err);
  20894. }
  20895. };
  20896. var onrequest = function onrequest() {
  20897. stream.req.on('finish', onfinish);
  20898. };
  20899. if (isRequest(stream)) {
  20900. stream.on('complete', onfinish);
  20901. stream.on('abort', onclose);
  20902. if (stream.req) onrequest();else stream.on('request', onrequest);
  20903. } else if (writable && !stream._writableState) {
  20904. // legacy streams
  20905. stream.on('end', onlegacyfinish);
  20906. stream.on('close', onlegacyfinish);
  20907. }
  20908. stream.on('end', onend);
  20909. stream.on('finish', onfinish);
  20910. if (opts.error !== false) stream.on('error', onerror);
  20911. stream.on('close', onclose);
  20912. return function () {
  20913. stream.removeListener('complete', onfinish);
  20914. stream.removeListener('abort', onclose);
  20915. stream.removeListener('request', onrequest);
  20916. if (stream.req) stream.req.removeListener('finish', onfinish);
  20917. stream.removeListener('end', onlegacyfinish);
  20918. stream.removeListener('close', onlegacyfinish);
  20919. stream.removeListener('finish', onfinish);
  20920. stream.removeListener('end', onend);
  20921. stream.removeListener('error', onerror);
  20922. stream.removeListener('close', onclose);
  20923. };
  20924. }
  20925. module.exports = eos;
  20926. /***/ }),
  20927. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/from-browser.js":
  20928. /*!********************************************************************************************************!*\
  20929. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/from-browser.js ***!
  20930. \********************************************************************************************************/
  20931. /***/ ((module) => {
  20932. module.exports = function () {
  20933. throw new Error('Readable.from is not available in the browser')
  20934. };
  20935. /***/ }),
  20936. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/pipeline.js":
  20937. /*!****************************************************************************************************!*\
  20938. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/pipeline.js ***!
  20939. \****************************************************************************************************/
  20940. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  20941. "use strict";
  20942. // Ported from https://github.com/mafintosh/pump with
  20943. // permission from the author, Mathias Buus (@mafintosh).
  20944. var eos;
  20945. function once(callback) {
  20946. var called = false;
  20947. return function () {
  20948. if (called) return;
  20949. called = true;
  20950. callback.apply(void 0, arguments);
  20951. };
  20952. }
  20953. var _require$codes = (__webpack_require__(/*! ../../../errors */ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js").codes),
  20954. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
  20955. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
  20956. function noop(err) {
  20957. // Rethrow the error if it exists to avoid swallowing it
  20958. if (err) throw err;
  20959. }
  20960. function isRequest(stream) {
  20961. return stream.setHeader && typeof stream.abort === 'function';
  20962. }
  20963. function destroyer(stream, reading, writing, callback) {
  20964. callback = once(callback);
  20965. var closed = false;
  20966. stream.on('close', function () {
  20967. closed = true;
  20968. });
  20969. if (eos === undefined) eos = __webpack_require__(/*! ./end-of-stream */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  20970. eos(stream, {
  20971. readable: reading,
  20972. writable: writing
  20973. }, function (err) {
  20974. if (err) return callback(err);
  20975. closed = true;
  20976. callback();
  20977. });
  20978. var destroyed = false;
  20979. return function (err) {
  20980. if (closed) return;
  20981. if (destroyed) return;
  20982. destroyed = true; // request.destroy just do .end - .abort is what we want
  20983. if (isRequest(stream)) return stream.abort();
  20984. if (typeof stream.destroy === 'function') return stream.destroy();
  20985. callback(err || new ERR_STREAM_DESTROYED('pipe'));
  20986. };
  20987. }
  20988. function call(fn) {
  20989. fn();
  20990. }
  20991. function pipe(from, to) {
  20992. return from.pipe(to);
  20993. }
  20994. function popCallback(streams) {
  20995. if (!streams.length) return noop;
  20996. if (typeof streams[streams.length - 1] !== 'function') return noop;
  20997. return streams.pop();
  20998. }
  20999. function pipeline() {
  21000. for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
  21001. streams[_key] = arguments[_key];
  21002. }
  21003. var callback = popCallback(streams);
  21004. if (Array.isArray(streams[0])) streams = streams[0];
  21005. if (streams.length < 2) {
  21006. throw new ERR_MISSING_ARGS('streams');
  21007. }
  21008. var error;
  21009. var destroys = streams.map(function (stream, i) {
  21010. var reading = i < streams.length - 1;
  21011. var writing = i > 0;
  21012. return destroyer(stream, reading, writing, function (err) {
  21013. if (!error) error = err;
  21014. if (err) destroys.forEach(call);
  21015. if (reading) return;
  21016. destroys.forEach(call);
  21017. callback(error);
  21018. });
  21019. });
  21020. return streams.reduce(pipe);
  21021. }
  21022. module.exports = pipeline;
  21023. /***/ }),
  21024. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/state.js":
  21025. /*!*************************************************************************************************!*\
  21026. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/state.js ***!
  21027. \*************************************************************************************************/
  21028. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21029. "use strict";
  21030. var ERR_INVALID_OPT_VALUE = (__webpack_require__(/*! ../../../errors */ "./node_modules/browserify-sign/node_modules/readable-stream/errors-browser.js").codes.ERR_INVALID_OPT_VALUE);
  21031. function highWaterMarkFrom(options, isDuplex, duplexKey) {
  21032. return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
  21033. }
  21034. function getHighWaterMark(state, options, duplexKey, isDuplex) {
  21035. var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
  21036. if (hwm != null) {
  21037. if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
  21038. var name = isDuplex ? duplexKey : 'highWaterMark';
  21039. throw new ERR_INVALID_OPT_VALUE(name, hwm);
  21040. }
  21041. return Math.floor(hwm);
  21042. } // Default value
  21043. return state.objectMode ? 16 : 16 * 1024;
  21044. }
  21045. module.exports = {
  21046. getHighWaterMark: getHighWaterMark
  21047. };
  21048. /***/ }),
  21049. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/stream-browser.js":
  21050. /*!**********************************************************************************************************!*\
  21051. !*** ./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/stream-browser.js ***!
  21052. \**********************************************************************************************************/
  21053. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21054. module.exports = __webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter;
  21055. /***/ }),
  21056. /***/ "./node_modules/browserify-sign/node_modules/readable-stream/readable-browser.js":
  21057. /*!***************************************************************************************!*\
  21058. !*** ./node_modules/browserify-sign/node_modules/readable-stream/readable-browser.js ***!
  21059. \***************************************************************************************/
  21060. /***/ ((module, exports, __webpack_require__) => {
  21061. exports = module.exports = __webpack_require__(/*! ./lib/_stream_readable.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js");
  21062. exports.Stream = exports;
  21063. exports.Readable = exports;
  21064. exports.Writable = __webpack_require__(/*! ./lib/_stream_writable.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js");
  21065. exports.Duplex = __webpack_require__(/*! ./lib/_stream_duplex.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js");
  21066. exports.Transform = __webpack_require__(/*! ./lib/_stream_transform.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_transform.js");
  21067. exports.PassThrough = __webpack_require__(/*! ./lib/_stream_passthrough.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_passthrough.js");
  21068. exports.finished = __webpack_require__(/*! ./lib/internal/streams/end-of-stream.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  21069. exports.pipeline = __webpack_require__(/*! ./lib/internal/streams/pipeline.js */ "./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/pipeline.js");
  21070. /***/ }),
  21071. /***/ "./node_modules/browserify-sign/node_modules/safe-buffer/index.js":
  21072. /*!************************************************************************!*\
  21073. !*** ./node_modules/browserify-sign/node_modules/safe-buffer/index.js ***!
  21074. \************************************************************************/
  21075. /***/ ((module, exports, __webpack_require__) => {
  21076. /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  21077. /* eslint-disable node/no-deprecated-api */
  21078. var buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")
  21079. var Buffer = buffer.Buffer
  21080. // alternative to using Object.keys for old browsers
  21081. function copyProps (src, dst) {
  21082. for (var key in src) {
  21083. dst[key] = src[key]
  21084. }
  21085. }
  21086. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  21087. module.exports = buffer
  21088. } else {
  21089. // Copy properties from require('buffer')
  21090. copyProps(buffer, exports)
  21091. exports.Buffer = SafeBuffer
  21092. }
  21093. function SafeBuffer (arg, encodingOrOffset, length) {
  21094. return Buffer(arg, encodingOrOffset, length)
  21095. }
  21096. SafeBuffer.prototype = Object.create(Buffer.prototype)
  21097. // Copy static methods from Buffer
  21098. copyProps(Buffer, SafeBuffer)
  21099. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  21100. if (typeof arg === 'number') {
  21101. throw new TypeError('Argument must not be a number')
  21102. }
  21103. return Buffer(arg, encodingOrOffset, length)
  21104. }
  21105. SafeBuffer.alloc = function (size, fill, encoding) {
  21106. if (typeof size !== 'number') {
  21107. throw new TypeError('Argument must be a number')
  21108. }
  21109. var buf = Buffer(size)
  21110. if (fill !== undefined) {
  21111. if (typeof encoding === 'string') {
  21112. buf.fill(fill, encoding)
  21113. } else {
  21114. buf.fill(fill)
  21115. }
  21116. } else {
  21117. buf.fill(0)
  21118. }
  21119. return buf
  21120. }
  21121. SafeBuffer.allocUnsafe = function (size) {
  21122. if (typeof size !== 'number') {
  21123. throw new TypeError('Argument must be a number')
  21124. }
  21125. return Buffer(size)
  21126. }
  21127. SafeBuffer.allocUnsafeSlow = function (size) {
  21128. if (typeof size !== 'number') {
  21129. throw new TypeError('Argument must be a number')
  21130. }
  21131. return buffer.SlowBuffer(size)
  21132. }
  21133. /***/ }),
  21134. /***/ "./node_modules/buffer-xor/index.js":
  21135. /*!******************************************!*\
  21136. !*** ./node_modules/buffer-xor/index.js ***!
  21137. \******************************************/
  21138. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21139. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
  21140. module.exports = function xor (a, b) {
  21141. var length = Math.min(a.length, b.length)
  21142. var buffer = new Buffer(length)
  21143. for (var i = 0; i < length; ++i) {
  21144. buffer[i] = a[i] ^ b[i]
  21145. }
  21146. return buffer
  21147. }
  21148. /***/ }),
  21149. /***/ "./node_modules/buffer/index.js":
  21150. /*!**************************************!*\
  21151. !*** ./node_modules/buffer/index.js ***!
  21152. \**************************************/
  21153. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  21154. "use strict";
  21155. /*!
  21156. * The buffer module from node.js, for the browser.
  21157. *
  21158. * @author Feross Aboukhadijeh <http://feross.org>
  21159. * @license MIT
  21160. */
  21161. /* eslint-disable no-proto */
  21162. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  21163. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  21164. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  21165. exports.Buffer = Buffer
  21166. exports.SlowBuffer = SlowBuffer
  21167. exports.INSPECT_MAX_BYTES = 50
  21168. /**
  21169. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  21170. * === true Use Uint8Array implementation (fastest)
  21171. * === false Use Object implementation (most compatible, even IE6)
  21172. *
  21173. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  21174. * Opera 11.6+, iOS 4.2+.
  21175. *
  21176. * Due to various browser bugs, sometimes the Object implementation will be used even
  21177. * when the browser supports typed arrays.
  21178. *
  21179. * Note:
  21180. *
  21181. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  21182. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  21183. *
  21184. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  21185. *
  21186. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  21187. * incorrect length in some situations.
  21188. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  21189. * get the Object implementation, which is slower but behaves correctly.
  21190. */
  21191. Buffer.TYPED_ARRAY_SUPPORT = __webpack_require__.g.TYPED_ARRAY_SUPPORT !== undefined
  21192. ? __webpack_require__.g.TYPED_ARRAY_SUPPORT
  21193. : typedArraySupport()
  21194. /*
  21195. * Export kMaxLength after typed array support is determined.
  21196. */
  21197. exports.kMaxLength = kMaxLength()
  21198. function typedArraySupport () {
  21199. try {
  21200. var arr = new Uint8Array(1)
  21201. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  21202. return arr.foo() === 42 && // typed array instances can be augmented
  21203. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  21204. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  21205. } catch (e) {
  21206. return false
  21207. }
  21208. }
  21209. function kMaxLength () {
  21210. return Buffer.TYPED_ARRAY_SUPPORT
  21211. ? 0x7fffffff
  21212. : 0x3fffffff
  21213. }
  21214. function createBuffer (that, length) {
  21215. if (kMaxLength() < length) {
  21216. throw new RangeError('Invalid typed array length')
  21217. }
  21218. if (Buffer.TYPED_ARRAY_SUPPORT) {
  21219. // Return an augmented `Uint8Array` instance, for best performance
  21220. that = new Uint8Array(length)
  21221. that.__proto__ = Buffer.prototype
  21222. } else {
  21223. // Fallback: Return an object instance of the Buffer class
  21224. if (that === null) {
  21225. that = new Buffer(length)
  21226. }
  21227. that.length = length
  21228. }
  21229. return that
  21230. }
  21231. /**
  21232. * The Buffer constructor returns instances of `Uint8Array` that have their
  21233. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  21234. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  21235. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  21236. * returns a single octet.
  21237. *
  21238. * The `Uint8Array` prototype remains unmodified.
  21239. */
  21240. function Buffer (arg, encodingOrOffset, length) {
  21241. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  21242. return new Buffer(arg, encodingOrOffset, length)
  21243. }
  21244. // Common case.
  21245. if (typeof arg === 'number') {
  21246. if (typeof encodingOrOffset === 'string') {
  21247. throw new Error(
  21248. 'If encoding is specified then the first argument must be a string'
  21249. )
  21250. }
  21251. return allocUnsafe(this, arg)
  21252. }
  21253. return from(this, arg, encodingOrOffset, length)
  21254. }
  21255. Buffer.poolSize = 8192 // not used by this implementation
  21256. // TODO: Legacy, not needed anymore. Remove in next major version.
  21257. Buffer._augment = function (arr) {
  21258. arr.__proto__ = Buffer.prototype
  21259. return arr
  21260. }
  21261. function from (that, value, encodingOrOffset, length) {
  21262. if (typeof value === 'number') {
  21263. throw new TypeError('"value" argument must not be a number')
  21264. }
  21265. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  21266. return fromArrayBuffer(that, value, encodingOrOffset, length)
  21267. }
  21268. if (typeof value === 'string') {
  21269. return fromString(that, value, encodingOrOffset)
  21270. }
  21271. return fromObject(that, value)
  21272. }
  21273. /**
  21274. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  21275. * if value is a number.
  21276. * Buffer.from(str[, encoding])
  21277. * Buffer.from(array)
  21278. * Buffer.from(buffer)
  21279. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  21280. **/
  21281. Buffer.from = function (value, encodingOrOffset, length) {
  21282. return from(null, value, encodingOrOffset, length)
  21283. }
  21284. if (Buffer.TYPED_ARRAY_SUPPORT) {
  21285. Buffer.prototype.__proto__ = Uint8Array.prototype
  21286. Buffer.__proto__ = Uint8Array
  21287. if (typeof Symbol !== 'undefined' && Symbol.species &&
  21288. Buffer[Symbol.species] === Buffer) {
  21289. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  21290. Object.defineProperty(Buffer, Symbol.species, {
  21291. value: null,
  21292. configurable: true
  21293. })
  21294. }
  21295. }
  21296. function assertSize (size) {
  21297. if (typeof size !== 'number') {
  21298. throw new TypeError('"size" argument must be a number')
  21299. } else if (size < 0) {
  21300. throw new RangeError('"size" argument must not be negative')
  21301. }
  21302. }
  21303. function alloc (that, size, fill, encoding) {
  21304. assertSize(size)
  21305. if (size <= 0) {
  21306. return createBuffer(that, size)
  21307. }
  21308. if (fill !== undefined) {
  21309. // Only pay attention to encoding if it's a string. This
  21310. // prevents accidentally sending in a number that would
  21311. // be interpretted as a start offset.
  21312. return typeof encoding === 'string'
  21313. ? createBuffer(that, size).fill(fill, encoding)
  21314. : createBuffer(that, size).fill(fill)
  21315. }
  21316. return createBuffer(that, size)
  21317. }
  21318. /**
  21319. * Creates a new filled Buffer instance.
  21320. * alloc(size[, fill[, encoding]])
  21321. **/
  21322. Buffer.alloc = function (size, fill, encoding) {
  21323. return alloc(null, size, fill, encoding)
  21324. }
  21325. function allocUnsafe (that, size) {
  21326. assertSize(size)
  21327. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  21328. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  21329. for (var i = 0; i < size; ++i) {
  21330. that[i] = 0
  21331. }
  21332. }
  21333. return that
  21334. }
  21335. /**
  21336. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  21337. * */
  21338. Buffer.allocUnsafe = function (size) {
  21339. return allocUnsafe(null, size)
  21340. }
  21341. /**
  21342. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  21343. */
  21344. Buffer.allocUnsafeSlow = function (size) {
  21345. return allocUnsafe(null, size)
  21346. }
  21347. function fromString (that, string, encoding) {
  21348. if (typeof encoding !== 'string' || encoding === '') {
  21349. encoding = 'utf8'
  21350. }
  21351. if (!Buffer.isEncoding(encoding)) {
  21352. throw new TypeError('"encoding" must be a valid string encoding')
  21353. }
  21354. var length = byteLength(string, encoding) | 0
  21355. that = createBuffer(that, length)
  21356. var actual = that.write(string, encoding)
  21357. if (actual !== length) {
  21358. // Writing a hex string, for example, that contains invalid characters will
  21359. // cause everything after the first invalid character to be ignored. (e.g.
  21360. // 'abxxcd' will be treated as 'ab')
  21361. that = that.slice(0, actual)
  21362. }
  21363. return that
  21364. }
  21365. function fromArrayLike (that, array) {
  21366. var length = array.length < 0 ? 0 : checked(array.length) | 0
  21367. that = createBuffer(that, length)
  21368. for (var i = 0; i < length; i += 1) {
  21369. that[i] = array[i] & 255
  21370. }
  21371. return that
  21372. }
  21373. function fromArrayBuffer (that, array, byteOffset, length) {
  21374. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  21375. if (byteOffset < 0 || array.byteLength < byteOffset) {
  21376. throw new RangeError('\'offset\' is out of bounds')
  21377. }
  21378. if (array.byteLength < byteOffset + (length || 0)) {
  21379. throw new RangeError('\'length\' is out of bounds')
  21380. }
  21381. if (byteOffset === undefined && length === undefined) {
  21382. array = new Uint8Array(array)
  21383. } else if (length === undefined) {
  21384. array = new Uint8Array(array, byteOffset)
  21385. } else {
  21386. array = new Uint8Array(array, byteOffset, length)
  21387. }
  21388. if (Buffer.TYPED_ARRAY_SUPPORT) {
  21389. // Return an augmented `Uint8Array` instance, for best performance
  21390. that = array
  21391. that.__proto__ = Buffer.prototype
  21392. } else {
  21393. // Fallback: Return an object instance of the Buffer class
  21394. that = fromArrayLike(that, array)
  21395. }
  21396. return that
  21397. }
  21398. function fromObject (that, obj) {
  21399. if (Buffer.isBuffer(obj)) {
  21400. var len = checked(obj.length) | 0
  21401. that = createBuffer(that, len)
  21402. if (that.length === 0) {
  21403. return that
  21404. }
  21405. obj.copy(that, 0, 0, len)
  21406. return that
  21407. }
  21408. if (obj) {
  21409. if ((typeof ArrayBuffer !== 'undefined' &&
  21410. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  21411. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  21412. return createBuffer(that, 0)
  21413. }
  21414. return fromArrayLike(that, obj)
  21415. }
  21416. if (obj.type === 'Buffer' && isArray(obj.data)) {
  21417. return fromArrayLike(that, obj.data)
  21418. }
  21419. }
  21420. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  21421. }
  21422. function checked (length) {
  21423. // Note: cannot use `length < kMaxLength()` here because that fails when
  21424. // length is NaN (which is otherwise coerced to zero.)
  21425. if (length >= kMaxLength()) {
  21426. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  21427. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  21428. }
  21429. return length | 0
  21430. }
  21431. function SlowBuffer (length) {
  21432. if (+length != length) { // eslint-disable-line eqeqeq
  21433. length = 0
  21434. }
  21435. return Buffer.alloc(+length)
  21436. }
  21437. Buffer.isBuffer = function isBuffer (b) {
  21438. return !!(b != null && b._isBuffer)
  21439. }
  21440. Buffer.compare = function compare (a, b) {
  21441. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  21442. throw new TypeError('Arguments must be Buffers')
  21443. }
  21444. if (a === b) return 0
  21445. var x = a.length
  21446. var y = b.length
  21447. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  21448. if (a[i] !== b[i]) {
  21449. x = a[i]
  21450. y = b[i]
  21451. break
  21452. }
  21453. }
  21454. if (x < y) return -1
  21455. if (y < x) return 1
  21456. return 0
  21457. }
  21458. Buffer.isEncoding = function isEncoding (encoding) {
  21459. switch (String(encoding).toLowerCase()) {
  21460. case 'hex':
  21461. case 'utf8':
  21462. case 'utf-8':
  21463. case 'ascii':
  21464. case 'latin1':
  21465. case 'binary':
  21466. case 'base64':
  21467. case 'ucs2':
  21468. case 'ucs-2':
  21469. case 'utf16le':
  21470. case 'utf-16le':
  21471. return true
  21472. default:
  21473. return false
  21474. }
  21475. }
  21476. Buffer.concat = function concat (list, length) {
  21477. if (!isArray(list)) {
  21478. throw new TypeError('"list" argument must be an Array of Buffers')
  21479. }
  21480. if (list.length === 0) {
  21481. return Buffer.alloc(0)
  21482. }
  21483. var i
  21484. if (length === undefined) {
  21485. length = 0
  21486. for (i = 0; i < list.length; ++i) {
  21487. length += list[i].length
  21488. }
  21489. }
  21490. var buffer = Buffer.allocUnsafe(length)
  21491. var pos = 0
  21492. for (i = 0; i < list.length; ++i) {
  21493. var buf = list[i]
  21494. if (!Buffer.isBuffer(buf)) {
  21495. throw new TypeError('"list" argument must be an Array of Buffers')
  21496. }
  21497. buf.copy(buffer, pos)
  21498. pos += buf.length
  21499. }
  21500. return buffer
  21501. }
  21502. function byteLength (string, encoding) {
  21503. if (Buffer.isBuffer(string)) {
  21504. return string.length
  21505. }
  21506. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  21507. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  21508. return string.byteLength
  21509. }
  21510. if (typeof string !== 'string') {
  21511. string = '' + string
  21512. }
  21513. var len = string.length
  21514. if (len === 0) return 0
  21515. // Use a for loop to avoid recursion
  21516. var loweredCase = false
  21517. for (;;) {
  21518. switch (encoding) {
  21519. case 'ascii':
  21520. case 'latin1':
  21521. case 'binary':
  21522. return len
  21523. case 'utf8':
  21524. case 'utf-8':
  21525. case undefined:
  21526. return utf8ToBytes(string).length
  21527. case 'ucs2':
  21528. case 'ucs-2':
  21529. case 'utf16le':
  21530. case 'utf-16le':
  21531. return len * 2
  21532. case 'hex':
  21533. return len >>> 1
  21534. case 'base64':
  21535. return base64ToBytes(string).length
  21536. default:
  21537. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  21538. encoding = ('' + encoding).toLowerCase()
  21539. loweredCase = true
  21540. }
  21541. }
  21542. }
  21543. Buffer.byteLength = byteLength
  21544. function slowToString (encoding, start, end) {
  21545. var loweredCase = false
  21546. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  21547. // property of a typed array.
  21548. // This behaves neither like String nor Uint8Array in that we set start/end
  21549. // to their upper/lower bounds if the value passed is out of range.
  21550. // undefined is handled specially as per ECMA-262 6th Edition,
  21551. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  21552. if (start === undefined || start < 0) {
  21553. start = 0
  21554. }
  21555. // Return early if start > this.length. Done here to prevent potential uint32
  21556. // coercion fail below.
  21557. if (start > this.length) {
  21558. return ''
  21559. }
  21560. if (end === undefined || end > this.length) {
  21561. end = this.length
  21562. }
  21563. if (end <= 0) {
  21564. return ''
  21565. }
  21566. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  21567. end >>>= 0
  21568. start >>>= 0
  21569. if (end <= start) {
  21570. return ''
  21571. }
  21572. if (!encoding) encoding = 'utf8'
  21573. while (true) {
  21574. switch (encoding) {
  21575. case 'hex':
  21576. return hexSlice(this, start, end)
  21577. case 'utf8':
  21578. case 'utf-8':
  21579. return utf8Slice(this, start, end)
  21580. case 'ascii':
  21581. return asciiSlice(this, start, end)
  21582. case 'latin1':
  21583. case 'binary':
  21584. return latin1Slice(this, start, end)
  21585. case 'base64':
  21586. return base64Slice(this, start, end)
  21587. case 'ucs2':
  21588. case 'ucs-2':
  21589. case 'utf16le':
  21590. case 'utf-16le':
  21591. return utf16leSlice(this, start, end)
  21592. default:
  21593. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  21594. encoding = (encoding + '').toLowerCase()
  21595. loweredCase = true
  21596. }
  21597. }
  21598. }
  21599. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  21600. // Buffer instances.
  21601. Buffer.prototype._isBuffer = true
  21602. function swap (b, n, m) {
  21603. var i = b[n]
  21604. b[n] = b[m]
  21605. b[m] = i
  21606. }
  21607. Buffer.prototype.swap16 = function swap16 () {
  21608. var len = this.length
  21609. if (len % 2 !== 0) {
  21610. throw new RangeError('Buffer size must be a multiple of 16-bits')
  21611. }
  21612. for (var i = 0; i < len; i += 2) {
  21613. swap(this, i, i + 1)
  21614. }
  21615. return this
  21616. }
  21617. Buffer.prototype.swap32 = function swap32 () {
  21618. var len = this.length
  21619. if (len % 4 !== 0) {
  21620. throw new RangeError('Buffer size must be a multiple of 32-bits')
  21621. }
  21622. for (var i = 0; i < len; i += 4) {
  21623. swap(this, i, i + 3)
  21624. swap(this, i + 1, i + 2)
  21625. }
  21626. return this
  21627. }
  21628. Buffer.prototype.swap64 = function swap64 () {
  21629. var len = this.length
  21630. if (len % 8 !== 0) {
  21631. throw new RangeError('Buffer size must be a multiple of 64-bits')
  21632. }
  21633. for (var i = 0; i < len; i += 8) {
  21634. swap(this, i, i + 7)
  21635. swap(this, i + 1, i + 6)
  21636. swap(this, i + 2, i + 5)
  21637. swap(this, i + 3, i + 4)
  21638. }
  21639. return this
  21640. }
  21641. Buffer.prototype.toString = function toString () {
  21642. var length = this.length | 0
  21643. if (length === 0) return ''
  21644. if (arguments.length === 0) return utf8Slice(this, 0, length)
  21645. return slowToString.apply(this, arguments)
  21646. }
  21647. Buffer.prototype.equals = function equals (b) {
  21648. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  21649. if (this === b) return true
  21650. return Buffer.compare(this, b) === 0
  21651. }
  21652. Buffer.prototype.inspect = function inspect () {
  21653. var str = ''
  21654. var max = exports.INSPECT_MAX_BYTES
  21655. if (this.length > 0) {
  21656. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  21657. if (this.length > max) str += ' ... '
  21658. }
  21659. return '<Buffer ' + str + '>'
  21660. }
  21661. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  21662. if (!Buffer.isBuffer(target)) {
  21663. throw new TypeError('Argument must be a Buffer')
  21664. }
  21665. if (start === undefined) {
  21666. start = 0
  21667. }
  21668. if (end === undefined) {
  21669. end = target ? target.length : 0
  21670. }
  21671. if (thisStart === undefined) {
  21672. thisStart = 0
  21673. }
  21674. if (thisEnd === undefined) {
  21675. thisEnd = this.length
  21676. }
  21677. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  21678. throw new RangeError('out of range index')
  21679. }
  21680. if (thisStart >= thisEnd && start >= end) {
  21681. return 0
  21682. }
  21683. if (thisStart >= thisEnd) {
  21684. return -1
  21685. }
  21686. if (start >= end) {
  21687. return 1
  21688. }
  21689. start >>>= 0
  21690. end >>>= 0
  21691. thisStart >>>= 0
  21692. thisEnd >>>= 0
  21693. if (this === target) return 0
  21694. var x = thisEnd - thisStart
  21695. var y = end - start
  21696. var len = Math.min(x, y)
  21697. var thisCopy = this.slice(thisStart, thisEnd)
  21698. var targetCopy = target.slice(start, end)
  21699. for (var i = 0; i < len; ++i) {
  21700. if (thisCopy[i] !== targetCopy[i]) {
  21701. x = thisCopy[i]
  21702. y = targetCopy[i]
  21703. break
  21704. }
  21705. }
  21706. if (x < y) return -1
  21707. if (y < x) return 1
  21708. return 0
  21709. }
  21710. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  21711. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  21712. //
  21713. // Arguments:
  21714. // - buffer - a Buffer to search
  21715. // - val - a string, Buffer, or number
  21716. // - byteOffset - an index into `buffer`; will be clamped to an int32
  21717. // - encoding - an optional encoding, relevant is val is a string
  21718. // - dir - true for indexOf, false for lastIndexOf
  21719. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  21720. // Empty buffer means no match
  21721. if (buffer.length === 0) return -1
  21722. // Normalize byteOffset
  21723. if (typeof byteOffset === 'string') {
  21724. encoding = byteOffset
  21725. byteOffset = 0
  21726. } else if (byteOffset > 0x7fffffff) {
  21727. byteOffset = 0x7fffffff
  21728. } else if (byteOffset < -0x80000000) {
  21729. byteOffset = -0x80000000
  21730. }
  21731. byteOffset = +byteOffset // Coerce to Number.
  21732. if (isNaN(byteOffset)) {
  21733. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  21734. byteOffset = dir ? 0 : (buffer.length - 1)
  21735. }
  21736. // Normalize byteOffset: negative offsets start from the end of the buffer
  21737. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  21738. if (byteOffset >= buffer.length) {
  21739. if (dir) return -1
  21740. else byteOffset = buffer.length - 1
  21741. } else if (byteOffset < 0) {
  21742. if (dir) byteOffset = 0
  21743. else return -1
  21744. }
  21745. // Normalize val
  21746. if (typeof val === 'string') {
  21747. val = Buffer.from(val, encoding)
  21748. }
  21749. // Finally, search either indexOf (if dir is true) or lastIndexOf
  21750. if (Buffer.isBuffer(val)) {
  21751. // Special case: looking for empty string/buffer always fails
  21752. if (val.length === 0) {
  21753. return -1
  21754. }
  21755. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  21756. } else if (typeof val === 'number') {
  21757. val = val & 0xFF // Search for a byte value [0-255]
  21758. if (Buffer.TYPED_ARRAY_SUPPORT &&
  21759. typeof Uint8Array.prototype.indexOf === 'function') {
  21760. if (dir) {
  21761. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  21762. } else {
  21763. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  21764. }
  21765. }
  21766. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  21767. }
  21768. throw new TypeError('val must be string, number or Buffer')
  21769. }
  21770. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  21771. var indexSize = 1
  21772. var arrLength = arr.length
  21773. var valLength = val.length
  21774. if (encoding !== undefined) {
  21775. encoding = String(encoding).toLowerCase()
  21776. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  21777. encoding === 'utf16le' || encoding === 'utf-16le') {
  21778. if (arr.length < 2 || val.length < 2) {
  21779. return -1
  21780. }
  21781. indexSize = 2
  21782. arrLength /= 2
  21783. valLength /= 2
  21784. byteOffset /= 2
  21785. }
  21786. }
  21787. function read (buf, i) {
  21788. if (indexSize === 1) {
  21789. return buf[i]
  21790. } else {
  21791. return buf.readUInt16BE(i * indexSize)
  21792. }
  21793. }
  21794. var i
  21795. if (dir) {
  21796. var foundIndex = -1
  21797. for (i = byteOffset; i < arrLength; i++) {
  21798. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  21799. if (foundIndex === -1) foundIndex = i
  21800. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  21801. } else {
  21802. if (foundIndex !== -1) i -= i - foundIndex
  21803. foundIndex = -1
  21804. }
  21805. }
  21806. } else {
  21807. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  21808. for (i = byteOffset; i >= 0; i--) {
  21809. var found = true
  21810. for (var j = 0; j < valLength; j++) {
  21811. if (read(arr, i + j) !== read(val, j)) {
  21812. found = false
  21813. break
  21814. }
  21815. }
  21816. if (found) return i
  21817. }
  21818. }
  21819. return -1
  21820. }
  21821. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  21822. return this.indexOf(val, byteOffset, encoding) !== -1
  21823. }
  21824. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  21825. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  21826. }
  21827. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  21828. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  21829. }
  21830. function hexWrite (buf, string, offset, length) {
  21831. offset = Number(offset) || 0
  21832. var remaining = buf.length - offset
  21833. if (!length) {
  21834. length = remaining
  21835. } else {
  21836. length = Number(length)
  21837. if (length > remaining) {
  21838. length = remaining
  21839. }
  21840. }
  21841. // must be an even number of digits
  21842. var strLen = string.length
  21843. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  21844. if (length > strLen / 2) {
  21845. length = strLen / 2
  21846. }
  21847. for (var i = 0; i < length; ++i) {
  21848. var parsed = parseInt(string.substr(i * 2, 2), 16)
  21849. if (isNaN(parsed)) return i
  21850. buf[offset + i] = parsed
  21851. }
  21852. return i
  21853. }
  21854. function utf8Write (buf, string, offset, length) {
  21855. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  21856. }
  21857. function asciiWrite (buf, string, offset, length) {
  21858. return blitBuffer(asciiToBytes(string), buf, offset, length)
  21859. }
  21860. function latin1Write (buf, string, offset, length) {
  21861. return asciiWrite(buf, string, offset, length)
  21862. }
  21863. function base64Write (buf, string, offset, length) {
  21864. return blitBuffer(base64ToBytes(string), buf, offset, length)
  21865. }
  21866. function ucs2Write (buf, string, offset, length) {
  21867. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  21868. }
  21869. Buffer.prototype.write = function write (string, offset, length, encoding) {
  21870. // Buffer#write(string)
  21871. if (offset === undefined) {
  21872. encoding = 'utf8'
  21873. length = this.length
  21874. offset = 0
  21875. // Buffer#write(string, encoding)
  21876. } else if (length === undefined && typeof offset === 'string') {
  21877. encoding = offset
  21878. length = this.length
  21879. offset = 0
  21880. // Buffer#write(string, offset[, length][, encoding])
  21881. } else if (isFinite(offset)) {
  21882. offset = offset | 0
  21883. if (isFinite(length)) {
  21884. length = length | 0
  21885. if (encoding === undefined) encoding = 'utf8'
  21886. } else {
  21887. encoding = length
  21888. length = undefined
  21889. }
  21890. // legacy write(string, encoding, offset, length) - remove in v0.13
  21891. } else {
  21892. throw new Error(
  21893. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  21894. )
  21895. }
  21896. var remaining = this.length - offset
  21897. if (length === undefined || length > remaining) length = remaining
  21898. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  21899. throw new RangeError('Attempt to write outside buffer bounds')
  21900. }
  21901. if (!encoding) encoding = 'utf8'
  21902. var loweredCase = false
  21903. for (;;) {
  21904. switch (encoding) {
  21905. case 'hex':
  21906. return hexWrite(this, string, offset, length)
  21907. case 'utf8':
  21908. case 'utf-8':
  21909. return utf8Write(this, string, offset, length)
  21910. case 'ascii':
  21911. return asciiWrite(this, string, offset, length)
  21912. case 'latin1':
  21913. case 'binary':
  21914. return latin1Write(this, string, offset, length)
  21915. case 'base64':
  21916. // Warning: maxLength not taken into account in base64Write
  21917. return base64Write(this, string, offset, length)
  21918. case 'ucs2':
  21919. case 'ucs-2':
  21920. case 'utf16le':
  21921. case 'utf-16le':
  21922. return ucs2Write(this, string, offset, length)
  21923. default:
  21924. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  21925. encoding = ('' + encoding).toLowerCase()
  21926. loweredCase = true
  21927. }
  21928. }
  21929. }
  21930. Buffer.prototype.toJSON = function toJSON () {
  21931. return {
  21932. type: 'Buffer',
  21933. data: Array.prototype.slice.call(this._arr || this, 0)
  21934. }
  21935. }
  21936. function base64Slice (buf, start, end) {
  21937. if (start === 0 && end === buf.length) {
  21938. return base64.fromByteArray(buf)
  21939. } else {
  21940. return base64.fromByteArray(buf.slice(start, end))
  21941. }
  21942. }
  21943. function utf8Slice (buf, start, end) {
  21944. end = Math.min(buf.length, end)
  21945. var res = []
  21946. var i = start
  21947. while (i < end) {
  21948. var firstByte = buf[i]
  21949. var codePoint = null
  21950. var bytesPerSequence = (firstByte > 0xEF) ? 4
  21951. : (firstByte > 0xDF) ? 3
  21952. : (firstByte > 0xBF) ? 2
  21953. : 1
  21954. if (i + bytesPerSequence <= end) {
  21955. var secondByte, thirdByte, fourthByte, tempCodePoint
  21956. switch (bytesPerSequence) {
  21957. case 1:
  21958. if (firstByte < 0x80) {
  21959. codePoint = firstByte
  21960. }
  21961. break
  21962. case 2:
  21963. secondByte = buf[i + 1]
  21964. if ((secondByte & 0xC0) === 0x80) {
  21965. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  21966. if (tempCodePoint > 0x7F) {
  21967. codePoint = tempCodePoint
  21968. }
  21969. }
  21970. break
  21971. case 3:
  21972. secondByte = buf[i + 1]
  21973. thirdByte = buf[i + 2]
  21974. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  21975. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  21976. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  21977. codePoint = tempCodePoint
  21978. }
  21979. }
  21980. break
  21981. case 4:
  21982. secondByte = buf[i + 1]
  21983. thirdByte = buf[i + 2]
  21984. fourthByte = buf[i + 3]
  21985. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  21986. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  21987. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  21988. codePoint = tempCodePoint
  21989. }
  21990. }
  21991. }
  21992. }
  21993. if (codePoint === null) {
  21994. // we did not generate a valid codePoint so insert a
  21995. // replacement char (U+FFFD) and advance only 1 byte
  21996. codePoint = 0xFFFD
  21997. bytesPerSequence = 1
  21998. } else if (codePoint > 0xFFFF) {
  21999. // encode to utf16 (surrogate pair dance)
  22000. codePoint -= 0x10000
  22001. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  22002. codePoint = 0xDC00 | codePoint & 0x3FF
  22003. }
  22004. res.push(codePoint)
  22005. i += bytesPerSequence
  22006. }
  22007. return decodeCodePointsArray(res)
  22008. }
  22009. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  22010. // the lowest limit is Chrome, with 0x10000 args.
  22011. // We go 1 magnitude less, for safety
  22012. var MAX_ARGUMENTS_LENGTH = 0x1000
  22013. function decodeCodePointsArray (codePoints) {
  22014. var len = codePoints.length
  22015. if (len <= MAX_ARGUMENTS_LENGTH) {
  22016. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  22017. }
  22018. // Decode in chunks to avoid "call stack size exceeded".
  22019. var res = ''
  22020. var i = 0
  22021. while (i < len) {
  22022. res += String.fromCharCode.apply(
  22023. String,
  22024. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  22025. )
  22026. }
  22027. return res
  22028. }
  22029. function asciiSlice (buf, start, end) {
  22030. var ret = ''
  22031. end = Math.min(buf.length, end)
  22032. for (var i = start; i < end; ++i) {
  22033. ret += String.fromCharCode(buf[i] & 0x7F)
  22034. }
  22035. return ret
  22036. }
  22037. function latin1Slice (buf, start, end) {
  22038. var ret = ''
  22039. end = Math.min(buf.length, end)
  22040. for (var i = start; i < end; ++i) {
  22041. ret += String.fromCharCode(buf[i])
  22042. }
  22043. return ret
  22044. }
  22045. function hexSlice (buf, start, end) {
  22046. var len = buf.length
  22047. if (!start || start < 0) start = 0
  22048. if (!end || end < 0 || end > len) end = len
  22049. var out = ''
  22050. for (var i = start; i < end; ++i) {
  22051. out += toHex(buf[i])
  22052. }
  22053. return out
  22054. }
  22055. function utf16leSlice (buf, start, end) {
  22056. var bytes = buf.slice(start, end)
  22057. var res = ''
  22058. for (var i = 0; i < bytes.length; i += 2) {
  22059. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  22060. }
  22061. return res
  22062. }
  22063. Buffer.prototype.slice = function slice (start, end) {
  22064. var len = this.length
  22065. start = ~~start
  22066. end = end === undefined ? len : ~~end
  22067. if (start < 0) {
  22068. start += len
  22069. if (start < 0) start = 0
  22070. } else if (start > len) {
  22071. start = len
  22072. }
  22073. if (end < 0) {
  22074. end += len
  22075. if (end < 0) end = 0
  22076. } else if (end > len) {
  22077. end = len
  22078. }
  22079. if (end < start) end = start
  22080. var newBuf
  22081. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22082. newBuf = this.subarray(start, end)
  22083. newBuf.__proto__ = Buffer.prototype
  22084. } else {
  22085. var sliceLen = end - start
  22086. newBuf = new Buffer(sliceLen, undefined)
  22087. for (var i = 0; i < sliceLen; ++i) {
  22088. newBuf[i] = this[i + start]
  22089. }
  22090. }
  22091. return newBuf
  22092. }
  22093. /*
  22094. * Need to make sure that buffer isn't trying to write out of bounds.
  22095. */
  22096. function checkOffset (offset, ext, length) {
  22097. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  22098. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  22099. }
  22100. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  22101. offset = offset | 0
  22102. byteLength = byteLength | 0
  22103. if (!noAssert) checkOffset(offset, byteLength, this.length)
  22104. var val = this[offset]
  22105. var mul = 1
  22106. var i = 0
  22107. while (++i < byteLength && (mul *= 0x100)) {
  22108. val += this[offset + i] * mul
  22109. }
  22110. return val
  22111. }
  22112. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  22113. offset = offset | 0
  22114. byteLength = byteLength | 0
  22115. if (!noAssert) {
  22116. checkOffset(offset, byteLength, this.length)
  22117. }
  22118. var val = this[offset + --byteLength]
  22119. var mul = 1
  22120. while (byteLength > 0 && (mul *= 0x100)) {
  22121. val += this[offset + --byteLength] * mul
  22122. }
  22123. return val
  22124. }
  22125. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  22126. if (!noAssert) checkOffset(offset, 1, this.length)
  22127. return this[offset]
  22128. }
  22129. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  22130. if (!noAssert) checkOffset(offset, 2, this.length)
  22131. return this[offset] | (this[offset + 1] << 8)
  22132. }
  22133. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  22134. if (!noAssert) checkOffset(offset, 2, this.length)
  22135. return (this[offset] << 8) | this[offset + 1]
  22136. }
  22137. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  22138. if (!noAssert) checkOffset(offset, 4, this.length)
  22139. return ((this[offset]) |
  22140. (this[offset + 1] << 8) |
  22141. (this[offset + 2] << 16)) +
  22142. (this[offset + 3] * 0x1000000)
  22143. }
  22144. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  22145. if (!noAssert) checkOffset(offset, 4, this.length)
  22146. return (this[offset] * 0x1000000) +
  22147. ((this[offset + 1] << 16) |
  22148. (this[offset + 2] << 8) |
  22149. this[offset + 3])
  22150. }
  22151. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  22152. offset = offset | 0
  22153. byteLength = byteLength | 0
  22154. if (!noAssert) checkOffset(offset, byteLength, this.length)
  22155. var val = this[offset]
  22156. var mul = 1
  22157. var i = 0
  22158. while (++i < byteLength && (mul *= 0x100)) {
  22159. val += this[offset + i] * mul
  22160. }
  22161. mul *= 0x80
  22162. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  22163. return val
  22164. }
  22165. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  22166. offset = offset | 0
  22167. byteLength = byteLength | 0
  22168. if (!noAssert) checkOffset(offset, byteLength, this.length)
  22169. var i = byteLength
  22170. var mul = 1
  22171. var val = this[offset + --i]
  22172. while (i > 0 && (mul *= 0x100)) {
  22173. val += this[offset + --i] * mul
  22174. }
  22175. mul *= 0x80
  22176. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  22177. return val
  22178. }
  22179. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  22180. if (!noAssert) checkOffset(offset, 1, this.length)
  22181. if (!(this[offset] & 0x80)) return (this[offset])
  22182. return ((0xff - this[offset] + 1) * -1)
  22183. }
  22184. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  22185. if (!noAssert) checkOffset(offset, 2, this.length)
  22186. var val = this[offset] | (this[offset + 1] << 8)
  22187. return (val & 0x8000) ? val | 0xFFFF0000 : val
  22188. }
  22189. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  22190. if (!noAssert) checkOffset(offset, 2, this.length)
  22191. var val = this[offset + 1] | (this[offset] << 8)
  22192. return (val & 0x8000) ? val | 0xFFFF0000 : val
  22193. }
  22194. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  22195. if (!noAssert) checkOffset(offset, 4, this.length)
  22196. return (this[offset]) |
  22197. (this[offset + 1] << 8) |
  22198. (this[offset + 2] << 16) |
  22199. (this[offset + 3] << 24)
  22200. }
  22201. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  22202. if (!noAssert) checkOffset(offset, 4, this.length)
  22203. return (this[offset] << 24) |
  22204. (this[offset + 1] << 16) |
  22205. (this[offset + 2] << 8) |
  22206. (this[offset + 3])
  22207. }
  22208. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  22209. if (!noAssert) checkOffset(offset, 4, this.length)
  22210. return ieee754.read(this, offset, true, 23, 4)
  22211. }
  22212. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  22213. if (!noAssert) checkOffset(offset, 4, this.length)
  22214. return ieee754.read(this, offset, false, 23, 4)
  22215. }
  22216. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  22217. if (!noAssert) checkOffset(offset, 8, this.length)
  22218. return ieee754.read(this, offset, true, 52, 8)
  22219. }
  22220. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  22221. if (!noAssert) checkOffset(offset, 8, this.length)
  22222. return ieee754.read(this, offset, false, 52, 8)
  22223. }
  22224. function checkInt (buf, value, offset, ext, max, min) {
  22225. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  22226. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  22227. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  22228. }
  22229. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  22230. value = +value
  22231. offset = offset | 0
  22232. byteLength = byteLength | 0
  22233. if (!noAssert) {
  22234. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  22235. checkInt(this, value, offset, byteLength, maxBytes, 0)
  22236. }
  22237. var mul = 1
  22238. var i = 0
  22239. this[offset] = value & 0xFF
  22240. while (++i < byteLength && (mul *= 0x100)) {
  22241. this[offset + i] = (value / mul) & 0xFF
  22242. }
  22243. return offset + byteLength
  22244. }
  22245. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  22246. value = +value
  22247. offset = offset | 0
  22248. byteLength = byteLength | 0
  22249. if (!noAssert) {
  22250. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  22251. checkInt(this, value, offset, byteLength, maxBytes, 0)
  22252. }
  22253. var i = byteLength - 1
  22254. var mul = 1
  22255. this[offset + i] = value & 0xFF
  22256. while (--i >= 0 && (mul *= 0x100)) {
  22257. this[offset + i] = (value / mul) & 0xFF
  22258. }
  22259. return offset + byteLength
  22260. }
  22261. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  22262. value = +value
  22263. offset = offset | 0
  22264. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  22265. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  22266. this[offset] = (value & 0xff)
  22267. return offset + 1
  22268. }
  22269. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  22270. if (value < 0) value = 0xffff + value + 1
  22271. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  22272. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  22273. (littleEndian ? i : 1 - i) * 8
  22274. }
  22275. }
  22276. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  22277. value = +value
  22278. offset = offset | 0
  22279. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  22280. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22281. this[offset] = (value & 0xff)
  22282. this[offset + 1] = (value >>> 8)
  22283. } else {
  22284. objectWriteUInt16(this, value, offset, true)
  22285. }
  22286. return offset + 2
  22287. }
  22288. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  22289. value = +value
  22290. offset = offset | 0
  22291. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  22292. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22293. this[offset] = (value >>> 8)
  22294. this[offset + 1] = (value & 0xff)
  22295. } else {
  22296. objectWriteUInt16(this, value, offset, false)
  22297. }
  22298. return offset + 2
  22299. }
  22300. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  22301. if (value < 0) value = 0xffffffff + value + 1
  22302. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  22303. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  22304. }
  22305. }
  22306. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  22307. value = +value
  22308. offset = offset | 0
  22309. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  22310. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22311. this[offset + 3] = (value >>> 24)
  22312. this[offset + 2] = (value >>> 16)
  22313. this[offset + 1] = (value >>> 8)
  22314. this[offset] = (value & 0xff)
  22315. } else {
  22316. objectWriteUInt32(this, value, offset, true)
  22317. }
  22318. return offset + 4
  22319. }
  22320. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  22321. value = +value
  22322. offset = offset | 0
  22323. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  22324. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22325. this[offset] = (value >>> 24)
  22326. this[offset + 1] = (value >>> 16)
  22327. this[offset + 2] = (value >>> 8)
  22328. this[offset + 3] = (value & 0xff)
  22329. } else {
  22330. objectWriteUInt32(this, value, offset, false)
  22331. }
  22332. return offset + 4
  22333. }
  22334. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  22335. value = +value
  22336. offset = offset | 0
  22337. if (!noAssert) {
  22338. var limit = Math.pow(2, 8 * byteLength - 1)
  22339. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  22340. }
  22341. var i = 0
  22342. var mul = 1
  22343. var sub = 0
  22344. this[offset] = value & 0xFF
  22345. while (++i < byteLength && (mul *= 0x100)) {
  22346. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  22347. sub = 1
  22348. }
  22349. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  22350. }
  22351. return offset + byteLength
  22352. }
  22353. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  22354. value = +value
  22355. offset = offset | 0
  22356. if (!noAssert) {
  22357. var limit = Math.pow(2, 8 * byteLength - 1)
  22358. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  22359. }
  22360. var i = byteLength - 1
  22361. var mul = 1
  22362. var sub = 0
  22363. this[offset + i] = value & 0xFF
  22364. while (--i >= 0 && (mul *= 0x100)) {
  22365. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  22366. sub = 1
  22367. }
  22368. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  22369. }
  22370. return offset + byteLength
  22371. }
  22372. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  22373. value = +value
  22374. offset = offset | 0
  22375. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  22376. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  22377. if (value < 0) value = 0xff + value + 1
  22378. this[offset] = (value & 0xff)
  22379. return offset + 1
  22380. }
  22381. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  22382. value = +value
  22383. offset = offset | 0
  22384. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  22385. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22386. this[offset] = (value & 0xff)
  22387. this[offset + 1] = (value >>> 8)
  22388. } else {
  22389. objectWriteUInt16(this, value, offset, true)
  22390. }
  22391. return offset + 2
  22392. }
  22393. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  22394. value = +value
  22395. offset = offset | 0
  22396. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  22397. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22398. this[offset] = (value >>> 8)
  22399. this[offset + 1] = (value & 0xff)
  22400. } else {
  22401. objectWriteUInt16(this, value, offset, false)
  22402. }
  22403. return offset + 2
  22404. }
  22405. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  22406. value = +value
  22407. offset = offset | 0
  22408. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  22409. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22410. this[offset] = (value & 0xff)
  22411. this[offset + 1] = (value >>> 8)
  22412. this[offset + 2] = (value >>> 16)
  22413. this[offset + 3] = (value >>> 24)
  22414. } else {
  22415. objectWriteUInt32(this, value, offset, true)
  22416. }
  22417. return offset + 4
  22418. }
  22419. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  22420. value = +value
  22421. offset = offset | 0
  22422. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  22423. if (value < 0) value = 0xffffffff + value + 1
  22424. if (Buffer.TYPED_ARRAY_SUPPORT) {
  22425. this[offset] = (value >>> 24)
  22426. this[offset + 1] = (value >>> 16)
  22427. this[offset + 2] = (value >>> 8)
  22428. this[offset + 3] = (value & 0xff)
  22429. } else {
  22430. objectWriteUInt32(this, value, offset, false)
  22431. }
  22432. return offset + 4
  22433. }
  22434. function checkIEEE754 (buf, value, offset, ext, max, min) {
  22435. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  22436. if (offset < 0) throw new RangeError('Index out of range')
  22437. }
  22438. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  22439. if (!noAssert) {
  22440. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  22441. }
  22442. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  22443. return offset + 4
  22444. }
  22445. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  22446. return writeFloat(this, value, offset, true, noAssert)
  22447. }
  22448. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  22449. return writeFloat(this, value, offset, false, noAssert)
  22450. }
  22451. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  22452. if (!noAssert) {
  22453. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  22454. }
  22455. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  22456. return offset + 8
  22457. }
  22458. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  22459. return writeDouble(this, value, offset, true, noAssert)
  22460. }
  22461. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  22462. return writeDouble(this, value, offset, false, noAssert)
  22463. }
  22464. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  22465. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  22466. if (!start) start = 0
  22467. if (!end && end !== 0) end = this.length
  22468. if (targetStart >= target.length) targetStart = target.length
  22469. if (!targetStart) targetStart = 0
  22470. if (end > 0 && end < start) end = start
  22471. // Copy 0 bytes; we're done
  22472. if (end === start) return 0
  22473. if (target.length === 0 || this.length === 0) return 0
  22474. // Fatal error conditions
  22475. if (targetStart < 0) {
  22476. throw new RangeError('targetStart out of bounds')
  22477. }
  22478. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  22479. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  22480. // Are we oob?
  22481. if (end > this.length) end = this.length
  22482. if (target.length - targetStart < end - start) {
  22483. end = target.length - targetStart + start
  22484. }
  22485. var len = end - start
  22486. var i
  22487. if (this === target && start < targetStart && targetStart < end) {
  22488. // descending copy from end
  22489. for (i = len - 1; i >= 0; --i) {
  22490. target[i + targetStart] = this[i + start]
  22491. }
  22492. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  22493. // ascending copy from start
  22494. for (i = 0; i < len; ++i) {
  22495. target[i + targetStart] = this[i + start]
  22496. }
  22497. } else {
  22498. Uint8Array.prototype.set.call(
  22499. target,
  22500. this.subarray(start, start + len),
  22501. targetStart
  22502. )
  22503. }
  22504. return len
  22505. }
  22506. // Usage:
  22507. // buffer.fill(number[, offset[, end]])
  22508. // buffer.fill(buffer[, offset[, end]])
  22509. // buffer.fill(string[, offset[, end]][, encoding])
  22510. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  22511. // Handle string cases:
  22512. if (typeof val === 'string') {
  22513. if (typeof start === 'string') {
  22514. encoding = start
  22515. start = 0
  22516. end = this.length
  22517. } else if (typeof end === 'string') {
  22518. encoding = end
  22519. end = this.length
  22520. }
  22521. if (val.length === 1) {
  22522. var code = val.charCodeAt(0)
  22523. if (code < 256) {
  22524. val = code
  22525. }
  22526. }
  22527. if (encoding !== undefined && typeof encoding !== 'string') {
  22528. throw new TypeError('encoding must be a string')
  22529. }
  22530. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  22531. throw new TypeError('Unknown encoding: ' + encoding)
  22532. }
  22533. } else if (typeof val === 'number') {
  22534. val = val & 255
  22535. }
  22536. // Invalid ranges are not set to a default, so can range check early.
  22537. if (start < 0 || this.length < start || this.length < end) {
  22538. throw new RangeError('Out of range index')
  22539. }
  22540. if (end <= start) {
  22541. return this
  22542. }
  22543. start = start >>> 0
  22544. end = end === undefined ? this.length : end >>> 0
  22545. if (!val) val = 0
  22546. var i
  22547. if (typeof val === 'number') {
  22548. for (i = start; i < end; ++i) {
  22549. this[i] = val
  22550. }
  22551. } else {
  22552. var bytes = Buffer.isBuffer(val)
  22553. ? val
  22554. : utf8ToBytes(new Buffer(val, encoding).toString())
  22555. var len = bytes.length
  22556. for (i = 0; i < end - start; ++i) {
  22557. this[i + start] = bytes[i % len]
  22558. }
  22559. }
  22560. return this
  22561. }
  22562. // HELPER FUNCTIONS
  22563. // ================
  22564. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  22565. function base64clean (str) {
  22566. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  22567. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  22568. // Node converts strings with length < 2 to ''
  22569. if (str.length < 2) return ''
  22570. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  22571. while (str.length % 4 !== 0) {
  22572. str = str + '='
  22573. }
  22574. return str
  22575. }
  22576. function stringtrim (str) {
  22577. if (str.trim) return str.trim()
  22578. return str.replace(/^\s+|\s+$/g, '')
  22579. }
  22580. function toHex (n) {
  22581. if (n < 16) return '0' + n.toString(16)
  22582. return n.toString(16)
  22583. }
  22584. function utf8ToBytes (string, units) {
  22585. units = units || Infinity
  22586. var codePoint
  22587. var length = string.length
  22588. var leadSurrogate = null
  22589. var bytes = []
  22590. for (var i = 0; i < length; ++i) {
  22591. codePoint = string.charCodeAt(i)
  22592. // is surrogate component
  22593. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  22594. // last char was a lead
  22595. if (!leadSurrogate) {
  22596. // no lead yet
  22597. if (codePoint > 0xDBFF) {
  22598. // unexpected trail
  22599. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22600. continue
  22601. } else if (i + 1 === length) {
  22602. // unpaired lead
  22603. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22604. continue
  22605. }
  22606. // valid lead
  22607. leadSurrogate = codePoint
  22608. continue
  22609. }
  22610. // 2 leads in a row
  22611. if (codePoint < 0xDC00) {
  22612. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22613. leadSurrogate = codePoint
  22614. continue
  22615. }
  22616. // valid surrogate pair
  22617. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  22618. } else if (leadSurrogate) {
  22619. // valid bmp char, but last char was a lead
  22620. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  22621. }
  22622. leadSurrogate = null
  22623. // encode utf8
  22624. if (codePoint < 0x80) {
  22625. if ((units -= 1) < 0) break
  22626. bytes.push(codePoint)
  22627. } else if (codePoint < 0x800) {
  22628. if ((units -= 2) < 0) break
  22629. bytes.push(
  22630. codePoint >> 0x6 | 0xC0,
  22631. codePoint & 0x3F | 0x80
  22632. )
  22633. } else if (codePoint < 0x10000) {
  22634. if ((units -= 3) < 0) break
  22635. bytes.push(
  22636. codePoint >> 0xC | 0xE0,
  22637. codePoint >> 0x6 & 0x3F | 0x80,
  22638. codePoint & 0x3F | 0x80
  22639. )
  22640. } else if (codePoint < 0x110000) {
  22641. if ((units -= 4) < 0) break
  22642. bytes.push(
  22643. codePoint >> 0x12 | 0xF0,
  22644. codePoint >> 0xC & 0x3F | 0x80,
  22645. codePoint >> 0x6 & 0x3F | 0x80,
  22646. codePoint & 0x3F | 0x80
  22647. )
  22648. } else {
  22649. throw new Error('Invalid code point')
  22650. }
  22651. }
  22652. return bytes
  22653. }
  22654. function asciiToBytes (str) {
  22655. var byteArray = []
  22656. for (var i = 0; i < str.length; ++i) {
  22657. // Node's code seems to be doing this and not & 0x7F..
  22658. byteArray.push(str.charCodeAt(i) & 0xFF)
  22659. }
  22660. return byteArray
  22661. }
  22662. function utf16leToBytes (str, units) {
  22663. var c, hi, lo
  22664. var byteArray = []
  22665. for (var i = 0; i < str.length; ++i) {
  22666. if ((units -= 2) < 0) break
  22667. c = str.charCodeAt(i)
  22668. hi = c >> 8
  22669. lo = c % 256
  22670. byteArray.push(lo)
  22671. byteArray.push(hi)
  22672. }
  22673. return byteArray
  22674. }
  22675. function base64ToBytes (str) {
  22676. return base64.toByteArray(base64clean(str))
  22677. }
  22678. function blitBuffer (src, dst, offset, length) {
  22679. for (var i = 0; i < length; ++i) {
  22680. if ((i + offset >= dst.length) || (i >= src.length)) break
  22681. dst[i + offset] = src[i]
  22682. }
  22683. return i
  22684. }
  22685. function isnan (val) {
  22686. return val !== val // eslint-disable-line no-self-compare
  22687. }
  22688. /***/ }),
  22689. /***/ "./node_modules/camel-case/dist.es2015/index.js":
  22690. /*!******************************************************!*\
  22691. !*** ./node_modules/camel-case/dist.es2015/index.js ***!
  22692. \******************************************************/
  22693. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  22694. "use strict";
  22695. __webpack_require__.r(__webpack_exports__);
  22696. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  22697. /* harmony export */ camelCase: () => (/* binding */ camelCase),
  22698. /* harmony export */ camelCaseTransform: () => (/* binding */ camelCaseTransform),
  22699. /* harmony export */ camelCaseTransformMerge: () => (/* binding */ camelCaseTransformMerge)
  22700. /* harmony export */ });
  22701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  22702. /* harmony import */ var pascal_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! pascal-case */ "./node_modules/pascal-case/dist.es2015/index.js");
  22703. function camelCaseTransform(input, index) {
  22704. if (index === 0)
  22705. return input.toLowerCase();
  22706. return (0,pascal_case__WEBPACK_IMPORTED_MODULE_0__.pascalCaseTransform)(input, index);
  22707. }
  22708. function camelCaseTransformMerge(input, index) {
  22709. if (index === 0)
  22710. return input.toLowerCase();
  22711. return (0,pascal_case__WEBPACK_IMPORTED_MODULE_0__.pascalCaseTransformMerge)(input);
  22712. }
  22713. function camelCase(input, options) {
  22714. if (options === void 0) { options = {}; }
  22715. return (0,pascal_case__WEBPACK_IMPORTED_MODULE_0__.pascalCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ transform: camelCaseTransform }, options));
  22716. }
  22717. //# sourceMappingURL=index.js.map
  22718. /***/ }),
  22719. /***/ "./node_modules/capital-case/dist.es2015/index.js":
  22720. /*!********************************************************!*\
  22721. !*** ./node_modules/capital-case/dist.es2015/index.js ***!
  22722. \********************************************************/
  22723. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  22724. "use strict";
  22725. __webpack_require__.r(__webpack_exports__);
  22726. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  22727. /* harmony export */ capitalCase: () => (/* binding */ capitalCase),
  22728. /* harmony export */ capitalCaseTransform: () => (/* binding */ capitalCaseTransform)
  22729. /* harmony export */ });
  22730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  22731. /* harmony import */ var no_case__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! no-case */ "./node_modules/no-case/dist.es2015/index.js");
  22732. /* harmony import */ var upper_case_first__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! upper-case-first */ "./node_modules/upper-case-first/dist.es2015/index.js");
  22733. function capitalCaseTransform(input) {
  22734. return (0,upper_case_first__WEBPACK_IMPORTED_MODULE_0__.upperCaseFirst)(input.toLowerCase());
  22735. }
  22736. function capitalCase(input, options) {
  22737. if (options === void 0) { options = {}; }
  22738. return (0,no_case__WEBPACK_IMPORTED_MODULE_1__.noCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ delimiter: " ", transform: capitalCaseTransform }, options));
  22739. }
  22740. //# sourceMappingURL=index.js.map
  22741. /***/ }),
  22742. /***/ "./node_modules/cipher-base/index.js":
  22743. /*!*******************************************!*\
  22744. !*** ./node_modules/cipher-base/index.js ***!
  22745. \*******************************************/
  22746. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  22747. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  22748. var Transform = (__webpack_require__(/*! stream */ "./node_modules/node-polyfill-webpack-plugin/node_modules/stream-browserify/index.js").Transform)
  22749. var StringDecoder = (__webpack_require__(/*! string_decoder */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder)
  22750. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  22751. function CipherBase (hashMode) {
  22752. Transform.call(this)
  22753. this.hashMode = typeof hashMode === 'string'
  22754. if (this.hashMode) {
  22755. this[hashMode] = this._finalOrDigest
  22756. } else {
  22757. this.final = this._finalOrDigest
  22758. }
  22759. if (this._final) {
  22760. this.__final = this._final
  22761. this._final = null
  22762. }
  22763. this._decoder = null
  22764. this._encoding = null
  22765. }
  22766. inherits(CipherBase, Transform)
  22767. CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
  22768. if (typeof data === 'string') {
  22769. data = Buffer.from(data, inputEnc)
  22770. }
  22771. var outData = this._update(data)
  22772. if (this.hashMode) return this
  22773. if (outputEnc) {
  22774. outData = this._toString(outData, outputEnc)
  22775. }
  22776. return outData
  22777. }
  22778. CipherBase.prototype.setAutoPadding = function () {}
  22779. CipherBase.prototype.getAuthTag = function () {
  22780. throw new Error('trying to get auth tag in unsupported state')
  22781. }
  22782. CipherBase.prototype.setAuthTag = function () {
  22783. throw new Error('trying to set auth tag in unsupported state')
  22784. }
  22785. CipherBase.prototype.setAAD = function () {
  22786. throw new Error('trying to set aad in unsupported state')
  22787. }
  22788. CipherBase.prototype._transform = function (data, _, next) {
  22789. var err
  22790. try {
  22791. if (this.hashMode) {
  22792. this._update(data)
  22793. } else {
  22794. this.push(this._update(data))
  22795. }
  22796. } catch (e) {
  22797. err = e
  22798. } finally {
  22799. next(err)
  22800. }
  22801. }
  22802. CipherBase.prototype._flush = function (done) {
  22803. var err
  22804. try {
  22805. this.push(this.__final())
  22806. } catch (e) {
  22807. err = e
  22808. }
  22809. done(err)
  22810. }
  22811. CipherBase.prototype._finalOrDigest = function (outputEnc) {
  22812. var outData = this.__final() || Buffer.alloc(0)
  22813. if (outputEnc) {
  22814. outData = this._toString(outData, outputEnc, true)
  22815. }
  22816. return outData
  22817. }
  22818. CipherBase.prototype._toString = function (value, enc, fin) {
  22819. if (!this._decoder) {
  22820. this._decoder = new StringDecoder(enc)
  22821. this._encoding = enc
  22822. }
  22823. if (this._encoding !== enc) throw new Error('can\'t switch encodings')
  22824. var out = this._decoder.write(value)
  22825. if (fin) {
  22826. out += this._decoder.end()
  22827. }
  22828. return out
  22829. }
  22830. module.exports = CipherBase
  22831. /***/ }),
  22832. /***/ "./node_modules/clipboard/dist/clipboard.js":
  22833. /*!**************************************************!*\
  22834. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  22835. \**************************************************/
  22836. /***/ (function(module) {
  22837. /*!
  22838. * clipboard.js v2.0.8
  22839. * https://clipboardjs.com/
  22840. *
  22841. * Licensed MIT © Zeno Rocha
  22842. */
  22843. (function webpackUniversalModuleDefinition(root, factory) {
  22844. if(true)
  22845. module.exports = factory();
  22846. else {}
  22847. })(this, function() {
  22848. return /******/ (function() { // webpackBootstrap
  22849. /******/ var __webpack_modules__ = ({
  22850. /***/ 134:
  22851. /***/ (function(__unused_webpack_module, __nested_webpack_exports__, __nested_webpack_require_622__) {
  22852. "use strict";
  22853. // EXPORTS
  22854. __nested_webpack_require_622__.d(__nested_webpack_exports__, {
  22855. "default": function() { return /* binding */ clipboard; }
  22856. });
  22857. // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
  22858. var tiny_emitter = __nested_webpack_require_622__(279);
  22859. var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_622__.n(tiny_emitter);
  22860. // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
  22861. var listen = __nested_webpack_require_622__(370);
  22862. var listen_default = /*#__PURE__*/__nested_webpack_require_622__.n(listen);
  22863. // EXTERNAL MODULE: ./node_modules/select/src/select.js
  22864. var src_select = __nested_webpack_require_622__(817);
  22865. var select_default = /*#__PURE__*/__nested_webpack_require_622__.n(src_select);
  22866. ;// CONCATENATED MODULE: ./src/clipboard-action.js
  22867. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  22868. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22869. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  22870. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  22871. /**
  22872. * Inner class which performs selection from either `text` or `target`
  22873. * properties and then executes copy or cut operations.
  22874. */
  22875. var ClipboardAction = /*#__PURE__*/function () {
  22876. /**
  22877. * @param {Object} options
  22878. */
  22879. function ClipboardAction(options) {
  22880. _classCallCheck(this, ClipboardAction);
  22881. this.resolveOptions(options);
  22882. this.initSelection();
  22883. }
  22884. /**
  22885. * Defines base properties passed from constructor.
  22886. * @param {Object} options
  22887. */
  22888. _createClass(ClipboardAction, [{
  22889. key: "resolveOptions",
  22890. value: function resolveOptions() {
  22891. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  22892. this.action = options.action;
  22893. this.container = options.container;
  22894. this.emitter = options.emitter;
  22895. this.target = options.target;
  22896. this.text = options.text;
  22897. this.trigger = options.trigger;
  22898. this.selectedText = '';
  22899. }
  22900. /**
  22901. * Decides which selection strategy is going to be applied based
  22902. * on the existence of `text` and `target` properties.
  22903. */
  22904. }, {
  22905. key: "initSelection",
  22906. value: function initSelection() {
  22907. if (this.text) {
  22908. this.selectFake();
  22909. } else if (this.target) {
  22910. this.selectTarget();
  22911. }
  22912. }
  22913. /**
  22914. * Creates a fake textarea element, sets its value from `text` property,
  22915. */
  22916. }, {
  22917. key: "createFakeElement",
  22918. value: function createFakeElement() {
  22919. var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
  22920. this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS
  22921. this.fakeElem.style.fontSize = '12pt'; // Reset box model
  22922. this.fakeElem.style.border = '0';
  22923. this.fakeElem.style.padding = '0';
  22924. this.fakeElem.style.margin = '0'; // Move element out of screen horizontally
  22925. this.fakeElem.style.position = 'absolute';
  22926. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
  22927. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  22928. this.fakeElem.style.top = "".concat(yPosition, "px");
  22929. this.fakeElem.setAttribute('readonly', '');
  22930. this.fakeElem.value = this.text;
  22931. return this.fakeElem;
  22932. }
  22933. /**
  22934. * Get's the value of fakeElem,
  22935. * and makes a selection on it.
  22936. */
  22937. }, {
  22938. key: "selectFake",
  22939. value: function selectFake() {
  22940. var _this = this;
  22941. var fakeElem = this.createFakeElement();
  22942. this.fakeHandlerCallback = function () {
  22943. return _this.removeFake();
  22944. };
  22945. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  22946. this.container.appendChild(fakeElem);
  22947. this.selectedText = select_default()(fakeElem);
  22948. this.copyText();
  22949. this.removeFake();
  22950. }
  22951. /**
  22952. * Only removes the fake element after another click event, that way
  22953. * a user can hit `Ctrl+C` to copy because selection still exists.
  22954. */
  22955. }, {
  22956. key: "removeFake",
  22957. value: function removeFake() {
  22958. if (this.fakeHandler) {
  22959. this.container.removeEventListener('click', this.fakeHandlerCallback);
  22960. this.fakeHandler = null;
  22961. this.fakeHandlerCallback = null;
  22962. }
  22963. if (this.fakeElem) {
  22964. this.container.removeChild(this.fakeElem);
  22965. this.fakeElem = null;
  22966. }
  22967. }
  22968. /**
  22969. * Selects the content from element passed on `target` property.
  22970. */
  22971. }, {
  22972. key: "selectTarget",
  22973. value: function selectTarget() {
  22974. this.selectedText = select_default()(this.target);
  22975. this.copyText();
  22976. }
  22977. /**
  22978. * Executes the copy operation based on the current selection.
  22979. */
  22980. }, {
  22981. key: "copyText",
  22982. value: function copyText() {
  22983. var succeeded;
  22984. try {
  22985. succeeded = document.execCommand(this.action);
  22986. } catch (err) {
  22987. succeeded = false;
  22988. }
  22989. this.handleResult(succeeded);
  22990. }
  22991. /**
  22992. * Fires an event based on the copy operation result.
  22993. * @param {Boolean} succeeded
  22994. */
  22995. }, {
  22996. key: "handleResult",
  22997. value: function handleResult(succeeded) {
  22998. this.emitter.emit(succeeded ? 'success' : 'error', {
  22999. action: this.action,
  23000. text: this.selectedText,
  23001. trigger: this.trigger,
  23002. clearSelection: this.clearSelection.bind(this)
  23003. });
  23004. }
  23005. /**
  23006. * Moves focus away from `target` and back to the trigger, removes current selection.
  23007. */
  23008. }, {
  23009. key: "clearSelection",
  23010. value: function clearSelection() {
  23011. if (this.trigger) {
  23012. this.trigger.focus();
  23013. }
  23014. document.activeElement.blur();
  23015. window.getSelection().removeAllRanges();
  23016. }
  23017. /**
  23018. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  23019. * @param {String} action
  23020. */
  23021. }, {
  23022. key: "destroy",
  23023. /**
  23024. * Destroy lifecycle.
  23025. */
  23026. value: function destroy() {
  23027. this.removeFake();
  23028. }
  23029. }, {
  23030. key: "action",
  23031. set: function set() {
  23032. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  23033. this._action = action;
  23034. if (this._action !== 'copy' && this._action !== 'cut') {
  23035. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  23036. }
  23037. }
  23038. /**
  23039. * Gets the `action` property.
  23040. * @return {String}
  23041. */
  23042. ,
  23043. get: function get() {
  23044. return this._action;
  23045. }
  23046. /**
  23047. * Sets the `target` property using an element
  23048. * that will be have its content copied.
  23049. * @param {Element} target
  23050. */
  23051. }, {
  23052. key: "target",
  23053. set: function set(target) {
  23054. if (target !== undefined) {
  23055. if (target && _typeof(target) === 'object' && target.nodeType === 1) {
  23056. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  23057. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  23058. }
  23059. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  23060. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  23061. }
  23062. this._target = target;
  23063. } else {
  23064. throw new Error('Invalid "target" value, use a valid Element');
  23065. }
  23066. }
  23067. }
  23068. /**
  23069. * Gets the `target` property.
  23070. * @return {String|HTMLElement}
  23071. */
  23072. ,
  23073. get: function get() {
  23074. return this._target;
  23075. }
  23076. }]);
  23077. return ClipboardAction;
  23078. }();
  23079. /* harmony default export */ var clipboard_action = (ClipboardAction);
  23080. ;// CONCATENATED MODULE: ./src/clipboard.js
  23081. function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
  23082. function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23083. function clipboard_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  23084. function clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) clipboard_defineProperties(Constructor, staticProps); return Constructor; }
  23085. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  23086. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  23087. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  23088. function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  23089. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  23090. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  23091. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  23092. /**
  23093. * Helper function to retrieve attribute value.
  23094. * @param {String} suffix
  23095. * @param {Element} element
  23096. */
  23097. function getAttributeValue(suffix, element) {
  23098. var attribute = "data-clipboard-".concat(suffix);
  23099. if (!element.hasAttribute(attribute)) {
  23100. return;
  23101. }
  23102. return element.getAttribute(attribute);
  23103. }
  23104. /**
  23105. * Base class which takes one or more elements, adds event listeners to them,
  23106. * and instantiates a new `ClipboardAction` on each click.
  23107. */
  23108. var Clipboard = /*#__PURE__*/function (_Emitter) {
  23109. _inherits(Clipboard, _Emitter);
  23110. var _super = _createSuper(Clipboard);
  23111. /**
  23112. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  23113. * @param {Object} options
  23114. */
  23115. function Clipboard(trigger, options) {
  23116. var _this;
  23117. clipboard_classCallCheck(this, Clipboard);
  23118. _this = _super.call(this);
  23119. _this.resolveOptions(options);
  23120. _this.listenClick(trigger);
  23121. return _this;
  23122. }
  23123. /**
  23124. * Defines if attributes would be resolved using internal setter functions
  23125. * or custom functions that were passed in the constructor.
  23126. * @param {Object} options
  23127. */
  23128. clipboard_createClass(Clipboard, [{
  23129. key: "resolveOptions",
  23130. value: function resolveOptions() {
  23131. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  23132. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  23133. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  23134. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  23135. this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
  23136. }
  23137. /**
  23138. * Adds a click event listener to the passed trigger.
  23139. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  23140. */
  23141. }, {
  23142. key: "listenClick",
  23143. value: function listenClick(trigger) {
  23144. var _this2 = this;
  23145. this.listener = listen_default()(trigger, 'click', function (e) {
  23146. return _this2.onClick(e);
  23147. });
  23148. }
  23149. /**
  23150. * Defines a new `ClipboardAction` on each click event.
  23151. * @param {Event} e
  23152. */
  23153. }, {
  23154. key: "onClick",
  23155. value: function onClick(e) {
  23156. var trigger = e.delegateTarget || e.currentTarget;
  23157. if (this.clipboardAction) {
  23158. this.clipboardAction = null;
  23159. }
  23160. this.clipboardAction = new clipboard_action({
  23161. action: this.action(trigger),
  23162. target: this.target(trigger),
  23163. text: this.text(trigger),
  23164. container: this.container,
  23165. trigger: trigger,
  23166. emitter: this
  23167. });
  23168. }
  23169. /**
  23170. * Default `action` lookup function.
  23171. * @param {Element} trigger
  23172. */
  23173. }, {
  23174. key: "defaultAction",
  23175. value: function defaultAction(trigger) {
  23176. return getAttributeValue('action', trigger);
  23177. }
  23178. /**
  23179. * Default `target` lookup function.
  23180. * @param {Element} trigger
  23181. */
  23182. }, {
  23183. key: "defaultTarget",
  23184. value: function defaultTarget(trigger) {
  23185. var selector = getAttributeValue('target', trigger);
  23186. if (selector) {
  23187. return document.querySelector(selector);
  23188. }
  23189. }
  23190. /**
  23191. * Returns the support of the given action, or all actions if no action is
  23192. * given.
  23193. * @param {String} [action]
  23194. */
  23195. }, {
  23196. key: "defaultText",
  23197. /**
  23198. * Default `text` lookup function.
  23199. * @param {Element} trigger
  23200. */
  23201. value: function defaultText(trigger) {
  23202. return getAttributeValue('text', trigger);
  23203. }
  23204. /**
  23205. * Destroy lifecycle.
  23206. */
  23207. }, {
  23208. key: "destroy",
  23209. value: function destroy() {
  23210. this.listener.destroy();
  23211. if (this.clipboardAction) {
  23212. this.clipboardAction.destroy();
  23213. this.clipboardAction = null;
  23214. }
  23215. }
  23216. }], [{
  23217. key: "isSupported",
  23218. value: function isSupported() {
  23219. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  23220. var actions = typeof action === 'string' ? [action] : action;
  23221. var support = !!document.queryCommandSupported;
  23222. actions.forEach(function (action) {
  23223. support = support && !!document.queryCommandSupported(action);
  23224. });
  23225. return support;
  23226. }
  23227. }]);
  23228. return Clipboard;
  23229. }((tiny_emitter_default()));
  23230. /* harmony default export */ var clipboard = (Clipboard);
  23231. /***/ }),
  23232. /***/ 828:
  23233. /***/ (function(module) {
  23234. var DOCUMENT_NODE_TYPE = 9;
  23235. /**
  23236. * A polyfill for Element.matches()
  23237. */
  23238. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  23239. var proto = Element.prototype;
  23240. proto.matches = proto.matchesSelector ||
  23241. proto.mozMatchesSelector ||
  23242. proto.msMatchesSelector ||
  23243. proto.oMatchesSelector ||
  23244. proto.webkitMatchesSelector;
  23245. }
  23246. /**
  23247. * Finds the closest parent that matches a selector.
  23248. *
  23249. * @param {Element} element
  23250. * @param {String} selector
  23251. * @return {Function}
  23252. */
  23253. function closest (element, selector) {
  23254. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  23255. if (typeof element.matches === 'function' &&
  23256. element.matches(selector)) {
  23257. return element;
  23258. }
  23259. element = element.parentNode;
  23260. }
  23261. }
  23262. module.exports = closest;
  23263. /***/ }),
  23264. /***/ 438:
  23265. /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_17417__) {
  23266. var closest = __nested_webpack_require_17417__(828);
  23267. /**
  23268. * Delegates event to a selector.
  23269. *
  23270. * @param {Element} element
  23271. * @param {String} selector
  23272. * @param {String} type
  23273. * @param {Function} callback
  23274. * @param {Boolean} useCapture
  23275. * @return {Object}
  23276. */
  23277. function _delegate(element, selector, type, callback, useCapture) {
  23278. var listenerFn = listener.apply(this, arguments);
  23279. element.addEventListener(type, listenerFn, useCapture);
  23280. return {
  23281. destroy: function() {
  23282. element.removeEventListener(type, listenerFn, useCapture);
  23283. }
  23284. }
  23285. }
  23286. /**
  23287. * Delegates event to a selector.
  23288. *
  23289. * @param {Element|String|Array} [elements]
  23290. * @param {String} selector
  23291. * @param {String} type
  23292. * @param {Function} callback
  23293. * @param {Boolean} useCapture
  23294. * @return {Object}
  23295. */
  23296. function delegate(elements, selector, type, callback, useCapture) {
  23297. // Handle the regular Element usage
  23298. if (typeof elements.addEventListener === 'function') {
  23299. return _delegate.apply(null, arguments);
  23300. }
  23301. // Handle Element-less usage, it defaults to global delegation
  23302. if (typeof type === 'function') {
  23303. // Use `document` as the first parameter, then apply arguments
  23304. // This is a short way to .unshift `arguments` without running into deoptimizations
  23305. return _delegate.bind(null, document).apply(null, arguments);
  23306. }
  23307. // Handle Selector-based usage
  23308. if (typeof elements === 'string') {
  23309. elements = document.querySelectorAll(elements);
  23310. }
  23311. // Handle Array-like based usage
  23312. return Array.prototype.map.call(elements, function (element) {
  23313. return _delegate(element, selector, type, callback, useCapture);
  23314. });
  23315. }
  23316. /**
  23317. * Finds closest match and invokes callback.
  23318. *
  23319. * @param {Element} element
  23320. * @param {String} selector
  23321. * @param {String} type
  23322. * @param {Function} callback
  23323. * @return {Function}
  23324. */
  23325. function listener(element, selector, type, callback) {
  23326. return function(e) {
  23327. e.delegateTarget = closest(e.target, selector);
  23328. if (e.delegateTarget) {
  23329. callback.call(element, e);
  23330. }
  23331. }
  23332. }
  23333. module.exports = delegate;
  23334. /***/ }),
  23335. /***/ 879:
  23336. /***/ (function(__unused_webpack_module, exports) {
  23337. /**
  23338. * Check if argument is a HTML element.
  23339. *
  23340. * @param {Object} value
  23341. * @return {Boolean}
  23342. */
  23343. exports.node = function(value) {
  23344. return value !== undefined
  23345. && value instanceof HTMLElement
  23346. && value.nodeType === 1;
  23347. };
  23348. /**
  23349. * Check if argument is a list of HTML elements.
  23350. *
  23351. * @param {Object} value
  23352. * @return {Boolean}
  23353. */
  23354. exports.nodeList = function(value) {
  23355. var type = Object.prototype.toString.call(value);
  23356. return value !== undefined
  23357. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  23358. && ('length' in value)
  23359. && (value.length === 0 || exports.node(value[0]));
  23360. };
  23361. /**
  23362. * Check if argument is a string.
  23363. *
  23364. * @param {Object} value
  23365. * @return {Boolean}
  23366. */
  23367. exports.string = function(value) {
  23368. return typeof value === 'string'
  23369. || value instanceof String;
  23370. };
  23371. /**
  23372. * Check if argument is a function.
  23373. *
  23374. * @param {Object} value
  23375. * @return {Boolean}
  23376. */
  23377. exports.fn = function(value) {
  23378. var type = Object.prototype.toString.call(value);
  23379. return type === '[object Function]';
  23380. };
  23381. /***/ }),
  23382. /***/ 370:
  23383. /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_20781__) {
  23384. var is = __nested_webpack_require_20781__(879);
  23385. var delegate = __nested_webpack_require_20781__(438);
  23386. /**
  23387. * Validates all params and calls the right
  23388. * listener function based on its target type.
  23389. *
  23390. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  23391. * @param {String} type
  23392. * @param {Function} callback
  23393. * @return {Object}
  23394. */
  23395. function listen(target, type, callback) {
  23396. if (!target && !type && !callback) {
  23397. throw new Error('Missing required arguments');
  23398. }
  23399. if (!is.string(type)) {
  23400. throw new TypeError('Second argument must be a String');
  23401. }
  23402. if (!is.fn(callback)) {
  23403. throw new TypeError('Third argument must be a Function');
  23404. }
  23405. if (is.node(target)) {
  23406. return listenNode(target, type, callback);
  23407. }
  23408. else if (is.nodeList(target)) {
  23409. return listenNodeList(target, type, callback);
  23410. }
  23411. else if (is.string(target)) {
  23412. return listenSelector(target, type, callback);
  23413. }
  23414. else {
  23415. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  23416. }
  23417. }
  23418. /**
  23419. * Adds an event listener to a HTML element
  23420. * and returns a remove listener function.
  23421. *
  23422. * @param {HTMLElement} node
  23423. * @param {String} type
  23424. * @param {Function} callback
  23425. * @return {Object}
  23426. */
  23427. function listenNode(node, type, callback) {
  23428. node.addEventListener(type, callback);
  23429. return {
  23430. destroy: function() {
  23431. node.removeEventListener(type, callback);
  23432. }
  23433. }
  23434. }
  23435. /**
  23436. * Add an event listener to a list of HTML elements
  23437. * and returns a remove listener function.
  23438. *
  23439. * @param {NodeList|HTMLCollection} nodeList
  23440. * @param {String} type
  23441. * @param {Function} callback
  23442. * @return {Object}
  23443. */
  23444. function listenNodeList(nodeList, type, callback) {
  23445. Array.prototype.forEach.call(nodeList, function(node) {
  23446. node.addEventListener(type, callback);
  23447. });
  23448. return {
  23449. destroy: function() {
  23450. Array.prototype.forEach.call(nodeList, function(node) {
  23451. node.removeEventListener(type, callback);
  23452. });
  23453. }
  23454. }
  23455. }
  23456. /**
  23457. * Add an event listener to a selector
  23458. * and returns a remove listener function.
  23459. *
  23460. * @param {String} selector
  23461. * @param {String} type
  23462. * @param {Function} callback
  23463. * @return {Object}
  23464. */
  23465. function listenSelector(selector, type, callback) {
  23466. return delegate(document.body, selector, type, callback);
  23467. }
  23468. module.exports = listen;
  23469. /***/ }),
  23470. /***/ 817:
  23471. /***/ (function(module) {
  23472. function select(element) {
  23473. var selectedText;
  23474. if (element.nodeName === 'SELECT') {
  23475. element.focus();
  23476. selectedText = element.value;
  23477. }
  23478. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  23479. var isReadOnly = element.hasAttribute('readonly');
  23480. if (!isReadOnly) {
  23481. element.setAttribute('readonly', '');
  23482. }
  23483. element.select();
  23484. element.setSelectionRange(0, element.value.length);
  23485. if (!isReadOnly) {
  23486. element.removeAttribute('readonly');
  23487. }
  23488. selectedText = element.value;
  23489. }
  23490. else {
  23491. if (element.hasAttribute('contenteditable')) {
  23492. element.focus();
  23493. }
  23494. var selection = window.getSelection();
  23495. var range = document.createRange();
  23496. range.selectNodeContents(element);
  23497. selection.removeAllRanges();
  23498. selection.addRange(range);
  23499. selectedText = selection.toString();
  23500. }
  23501. return selectedText;
  23502. }
  23503. module.exports = select;
  23504. /***/ }),
  23505. /***/ 279:
  23506. /***/ (function(module) {
  23507. function E () {
  23508. // Keep this empty so it's easier to inherit from
  23509. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  23510. }
  23511. E.prototype = {
  23512. on: function (name, callback, ctx) {
  23513. var e = this.e || (this.e = {});
  23514. (e[name] || (e[name] = [])).push({
  23515. fn: callback,
  23516. ctx: ctx
  23517. });
  23518. return this;
  23519. },
  23520. once: function (name, callback, ctx) {
  23521. var self = this;
  23522. function listener () {
  23523. self.off(name, listener);
  23524. callback.apply(ctx, arguments);
  23525. };
  23526. listener._ = callback
  23527. return this.on(name, listener, ctx);
  23528. },
  23529. emit: function (name) {
  23530. var data = [].slice.call(arguments, 1);
  23531. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  23532. var i = 0;
  23533. var len = evtArr.length;
  23534. for (i; i < len; i++) {
  23535. evtArr[i].fn.apply(evtArr[i].ctx, data);
  23536. }
  23537. return this;
  23538. },
  23539. off: function (name, callback) {
  23540. var e = this.e || (this.e = {});
  23541. var evts = e[name];
  23542. var liveEvents = [];
  23543. if (evts && callback) {
  23544. for (var i = 0, len = evts.length; i < len; i++) {
  23545. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  23546. liveEvents.push(evts[i]);
  23547. }
  23548. }
  23549. // Remove event from queue to prevent memory leak
  23550. // Suggested by https://github.com/lazd
  23551. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  23552. (liveEvents.length)
  23553. ? e[name] = liveEvents
  23554. : delete e[name];
  23555. return this;
  23556. }
  23557. };
  23558. module.exports = E;
  23559. module.exports.TinyEmitter = E;
  23560. /***/ })
  23561. /******/ });
  23562. /************************************************************************/
  23563. /******/ // The module cache
  23564. /******/ var __webpack_module_cache__ = {};
  23565. /******/
  23566. /******/ // The require function
  23567. /******/ function __nested_webpack_require_26163__(moduleId) {
  23568. /******/ // Check if module is in cache
  23569. /******/ if(__webpack_module_cache__[moduleId]) {
  23570. /******/ return __webpack_module_cache__[moduleId].exports;
  23571. /******/ }
  23572. /******/ // Create a new module (and put it into the cache)
  23573. /******/ var module = __webpack_module_cache__[moduleId] = {
  23574. /******/ // no module.id needed
  23575. /******/ // no module.loaded needed
  23576. /******/ exports: {}
  23577. /******/ };
  23578. /******/
  23579. /******/ // Execute the module function
  23580. /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_26163__);
  23581. /******/
  23582. /******/ // Return the exports of the module
  23583. /******/ return module.exports;
  23584. /******/ }
  23585. /******/
  23586. /************************************************************************/
  23587. /******/ /* webpack/runtime/compat get default export */
  23588. /******/ !function() {
  23589. /******/ // getDefaultExport function for compatibility with non-harmony modules
  23590. /******/ __nested_webpack_require_26163__.n = function(module) {
  23591. /******/ var getter = module && module.__esModule ?
  23592. /******/ function() { return module['default']; } :
  23593. /******/ function() { return module; };
  23594. /******/ __nested_webpack_require_26163__.d(getter, { a: getter });
  23595. /******/ return getter;
  23596. /******/ };
  23597. /******/ }();
  23598. /******/
  23599. /******/ /* webpack/runtime/define property getters */
  23600. /******/ !function() {
  23601. /******/ // define getter functions for harmony exports
  23602. /******/ __nested_webpack_require_26163__.d = function(exports, definition) {
  23603. /******/ for(var key in definition) {
  23604. /******/ if(__nested_webpack_require_26163__.o(definition, key) && !__nested_webpack_require_26163__.o(exports, key)) {
  23605. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  23606. /******/ }
  23607. /******/ }
  23608. /******/ };
  23609. /******/ }();
  23610. /******/
  23611. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  23612. /******/ !function() {
  23613. /******/ __nested_webpack_require_26163__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  23614. /******/ }();
  23615. /******/
  23616. /************************************************************************/
  23617. /******/ // module exports must be returned from runtime so entry inlining is disabled
  23618. /******/ // startup
  23619. /******/ // Load entry module and return exports
  23620. /******/ return __nested_webpack_require_26163__(134);
  23621. /******/ })()
  23622. .default;
  23623. });
  23624. /***/ }),
  23625. /***/ "./node_modules/clusterize.js/clusterize.js":
  23626. /*!**************************************************!*\
  23627. !*** ./node_modules/clusterize.js/clusterize.js ***!
  23628. \**************************************************/
  23629. /***/ ((module) => {
  23630. /* Clusterize.js - v0.19.0 - 2021-12-19
  23631. http://NeXTs.github.com/Clusterize.js/
  23632. Copyright (c) 2015 Denis Lukov; Licensed GPLv3 */
  23633. ;(function(name, definition) {
  23634. if (true) module.exports = definition();
  23635. else {}
  23636. }('Clusterize', function() {
  23637. "use strict"
  23638. // detect ie9 and lower
  23639. // https://gist.github.com/padolsey/527683#comment-786682
  23640. var ie = (function(){
  23641. for( var v = 3,
  23642. el = document.createElement('b'),
  23643. all = el.all || [];
  23644. el.innerHTML = '<!--[if gt IE ' + (++v) + ']><i><![endif]-->',
  23645. all[0];
  23646. ){}
  23647. return v > 4 ? v : document.documentMode;
  23648. }()),
  23649. is_mac = navigator.platform.toLowerCase().indexOf('mac') + 1;
  23650. var Clusterize = function(data) {
  23651. if( ! (this instanceof Clusterize))
  23652. return new Clusterize(data);
  23653. var self = this;
  23654. var defaults = {
  23655. rows_in_block: 50,
  23656. blocks_in_cluster: 4,
  23657. tag: null,
  23658. show_no_data_row: true,
  23659. no_data_class: 'clusterize-no-data',
  23660. no_data_text: 'No data',
  23661. keep_parity: true,
  23662. callbacks: {}
  23663. }
  23664. // public parameters
  23665. self.options = {};
  23666. var options = ['rows_in_block', 'blocks_in_cluster', 'show_no_data_row', 'no_data_class', 'no_data_text', 'keep_parity', 'tag', 'callbacks'];
  23667. for(var i = 0, option; option = options[i]; i++) {
  23668. self.options[option] = typeof data[option] != 'undefined' && data[option] != null
  23669. ? data[option]
  23670. : defaults[option];
  23671. }
  23672. var elems = ['scroll', 'content'];
  23673. for(var i = 0, elem; elem = elems[i]; i++) {
  23674. self[elem + '_elem'] = data[elem + 'Id']
  23675. ? document.getElementById(data[elem + 'Id'])
  23676. : data[elem + 'Elem'];
  23677. if( ! self[elem + '_elem'])
  23678. throw new Error("Error! Could not find " + elem + " element");
  23679. }
  23680. // tabindex forces the browser to keep focus on the scrolling list, fixes #11
  23681. if( ! self.content_elem.hasAttribute('tabindex'))
  23682. self.content_elem.setAttribute('tabindex', 0);
  23683. // private parameters
  23684. var rows = isArray(data.rows)
  23685. ? data.rows
  23686. : self.fetchMarkup(),
  23687. cache = {},
  23688. scroll_top = self.scroll_elem.scrollTop;
  23689. // append initial data
  23690. self.insertToDOM(rows, cache);
  23691. // restore the scroll position
  23692. self.scroll_elem.scrollTop = scroll_top;
  23693. // adding scroll handler
  23694. var last_cluster = false,
  23695. scroll_debounce = 0,
  23696. pointer_events_set = false,
  23697. scrollEv = function() {
  23698. // fixes scrolling issue on Mac #3
  23699. if (is_mac) {
  23700. if( ! pointer_events_set) self.content_elem.style.pointerEvents = 'none';
  23701. pointer_events_set = true;
  23702. clearTimeout(scroll_debounce);
  23703. scroll_debounce = setTimeout(function () {
  23704. self.content_elem.style.pointerEvents = 'auto';
  23705. pointer_events_set = false;
  23706. }, 50);
  23707. }
  23708. if (last_cluster != (last_cluster = self.getClusterNum(rows)))
  23709. self.insertToDOM(rows, cache);
  23710. if (self.options.callbacks.scrollingProgress)
  23711. self.options.callbacks.scrollingProgress(self.getScrollProgress());
  23712. },
  23713. resize_debounce = 0,
  23714. resizeEv = function() {
  23715. clearTimeout(resize_debounce);
  23716. resize_debounce = setTimeout(self.refresh, 100);
  23717. }
  23718. on('scroll', self.scroll_elem, scrollEv);
  23719. on('resize', window, resizeEv);
  23720. // public methods
  23721. self.destroy = function(clean) {
  23722. off('scroll', self.scroll_elem, scrollEv);
  23723. off('resize', window, resizeEv);
  23724. self.html((clean ? self.generateEmptyRow() : rows).join(''));
  23725. }
  23726. self.refresh = function(force) {
  23727. if(self.getRowsHeight(rows) || force) self.update(rows);
  23728. }
  23729. self.update = function(new_rows) {
  23730. rows = isArray(new_rows)
  23731. ? new_rows
  23732. : [];
  23733. var scroll_top = self.scroll_elem.scrollTop;
  23734. // fixes #39
  23735. if(rows.length * self.options.item_height < scroll_top) {
  23736. self.scroll_elem.scrollTop = 0;
  23737. last_cluster = 0;
  23738. }
  23739. self.insertToDOM(rows, cache);
  23740. self.scroll_elem.scrollTop = scroll_top;
  23741. }
  23742. self.clear = function() {
  23743. self.update([]);
  23744. }
  23745. self.getRowsAmount = function() {
  23746. return rows.length;
  23747. }
  23748. self.getScrollProgress = function() {
  23749. return this.options.scroll_top / (rows.length * this.options.item_height) * 100 || 0;
  23750. }
  23751. var add = function(where, _new_rows) {
  23752. var new_rows = isArray(_new_rows)
  23753. ? _new_rows
  23754. : [];
  23755. if( ! new_rows.length) return;
  23756. rows = where == 'append'
  23757. ? rows.concat(new_rows)
  23758. : new_rows.concat(rows);
  23759. self.insertToDOM(rows, cache);
  23760. }
  23761. self.append = function(rows) {
  23762. add('append', rows);
  23763. }
  23764. self.prepend = function(rows) {
  23765. add('prepend', rows);
  23766. }
  23767. }
  23768. Clusterize.prototype = {
  23769. constructor: Clusterize,
  23770. // fetch existing markup
  23771. fetchMarkup: function() {
  23772. var rows = [], rows_nodes = this.getChildNodes(this.content_elem);
  23773. while (rows_nodes.length) {
  23774. rows.push(rows_nodes.shift().outerHTML);
  23775. }
  23776. return rows;
  23777. },
  23778. // get tag name, content tag name, tag height, calc cluster height
  23779. exploreEnvironment: function(rows, cache) {
  23780. var opts = this.options;
  23781. opts.content_tag = this.content_elem.tagName.toLowerCase();
  23782. if( ! rows.length) return;
  23783. if(ie && ie <= 9 && ! opts.tag) opts.tag = rows[0].match(/<([^>\s/]*)/)[1].toLowerCase();
  23784. if(this.content_elem.children.length <= 1) cache.data = this.html(rows[0] + rows[0] + rows[0]);
  23785. if( ! opts.tag) opts.tag = this.content_elem.children[0].tagName.toLowerCase();
  23786. this.getRowsHeight(rows);
  23787. },
  23788. getRowsHeight: function(rows) {
  23789. var opts = this.options,
  23790. prev_item_height = opts.item_height;
  23791. opts.cluster_height = 0;
  23792. if( ! rows.length) return;
  23793. var nodes = this.content_elem.children;
  23794. if( ! nodes.length) return;
  23795. var node = nodes[Math.floor(nodes.length / 2)];
  23796. opts.item_height = node.offsetHeight;
  23797. // consider table's border-spacing
  23798. if(opts.tag == 'tr' && getStyle('borderCollapse', this.content_elem) != 'collapse')
  23799. opts.item_height += parseInt(getStyle('borderSpacing', this.content_elem), 10) || 0;
  23800. // consider margins (and margins collapsing)
  23801. if(opts.tag != 'tr') {
  23802. var marginTop = parseInt(getStyle('marginTop', node), 10) || 0;
  23803. var marginBottom = parseInt(getStyle('marginBottom', node), 10) || 0;
  23804. opts.item_height += Math.max(marginTop, marginBottom);
  23805. }
  23806. opts.block_height = opts.item_height * opts.rows_in_block;
  23807. opts.rows_in_cluster = opts.blocks_in_cluster * opts.rows_in_block;
  23808. opts.cluster_height = opts.blocks_in_cluster * opts.block_height;
  23809. return prev_item_height != opts.item_height;
  23810. },
  23811. // get current cluster number
  23812. getClusterNum: function (rows) {
  23813. var opts = this.options;
  23814. opts.scroll_top = this.scroll_elem.scrollTop;
  23815. var cluster_divider = opts.cluster_height - opts.block_height;
  23816. var current_cluster = Math.floor(opts.scroll_top / cluster_divider);
  23817. var max_cluster = Math.floor((rows.length * opts.item_height) / cluster_divider);
  23818. return Math.min(current_cluster, max_cluster);
  23819. },
  23820. // generate empty row if no data provided
  23821. generateEmptyRow: function() {
  23822. var opts = this.options;
  23823. if( ! opts.tag || ! opts.show_no_data_row) return [];
  23824. var empty_row = document.createElement(opts.tag),
  23825. no_data_content = document.createTextNode(opts.no_data_text), td;
  23826. empty_row.className = opts.no_data_class;
  23827. if(opts.tag == 'tr') {
  23828. td = document.createElement('td');
  23829. // fixes #53
  23830. td.colSpan = 100;
  23831. td.appendChild(no_data_content);
  23832. }
  23833. empty_row.appendChild(td || no_data_content);
  23834. return [empty_row.outerHTML];
  23835. },
  23836. // generate cluster for current scroll position
  23837. generate: function (rows) {
  23838. var opts = this.options,
  23839. rows_len = rows.length;
  23840. if (rows_len < opts.rows_in_block) {
  23841. return {
  23842. top_offset: 0,
  23843. bottom_offset: 0,
  23844. rows_above: 0,
  23845. rows: rows_len ? rows : this.generateEmptyRow()
  23846. }
  23847. }
  23848. var items_start = Math.max((opts.rows_in_cluster - opts.rows_in_block) * this.getClusterNum(rows), 0),
  23849. items_end = items_start + opts.rows_in_cluster,
  23850. top_offset = Math.max(items_start * opts.item_height, 0),
  23851. bottom_offset = Math.max((rows_len - items_end) * opts.item_height, 0),
  23852. this_cluster_rows = [],
  23853. rows_above = items_start;
  23854. if(top_offset < 1) {
  23855. rows_above++;
  23856. }
  23857. for (var i = items_start; i < items_end; i++) {
  23858. rows[i] && this_cluster_rows.push(rows[i]);
  23859. }
  23860. return {
  23861. top_offset: top_offset,
  23862. bottom_offset: bottom_offset,
  23863. rows_above: rows_above,
  23864. rows: this_cluster_rows
  23865. }
  23866. },
  23867. renderExtraTag: function(class_name, height) {
  23868. var tag = document.createElement(this.options.tag),
  23869. clusterize_prefix = 'clusterize-';
  23870. tag.className = [clusterize_prefix + 'extra-row', clusterize_prefix + class_name].join(' ');
  23871. height && (tag.style.height = height + 'px');
  23872. return tag.outerHTML;
  23873. },
  23874. // if necessary verify data changed and insert to DOM
  23875. insertToDOM: function(rows, cache) {
  23876. // explore row's height
  23877. if( ! this.options.cluster_height) {
  23878. this.exploreEnvironment(rows, cache);
  23879. }
  23880. var data = this.generate(rows),
  23881. this_cluster_rows = data.rows.join(''),
  23882. this_cluster_content_changed = this.checkChanges('data', this_cluster_rows, cache),
  23883. top_offset_changed = this.checkChanges('top', data.top_offset, cache),
  23884. only_bottom_offset_changed = this.checkChanges('bottom', data.bottom_offset, cache),
  23885. callbacks = this.options.callbacks,
  23886. layout = [];
  23887. if(this_cluster_content_changed || top_offset_changed) {
  23888. if(data.top_offset) {
  23889. this.options.keep_parity && layout.push(this.renderExtraTag('keep-parity'));
  23890. layout.push(this.renderExtraTag('top-space', data.top_offset));
  23891. }
  23892. layout.push(this_cluster_rows);
  23893. data.bottom_offset && layout.push(this.renderExtraTag('bottom-space', data.bottom_offset));
  23894. callbacks.clusterWillChange && callbacks.clusterWillChange();
  23895. this.html(layout.join(''));
  23896. this.options.content_tag == 'ol' && this.content_elem.setAttribute('start', data.rows_above);
  23897. this.content_elem.style['counter-increment'] = 'clusterize-counter ' + (data.rows_above-1);
  23898. callbacks.clusterChanged && callbacks.clusterChanged();
  23899. } else if(only_bottom_offset_changed) {
  23900. this.content_elem.lastChild.style.height = data.bottom_offset + 'px';
  23901. }
  23902. },
  23903. // unfortunately ie <= 9 does not allow to use innerHTML for table elements, so make a workaround
  23904. html: function(data) {
  23905. var content_elem = this.content_elem;
  23906. if(ie && ie <= 9 && this.options.tag == 'tr') {
  23907. var div = document.createElement('div'), last;
  23908. div.innerHTML = '<table><tbody>' + data + '</tbody></table>';
  23909. while((last = content_elem.lastChild)) {
  23910. content_elem.removeChild(last);
  23911. }
  23912. var rows_nodes = this.getChildNodes(div.firstChild.firstChild);
  23913. while (rows_nodes.length) {
  23914. content_elem.appendChild(rows_nodes.shift());
  23915. }
  23916. } else {
  23917. content_elem.innerHTML = data;
  23918. }
  23919. },
  23920. getChildNodes: function(tag) {
  23921. var child_nodes = tag.children, nodes = [];
  23922. for (var i = 0, ii = child_nodes.length; i < ii; i++) {
  23923. nodes.push(child_nodes[i]);
  23924. }
  23925. return nodes;
  23926. },
  23927. checkChanges: function(type, value, cache) {
  23928. var changed = value != cache[type];
  23929. cache[type] = value;
  23930. return changed;
  23931. }
  23932. }
  23933. // support functions
  23934. function on(evt, element, fnc) {
  23935. return element.addEventListener ? element.addEventListener(evt, fnc, false) : element.attachEvent("on" + evt, fnc);
  23936. }
  23937. function off(evt, element, fnc) {
  23938. return element.removeEventListener ? element.removeEventListener(evt, fnc, false) : element.detachEvent("on" + evt, fnc);
  23939. }
  23940. function isArray(arr) {
  23941. return Object.prototype.toString.call(arr) === '[object Array]';
  23942. }
  23943. function getStyle(prop, elem) {
  23944. return window.getComputedStyle ? window.getComputedStyle(elem)[prop] : elem.currentStyle[prop];
  23945. }
  23946. return Clusterize;
  23947. }));
  23948. /***/ }),
  23949. /***/ "./node_modules/console-browserify/index.js":
  23950. /*!**************************************************!*\
  23951. !*** ./node_modules/console-browserify/index.js ***!
  23952. \**************************************************/
  23953. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23954. /*global window, global*/
  23955. var util = __webpack_require__(/*! util */ "./node_modules/util/util.js")
  23956. var assert = __webpack_require__(/*! assert */ "./node_modules/assert/assert.js")
  23957. function now() { return new Date().getTime() }
  23958. var slice = Array.prototype.slice
  23959. var console
  23960. var times = {}
  23961. if (typeof __webpack_require__.g !== "undefined" && __webpack_require__.g.console) {
  23962. console = __webpack_require__.g.console
  23963. } else if (typeof window !== "undefined" && window.console) {
  23964. console = window.console
  23965. } else {
  23966. console = {}
  23967. }
  23968. var functions = [
  23969. [log, "log"],
  23970. [info, "info"],
  23971. [warn, "warn"],
  23972. [error, "error"],
  23973. [time, "time"],
  23974. [timeEnd, "timeEnd"],
  23975. [trace, "trace"],
  23976. [dir, "dir"],
  23977. [consoleAssert, "assert"]
  23978. ]
  23979. for (var i = 0; i < functions.length; i++) {
  23980. var tuple = functions[i]
  23981. var f = tuple[0]
  23982. var name = tuple[1]
  23983. if (!console[name]) {
  23984. console[name] = f
  23985. }
  23986. }
  23987. module.exports = console
  23988. function log() {}
  23989. function info() {
  23990. console.log.apply(console, arguments)
  23991. }
  23992. function warn() {
  23993. console.log.apply(console, arguments)
  23994. }
  23995. function error() {
  23996. console.warn.apply(console, arguments)
  23997. }
  23998. function time(label) {
  23999. times[label] = now()
  24000. }
  24001. function timeEnd(label) {
  24002. var time = times[label]
  24003. if (!time) {
  24004. throw new Error("No such label: " + label)
  24005. }
  24006. delete times[label]
  24007. var duration = now() - time
  24008. console.log(label + ": " + duration + "ms")
  24009. }
  24010. function trace() {
  24011. var err = new Error()
  24012. err.name = "Trace"
  24013. err.message = util.format.apply(null, arguments)
  24014. console.error(err.stack)
  24015. }
  24016. function dir(object) {
  24017. console.log(util.inspect(object) + "\n")
  24018. }
  24019. function consoleAssert(expression) {
  24020. if (!expression) {
  24021. var arr = slice.call(arguments, 1)
  24022. assert.ok(false, util.format.apply(null, arr))
  24023. }
  24024. }
  24025. /***/ }),
  24026. /***/ "./node_modules/constant-case/dist.es2015/index.js":
  24027. /*!*********************************************************!*\
  24028. !*** ./node_modules/constant-case/dist.es2015/index.js ***!
  24029. \*********************************************************/
  24030. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  24031. "use strict";
  24032. __webpack_require__.r(__webpack_exports__);
  24033. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  24034. /* harmony export */ constantCase: () => (/* binding */ constantCase)
  24035. /* harmony export */ });
  24036. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  24037. /* harmony import */ var no_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! no-case */ "./node_modules/no-case/dist.es2015/index.js");
  24038. /* harmony import */ var upper_case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! upper-case */ "./node_modules/upper-case/dist.es2015/index.js");
  24039. function constantCase(input, options) {
  24040. if (options === void 0) { options = {}; }
  24041. return (0,no_case__WEBPACK_IMPORTED_MODULE_0__.noCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ delimiter: "_", transform: upper_case__WEBPACK_IMPORTED_MODULE_2__.upperCase }, options));
  24042. }
  24043. //# sourceMappingURL=index.js.map
  24044. /***/ }),
  24045. /***/ "./node_modules/create-ecdh/browser.js":
  24046. /*!*********************************************!*\
  24047. !*** ./node_modules/create-ecdh/browser.js ***!
  24048. \*********************************************/
  24049. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  24050. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
  24051. var elliptic = __webpack_require__(/*! elliptic */ "./node_modules/elliptic/lib/elliptic.js")
  24052. var BN = __webpack_require__(/*! bn.js */ "./node_modules/create-ecdh/node_modules/bn.js/lib/bn.js")
  24053. module.exports = function createECDH (curve) {
  24054. return new ECDH(curve)
  24055. }
  24056. var aliases = {
  24057. secp256k1: {
  24058. name: 'secp256k1',
  24059. byteLength: 32
  24060. },
  24061. secp224r1: {
  24062. name: 'p224',
  24063. byteLength: 28
  24064. },
  24065. prime256v1: {
  24066. name: 'p256',
  24067. byteLength: 32
  24068. },
  24069. prime192v1: {
  24070. name: 'p192',
  24071. byteLength: 24
  24072. },
  24073. ed25519: {
  24074. name: 'ed25519',
  24075. byteLength: 32
  24076. },
  24077. secp384r1: {
  24078. name: 'p384',
  24079. byteLength: 48
  24080. },
  24081. secp521r1: {
  24082. name: 'p521',
  24083. byteLength: 66
  24084. }
  24085. }
  24086. aliases.p224 = aliases.secp224r1
  24087. aliases.p256 = aliases.secp256r1 = aliases.prime256v1
  24088. aliases.p192 = aliases.secp192r1 = aliases.prime192v1
  24089. aliases.p384 = aliases.secp384r1
  24090. aliases.p521 = aliases.secp521r1
  24091. function ECDH (curve) {
  24092. this.curveType = aliases[curve]
  24093. if (!this.curveType) {
  24094. this.curveType = {
  24095. name: curve
  24096. }
  24097. }
  24098. this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
  24099. this.keys = void 0
  24100. }
  24101. ECDH.prototype.generateKeys = function (enc, format) {
  24102. this.keys = this.curve.genKeyPair()
  24103. return this.getPublicKey(enc, format)
  24104. }
  24105. ECDH.prototype.computeSecret = function (other, inenc, enc) {
  24106. inenc = inenc || 'utf8'
  24107. if (!Buffer.isBuffer(other)) {
  24108. other = new Buffer(other, inenc)
  24109. }
  24110. var otherPub = this.curve.keyFromPublic(other).getPublic()
  24111. var out = otherPub.mul(this.keys.getPrivate()).getX()
  24112. return formatReturnValue(out, enc, this.curveType.byteLength)
  24113. }
  24114. ECDH.prototype.getPublicKey = function (enc, format) {
  24115. var key = this.keys.getPublic(format === 'compressed', true)
  24116. if (format === 'hybrid') {
  24117. if (key[key.length - 1] % 2) {
  24118. key[0] = 7
  24119. } else {
  24120. key[0] = 6
  24121. }
  24122. }
  24123. return formatReturnValue(key, enc)
  24124. }
  24125. ECDH.prototype.getPrivateKey = function (enc) {
  24126. return formatReturnValue(this.keys.getPrivate(), enc)
  24127. }
  24128. ECDH.prototype.setPublicKey = function (pub, enc) {
  24129. enc = enc || 'utf8'
  24130. if (!Buffer.isBuffer(pub)) {
  24131. pub = new Buffer(pub, enc)
  24132. }
  24133. this.keys._importPublic(pub)
  24134. return this
  24135. }
  24136. ECDH.prototype.setPrivateKey = function (priv, enc) {
  24137. enc = enc || 'utf8'
  24138. if (!Buffer.isBuffer(priv)) {
  24139. priv = new Buffer(priv, enc)
  24140. }
  24141. var _priv = new BN(priv)
  24142. _priv = _priv.toString(16)
  24143. this.keys = this.curve.genKeyPair()
  24144. this.keys._importPrivate(_priv)
  24145. return this
  24146. }
  24147. function formatReturnValue (bn, enc, len) {
  24148. if (!Array.isArray(bn)) {
  24149. bn = bn.toArray()
  24150. }
  24151. var buf = new Buffer(bn)
  24152. if (len && buf.length < len) {
  24153. var zeros = new Buffer(len - buf.length)
  24154. zeros.fill(0)
  24155. buf = Buffer.concat([zeros, buf])
  24156. }
  24157. if (!enc) {
  24158. return buf
  24159. } else {
  24160. return buf.toString(enc)
  24161. }
  24162. }
  24163. /***/ }),
  24164. /***/ "./node_modules/create-ecdh/node_modules/bn.js/lib/bn.js":
  24165. /*!***************************************************************!*\
  24166. !*** ./node_modules/create-ecdh/node_modules/bn.js/lib/bn.js ***!
  24167. \***************************************************************/
  24168. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  24169. /* module decorator */ module = __webpack_require__.nmd(module);
  24170. (function (module, exports) {
  24171. 'use strict';
  24172. // Utils
  24173. function assert (val, msg) {
  24174. if (!val) throw new Error(msg || 'Assertion failed');
  24175. }
  24176. // Could use `inherits` module, but don't want to move from single file
  24177. // architecture yet.
  24178. function inherits (ctor, superCtor) {
  24179. ctor.super_ = superCtor;
  24180. var TempCtor = function () {};
  24181. TempCtor.prototype = superCtor.prototype;
  24182. ctor.prototype = new TempCtor();
  24183. ctor.prototype.constructor = ctor;
  24184. }
  24185. // BN
  24186. function BN (number, base, endian) {
  24187. if (BN.isBN(number)) {
  24188. return number;
  24189. }
  24190. this.negative = 0;
  24191. this.words = null;
  24192. this.length = 0;
  24193. // Reduction context
  24194. this.red = null;
  24195. if (number !== null) {
  24196. if (base === 'le' || base === 'be') {
  24197. endian = base;
  24198. base = 10;
  24199. }
  24200. this._init(number || 0, base || 10, endian || 'be');
  24201. }
  24202. }
  24203. if (typeof module === 'object') {
  24204. module.exports = BN;
  24205. } else {
  24206. exports.BN = BN;
  24207. }
  24208. BN.BN = BN;
  24209. BN.wordSize = 26;
  24210. var Buffer;
  24211. try {
  24212. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  24213. Buffer = window.Buffer;
  24214. } else {
  24215. Buffer = (__webpack_require__(/*! buffer */ "?5f8c").Buffer);
  24216. }
  24217. } catch (e) {
  24218. }
  24219. BN.isBN = function isBN (num) {
  24220. if (num instanceof BN) {
  24221. return true;
  24222. }
  24223. return num !== null && typeof num === 'object' &&
  24224. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  24225. };
  24226. BN.max = function max (left, right) {
  24227. if (left.cmp(right) > 0) return left;
  24228. return right;
  24229. };
  24230. BN.min = function min (left, right) {
  24231. if (left.cmp(right) < 0) return left;
  24232. return right;
  24233. };
  24234. BN.prototype._init = function init (number, base, endian) {
  24235. if (typeof number === 'number') {
  24236. return this._initNumber(number, base, endian);
  24237. }
  24238. if (typeof number === 'object') {
  24239. return this._initArray(number, base, endian);
  24240. }
  24241. if (base === 'hex') {
  24242. base = 16;
  24243. }
  24244. assert(base === (base | 0) && base >= 2 && base <= 36);
  24245. number = number.toString().replace(/\s+/g, '');
  24246. var start = 0;
  24247. if (number[0] === '-') {
  24248. start++;
  24249. this.negative = 1;
  24250. }
  24251. if (start < number.length) {
  24252. if (base === 16) {
  24253. this._parseHex(number, start, endian);
  24254. } else {
  24255. this._parseBase(number, base, start);
  24256. if (endian === 'le') {
  24257. this._initArray(this.toArray(), base, endian);
  24258. }
  24259. }
  24260. }
  24261. };
  24262. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  24263. if (number < 0) {
  24264. this.negative = 1;
  24265. number = -number;
  24266. }
  24267. if (number < 0x4000000) {
  24268. this.words = [ number & 0x3ffffff ];
  24269. this.length = 1;
  24270. } else if (number < 0x10000000000000) {
  24271. this.words = [
  24272. number & 0x3ffffff,
  24273. (number / 0x4000000) & 0x3ffffff
  24274. ];
  24275. this.length = 2;
  24276. } else {
  24277. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  24278. this.words = [
  24279. number & 0x3ffffff,
  24280. (number / 0x4000000) & 0x3ffffff,
  24281. 1
  24282. ];
  24283. this.length = 3;
  24284. }
  24285. if (endian !== 'le') return;
  24286. // Reverse the bytes
  24287. this._initArray(this.toArray(), base, endian);
  24288. };
  24289. BN.prototype._initArray = function _initArray (number, base, endian) {
  24290. // Perhaps a Uint8Array
  24291. assert(typeof number.length === 'number');
  24292. if (number.length <= 0) {
  24293. this.words = [ 0 ];
  24294. this.length = 1;
  24295. return this;
  24296. }
  24297. this.length = Math.ceil(number.length / 3);
  24298. this.words = new Array(this.length);
  24299. for (var i = 0; i < this.length; i++) {
  24300. this.words[i] = 0;
  24301. }
  24302. var j, w;
  24303. var off = 0;
  24304. if (endian === 'be') {
  24305. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  24306. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  24307. this.words[j] |= (w << off) & 0x3ffffff;
  24308. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  24309. off += 24;
  24310. if (off >= 26) {
  24311. off -= 26;
  24312. j++;
  24313. }
  24314. }
  24315. } else if (endian === 'le') {
  24316. for (i = 0, j = 0; i < number.length; i += 3) {
  24317. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  24318. this.words[j] |= (w << off) & 0x3ffffff;
  24319. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  24320. off += 24;
  24321. if (off >= 26) {
  24322. off -= 26;
  24323. j++;
  24324. }
  24325. }
  24326. }
  24327. return this.strip();
  24328. };
  24329. function parseHex4Bits (string, index) {
  24330. var c = string.charCodeAt(index);
  24331. // 'A' - 'F'
  24332. if (c >= 65 && c <= 70) {
  24333. return c - 55;
  24334. // 'a' - 'f'
  24335. } else if (c >= 97 && c <= 102) {
  24336. return c - 87;
  24337. // '0' - '9'
  24338. } else {
  24339. return (c - 48) & 0xf;
  24340. }
  24341. }
  24342. function parseHexByte (string, lowerBound, index) {
  24343. var r = parseHex4Bits(string, index);
  24344. if (index - 1 >= lowerBound) {
  24345. r |= parseHex4Bits(string, index - 1) << 4;
  24346. }
  24347. return r;
  24348. }
  24349. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  24350. // Create possibly bigger array to ensure that it fits the number
  24351. this.length = Math.ceil((number.length - start) / 6);
  24352. this.words = new Array(this.length);
  24353. for (var i = 0; i < this.length; i++) {
  24354. this.words[i] = 0;
  24355. }
  24356. // 24-bits chunks
  24357. var off = 0;
  24358. var j = 0;
  24359. var w;
  24360. if (endian === 'be') {
  24361. for (i = number.length - 1; i >= start; i -= 2) {
  24362. w = parseHexByte(number, start, i) << off;
  24363. this.words[j] |= w & 0x3ffffff;
  24364. if (off >= 18) {
  24365. off -= 18;
  24366. j += 1;
  24367. this.words[j] |= w >>> 26;
  24368. } else {
  24369. off += 8;
  24370. }
  24371. }
  24372. } else {
  24373. var parseLength = number.length - start;
  24374. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  24375. w = parseHexByte(number, start, i) << off;
  24376. this.words[j] |= w & 0x3ffffff;
  24377. if (off >= 18) {
  24378. off -= 18;
  24379. j += 1;
  24380. this.words[j] |= w >>> 26;
  24381. } else {
  24382. off += 8;
  24383. }
  24384. }
  24385. }
  24386. this.strip();
  24387. };
  24388. function parseBase (str, start, end, mul) {
  24389. var r = 0;
  24390. var len = Math.min(str.length, end);
  24391. for (var i = start; i < len; i++) {
  24392. var c = str.charCodeAt(i) - 48;
  24393. r *= mul;
  24394. // 'a'
  24395. if (c >= 49) {
  24396. r += c - 49 + 0xa;
  24397. // 'A'
  24398. } else if (c >= 17) {
  24399. r += c - 17 + 0xa;
  24400. // '0' - '9'
  24401. } else {
  24402. r += c;
  24403. }
  24404. }
  24405. return r;
  24406. }
  24407. BN.prototype._parseBase = function _parseBase (number, base, start) {
  24408. // Initialize as zero
  24409. this.words = [ 0 ];
  24410. this.length = 1;
  24411. // Find length of limb in base
  24412. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  24413. limbLen++;
  24414. }
  24415. limbLen--;
  24416. limbPow = (limbPow / base) | 0;
  24417. var total = number.length - start;
  24418. var mod = total % limbLen;
  24419. var end = Math.min(total, total - mod) + start;
  24420. var word = 0;
  24421. for (var i = start; i < end; i += limbLen) {
  24422. word = parseBase(number, i, i + limbLen, base);
  24423. this.imuln(limbPow);
  24424. if (this.words[0] + word < 0x4000000) {
  24425. this.words[0] += word;
  24426. } else {
  24427. this._iaddn(word);
  24428. }
  24429. }
  24430. if (mod !== 0) {
  24431. var pow = 1;
  24432. word = parseBase(number, i, number.length, base);
  24433. for (i = 0; i < mod; i++) {
  24434. pow *= base;
  24435. }
  24436. this.imuln(pow);
  24437. if (this.words[0] + word < 0x4000000) {
  24438. this.words[0] += word;
  24439. } else {
  24440. this._iaddn(word);
  24441. }
  24442. }
  24443. this.strip();
  24444. };
  24445. BN.prototype.copy = function copy (dest) {
  24446. dest.words = new Array(this.length);
  24447. for (var i = 0; i < this.length; i++) {
  24448. dest.words[i] = this.words[i];
  24449. }
  24450. dest.length = this.length;
  24451. dest.negative = this.negative;
  24452. dest.red = this.red;
  24453. };
  24454. BN.prototype.clone = function clone () {
  24455. var r = new BN(null);
  24456. this.copy(r);
  24457. return r;
  24458. };
  24459. BN.prototype._expand = function _expand (size) {
  24460. while (this.length < size) {
  24461. this.words[this.length++] = 0;
  24462. }
  24463. return this;
  24464. };
  24465. // Remove leading `0` from `this`
  24466. BN.prototype.strip = function strip () {
  24467. while (this.length > 1 && this.words[this.length - 1] === 0) {
  24468. this.length--;
  24469. }
  24470. return this._normSign();
  24471. };
  24472. BN.prototype._normSign = function _normSign () {
  24473. // -0 = 0
  24474. if (this.length === 1 && this.words[0] === 0) {
  24475. this.negative = 0;
  24476. }
  24477. return this;
  24478. };
  24479. BN.prototype.inspect = function inspect () {
  24480. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  24481. };
  24482. /*
  24483. var zeros = [];
  24484. var groupSizes = [];
  24485. var groupBases = [];
  24486. var s = '';
  24487. var i = -1;
  24488. while (++i < BN.wordSize) {
  24489. zeros[i] = s;
  24490. s += '0';
  24491. }
  24492. groupSizes[0] = 0;
  24493. groupSizes[1] = 0;
  24494. groupBases[0] = 0;
  24495. groupBases[1] = 0;
  24496. var base = 2 - 1;
  24497. while (++base < 36 + 1) {
  24498. var groupSize = 0;
  24499. var groupBase = 1;
  24500. while (groupBase < (1 << BN.wordSize) / base) {
  24501. groupBase *= base;
  24502. groupSize += 1;
  24503. }
  24504. groupSizes[base] = groupSize;
  24505. groupBases[base] = groupBase;
  24506. }
  24507. */
  24508. var zeros = [
  24509. '',
  24510. '0',
  24511. '00',
  24512. '000',
  24513. '0000',
  24514. '00000',
  24515. '000000',
  24516. '0000000',
  24517. '00000000',
  24518. '000000000',
  24519. '0000000000',
  24520. '00000000000',
  24521. '000000000000',
  24522. '0000000000000',
  24523. '00000000000000',
  24524. '000000000000000',
  24525. '0000000000000000',
  24526. '00000000000000000',
  24527. '000000000000000000',
  24528. '0000000000000000000',
  24529. '00000000000000000000',
  24530. '000000000000000000000',
  24531. '0000000000000000000000',
  24532. '00000000000000000000000',
  24533. '000000000000000000000000',
  24534. '0000000000000000000000000'
  24535. ];
  24536. var groupSizes = [
  24537. 0, 0,
  24538. 25, 16, 12, 11, 10, 9, 8,
  24539. 8, 7, 7, 7, 7, 6, 6,
  24540. 6, 6, 6, 6, 6, 5, 5,
  24541. 5, 5, 5, 5, 5, 5, 5,
  24542. 5, 5, 5, 5, 5, 5, 5
  24543. ];
  24544. var groupBases = [
  24545. 0, 0,
  24546. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  24547. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  24548. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  24549. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  24550. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  24551. ];
  24552. BN.prototype.toString = function toString (base, padding) {
  24553. base = base || 10;
  24554. padding = padding | 0 || 1;
  24555. var out;
  24556. if (base === 16 || base === 'hex') {
  24557. out = '';
  24558. var off = 0;
  24559. var carry = 0;
  24560. for (var i = 0; i < this.length; i++) {
  24561. var w = this.words[i];
  24562. var word = (((w << off) | carry) & 0xffffff).toString(16);
  24563. carry = (w >>> (24 - off)) & 0xffffff;
  24564. if (carry !== 0 || i !== this.length - 1) {
  24565. out = zeros[6 - word.length] + word + out;
  24566. } else {
  24567. out = word + out;
  24568. }
  24569. off += 2;
  24570. if (off >= 26) {
  24571. off -= 26;
  24572. i--;
  24573. }
  24574. }
  24575. if (carry !== 0) {
  24576. out = carry.toString(16) + out;
  24577. }
  24578. while (out.length % padding !== 0) {
  24579. out = '0' + out;
  24580. }
  24581. if (this.negative !== 0) {
  24582. out = '-' + out;
  24583. }
  24584. return out;
  24585. }
  24586. if (base === (base | 0) && base >= 2 && base <= 36) {
  24587. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  24588. var groupSize = groupSizes[base];
  24589. // var groupBase = Math.pow(base, groupSize);
  24590. var groupBase = groupBases[base];
  24591. out = '';
  24592. var c = this.clone();
  24593. c.negative = 0;
  24594. while (!c.isZero()) {
  24595. var r = c.modn(groupBase).toString(base);
  24596. c = c.idivn(groupBase);
  24597. if (!c.isZero()) {
  24598. out = zeros[groupSize - r.length] + r + out;
  24599. } else {
  24600. out = r + out;
  24601. }
  24602. }
  24603. if (this.isZero()) {
  24604. out = '0' + out;
  24605. }
  24606. while (out.length % padding !== 0) {
  24607. out = '0' + out;
  24608. }
  24609. if (this.negative !== 0) {
  24610. out = '-' + out;
  24611. }
  24612. return out;
  24613. }
  24614. assert(false, 'Base should be between 2 and 36');
  24615. };
  24616. BN.prototype.toNumber = function toNumber () {
  24617. var ret = this.words[0];
  24618. if (this.length === 2) {
  24619. ret += this.words[1] * 0x4000000;
  24620. } else if (this.length === 3 && this.words[2] === 0x01) {
  24621. // NOTE: at this stage it is known that the top bit is set
  24622. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  24623. } else if (this.length > 2) {
  24624. assert(false, 'Number can only safely store up to 53 bits');
  24625. }
  24626. return (this.negative !== 0) ? -ret : ret;
  24627. };
  24628. BN.prototype.toJSON = function toJSON () {
  24629. return this.toString(16);
  24630. };
  24631. BN.prototype.toBuffer = function toBuffer (endian, length) {
  24632. assert(typeof Buffer !== 'undefined');
  24633. return this.toArrayLike(Buffer, endian, length);
  24634. };
  24635. BN.prototype.toArray = function toArray (endian, length) {
  24636. return this.toArrayLike(Array, endian, length);
  24637. };
  24638. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  24639. var byteLength = this.byteLength();
  24640. var reqLength = length || Math.max(1, byteLength);
  24641. assert(byteLength <= reqLength, 'byte array longer than desired length');
  24642. assert(reqLength > 0, 'Requested array length <= 0');
  24643. this.strip();
  24644. var littleEndian = endian === 'le';
  24645. var res = new ArrayType(reqLength);
  24646. var b, i;
  24647. var q = this.clone();
  24648. if (!littleEndian) {
  24649. // Assume big-endian
  24650. for (i = 0; i < reqLength - byteLength; i++) {
  24651. res[i] = 0;
  24652. }
  24653. for (i = 0; !q.isZero(); i++) {
  24654. b = q.andln(0xff);
  24655. q.iushrn(8);
  24656. res[reqLength - i - 1] = b;
  24657. }
  24658. } else {
  24659. for (i = 0; !q.isZero(); i++) {
  24660. b = q.andln(0xff);
  24661. q.iushrn(8);
  24662. res[i] = b;
  24663. }
  24664. for (; i < reqLength; i++) {
  24665. res[i] = 0;
  24666. }
  24667. }
  24668. return res;
  24669. };
  24670. if (Math.clz32) {
  24671. BN.prototype._countBits = function _countBits (w) {
  24672. return 32 - Math.clz32(w);
  24673. };
  24674. } else {
  24675. BN.prototype._countBits = function _countBits (w) {
  24676. var t = w;
  24677. var r = 0;
  24678. if (t >= 0x1000) {
  24679. r += 13;
  24680. t >>>= 13;
  24681. }
  24682. if (t >= 0x40) {
  24683. r += 7;
  24684. t >>>= 7;
  24685. }
  24686. if (t >= 0x8) {
  24687. r += 4;
  24688. t >>>= 4;
  24689. }
  24690. if (t >= 0x02) {
  24691. r += 2;
  24692. t >>>= 2;
  24693. }
  24694. return r + t;
  24695. };
  24696. }
  24697. BN.prototype._zeroBits = function _zeroBits (w) {
  24698. // Short-cut
  24699. if (w === 0) return 26;
  24700. var t = w;
  24701. var r = 0;
  24702. if ((t & 0x1fff) === 0) {
  24703. r += 13;
  24704. t >>>= 13;
  24705. }
  24706. if ((t & 0x7f) === 0) {
  24707. r += 7;
  24708. t >>>= 7;
  24709. }
  24710. if ((t & 0xf) === 0) {
  24711. r += 4;
  24712. t >>>= 4;
  24713. }
  24714. if ((t & 0x3) === 0) {
  24715. r += 2;
  24716. t >>>= 2;
  24717. }
  24718. if ((t & 0x1) === 0) {
  24719. r++;
  24720. }
  24721. return r;
  24722. };
  24723. // Return number of used bits in a BN
  24724. BN.prototype.bitLength = function bitLength () {
  24725. var w = this.words[this.length - 1];
  24726. var hi = this._countBits(w);
  24727. return (this.length - 1) * 26 + hi;
  24728. };
  24729. function toBitArray (num) {
  24730. var w = new Array(num.bitLength());
  24731. for (var bit = 0; bit < w.length; bit++) {
  24732. var off = (bit / 26) | 0;
  24733. var wbit = bit % 26;
  24734. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  24735. }
  24736. return w;
  24737. }
  24738. // Number of trailing zero bits
  24739. BN.prototype.zeroBits = function zeroBits () {
  24740. if (this.isZero()) return 0;
  24741. var r = 0;
  24742. for (var i = 0; i < this.length; i++) {
  24743. var b = this._zeroBits(this.words[i]);
  24744. r += b;
  24745. if (b !== 26) break;
  24746. }
  24747. return r;
  24748. };
  24749. BN.prototype.byteLength = function byteLength () {
  24750. return Math.ceil(this.bitLength() / 8);
  24751. };
  24752. BN.prototype.toTwos = function toTwos (width) {
  24753. if (this.negative !== 0) {
  24754. return this.abs().inotn(width).iaddn(1);
  24755. }
  24756. return this.clone();
  24757. };
  24758. BN.prototype.fromTwos = function fromTwos (width) {
  24759. if (this.testn(width - 1)) {
  24760. return this.notn(width).iaddn(1).ineg();
  24761. }
  24762. return this.clone();
  24763. };
  24764. BN.prototype.isNeg = function isNeg () {
  24765. return this.negative !== 0;
  24766. };
  24767. // Return negative clone of `this`
  24768. BN.prototype.neg = function neg () {
  24769. return this.clone().ineg();
  24770. };
  24771. BN.prototype.ineg = function ineg () {
  24772. if (!this.isZero()) {
  24773. this.negative ^= 1;
  24774. }
  24775. return this;
  24776. };
  24777. // Or `num` with `this` in-place
  24778. BN.prototype.iuor = function iuor (num) {
  24779. while (this.length < num.length) {
  24780. this.words[this.length++] = 0;
  24781. }
  24782. for (var i = 0; i < num.length; i++) {
  24783. this.words[i] = this.words[i] | num.words[i];
  24784. }
  24785. return this.strip();
  24786. };
  24787. BN.prototype.ior = function ior (num) {
  24788. assert((this.negative | num.negative) === 0);
  24789. return this.iuor(num);
  24790. };
  24791. // Or `num` with `this`
  24792. BN.prototype.or = function or (num) {
  24793. if (this.length > num.length) return this.clone().ior(num);
  24794. return num.clone().ior(this);
  24795. };
  24796. BN.prototype.uor = function uor (num) {
  24797. if (this.length > num.length) return this.clone().iuor(num);
  24798. return num.clone().iuor(this);
  24799. };
  24800. // And `num` with `this` in-place
  24801. BN.prototype.iuand = function iuand (num) {
  24802. // b = min-length(num, this)
  24803. var b;
  24804. if (this.length > num.length) {
  24805. b = num;
  24806. } else {
  24807. b = this;
  24808. }
  24809. for (var i = 0; i < b.length; i++) {
  24810. this.words[i] = this.words[i] & num.words[i];
  24811. }
  24812. this.length = b.length;
  24813. return this.strip();
  24814. };
  24815. BN.prototype.iand = function iand (num) {
  24816. assert((this.negative | num.negative) === 0);
  24817. return this.iuand(num);
  24818. };
  24819. // And `num` with `this`
  24820. BN.prototype.and = function and (num) {
  24821. if (this.length > num.length) return this.clone().iand(num);
  24822. return num.clone().iand(this);
  24823. };
  24824. BN.prototype.uand = function uand (num) {
  24825. if (this.length > num.length) return this.clone().iuand(num);
  24826. return num.clone().iuand(this);
  24827. };
  24828. // Xor `num` with `this` in-place
  24829. BN.prototype.iuxor = function iuxor (num) {
  24830. // a.length > b.length
  24831. var a;
  24832. var b;
  24833. if (this.length > num.length) {
  24834. a = this;
  24835. b = num;
  24836. } else {
  24837. a = num;
  24838. b = this;
  24839. }
  24840. for (var i = 0; i < b.length; i++) {
  24841. this.words[i] = a.words[i] ^ b.words[i];
  24842. }
  24843. if (this !== a) {
  24844. for (; i < a.length; i++) {
  24845. this.words[i] = a.words[i];
  24846. }
  24847. }
  24848. this.length = a.length;
  24849. return this.strip();
  24850. };
  24851. BN.prototype.ixor = function ixor (num) {
  24852. assert((this.negative | num.negative) === 0);
  24853. return this.iuxor(num);
  24854. };
  24855. // Xor `num` with `this`
  24856. BN.prototype.xor = function xor (num) {
  24857. if (this.length > num.length) return this.clone().ixor(num);
  24858. return num.clone().ixor(this);
  24859. };
  24860. BN.prototype.uxor = function uxor (num) {
  24861. if (this.length > num.length) return this.clone().iuxor(num);
  24862. return num.clone().iuxor(this);
  24863. };
  24864. // Not ``this`` with ``width`` bitwidth
  24865. BN.prototype.inotn = function inotn (width) {
  24866. assert(typeof width === 'number' && width >= 0);
  24867. var bytesNeeded = Math.ceil(width / 26) | 0;
  24868. var bitsLeft = width % 26;
  24869. // Extend the buffer with leading zeroes
  24870. this._expand(bytesNeeded);
  24871. if (bitsLeft > 0) {
  24872. bytesNeeded--;
  24873. }
  24874. // Handle complete words
  24875. for (var i = 0; i < bytesNeeded; i++) {
  24876. this.words[i] = ~this.words[i] & 0x3ffffff;
  24877. }
  24878. // Handle the residue
  24879. if (bitsLeft > 0) {
  24880. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  24881. }
  24882. // And remove leading zeroes
  24883. return this.strip();
  24884. };
  24885. BN.prototype.notn = function notn (width) {
  24886. return this.clone().inotn(width);
  24887. };
  24888. // Set `bit` of `this`
  24889. BN.prototype.setn = function setn (bit, val) {
  24890. assert(typeof bit === 'number' && bit >= 0);
  24891. var off = (bit / 26) | 0;
  24892. var wbit = bit % 26;
  24893. this._expand(off + 1);
  24894. if (val) {
  24895. this.words[off] = this.words[off] | (1 << wbit);
  24896. } else {
  24897. this.words[off] = this.words[off] & ~(1 << wbit);
  24898. }
  24899. return this.strip();
  24900. };
  24901. // Add `num` to `this` in-place
  24902. BN.prototype.iadd = function iadd (num) {
  24903. var r;
  24904. // negative + positive
  24905. if (this.negative !== 0 && num.negative === 0) {
  24906. this.negative = 0;
  24907. r = this.isub(num);
  24908. this.negative ^= 1;
  24909. return this._normSign();
  24910. // positive + negative
  24911. } else if (this.negative === 0 && num.negative !== 0) {
  24912. num.negative = 0;
  24913. r = this.isub(num);
  24914. num.negative = 1;
  24915. return r._normSign();
  24916. }
  24917. // a.length > b.length
  24918. var a, b;
  24919. if (this.length > num.length) {
  24920. a = this;
  24921. b = num;
  24922. } else {
  24923. a = num;
  24924. b = this;
  24925. }
  24926. var carry = 0;
  24927. for (var i = 0; i < b.length; i++) {
  24928. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  24929. this.words[i] = r & 0x3ffffff;
  24930. carry = r >>> 26;
  24931. }
  24932. for (; carry !== 0 && i < a.length; i++) {
  24933. r = (a.words[i] | 0) + carry;
  24934. this.words[i] = r & 0x3ffffff;
  24935. carry = r >>> 26;
  24936. }
  24937. this.length = a.length;
  24938. if (carry !== 0) {
  24939. this.words[this.length] = carry;
  24940. this.length++;
  24941. // Copy the rest of the words
  24942. } else if (a !== this) {
  24943. for (; i < a.length; i++) {
  24944. this.words[i] = a.words[i];
  24945. }
  24946. }
  24947. return this;
  24948. };
  24949. // Add `num` to `this`
  24950. BN.prototype.add = function add (num) {
  24951. var res;
  24952. if (num.negative !== 0 && this.negative === 0) {
  24953. num.negative = 0;
  24954. res = this.sub(num);
  24955. num.negative ^= 1;
  24956. return res;
  24957. } else if (num.negative === 0 && this.negative !== 0) {
  24958. this.negative = 0;
  24959. res = num.sub(this);
  24960. this.negative = 1;
  24961. return res;
  24962. }
  24963. if (this.length > num.length) return this.clone().iadd(num);
  24964. return num.clone().iadd(this);
  24965. };
  24966. // Subtract `num` from `this` in-place
  24967. BN.prototype.isub = function isub (num) {
  24968. // this - (-num) = this + num
  24969. if (num.negative !== 0) {
  24970. num.negative = 0;
  24971. var r = this.iadd(num);
  24972. num.negative = 1;
  24973. return r._normSign();
  24974. // -this - num = -(this + num)
  24975. } else if (this.negative !== 0) {
  24976. this.negative = 0;
  24977. this.iadd(num);
  24978. this.negative = 1;
  24979. return this._normSign();
  24980. }
  24981. // At this point both numbers are positive
  24982. var cmp = this.cmp(num);
  24983. // Optimization - zeroify
  24984. if (cmp === 0) {
  24985. this.negative = 0;
  24986. this.length = 1;
  24987. this.words[0] = 0;
  24988. return this;
  24989. }
  24990. // a > b
  24991. var a, b;
  24992. if (cmp > 0) {
  24993. a = this;
  24994. b = num;
  24995. } else {
  24996. a = num;
  24997. b = this;
  24998. }
  24999. var carry = 0;
  25000. for (var i = 0; i < b.length; i++) {
  25001. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  25002. carry = r >> 26;
  25003. this.words[i] = r & 0x3ffffff;
  25004. }
  25005. for (; carry !== 0 && i < a.length; i++) {
  25006. r = (a.words[i] | 0) + carry;
  25007. carry = r >> 26;
  25008. this.words[i] = r & 0x3ffffff;
  25009. }
  25010. // Copy rest of the words
  25011. if (carry === 0 && i < a.length && a !== this) {
  25012. for (; i < a.length; i++) {
  25013. this.words[i] = a.words[i];
  25014. }
  25015. }
  25016. this.length = Math.max(this.length, i);
  25017. if (a !== this) {
  25018. this.negative = 1;
  25019. }
  25020. return this.strip();
  25021. };
  25022. // Subtract `num` from `this`
  25023. BN.prototype.sub = function sub (num) {
  25024. return this.clone().isub(num);
  25025. };
  25026. function smallMulTo (self, num, out) {
  25027. out.negative = num.negative ^ self.negative;
  25028. var len = (self.length + num.length) | 0;
  25029. out.length = len;
  25030. len = (len - 1) | 0;
  25031. // Peel one iteration (compiler can't do it, because of code complexity)
  25032. var a = self.words[0] | 0;
  25033. var b = num.words[0] | 0;
  25034. var r = a * b;
  25035. var lo = r & 0x3ffffff;
  25036. var carry = (r / 0x4000000) | 0;
  25037. out.words[0] = lo;
  25038. for (var k = 1; k < len; k++) {
  25039. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  25040. // note that ncarry could be >= 0x3ffffff
  25041. var ncarry = carry >>> 26;
  25042. var rword = carry & 0x3ffffff;
  25043. var maxJ = Math.min(k, num.length - 1);
  25044. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  25045. var i = (k - j) | 0;
  25046. a = self.words[i] | 0;
  25047. b = num.words[j] | 0;
  25048. r = a * b + rword;
  25049. ncarry += (r / 0x4000000) | 0;
  25050. rword = r & 0x3ffffff;
  25051. }
  25052. out.words[k] = rword | 0;
  25053. carry = ncarry | 0;
  25054. }
  25055. if (carry !== 0) {
  25056. out.words[k] = carry | 0;
  25057. } else {
  25058. out.length--;
  25059. }
  25060. return out.strip();
  25061. }
  25062. // TODO(indutny): it may be reasonable to omit it for users who don't need
  25063. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  25064. // multiplication (like elliptic secp256k1).
  25065. var comb10MulTo = function comb10MulTo (self, num, out) {
  25066. var a = self.words;
  25067. var b = num.words;
  25068. var o = out.words;
  25069. var c = 0;
  25070. var lo;
  25071. var mid;
  25072. var hi;
  25073. var a0 = a[0] | 0;
  25074. var al0 = a0 & 0x1fff;
  25075. var ah0 = a0 >>> 13;
  25076. var a1 = a[1] | 0;
  25077. var al1 = a1 & 0x1fff;
  25078. var ah1 = a1 >>> 13;
  25079. var a2 = a[2] | 0;
  25080. var al2 = a2 & 0x1fff;
  25081. var ah2 = a2 >>> 13;
  25082. var a3 = a[3] | 0;
  25083. var al3 = a3 & 0x1fff;
  25084. var ah3 = a3 >>> 13;
  25085. var a4 = a[4] | 0;
  25086. var al4 = a4 & 0x1fff;
  25087. var ah4 = a4 >>> 13;
  25088. var a5 = a[5] | 0;
  25089. var al5 = a5 & 0x1fff;
  25090. var ah5 = a5 >>> 13;
  25091. var a6 = a[6] | 0;
  25092. var al6 = a6 & 0x1fff;
  25093. var ah6 = a6 >>> 13;
  25094. var a7 = a[7] | 0;
  25095. var al7 = a7 & 0x1fff;
  25096. var ah7 = a7 >>> 13;
  25097. var a8 = a[8] | 0;
  25098. var al8 = a8 & 0x1fff;
  25099. var ah8 = a8 >>> 13;
  25100. var a9 = a[9] | 0;
  25101. var al9 = a9 & 0x1fff;
  25102. var ah9 = a9 >>> 13;
  25103. var b0 = b[0] | 0;
  25104. var bl0 = b0 & 0x1fff;
  25105. var bh0 = b0 >>> 13;
  25106. var b1 = b[1] | 0;
  25107. var bl1 = b1 & 0x1fff;
  25108. var bh1 = b1 >>> 13;
  25109. var b2 = b[2] | 0;
  25110. var bl2 = b2 & 0x1fff;
  25111. var bh2 = b2 >>> 13;
  25112. var b3 = b[3] | 0;
  25113. var bl3 = b3 & 0x1fff;
  25114. var bh3 = b3 >>> 13;
  25115. var b4 = b[4] | 0;
  25116. var bl4 = b4 & 0x1fff;
  25117. var bh4 = b4 >>> 13;
  25118. var b5 = b[5] | 0;
  25119. var bl5 = b5 & 0x1fff;
  25120. var bh5 = b5 >>> 13;
  25121. var b6 = b[6] | 0;
  25122. var bl6 = b6 & 0x1fff;
  25123. var bh6 = b6 >>> 13;
  25124. var b7 = b[7] | 0;
  25125. var bl7 = b7 & 0x1fff;
  25126. var bh7 = b7 >>> 13;
  25127. var b8 = b[8] | 0;
  25128. var bl8 = b8 & 0x1fff;
  25129. var bh8 = b8 >>> 13;
  25130. var b9 = b[9] | 0;
  25131. var bl9 = b9 & 0x1fff;
  25132. var bh9 = b9 >>> 13;
  25133. out.negative = self.negative ^ num.negative;
  25134. out.length = 19;
  25135. /* k = 0 */
  25136. lo = Math.imul(al0, bl0);
  25137. mid = Math.imul(al0, bh0);
  25138. mid = (mid + Math.imul(ah0, bl0)) | 0;
  25139. hi = Math.imul(ah0, bh0);
  25140. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25141. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  25142. w0 &= 0x3ffffff;
  25143. /* k = 1 */
  25144. lo = Math.imul(al1, bl0);
  25145. mid = Math.imul(al1, bh0);
  25146. mid = (mid + Math.imul(ah1, bl0)) | 0;
  25147. hi = Math.imul(ah1, bh0);
  25148. lo = (lo + Math.imul(al0, bl1)) | 0;
  25149. mid = (mid + Math.imul(al0, bh1)) | 0;
  25150. mid = (mid + Math.imul(ah0, bl1)) | 0;
  25151. hi = (hi + Math.imul(ah0, bh1)) | 0;
  25152. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25153. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  25154. w1 &= 0x3ffffff;
  25155. /* k = 2 */
  25156. lo = Math.imul(al2, bl0);
  25157. mid = Math.imul(al2, bh0);
  25158. mid = (mid + Math.imul(ah2, bl0)) | 0;
  25159. hi = Math.imul(ah2, bh0);
  25160. lo = (lo + Math.imul(al1, bl1)) | 0;
  25161. mid = (mid + Math.imul(al1, bh1)) | 0;
  25162. mid = (mid + Math.imul(ah1, bl1)) | 0;
  25163. hi = (hi + Math.imul(ah1, bh1)) | 0;
  25164. lo = (lo + Math.imul(al0, bl2)) | 0;
  25165. mid = (mid + Math.imul(al0, bh2)) | 0;
  25166. mid = (mid + Math.imul(ah0, bl2)) | 0;
  25167. hi = (hi + Math.imul(ah0, bh2)) | 0;
  25168. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25169. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  25170. w2 &= 0x3ffffff;
  25171. /* k = 3 */
  25172. lo = Math.imul(al3, bl0);
  25173. mid = Math.imul(al3, bh0);
  25174. mid = (mid + Math.imul(ah3, bl0)) | 0;
  25175. hi = Math.imul(ah3, bh0);
  25176. lo = (lo + Math.imul(al2, bl1)) | 0;
  25177. mid = (mid + Math.imul(al2, bh1)) | 0;
  25178. mid = (mid + Math.imul(ah2, bl1)) | 0;
  25179. hi = (hi + Math.imul(ah2, bh1)) | 0;
  25180. lo = (lo + Math.imul(al1, bl2)) | 0;
  25181. mid = (mid + Math.imul(al1, bh2)) | 0;
  25182. mid = (mid + Math.imul(ah1, bl2)) | 0;
  25183. hi = (hi + Math.imul(ah1, bh2)) | 0;
  25184. lo = (lo + Math.imul(al0, bl3)) | 0;
  25185. mid = (mid + Math.imul(al0, bh3)) | 0;
  25186. mid = (mid + Math.imul(ah0, bl3)) | 0;
  25187. hi = (hi + Math.imul(ah0, bh3)) | 0;
  25188. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25189. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  25190. w3 &= 0x3ffffff;
  25191. /* k = 4 */
  25192. lo = Math.imul(al4, bl0);
  25193. mid = Math.imul(al4, bh0);
  25194. mid = (mid + Math.imul(ah4, bl0)) | 0;
  25195. hi = Math.imul(ah4, bh0);
  25196. lo = (lo + Math.imul(al3, bl1)) | 0;
  25197. mid = (mid + Math.imul(al3, bh1)) | 0;
  25198. mid = (mid + Math.imul(ah3, bl1)) | 0;
  25199. hi = (hi + Math.imul(ah3, bh1)) | 0;
  25200. lo = (lo + Math.imul(al2, bl2)) | 0;
  25201. mid = (mid + Math.imul(al2, bh2)) | 0;
  25202. mid = (mid + Math.imul(ah2, bl2)) | 0;
  25203. hi = (hi + Math.imul(ah2, bh2)) | 0;
  25204. lo = (lo + Math.imul(al1, bl3)) | 0;
  25205. mid = (mid + Math.imul(al1, bh3)) | 0;
  25206. mid = (mid + Math.imul(ah1, bl3)) | 0;
  25207. hi = (hi + Math.imul(ah1, bh3)) | 0;
  25208. lo = (lo + Math.imul(al0, bl4)) | 0;
  25209. mid = (mid + Math.imul(al0, bh4)) | 0;
  25210. mid = (mid + Math.imul(ah0, bl4)) | 0;
  25211. hi = (hi + Math.imul(ah0, bh4)) | 0;
  25212. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25213. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  25214. w4 &= 0x3ffffff;
  25215. /* k = 5 */
  25216. lo = Math.imul(al5, bl0);
  25217. mid = Math.imul(al5, bh0);
  25218. mid = (mid + Math.imul(ah5, bl0)) | 0;
  25219. hi = Math.imul(ah5, bh0);
  25220. lo = (lo + Math.imul(al4, bl1)) | 0;
  25221. mid = (mid + Math.imul(al4, bh1)) | 0;
  25222. mid = (mid + Math.imul(ah4, bl1)) | 0;
  25223. hi = (hi + Math.imul(ah4, bh1)) | 0;
  25224. lo = (lo + Math.imul(al3, bl2)) | 0;
  25225. mid = (mid + Math.imul(al3, bh2)) | 0;
  25226. mid = (mid + Math.imul(ah3, bl2)) | 0;
  25227. hi = (hi + Math.imul(ah3, bh2)) | 0;
  25228. lo = (lo + Math.imul(al2, bl3)) | 0;
  25229. mid = (mid + Math.imul(al2, bh3)) | 0;
  25230. mid = (mid + Math.imul(ah2, bl3)) | 0;
  25231. hi = (hi + Math.imul(ah2, bh3)) | 0;
  25232. lo = (lo + Math.imul(al1, bl4)) | 0;
  25233. mid = (mid + Math.imul(al1, bh4)) | 0;
  25234. mid = (mid + Math.imul(ah1, bl4)) | 0;
  25235. hi = (hi + Math.imul(ah1, bh4)) | 0;
  25236. lo = (lo + Math.imul(al0, bl5)) | 0;
  25237. mid = (mid + Math.imul(al0, bh5)) | 0;
  25238. mid = (mid + Math.imul(ah0, bl5)) | 0;
  25239. hi = (hi + Math.imul(ah0, bh5)) | 0;
  25240. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25241. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  25242. w5 &= 0x3ffffff;
  25243. /* k = 6 */
  25244. lo = Math.imul(al6, bl0);
  25245. mid = Math.imul(al6, bh0);
  25246. mid = (mid + Math.imul(ah6, bl0)) | 0;
  25247. hi = Math.imul(ah6, bh0);
  25248. lo = (lo + Math.imul(al5, bl1)) | 0;
  25249. mid = (mid + Math.imul(al5, bh1)) | 0;
  25250. mid = (mid + Math.imul(ah5, bl1)) | 0;
  25251. hi = (hi + Math.imul(ah5, bh1)) | 0;
  25252. lo = (lo + Math.imul(al4, bl2)) | 0;
  25253. mid = (mid + Math.imul(al4, bh2)) | 0;
  25254. mid = (mid + Math.imul(ah4, bl2)) | 0;
  25255. hi = (hi + Math.imul(ah4, bh2)) | 0;
  25256. lo = (lo + Math.imul(al3, bl3)) | 0;
  25257. mid = (mid + Math.imul(al3, bh3)) | 0;
  25258. mid = (mid + Math.imul(ah3, bl3)) | 0;
  25259. hi = (hi + Math.imul(ah3, bh3)) | 0;
  25260. lo = (lo + Math.imul(al2, bl4)) | 0;
  25261. mid = (mid + Math.imul(al2, bh4)) | 0;
  25262. mid = (mid + Math.imul(ah2, bl4)) | 0;
  25263. hi = (hi + Math.imul(ah2, bh4)) | 0;
  25264. lo = (lo + Math.imul(al1, bl5)) | 0;
  25265. mid = (mid + Math.imul(al1, bh5)) | 0;
  25266. mid = (mid + Math.imul(ah1, bl5)) | 0;
  25267. hi = (hi + Math.imul(ah1, bh5)) | 0;
  25268. lo = (lo + Math.imul(al0, bl6)) | 0;
  25269. mid = (mid + Math.imul(al0, bh6)) | 0;
  25270. mid = (mid + Math.imul(ah0, bl6)) | 0;
  25271. hi = (hi + Math.imul(ah0, bh6)) | 0;
  25272. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25273. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  25274. w6 &= 0x3ffffff;
  25275. /* k = 7 */
  25276. lo = Math.imul(al7, bl0);
  25277. mid = Math.imul(al7, bh0);
  25278. mid = (mid + Math.imul(ah7, bl0)) | 0;
  25279. hi = Math.imul(ah7, bh0);
  25280. lo = (lo + Math.imul(al6, bl1)) | 0;
  25281. mid = (mid + Math.imul(al6, bh1)) | 0;
  25282. mid = (mid + Math.imul(ah6, bl1)) | 0;
  25283. hi = (hi + Math.imul(ah6, bh1)) | 0;
  25284. lo = (lo + Math.imul(al5, bl2)) | 0;
  25285. mid = (mid + Math.imul(al5, bh2)) | 0;
  25286. mid = (mid + Math.imul(ah5, bl2)) | 0;
  25287. hi = (hi + Math.imul(ah5, bh2)) | 0;
  25288. lo = (lo + Math.imul(al4, bl3)) | 0;
  25289. mid = (mid + Math.imul(al4, bh3)) | 0;
  25290. mid = (mid + Math.imul(ah4, bl3)) | 0;
  25291. hi = (hi + Math.imul(ah4, bh3)) | 0;
  25292. lo = (lo + Math.imul(al3, bl4)) | 0;
  25293. mid = (mid + Math.imul(al3, bh4)) | 0;
  25294. mid = (mid + Math.imul(ah3, bl4)) | 0;
  25295. hi = (hi + Math.imul(ah3, bh4)) | 0;
  25296. lo = (lo + Math.imul(al2, bl5)) | 0;
  25297. mid = (mid + Math.imul(al2, bh5)) | 0;
  25298. mid = (mid + Math.imul(ah2, bl5)) | 0;
  25299. hi = (hi + Math.imul(ah2, bh5)) | 0;
  25300. lo = (lo + Math.imul(al1, bl6)) | 0;
  25301. mid = (mid + Math.imul(al1, bh6)) | 0;
  25302. mid = (mid + Math.imul(ah1, bl6)) | 0;
  25303. hi = (hi + Math.imul(ah1, bh6)) | 0;
  25304. lo = (lo + Math.imul(al0, bl7)) | 0;
  25305. mid = (mid + Math.imul(al0, bh7)) | 0;
  25306. mid = (mid + Math.imul(ah0, bl7)) | 0;
  25307. hi = (hi + Math.imul(ah0, bh7)) | 0;
  25308. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25309. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  25310. w7 &= 0x3ffffff;
  25311. /* k = 8 */
  25312. lo = Math.imul(al8, bl0);
  25313. mid = Math.imul(al8, bh0);
  25314. mid = (mid + Math.imul(ah8, bl0)) | 0;
  25315. hi = Math.imul(ah8, bh0);
  25316. lo = (lo + Math.imul(al7, bl1)) | 0;
  25317. mid = (mid + Math.imul(al7, bh1)) | 0;
  25318. mid = (mid + Math.imul(ah7, bl1)) | 0;
  25319. hi = (hi + Math.imul(ah7, bh1)) | 0;
  25320. lo = (lo + Math.imul(al6, bl2)) | 0;
  25321. mid = (mid + Math.imul(al6, bh2)) | 0;
  25322. mid = (mid + Math.imul(ah6, bl2)) | 0;
  25323. hi = (hi + Math.imul(ah6, bh2)) | 0;
  25324. lo = (lo + Math.imul(al5, bl3)) | 0;
  25325. mid = (mid + Math.imul(al5, bh3)) | 0;
  25326. mid = (mid + Math.imul(ah5, bl3)) | 0;
  25327. hi = (hi + Math.imul(ah5, bh3)) | 0;
  25328. lo = (lo + Math.imul(al4, bl4)) | 0;
  25329. mid = (mid + Math.imul(al4, bh4)) | 0;
  25330. mid = (mid + Math.imul(ah4, bl4)) | 0;
  25331. hi = (hi + Math.imul(ah4, bh4)) | 0;
  25332. lo = (lo + Math.imul(al3, bl5)) | 0;
  25333. mid = (mid + Math.imul(al3, bh5)) | 0;
  25334. mid = (mid + Math.imul(ah3, bl5)) | 0;
  25335. hi = (hi + Math.imul(ah3, bh5)) | 0;
  25336. lo = (lo + Math.imul(al2, bl6)) | 0;
  25337. mid = (mid + Math.imul(al2, bh6)) | 0;
  25338. mid = (mid + Math.imul(ah2, bl6)) | 0;
  25339. hi = (hi + Math.imul(ah2, bh6)) | 0;
  25340. lo = (lo + Math.imul(al1, bl7)) | 0;
  25341. mid = (mid + Math.imul(al1, bh7)) | 0;
  25342. mid = (mid + Math.imul(ah1, bl7)) | 0;
  25343. hi = (hi + Math.imul(ah1, bh7)) | 0;
  25344. lo = (lo + Math.imul(al0, bl8)) | 0;
  25345. mid = (mid + Math.imul(al0, bh8)) | 0;
  25346. mid = (mid + Math.imul(ah0, bl8)) | 0;
  25347. hi = (hi + Math.imul(ah0, bh8)) | 0;
  25348. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25349. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  25350. w8 &= 0x3ffffff;
  25351. /* k = 9 */
  25352. lo = Math.imul(al9, bl0);
  25353. mid = Math.imul(al9, bh0);
  25354. mid = (mid + Math.imul(ah9, bl0)) | 0;
  25355. hi = Math.imul(ah9, bh0);
  25356. lo = (lo + Math.imul(al8, bl1)) | 0;
  25357. mid = (mid + Math.imul(al8, bh1)) | 0;
  25358. mid = (mid + Math.imul(ah8, bl1)) | 0;
  25359. hi = (hi + Math.imul(ah8, bh1)) | 0;
  25360. lo = (lo + Math.imul(al7, bl2)) | 0;
  25361. mid = (mid + Math.imul(al7, bh2)) | 0;
  25362. mid = (mid + Math.imul(ah7, bl2)) | 0;
  25363. hi = (hi + Math.imul(ah7, bh2)) | 0;
  25364. lo = (lo + Math.imul(al6, bl3)) | 0;
  25365. mid = (mid + Math.imul(al6, bh3)) | 0;
  25366. mid = (mid + Math.imul(ah6, bl3)) | 0;
  25367. hi = (hi + Math.imul(ah6, bh3)) | 0;
  25368. lo = (lo + Math.imul(al5, bl4)) | 0;
  25369. mid = (mid + Math.imul(al5, bh4)) | 0;
  25370. mid = (mid + Math.imul(ah5, bl4)) | 0;
  25371. hi = (hi + Math.imul(ah5, bh4)) | 0;
  25372. lo = (lo + Math.imul(al4, bl5)) | 0;
  25373. mid = (mid + Math.imul(al4, bh5)) | 0;
  25374. mid = (mid + Math.imul(ah4, bl5)) | 0;
  25375. hi = (hi + Math.imul(ah4, bh5)) | 0;
  25376. lo = (lo + Math.imul(al3, bl6)) | 0;
  25377. mid = (mid + Math.imul(al3, bh6)) | 0;
  25378. mid = (mid + Math.imul(ah3, bl6)) | 0;
  25379. hi = (hi + Math.imul(ah3, bh6)) | 0;
  25380. lo = (lo + Math.imul(al2, bl7)) | 0;
  25381. mid = (mid + Math.imul(al2, bh7)) | 0;
  25382. mid = (mid + Math.imul(ah2, bl7)) | 0;
  25383. hi = (hi + Math.imul(ah2, bh7)) | 0;
  25384. lo = (lo + Math.imul(al1, bl8)) | 0;
  25385. mid = (mid + Math.imul(al1, bh8)) | 0;
  25386. mid = (mid + Math.imul(ah1, bl8)) | 0;
  25387. hi = (hi + Math.imul(ah1, bh8)) | 0;
  25388. lo = (lo + Math.imul(al0, bl9)) | 0;
  25389. mid = (mid + Math.imul(al0, bh9)) | 0;
  25390. mid = (mid + Math.imul(ah0, bl9)) | 0;
  25391. hi = (hi + Math.imul(ah0, bh9)) | 0;
  25392. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25393. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  25394. w9 &= 0x3ffffff;
  25395. /* k = 10 */
  25396. lo = Math.imul(al9, bl1);
  25397. mid = Math.imul(al9, bh1);
  25398. mid = (mid + Math.imul(ah9, bl1)) | 0;
  25399. hi = Math.imul(ah9, bh1);
  25400. lo = (lo + Math.imul(al8, bl2)) | 0;
  25401. mid = (mid + Math.imul(al8, bh2)) | 0;
  25402. mid = (mid + Math.imul(ah8, bl2)) | 0;
  25403. hi = (hi + Math.imul(ah8, bh2)) | 0;
  25404. lo = (lo + Math.imul(al7, bl3)) | 0;
  25405. mid = (mid + Math.imul(al7, bh3)) | 0;
  25406. mid = (mid + Math.imul(ah7, bl3)) | 0;
  25407. hi = (hi + Math.imul(ah7, bh3)) | 0;
  25408. lo = (lo + Math.imul(al6, bl4)) | 0;
  25409. mid = (mid + Math.imul(al6, bh4)) | 0;
  25410. mid = (mid + Math.imul(ah6, bl4)) | 0;
  25411. hi = (hi + Math.imul(ah6, bh4)) | 0;
  25412. lo = (lo + Math.imul(al5, bl5)) | 0;
  25413. mid = (mid + Math.imul(al5, bh5)) | 0;
  25414. mid = (mid + Math.imul(ah5, bl5)) | 0;
  25415. hi = (hi + Math.imul(ah5, bh5)) | 0;
  25416. lo = (lo + Math.imul(al4, bl6)) | 0;
  25417. mid = (mid + Math.imul(al4, bh6)) | 0;
  25418. mid = (mid + Math.imul(ah4, bl6)) | 0;
  25419. hi = (hi + Math.imul(ah4, bh6)) | 0;
  25420. lo = (lo + Math.imul(al3, bl7)) | 0;
  25421. mid = (mid + Math.imul(al3, bh7)) | 0;
  25422. mid = (mid + Math.imul(ah3, bl7)) | 0;
  25423. hi = (hi + Math.imul(ah3, bh7)) | 0;
  25424. lo = (lo + Math.imul(al2, bl8)) | 0;
  25425. mid = (mid + Math.imul(al2, bh8)) | 0;
  25426. mid = (mid + Math.imul(ah2, bl8)) | 0;
  25427. hi = (hi + Math.imul(ah2, bh8)) | 0;
  25428. lo = (lo + Math.imul(al1, bl9)) | 0;
  25429. mid = (mid + Math.imul(al1, bh9)) | 0;
  25430. mid = (mid + Math.imul(ah1, bl9)) | 0;
  25431. hi = (hi + Math.imul(ah1, bh9)) | 0;
  25432. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25433. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  25434. w10 &= 0x3ffffff;
  25435. /* k = 11 */
  25436. lo = Math.imul(al9, bl2);
  25437. mid = Math.imul(al9, bh2);
  25438. mid = (mid + Math.imul(ah9, bl2)) | 0;
  25439. hi = Math.imul(ah9, bh2);
  25440. lo = (lo + Math.imul(al8, bl3)) | 0;
  25441. mid = (mid + Math.imul(al8, bh3)) | 0;
  25442. mid = (mid + Math.imul(ah8, bl3)) | 0;
  25443. hi = (hi + Math.imul(ah8, bh3)) | 0;
  25444. lo = (lo + Math.imul(al7, bl4)) | 0;
  25445. mid = (mid + Math.imul(al7, bh4)) | 0;
  25446. mid = (mid + Math.imul(ah7, bl4)) | 0;
  25447. hi = (hi + Math.imul(ah7, bh4)) | 0;
  25448. lo = (lo + Math.imul(al6, bl5)) | 0;
  25449. mid = (mid + Math.imul(al6, bh5)) | 0;
  25450. mid = (mid + Math.imul(ah6, bl5)) | 0;
  25451. hi = (hi + Math.imul(ah6, bh5)) | 0;
  25452. lo = (lo + Math.imul(al5, bl6)) | 0;
  25453. mid = (mid + Math.imul(al5, bh6)) | 0;
  25454. mid = (mid + Math.imul(ah5, bl6)) | 0;
  25455. hi = (hi + Math.imul(ah5, bh6)) | 0;
  25456. lo = (lo + Math.imul(al4, bl7)) | 0;
  25457. mid = (mid + Math.imul(al4, bh7)) | 0;
  25458. mid = (mid + Math.imul(ah4, bl7)) | 0;
  25459. hi = (hi + Math.imul(ah4, bh7)) | 0;
  25460. lo = (lo + Math.imul(al3, bl8)) | 0;
  25461. mid = (mid + Math.imul(al3, bh8)) | 0;
  25462. mid = (mid + Math.imul(ah3, bl8)) | 0;
  25463. hi = (hi + Math.imul(ah3, bh8)) | 0;
  25464. lo = (lo + Math.imul(al2, bl9)) | 0;
  25465. mid = (mid + Math.imul(al2, bh9)) | 0;
  25466. mid = (mid + Math.imul(ah2, bl9)) | 0;
  25467. hi = (hi + Math.imul(ah2, bh9)) | 0;
  25468. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25469. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  25470. w11 &= 0x3ffffff;
  25471. /* k = 12 */
  25472. lo = Math.imul(al9, bl3);
  25473. mid = Math.imul(al9, bh3);
  25474. mid = (mid + Math.imul(ah9, bl3)) | 0;
  25475. hi = Math.imul(ah9, bh3);
  25476. lo = (lo + Math.imul(al8, bl4)) | 0;
  25477. mid = (mid + Math.imul(al8, bh4)) | 0;
  25478. mid = (mid + Math.imul(ah8, bl4)) | 0;
  25479. hi = (hi + Math.imul(ah8, bh4)) | 0;
  25480. lo = (lo + Math.imul(al7, bl5)) | 0;
  25481. mid = (mid + Math.imul(al7, bh5)) | 0;
  25482. mid = (mid + Math.imul(ah7, bl5)) | 0;
  25483. hi = (hi + Math.imul(ah7, bh5)) | 0;
  25484. lo = (lo + Math.imul(al6, bl6)) | 0;
  25485. mid = (mid + Math.imul(al6, bh6)) | 0;
  25486. mid = (mid + Math.imul(ah6, bl6)) | 0;
  25487. hi = (hi + Math.imul(ah6, bh6)) | 0;
  25488. lo = (lo + Math.imul(al5, bl7)) | 0;
  25489. mid = (mid + Math.imul(al5, bh7)) | 0;
  25490. mid = (mid + Math.imul(ah5, bl7)) | 0;
  25491. hi = (hi + Math.imul(ah5, bh7)) | 0;
  25492. lo = (lo + Math.imul(al4, bl8)) | 0;
  25493. mid = (mid + Math.imul(al4, bh8)) | 0;
  25494. mid = (mid + Math.imul(ah4, bl8)) | 0;
  25495. hi = (hi + Math.imul(ah4, bh8)) | 0;
  25496. lo = (lo + Math.imul(al3, bl9)) | 0;
  25497. mid = (mid + Math.imul(al3, bh9)) | 0;
  25498. mid = (mid + Math.imul(ah3, bl9)) | 0;
  25499. hi = (hi + Math.imul(ah3, bh9)) | 0;
  25500. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25501. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  25502. w12 &= 0x3ffffff;
  25503. /* k = 13 */
  25504. lo = Math.imul(al9, bl4);
  25505. mid = Math.imul(al9, bh4);
  25506. mid = (mid + Math.imul(ah9, bl4)) | 0;
  25507. hi = Math.imul(ah9, bh4);
  25508. lo = (lo + Math.imul(al8, bl5)) | 0;
  25509. mid = (mid + Math.imul(al8, bh5)) | 0;
  25510. mid = (mid + Math.imul(ah8, bl5)) | 0;
  25511. hi = (hi + Math.imul(ah8, bh5)) | 0;
  25512. lo = (lo + Math.imul(al7, bl6)) | 0;
  25513. mid = (mid + Math.imul(al7, bh6)) | 0;
  25514. mid = (mid + Math.imul(ah7, bl6)) | 0;
  25515. hi = (hi + Math.imul(ah7, bh6)) | 0;
  25516. lo = (lo + Math.imul(al6, bl7)) | 0;
  25517. mid = (mid + Math.imul(al6, bh7)) | 0;
  25518. mid = (mid + Math.imul(ah6, bl7)) | 0;
  25519. hi = (hi + Math.imul(ah6, bh7)) | 0;
  25520. lo = (lo + Math.imul(al5, bl8)) | 0;
  25521. mid = (mid + Math.imul(al5, bh8)) | 0;
  25522. mid = (mid + Math.imul(ah5, bl8)) | 0;
  25523. hi = (hi + Math.imul(ah5, bh8)) | 0;
  25524. lo = (lo + Math.imul(al4, bl9)) | 0;
  25525. mid = (mid + Math.imul(al4, bh9)) | 0;
  25526. mid = (mid + Math.imul(ah4, bl9)) | 0;
  25527. hi = (hi + Math.imul(ah4, bh9)) | 0;
  25528. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25529. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  25530. w13 &= 0x3ffffff;
  25531. /* k = 14 */
  25532. lo = Math.imul(al9, bl5);
  25533. mid = Math.imul(al9, bh5);
  25534. mid = (mid + Math.imul(ah9, bl5)) | 0;
  25535. hi = Math.imul(ah9, bh5);
  25536. lo = (lo + Math.imul(al8, bl6)) | 0;
  25537. mid = (mid + Math.imul(al8, bh6)) | 0;
  25538. mid = (mid + Math.imul(ah8, bl6)) | 0;
  25539. hi = (hi + Math.imul(ah8, bh6)) | 0;
  25540. lo = (lo + Math.imul(al7, bl7)) | 0;
  25541. mid = (mid + Math.imul(al7, bh7)) | 0;
  25542. mid = (mid + Math.imul(ah7, bl7)) | 0;
  25543. hi = (hi + Math.imul(ah7, bh7)) | 0;
  25544. lo = (lo + Math.imul(al6, bl8)) | 0;
  25545. mid = (mid + Math.imul(al6, bh8)) | 0;
  25546. mid = (mid + Math.imul(ah6, bl8)) | 0;
  25547. hi = (hi + Math.imul(ah6, bh8)) | 0;
  25548. lo = (lo + Math.imul(al5, bl9)) | 0;
  25549. mid = (mid + Math.imul(al5, bh9)) | 0;
  25550. mid = (mid + Math.imul(ah5, bl9)) | 0;
  25551. hi = (hi + Math.imul(ah5, bh9)) | 0;
  25552. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25553. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  25554. w14 &= 0x3ffffff;
  25555. /* k = 15 */
  25556. lo = Math.imul(al9, bl6);
  25557. mid = Math.imul(al9, bh6);
  25558. mid = (mid + Math.imul(ah9, bl6)) | 0;
  25559. hi = Math.imul(ah9, bh6);
  25560. lo = (lo + Math.imul(al8, bl7)) | 0;
  25561. mid = (mid + Math.imul(al8, bh7)) | 0;
  25562. mid = (mid + Math.imul(ah8, bl7)) | 0;
  25563. hi = (hi + Math.imul(ah8, bh7)) | 0;
  25564. lo = (lo + Math.imul(al7, bl8)) | 0;
  25565. mid = (mid + Math.imul(al7, bh8)) | 0;
  25566. mid = (mid + Math.imul(ah7, bl8)) | 0;
  25567. hi = (hi + Math.imul(ah7, bh8)) | 0;
  25568. lo = (lo + Math.imul(al6, bl9)) | 0;
  25569. mid = (mid + Math.imul(al6, bh9)) | 0;
  25570. mid = (mid + Math.imul(ah6, bl9)) | 0;
  25571. hi = (hi + Math.imul(ah6, bh9)) | 0;
  25572. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25573. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  25574. w15 &= 0x3ffffff;
  25575. /* k = 16 */
  25576. lo = Math.imul(al9, bl7);
  25577. mid = Math.imul(al9, bh7);
  25578. mid = (mid + Math.imul(ah9, bl7)) | 0;
  25579. hi = Math.imul(ah9, bh7);
  25580. lo = (lo + Math.imul(al8, bl8)) | 0;
  25581. mid = (mid + Math.imul(al8, bh8)) | 0;
  25582. mid = (mid + Math.imul(ah8, bl8)) | 0;
  25583. hi = (hi + Math.imul(ah8, bh8)) | 0;
  25584. lo = (lo + Math.imul(al7, bl9)) | 0;
  25585. mid = (mid + Math.imul(al7, bh9)) | 0;
  25586. mid = (mid + Math.imul(ah7, bl9)) | 0;
  25587. hi = (hi + Math.imul(ah7, bh9)) | 0;
  25588. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25589. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  25590. w16 &= 0x3ffffff;
  25591. /* k = 17 */
  25592. lo = Math.imul(al9, bl8);
  25593. mid = Math.imul(al9, bh8);
  25594. mid = (mid + Math.imul(ah9, bl8)) | 0;
  25595. hi = Math.imul(ah9, bh8);
  25596. lo = (lo + Math.imul(al8, bl9)) | 0;
  25597. mid = (mid + Math.imul(al8, bh9)) | 0;
  25598. mid = (mid + Math.imul(ah8, bl9)) | 0;
  25599. hi = (hi + Math.imul(ah8, bh9)) | 0;
  25600. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25601. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  25602. w17 &= 0x3ffffff;
  25603. /* k = 18 */
  25604. lo = Math.imul(al9, bl9);
  25605. mid = Math.imul(al9, bh9);
  25606. mid = (mid + Math.imul(ah9, bl9)) | 0;
  25607. hi = Math.imul(ah9, bh9);
  25608. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  25609. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  25610. w18 &= 0x3ffffff;
  25611. o[0] = w0;
  25612. o[1] = w1;
  25613. o[2] = w2;
  25614. o[3] = w3;
  25615. o[4] = w4;
  25616. o[5] = w5;
  25617. o[6] = w6;
  25618. o[7] = w7;
  25619. o[8] = w8;
  25620. o[9] = w9;
  25621. o[10] = w10;
  25622. o[11] = w11;
  25623. o[12] = w12;
  25624. o[13] = w13;
  25625. o[14] = w14;
  25626. o[15] = w15;
  25627. o[16] = w16;
  25628. o[17] = w17;
  25629. o[18] = w18;
  25630. if (c !== 0) {
  25631. o[19] = c;
  25632. out.length++;
  25633. }
  25634. return out;
  25635. };
  25636. // Polyfill comb
  25637. if (!Math.imul) {
  25638. comb10MulTo = smallMulTo;
  25639. }
  25640. function bigMulTo (self, num, out) {
  25641. out.negative = num.negative ^ self.negative;
  25642. out.length = self.length + num.length;
  25643. var carry = 0;
  25644. var hncarry = 0;
  25645. for (var k = 0; k < out.length - 1; k++) {
  25646. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  25647. // note that ncarry could be >= 0x3ffffff
  25648. var ncarry = hncarry;
  25649. hncarry = 0;
  25650. var rword = carry & 0x3ffffff;
  25651. var maxJ = Math.min(k, num.length - 1);
  25652. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  25653. var i = k - j;
  25654. var a = self.words[i] | 0;
  25655. var b = num.words[j] | 0;
  25656. var r = a * b;
  25657. var lo = r & 0x3ffffff;
  25658. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  25659. lo = (lo + rword) | 0;
  25660. rword = lo & 0x3ffffff;
  25661. ncarry = (ncarry + (lo >>> 26)) | 0;
  25662. hncarry += ncarry >>> 26;
  25663. ncarry &= 0x3ffffff;
  25664. }
  25665. out.words[k] = rword;
  25666. carry = ncarry;
  25667. ncarry = hncarry;
  25668. }
  25669. if (carry !== 0) {
  25670. out.words[k] = carry;
  25671. } else {
  25672. out.length--;
  25673. }
  25674. return out.strip();
  25675. }
  25676. function jumboMulTo (self, num, out) {
  25677. var fftm = new FFTM();
  25678. return fftm.mulp(self, num, out);
  25679. }
  25680. BN.prototype.mulTo = function mulTo (num, out) {
  25681. var res;
  25682. var len = this.length + num.length;
  25683. if (this.length === 10 && num.length === 10) {
  25684. res = comb10MulTo(this, num, out);
  25685. } else if (len < 63) {
  25686. res = smallMulTo(this, num, out);
  25687. } else if (len < 1024) {
  25688. res = bigMulTo(this, num, out);
  25689. } else {
  25690. res = jumboMulTo(this, num, out);
  25691. }
  25692. return res;
  25693. };
  25694. // Cooley-Tukey algorithm for FFT
  25695. // slightly revisited to rely on looping instead of recursion
  25696. function FFTM (x, y) {
  25697. this.x = x;
  25698. this.y = y;
  25699. }
  25700. FFTM.prototype.makeRBT = function makeRBT (N) {
  25701. var t = new Array(N);
  25702. var l = BN.prototype._countBits(N) - 1;
  25703. for (var i = 0; i < N; i++) {
  25704. t[i] = this.revBin(i, l, N);
  25705. }
  25706. return t;
  25707. };
  25708. // Returns binary-reversed representation of `x`
  25709. FFTM.prototype.revBin = function revBin (x, l, N) {
  25710. if (x === 0 || x === N - 1) return x;
  25711. var rb = 0;
  25712. for (var i = 0; i < l; i++) {
  25713. rb |= (x & 1) << (l - i - 1);
  25714. x >>= 1;
  25715. }
  25716. return rb;
  25717. };
  25718. // Performs "tweedling" phase, therefore 'emulating'
  25719. // behaviour of the recursive algorithm
  25720. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  25721. for (var i = 0; i < N; i++) {
  25722. rtws[i] = rws[rbt[i]];
  25723. itws[i] = iws[rbt[i]];
  25724. }
  25725. };
  25726. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  25727. this.permute(rbt, rws, iws, rtws, itws, N);
  25728. for (var s = 1; s < N; s <<= 1) {
  25729. var l = s << 1;
  25730. var rtwdf = Math.cos(2 * Math.PI / l);
  25731. var itwdf = Math.sin(2 * Math.PI / l);
  25732. for (var p = 0; p < N; p += l) {
  25733. var rtwdf_ = rtwdf;
  25734. var itwdf_ = itwdf;
  25735. for (var j = 0; j < s; j++) {
  25736. var re = rtws[p + j];
  25737. var ie = itws[p + j];
  25738. var ro = rtws[p + j + s];
  25739. var io = itws[p + j + s];
  25740. var rx = rtwdf_ * ro - itwdf_ * io;
  25741. io = rtwdf_ * io + itwdf_ * ro;
  25742. ro = rx;
  25743. rtws[p + j] = re + ro;
  25744. itws[p + j] = ie + io;
  25745. rtws[p + j + s] = re - ro;
  25746. itws[p + j + s] = ie - io;
  25747. /* jshint maxdepth : false */
  25748. if (j !== l) {
  25749. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  25750. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  25751. rtwdf_ = rx;
  25752. }
  25753. }
  25754. }
  25755. }
  25756. };
  25757. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  25758. var N = Math.max(m, n) | 1;
  25759. var odd = N & 1;
  25760. var i = 0;
  25761. for (N = N / 2 | 0; N; N = N >>> 1) {
  25762. i++;
  25763. }
  25764. return 1 << i + 1 + odd;
  25765. };
  25766. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  25767. if (N <= 1) return;
  25768. for (var i = 0; i < N / 2; i++) {
  25769. var t = rws[i];
  25770. rws[i] = rws[N - i - 1];
  25771. rws[N - i - 1] = t;
  25772. t = iws[i];
  25773. iws[i] = -iws[N - i - 1];
  25774. iws[N - i - 1] = -t;
  25775. }
  25776. };
  25777. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  25778. var carry = 0;
  25779. for (var i = 0; i < N / 2; i++) {
  25780. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  25781. Math.round(ws[2 * i] / N) +
  25782. carry;
  25783. ws[i] = w & 0x3ffffff;
  25784. if (w < 0x4000000) {
  25785. carry = 0;
  25786. } else {
  25787. carry = w / 0x4000000 | 0;
  25788. }
  25789. }
  25790. return ws;
  25791. };
  25792. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  25793. var carry = 0;
  25794. for (var i = 0; i < len; i++) {
  25795. carry = carry + (ws[i] | 0);
  25796. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  25797. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  25798. }
  25799. // Pad with zeroes
  25800. for (i = 2 * len; i < N; ++i) {
  25801. rws[i] = 0;
  25802. }
  25803. assert(carry === 0);
  25804. assert((carry & ~0x1fff) === 0);
  25805. };
  25806. FFTM.prototype.stub = function stub (N) {
  25807. var ph = new Array(N);
  25808. for (var i = 0; i < N; i++) {
  25809. ph[i] = 0;
  25810. }
  25811. return ph;
  25812. };
  25813. FFTM.prototype.mulp = function mulp (x, y, out) {
  25814. var N = 2 * this.guessLen13b(x.length, y.length);
  25815. var rbt = this.makeRBT(N);
  25816. var _ = this.stub(N);
  25817. var rws = new Array(N);
  25818. var rwst = new Array(N);
  25819. var iwst = new Array(N);
  25820. var nrws = new Array(N);
  25821. var nrwst = new Array(N);
  25822. var niwst = new Array(N);
  25823. var rmws = out.words;
  25824. rmws.length = N;
  25825. this.convert13b(x.words, x.length, rws, N);
  25826. this.convert13b(y.words, y.length, nrws, N);
  25827. this.transform(rws, _, rwst, iwst, N, rbt);
  25828. this.transform(nrws, _, nrwst, niwst, N, rbt);
  25829. for (var i = 0; i < N; i++) {
  25830. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  25831. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  25832. rwst[i] = rx;
  25833. }
  25834. this.conjugate(rwst, iwst, N);
  25835. this.transform(rwst, iwst, rmws, _, N, rbt);
  25836. this.conjugate(rmws, _, N);
  25837. this.normalize13b(rmws, N);
  25838. out.negative = x.negative ^ y.negative;
  25839. out.length = x.length + y.length;
  25840. return out.strip();
  25841. };
  25842. // Multiply `this` by `num`
  25843. BN.prototype.mul = function mul (num) {
  25844. var out = new BN(null);
  25845. out.words = new Array(this.length + num.length);
  25846. return this.mulTo(num, out);
  25847. };
  25848. // Multiply employing FFT
  25849. BN.prototype.mulf = function mulf (num) {
  25850. var out = new BN(null);
  25851. out.words = new Array(this.length + num.length);
  25852. return jumboMulTo(this, num, out);
  25853. };
  25854. // In-place Multiplication
  25855. BN.prototype.imul = function imul (num) {
  25856. return this.clone().mulTo(num, this);
  25857. };
  25858. BN.prototype.imuln = function imuln (num) {
  25859. assert(typeof num === 'number');
  25860. assert(num < 0x4000000);
  25861. // Carry
  25862. var carry = 0;
  25863. for (var i = 0; i < this.length; i++) {
  25864. var w = (this.words[i] | 0) * num;
  25865. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  25866. carry >>= 26;
  25867. carry += (w / 0x4000000) | 0;
  25868. // NOTE: lo is 27bit maximum
  25869. carry += lo >>> 26;
  25870. this.words[i] = lo & 0x3ffffff;
  25871. }
  25872. if (carry !== 0) {
  25873. this.words[i] = carry;
  25874. this.length++;
  25875. }
  25876. return this;
  25877. };
  25878. BN.prototype.muln = function muln (num) {
  25879. return this.clone().imuln(num);
  25880. };
  25881. // `this` * `this`
  25882. BN.prototype.sqr = function sqr () {
  25883. return this.mul(this);
  25884. };
  25885. // `this` * `this` in-place
  25886. BN.prototype.isqr = function isqr () {
  25887. return this.imul(this.clone());
  25888. };
  25889. // Math.pow(`this`, `num`)
  25890. BN.prototype.pow = function pow (num) {
  25891. var w = toBitArray(num);
  25892. if (w.length === 0) return new BN(1);
  25893. // Skip leading zeroes
  25894. var res = this;
  25895. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  25896. if (w[i] !== 0) break;
  25897. }
  25898. if (++i < w.length) {
  25899. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  25900. if (w[i] === 0) continue;
  25901. res = res.mul(q);
  25902. }
  25903. }
  25904. return res;
  25905. };
  25906. // Shift-left in-place
  25907. BN.prototype.iushln = function iushln (bits) {
  25908. assert(typeof bits === 'number' && bits >= 0);
  25909. var r = bits % 26;
  25910. var s = (bits - r) / 26;
  25911. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  25912. var i;
  25913. if (r !== 0) {
  25914. var carry = 0;
  25915. for (i = 0; i < this.length; i++) {
  25916. var newCarry = this.words[i] & carryMask;
  25917. var c = ((this.words[i] | 0) - newCarry) << r;
  25918. this.words[i] = c | carry;
  25919. carry = newCarry >>> (26 - r);
  25920. }
  25921. if (carry) {
  25922. this.words[i] = carry;
  25923. this.length++;
  25924. }
  25925. }
  25926. if (s !== 0) {
  25927. for (i = this.length - 1; i >= 0; i--) {
  25928. this.words[i + s] = this.words[i];
  25929. }
  25930. for (i = 0; i < s; i++) {
  25931. this.words[i] = 0;
  25932. }
  25933. this.length += s;
  25934. }
  25935. return this.strip();
  25936. };
  25937. BN.prototype.ishln = function ishln (bits) {
  25938. // TODO(indutny): implement me
  25939. assert(this.negative === 0);
  25940. return this.iushln(bits);
  25941. };
  25942. // Shift-right in-place
  25943. // NOTE: `hint` is a lowest bit before trailing zeroes
  25944. // NOTE: if `extended` is present - it will be filled with destroyed bits
  25945. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  25946. assert(typeof bits === 'number' && bits >= 0);
  25947. var h;
  25948. if (hint) {
  25949. h = (hint - (hint % 26)) / 26;
  25950. } else {
  25951. h = 0;
  25952. }
  25953. var r = bits % 26;
  25954. var s = Math.min((bits - r) / 26, this.length);
  25955. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  25956. var maskedWords = extended;
  25957. h -= s;
  25958. h = Math.max(0, h);
  25959. // Extended mode, copy masked part
  25960. if (maskedWords) {
  25961. for (var i = 0; i < s; i++) {
  25962. maskedWords.words[i] = this.words[i];
  25963. }
  25964. maskedWords.length = s;
  25965. }
  25966. if (s === 0) {
  25967. // No-op, we should not move anything at all
  25968. } else if (this.length > s) {
  25969. this.length -= s;
  25970. for (i = 0; i < this.length; i++) {
  25971. this.words[i] = this.words[i + s];
  25972. }
  25973. } else {
  25974. this.words[0] = 0;
  25975. this.length = 1;
  25976. }
  25977. var carry = 0;
  25978. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  25979. var word = this.words[i] | 0;
  25980. this.words[i] = (carry << (26 - r)) | (word >>> r);
  25981. carry = word & mask;
  25982. }
  25983. // Push carried bits as a mask
  25984. if (maskedWords && carry !== 0) {
  25985. maskedWords.words[maskedWords.length++] = carry;
  25986. }
  25987. if (this.length === 0) {
  25988. this.words[0] = 0;
  25989. this.length = 1;
  25990. }
  25991. return this.strip();
  25992. };
  25993. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  25994. // TODO(indutny): implement me
  25995. assert(this.negative === 0);
  25996. return this.iushrn(bits, hint, extended);
  25997. };
  25998. // Shift-left
  25999. BN.prototype.shln = function shln (bits) {
  26000. return this.clone().ishln(bits);
  26001. };
  26002. BN.prototype.ushln = function ushln (bits) {
  26003. return this.clone().iushln(bits);
  26004. };
  26005. // Shift-right
  26006. BN.prototype.shrn = function shrn (bits) {
  26007. return this.clone().ishrn(bits);
  26008. };
  26009. BN.prototype.ushrn = function ushrn (bits) {
  26010. return this.clone().iushrn(bits);
  26011. };
  26012. // Test if n bit is set
  26013. BN.prototype.testn = function testn (bit) {
  26014. assert(typeof bit === 'number' && bit >= 0);
  26015. var r = bit % 26;
  26016. var s = (bit - r) / 26;
  26017. var q = 1 << r;
  26018. // Fast case: bit is much higher than all existing words
  26019. if (this.length <= s) return false;
  26020. // Check bit and return
  26021. var w = this.words[s];
  26022. return !!(w & q);
  26023. };
  26024. // Return only lowers bits of number (in-place)
  26025. BN.prototype.imaskn = function imaskn (bits) {
  26026. assert(typeof bits === 'number' && bits >= 0);
  26027. var r = bits % 26;
  26028. var s = (bits - r) / 26;
  26029. assert(this.negative === 0, 'imaskn works only with positive numbers');
  26030. if (this.length <= s) {
  26031. return this;
  26032. }
  26033. if (r !== 0) {
  26034. s++;
  26035. }
  26036. this.length = Math.min(s, this.length);
  26037. if (r !== 0) {
  26038. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  26039. this.words[this.length - 1] &= mask;
  26040. }
  26041. return this.strip();
  26042. };
  26043. // Return only lowers bits of number
  26044. BN.prototype.maskn = function maskn (bits) {
  26045. return this.clone().imaskn(bits);
  26046. };
  26047. // Add plain number `num` to `this`
  26048. BN.prototype.iaddn = function iaddn (num) {
  26049. assert(typeof num === 'number');
  26050. assert(num < 0x4000000);
  26051. if (num < 0) return this.isubn(-num);
  26052. // Possible sign change
  26053. if (this.negative !== 0) {
  26054. if (this.length === 1 && (this.words[0] | 0) < num) {
  26055. this.words[0] = num - (this.words[0] | 0);
  26056. this.negative = 0;
  26057. return this;
  26058. }
  26059. this.negative = 0;
  26060. this.isubn(num);
  26061. this.negative = 1;
  26062. return this;
  26063. }
  26064. // Add without checks
  26065. return this._iaddn(num);
  26066. };
  26067. BN.prototype._iaddn = function _iaddn (num) {
  26068. this.words[0] += num;
  26069. // Carry
  26070. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  26071. this.words[i] -= 0x4000000;
  26072. if (i === this.length - 1) {
  26073. this.words[i + 1] = 1;
  26074. } else {
  26075. this.words[i + 1]++;
  26076. }
  26077. }
  26078. this.length = Math.max(this.length, i + 1);
  26079. return this;
  26080. };
  26081. // Subtract plain number `num` from `this`
  26082. BN.prototype.isubn = function isubn (num) {
  26083. assert(typeof num === 'number');
  26084. assert(num < 0x4000000);
  26085. if (num < 0) return this.iaddn(-num);
  26086. if (this.negative !== 0) {
  26087. this.negative = 0;
  26088. this.iaddn(num);
  26089. this.negative = 1;
  26090. return this;
  26091. }
  26092. this.words[0] -= num;
  26093. if (this.length === 1 && this.words[0] < 0) {
  26094. this.words[0] = -this.words[0];
  26095. this.negative = 1;
  26096. } else {
  26097. // Carry
  26098. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  26099. this.words[i] += 0x4000000;
  26100. this.words[i + 1] -= 1;
  26101. }
  26102. }
  26103. return this.strip();
  26104. };
  26105. BN.prototype.addn = function addn (num) {
  26106. return this.clone().iaddn(num);
  26107. };
  26108. BN.prototype.subn = function subn (num) {
  26109. return this.clone().isubn(num);
  26110. };
  26111. BN.prototype.iabs = function iabs () {
  26112. this.negative = 0;
  26113. return this;
  26114. };
  26115. BN.prototype.abs = function abs () {
  26116. return this.clone().iabs();
  26117. };
  26118. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  26119. var len = num.length + shift;
  26120. var i;
  26121. this._expand(len);
  26122. var w;
  26123. var carry = 0;
  26124. for (i = 0; i < num.length; i++) {
  26125. w = (this.words[i + shift] | 0) + carry;
  26126. var right = (num.words[i] | 0) * mul;
  26127. w -= right & 0x3ffffff;
  26128. carry = (w >> 26) - ((right / 0x4000000) | 0);
  26129. this.words[i + shift] = w & 0x3ffffff;
  26130. }
  26131. for (; i < this.length - shift; i++) {
  26132. w = (this.words[i + shift] | 0) + carry;
  26133. carry = w >> 26;
  26134. this.words[i + shift] = w & 0x3ffffff;
  26135. }
  26136. if (carry === 0) return this.strip();
  26137. // Subtraction overflow
  26138. assert(carry === -1);
  26139. carry = 0;
  26140. for (i = 0; i < this.length; i++) {
  26141. w = -(this.words[i] | 0) + carry;
  26142. carry = w >> 26;
  26143. this.words[i] = w & 0x3ffffff;
  26144. }
  26145. this.negative = 1;
  26146. return this.strip();
  26147. };
  26148. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  26149. var shift = this.length - num.length;
  26150. var a = this.clone();
  26151. var b = num;
  26152. // Normalize
  26153. var bhi = b.words[b.length - 1] | 0;
  26154. var bhiBits = this._countBits(bhi);
  26155. shift = 26 - bhiBits;
  26156. if (shift !== 0) {
  26157. b = b.ushln(shift);
  26158. a.iushln(shift);
  26159. bhi = b.words[b.length - 1] | 0;
  26160. }
  26161. // Initialize quotient
  26162. var m = a.length - b.length;
  26163. var q;
  26164. if (mode !== 'mod') {
  26165. q = new BN(null);
  26166. q.length = m + 1;
  26167. q.words = new Array(q.length);
  26168. for (var i = 0; i < q.length; i++) {
  26169. q.words[i] = 0;
  26170. }
  26171. }
  26172. var diff = a.clone()._ishlnsubmul(b, 1, m);
  26173. if (diff.negative === 0) {
  26174. a = diff;
  26175. if (q) {
  26176. q.words[m] = 1;
  26177. }
  26178. }
  26179. for (var j = m - 1; j >= 0; j--) {
  26180. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  26181. (a.words[b.length + j - 1] | 0);
  26182. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  26183. // (0x7ffffff)
  26184. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  26185. a._ishlnsubmul(b, qj, j);
  26186. while (a.negative !== 0) {
  26187. qj--;
  26188. a.negative = 0;
  26189. a._ishlnsubmul(b, 1, j);
  26190. if (!a.isZero()) {
  26191. a.negative ^= 1;
  26192. }
  26193. }
  26194. if (q) {
  26195. q.words[j] = qj;
  26196. }
  26197. }
  26198. if (q) {
  26199. q.strip();
  26200. }
  26201. a.strip();
  26202. // Denormalize
  26203. if (mode !== 'div' && shift !== 0) {
  26204. a.iushrn(shift);
  26205. }
  26206. return {
  26207. div: q || null,
  26208. mod: a
  26209. };
  26210. };
  26211. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  26212. // to `div` to request div only, or be absent to
  26213. // request both div & mod
  26214. // 2) `positive` is true if unsigned mod is requested
  26215. BN.prototype.divmod = function divmod (num, mode, positive) {
  26216. assert(!num.isZero());
  26217. if (this.isZero()) {
  26218. return {
  26219. div: new BN(0),
  26220. mod: new BN(0)
  26221. };
  26222. }
  26223. var div, mod, res;
  26224. if (this.negative !== 0 && num.negative === 0) {
  26225. res = this.neg().divmod(num, mode);
  26226. if (mode !== 'mod') {
  26227. div = res.div.neg();
  26228. }
  26229. if (mode !== 'div') {
  26230. mod = res.mod.neg();
  26231. if (positive && mod.negative !== 0) {
  26232. mod.iadd(num);
  26233. }
  26234. }
  26235. return {
  26236. div: div,
  26237. mod: mod
  26238. };
  26239. }
  26240. if (this.negative === 0 && num.negative !== 0) {
  26241. res = this.divmod(num.neg(), mode);
  26242. if (mode !== 'mod') {
  26243. div = res.div.neg();
  26244. }
  26245. return {
  26246. div: div,
  26247. mod: res.mod
  26248. };
  26249. }
  26250. if ((this.negative & num.negative) !== 0) {
  26251. res = this.neg().divmod(num.neg(), mode);
  26252. if (mode !== 'div') {
  26253. mod = res.mod.neg();
  26254. if (positive && mod.negative !== 0) {
  26255. mod.isub(num);
  26256. }
  26257. }
  26258. return {
  26259. div: res.div,
  26260. mod: mod
  26261. };
  26262. }
  26263. // Both numbers are positive at this point
  26264. // Strip both numbers to approximate shift value
  26265. if (num.length > this.length || this.cmp(num) < 0) {
  26266. return {
  26267. div: new BN(0),
  26268. mod: this
  26269. };
  26270. }
  26271. // Very short reduction
  26272. if (num.length === 1) {
  26273. if (mode === 'div') {
  26274. return {
  26275. div: this.divn(num.words[0]),
  26276. mod: null
  26277. };
  26278. }
  26279. if (mode === 'mod') {
  26280. return {
  26281. div: null,
  26282. mod: new BN(this.modn(num.words[0]))
  26283. };
  26284. }
  26285. return {
  26286. div: this.divn(num.words[0]),
  26287. mod: new BN(this.modn(num.words[0]))
  26288. };
  26289. }
  26290. return this._wordDiv(num, mode);
  26291. };
  26292. // Find `this` / `num`
  26293. BN.prototype.div = function div (num) {
  26294. return this.divmod(num, 'div', false).div;
  26295. };
  26296. // Find `this` % `num`
  26297. BN.prototype.mod = function mod (num) {
  26298. return this.divmod(num, 'mod', false).mod;
  26299. };
  26300. BN.prototype.umod = function umod (num) {
  26301. return this.divmod(num, 'mod', true).mod;
  26302. };
  26303. // Find Round(`this` / `num`)
  26304. BN.prototype.divRound = function divRound (num) {
  26305. var dm = this.divmod(num);
  26306. // Fast case - exact division
  26307. if (dm.mod.isZero()) return dm.div;
  26308. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  26309. var half = num.ushrn(1);
  26310. var r2 = num.andln(1);
  26311. var cmp = mod.cmp(half);
  26312. // Round down
  26313. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  26314. // Round up
  26315. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  26316. };
  26317. BN.prototype.modn = function modn (num) {
  26318. assert(num <= 0x3ffffff);
  26319. var p = (1 << 26) % num;
  26320. var acc = 0;
  26321. for (var i = this.length - 1; i >= 0; i--) {
  26322. acc = (p * acc + (this.words[i] | 0)) % num;
  26323. }
  26324. return acc;
  26325. };
  26326. // In-place division by number
  26327. BN.prototype.idivn = function idivn (num) {
  26328. assert(num <= 0x3ffffff);
  26329. var carry = 0;
  26330. for (var i = this.length - 1; i >= 0; i--) {
  26331. var w = (this.words[i] | 0) + carry * 0x4000000;
  26332. this.words[i] = (w / num) | 0;
  26333. carry = w % num;
  26334. }
  26335. return this.strip();
  26336. };
  26337. BN.prototype.divn = function divn (num) {
  26338. return this.clone().idivn(num);
  26339. };
  26340. BN.prototype.egcd = function egcd (p) {
  26341. assert(p.negative === 0);
  26342. assert(!p.isZero());
  26343. var x = this;
  26344. var y = p.clone();
  26345. if (x.negative !== 0) {
  26346. x = x.umod(p);
  26347. } else {
  26348. x = x.clone();
  26349. }
  26350. // A * x + B * y = x
  26351. var A = new BN(1);
  26352. var B = new BN(0);
  26353. // C * x + D * y = y
  26354. var C = new BN(0);
  26355. var D = new BN(1);
  26356. var g = 0;
  26357. while (x.isEven() && y.isEven()) {
  26358. x.iushrn(1);
  26359. y.iushrn(1);
  26360. ++g;
  26361. }
  26362. var yp = y.clone();
  26363. var xp = x.clone();
  26364. while (!x.isZero()) {
  26365. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  26366. if (i > 0) {
  26367. x.iushrn(i);
  26368. while (i-- > 0) {
  26369. if (A.isOdd() || B.isOdd()) {
  26370. A.iadd(yp);
  26371. B.isub(xp);
  26372. }
  26373. A.iushrn(1);
  26374. B.iushrn(1);
  26375. }
  26376. }
  26377. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  26378. if (j > 0) {
  26379. y.iushrn(j);
  26380. while (j-- > 0) {
  26381. if (C.isOdd() || D.isOdd()) {
  26382. C.iadd(yp);
  26383. D.isub(xp);
  26384. }
  26385. C.iushrn(1);
  26386. D.iushrn(1);
  26387. }
  26388. }
  26389. if (x.cmp(y) >= 0) {
  26390. x.isub(y);
  26391. A.isub(C);
  26392. B.isub(D);
  26393. } else {
  26394. y.isub(x);
  26395. C.isub(A);
  26396. D.isub(B);
  26397. }
  26398. }
  26399. return {
  26400. a: C,
  26401. b: D,
  26402. gcd: y.iushln(g)
  26403. };
  26404. };
  26405. // This is reduced incarnation of the binary EEA
  26406. // above, designated to invert members of the
  26407. // _prime_ fields F(p) at a maximal speed
  26408. BN.prototype._invmp = function _invmp (p) {
  26409. assert(p.negative === 0);
  26410. assert(!p.isZero());
  26411. var a = this;
  26412. var b = p.clone();
  26413. if (a.negative !== 0) {
  26414. a = a.umod(p);
  26415. } else {
  26416. a = a.clone();
  26417. }
  26418. var x1 = new BN(1);
  26419. var x2 = new BN(0);
  26420. var delta = b.clone();
  26421. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  26422. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  26423. if (i > 0) {
  26424. a.iushrn(i);
  26425. while (i-- > 0) {
  26426. if (x1.isOdd()) {
  26427. x1.iadd(delta);
  26428. }
  26429. x1.iushrn(1);
  26430. }
  26431. }
  26432. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  26433. if (j > 0) {
  26434. b.iushrn(j);
  26435. while (j-- > 0) {
  26436. if (x2.isOdd()) {
  26437. x2.iadd(delta);
  26438. }
  26439. x2.iushrn(1);
  26440. }
  26441. }
  26442. if (a.cmp(b) >= 0) {
  26443. a.isub(b);
  26444. x1.isub(x2);
  26445. } else {
  26446. b.isub(a);
  26447. x2.isub(x1);
  26448. }
  26449. }
  26450. var res;
  26451. if (a.cmpn(1) === 0) {
  26452. res = x1;
  26453. } else {
  26454. res = x2;
  26455. }
  26456. if (res.cmpn(0) < 0) {
  26457. res.iadd(p);
  26458. }
  26459. return res;
  26460. };
  26461. BN.prototype.gcd = function gcd (num) {
  26462. if (this.isZero()) return num.abs();
  26463. if (num.isZero()) return this.abs();
  26464. var a = this.clone();
  26465. var b = num.clone();
  26466. a.negative = 0;
  26467. b.negative = 0;
  26468. // Remove common factor of two
  26469. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  26470. a.iushrn(1);
  26471. b.iushrn(1);
  26472. }
  26473. do {
  26474. while (a.isEven()) {
  26475. a.iushrn(1);
  26476. }
  26477. while (b.isEven()) {
  26478. b.iushrn(1);
  26479. }
  26480. var r = a.cmp(b);
  26481. if (r < 0) {
  26482. // Swap `a` and `b` to make `a` always bigger than `b`
  26483. var t = a;
  26484. a = b;
  26485. b = t;
  26486. } else if (r === 0 || b.cmpn(1) === 0) {
  26487. break;
  26488. }
  26489. a.isub(b);
  26490. } while (true);
  26491. return b.iushln(shift);
  26492. };
  26493. // Invert number in the field F(num)
  26494. BN.prototype.invm = function invm (num) {
  26495. return this.egcd(num).a.umod(num);
  26496. };
  26497. BN.prototype.isEven = function isEven () {
  26498. return (this.words[0] & 1) === 0;
  26499. };
  26500. BN.prototype.isOdd = function isOdd () {
  26501. return (this.words[0] & 1) === 1;
  26502. };
  26503. // And first word and num
  26504. BN.prototype.andln = function andln (num) {
  26505. return this.words[0] & num;
  26506. };
  26507. // Increment at the bit position in-line
  26508. BN.prototype.bincn = function bincn (bit) {
  26509. assert(typeof bit === 'number');
  26510. var r = bit % 26;
  26511. var s = (bit - r) / 26;
  26512. var q = 1 << r;
  26513. // Fast case: bit is much higher than all existing words
  26514. if (this.length <= s) {
  26515. this._expand(s + 1);
  26516. this.words[s] |= q;
  26517. return this;
  26518. }
  26519. // Add bit and propagate, if needed
  26520. var carry = q;
  26521. for (var i = s; carry !== 0 && i < this.length; i++) {
  26522. var w = this.words[i] | 0;
  26523. w += carry;
  26524. carry = w >>> 26;
  26525. w &= 0x3ffffff;
  26526. this.words[i] = w;
  26527. }
  26528. if (carry !== 0) {
  26529. this.words[i] = carry;
  26530. this.length++;
  26531. }
  26532. return this;
  26533. };
  26534. BN.prototype.isZero = function isZero () {
  26535. return this.length === 1 && this.words[0] === 0;
  26536. };
  26537. BN.prototype.cmpn = function cmpn (num) {
  26538. var negative = num < 0;
  26539. if (this.negative !== 0 && !negative) return -1;
  26540. if (this.negative === 0 && negative) return 1;
  26541. this.strip();
  26542. var res;
  26543. if (this.length > 1) {
  26544. res = 1;
  26545. } else {
  26546. if (negative) {
  26547. num = -num;
  26548. }
  26549. assert(num <= 0x3ffffff, 'Number is too big');
  26550. var w = this.words[0] | 0;
  26551. res = w === num ? 0 : w < num ? -1 : 1;
  26552. }
  26553. if (this.negative !== 0) return -res | 0;
  26554. return res;
  26555. };
  26556. // Compare two numbers and return:
  26557. // 1 - if `this` > `num`
  26558. // 0 - if `this` == `num`
  26559. // -1 - if `this` < `num`
  26560. BN.prototype.cmp = function cmp (num) {
  26561. if (this.negative !== 0 && num.negative === 0) return -1;
  26562. if (this.negative === 0 && num.negative !== 0) return 1;
  26563. var res = this.ucmp(num);
  26564. if (this.negative !== 0) return -res | 0;
  26565. return res;
  26566. };
  26567. // Unsigned comparison
  26568. BN.prototype.ucmp = function ucmp (num) {
  26569. // At this point both numbers have the same sign
  26570. if (this.length > num.length) return 1;
  26571. if (this.length < num.length) return -1;
  26572. var res = 0;
  26573. for (var i = this.length - 1; i >= 0; i--) {
  26574. var a = this.words[i] | 0;
  26575. var b = num.words[i] | 0;
  26576. if (a === b) continue;
  26577. if (a < b) {
  26578. res = -1;
  26579. } else if (a > b) {
  26580. res = 1;
  26581. }
  26582. break;
  26583. }
  26584. return res;
  26585. };
  26586. BN.prototype.gtn = function gtn (num) {
  26587. return this.cmpn(num) === 1;
  26588. };
  26589. BN.prototype.gt = function gt (num) {
  26590. return this.cmp(num) === 1;
  26591. };
  26592. BN.prototype.gten = function gten (num) {
  26593. return this.cmpn(num) >= 0;
  26594. };
  26595. BN.prototype.gte = function gte (num) {
  26596. return this.cmp(num) >= 0;
  26597. };
  26598. BN.prototype.ltn = function ltn (num) {
  26599. return this.cmpn(num) === -1;
  26600. };
  26601. BN.prototype.lt = function lt (num) {
  26602. return this.cmp(num) === -1;
  26603. };
  26604. BN.prototype.lten = function lten (num) {
  26605. return this.cmpn(num) <= 0;
  26606. };
  26607. BN.prototype.lte = function lte (num) {
  26608. return this.cmp(num) <= 0;
  26609. };
  26610. BN.prototype.eqn = function eqn (num) {
  26611. return this.cmpn(num) === 0;
  26612. };
  26613. BN.prototype.eq = function eq (num) {
  26614. return this.cmp(num) === 0;
  26615. };
  26616. //
  26617. // A reduce context, could be using montgomery or something better, depending
  26618. // on the `m` itself.
  26619. //
  26620. BN.red = function red (num) {
  26621. return new Red(num);
  26622. };
  26623. BN.prototype.toRed = function toRed (ctx) {
  26624. assert(!this.red, 'Already a number in reduction context');
  26625. assert(this.negative === 0, 'red works only with positives');
  26626. return ctx.convertTo(this)._forceRed(ctx);
  26627. };
  26628. BN.prototype.fromRed = function fromRed () {
  26629. assert(this.red, 'fromRed works only with numbers in reduction context');
  26630. return this.red.convertFrom(this);
  26631. };
  26632. BN.prototype._forceRed = function _forceRed (ctx) {
  26633. this.red = ctx;
  26634. return this;
  26635. };
  26636. BN.prototype.forceRed = function forceRed (ctx) {
  26637. assert(!this.red, 'Already a number in reduction context');
  26638. return this._forceRed(ctx);
  26639. };
  26640. BN.prototype.redAdd = function redAdd (num) {
  26641. assert(this.red, 'redAdd works only with red numbers');
  26642. return this.red.add(this, num);
  26643. };
  26644. BN.prototype.redIAdd = function redIAdd (num) {
  26645. assert(this.red, 'redIAdd works only with red numbers');
  26646. return this.red.iadd(this, num);
  26647. };
  26648. BN.prototype.redSub = function redSub (num) {
  26649. assert(this.red, 'redSub works only with red numbers');
  26650. return this.red.sub(this, num);
  26651. };
  26652. BN.prototype.redISub = function redISub (num) {
  26653. assert(this.red, 'redISub works only with red numbers');
  26654. return this.red.isub(this, num);
  26655. };
  26656. BN.prototype.redShl = function redShl (num) {
  26657. assert(this.red, 'redShl works only with red numbers');
  26658. return this.red.shl(this, num);
  26659. };
  26660. BN.prototype.redMul = function redMul (num) {
  26661. assert(this.red, 'redMul works only with red numbers');
  26662. this.red._verify2(this, num);
  26663. return this.red.mul(this, num);
  26664. };
  26665. BN.prototype.redIMul = function redIMul (num) {
  26666. assert(this.red, 'redMul works only with red numbers');
  26667. this.red._verify2(this, num);
  26668. return this.red.imul(this, num);
  26669. };
  26670. BN.prototype.redSqr = function redSqr () {
  26671. assert(this.red, 'redSqr works only with red numbers');
  26672. this.red._verify1(this);
  26673. return this.red.sqr(this);
  26674. };
  26675. BN.prototype.redISqr = function redISqr () {
  26676. assert(this.red, 'redISqr works only with red numbers');
  26677. this.red._verify1(this);
  26678. return this.red.isqr(this);
  26679. };
  26680. // Square root over p
  26681. BN.prototype.redSqrt = function redSqrt () {
  26682. assert(this.red, 'redSqrt works only with red numbers');
  26683. this.red._verify1(this);
  26684. return this.red.sqrt(this);
  26685. };
  26686. BN.prototype.redInvm = function redInvm () {
  26687. assert(this.red, 'redInvm works only with red numbers');
  26688. this.red._verify1(this);
  26689. return this.red.invm(this);
  26690. };
  26691. // Return negative clone of `this` % `red modulo`
  26692. BN.prototype.redNeg = function redNeg () {
  26693. assert(this.red, 'redNeg works only with red numbers');
  26694. this.red._verify1(this);
  26695. return this.red.neg(this);
  26696. };
  26697. BN.prototype.redPow = function redPow (num) {
  26698. assert(this.red && !num.red, 'redPow(normalNum)');
  26699. this.red._verify1(this);
  26700. return this.red.pow(this, num);
  26701. };
  26702. // Prime numbers with efficient reduction
  26703. var primes = {
  26704. k256: null,
  26705. p224: null,
  26706. p192: null,
  26707. p25519: null
  26708. };
  26709. // Pseudo-Mersenne prime
  26710. function MPrime (name, p) {
  26711. // P = 2 ^ N - K
  26712. this.name = name;
  26713. this.p = new BN(p, 16);
  26714. this.n = this.p.bitLength();
  26715. this.k = new BN(1).iushln(this.n).isub(this.p);
  26716. this.tmp = this._tmp();
  26717. }
  26718. MPrime.prototype._tmp = function _tmp () {
  26719. var tmp = new BN(null);
  26720. tmp.words = new Array(Math.ceil(this.n / 13));
  26721. return tmp;
  26722. };
  26723. MPrime.prototype.ireduce = function ireduce (num) {
  26724. // Assumes that `num` is less than `P^2`
  26725. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  26726. var r = num;
  26727. var rlen;
  26728. do {
  26729. this.split(r, this.tmp);
  26730. r = this.imulK(r);
  26731. r = r.iadd(this.tmp);
  26732. rlen = r.bitLength();
  26733. } while (rlen > this.n);
  26734. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  26735. if (cmp === 0) {
  26736. r.words[0] = 0;
  26737. r.length = 1;
  26738. } else if (cmp > 0) {
  26739. r.isub(this.p);
  26740. } else {
  26741. if (r.strip !== undefined) {
  26742. // r is BN v4 instance
  26743. r.strip();
  26744. } else {
  26745. // r is BN v5 instance
  26746. r._strip();
  26747. }
  26748. }
  26749. return r;
  26750. };
  26751. MPrime.prototype.split = function split (input, out) {
  26752. input.iushrn(this.n, 0, out);
  26753. };
  26754. MPrime.prototype.imulK = function imulK (num) {
  26755. return num.imul(this.k);
  26756. };
  26757. function K256 () {
  26758. MPrime.call(
  26759. this,
  26760. 'k256',
  26761. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  26762. }
  26763. inherits(K256, MPrime);
  26764. K256.prototype.split = function split (input, output) {
  26765. // 256 = 9 * 26 + 22
  26766. var mask = 0x3fffff;
  26767. var outLen = Math.min(input.length, 9);
  26768. for (var i = 0; i < outLen; i++) {
  26769. output.words[i] = input.words[i];
  26770. }
  26771. output.length = outLen;
  26772. if (input.length <= 9) {
  26773. input.words[0] = 0;
  26774. input.length = 1;
  26775. return;
  26776. }
  26777. // Shift by 9 limbs
  26778. var prev = input.words[9];
  26779. output.words[output.length++] = prev & mask;
  26780. for (i = 10; i < input.length; i++) {
  26781. var next = input.words[i] | 0;
  26782. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  26783. prev = next;
  26784. }
  26785. prev >>>= 22;
  26786. input.words[i - 10] = prev;
  26787. if (prev === 0 && input.length > 10) {
  26788. input.length -= 10;
  26789. } else {
  26790. input.length -= 9;
  26791. }
  26792. };
  26793. K256.prototype.imulK = function imulK (num) {
  26794. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  26795. num.words[num.length] = 0;
  26796. num.words[num.length + 1] = 0;
  26797. num.length += 2;
  26798. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  26799. var lo = 0;
  26800. for (var i = 0; i < num.length; i++) {
  26801. var w = num.words[i] | 0;
  26802. lo += w * 0x3d1;
  26803. num.words[i] = lo & 0x3ffffff;
  26804. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  26805. }
  26806. // Fast length reduction
  26807. if (num.words[num.length - 1] === 0) {
  26808. num.length--;
  26809. if (num.words[num.length - 1] === 0) {
  26810. num.length--;
  26811. }
  26812. }
  26813. return num;
  26814. };
  26815. function P224 () {
  26816. MPrime.call(
  26817. this,
  26818. 'p224',
  26819. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  26820. }
  26821. inherits(P224, MPrime);
  26822. function P192 () {
  26823. MPrime.call(
  26824. this,
  26825. 'p192',
  26826. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  26827. }
  26828. inherits(P192, MPrime);
  26829. function P25519 () {
  26830. // 2 ^ 255 - 19
  26831. MPrime.call(
  26832. this,
  26833. '25519',
  26834. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  26835. }
  26836. inherits(P25519, MPrime);
  26837. P25519.prototype.imulK = function imulK (num) {
  26838. // K = 0x13
  26839. var carry = 0;
  26840. for (var i = 0; i < num.length; i++) {
  26841. var hi = (num.words[i] | 0) * 0x13 + carry;
  26842. var lo = hi & 0x3ffffff;
  26843. hi >>>= 26;
  26844. num.words[i] = lo;
  26845. carry = hi;
  26846. }
  26847. if (carry !== 0) {
  26848. num.words[num.length++] = carry;
  26849. }
  26850. return num;
  26851. };
  26852. // Exported mostly for testing purposes, use plain name instead
  26853. BN._prime = function prime (name) {
  26854. // Cached version of prime
  26855. if (primes[name]) return primes[name];
  26856. var prime;
  26857. if (name === 'k256') {
  26858. prime = new K256();
  26859. } else if (name === 'p224') {
  26860. prime = new P224();
  26861. } else if (name === 'p192') {
  26862. prime = new P192();
  26863. } else if (name === 'p25519') {
  26864. prime = new P25519();
  26865. } else {
  26866. throw new Error('Unknown prime ' + name);
  26867. }
  26868. primes[name] = prime;
  26869. return prime;
  26870. };
  26871. //
  26872. // Base reduction engine
  26873. //
  26874. function Red (m) {
  26875. if (typeof m === 'string') {
  26876. var prime = BN._prime(m);
  26877. this.m = prime.p;
  26878. this.prime = prime;
  26879. } else {
  26880. assert(m.gtn(1), 'modulus must be greater than 1');
  26881. this.m = m;
  26882. this.prime = null;
  26883. }
  26884. }
  26885. Red.prototype._verify1 = function _verify1 (a) {
  26886. assert(a.negative === 0, 'red works only with positives');
  26887. assert(a.red, 'red works only with red numbers');
  26888. };
  26889. Red.prototype._verify2 = function _verify2 (a, b) {
  26890. assert((a.negative | b.negative) === 0, 'red works only with positives');
  26891. assert(a.red && a.red === b.red,
  26892. 'red works only with red numbers');
  26893. };
  26894. Red.prototype.imod = function imod (a) {
  26895. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  26896. return a.umod(this.m)._forceRed(this);
  26897. };
  26898. Red.prototype.neg = function neg (a) {
  26899. if (a.isZero()) {
  26900. return a.clone();
  26901. }
  26902. return this.m.sub(a)._forceRed(this);
  26903. };
  26904. Red.prototype.add = function add (a, b) {
  26905. this._verify2(a, b);
  26906. var res = a.add(b);
  26907. if (res.cmp(this.m) >= 0) {
  26908. res.isub(this.m);
  26909. }
  26910. return res._forceRed(this);
  26911. };
  26912. Red.prototype.iadd = function iadd (a, b) {
  26913. this._verify2(a, b);
  26914. var res = a.iadd(b);
  26915. if (res.cmp(this.m) >= 0) {
  26916. res.isub(this.m);
  26917. }
  26918. return res;
  26919. };
  26920. Red.prototype.sub = function sub (a, b) {
  26921. this._verify2(a, b);
  26922. var res = a.sub(b);
  26923. if (res.cmpn(0) < 0) {
  26924. res.iadd(this.m);
  26925. }
  26926. return res._forceRed(this);
  26927. };
  26928. Red.prototype.isub = function isub (a, b) {
  26929. this._verify2(a, b);
  26930. var res = a.isub(b);
  26931. if (res.cmpn(0) < 0) {
  26932. res.iadd(this.m);
  26933. }
  26934. return res;
  26935. };
  26936. Red.prototype.shl = function shl (a, num) {
  26937. this._verify1(a);
  26938. return this.imod(a.ushln(num));
  26939. };
  26940. Red.prototype.imul = function imul (a, b) {
  26941. this._verify2(a, b);
  26942. return this.imod(a.imul(b));
  26943. };
  26944. Red.prototype.mul = function mul (a, b) {
  26945. this._verify2(a, b);
  26946. return this.imod(a.mul(b));
  26947. };
  26948. Red.prototype.isqr = function isqr (a) {
  26949. return this.imul(a, a.clone());
  26950. };
  26951. Red.prototype.sqr = function sqr (a) {
  26952. return this.mul(a, a);
  26953. };
  26954. Red.prototype.sqrt = function sqrt (a) {
  26955. if (a.isZero()) return a.clone();
  26956. var mod3 = this.m.andln(3);
  26957. assert(mod3 % 2 === 1);
  26958. // Fast case
  26959. if (mod3 === 3) {
  26960. var pow = this.m.add(new BN(1)).iushrn(2);
  26961. return this.pow(a, pow);
  26962. }
  26963. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  26964. //
  26965. // Find Q and S, that Q * 2 ^ S = (P - 1)
  26966. var q = this.m.subn(1);
  26967. var s = 0;
  26968. while (!q.isZero() && q.andln(1) === 0) {
  26969. s++;
  26970. q.iushrn(1);
  26971. }
  26972. assert(!q.isZero());
  26973. var one = new BN(1).toRed(this);
  26974. var nOne = one.redNeg();
  26975. // Find quadratic non-residue
  26976. // NOTE: Max is such because of generalized Riemann hypothesis.
  26977. var lpow = this.m.subn(1).iushrn(1);
  26978. var z = this.m.bitLength();
  26979. z = new BN(2 * z * z).toRed(this);
  26980. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  26981. z.redIAdd(nOne);
  26982. }
  26983. var c = this.pow(z, q);
  26984. var r = this.pow(a, q.addn(1).iushrn(1));
  26985. var t = this.pow(a, q);
  26986. var m = s;
  26987. while (t.cmp(one) !== 0) {
  26988. var tmp = t;
  26989. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  26990. tmp = tmp.redSqr();
  26991. }
  26992. assert(i < m);
  26993. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  26994. r = r.redMul(b);
  26995. c = b.redSqr();
  26996. t = t.redMul(c);
  26997. m = i;
  26998. }
  26999. return r;
  27000. };
  27001. Red.prototype.invm = function invm (a) {
  27002. var inv = a._invmp(this.m);
  27003. if (inv.negative !== 0) {
  27004. inv.negative = 0;
  27005. return this.imod(inv).redNeg();
  27006. } else {
  27007. return this.imod(inv);
  27008. }
  27009. };
  27010. Red.prototype.pow = function pow (a, num) {
  27011. if (num.isZero()) return new BN(1).toRed(this);
  27012. if (num.cmpn(1) === 0) return a.clone();
  27013. var windowSize = 4;
  27014. var wnd = new Array(1 << windowSize);
  27015. wnd[0] = new BN(1).toRed(this);
  27016. wnd[1] = a;
  27017. for (var i = 2; i < wnd.length; i++) {
  27018. wnd[i] = this.mul(wnd[i - 1], a);
  27019. }
  27020. var res = wnd[0];
  27021. var current = 0;
  27022. var currentLen = 0;
  27023. var start = num.bitLength() % 26;
  27024. if (start === 0) {
  27025. start = 26;
  27026. }
  27027. for (i = num.length - 1; i >= 0; i--) {
  27028. var word = num.words[i];
  27029. for (var j = start - 1; j >= 0; j--) {
  27030. var bit = (word >> j) & 1;
  27031. if (res !== wnd[0]) {
  27032. res = this.sqr(res);
  27033. }
  27034. if (bit === 0 && current === 0) {
  27035. currentLen = 0;
  27036. continue;
  27037. }
  27038. current <<= 1;
  27039. current |= bit;
  27040. currentLen++;
  27041. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  27042. res = this.mul(res, wnd[current]);
  27043. currentLen = 0;
  27044. current = 0;
  27045. }
  27046. start = 26;
  27047. }
  27048. return res;
  27049. };
  27050. Red.prototype.convertTo = function convertTo (num) {
  27051. var r = num.umod(this.m);
  27052. return r === num ? r.clone() : r;
  27053. };
  27054. Red.prototype.convertFrom = function convertFrom (num) {
  27055. var res = num.clone();
  27056. res.red = null;
  27057. return res;
  27058. };
  27059. //
  27060. // Montgomery method engine
  27061. //
  27062. BN.mont = function mont (num) {
  27063. return new Mont(num);
  27064. };
  27065. function Mont (m) {
  27066. Red.call(this, m);
  27067. this.shift = this.m.bitLength();
  27068. if (this.shift % 26 !== 0) {
  27069. this.shift += 26 - (this.shift % 26);
  27070. }
  27071. this.r = new BN(1).iushln(this.shift);
  27072. this.r2 = this.imod(this.r.sqr());
  27073. this.rinv = this.r._invmp(this.m);
  27074. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  27075. this.minv = this.minv.umod(this.r);
  27076. this.minv = this.r.sub(this.minv);
  27077. }
  27078. inherits(Mont, Red);
  27079. Mont.prototype.convertTo = function convertTo (num) {
  27080. return this.imod(num.ushln(this.shift));
  27081. };
  27082. Mont.prototype.convertFrom = function convertFrom (num) {
  27083. var r = this.imod(num.mul(this.rinv));
  27084. r.red = null;
  27085. return r;
  27086. };
  27087. Mont.prototype.imul = function imul (a, b) {
  27088. if (a.isZero() || b.isZero()) {
  27089. a.words[0] = 0;
  27090. a.length = 1;
  27091. return a;
  27092. }
  27093. var t = a.imul(b);
  27094. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  27095. var u = t.isub(c).iushrn(this.shift);
  27096. var res = u;
  27097. if (u.cmp(this.m) >= 0) {
  27098. res = u.isub(this.m);
  27099. } else if (u.cmpn(0) < 0) {
  27100. res = u.iadd(this.m);
  27101. }
  27102. return res._forceRed(this);
  27103. };
  27104. Mont.prototype.mul = function mul (a, b) {
  27105. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  27106. var t = a.mul(b);
  27107. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  27108. var u = t.isub(c).iushrn(this.shift);
  27109. var res = u;
  27110. if (u.cmp(this.m) >= 0) {
  27111. res = u.isub(this.m);
  27112. } else if (u.cmpn(0) < 0) {
  27113. res = u.iadd(this.m);
  27114. }
  27115. return res._forceRed(this);
  27116. };
  27117. Mont.prototype.invm = function invm (a) {
  27118. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  27119. var res = this.imod(a._invmp(this.m).mul(this.r2));
  27120. return res._forceRed(this);
  27121. };
  27122. })( false || module, this);
  27123. /***/ }),
  27124. /***/ "./node_modules/create-hash/browser.js":
  27125. /*!*********************************************!*\
  27126. !*** ./node_modules/create-hash/browser.js ***!
  27127. \*********************************************/
  27128. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27129. "use strict";
  27130. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  27131. var MD5 = __webpack_require__(/*! md5.js */ "./node_modules/md5.js/index.js")
  27132. var RIPEMD160 = __webpack_require__(/*! ripemd160 */ "./node_modules/ripemd160/index.js")
  27133. var sha = __webpack_require__(/*! sha.js */ "./node_modules/sha.js/index.js")
  27134. var Base = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  27135. function Hash (hash) {
  27136. Base.call(this, 'digest')
  27137. this._hash = hash
  27138. }
  27139. inherits(Hash, Base)
  27140. Hash.prototype._update = function (data) {
  27141. this._hash.update(data)
  27142. }
  27143. Hash.prototype._final = function () {
  27144. return this._hash.digest()
  27145. }
  27146. module.exports = function createHash (alg) {
  27147. alg = alg.toLowerCase()
  27148. if (alg === 'md5') return new MD5()
  27149. if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
  27150. return new Hash(sha(alg))
  27151. }
  27152. /***/ }),
  27153. /***/ "./node_modules/create-hash/md5.js":
  27154. /*!*****************************************!*\
  27155. !*** ./node_modules/create-hash/md5.js ***!
  27156. \*****************************************/
  27157. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27158. var MD5 = __webpack_require__(/*! md5.js */ "./node_modules/md5.js/index.js")
  27159. module.exports = function (buffer) {
  27160. return new MD5().update(buffer).digest()
  27161. }
  27162. /***/ }),
  27163. /***/ "./node_modules/create-hmac/browser.js":
  27164. /*!*********************************************!*\
  27165. !*** ./node_modules/create-hmac/browser.js ***!
  27166. \*********************************************/
  27167. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27168. "use strict";
  27169. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  27170. var Legacy = __webpack_require__(/*! ./legacy */ "./node_modules/create-hmac/legacy.js")
  27171. var Base = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  27172. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  27173. var md5 = __webpack_require__(/*! create-hash/md5 */ "./node_modules/create-hash/md5.js")
  27174. var RIPEMD160 = __webpack_require__(/*! ripemd160 */ "./node_modules/ripemd160/index.js")
  27175. var sha = __webpack_require__(/*! sha.js */ "./node_modules/sha.js/index.js")
  27176. var ZEROS = Buffer.alloc(128)
  27177. function Hmac (alg, key) {
  27178. Base.call(this, 'digest')
  27179. if (typeof key === 'string') {
  27180. key = Buffer.from(key)
  27181. }
  27182. var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
  27183. this._alg = alg
  27184. this._key = key
  27185. if (key.length > blocksize) {
  27186. var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
  27187. key = hash.update(key).digest()
  27188. } else if (key.length < blocksize) {
  27189. key = Buffer.concat([key, ZEROS], blocksize)
  27190. }
  27191. var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
  27192. var opad = this._opad = Buffer.allocUnsafe(blocksize)
  27193. for (var i = 0; i < blocksize; i++) {
  27194. ipad[i] = key[i] ^ 0x36
  27195. opad[i] = key[i] ^ 0x5C
  27196. }
  27197. this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
  27198. this._hash.update(ipad)
  27199. }
  27200. inherits(Hmac, Base)
  27201. Hmac.prototype._update = function (data) {
  27202. this._hash.update(data)
  27203. }
  27204. Hmac.prototype._final = function () {
  27205. var h = this._hash.digest()
  27206. var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
  27207. return hash.update(this._opad).update(h).digest()
  27208. }
  27209. module.exports = function createHmac (alg, key) {
  27210. alg = alg.toLowerCase()
  27211. if (alg === 'rmd160' || alg === 'ripemd160') {
  27212. return new Hmac('rmd160', key)
  27213. }
  27214. if (alg === 'md5') {
  27215. return new Legacy(md5, key)
  27216. }
  27217. return new Hmac(alg, key)
  27218. }
  27219. /***/ }),
  27220. /***/ "./node_modules/create-hmac/legacy.js":
  27221. /*!********************************************!*\
  27222. !*** ./node_modules/create-hmac/legacy.js ***!
  27223. \********************************************/
  27224. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27225. "use strict";
  27226. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  27227. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  27228. var Base = __webpack_require__(/*! cipher-base */ "./node_modules/cipher-base/index.js")
  27229. var ZEROS = Buffer.alloc(128)
  27230. var blocksize = 64
  27231. function Hmac (alg, key) {
  27232. Base.call(this, 'digest')
  27233. if (typeof key === 'string') {
  27234. key = Buffer.from(key)
  27235. }
  27236. this._alg = alg
  27237. this._key = key
  27238. if (key.length > blocksize) {
  27239. key = alg(key)
  27240. } else if (key.length < blocksize) {
  27241. key = Buffer.concat([key, ZEROS], blocksize)
  27242. }
  27243. var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
  27244. var opad = this._opad = Buffer.allocUnsafe(blocksize)
  27245. for (var i = 0; i < blocksize; i++) {
  27246. ipad[i] = key[i] ^ 0x36
  27247. opad[i] = key[i] ^ 0x5C
  27248. }
  27249. this._hash = [ipad]
  27250. }
  27251. inherits(Hmac, Base)
  27252. Hmac.prototype._update = function (data) {
  27253. this._hash.push(data)
  27254. }
  27255. Hmac.prototype._final = function () {
  27256. var h = this._alg(Buffer.concat(this._hash))
  27257. return this._alg(Buffer.concat([this._opad, h]))
  27258. }
  27259. module.exports = Hmac
  27260. /***/ }),
  27261. /***/ "./node_modules/crossfilter/crossfilter.js":
  27262. /*!*************************************************!*\
  27263. !*** ./node_modules/crossfilter/crossfilter.js ***!
  27264. \*************************************************/
  27265. /***/ (function(__unused_webpack_module, exports) {
  27266. (function(exports){
  27267. crossfilter.version = "1.3.12";
  27268. function crossfilter_identity(d) {
  27269. return d;
  27270. }
  27271. crossfilter.permute = permute;
  27272. function permute(array, index) {
  27273. for (var i = 0, n = index.length, copy = new Array(n); i < n; ++i) {
  27274. copy[i] = array[index[i]];
  27275. }
  27276. return copy;
  27277. }
  27278. var bisect = crossfilter.bisect = bisect_by(crossfilter_identity);
  27279. bisect.by = bisect_by;
  27280. function bisect_by(f) {
  27281. // Locate the insertion point for x in a to maintain sorted order. The
  27282. // arguments lo and hi may be used to specify a subset of the array which
  27283. // should be considered; by default the entire array is used. If x is already
  27284. // present in a, the insertion point will be before (to the left of) any
  27285. // existing entries. The return value is suitable for use as the first
  27286. // argument to `array.splice` assuming that a is already sorted.
  27287. //
  27288. // The returned insertion point i partitions the array a into two halves so
  27289. // that all v < x for v in a[lo:i] for the left side and all v >= x for v in
  27290. // a[i:hi] for the right side.
  27291. function bisectLeft(a, x, lo, hi) {
  27292. while (lo < hi) {
  27293. var mid = lo + hi >>> 1;
  27294. if (f(a[mid]) < x) lo = mid + 1;
  27295. else hi = mid;
  27296. }
  27297. return lo;
  27298. }
  27299. // Similar to bisectLeft, but returns an insertion point which comes after (to
  27300. // the right of) any existing entries of x in a.
  27301. //
  27302. // The returned insertion point i partitions the array into two halves so that
  27303. // all v <= x for v in a[lo:i] for the left side and all v > x for v in
  27304. // a[i:hi] for the right side.
  27305. function bisectRight(a, x, lo, hi) {
  27306. while (lo < hi) {
  27307. var mid = lo + hi >>> 1;
  27308. if (x < f(a[mid])) hi = mid;
  27309. else lo = mid + 1;
  27310. }
  27311. return lo;
  27312. }
  27313. bisectRight.right = bisectRight;
  27314. bisectRight.left = bisectLeft;
  27315. return bisectRight;
  27316. }
  27317. var heap = crossfilter.heap = heap_by(crossfilter_identity);
  27318. heap.by = heap_by;
  27319. function heap_by(f) {
  27320. // Builds a binary heap within the specified array a[lo:hi]. The heap has the
  27321. // property such that the parent a[lo+i] is always less than or equal to its
  27322. // two children: a[lo+2*i+1] and a[lo+2*i+2].
  27323. function heap(a, lo, hi) {
  27324. var n = hi - lo,
  27325. i = (n >>> 1) + 1;
  27326. while (--i > 0) sift(a, i, n, lo);
  27327. return a;
  27328. }
  27329. // Sorts the specified array a[lo:hi] in descending order, assuming it is
  27330. // already a heap.
  27331. function sort(a, lo, hi) {
  27332. var n = hi - lo,
  27333. t;
  27334. while (--n > 0) t = a[lo], a[lo] = a[lo + n], a[lo + n] = t, sift(a, 1, n, lo);
  27335. return a;
  27336. }
  27337. // Sifts the element a[lo+i-1] down the heap, where the heap is the contiguous
  27338. // slice of array a[lo:lo+n]. This method can also be used to update the heap
  27339. // incrementally, without incurring the full cost of reconstructing the heap.
  27340. function sift(a, i, n, lo) {
  27341. var d = a[--lo + i],
  27342. x = f(d),
  27343. child;
  27344. while ((child = i << 1) <= n) {
  27345. if (child < n && f(a[lo + child]) > f(a[lo + child + 1])) child++;
  27346. if (x <= f(a[lo + child])) break;
  27347. a[lo + i] = a[lo + child];
  27348. i = child;
  27349. }
  27350. a[lo + i] = d;
  27351. }
  27352. heap.sort = sort;
  27353. return heap;
  27354. }
  27355. var heapselect = crossfilter.heapselect = heapselect_by(crossfilter_identity);
  27356. heapselect.by = heapselect_by;
  27357. function heapselect_by(f) {
  27358. var heap = heap_by(f);
  27359. // Returns a new array containing the top k elements in the array a[lo:hi].
  27360. // The returned array is not sorted, but maintains the heap property. If k is
  27361. // greater than hi - lo, then fewer than k elements will be returned. The
  27362. // order of elements in a is unchanged by this operation.
  27363. function heapselect(a, lo, hi, k) {
  27364. var queue = new Array(k = Math.min(hi - lo, k)),
  27365. min,
  27366. i,
  27367. x,
  27368. d;
  27369. for (i = 0; i < k; ++i) queue[i] = a[lo++];
  27370. heap(queue, 0, k);
  27371. if (lo < hi) {
  27372. min = f(queue[0]);
  27373. do {
  27374. if (x = f(d = a[lo]) > min) {
  27375. queue[0] = d;
  27376. min = f(heap(queue, 0, k)[0]);
  27377. }
  27378. } while (++lo < hi);
  27379. }
  27380. return queue;
  27381. }
  27382. return heapselect;
  27383. }
  27384. var insertionsort = crossfilter.insertionsort = insertionsort_by(crossfilter_identity);
  27385. insertionsort.by = insertionsort_by;
  27386. function insertionsort_by(f) {
  27387. function insertionsort(a, lo, hi) {
  27388. for (var i = lo + 1; i < hi; ++i) {
  27389. for (var j = i, t = a[i], x = f(t); j > lo && f(a[j - 1]) > x; --j) {
  27390. a[j] = a[j - 1];
  27391. }
  27392. a[j] = t;
  27393. }
  27394. return a;
  27395. }
  27396. return insertionsort;
  27397. }
  27398. // Algorithm designed by Vladimir Yaroslavskiy.
  27399. // Implementation based on the Dart project; see lib/dart/LICENSE for details.
  27400. var quicksort = crossfilter.quicksort = quicksort_by(crossfilter_identity);
  27401. quicksort.by = quicksort_by;
  27402. function quicksort_by(f) {
  27403. var insertionsort = insertionsort_by(f);
  27404. function sort(a, lo, hi) {
  27405. return (hi - lo < quicksort_sizeThreshold
  27406. ? insertionsort
  27407. : quicksort)(a, lo, hi);
  27408. }
  27409. function quicksort(a, lo, hi) {
  27410. // Compute the two pivots by looking at 5 elements.
  27411. var sixth = (hi - lo) / 6 | 0,
  27412. i1 = lo + sixth,
  27413. i5 = hi - 1 - sixth,
  27414. i3 = lo + hi - 1 >> 1, // The midpoint.
  27415. i2 = i3 - sixth,
  27416. i4 = i3 + sixth;
  27417. var e1 = a[i1], x1 = f(e1),
  27418. e2 = a[i2], x2 = f(e2),
  27419. e3 = a[i3], x3 = f(e3),
  27420. e4 = a[i4], x4 = f(e4),
  27421. e5 = a[i5], x5 = f(e5);
  27422. var t;
  27423. // Sort the selected 5 elements using a sorting network.
  27424. if (x1 > x2) t = e1, e1 = e2, e2 = t, t = x1, x1 = x2, x2 = t;
  27425. if (x4 > x5) t = e4, e4 = e5, e5 = t, t = x4, x4 = x5, x5 = t;
  27426. if (x1 > x3) t = e1, e1 = e3, e3 = t, t = x1, x1 = x3, x3 = t;
  27427. if (x2 > x3) t = e2, e2 = e3, e3 = t, t = x2, x2 = x3, x3 = t;
  27428. if (x1 > x4) t = e1, e1 = e4, e4 = t, t = x1, x1 = x4, x4 = t;
  27429. if (x3 > x4) t = e3, e3 = e4, e4 = t, t = x3, x3 = x4, x4 = t;
  27430. if (x2 > x5) t = e2, e2 = e5, e5 = t, t = x2, x2 = x5, x5 = t;
  27431. if (x2 > x3) t = e2, e2 = e3, e3 = t, t = x2, x2 = x3, x3 = t;
  27432. if (x4 > x5) t = e4, e4 = e5, e5 = t, t = x4, x4 = x5, x5 = t;
  27433. var pivot1 = e2, pivotValue1 = x2,
  27434. pivot2 = e4, pivotValue2 = x4;
  27435. // e2 and e4 have been saved in the pivot variables. They will be written
  27436. // back, once the partitioning is finished.
  27437. a[i1] = e1;
  27438. a[i2] = a[lo];
  27439. a[i3] = e3;
  27440. a[i4] = a[hi - 1];
  27441. a[i5] = e5;
  27442. var less = lo + 1, // First element in the middle partition.
  27443. great = hi - 2; // Last element in the middle partition.
  27444. // Note that for value comparison, <, <=, >= and > coerce to a primitive via
  27445. // Object.prototype.valueOf; == and === do not, so in order to be consistent
  27446. // with natural order (such as for Date objects), we must do two compares.
  27447. var pivotsEqual = pivotValue1 <= pivotValue2 && pivotValue1 >= pivotValue2;
  27448. if (pivotsEqual) {
  27449. // Degenerated case where the partitioning becomes a dutch national flag
  27450. // problem.
  27451. //
  27452. // [ | < pivot | == pivot | unpartitioned | > pivot | ]
  27453. // ^ ^ ^ ^ ^
  27454. // left less k great right
  27455. //
  27456. // a[left] and a[right] are undefined and are filled after the
  27457. // partitioning.
  27458. //
  27459. // Invariants:
  27460. // 1) for x in ]left, less[ : x < pivot.
  27461. // 2) for x in [less, k[ : x == pivot.
  27462. // 3) for x in ]great, right[ : x > pivot.
  27463. for (var k = less; k <= great; ++k) {
  27464. var ek = a[k], xk = f(ek);
  27465. if (xk < pivotValue1) {
  27466. if (k !== less) {
  27467. a[k] = a[less];
  27468. a[less] = ek;
  27469. }
  27470. ++less;
  27471. } else if (xk > pivotValue1) {
  27472. // Find the first element <= pivot in the range [k - 1, great] and
  27473. // put [:ek:] there. We know that such an element must exist:
  27474. // When k == less, then el3 (which is equal to pivot) lies in the
  27475. // interval. Otherwise a[k - 1] == pivot and the search stops at k-1.
  27476. // Note that in the latter case invariant 2 will be violated for a
  27477. // short amount of time. The invariant will be restored when the
  27478. // pivots are put into their final positions.
  27479. while (true) {
  27480. var greatValue = f(a[great]);
  27481. if (greatValue > pivotValue1) {
  27482. great--;
  27483. // This is the only location in the while-loop where a new
  27484. // iteration is started.
  27485. continue;
  27486. } else if (greatValue < pivotValue1) {
  27487. // Triple exchange.
  27488. a[k] = a[less];
  27489. a[less++] = a[great];
  27490. a[great--] = ek;
  27491. break;
  27492. } else {
  27493. a[k] = a[great];
  27494. a[great--] = ek;
  27495. // Note: if great < k then we will exit the outer loop and fix
  27496. // invariant 2 (which we just violated).
  27497. break;
  27498. }
  27499. }
  27500. }
  27501. }
  27502. } else {
  27503. // We partition the list into three parts:
  27504. // 1. < pivot1
  27505. // 2. >= pivot1 && <= pivot2
  27506. // 3. > pivot2
  27507. //
  27508. // During the loop we have:
  27509. // [ | < pivot1 | >= pivot1 && <= pivot2 | unpartitioned | > pivot2 | ]
  27510. // ^ ^ ^ ^ ^
  27511. // left less k great right
  27512. //
  27513. // a[left] and a[right] are undefined and are filled after the
  27514. // partitioning.
  27515. //
  27516. // Invariants:
  27517. // 1. for x in ]left, less[ : x < pivot1
  27518. // 2. for x in [less, k[ : pivot1 <= x && x <= pivot2
  27519. // 3. for x in ]great, right[ : x > pivot2
  27520. for (var k = less; k <= great; k++) {
  27521. var ek = a[k], xk = f(ek);
  27522. if (xk < pivotValue1) {
  27523. if (k !== less) {
  27524. a[k] = a[less];
  27525. a[less] = ek;
  27526. }
  27527. ++less;
  27528. } else {
  27529. if (xk > pivotValue2) {
  27530. while (true) {
  27531. var greatValue = f(a[great]);
  27532. if (greatValue > pivotValue2) {
  27533. great--;
  27534. if (great < k) break;
  27535. // This is the only location inside the loop where a new
  27536. // iteration is started.
  27537. continue;
  27538. } else {
  27539. // a[great] <= pivot2.
  27540. if (greatValue < pivotValue1) {
  27541. // Triple exchange.
  27542. a[k] = a[less];
  27543. a[less++] = a[great];
  27544. a[great--] = ek;
  27545. } else {
  27546. // a[great] >= pivot1.
  27547. a[k] = a[great];
  27548. a[great--] = ek;
  27549. }
  27550. break;
  27551. }
  27552. }
  27553. }
  27554. }
  27555. }
  27556. }
  27557. // Move pivots into their final positions.
  27558. // We shrunk the list from both sides (a[left] and a[right] have
  27559. // meaningless values in them) and now we move elements from the first
  27560. // and third partition into these locations so that we can store the
  27561. // pivots.
  27562. a[lo] = a[less - 1];
  27563. a[less - 1] = pivot1;
  27564. a[hi - 1] = a[great + 1];
  27565. a[great + 1] = pivot2;
  27566. // The list is now partitioned into three partitions:
  27567. // [ < pivot1 | >= pivot1 && <= pivot2 | > pivot2 ]
  27568. // ^ ^ ^ ^
  27569. // left less great right
  27570. // Recursive descent. (Don't include the pivot values.)
  27571. sort(a, lo, less - 1);
  27572. sort(a, great + 2, hi);
  27573. if (pivotsEqual) {
  27574. // All elements in the second partition are equal to the pivot. No
  27575. // need to sort them.
  27576. return a;
  27577. }
  27578. // In theory it should be enough to call _doSort recursively on the second
  27579. // partition.
  27580. // The Android source however removes the pivot elements from the recursive
  27581. // call if the second partition is too large (more than 2/3 of the list).
  27582. if (less < i1 && great > i5) {
  27583. var lessValue, greatValue;
  27584. while ((lessValue = f(a[less])) <= pivotValue1 && lessValue >= pivotValue1) ++less;
  27585. while ((greatValue = f(a[great])) <= pivotValue2 && greatValue >= pivotValue2) --great;
  27586. // Copy paste of the previous 3-way partitioning with adaptions.
  27587. //
  27588. // We partition the list into three parts:
  27589. // 1. == pivot1
  27590. // 2. > pivot1 && < pivot2
  27591. // 3. == pivot2
  27592. //
  27593. // During the loop we have:
  27594. // [ == pivot1 | > pivot1 && < pivot2 | unpartitioned | == pivot2 ]
  27595. // ^ ^ ^
  27596. // less k great
  27597. //
  27598. // Invariants:
  27599. // 1. for x in [ *, less[ : x == pivot1
  27600. // 2. for x in [less, k[ : pivot1 < x && x < pivot2
  27601. // 3. for x in ]great, * ] : x == pivot2
  27602. for (var k = less; k <= great; k++) {
  27603. var ek = a[k], xk = f(ek);
  27604. if (xk <= pivotValue1 && xk >= pivotValue1) {
  27605. if (k !== less) {
  27606. a[k] = a[less];
  27607. a[less] = ek;
  27608. }
  27609. less++;
  27610. } else {
  27611. if (xk <= pivotValue2 && xk >= pivotValue2) {
  27612. while (true) {
  27613. var greatValue = f(a[great]);
  27614. if (greatValue <= pivotValue2 && greatValue >= pivotValue2) {
  27615. great--;
  27616. if (great < k) break;
  27617. // This is the only location inside the loop where a new
  27618. // iteration is started.
  27619. continue;
  27620. } else {
  27621. // a[great] < pivot2.
  27622. if (greatValue < pivotValue1) {
  27623. // Triple exchange.
  27624. a[k] = a[less];
  27625. a[less++] = a[great];
  27626. a[great--] = ek;
  27627. } else {
  27628. // a[great] == pivot1.
  27629. a[k] = a[great];
  27630. a[great--] = ek;
  27631. }
  27632. break;
  27633. }
  27634. }
  27635. }
  27636. }
  27637. }
  27638. }
  27639. // The second partition has now been cleared of pivot elements and looks
  27640. // as follows:
  27641. // [ * | > pivot1 && < pivot2 | * ]
  27642. // ^ ^
  27643. // less great
  27644. // Sort the second partition using recursive descent.
  27645. // The second partition looks as follows:
  27646. // [ * | >= pivot1 && <= pivot2 | * ]
  27647. // ^ ^
  27648. // less great
  27649. // Simply sort it by recursive descent.
  27650. return sort(a, less, great + 1);
  27651. }
  27652. return sort;
  27653. }
  27654. var quicksort_sizeThreshold = 32;
  27655. var crossfilter_array8 = crossfilter_arrayUntyped,
  27656. crossfilter_array16 = crossfilter_arrayUntyped,
  27657. crossfilter_array32 = crossfilter_arrayUntyped,
  27658. crossfilter_arrayLengthen = crossfilter_arrayLengthenUntyped,
  27659. crossfilter_arrayWiden = crossfilter_arrayWidenUntyped;
  27660. if (typeof Uint8Array !== "undefined") {
  27661. crossfilter_array8 = function(n) { return new Uint8Array(n); };
  27662. crossfilter_array16 = function(n) { return new Uint16Array(n); };
  27663. crossfilter_array32 = function(n) { return new Uint32Array(n); };
  27664. crossfilter_arrayLengthen = function(array, length) {
  27665. if (array.length >= length) return array;
  27666. var copy = new array.constructor(length);
  27667. copy.set(array);
  27668. return copy;
  27669. };
  27670. crossfilter_arrayWiden = function(array, width) {
  27671. var copy;
  27672. switch (width) {
  27673. case 16: copy = crossfilter_array16(array.length); break;
  27674. case 32: copy = crossfilter_array32(array.length); break;
  27675. default: throw new Error("invalid array width!");
  27676. }
  27677. copy.set(array);
  27678. return copy;
  27679. };
  27680. }
  27681. function crossfilter_arrayUntyped(n) {
  27682. var array = new Array(n), i = -1;
  27683. while (++i < n) array[i] = 0;
  27684. return array;
  27685. }
  27686. function crossfilter_arrayLengthenUntyped(array, length) {
  27687. var n = array.length;
  27688. while (n < length) array[n++] = 0;
  27689. return array;
  27690. }
  27691. function crossfilter_arrayWidenUntyped(array, width) {
  27692. if (width > 32) throw new Error("invalid array width!");
  27693. return array;
  27694. }
  27695. function crossfilter_filterExact(bisect, value) {
  27696. return function(values) {
  27697. var n = values.length;
  27698. return [bisect.left(values, value, 0, n), bisect.right(values, value, 0, n)];
  27699. };
  27700. }
  27701. function crossfilter_filterRange(bisect, range) {
  27702. var min = range[0],
  27703. max = range[1];
  27704. return function(values) {
  27705. var n = values.length;
  27706. return [bisect.left(values, min, 0, n), bisect.left(values, max, 0, n)];
  27707. };
  27708. }
  27709. function crossfilter_filterAll(values) {
  27710. return [0, values.length];
  27711. }
  27712. function crossfilter_null() {
  27713. return null;
  27714. }
  27715. function crossfilter_zero() {
  27716. return 0;
  27717. }
  27718. function crossfilter_reduceIncrement(p) {
  27719. return p + 1;
  27720. }
  27721. function crossfilter_reduceDecrement(p) {
  27722. return p - 1;
  27723. }
  27724. function crossfilter_reduceAdd(f) {
  27725. return function(p, v) {
  27726. return p + +f(v);
  27727. };
  27728. }
  27729. function crossfilter_reduceSubtract(f) {
  27730. return function(p, v) {
  27731. return p - f(v);
  27732. };
  27733. }
  27734. exports.crossfilter = crossfilter;
  27735. function crossfilter() {
  27736. var crossfilter = {
  27737. add: add,
  27738. remove: removeData,
  27739. dimension: dimension,
  27740. groupAll: groupAll,
  27741. size: size
  27742. };
  27743. var data = [], // the records
  27744. n = 0, // the number of records; data.length
  27745. m = 0, // a bit mask representing which dimensions are in use
  27746. M = 8, // number of dimensions that can fit in `filters`
  27747. filters = crossfilter_array8(0), // M bits per record; 1 is filtered out
  27748. filterListeners = [], // when the filters change
  27749. dataListeners = [], // when data is added
  27750. removeDataListeners = []; // when data is removed
  27751. // Adds the specified new records to this crossfilter.
  27752. function add(newData) {
  27753. var n0 = n,
  27754. n1 = newData.length;
  27755. // If there's actually new data to add…
  27756. // Merge the new data into the existing data.
  27757. // Lengthen the filter bitset to handle the new records.
  27758. // Notify listeners (dimensions and groups) that new data is available.
  27759. if (n1) {
  27760. data = data.concat(newData);
  27761. filters = crossfilter_arrayLengthen(filters, n += n1);
  27762. dataListeners.forEach(function(l) { l(newData, n0, n1); });
  27763. }
  27764. return crossfilter;
  27765. }
  27766. // Removes all records that match the current filters.
  27767. function removeData() {
  27768. var newIndex = crossfilter_index(n, n),
  27769. removed = [];
  27770. for (var i = 0, j = 0; i < n; ++i) {
  27771. if (filters[i]) newIndex[i] = j++;
  27772. else removed.push(i);
  27773. }
  27774. // Remove all matching records from groups.
  27775. filterListeners.forEach(function(l) { l(0, [], removed); });
  27776. // Update indexes.
  27777. removeDataListeners.forEach(function(l) { l(newIndex); });
  27778. // Remove old filters and data by overwriting.
  27779. for (var i = 0, j = 0, k; i < n; ++i) {
  27780. if (k = filters[i]) {
  27781. if (i !== j) filters[j] = k, data[j] = data[i];
  27782. ++j;
  27783. }
  27784. }
  27785. data.length = j;
  27786. while (n > j) filters[--n] = 0;
  27787. }
  27788. // Adds a new dimension with the specified value accessor function.
  27789. function dimension(value) {
  27790. var dimension = {
  27791. filter: filter,
  27792. filterExact: filterExact,
  27793. filterRange: filterRange,
  27794. filterFunction: filterFunction,
  27795. filterAll: filterAll,
  27796. top: top,
  27797. bottom: bottom,
  27798. group: group,
  27799. groupAll: groupAll,
  27800. dispose: dispose,
  27801. remove: dispose // for backwards-compatibility
  27802. };
  27803. var one = ~m & -~m, // lowest unset bit as mask, e.g., 00001000
  27804. zero = ~one, // inverted one, e.g., 11110111
  27805. values, // sorted, cached array
  27806. index, // value rank ↦ object id
  27807. newValues, // temporary array storing newly-added values
  27808. newIndex, // temporary array storing newly-added index
  27809. sort = quicksort_by(function(i) { return newValues[i]; }),
  27810. refilter = crossfilter_filterAll, // for recomputing filter
  27811. refilterFunction, // the custom filter function in use
  27812. indexListeners = [], // when data is added
  27813. dimensionGroups = [],
  27814. lo0 = 0,
  27815. hi0 = 0;
  27816. // Updating a dimension is a two-stage process. First, we must update the
  27817. // associated filters for the newly-added records. Once all dimensions have
  27818. // updated their filters, the groups are notified to update.
  27819. dataListeners.unshift(preAdd);
  27820. dataListeners.push(postAdd);
  27821. removeDataListeners.push(removeData);
  27822. // Incorporate any existing data into this dimension, and make sure that the
  27823. // filter bitset is wide enough to handle the new dimension.
  27824. m |= one;
  27825. if (M >= 32 ? !one : m & -(1 << M)) {
  27826. filters = crossfilter_arrayWiden(filters, M <<= 1);
  27827. }
  27828. preAdd(data, 0, n);
  27829. postAdd(data, 0, n);
  27830. // Incorporates the specified new records into this dimension.
  27831. // This function is responsible for updating filters, values, and index.
  27832. function preAdd(newData, n0, n1) {
  27833. // Permute new values into natural order using a sorted index.
  27834. newValues = newData.map(value);
  27835. newIndex = sort(crossfilter_range(n1), 0, n1);
  27836. newValues = permute(newValues, newIndex);
  27837. // Bisect newValues to determine which new records are selected.
  27838. var bounds = refilter(newValues), lo1 = bounds[0], hi1 = bounds[1], i;
  27839. if (refilterFunction) {
  27840. for (i = 0; i < n1; ++i) {
  27841. if (!refilterFunction(newValues[i], i)) filters[newIndex[i] + n0] |= one;
  27842. }
  27843. } else {
  27844. for (i = 0; i < lo1; ++i) filters[newIndex[i] + n0] |= one;
  27845. for (i = hi1; i < n1; ++i) filters[newIndex[i] + n0] |= one;
  27846. }
  27847. // If this dimension previously had no data, then we don't need to do the
  27848. // more expensive merge operation; use the new values and index as-is.
  27849. if (!n0) {
  27850. values = newValues;
  27851. index = newIndex;
  27852. lo0 = lo1;
  27853. hi0 = hi1;
  27854. return;
  27855. }
  27856. var oldValues = values,
  27857. oldIndex = index,
  27858. i0 = 0,
  27859. i1 = 0;
  27860. // Otherwise, create new arrays into which to merge new and old.
  27861. values = new Array(n);
  27862. index = crossfilter_index(n, n);
  27863. // Merge the old and new sorted values, and old and new index.
  27864. for (i = 0; i0 < n0 && i1 < n1; ++i) {
  27865. if (oldValues[i0] < newValues[i1]) {
  27866. values[i] = oldValues[i0];
  27867. index[i] = oldIndex[i0++];
  27868. } else {
  27869. values[i] = newValues[i1];
  27870. index[i] = newIndex[i1++] + n0;
  27871. }
  27872. }
  27873. // Add any remaining old values.
  27874. for (; i0 < n0; ++i0, ++i) {
  27875. values[i] = oldValues[i0];
  27876. index[i] = oldIndex[i0];
  27877. }
  27878. // Add any remaining new values.
  27879. for (; i1 < n1; ++i1, ++i) {
  27880. values[i] = newValues[i1];
  27881. index[i] = newIndex[i1] + n0;
  27882. }
  27883. // Bisect again to recompute lo0 and hi0.
  27884. bounds = refilter(values), lo0 = bounds[0], hi0 = bounds[1];
  27885. }
  27886. // When all filters have updated, notify index listeners of the new values.
  27887. function postAdd(newData, n0, n1) {
  27888. indexListeners.forEach(function(l) { l(newValues, newIndex, n0, n1); });
  27889. newValues = newIndex = null;
  27890. }
  27891. function removeData(reIndex) {
  27892. for (var i = 0, j = 0, k; i < n; ++i) {
  27893. if (filters[k = index[i]]) {
  27894. if (i !== j) values[j] = values[i];
  27895. index[j] = reIndex[k];
  27896. ++j;
  27897. }
  27898. }
  27899. values.length = j;
  27900. while (j < n) index[j++] = 0;
  27901. // Bisect again to recompute lo0 and hi0.
  27902. var bounds = refilter(values);
  27903. lo0 = bounds[0], hi0 = bounds[1];
  27904. }
  27905. // Updates the selected values based on the specified bounds [lo, hi].
  27906. // This implementation is used by all the public filter methods.
  27907. function filterIndexBounds(bounds) {
  27908. var lo1 = bounds[0],
  27909. hi1 = bounds[1];
  27910. if (refilterFunction) {
  27911. refilterFunction = null;
  27912. filterIndexFunction(function(d, i) { return lo1 <= i && i < hi1; });
  27913. lo0 = lo1;
  27914. hi0 = hi1;
  27915. return dimension;
  27916. }
  27917. var i,
  27918. j,
  27919. k,
  27920. added = [],
  27921. removed = [];
  27922. // Fast incremental update based on previous lo index.
  27923. if (lo1 < lo0) {
  27924. for (i = lo1, j = Math.min(lo0, hi1); i < j; ++i) {
  27925. filters[k = index[i]] ^= one;
  27926. added.push(k);
  27927. }
  27928. } else if (lo1 > lo0) {
  27929. for (i = lo0, j = Math.min(lo1, hi0); i < j; ++i) {
  27930. filters[k = index[i]] ^= one;
  27931. removed.push(k);
  27932. }
  27933. }
  27934. // Fast incremental update based on previous hi index.
  27935. if (hi1 > hi0) {
  27936. for (i = Math.max(lo1, hi0), j = hi1; i < j; ++i) {
  27937. filters[k = index[i]] ^= one;
  27938. added.push(k);
  27939. }
  27940. } else if (hi1 < hi0) {
  27941. for (i = Math.max(lo0, hi1), j = hi0; i < j; ++i) {
  27942. filters[k = index[i]] ^= one;
  27943. removed.push(k);
  27944. }
  27945. }
  27946. lo0 = lo1;
  27947. hi0 = hi1;
  27948. filterListeners.forEach(function(l) { l(one, added, removed); });
  27949. return dimension;
  27950. }
  27951. // Filters this dimension using the specified range, value, or null.
  27952. // If the range is null, this is equivalent to filterAll.
  27953. // If the range is an array, this is equivalent to filterRange.
  27954. // Otherwise, this is equivalent to filterExact.
  27955. function filter(range) {
  27956. return range == null
  27957. ? filterAll() : Array.isArray(range)
  27958. ? filterRange(range) : typeof range === "function"
  27959. ? filterFunction(range)
  27960. : filterExact(range);
  27961. }
  27962. // Filters this dimension to select the exact value.
  27963. function filterExact(value) {
  27964. return filterIndexBounds((refilter = crossfilter_filterExact(bisect, value))(values));
  27965. }
  27966. // Filters this dimension to select the specified range [lo, hi].
  27967. // The lower bound is inclusive, and the upper bound is exclusive.
  27968. function filterRange(range) {
  27969. return filterIndexBounds((refilter = crossfilter_filterRange(bisect, range))(values));
  27970. }
  27971. // Clears any filters on this dimension.
  27972. function filterAll() {
  27973. return filterIndexBounds((refilter = crossfilter_filterAll)(values));
  27974. }
  27975. // Filters this dimension using an arbitrary function.
  27976. function filterFunction(f) {
  27977. refilter = crossfilter_filterAll;
  27978. filterIndexFunction(refilterFunction = f);
  27979. lo0 = 0;
  27980. hi0 = n;
  27981. return dimension;
  27982. }
  27983. function filterIndexFunction(f) {
  27984. var i,
  27985. k,
  27986. x,
  27987. added = [],
  27988. removed = [];
  27989. for (i = 0; i < n; ++i) {
  27990. if (!(filters[k = index[i]] & one) ^ !!(x = f(values[i], i))) {
  27991. if (x) filters[k] &= zero, added.push(k);
  27992. else filters[k] |= one, removed.push(k);
  27993. }
  27994. }
  27995. filterListeners.forEach(function(l) { l(one, added, removed); });
  27996. }
  27997. // Returns the top K selected records based on this dimension's order.
  27998. // Note: observes this dimension's filter, unlike group and groupAll.
  27999. function top(k) {
  28000. var array = [],
  28001. i = hi0,
  28002. j;
  28003. while (--i >= lo0 && k > 0) {
  28004. if (!filters[j = index[i]]) {
  28005. array.push(data[j]);
  28006. --k;
  28007. }
  28008. }
  28009. return array;
  28010. }
  28011. // Returns the bottom K selected records based on this dimension's order.
  28012. // Note: observes this dimension's filter, unlike group and groupAll.
  28013. function bottom(k) {
  28014. var array = [],
  28015. i = lo0,
  28016. j;
  28017. while (i < hi0 && k > 0) {
  28018. if (!filters[j = index[i]]) {
  28019. array.push(data[j]);
  28020. --k;
  28021. }
  28022. i++;
  28023. }
  28024. return array;
  28025. }
  28026. // Adds a new group to this dimension, using the specified key function.
  28027. function group(key) {
  28028. var group = {
  28029. top: top,
  28030. all: all,
  28031. reduce: reduce,
  28032. reduceCount: reduceCount,
  28033. reduceSum: reduceSum,
  28034. order: order,
  28035. orderNatural: orderNatural,
  28036. size: size,
  28037. dispose: dispose,
  28038. remove: dispose // for backwards-compatibility
  28039. };
  28040. // Ensure that this group will be removed when the dimension is removed.
  28041. dimensionGroups.push(group);
  28042. var groups, // array of {key, value}
  28043. groupIndex, // object id ↦ group id
  28044. groupWidth = 8,
  28045. groupCapacity = crossfilter_capacity(groupWidth),
  28046. k = 0, // cardinality
  28047. select,
  28048. heap,
  28049. reduceAdd,
  28050. reduceRemove,
  28051. reduceInitial,
  28052. update = crossfilter_null,
  28053. reset = crossfilter_null,
  28054. resetNeeded = true,
  28055. groupAll = key === crossfilter_null;
  28056. if (arguments.length < 1) key = crossfilter_identity;
  28057. // The group listens to the crossfilter for when any dimension changes, so
  28058. // that it can update the associated reduce values. It must also listen to
  28059. // the parent dimension for when data is added, and compute new keys.
  28060. filterListeners.push(update);
  28061. indexListeners.push(add);
  28062. removeDataListeners.push(removeData);
  28063. // Incorporate any existing data into the grouping.
  28064. add(values, index, 0, n);
  28065. // Incorporates the specified new values into this group.
  28066. // This function is responsible for updating groups and groupIndex.
  28067. function add(newValues, newIndex, n0, n1) {
  28068. var oldGroups = groups,
  28069. reIndex = crossfilter_index(k, groupCapacity),
  28070. add = reduceAdd,
  28071. initial = reduceInitial,
  28072. k0 = k, // old cardinality
  28073. i0 = 0, // index of old group
  28074. i1 = 0, // index of new record
  28075. j, // object id
  28076. g0, // old group
  28077. x0, // old key
  28078. x1, // new key
  28079. g, // group to add
  28080. x; // key of group to add
  28081. // If a reset is needed, we don't need to update the reduce values.
  28082. if (resetNeeded) add = initial = crossfilter_null;
  28083. // Reset the new groups (k is a lower bound).
  28084. // Also, make sure that groupIndex exists and is long enough.
  28085. groups = new Array(k), k = 0;
  28086. groupIndex = k0 > 1 ? crossfilter_arrayLengthen(groupIndex, n) : crossfilter_index(n, groupCapacity);
  28087. // Get the first old key (x0 of g0), if it exists.
  28088. if (k0) x0 = (g0 = oldGroups[0]).key;
  28089. // Find the first new key (x1), skipping NaN keys.
  28090. while (i1 < n1 && !((x1 = key(newValues[i1])) >= x1)) ++i1;
  28091. // While new keys remain…
  28092. while (i1 < n1) {
  28093. // Determine the lesser of the two current keys; new and old.
  28094. // If there are no old keys remaining, then always add the new key.
  28095. if (g0 && x0 <= x1) {
  28096. g = g0, x = x0;
  28097. // Record the new index of the old group.
  28098. reIndex[i0] = k;
  28099. // Retrieve the next old key.
  28100. if (g0 = oldGroups[++i0]) x0 = g0.key;
  28101. } else {
  28102. g = {key: x1, value: initial()}, x = x1;
  28103. }
  28104. // Add the lesser group.
  28105. groups[k] = g;
  28106. // Add any selected records belonging to the added group, while
  28107. // advancing the new key and populating the associated group index.
  28108. while (!(x1 > x)) {
  28109. groupIndex[j = newIndex[i1] + n0] = k;
  28110. if (!(filters[j] & zero)) g.value = add(g.value, data[j]);
  28111. if (++i1 >= n1) break;
  28112. x1 = key(newValues[i1]);
  28113. }
  28114. groupIncrement();
  28115. }
  28116. // Add any remaining old groups that were greater than all new keys.
  28117. // No incremental reduce is needed; these groups have no new records.
  28118. // Also record the new index of the old group.
  28119. while (i0 < k0) {
  28120. groups[reIndex[i0] = k] = oldGroups[i0++];
  28121. groupIncrement();
  28122. }
  28123. // If we added any new groups before any old groups,
  28124. // update the group index of all the old records.
  28125. if (k > i0) for (i0 = 0; i0 < n0; ++i0) {
  28126. groupIndex[i0] = reIndex[groupIndex[i0]];
  28127. }
  28128. // Modify the update and reset behavior based on the cardinality.
  28129. // If the cardinality is less than or equal to one, then the groupIndex
  28130. // is not needed. If the cardinality is zero, then there are no records
  28131. // and therefore no groups to update or reset. Note that we also must
  28132. // change the registered listener to point to the new method.
  28133. j = filterListeners.indexOf(update);
  28134. if (k > 1) {
  28135. update = updateMany;
  28136. reset = resetMany;
  28137. } else {
  28138. if (!k && groupAll) {
  28139. k = 1;
  28140. groups = [{key: null, value: initial()}];
  28141. }
  28142. if (k === 1) {
  28143. update = updateOne;
  28144. reset = resetOne;
  28145. } else {
  28146. update = crossfilter_null;
  28147. reset = crossfilter_null;
  28148. }
  28149. groupIndex = null;
  28150. }
  28151. filterListeners[j] = update;
  28152. // Count the number of added groups,
  28153. // and widen the group index as needed.
  28154. function groupIncrement() {
  28155. if (++k === groupCapacity) {
  28156. reIndex = crossfilter_arrayWiden(reIndex, groupWidth <<= 1);
  28157. groupIndex = crossfilter_arrayWiden(groupIndex, groupWidth);
  28158. groupCapacity = crossfilter_capacity(groupWidth);
  28159. }
  28160. }
  28161. }
  28162. function removeData() {
  28163. if (k > 1) {
  28164. var oldK = k,
  28165. oldGroups = groups,
  28166. seenGroups = crossfilter_index(oldK, oldK);
  28167. // Filter out non-matches by copying matching group index entries to
  28168. // the beginning of the array.
  28169. for (var i = 0, j = 0; i < n; ++i) {
  28170. if (filters[i]) {
  28171. seenGroups[groupIndex[j] = groupIndex[i]] = 1;
  28172. ++j;
  28173. }
  28174. }
  28175. // Reassemble groups including only those groups that were referred
  28176. // to by matching group index entries. Note the new group index in
  28177. // seenGroups.
  28178. groups = [], k = 0;
  28179. for (i = 0; i < oldK; ++i) {
  28180. if (seenGroups[i]) {
  28181. seenGroups[i] = k++;
  28182. groups.push(oldGroups[i]);
  28183. }
  28184. }
  28185. if (k > 1) {
  28186. // Reindex the group index using seenGroups to find the new index.
  28187. for (var i = 0; i < j; ++i) groupIndex[i] = seenGroups[groupIndex[i]];
  28188. } else {
  28189. groupIndex = null;
  28190. }
  28191. filterListeners[filterListeners.indexOf(update)] = k > 1
  28192. ? (reset = resetMany, update = updateMany)
  28193. : k === 1 ? (reset = resetOne, update = updateOne)
  28194. : reset = update = crossfilter_null;
  28195. } else if (k === 1) {
  28196. if (groupAll) return;
  28197. for (var i = 0; i < n; ++i) if (filters[i]) return;
  28198. groups = [], k = 0;
  28199. filterListeners[filterListeners.indexOf(update)] =
  28200. update = reset = crossfilter_null;
  28201. }
  28202. }
  28203. // Reduces the specified selected or deselected records.
  28204. // This function is only used when the cardinality is greater than 1.
  28205. function updateMany(filterOne, added, removed) {
  28206. if (filterOne === one || resetNeeded) return;
  28207. var i,
  28208. k,
  28209. n,
  28210. g;
  28211. // Add the added values.
  28212. for (i = 0, n = added.length; i < n; ++i) {
  28213. if (!(filters[k = added[i]] & zero)) {
  28214. g = groups[groupIndex[k]];
  28215. g.value = reduceAdd(g.value, data[k]);
  28216. }
  28217. }
  28218. // Remove the removed values.
  28219. for (i = 0, n = removed.length; i < n; ++i) {
  28220. if ((filters[k = removed[i]] & zero) === filterOne) {
  28221. g = groups[groupIndex[k]];
  28222. g.value = reduceRemove(g.value, data[k]);
  28223. }
  28224. }
  28225. }
  28226. // Reduces the specified selected or deselected records.
  28227. // This function is only used when the cardinality is 1.
  28228. function updateOne(filterOne, added, removed) {
  28229. if (filterOne === one || resetNeeded) return;
  28230. var i,
  28231. k,
  28232. n,
  28233. g = groups[0];
  28234. // Add the added values.
  28235. for (i = 0, n = added.length; i < n; ++i) {
  28236. if (!(filters[k = added[i]] & zero)) {
  28237. g.value = reduceAdd(g.value, data[k]);
  28238. }
  28239. }
  28240. // Remove the removed values.
  28241. for (i = 0, n = removed.length; i < n; ++i) {
  28242. if ((filters[k = removed[i]] & zero) === filterOne) {
  28243. g.value = reduceRemove(g.value, data[k]);
  28244. }
  28245. }
  28246. }
  28247. // Recomputes the group reduce values from scratch.
  28248. // This function is only used when the cardinality is greater than 1.
  28249. function resetMany() {
  28250. var i,
  28251. g;
  28252. // Reset all group values.
  28253. for (i = 0; i < k; ++i) {
  28254. groups[i].value = reduceInitial();
  28255. }
  28256. // Add any selected records.
  28257. for (i = 0; i < n; ++i) {
  28258. if (!(filters[i] & zero)) {
  28259. g = groups[groupIndex[i]];
  28260. g.value = reduceAdd(g.value, data[i]);
  28261. }
  28262. }
  28263. }
  28264. // Recomputes the group reduce values from scratch.
  28265. // This function is only used when the cardinality is 1.
  28266. function resetOne() {
  28267. var i,
  28268. g = groups[0];
  28269. // Reset the singleton group values.
  28270. g.value = reduceInitial();
  28271. // Add any selected records.
  28272. for (i = 0; i < n; ++i) {
  28273. if (!(filters[i] & zero)) {
  28274. g.value = reduceAdd(g.value, data[i]);
  28275. }
  28276. }
  28277. }
  28278. // Returns the array of group values, in the dimension's natural order.
  28279. function all() {
  28280. if (resetNeeded) reset(), resetNeeded = false;
  28281. return groups;
  28282. }
  28283. // Returns a new array containing the top K group values, in reduce order.
  28284. function top(k) {
  28285. var top = select(all(), 0, groups.length, k);
  28286. return heap.sort(top, 0, top.length);
  28287. }
  28288. // Sets the reduce behavior for this group to use the specified functions.
  28289. // This method lazily recomputes the reduce values, waiting until needed.
  28290. function reduce(add, remove, initial) {
  28291. reduceAdd = add;
  28292. reduceRemove = remove;
  28293. reduceInitial = initial;
  28294. resetNeeded = true;
  28295. return group;
  28296. }
  28297. // A convenience method for reducing by count.
  28298. function reduceCount() {
  28299. return reduce(crossfilter_reduceIncrement, crossfilter_reduceDecrement, crossfilter_zero);
  28300. }
  28301. // A convenience method for reducing by sum(value).
  28302. function reduceSum(value) {
  28303. return reduce(crossfilter_reduceAdd(value), crossfilter_reduceSubtract(value), crossfilter_zero);
  28304. }
  28305. // Sets the reduce order, using the specified accessor.
  28306. function order(value) {
  28307. select = heapselect_by(valueOf);
  28308. heap = heap_by(valueOf);
  28309. function valueOf(d) { return value(d.value); }
  28310. return group;
  28311. }
  28312. // A convenience method for natural ordering by reduce value.
  28313. function orderNatural() {
  28314. return order(crossfilter_identity);
  28315. }
  28316. // Returns the cardinality of this group, irrespective of any filters.
  28317. function size() {
  28318. return k;
  28319. }
  28320. // Removes this group and associated event listeners.
  28321. function dispose() {
  28322. var i = filterListeners.indexOf(update);
  28323. if (i >= 0) filterListeners.splice(i, 1);
  28324. i = indexListeners.indexOf(add);
  28325. if (i >= 0) indexListeners.splice(i, 1);
  28326. i = removeDataListeners.indexOf(removeData);
  28327. if (i >= 0) removeDataListeners.splice(i, 1);
  28328. return group;
  28329. }
  28330. return reduceCount().orderNatural();
  28331. }
  28332. // A convenience function for generating a singleton group.
  28333. function groupAll() {
  28334. var g = group(crossfilter_null), all = g.all;
  28335. delete g.all;
  28336. delete g.top;
  28337. delete g.order;
  28338. delete g.orderNatural;
  28339. delete g.size;
  28340. g.value = function() { return all()[0].value; };
  28341. return g;
  28342. }
  28343. // Removes this dimension and associated groups and event listeners.
  28344. function dispose() {
  28345. dimensionGroups.forEach(function(group) { group.dispose(); });
  28346. var i = dataListeners.indexOf(preAdd);
  28347. if (i >= 0) dataListeners.splice(i, 1);
  28348. i = dataListeners.indexOf(postAdd);
  28349. if (i >= 0) dataListeners.splice(i, 1);
  28350. i = removeDataListeners.indexOf(removeData);
  28351. if (i >= 0) removeDataListeners.splice(i, 1);
  28352. m &= zero;
  28353. return filterAll();
  28354. }
  28355. return dimension;
  28356. }
  28357. // A convenience method for groupAll on a dummy dimension.
  28358. // This implementation can be optimized since it always has cardinality 1.
  28359. function groupAll() {
  28360. var group = {
  28361. reduce: reduce,
  28362. reduceCount: reduceCount,
  28363. reduceSum: reduceSum,
  28364. value: value,
  28365. dispose: dispose,
  28366. remove: dispose // for backwards-compatibility
  28367. };
  28368. var reduceValue,
  28369. reduceAdd,
  28370. reduceRemove,
  28371. reduceInitial,
  28372. resetNeeded = true;
  28373. // The group listens to the crossfilter for when any dimension changes, so
  28374. // that it can update the reduce value. It must also listen to the parent
  28375. // dimension for when data is added.
  28376. filterListeners.push(update);
  28377. dataListeners.push(add);
  28378. // For consistency; actually a no-op since resetNeeded is true.
  28379. add(data, 0, n);
  28380. // Incorporates the specified new values into this group.
  28381. function add(newData, n0) {
  28382. var i;
  28383. if (resetNeeded) return;
  28384. // Add the added values.
  28385. for (i = n0; i < n; ++i) {
  28386. if (!filters[i]) {
  28387. reduceValue = reduceAdd(reduceValue, data[i]);
  28388. }
  28389. }
  28390. }
  28391. // Reduces the specified selected or deselected records.
  28392. function update(filterOne, added, removed) {
  28393. var i,
  28394. k,
  28395. n;
  28396. if (resetNeeded) return;
  28397. // Add the added values.
  28398. for (i = 0, n = added.length; i < n; ++i) {
  28399. if (!filters[k = added[i]]) {
  28400. reduceValue = reduceAdd(reduceValue, data[k]);
  28401. }
  28402. }
  28403. // Remove the removed values.
  28404. for (i = 0, n = removed.length; i < n; ++i) {
  28405. if (filters[k = removed[i]] === filterOne) {
  28406. reduceValue = reduceRemove(reduceValue, data[k]);
  28407. }
  28408. }
  28409. }
  28410. // Recomputes the group reduce value from scratch.
  28411. function reset() {
  28412. var i;
  28413. reduceValue = reduceInitial();
  28414. for (i = 0; i < n; ++i) {
  28415. if (!filters[i]) {
  28416. reduceValue = reduceAdd(reduceValue, data[i]);
  28417. }
  28418. }
  28419. }
  28420. // Sets the reduce behavior for this group to use the specified functions.
  28421. // This method lazily recomputes the reduce value, waiting until needed.
  28422. function reduce(add, remove, initial) {
  28423. reduceAdd = add;
  28424. reduceRemove = remove;
  28425. reduceInitial = initial;
  28426. resetNeeded = true;
  28427. return group;
  28428. }
  28429. // A convenience method for reducing by count.
  28430. function reduceCount() {
  28431. return reduce(crossfilter_reduceIncrement, crossfilter_reduceDecrement, crossfilter_zero);
  28432. }
  28433. // A convenience method for reducing by sum(value).
  28434. function reduceSum(value) {
  28435. return reduce(crossfilter_reduceAdd(value), crossfilter_reduceSubtract(value), crossfilter_zero);
  28436. }
  28437. // Returns the computed reduce value.
  28438. function value() {
  28439. if (resetNeeded) reset(), resetNeeded = false;
  28440. return reduceValue;
  28441. }
  28442. // Removes this group and associated event listeners.
  28443. function dispose() {
  28444. var i = filterListeners.indexOf(update);
  28445. if (i >= 0) filterListeners.splice(i);
  28446. i = dataListeners.indexOf(add);
  28447. if (i >= 0) dataListeners.splice(i);
  28448. return group;
  28449. }
  28450. return reduceCount();
  28451. }
  28452. // Returns the number of records in this crossfilter, irrespective of any filters.
  28453. function size() {
  28454. return n;
  28455. }
  28456. return arguments.length
  28457. ? add(arguments[0])
  28458. : crossfilter;
  28459. }
  28460. // Returns an array of size n, big enough to store ids up to m.
  28461. function crossfilter_index(n, m) {
  28462. return (m < 0x101
  28463. ? crossfilter_array8 : m < 0x10001
  28464. ? crossfilter_array16
  28465. : crossfilter_array32)(n);
  28466. }
  28467. // Constructs a new array of size n, with sequential values from 0 to n - 1.
  28468. function crossfilter_range(n) {
  28469. var range = crossfilter_index(n, n);
  28470. for (var i = -1; ++i < n;) range[i] = i;
  28471. return range;
  28472. }
  28473. function crossfilter_capacity(w) {
  28474. return w === 8
  28475. ? 0x100 : w === 16
  28476. ? 0x10000
  28477. : 0x100000000;
  28478. }
  28479. })( true && exports || this);
  28480. /***/ }),
  28481. /***/ "./node_modules/crossfilter/index.js":
  28482. /*!*******************************************!*\
  28483. !*** ./node_modules/crossfilter/index.js ***!
  28484. \*******************************************/
  28485. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28486. module.exports = __webpack_require__(/*! ./crossfilter */ "./node_modules/crossfilter/crossfilter.js").crossfilter;
  28487. /***/ }),
  28488. /***/ "./node_modules/crypto-browserify/index.js":
  28489. /*!*************************************************!*\
  28490. !*** ./node_modules/crypto-browserify/index.js ***!
  28491. \*************************************************/
  28492. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28493. "use strict";
  28494. exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(/*! randombytes */ "./node_modules/randombytes/browser.js")
  28495. exports.createHash = exports.Hash = __webpack_require__(/*! create-hash */ "./node_modules/create-hash/browser.js")
  28496. exports.createHmac = exports.Hmac = __webpack_require__(/*! create-hmac */ "./node_modules/create-hmac/browser.js")
  28497. var algos = __webpack_require__(/*! browserify-sign/algos */ "./node_modules/browserify-sign/algos.js")
  28498. var algoKeys = Object.keys(algos)
  28499. var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
  28500. exports.getHashes = function () {
  28501. return hashes
  28502. }
  28503. var p = __webpack_require__(/*! pbkdf2 */ "./node_modules/pbkdf2/browser.js")
  28504. exports.pbkdf2 = p.pbkdf2
  28505. exports.pbkdf2Sync = p.pbkdf2Sync
  28506. var aes = __webpack_require__(/*! browserify-cipher */ "./node_modules/browserify-cipher/browser.js")
  28507. exports.Cipher = aes.Cipher
  28508. exports.createCipher = aes.createCipher
  28509. exports.Cipheriv = aes.Cipheriv
  28510. exports.createCipheriv = aes.createCipheriv
  28511. exports.Decipher = aes.Decipher
  28512. exports.createDecipher = aes.createDecipher
  28513. exports.Decipheriv = aes.Decipheriv
  28514. exports.createDecipheriv = aes.createDecipheriv
  28515. exports.getCiphers = aes.getCiphers
  28516. exports.listCiphers = aes.listCiphers
  28517. var dh = __webpack_require__(/*! diffie-hellman */ "./node_modules/diffie-hellman/browser.js")
  28518. exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
  28519. exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
  28520. exports.getDiffieHellman = dh.getDiffieHellman
  28521. exports.createDiffieHellman = dh.createDiffieHellman
  28522. exports.DiffieHellman = dh.DiffieHellman
  28523. var sign = __webpack_require__(/*! browserify-sign */ "./node_modules/browserify-sign/browser/index.js")
  28524. exports.createSign = sign.createSign
  28525. exports.Sign = sign.Sign
  28526. exports.createVerify = sign.createVerify
  28527. exports.Verify = sign.Verify
  28528. exports.createECDH = __webpack_require__(/*! create-ecdh */ "./node_modules/create-ecdh/browser.js")
  28529. var publicEncrypt = __webpack_require__(/*! public-encrypt */ "./node_modules/public-encrypt/browser.js")
  28530. exports.publicEncrypt = publicEncrypt.publicEncrypt
  28531. exports.privateEncrypt = publicEncrypt.privateEncrypt
  28532. exports.publicDecrypt = publicEncrypt.publicDecrypt
  28533. exports.privateDecrypt = publicEncrypt.privateDecrypt
  28534. // the least I can do is make error messages for the rest of the node.js/crypto api.
  28535. // ;[
  28536. // 'createCredentials'
  28537. // ].forEach(function (name) {
  28538. // exports[name] = function () {
  28539. // throw new Error([
  28540. // 'sorry, ' + name + ' is not implemented yet',
  28541. // 'we accept pull requests',
  28542. // 'https://github.com/crypto-browserify/crypto-browserify'
  28543. // ].join('\n'))
  28544. // }
  28545. // })
  28546. var rf = __webpack_require__(/*! randomfill */ "./node_modules/randomfill/browser.js")
  28547. exports.randomFill = rf.randomFill
  28548. exports.randomFillSync = rf.randomFillSync
  28549. exports.createCredentials = function () {
  28550. throw new Error([
  28551. 'sorry, createCredentials is not implemented yet',
  28552. 'we accept pull requests',
  28553. 'https://github.com/crypto-browserify/crypto-browserify'
  28554. ].join('\n'))
  28555. }
  28556. exports.constants = {
  28557. 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
  28558. 'DH_CHECK_P_NOT_PRIME': 1,
  28559. 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
  28560. 'DH_NOT_SUITABLE_GENERATOR': 8,
  28561. 'NPN_ENABLED': 1,
  28562. 'ALPN_ENABLED': 1,
  28563. 'RSA_PKCS1_PADDING': 1,
  28564. 'RSA_SSLV23_PADDING': 2,
  28565. 'RSA_NO_PADDING': 3,
  28566. 'RSA_PKCS1_OAEP_PADDING': 4,
  28567. 'RSA_X931_PADDING': 5,
  28568. 'RSA_PKCS1_PSS_PADDING': 6,
  28569. 'POINT_CONVERSION_COMPRESSED': 2,
  28570. 'POINT_CONVERSION_UNCOMPRESSED': 4,
  28571. 'POINT_CONVERSION_HYBRID': 6
  28572. }
  28573. /***/ }),
  28574. /***/ "./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[2]!./node_modules/izitoast/dist/css/iziToast.min.css":
  28575. /*!*******************************************************************************************************************************************************************************************************************!*\
  28576. !*** ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[2]!./node_modules/izitoast/dist/css/iziToast.min.css ***!
  28577. \*******************************************************************************************************************************************************************************************************************/
  28578. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  28579. "use strict";
  28580. __webpack_require__.r(__webpack_exports__);
  28581. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  28582. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  28583. /* harmony export */ });
  28584. /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
  28585. /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0__);
  28586. // Imports
  28587. var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_0___default()(function(i){return i[1]});
  28588. // Module
  28589. ___CSS_LOADER_EXPORT___.push([module.id, "/*\r\n* iziToast | v1.4.0\r\n* http://izitoast.marcelodolce.com\r\n* by Marcelo Dolce.\r\n*/\r\n.iziToast-capsule{font-size:0;height:0;width:100%;transform:translateZ(0);-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:transform .5s cubic-bezier(.25,.8,.25,1),height .5s cubic-bezier(.25,.8,.25,1)}.iziToast-capsule,.iziToast-capsule *{box-sizing:border-box}.iziToast-overlay{display:block;position:fixed;top:-100px;left:0;right:0;bottom:-100px;z-index:997}.iziToast{display:inline-block;clear:both;position:relative;font-family:'Lato',Tahoma,Arial;font-size:14px;padding:8px 45px 9px 0;background:rgba(238,238,238,.9);border-color:rgba(238,238,238,.9);width:100%;pointer-events:all;cursor:default;transform:translateX(0);-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;min-height:54px}.iziToast>.iziToast-progressbar{position:absolute;left:0;bottom:0;width:100%;z-index:1;background:rgba(255,255,255,.2)}.iziToast>.iziToast-progressbar>div{height:2px;width:100%;background:rgba(0,0,0,.3);border-radius:0 0 3px 3px}.iziToast.iziToast-balloon:before{content:'';position:absolute;right:8px;left:auto;width:0;height:0;top:100%;border-right:0 solid transparent;border-left:15px solid transparent;border-top:10px solid #000;border-top-color:inherit;border-radius:0}.iziToast.iziToast-balloon .iziToast-progressbar{top:0;bottom:auto}.iziToast.iziToast-balloon>div{border-radius:0 0 0 3px}.iziToast>.iziToast-cover{position:absolute;left:0;top:0;bottom:0;height:100%;margin:0;background-size:100%;background-position:50% 50%;background-repeat:no-repeat;background-color:rgba(0,0,0,.1)}.iziToast>.iziToast-close{position:absolute;right:0;top:0;border:0;padding:0;opacity:.6;width:42px;height:100%;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAJPAAACTwBcGfW0QAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAD3SURBVFiF1ZdtDoMgDEBfdi4PwAX8vLFn0qT7wxantojKupmQmCi8R4tSACpgjC2ICCUbEBa8ingjsU1AXRBeR8aLN64FiknswN8CYefBBDQ3whuFESy7WyQMeC0ipEI0A+0FeBvHUFN8xPaUhAH/iKoWsnXHGegy4J0yxialOfaHJAz4bhRzQzgDvdGnz4GbAonZbCQMuBm1K/kcFu8Mp1N2cFFpsxsMuJqqbIGExGl4loARajU1twskJLLhIsID7+tvUoDnIjTg5T9DPH9EBrz8rxjPzciAl9+O8SxI8CzJ8CxKFfh3ynK8Dyb8wNHM/XDqejx/AtNyPO87tNybAAAAAElFTkSuQmCC) no-repeat 50% 50%;background-size:8px;cursor:pointer;outline:0}.iziToast>.iziToast-close:hover{opacity:1}.iziToast>.iziToast-body{position:relative;padding:0 0 0 10px;height:auto;min-height:36px;margin:0 0 0 15px;text-align:left}.iziToast>.iziToast-body:after{content:\"\";display:table;clear:both}.iziToast>.iziToast-body .iziToast-texts{margin:10px 0 0;padding-right:2px;display:inline-block;float:left}.iziToast>.iziToast-body .iziToast-inputs{min-height:19px;float:left;margin:3px -2px}.iziToast>.iziToast-body .iziToast-inputs>input:not([type=checkbox]):not([type=radio]),.iziToast>.iziToast-body .iziToast-inputs>select{position:relative;display:inline-block;margin:2px;border-radius:2px;border:0;padding:4px 7px;font-size:13px;letter-spacing:.02em;background:rgba(0,0,0,.1);color:#000;box-shadow:0 0 0 1px rgba(0,0,0,.2);min-height:26px}.iziToast>.iziToast-body .iziToast-inputs>input:not([type=checkbox]):not([type=radio]):focus,.iziToast>.iziToast-body .iziToast-inputs>select:focus{box-shadow:0 0 0 1px rgba(0,0,0,.6)}.iziToast>.iziToast-body .iziToast-buttons{min-height:17px;float:left;margin:4px -2px}.iziToast>.iziToast-body .iziToast-buttons>a,.iziToast>.iziToast-body .iziToast-buttons>button,.iziToast>.iziToast-body .iziToast-buttons>input:not([type=checkbox]):not([type=radio]){position:relative;display:inline-block;margin:2px;border-radius:2px;border:0;padding:5px 10px;font-size:12px;letter-spacing:.02em;cursor:pointer;background:rgba(0,0,0,.1);color:#000}.iziToast>.iziToast-body .iziToast-buttons>a:hover,.iziToast>.iziToast-body .iziToast-buttons>button:hover,.iziToast>.iziToast-body .iziToast-buttons>input:not([type=checkbox]):not([type=radio]):hover{background:rgba(0,0,0,.2)}.iziToast>.iziToast-body .iziToast-buttons>a:focus,.iziToast>.iziToast-body .iziToast-buttons>button:focus,.iziToast>.iziToast-body .iziToast-buttons>input:not([type=checkbox]):not([type=radio]):focus{box-shadow:0 0 0 1px rgba(0,0,0,.6)}.iziToast>.iziToast-body .iziToast-buttons>a:active,.iziToast>.iziToast-body .iziToast-buttons>button:active,.iziToast>.iziToast-body .iziToast-buttons>input:not([type=checkbox]):not([type=radio]):active{top:1px}.iziToast>.iziToast-body .iziToast-icon{position:absolute;left:0;top:50%;display:table;font-size:23px;line-height:24px;margin-top:-12px;color:#000;width:24px;height:24px}.iziToast>.iziToast-body .iziToast-icon.ico-info{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAflBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCtoPsAAAAKXRSTlMA6PsIvDob+OapavVhWRYPrIry2MxGQ97czsOzpJaMcE0qJQOwVtKjfxCVFeIAAAI3SURBVFjDlJPZsoIwEETnCiGyb8q+qmjl/3/wFmGKwjBROS9QWbtnOqDDGPq4MdMkSc0m7gcDDhF4NRdv8NoL4EcMpzoJglPl/KTDz4WW3IdvXEvxkfIKn7BMZb1bFK4yZFqghZ03jk0nG8N5NBwzx9xU5cxAg8fXi20/hDdC316lcA8o7t16eRuQvW1XGd2d2P8QSHQDDbdIII/9CR3lUF+lbucfJy4WfMS64EJPORnrZxtfc2pjJdnbuags3l04TTtJMXrdTph4Pyg4XAjugAJqMDf5Rf+oXx2/qi4u6nipakIi7CsgiuMSEF9IGKg8heQJKkxIfFSUU/egWSwNrS1fPDtLfon8sZOcYUQml1Qv9a3kfwsEUyJEMgFBKzdV8o3Iw9yAjg1jdLQCV4qbd3no8yD2GugaC3oMbF0NYHCpJYSDhNI5N2DAWB4F4z9Aj/04Cna/x7eVAQ17vRjQZPh+G/kddYv0h49yY4NWNDWMMOMUIRYvlTECmrN8pUAjo5RCMn8KoPmbJ/+Appgnk//Sy90GYBCGgm7IAskQ7D9hFKW4ApB1ei3FSYD9PjGAKygAV+ARFYBH5BsVgG9kkBSAQWKUFYBRZpkUgGVinRWAdUZQDABBQdIcAElDVBUAUUXWHQBZx1gMAGMprM0AsLbVXHsA5trZe93/wp3svQ0YNb/jWV3AIOLsMtlznSNOH7JqjOpDVh7z8qCZR10ftvO4nxeOvPLkpSuvfXnxzKtvXr7j+v8C5ii0e71At7cAAAAASUVORK5CYII=) no-repeat 50% 50%;background-size:85%}.iziToast>.iziToast-body .iziToast-icon.ico-warning{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEQAAABECAMAAAAPzWOAAAAAkFBMVEUAAAAAAAABAAIAAAABAAIAAAMAAAABAAIBAAIBAAIAAAIAAAABAAIAAAABAAICAAICAAIAAAIAAAAAAAAAAAABAAIBAAIAAAMAAAABAAIBAAMBAAECAAIAAAIAAAIAAAABAAIBAAIBAAMBAAIBAAEAAAIAAAMAAAAAAAABAAECAAICAAIAAAIAAAMAAAQAAAE05yNAAAAAL3RSTlMAB+kD7V8Q+PXicwv7I9iYhkAzJxnx01IV5cmnk2xmHfzexsK4eEw5L7Gei39aRw640awAAAHQSURBVFjD7ZfJdoJAEEWJgCiI4oDiPM8m7///LidErRO7sHrY5u7YXLr7vKqu9kTC0HPmo9n8cJbEQOzqqAdAUHeUZACQuTkGDQBoDJwkHZR0XBz9FkpafXuHP0SJ09mGeJLZ5wwlTmcbA0THPmdEK7XPGTG1zxmInn3OiJ19zkB0jSVTKExMHT0wjAwlWzC0fSPHF1gWRpIhWMYm7fYTFcQGlbemf4dFfdTGg0B/KXM8qBU/3wntbq7rSGqvJ9kla6IpueFJet8fxfem5yhykjyOgNaWF1qSGd5JMNNxpNF7SZQaVh5JzLrTCZIEJ1GyEyVyd+pClMjdaSJK5O40giSRu5PfFiVyd1pAksjdKRnrSsbVdbiHrgT7yss315fkVQPLFQrL+4FHeOXKO5YRFEKv5AiFaMlKLlBpJuVCJlC5sJfvCgztru/3NmBYccPgGTxRAzxn1XGEMUf58pXZvjoOsOCgjL08+b53mtfAM/SVsZcjKLtysQZPqIy9HPP3m/3zKItRwT0LyQo8sTr26tcO83DIUMWIJjierHLsJda/tbNBFY0BP/bKtcM8HNIWCK3aYR4OMzgxo5w5EFLOLKDExXAm9gI4E3iAO94/Ct/lKWuM2LMGbgAAAABJRU5ErkJggg==) no-repeat 50% 50%;background-size:85%}.iziToast>.iziToast-body .iziToast-icon.ico-error{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAeFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVyEiIAAAAJ3RSTlMA3BsB98QV8uSyWVUFz7+kcWMM2LuZioBpTUVBNcq2qaibj4d1azLZZYABAAACZElEQVRYw7WX25KCMAyGAxUoFDkpiohnV97/DXeGBtoOUprZ2dyo1K82fxKbwJJVp+KQZ7so2mX5oThVQLKwjDe9YZu4DF3ptAn6rxY0qQPOEq9fNC9ha3y77a22ba24v+9Xbe8v8x03dPOC2/NdvB6xeSreLfGJpnx0TyotKqLm2s7Jd/WO6ivXNp0tCy02R/aFz5VQ5wUPlUL5fIfj5KIlVGU0nWHm/5QtoTVMWY8mzIVu1K9O7XH2JiU/xnOOT39gnUfj+lFHddx4tFjL3/H8jjzaFCy2Rf0c/fdQyQszI8BDR973IyMSKa4krjxAiW/lkRvMP+bKK9WbYS1ASQg8dKjaUGlYPwRe/WoIkz8tiQchH5QAEMv6T0k8MD4mUyWr4E7jAWqZ+xWcMIYkXvlwggJ3IvFK+wIOcpXAo8n8P0COAaXyKH4OsjBuZB4ew0IGu+H1SebhNazsQBbWm8yj+hFuUJB5eMsN0IUXmYendAFFfJB5uEkRMYwxmcd6zDGRtmQePEykAgubymMRFmMxCSIPCRbTuFNN5OGORTjmNGc0Po0m8Uv0gcCry6xUhR2QeLii9tofbEfhz/qvNti+OfPqNm2Mq6105FUMvdT4GPmufMiV8PqBMkc+DdT1bjYYbjzU/ew23VP4n3mLAz4n8Jtv/Ui3ceTT2mzz5o1mZt0gnBpmsdjqRqVlmplcPdqa7X23kL9brdm2t/uBYDPn2+tyu48mtIGD10JTuUrukVrbCFiwDzcHrPjxKt7PW+AZQyT/WESO+1WL7f3o+WLHL2dYMSZsg6dg/z360ofvP4//v1NPzgs28WlWAAAAAElFTkSuQmCC) no-repeat 50% 50%;background-size:80%}.iziToast>.iziToast-body .iziToast-icon.ico-success{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABt0UjBAAAACnRSTlMApAPhIFn82wgGv8mVtwAAAKVJREFUSMft0LEJAkEARNFFFEw1NFJb8CKjAy1AEOzAxNw+bEEEg6nyFjbY4LOzcBwX7S/gwUxoTdIn+Jbv4Lv8bx446+kB6VsBtK0B+wbMCKxrwL33wOrVeeChX28n7KTOTjgoEu6DRSYAgAAAAkAmAIAAAAIACQIkMkACAAgAIACAyECBKAOJuCagTJwSUCaUAEMAABEBRwAAEQFLbCJgO4bW+AZKGnktR+jAFAAAAABJRU5ErkJggg==) no-repeat 50% 50%;background-size:85%}.iziToast>.iziToast-body .iziToast-icon.ico-question{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAADdcAAA3XAUIom3gAAAAHdElNRQfhCQkUEhFovxTxAAAEDklEQVRo3s2ZTWgTQRTHf03ipTRUqghNSgsRjHgQrFUQC6JgD1Kak3gQUUoPqRdBglf1oBehBws9Cn4cGk+1SOmh2upBxAYVoeJHrR9tgq0i1Cq0lqYeks7MbpPdmU00/c8hm9n33v/t7Nt5M2+qMEWQI0QIibZKRrQpHvLL2KI2wnQzzBKrDm2RIeKEy01dTYKUI7G1ZRknQXV5yP10kTYgly1NF/5S6duZ8ES+1iZodyaocrjXxE0OFeifYYgp0mRIkwFChAkRJsIxGgrIP+I0n82fvZW5dc/zkss0O2o1c5mX6/TmaDWl77RFe5YkUW3tKEmyFv0lOvXJ/fTYnmCEFuMRbGHEZqVHLyT9DFjUJmkzJl9DG5MWWwM6Llif/gF1nukB6nhgGwUXdFrE+wiURA8QoM9i0zEWWpXQW+ZsyeRrOMuyEo5Fv4gmy4dXPvqcC+pH2VRYaMwy+OWG+iLGCgm0W0Kv9HdvR8ASjmKCXpuK/bxiV/76A/v5UdDIZuKcJGjrnec5KZ7wwsWFOp6xPX/9mt2sqDe7FO+Kf/fXHBPPDWpdXGhTpLvUG9VKwh1xMDDjkvu+cNDFBTk7ptX1QkKZ850m3duu6fcrWxwdaFFyREJ2j4vOpKP6Du6z4uJCv8sYJIVkCnJBGGZaBONO3roY2EqNrSfIPi7SKP4fdXyNUd6I6wbSAHEl33tFLe+FlSsusnK90A0+oEPcuufZgXnOi+u9LrKSJQZQw6LwqBnv2CKsfHORbFbyQhA6xN/pEuihSdj56Co7LWRjPiKie6gkB2LiKuUqK5kiPkLiz1QJ9K1cNXBAMoUCigNpQ9IqDtMI1HKA4/jyvUsaoSyZLA5kjOjDPFZen8Ql5TsvBskUgjciIPSX3QAXC86DT7VWvlEh/xZ+ij9BDVWJ0QL0SbZq6QaFxoLPcXPmBLveLCc4wXdDK6s+6/vwhCSniFLPXW0NJe5UB8zKCsviqpc7vGPVQFcyZbyPwGD+d5ZnxmNWlhG4xSBZZjivjIWHEQgoDkSMjMwTo54569JSE5IpA7EyJSMTyGTUAUFlO1ZKOtaHTMeL1PhYYFTcihmY2cQ5+ullj7EDkiVfVez2sCTz8yiv84djhg7IJVk81xFWJlPdfHBG0flkRC/zQFZ+DSllNtfDdUsOMCliyGX5uOzU3ZhIXFDof4m1gDuKbEx0t2YS25gVGpcMnr/I1kx3c6piB8P8ZoqEwfMX3ZyCXynJTmq/U7NUXqfUzCbWL1wqVKBQUeESzQYoUlW8TAcVL1RCxUu1G6BYXfFyfQ4VPbDI4T8d2WzgQ6sc/vmxnTsqfHCZQzUJxm1h5dxS5Tu6lQgTZ0ipqRVqSwzTbbLHMt+c19iO76tsx/cLZub+Ali+tYC93olEAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE3LTA5LTA5VDIwOjE4OjE3KzAyOjAwjKtfjgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNy0wOS0wOVQyMDoxODoxNyswMjowMP325zIAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC) no-repeat 50% 50%;background-size:85%}.iziToast>.iziToast-body .iziToast-message,.iziToast>.iziToast-body .iziToast-title{padding:0;font-size:14px;line-height:16px;text-align:left;float:left;white-space:normal}.iziToast>.iziToast-body .iziToast-title{color:#000;margin:0}.iziToast>.iziToast-body .iziToast-message{margin:0 0 10px;color:rgba(0,0,0,.6)}.iziToast.iziToast-animateInside .iziToast-buttons-child,.iziToast.iziToast-animateInside .iziToast-icon,.iziToast.iziToast-animateInside .iziToast-inputs-child,.iziToast.iziToast-animateInside .iziToast-message,.iziToast.iziToast-animateInside .iziToast-title{opacity:0}.iziToast-target{position:relative;width:100%;margin:0 auto}.iziToast-target .iziToast-capsule{overflow:hidden}.iziToast-target .iziToast-capsule:after{visibility:hidden;display:block;font-size:0;content:\" \";clear:both;height:0}.iziToast-target .iziToast-capsule .iziToast{width:100%;float:left}.iziToast-wrapper{z-index:99999;position:fixed;width:100%;pointer-events:none;display:flex;flex-direction:column}.iziToast-wrapper .iziToast.iziToast-balloon:before{border-right:0 solid transparent;border-left:15px solid transparent;border-top:10px solid #000;border-top-color:inherit;right:8px;left:auto}.iziToast-wrapper-bottomLeft{left:0;bottom:0;text-align:left}.iziToast-wrapper-bottomLeft .iziToast.iziToast-balloon:before,.iziToast-wrapper-topLeft .iziToast.iziToast-balloon:before{border-right:15px solid transparent;border-left:0 solid transparent;right:auto;left:8px}.iziToast-wrapper-bottomRight{right:0;bottom:0;text-align:right}.iziToast-wrapper-topLeft{left:0;top:0;text-align:left}.iziToast-wrapper-topRight{top:0;right:0;text-align:right}.iziToast-wrapper-topCenter{top:0;left:0;right:0;text-align:center}.iziToast-wrapper-bottomCenter,.iziToast-wrapper-center{bottom:0;left:0;right:0;text-align:center}.iziToast-wrapper-center{top:0;justify-content:center;flex-flow:column;align-items:center}.iziToast-rtl{direction:rtl;padding:8px 0 9px 45px;font-family:Tahoma,'Lato',Arial}.iziToast-rtl .iziToast-cover{left:auto;right:0}.iziToast-rtl .iziToast-close{right:auto;left:0}.iziToast-rtl .iziToast-body{padding:0 10px 0 0;margin:0 16px 0 0;text-align:right}.iziToast-rtl .iziToast-body .iziToast-buttons,.iziToast-rtl .iziToast-body .iziToast-inputs,.iziToast-rtl .iziToast-body .iziToast-message,.iziToast-rtl .iziToast-body .iziToast-texts,.iziToast-rtl .iziToast-body .iziToast-title{float:right;text-align:right}.iziToast-rtl .iziToast-body .iziToast-icon{left:auto;right:0}@media only screen and (min-width:568px){.iziToast-wrapper{padding:10px 15px}.iziToast{margin:5px 0;border-radius:3px;width:auto}.iziToast:after{content:'';z-index:-1;position:absolute;top:0;left:0;width:100%;height:100%;border-radius:3px;box-shadow:inset 0 -10px 20px -10px rgba(0,0,0,.2),inset 0 0 5px rgba(0,0,0,.1),0 8px 8px -5px rgba(0,0,0,.25)}.iziToast:not(.iziToast-rtl) .iziToast-cover{border-radius:3px 0 0 3px}.iziToast.iziToast-rtl .iziToast-cover{border-radius:0 3px 3px 0}.iziToast.iziToast-color-dark:after{box-shadow:inset 0 -10px 20px -10px rgba(255,255,255,.3),0 10px 10px -5px rgba(0,0,0,.25)}.iziToast.iziToast-balloon .iziToast-progressbar{background:0 0}.iziToast.iziToast-balloon:after{box-shadow:0 10px 10px -5px rgba(0,0,0,.25),inset 0 10px 20px -5px rgba(0,0,0,.25)}.iziToast-target .iziToast:after{box-shadow:inset 0 -10px 20px -10px rgba(0,0,0,.2),inset 0 0 5px rgba(0,0,0,.1)}}.iziToast.iziToast-theme-dark{background:#565c70;border-color:#565c70}.iziToast.iziToast-theme-dark .iziToast-title{color:#fff}.iziToast.iziToast-theme-dark .iziToast-message{color:rgba(255,255,255,.7);font-weight:300}.iziToast.iziToast-theme-dark .iziToast-close{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAADdcAAA3XAUIom3gAAAAHdElNRQfgCR4OIQIPSao6AAAAwElEQVRIx72VUQ6EIAwFmz2XB+AConhjzqTJ7JeGKhLYlyx/BGdoBVpjIpMJNjgIZDKTkQHYmYfwmR2AfAqGFBcO2QjXZCd24bEggvd1KBx+xlwoDpYmvnBUUy68DYXD77ESr8WDtYqvxRex7a8oHP4Wo1Mkt5I68Mc+qYqv1h5OsZmZsQ3gj/02h6cO/KEYx29hu3R+VTTwz6D3TymIP1E8RvEiiVdZfEzicxYLiljSxKIqlnW5seitTW6uYnv/Aqh4whX3mEUrAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE2LTA5LTMwVDE0OjMzOjAyKzAyOjAwl6RMVgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0wOS0zMFQxNDozMzowMiswMjowMOb59OoAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC) no-repeat 50% 50%;background-size:8px}.iziToast.iziToast-theme-dark .iziToast-icon{color:#fff}.iziToast.iziToast-theme-dark .iziToast-icon.ico-info{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAflBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////vroaSAAAAKXRSTlMA6PsIvDob+OapavVhWRYPrIry2MxGQ97czsOzpJaMcE0qJQOwVtKjfxCVFeIAAAI3SURBVFjDlJPZsoIwEETnCiGyb8q+qmjl/3/wFmGKwjBROS9QWbtnOqDDGPq4MdMkSc0m7gcDDhF4NRdv8NoL4EcMpzoJglPl/KTDz4WW3IdvXEvxkfIKn7BMZb1bFK4yZFqghZ03jk0nG8N5NBwzx9xU5cxAg8fXi20/hDdC316lcA8o7t16eRuQvW1XGd2d2P8QSHQDDbdIII/9CR3lUF+lbucfJy4WfMS64EJPORnrZxtfc2pjJdnbuags3l04TTtJMXrdTph4Pyg4XAjugAJqMDf5Rf+oXx2/qi4u6nipakIi7CsgiuMSEF9IGKg8heQJKkxIfFSUU/egWSwNrS1fPDtLfon8sZOcYUQml1Qv9a3kfwsEUyJEMgFBKzdV8o3Iw9yAjg1jdLQCV4qbd3no8yD2GugaC3oMbF0NYHCpJYSDhNI5N2DAWB4F4z9Aj/04Cna/x7eVAQ17vRjQZPh+G/kddYv0h49yY4NWNDWMMOMUIRYvlTECmrN8pUAjo5RCMn8KoPmbJ/+Appgnk//Sy90GYBCGgm7IAskQ7D9hFKW4ApB1ei3FSYD9PjGAKygAV+ARFYBH5BsVgG9kkBSAQWKUFYBRZpkUgGVinRWAdUZQDABBQdIcAElDVBUAUUXWHQBZx1gMAGMprM0AsLbVXHsA5trZe93/wp3svQ0YNb/jWV3AIOLsMtlznSNOH7JqjOpDVh7z8qCZR10ftvO4nxeOvPLkpSuvfXnxzKtvXr7j+v8C5ii0e71At7cAAAAASUVORK5CYII=) no-repeat 50% 50%;background-size:85%}.iziToast.iziToast-theme-dark .iziToast-icon.ico-warning{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEQAAABECAMAAAAPzWOAAAAAllBMVEUAAAD////+//3+//3+//3///////z+//3+//3+//3////////////9//3////+//39//3///3////////////+//3+//39//3///z+//z+//7///3///3///3///3////////+//3+//3+//3+//z+//3+//7///3///z////////+//79//3///3///z///v+//3///+trXouAAAAMHRSTlMAB+j87RBf+PXiCwQClSPYhkAzJxnx05tSyadzcmxmHRbp5d7Gwrh4TDkvsYt/WkdQzCITAAAB1UlEQVRYw+3XaXKCQBCGYSIIighoxCVqNJrEPfly/8vFImKXduNsf/Mc4K1y7FnwlMLQc/bUbj85R6bA1LXRDICg6RjJcZa7NQYtnLUGTpERSiOXxrOPkv9s30iGKDmtbYir3H7OUHJa2ylAuvZzRvzUfs7Ii/2cgfTt54x82s8ZSM848gJmYtroQzA2jHwA+LkBIEuMGt+QIng1igzlyMrkuP2CyOi47axRaYTL5jhDJehoR+aovC29s3iIyly3Eb+hRCvZo2qsGTnhKr2cLDS+J73GsqBI9W80UCmWWpEuhIjh6ZRGjyNRarjzKGJ2Ou2himCvjHwqI+rTqQdlRH06TZQR9ek0hiqiPp06mV4ke7QPX6ERUZxO8Uo3sqrfhxvoRrCpvXwL/UjR9GRHMIvLgke4d5QbiwhM6JV2YKKF4vIl7XIBkwm4keryJVmvk/TfwcmPwQNkUQuyA2/sYGwnXL7GPu4bW1jYsmevrNj09/MGZMOEPXslQVqO8hqykD17JfPHP/bmo2yGGpdZiH3IZvzZa7B3+IdDjjpjesHJcvbs5dZ/e+cddVoDdvlq7x12Nac+iN7e4R8OXTjp0pw5CGnOLNDEzeBs5gVwFniAO+8f8wvfeXP2hyqnmwAAAABJRU5ErkJggg==) no-repeat 50% 50%;background-size:85%}.iziToast.iziToast-theme-dark .iziToast-icon.ico-error{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAeFBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////GqOSsAAAAJ3RSTlMA3BsB98QV8uSyWVUFz6RxYwzYvbupmYqAaU1FQTXKv7abj4d1azKNUit3AAACZElEQVRYw7WXaZOCMAyGw30UORRQBLxX/v8/3BkaWjrY2szO5otKfGrzJrEp6Kw6F8f8sI+i/SE/FucKSBaWiT8p5idlaEtnXTB9tKDLLHAvdSatOan3je93k9F2vRF36+mr1a6eH2NFNydoHq/ieU/UXcWjjk9XykdNWq2ywtp4tXL6Wb2T/MqtzzZutsrNyfvA51KoQROhVCjfrnASIRpSVUZiD5v4RbWExjRdJzSmOsZFvzYz59kRSr6V5zE+/QELHkNdb3VRx45HS1b1u+zfkkcbRAZ3qJ9l/A4qefHUDMShJe+6kZKJDD2pLQ9Q4lu+5Q7rz7Plperd7AtQEgIPI6o2dxr2D4GXvxqCiKcn8cD4gxIAEt7/GYkHL16KqeJd0NB4gJbXfgVnzCGJlzGcocCVSLzUvoAj9xJ4NF7/R8gxoVQexc/hgBpSebjPjgPs59cHmYfn7NkDb6wXmUf1I1ygIPPw4gtgCE8yDw8eAop4J/PQcBExjQmZx37MsZB2ZB4cLKQCG5vKYxMWSzMxIg8pNtOyUkvkocEmXGo69mh8FgnxS4yBwMvDrJSNHZB4uC3ayz/YkcIP4lflwVIT+OU07ZSjrbTkZQ6dTPkYubZ8GC/Cqxu6WvJZII93dcCw46GdNqdpTeF/tiMOuDGB9z/NI6NvyWetGPM0g+bVNeovBmamHXWj0nCbEaGeTMN2PWrqd6cM26ZxP2DeJvj+ph/30Zi/GmRbtlK5SptI+nwGGnvH6gUruT+L16MJHF+58rwNIifTV0vM8+hwMeOXAb6Yx0wXT+b999WXfvn+8/X/F7fWzjdTord5AAAAAElFTkSuQmCC) no-repeat 50% 50%;background-size:80%}.iziToast.iziToast-theme-dark .iziToast-icon.ico-success{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMApAPhIFn82wgGv8mVtwAAAKVJREFUSMft0LEJAkEARNFFFEw1NFJb8CKjAy1AEOzAxNw+bEEEg6nyFjbY4LOzcBwX7S/gwUxoTdIn+Jbv4Lv8bx446+kB6VsBtK0B+wbMCKxrwL33wOrVeeChX28n7KTOTjgoEu6DRSYAgAAAAkAmAIAAAAIACQIkMkACAAgAIACAyECBKAOJuCagTJwSUCaUAEMAABEBRwAAEQFLbCJgO4bW+AZKGnktR+jAFAAAAABJRU5ErkJggg==) no-repeat 50% 50%;background-size:85%}.iziToast.iziToast-theme-dark .iziToast-icon.ico-question{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAJcEhZcwAADdcAAA3XAUIom3gAAAAHdElNRQfhCQkUEg18vki+AAAETUlEQVRo3s1ZTWhbRxD+VlIuxsLFCYVIIQYVopBDoK5bKDWUBupDMNbJ5FBKg/FBziUQdE9yaC+FHBrwsdCfQ9RTGoLxwWl+DqHEojUFFydxnB9bInZDqOsErBrr6yGvs/ueX97bldTKo4Pe7puZb3Z33s7srIIjMY1jyCEjP6ImvyX8pF64arSHznKC06wzijY5xSKz7YbuYokV2lODsyyxqz3gSY6z6gCuqcpxJluFH+Z8U+D/0jyHoxFUBHgfvsGHIS9WMIUlVFFDFTUAGWSRQRY5HMeBEP6b+Ew9dh/7INd2jGeO59kfKdXP85zbIbfGQVf4sYC3N1hm3lo6zzIbPvk6x+zBk7wQGMEMB5xncIAzAS0XrFySSV72iS1yyBVcdA1x0afrsoUJgdFfY2+z8ADAXl7zz0KcwJiPfZKpVuABgClO+nRG+QIHDdfb4qlWwUXvKW4Z7vi6L4J9vg+vbfCeCeZH2RfOdMOc/HbCA4BvIW6EMQz7XK/ltd+hP+VzR9mgva2YSfyGI17fA7ynnocqeQNFfIJ0oHsdv6CC2+rXGBN6cQdveY3fcVRtmy/HDete+93zy8jA8zV7YkwYMrjHzRddRsCdiVCwwmh6wg9iTNC7Y9XIF1iS7kbUpsvvGEdPuTfSgAEjRpR096x0liPFD/Eqt2NMuBQzB2XhrACAApjFsuQFh9XdGAX70B3oSuNdnMVBaX+sopYxjwVpHFBVACyKTXNoktjD+6Ll8xhenS9MAAkAI/Lux2YNUOs4I413Ypg1SgEAu7kpFvWjaeJe0fJHDGe/cNaZBkekudw8PMA+0fMwlndZeAsJ5KR/qhUDUJCnSiyvRsolkJHGUgvjH8QXDgZopEzKMKDqCKrwEQ4C6MH7GEXC665buLJG8hlQc4LP4paxfJrOqYVYYY2UARfEIazTbgDg2dB98GebzJd54b8L/iWNdLyooeR6CHyZ+6xk0yKxkYg6nEVSUG4VJ9QJ9cxRCxO+9WiOyvgUeexXP1hLGH5nGuBWVtiSp4vqe3VP0UFWI9Wan4Er3v8q7jjPWVtm4FtcQQMrOKO2nOQCM5AyDMi56FDrKHA/1nyppS1ppBpYaE8wciEjGI2AaeM41kI4doDX4XiT3Qm1gevyruCgZg9P8xIv8m1nCzTKq6oiJ9xTMiZ505P5m8cdZ0CnZMVXHVljM7WMBzxpyDxygtdxoCEFTaMIWbZU85UvBjgUMYy0fBaAF8V1Lj9qWQ1aMZ5f4k9r+AGMSkMP1vZoZih6k6sicc5h/OFHM9vDqU/VIU7zJZdYYsKGH4g4nAJMGiXZRds1pVMoZ69RM5vfkbh0qkBhsnS2RLMLilQdL9MBHS9UAh0v1e6CYnXHy/WeeCcvLDwl/9OVze69tPKM+M+v7eJN6OzFpWdEF0ucDbhVNFXadnVrmJFlkVNGTS2M6pzmhMvltfPhnN2B63sVuL7fcNP3D1TSk2ihosPrAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE3LTA5LTA5VDIwOjE4OjEzKzAyOjAweOR7nQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNy0wOS0wOVQyMDoxODoxMyswMjowMAm5wyEAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC) no-repeat 50% 50%;background-size:85%}.iziToast.iziToast-theme-dark .iziToast-buttons>a,.iziToast.iziToast-theme-dark .iziToast-buttons>button,.iziToast.iziToast-theme-dark .iziToast-buttons>input{color:#fff;background:rgba(255,255,255,.1)}.iziToast.iziToast-theme-dark .iziToast-buttons>a:hover,.iziToast.iziToast-theme-dark .iziToast-buttons>button:hover,.iziToast.iziToast-theme-dark .iziToast-buttons>input:hover{background:rgba(255,255,255,.2)}.iziToast.iziToast-theme-dark .iziToast-buttons>a:focus,.iziToast.iziToast-theme-dark .iziToast-buttons>button:focus,.iziToast.iziToast-theme-dark .iziToast-buttons>input:focus{box-shadow:0 0 0 1px rgba(255,255,255,.6)}.iziToast.iziToast-color-red{background:rgba(255,175,180,.9);border-color:rgba(255,175,180,.9)}.iziToast.iziToast-color-orange{background:rgba(255,207,165,.9);border-color:rgba(255,207,165,.9)}.iziToast.iziToast-color-yellow{background:rgba(255,249,178,.9);border-color:rgba(255,249,178,.9)}.iziToast.iziToast-color-blue{background:rgba(157,222,255,.9);border-color:rgba(157,222,255,.9)}.iziToast.iziToast-color-green{background:rgba(166,239,184,.9);border-color:rgba(166,239,184,.9)}.iziToast.iziToast-layout2 .iziToast-body .iziToast-message,.iziToast.iziToast-layout2 .iziToast-body .iziToast-texts{width:100%}.iziToast.iziToast-layout3{border-radius:2px}.iziToast.iziToast-layout3::after{display:none}.iziToast .revealIn,.iziToast.revealIn{animation:iziT-revealIn 1s cubic-bezier(.25,1.6,.25,1) both}.iziToast .slideIn,.iziToast.slideIn{animation:iziT-slideIn 1s cubic-bezier(.16,.81,.32,1) both}.iziToast.bounceInLeft{animation:iziT-bounceInLeft .7s ease-in-out both}.iziToast.bounceInRight{animation:iziT-bounceInRight .85s ease-in-out both}.iziToast.bounceInDown{animation:iziT-bounceInDown .7s ease-in-out both}.iziToast.bounceInUp{animation:iziT-bounceInUp .7s ease-in-out both}.iziToast .fadeIn,.iziToast.fadeIn{animation:iziT-fadeIn .5s ease both}.iziToast.fadeInUp{animation:iziT-fadeInUp .7s ease both}.iziToast.fadeInDown{animation:iziT-fadeInDown .7s ease both}.iziToast.fadeInLeft{animation:iziT-fadeInLeft .85s cubic-bezier(.25,.8,.25,1) both}.iziToast.fadeInRight{animation:iziT-fadeInRight .85s cubic-bezier(.25,.8,.25,1) both}.iziToast.flipInX{animation:iziT-flipInX .85s cubic-bezier(.35,0,.25,1) both}.iziToast.fadeOut{animation:iziT-fadeOut .7s ease both}.iziToast.fadeOutDown{animation:iziT-fadeOutDown .7s cubic-bezier(.4,.45,.15,.91) both}.iziToast.fadeOutUp{animation:iziT-fadeOutUp .7s cubic-bezier(.4,.45,.15,.91) both}.iziToast.fadeOutLeft{animation:iziT-fadeOutLeft .5s ease both}.iziToast.fadeOutRight{animation:iziT-fadeOutRight .5s ease both}.iziToast.flipOutX{-webkit-backface-visibility:visible!important;backface-visibility:visible!important;animation:iziT-flipOutX .7s cubic-bezier(.4,.45,.15,.91) both}.iziToast-overlay.fadeIn{animation:iziT-fadeIn .5s ease both}.iziToast-overlay.fadeOut{animation:iziT-fadeOut .7s ease both}@keyframes iziT-revealIn{0%{opacity:0;transform:scale3d(.3,.3,1)}to{opacity:1}}@keyframes iziT-slideIn{0%{opacity:0;transform:translateX(50px)}to{opacity:1;transform:translateX(0)}}@keyframes iziT-bounceInLeft{0%{opacity:0;transform:translateX(280px)}50%{opacity:1;transform:translateX(-20px)}70%{transform:translateX(10px)}to{transform:translateX(0)}}@keyframes iziT-bounceInRight{0%{opacity:0;transform:translateX(-280px)}50%{opacity:1;transform:translateX(20px)}70%{transform:translateX(-10px)}to{transform:translateX(0)}}@keyframes iziT-bounceInDown{0%{opacity:0;transform:translateY(-200px)}50%{opacity:1;transform:translateY(10px)}70%{transform:translateY(-5px)}to{transform:translateY(0)}}@keyframes iziT-bounceInUp{0%{opacity:0;transform:translateY(200px)}50%{opacity:1;transform:translateY(-10px)}70%{transform:translateY(5px)}to{transform:translateY(0)}}@keyframes iziT-fadeIn{0%{opacity:0}to{opacity:1}}@keyframes iziT-fadeInUp{0%{opacity:0;transform:translate3d(0,100%,0)}to{opacity:1;transform:none}}@keyframes iziT-fadeInDown{0%{opacity:0;transform:translate3d(0,-100%,0)}to{opacity:1;transform:none}}@keyframes iziT-fadeInLeft{0%{opacity:0;transform:translate3d(300px,0,0)}to{opacity:1;transform:none}}@keyframes iziT-fadeInRight{0%{opacity:0;transform:translate3d(-300px,0,0)}to{opacity:1;transform:none}}@keyframes iziT-flipInX{0%{transform:perspective(400px) rotate3d(1,0,0,90deg);opacity:0}40%{transform:perspective(400px) rotate3d(1,0,0,-20deg)}60%{transform:perspective(400px) rotate3d(1,0,0,10deg);opacity:1}80%{transform:perspective(400px) rotate3d(1,0,0,-5deg)}to{transform:perspective(400px)}}@keyframes iziT-fadeOut{0%{opacity:1}to{opacity:0}}@keyframes iziT-fadeOutDown{0%{opacity:1}to{opacity:0;transform:translate3d(0,100%,0)}}@keyframes iziT-fadeOutUp{0%{opacity:1}to{opacity:0;transform:translate3d(0,-100%,0)}}@keyframes iziT-fadeOutLeft{0%{opacity:1}to{opacity:0;transform:translate3d(-200px,0,0)}}@keyframes iziT-fadeOutRight{0%{opacity:1}to{opacity:0;transform:translate3d(200px,0,0)}}@keyframes iziT-flipOutX{0%{transform:perspective(400px)}30%{transform:perspective(400px) rotate3d(1,0,0,-20deg);opacity:1}to{transform:perspective(400px) rotate3d(1,0,0,90deg);opacity:0}}", ""]);
  28590. // Exports
  28591. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  28592. /***/ }),
  28593. /***/ "./node_modules/css-loader/dist/runtime/api.js":
  28594. /*!*****************************************************!*\
  28595. !*** ./node_modules/css-loader/dist/runtime/api.js ***!
  28596. \*****************************************************/
  28597. /***/ ((module) => {
  28598. "use strict";
  28599. /*
  28600. MIT License http://www.opensource.org/licenses/mit-license.php
  28601. Author Tobias Koppers @sokra
  28602. */
  28603. // css base code, injected by the css-loader
  28604. // eslint-disable-next-line func-names
  28605. module.exports = function (cssWithMappingToString) {
  28606. var list = []; // return the list of modules as css string
  28607. list.toString = function toString() {
  28608. return this.map(function (item) {
  28609. var content = cssWithMappingToString(item);
  28610. if (item[2]) {
  28611. return "@media ".concat(item[2], " {").concat(content, "}");
  28612. }
  28613. return content;
  28614. }).join("");
  28615. }; // import a list of modules into the list
  28616. // eslint-disable-next-line func-names
  28617. list.i = function (modules, mediaQuery, dedupe) {
  28618. if (typeof modules === "string") {
  28619. // eslint-disable-next-line no-param-reassign
  28620. modules = [[null, modules, ""]];
  28621. }
  28622. var alreadyImportedModules = {};
  28623. if (dedupe) {
  28624. for (var i = 0; i < this.length; i++) {
  28625. // eslint-disable-next-line prefer-destructuring
  28626. var id = this[i][0];
  28627. if (id != null) {
  28628. alreadyImportedModules[id] = true;
  28629. }
  28630. }
  28631. }
  28632. for (var _i = 0; _i < modules.length; _i++) {
  28633. var item = [].concat(modules[_i]);
  28634. if (dedupe && alreadyImportedModules[item[0]]) {
  28635. // eslint-disable-next-line no-continue
  28636. continue;
  28637. }
  28638. if (mediaQuery) {
  28639. if (!item[2]) {
  28640. item[2] = mediaQuery;
  28641. } else {
  28642. item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
  28643. }
  28644. }
  28645. list.push(item);
  28646. }
  28647. };
  28648. return list;
  28649. };
  28650. /***/ }),
  28651. /***/ "./node_modules/des.js/lib/des.js":
  28652. /*!****************************************!*\
  28653. !*** ./node_modules/des.js/lib/des.js ***!
  28654. \****************************************/
  28655. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28656. "use strict";
  28657. exports.utils = __webpack_require__(/*! ./des/utils */ "./node_modules/des.js/lib/des/utils.js");
  28658. exports.Cipher = __webpack_require__(/*! ./des/cipher */ "./node_modules/des.js/lib/des/cipher.js");
  28659. exports.DES = __webpack_require__(/*! ./des/des */ "./node_modules/des.js/lib/des/des.js");
  28660. exports.CBC = __webpack_require__(/*! ./des/cbc */ "./node_modules/des.js/lib/des/cbc.js");
  28661. exports.EDE = __webpack_require__(/*! ./des/ede */ "./node_modules/des.js/lib/des/ede.js");
  28662. /***/ }),
  28663. /***/ "./node_modules/des.js/lib/des/cbc.js":
  28664. /*!********************************************!*\
  28665. !*** ./node_modules/des.js/lib/des/cbc.js ***!
  28666. \********************************************/
  28667. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28668. "use strict";
  28669. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  28670. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  28671. var proto = {};
  28672. function CBCState(iv) {
  28673. assert.equal(iv.length, 8, 'Invalid IV length');
  28674. this.iv = new Array(8);
  28675. for (var i = 0; i < this.iv.length; i++)
  28676. this.iv[i] = iv[i];
  28677. }
  28678. function instantiate(Base) {
  28679. function CBC(options) {
  28680. Base.call(this, options);
  28681. this._cbcInit();
  28682. }
  28683. inherits(CBC, Base);
  28684. var keys = Object.keys(proto);
  28685. for (var i = 0; i < keys.length; i++) {
  28686. var key = keys[i];
  28687. CBC.prototype[key] = proto[key];
  28688. }
  28689. CBC.create = function create(options) {
  28690. return new CBC(options);
  28691. };
  28692. return CBC;
  28693. }
  28694. exports.instantiate = instantiate;
  28695. proto._cbcInit = function _cbcInit() {
  28696. var state = new CBCState(this.options.iv);
  28697. this._cbcState = state;
  28698. };
  28699. proto._update = function _update(inp, inOff, out, outOff) {
  28700. var state = this._cbcState;
  28701. var superProto = this.constructor.super_.prototype;
  28702. var iv = state.iv;
  28703. if (this.type === 'encrypt') {
  28704. for (var i = 0; i < this.blockSize; i++)
  28705. iv[i] ^= inp[inOff + i];
  28706. superProto._update.call(this, iv, 0, out, outOff);
  28707. for (var i = 0; i < this.blockSize; i++)
  28708. iv[i] = out[outOff + i];
  28709. } else {
  28710. superProto._update.call(this, inp, inOff, out, outOff);
  28711. for (var i = 0; i < this.blockSize; i++)
  28712. out[outOff + i] ^= iv[i];
  28713. for (var i = 0; i < this.blockSize; i++)
  28714. iv[i] = inp[inOff + i];
  28715. }
  28716. };
  28717. /***/ }),
  28718. /***/ "./node_modules/des.js/lib/des/cipher.js":
  28719. /*!***********************************************!*\
  28720. !*** ./node_modules/des.js/lib/des/cipher.js ***!
  28721. \***********************************************/
  28722. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28723. "use strict";
  28724. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  28725. function Cipher(options) {
  28726. this.options = options;
  28727. this.type = this.options.type;
  28728. this.blockSize = 8;
  28729. this._init();
  28730. this.buffer = new Array(this.blockSize);
  28731. this.bufferOff = 0;
  28732. }
  28733. module.exports = Cipher;
  28734. Cipher.prototype._init = function _init() {
  28735. // Might be overrided
  28736. };
  28737. Cipher.prototype.update = function update(data) {
  28738. if (data.length === 0)
  28739. return [];
  28740. if (this.type === 'decrypt')
  28741. return this._updateDecrypt(data);
  28742. else
  28743. return this._updateEncrypt(data);
  28744. };
  28745. Cipher.prototype._buffer = function _buffer(data, off) {
  28746. // Append data to buffer
  28747. var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
  28748. for (var i = 0; i < min; i++)
  28749. this.buffer[this.bufferOff + i] = data[off + i];
  28750. this.bufferOff += min;
  28751. // Shift next
  28752. return min;
  28753. };
  28754. Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
  28755. this._update(this.buffer, 0, out, off);
  28756. this.bufferOff = 0;
  28757. return this.blockSize;
  28758. };
  28759. Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
  28760. var inputOff = 0;
  28761. var outputOff = 0;
  28762. var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
  28763. var out = new Array(count * this.blockSize);
  28764. if (this.bufferOff !== 0) {
  28765. inputOff += this._buffer(data, inputOff);
  28766. if (this.bufferOff === this.buffer.length)
  28767. outputOff += this._flushBuffer(out, outputOff);
  28768. }
  28769. // Write blocks
  28770. var max = data.length - ((data.length - inputOff) % this.blockSize);
  28771. for (; inputOff < max; inputOff += this.blockSize) {
  28772. this._update(data, inputOff, out, outputOff);
  28773. outputOff += this.blockSize;
  28774. }
  28775. // Queue rest
  28776. for (; inputOff < data.length; inputOff++, this.bufferOff++)
  28777. this.buffer[this.bufferOff] = data[inputOff];
  28778. return out;
  28779. };
  28780. Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
  28781. var inputOff = 0;
  28782. var outputOff = 0;
  28783. var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
  28784. var out = new Array(count * this.blockSize);
  28785. // TODO(indutny): optimize it, this is far from optimal
  28786. for (; count > 0; count--) {
  28787. inputOff += this._buffer(data, inputOff);
  28788. outputOff += this._flushBuffer(out, outputOff);
  28789. }
  28790. // Buffer rest of the input
  28791. inputOff += this._buffer(data, inputOff);
  28792. return out;
  28793. };
  28794. Cipher.prototype.final = function final(buffer) {
  28795. var first;
  28796. if (buffer)
  28797. first = this.update(buffer);
  28798. var last;
  28799. if (this.type === 'encrypt')
  28800. last = this._finalEncrypt();
  28801. else
  28802. last = this._finalDecrypt();
  28803. if (first)
  28804. return first.concat(last);
  28805. else
  28806. return last;
  28807. };
  28808. Cipher.prototype._pad = function _pad(buffer, off) {
  28809. if (off === 0)
  28810. return false;
  28811. while (off < buffer.length)
  28812. buffer[off++] = 0;
  28813. return true;
  28814. };
  28815. Cipher.prototype._finalEncrypt = function _finalEncrypt() {
  28816. if (!this._pad(this.buffer, this.bufferOff))
  28817. return [];
  28818. var out = new Array(this.blockSize);
  28819. this._update(this.buffer, 0, out, 0);
  28820. return out;
  28821. };
  28822. Cipher.prototype._unpad = function _unpad(buffer) {
  28823. return buffer;
  28824. };
  28825. Cipher.prototype._finalDecrypt = function _finalDecrypt() {
  28826. assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
  28827. var out = new Array(this.blockSize);
  28828. this._flushBuffer(out, 0);
  28829. return this._unpad(out);
  28830. };
  28831. /***/ }),
  28832. /***/ "./node_modules/des.js/lib/des/des.js":
  28833. /*!********************************************!*\
  28834. !*** ./node_modules/des.js/lib/des/des.js ***!
  28835. \********************************************/
  28836. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28837. "use strict";
  28838. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  28839. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  28840. var utils = __webpack_require__(/*! ./utils */ "./node_modules/des.js/lib/des/utils.js");
  28841. var Cipher = __webpack_require__(/*! ./cipher */ "./node_modules/des.js/lib/des/cipher.js");
  28842. function DESState() {
  28843. this.tmp = new Array(2);
  28844. this.keys = null;
  28845. }
  28846. function DES(options) {
  28847. Cipher.call(this, options);
  28848. var state = new DESState();
  28849. this._desState = state;
  28850. this.deriveKeys(state, options.key);
  28851. }
  28852. inherits(DES, Cipher);
  28853. module.exports = DES;
  28854. DES.create = function create(options) {
  28855. return new DES(options);
  28856. };
  28857. var shiftTable = [
  28858. 1, 1, 2, 2, 2, 2, 2, 2,
  28859. 1, 2, 2, 2, 2, 2, 2, 1
  28860. ];
  28861. DES.prototype.deriveKeys = function deriveKeys(state, key) {
  28862. state.keys = new Array(16 * 2);
  28863. assert.equal(key.length, this.blockSize, 'Invalid key length');
  28864. var kL = utils.readUInt32BE(key, 0);
  28865. var kR = utils.readUInt32BE(key, 4);
  28866. utils.pc1(kL, kR, state.tmp, 0);
  28867. kL = state.tmp[0];
  28868. kR = state.tmp[1];
  28869. for (var i = 0; i < state.keys.length; i += 2) {
  28870. var shift = shiftTable[i >>> 1];
  28871. kL = utils.r28shl(kL, shift);
  28872. kR = utils.r28shl(kR, shift);
  28873. utils.pc2(kL, kR, state.keys, i);
  28874. }
  28875. };
  28876. DES.prototype._update = function _update(inp, inOff, out, outOff) {
  28877. var state = this._desState;
  28878. var l = utils.readUInt32BE(inp, inOff);
  28879. var r = utils.readUInt32BE(inp, inOff + 4);
  28880. // Initial Permutation
  28881. utils.ip(l, r, state.tmp, 0);
  28882. l = state.tmp[0];
  28883. r = state.tmp[1];
  28884. if (this.type === 'encrypt')
  28885. this._encrypt(state, l, r, state.tmp, 0);
  28886. else
  28887. this._decrypt(state, l, r, state.tmp, 0);
  28888. l = state.tmp[0];
  28889. r = state.tmp[1];
  28890. utils.writeUInt32BE(out, l, outOff);
  28891. utils.writeUInt32BE(out, r, outOff + 4);
  28892. };
  28893. DES.prototype._pad = function _pad(buffer, off) {
  28894. var value = buffer.length - off;
  28895. for (var i = off; i < buffer.length; i++)
  28896. buffer[i] = value;
  28897. return true;
  28898. };
  28899. DES.prototype._unpad = function _unpad(buffer) {
  28900. var pad = buffer[buffer.length - 1];
  28901. for (var i = buffer.length - pad; i < buffer.length; i++)
  28902. assert.equal(buffer[i], pad);
  28903. return buffer.slice(0, buffer.length - pad);
  28904. };
  28905. DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
  28906. var l = lStart;
  28907. var r = rStart;
  28908. // Apply f() x16 times
  28909. for (var i = 0; i < state.keys.length; i += 2) {
  28910. var keyL = state.keys[i];
  28911. var keyR = state.keys[i + 1];
  28912. // f(r, k)
  28913. utils.expand(r, state.tmp, 0);
  28914. keyL ^= state.tmp[0];
  28915. keyR ^= state.tmp[1];
  28916. var s = utils.substitute(keyL, keyR);
  28917. var f = utils.permute(s);
  28918. var t = r;
  28919. r = (l ^ f) >>> 0;
  28920. l = t;
  28921. }
  28922. // Reverse Initial Permutation
  28923. utils.rip(r, l, out, off);
  28924. };
  28925. DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
  28926. var l = rStart;
  28927. var r = lStart;
  28928. // Apply f() x16 times
  28929. for (var i = state.keys.length - 2; i >= 0; i -= 2) {
  28930. var keyL = state.keys[i];
  28931. var keyR = state.keys[i + 1];
  28932. // f(r, k)
  28933. utils.expand(l, state.tmp, 0);
  28934. keyL ^= state.tmp[0];
  28935. keyR ^= state.tmp[1];
  28936. var s = utils.substitute(keyL, keyR);
  28937. var f = utils.permute(s);
  28938. var t = l;
  28939. l = (r ^ f) >>> 0;
  28940. r = t;
  28941. }
  28942. // Reverse Initial Permutation
  28943. utils.rip(l, r, out, off);
  28944. };
  28945. /***/ }),
  28946. /***/ "./node_modules/des.js/lib/des/ede.js":
  28947. /*!********************************************!*\
  28948. !*** ./node_modules/des.js/lib/des/ede.js ***!
  28949. \********************************************/
  28950. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28951. "use strict";
  28952. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  28953. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  28954. var Cipher = __webpack_require__(/*! ./cipher */ "./node_modules/des.js/lib/des/cipher.js");
  28955. var DES = __webpack_require__(/*! ./des */ "./node_modules/des.js/lib/des/des.js");
  28956. function EDEState(type, key) {
  28957. assert.equal(key.length, 24, 'Invalid key length');
  28958. var k1 = key.slice(0, 8);
  28959. var k2 = key.slice(8, 16);
  28960. var k3 = key.slice(16, 24);
  28961. if (type === 'encrypt') {
  28962. this.ciphers = [
  28963. DES.create({ type: 'encrypt', key: k1 }),
  28964. DES.create({ type: 'decrypt', key: k2 }),
  28965. DES.create({ type: 'encrypt', key: k3 })
  28966. ];
  28967. } else {
  28968. this.ciphers = [
  28969. DES.create({ type: 'decrypt', key: k3 }),
  28970. DES.create({ type: 'encrypt', key: k2 }),
  28971. DES.create({ type: 'decrypt', key: k1 })
  28972. ];
  28973. }
  28974. }
  28975. function EDE(options) {
  28976. Cipher.call(this, options);
  28977. var state = new EDEState(this.type, this.options.key);
  28978. this._edeState = state;
  28979. }
  28980. inherits(EDE, Cipher);
  28981. module.exports = EDE;
  28982. EDE.create = function create(options) {
  28983. return new EDE(options);
  28984. };
  28985. EDE.prototype._update = function _update(inp, inOff, out, outOff) {
  28986. var state = this._edeState;
  28987. state.ciphers[0]._update(inp, inOff, out, outOff);
  28988. state.ciphers[1]._update(out, outOff, out, outOff);
  28989. state.ciphers[2]._update(out, outOff, out, outOff);
  28990. };
  28991. EDE.prototype._pad = DES.prototype._pad;
  28992. EDE.prototype._unpad = DES.prototype._unpad;
  28993. /***/ }),
  28994. /***/ "./node_modules/des.js/lib/des/utils.js":
  28995. /*!**********************************************!*\
  28996. !*** ./node_modules/des.js/lib/des/utils.js ***!
  28997. \**********************************************/
  28998. /***/ ((__unused_webpack_module, exports) => {
  28999. "use strict";
  29000. exports.readUInt32BE = function readUInt32BE(bytes, off) {
  29001. var res = (bytes[0 + off] << 24) |
  29002. (bytes[1 + off] << 16) |
  29003. (bytes[2 + off] << 8) |
  29004. bytes[3 + off];
  29005. return res >>> 0;
  29006. };
  29007. exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
  29008. bytes[0 + off] = value >>> 24;
  29009. bytes[1 + off] = (value >>> 16) & 0xff;
  29010. bytes[2 + off] = (value >>> 8) & 0xff;
  29011. bytes[3 + off] = value & 0xff;
  29012. };
  29013. exports.ip = function ip(inL, inR, out, off) {
  29014. var outL = 0;
  29015. var outR = 0;
  29016. for (var i = 6; i >= 0; i -= 2) {
  29017. for (var j = 0; j <= 24; j += 8) {
  29018. outL <<= 1;
  29019. outL |= (inR >>> (j + i)) & 1;
  29020. }
  29021. for (var j = 0; j <= 24; j += 8) {
  29022. outL <<= 1;
  29023. outL |= (inL >>> (j + i)) & 1;
  29024. }
  29025. }
  29026. for (var i = 6; i >= 0; i -= 2) {
  29027. for (var j = 1; j <= 25; j += 8) {
  29028. outR <<= 1;
  29029. outR |= (inR >>> (j + i)) & 1;
  29030. }
  29031. for (var j = 1; j <= 25; j += 8) {
  29032. outR <<= 1;
  29033. outR |= (inL >>> (j + i)) & 1;
  29034. }
  29035. }
  29036. out[off + 0] = outL >>> 0;
  29037. out[off + 1] = outR >>> 0;
  29038. };
  29039. exports.rip = function rip(inL, inR, out, off) {
  29040. var outL = 0;
  29041. var outR = 0;
  29042. for (var i = 0; i < 4; i++) {
  29043. for (var j = 24; j >= 0; j -= 8) {
  29044. outL <<= 1;
  29045. outL |= (inR >>> (j + i)) & 1;
  29046. outL <<= 1;
  29047. outL |= (inL >>> (j + i)) & 1;
  29048. }
  29049. }
  29050. for (var i = 4; i < 8; i++) {
  29051. for (var j = 24; j >= 0; j -= 8) {
  29052. outR <<= 1;
  29053. outR |= (inR >>> (j + i)) & 1;
  29054. outR <<= 1;
  29055. outR |= (inL >>> (j + i)) & 1;
  29056. }
  29057. }
  29058. out[off + 0] = outL >>> 0;
  29059. out[off + 1] = outR >>> 0;
  29060. };
  29061. exports.pc1 = function pc1(inL, inR, out, off) {
  29062. var outL = 0;
  29063. var outR = 0;
  29064. // 7, 15, 23, 31, 39, 47, 55, 63
  29065. // 6, 14, 22, 30, 39, 47, 55, 63
  29066. // 5, 13, 21, 29, 39, 47, 55, 63
  29067. // 4, 12, 20, 28
  29068. for (var i = 7; i >= 5; i--) {
  29069. for (var j = 0; j <= 24; j += 8) {
  29070. outL <<= 1;
  29071. outL |= (inR >> (j + i)) & 1;
  29072. }
  29073. for (var j = 0; j <= 24; j += 8) {
  29074. outL <<= 1;
  29075. outL |= (inL >> (j + i)) & 1;
  29076. }
  29077. }
  29078. for (var j = 0; j <= 24; j += 8) {
  29079. outL <<= 1;
  29080. outL |= (inR >> (j + i)) & 1;
  29081. }
  29082. // 1, 9, 17, 25, 33, 41, 49, 57
  29083. // 2, 10, 18, 26, 34, 42, 50, 58
  29084. // 3, 11, 19, 27, 35, 43, 51, 59
  29085. // 36, 44, 52, 60
  29086. for (var i = 1; i <= 3; i++) {
  29087. for (var j = 0; j <= 24; j += 8) {
  29088. outR <<= 1;
  29089. outR |= (inR >> (j + i)) & 1;
  29090. }
  29091. for (var j = 0; j <= 24; j += 8) {
  29092. outR <<= 1;
  29093. outR |= (inL >> (j + i)) & 1;
  29094. }
  29095. }
  29096. for (var j = 0; j <= 24; j += 8) {
  29097. outR <<= 1;
  29098. outR |= (inL >> (j + i)) & 1;
  29099. }
  29100. out[off + 0] = outL >>> 0;
  29101. out[off + 1] = outR >>> 0;
  29102. };
  29103. exports.r28shl = function r28shl(num, shift) {
  29104. return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
  29105. };
  29106. var pc2table = [
  29107. // inL => outL
  29108. 14, 11, 17, 4, 27, 23, 25, 0,
  29109. 13, 22, 7, 18, 5, 9, 16, 24,
  29110. 2, 20, 12, 21, 1, 8, 15, 26,
  29111. // inR => outR
  29112. 15, 4, 25, 19, 9, 1, 26, 16,
  29113. 5, 11, 23, 8, 12, 7, 17, 0,
  29114. 22, 3, 10, 14, 6, 20, 27, 24
  29115. ];
  29116. exports.pc2 = function pc2(inL, inR, out, off) {
  29117. var outL = 0;
  29118. var outR = 0;
  29119. var len = pc2table.length >>> 1;
  29120. for (var i = 0; i < len; i++) {
  29121. outL <<= 1;
  29122. outL |= (inL >>> pc2table[i]) & 0x1;
  29123. }
  29124. for (var i = len; i < pc2table.length; i++) {
  29125. outR <<= 1;
  29126. outR |= (inR >>> pc2table[i]) & 0x1;
  29127. }
  29128. out[off + 0] = outL >>> 0;
  29129. out[off + 1] = outR >>> 0;
  29130. };
  29131. exports.expand = function expand(r, out, off) {
  29132. var outL = 0;
  29133. var outR = 0;
  29134. outL = ((r & 1) << 5) | (r >>> 27);
  29135. for (var i = 23; i >= 15; i -= 4) {
  29136. outL <<= 6;
  29137. outL |= (r >>> i) & 0x3f;
  29138. }
  29139. for (var i = 11; i >= 3; i -= 4) {
  29140. outR |= (r >>> i) & 0x3f;
  29141. outR <<= 6;
  29142. }
  29143. outR |= ((r & 0x1f) << 1) | (r >>> 31);
  29144. out[off + 0] = outL >>> 0;
  29145. out[off + 1] = outR >>> 0;
  29146. };
  29147. var sTable = [
  29148. 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
  29149. 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
  29150. 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
  29151. 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
  29152. 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
  29153. 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
  29154. 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
  29155. 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
  29156. 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
  29157. 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
  29158. 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
  29159. 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
  29160. 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
  29161. 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
  29162. 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
  29163. 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
  29164. 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
  29165. 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
  29166. 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
  29167. 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
  29168. 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
  29169. 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
  29170. 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
  29171. 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
  29172. 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
  29173. 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
  29174. 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
  29175. 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
  29176. 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
  29177. 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
  29178. 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
  29179. 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
  29180. ];
  29181. exports.substitute = function substitute(inL, inR) {
  29182. var out = 0;
  29183. for (var i = 0; i < 4; i++) {
  29184. var b = (inL >>> (18 - i * 6)) & 0x3f;
  29185. var sb = sTable[i * 0x40 + b];
  29186. out <<= 4;
  29187. out |= sb;
  29188. }
  29189. for (var i = 0; i < 4; i++) {
  29190. var b = (inR >>> (18 - i * 6)) & 0x3f;
  29191. var sb = sTable[4 * 0x40 + i * 0x40 + b];
  29192. out <<= 4;
  29193. out |= sb;
  29194. }
  29195. return out >>> 0;
  29196. };
  29197. var permuteTable = [
  29198. 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
  29199. 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
  29200. ];
  29201. exports.permute = function permute(num) {
  29202. var out = 0;
  29203. for (var i = 0; i < permuteTable.length; i++) {
  29204. out <<= 1;
  29205. out |= (num >>> permuteTable[i]) & 0x1;
  29206. }
  29207. return out >>> 0;
  29208. };
  29209. exports.padSplit = function padSplit(num, size, group) {
  29210. var str = num.toString(2);
  29211. while (str.length < size)
  29212. str = '0' + str;
  29213. var out = [];
  29214. for (var i = 0; i < size; i += group)
  29215. out.push(str.slice(i, i + group));
  29216. return out.join(' ');
  29217. };
  29218. /***/ }),
  29219. /***/ "./node_modules/diffie-hellman/browser.js":
  29220. /*!************************************************!*\
  29221. !*** ./node_modules/diffie-hellman/browser.js ***!
  29222. \************************************************/
  29223. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  29224. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
  29225. var generatePrime = __webpack_require__(/*! ./lib/generatePrime */ "./node_modules/diffie-hellman/lib/generatePrime.js")
  29226. var primes = __webpack_require__(/*! ./lib/primes.json */ "./node_modules/diffie-hellman/lib/primes.json")
  29227. var DH = __webpack_require__(/*! ./lib/dh */ "./node_modules/diffie-hellman/lib/dh.js")
  29228. function getDiffieHellman (mod) {
  29229. var prime = new Buffer(primes[mod].prime, 'hex')
  29230. var gen = new Buffer(primes[mod].gen, 'hex')
  29231. return new DH(prime, gen)
  29232. }
  29233. var ENCODINGS = {
  29234. 'binary': true, 'hex': true, 'base64': true
  29235. }
  29236. function createDiffieHellman (prime, enc, generator, genc) {
  29237. if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
  29238. return createDiffieHellman(prime, 'binary', enc, generator)
  29239. }
  29240. enc = enc || 'binary'
  29241. genc = genc || 'binary'
  29242. generator = generator || new Buffer([2])
  29243. if (!Buffer.isBuffer(generator)) {
  29244. generator = new Buffer(generator, genc)
  29245. }
  29246. if (typeof prime === 'number') {
  29247. return new DH(generatePrime(prime, generator), generator, true)
  29248. }
  29249. if (!Buffer.isBuffer(prime)) {
  29250. prime = new Buffer(prime, enc)
  29251. }
  29252. return new DH(prime, generator, true)
  29253. }
  29254. exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
  29255. exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
  29256. /***/ }),
  29257. /***/ "./node_modules/diffie-hellman/lib/dh.js":
  29258. /*!***********************************************!*\
  29259. !*** ./node_modules/diffie-hellman/lib/dh.js ***!
  29260. \***********************************************/
  29261. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29262. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")["Buffer"];
  29263. var BN = __webpack_require__(/*! bn.js */ "./node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  29264. var MillerRabin = __webpack_require__(/*! miller-rabin */ "./node_modules/miller-rabin/lib/mr.js");
  29265. var millerRabin = new MillerRabin();
  29266. var TWENTYFOUR = new BN(24);
  29267. var ELEVEN = new BN(11);
  29268. var TEN = new BN(10);
  29269. var THREE = new BN(3);
  29270. var SEVEN = new BN(7);
  29271. var primes = __webpack_require__(/*! ./generatePrime */ "./node_modules/diffie-hellman/lib/generatePrime.js");
  29272. var randomBytes = __webpack_require__(/*! randombytes */ "./node_modules/randombytes/browser.js");
  29273. module.exports = DH;
  29274. function setPublicKey(pub, enc) {
  29275. enc = enc || 'utf8';
  29276. if (!Buffer.isBuffer(pub)) {
  29277. pub = new Buffer(pub, enc);
  29278. }
  29279. this._pub = new BN(pub);
  29280. return this;
  29281. }
  29282. function setPrivateKey(priv, enc) {
  29283. enc = enc || 'utf8';
  29284. if (!Buffer.isBuffer(priv)) {
  29285. priv = new Buffer(priv, enc);
  29286. }
  29287. this._priv = new BN(priv);
  29288. return this;
  29289. }
  29290. var primeCache = {};
  29291. function checkPrime(prime, generator) {
  29292. var gen = generator.toString('hex');
  29293. var hex = [gen, prime.toString(16)].join('_');
  29294. if (hex in primeCache) {
  29295. return primeCache[hex];
  29296. }
  29297. var error = 0;
  29298. if (prime.isEven() ||
  29299. !primes.simpleSieve ||
  29300. !primes.fermatTest(prime) ||
  29301. !millerRabin.test(prime)) {
  29302. //not a prime so +1
  29303. error += 1;
  29304. if (gen === '02' || gen === '05') {
  29305. // we'd be able to check the generator
  29306. // it would fail so +8
  29307. error += 8;
  29308. } else {
  29309. //we wouldn't be able to test the generator
  29310. // so +4
  29311. error += 4;
  29312. }
  29313. primeCache[hex] = error;
  29314. return error;
  29315. }
  29316. if (!millerRabin.test(prime.shrn(1))) {
  29317. //not a safe prime
  29318. error += 2;
  29319. }
  29320. var rem;
  29321. switch (gen) {
  29322. case '02':
  29323. if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
  29324. // unsuidable generator
  29325. error += 8;
  29326. }
  29327. break;
  29328. case '05':
  29329. rem = prime.mod(TEN);
  29330. if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
  29331. // prime mod 10 needs to equal 3 or 7
  29332. error += 8;
  29333. }
  29334. break;
  29335. default:
  29336. error += 4;
  29337. }
  29338. primeCache[hex] = error;
  29339. return error;
  29340. }
  29341. function DH(prime, generator, malleable) {
  29342. this.setGenerator(generator);
  29343. this.__prime = new BN(prime);
  29344. this._prime = BN.mont(this.__prime);
  29345. this._primeLen = prime.length;
  29346. this._pub = undefined;
  29347. this._priv = undefined;
  29348. this._primeCode = undefined;
  29349. if (malleable) {
  29350. this.setPublicKey = setPublicKey;
  29351. this.setPrivateKey = setPrivateKey;
  29352. } else {
  29353. this._primeCode = 8;
  29354. }
  29355. }
  29356. Object.defineProperty(DH.prototype, 'verifyError', {
  29357. enumerable: true,
  29358. get: function () {
  29359. if (typeof this._primeCode !== 'number') {
  29360. this._primeCode = checkPrime(this.__prime, this.__gen);
  29361. }
  29362. return this._primeCode;
  29363. }
  29364. });
  29365. DH.prototype.generateKeys = function () {
  29366. if (!this._priv) {
  29367. this._priv = new BN(randomBytes(this._primeLen));
  29368. }
  29369. this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
  29370. return this.getPublicKey();
  29371. };
  29372. DH.prototype.computeSecret = function (other) {
  29373. other = new BN(other);
  29374. other = other.toRed(this._prime);
  29375. var secret = other.redPow(this._priv).fromRed();
  29376. var out = new Buffer(secret.toArray());
  29377. var prime = this.getPrime();
  29378. if (out.length < prime.length) {
  29379. var front = new Buffer(prime.length - out.length);
  29380. front.fill(0);
  29381. out = Buffer.concat([front, out]);
  29382. }
  29383. return out;
  29384. };
  29385. DH.prototype.getPublicKey = function getPublicKey(enc) {
  29386. return formatReturnValue(this._pub, enc);
  29387. };
  29388. DH.prototype.getPrivateKey = function getPrivateKey(enc) {
  29389. return formatReturnValue(this._priv, enc);
  29390. };
  29391. DH.prototype.getPrime = function (enc) {
  29392. return formatReturnValue(this.__prime, enc);
  29393. };
  29394. DH.prototype.getGenerator = function (enc) {
  29395. return formatReturnValue(this._gen, enc);
  29396. };
  29397. DH.prototype.setGenerator = function (gen, enc) {
  29398. enc = enc || 'utf8';
  29399. if (!Buffer.isBuffer(gen)) {
  29400. gen = new Buffer(gen, enc);
  29401. }
  29402. this.__gen = gen;
  29403. this._gen = new BN(gen);
  29404. return this;
  29405. };
  29406. function formatReturnValue(bn, enc) {
  29407. var buf = new Buffer(bn.toArray());
  29408. if (!enc) {
  29409. return buf;
  29410. } else {
  29411. return buf.toString(enc);
  29412. }
  29413. }
  29414. /***/ }),
  29415. /***/ "./node_modules/diffie-hellman/lib/generatePrime.js":
  29416. /*!**********************************************************!*\
  29417. !*** ./node_modules/diffie-hellman/lib/generatePrime.js ***!
  29418. \**********************************************************/
  29419. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29420. var randomBytes = __webpack_require__(/*! randombytes */ "./node_modules/randombytes/browser.js");
  29421. module.exports = findPrime;
  29422. findPrime.simpleSieve = simpleSieve;
  29423. findPrime.fermatTest = fermatTest;
  29424. var BN = __webpack_require__(/*! bn.js */ "./node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  29425. var TWENTYFOUR = new BN(24);
  29426. var MillerRabin = __webpack_require__(/*! miller-rabin */ "./node_modules/miller-rabin/lib/mr.js");
  29427. var millerRabin = new MillerRabin();
  29428. var ONE = new BN(1);
  29429. var TWO = new BN(2);
  29430. var FIVE = new BN(5);
  29431. var SIXTEEN = new BN(16);
  29432. var EIGHT = new BN(8);
  29433. var TEN = new BN(10);
  29434. var THREE = new BN(3);
  29435. var SEVEN = new BN(7);
  29436. var ELEVEN = new BN(11);
  29437. var FOUR = new BN(4);
  29438. var TWELVE = new BN(12);
  29439. var primes = null;
  29440. function _getPrimes() {
  29441. if (primes !== null)
  29442. return primes;
  29443. var limit = 0x100000;
  29444. var res = [];
  29445. res[0] = 2;
  29446. for (var i = 1, k = 3; k < limit; k += 2) {
  29447. var sqrt = Math.ceil(Math.sqrt(k));
  29448. for (var j = 0; j < i && res[j] <= sqrt; j++)
  29449. if (k % res[j] === 0)
  29450. break;
  29451. if (i !== j && res[j] <= sqrt)
  29452. continue;
  29453. res[i++] = k;
  29454. }
  29455. primes = res;
  29456. return res;
  29457. }
  29458. function simpleSieve(p) {
  29459. var primes = _getPrimes();
  29460. for (var i = 0; i < primes.length; i++)
  29461. if (p.modn(primes[i]) === 0) {
  29462. if (p.cmpn(primes[i]) === 0) {
  29463. return true;
  29464. } else {
  29465. return false;
  29466. }
  29467. }
  29468. return true;
  29469. }
  29470. function fermatTest(p) {
  29471. var red = BN.mont(p);
  29472. return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
  29473. }
  29474. function findPrime(bits, gen) {
  29475. if (bits < 16) {
  29476. // this is what openssl does
  29477. if (gen === 2 || gen === 5) {
  29478. return new BN([0x8c, 0x7b]);
  29479. } else {
  29480. return new BN([0x8c, 0x27]);
  29481. }
  29482. }
  29483. gen = new BN(gen);
  29484. var num, n2;
  29485. while (true) {
  29486. num = new BN(randomBytes(Math.ceil(bits / 8)));
  29487. while (num.bitLength() > bits) {
  29488. num.ishrn(1);
  29489. }
  29490. if (num.isEven()) {
  29491. num.iadd(ONE);
  29492. }
  29493. if (!num.testn(1)) {
  29494. num.iadd(TWO);
  29495. }
  29496. if (!gen.cmp(TWO)) {
  29497. while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
  29498. num.iadd(FOUR);
  29499. }
  29500. } else if (!gen.cmp(FIVE)) {
  29501. while (num.mod(TEN).cmp(THREE)) {
  29502. num.iadd(FOUR);
  29503. }
  29504. }
  29505. n2 = num.shrn(1);
  29506. if (simpleSieve(n2) && simpleSieve(num) &&
  29507. fermatTest(n2) && fermatTest(num) &&
  29508. millerRabin.test(n2) && millerRabin.test(num)) {
  29509. return num;
  29510. }
  29511. }
  29512. }
  29513. /***/ }),
  29514. /***/ "./node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js":
  29515. /*!******************************************************************!*\
  29516. !*** ./node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js ***!
  29517. \******************************************************************/
  29518. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  29519. /* module decorator */ module = __webpack_require__.nmd(module);
  29520. (function (module, exports) {
  29521. 'use strict';
  29522. // Utils
  29523. function assert (val, msg) {
  29524. if (!val) throw new Error(msg || 'Assertion failed');
  29525. }
  29526. // Could use `inherits` module, but don't want to move from single file
  29527. // architecture yet.
  29528. function inherits (ctor, superCtor) {
  29529. ctor.super_ = superCtor;
  29530. var TempCtor = function () {};
  29531. TempCtor.prototype = superCtor.prototype;
  29532. ctor.prototype = new TempCtor();
  29533. ctor.prototype.constructor = ctor;
  29534. }
  29535. // BN
  29536. function BN (number, base, endian) {
  29537. if (BN.isBN(number)) {
  29538. return number;
  29539. }
  29540. this.negative = 0;
  29541. this.words = null;
  29542. this.length = 0;
  29543. // Reduction context
  29544. this.red = null;
  29545. if (number !== null) {
  29546. if (base === 'le' || base === 'be') {
  29547. endian = base;
  29548. base = 10;
  29549. }
  29550. this._init(number || 0, base || 10, endian || 'be');
  29551. }
  29552. }
  29553. if (typeof module === 'object') {
  29554. module.exports = BN;
  29555. } else {
  29556. exports.BN = BN;
  29557. }
  29558. BN.BN = BN;
  29559. BN.wordSize = 26;
  29560. var Buffer;
  29561. try {
  29562. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  29563. Buffer = window.Buffer;
  29564. } else {
  29565. Buffer = (__webpack_require__(/*! buffer */ "?8f95").Buffer);
  29566. }
  29567. } catch (e) {
  29568. }
  29569. BN.isBN = function isBN (num) {
  29570. if (num instanceof BN) {
  29571. return true;
  29572. }
  29573. return num !== null && typeof num === 'object' &&
  29574. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  29575. };
  29576. BN.max = function max (left, right) {
  29577. if (left.cmp(right) > 0) return left;
  29578. return right;
  29579. };
  29580. BN.min = function min (left, right) {
  29581. if (left.cmp(right) < 0) return left;
  29582. return right;
  29583. };
  29584. BN.prototype._init = function init (number, base, endian) {
  29585. if (typeof number === 'number') {
  29586. return this._initNumber(number, base, endian);
  29587. }
  29588. if (typeof number === 'object') {
  29589. return this._initArray(number, base, endian);
  29590. }
  29591. if (base === 'hex') {
  29592. base = 16;
  29593. }
  29594. assert(base === (base | 0) && base >= 2 && base <= 36);
  29595. number = number.toString().replace(/\s+/g, '');
  29596. var start = 0;
  29597. if (number[0] === '-') {
  29598. start++;
  29599. this.negative = 1;
  29600. }
  29601. if (start < number.length) {
  29602. if (base === 16) {
  29603. this._parseHex(number, start, endian);
  29604. } else {
  29605. this._parseBase(number, base, start);
  29606. if (endian === 'le') {
  29607. this._initArray(this.toArray(), base, endian);
  29608. }
  29609. }
  29610. }
  29611. };
  29612. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  29613. if (number < 0) {
  29614. this.negative = 1;
  29615. number = -number;
  29616. }
  29617. if (number < 0x4000000) {
  29618. this.words = [ number & 0x3ffffff ];
  29619. this.length = 1;
  29620. } else if (number < 0x10000000000000) {
  29621. this.words = [
  29622. number & 0x3ffffff,
  29623. (number / 0x4000000) & 0x3ffffff
  29624. ];
  29625. this.length = 2;
  29626. } else {
  29627. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  29628. this.words = [
  29629. number & 0x3ffffff,
  29630. (number / 0x4000000) & 0x3ffffff,
  29631. 1
  29632. ];
  29633. this.length = 3;
  29634. }
  29635. if (endian !== 'le') return;
  29636. // Reverse the bytes
  29637. this._initArray(this.toArray(), base, endian);
  29638. };
  29639. BN.prototype._initArray = function _initArray (number, base, endian) {
  29640. // Perhaps a Uint8Array
  29641. assert(typeof number.length === 'number');
  29642. if (number.length <= 0) {
  29643. this.words = [ 0 ];
  29644. this.length = 1;
  29645. return this;
  29646. }
  29647. this.length = Math.ceil(number.length / 3);
  29648. this.words = new Array(this.length);
  29649. for (var i = 0; i < this.length; i++) {
  29650. this.words[i] = 0;
  29651. }
  29652. var j, w;
  29653. var off = 0;
  29654. if (endian === 'be') {
  29655. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  29656. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  29657. this.words[j] |= (w << off) & 0x3ffffff;
  29658. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  29659. off += 24;
  29660. if (off >= 26) {
  29661. off -= 26;
  29662. j++;
  29663. }
  29664. }
  29665. } else if (endian === 'le') {
  29666. for (i = 0, j = 0; i < number.length; i += 3) {
  29667. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  29668. this.words[j] |= (w << off) & 0x3ffffff;
  29669. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  29670. off += 24;
  29671. if (off >= 26) {
  29672. off -= 26;
  29673. j++;
  29674. }
  29675. }
  29676. }
  29677. return this.strip();
  29678. };
  29679. function parseHex4Bits (string, index) {
  29680. var c = string.charCodeAt(index);
  29681. // 'A' - 'F'
  29682. if (c >= 65 && c <= 70) {
  29683. return c - 55;
  29684. // 'a' - 'f'
  29685. } else if (c >= 97 && c <= 102) {
  29686. return c - 87;
  29687. // '0' - '9'
  29688. } else {
  29689. return (c - 48) & 0xf;
  29690. }
  29691. }
  29692. function parseHexByte (string, lowerBound, index) {
  29693. var r = parseHex4Bits(string, index);
  29694. if (index - 1 >= lowerBound) {
  29695. r |= parseHex4Bits(string, index - 1) << 4;
  29696. }
  29697. return r;
  29698. }
  29699. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  29700. // Create possibly bigger array to ensure that it fits the number
  29701. this.length = Math.ceil((number.length - start) / 6);
  29702. this.words = new Array(this.length);
  29703. for (var i = 0; i < this.length; i++) {
  29704. this.words[i] = 0;
  29705. }
  29706. // 24-bits chunks
  29707. var off = 0;
  29708. var j = 0;
  29709. var w;
  29710. if (endian === 'be') {
  29711. for (i = number.length - 1; i >= start; i -= 2) {
  29712. w = parseHexByte(number, start, i) << off;
  29713. this.words[j] |= w & 0x3ffffff;
  29714. if (off >= 18) {
  29715. off -= 18;
  29716. j += 1;
  29717. this.words[j] |= w >>> 26;
  29718. } else {
  29719. off += 8;
  29720. }
  29721. }
  29722. } else {
  29723. var parseLength = number.length - start;
  29724. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  29725. w = parseHexByte(number, start, i) << off;
  29726. this.words[j] |= w & 0x3ffffff;
  29727. if (off >= 18) {
  29728. off -= 18;
  29729. j += 1;
  29730. this.words[j] |= w >>> 26;
  29731. } else {
  29732. off += 8;
  29733. }
  29734. }
  29735. }
  29736. this.strip();
  29737. };
  29738. function parseBase (str, start, end, mul) {
  29739. var r = 0;
  29740. var len = Math.min(str.length, end);
  29741. for (var i = start; i < len; i++) {
  29742. var c = str.charCodeAt(i) - 48;
  29743. r *= mul;
  29744. // 'a'
  29745. if (c >= 49) {
  29746. r += c - 49 + 0xa;
  29747. // 'A'
  29748. } else if (c >= 17) {
  29749. r += c - 17 + 0xa;
  29750. // '0' - '9'
  29751. } else {
  29752. r += c;
  29753. }
  29754. }
  29755. return r;
  29756. }
  29757. BN.prototype._parseBase = function _parseBase (number, base, start) {
  29758. // Initialize as zero
  29759. this.words = [ 0 ];
  29760. this.length = 1;
  29761. // Find length of limb in base
  29762. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  29763. limbLen++;
  29764. }
  29765. limbLen--;
  29766. limbPow = (limbPow / base) | 0;
  29767. var total = number.length - start;
  29768. var mod = total % limbLen;
  29769. var end = Math.min(total, total - mod) + start;
  29770. var word = 0;
  29771. for (var i = start; i < end; i += limbLen) {
  29772. word = parseBase(number, i, i + limbLen, base);
  29773. this.imuln(limbPow);
  29774. if (this.words[0] + word < 0x4000000) {
  29775. this.words[0] += word;
  29776. } else {
  29777. this._iaddn(word);
  29778. }
  29779. }
  29780. if (mod !== 0) {
  29781. var pow = 1;
  29782. word = parseBase(number, i, number.length, base);
  29783. for (i = 0; i < mod; i++) {
  29784. pow *= base;
  29785. }
  29786. this.imuln(pow);
  29787. if (this.words[0] + word < 0x4000000) {
  29788. this.words[0] += word;
  29789. } else {
  29790. this._iaddn(word);
  29791. }
  29792. }
  29793. this.strip();
  29794. };
  29795. BN.prototype.copy = function copy (dest) {
  29796. dest.words = new Array(this.length);
  29797. for (var i = 0; i < this.length; i++) {
  29798. dest.words[i] = this.words[i];
  29799. }
  29800. dest.length = this.length;
  29801. dest.negative = this.negative;
  29802. dest.red = this.red;
  29803. };
  29804. BN.prototype.clone = function clone () {
  29805. var r = new BN(null);
  29806. this.copy(r);
  29807. return r;
  29808. };
  29809. BN.prototype._expand = function _expand (size) {
  29810. while (this.length < size) {
  29811. this.words[this.length++] = 0;
  29812. }
  29813. return this;
  29814. };
  29815. // Remove leading `0` from `this`
  29816. BN.prototype.strip = function strip () {
  29817. while (this.length > 1 && this.words[this.length - 1] === 0) {
  29818. this.length--;
  29819. }
  29820. return this._normSign();
  29821. };
  29822. BN.prototype._normSign = function _normSign () {
  29823. // -0 = 0
  29824. if (this.length === 1 && this.words[0] === 0) {
  29825. this.negative = 0;
  29826. }
  29827. return this;
  29828. };
  29829. BN.prototype.inspect = function inspect () {
  29830. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  29831. };
  29832. /*
  29833. var zeros = [];
  29834. var groupSizes = [];
  29835. var groupBases = [];
  29836. var s = '';
  29837. var i = -1;
  29838. while (++i < BN.wordSize) {
  29839. zeros[i] = s;
  29840. s += '0';
  29841. }
  29842. groupSizes[0] = 0;
  29843. groupSizes[1] = 0;
  29844. groupBases[0] = 0;
  29845. groupBases[1] = 0;
  29846. var base = 2 - 1;
  29847. while (++base < 36 + 1) {
  29848. var groupSize = 0;
  29849. var groupBase = 1;
  29850. while (groupBase < (1 << BN.wordSize) / base) {
  29851. groupBase *= base;
  29852. groupSize += 1;
  29853. }
  29854. groupSizes[base] = groupSize;
  29855. groupBases[base] = groupBase;
  29856. }
  29857. */
  29858. var zeros = [
  29859. '',
  29860. '0',
  29861. '00',
  29862. '000',
  29863. '0000',
  29864. '00000',
  29865. '000000',
  29866. '0000000',
  29867. '00000000',
  29868. '000000000',
  29869. '0000000000',
  29870. '00000000000',
  29871. '000000000000',
  29872. '0000000000000',
  29873. '00000000000000',
  29874. '000000000000000',
  29875. '0000000000000000',
  29876. '00000000000000000',
  29877. '000000000000000000',
  29878. '0000000000000000000',
  29879. '00000000000000000000',
  29880. '000000000000000000000',
  29881. '0000000000000000000000',
  29882. '00000000000000000000000',
  29883. '000000000000000000000000',
  29884. '0000000000000000000000000'
  29885. ];
  29886. var groupSizes = [
  29887. 0, 0,
  29888. 25, 16, 12, 11, 10, 9, 8,
  29889. 8, 7, 7, 7, 7, 6, 6,
  29890. 6, 6, 6, 6, 6, 5, 5,
  29891. 5, 5, 5, 5, 5, 5, 5,
  29892. 5, 5, 5, 5, 5, 5, 5
  29893. ];
  29894. var groupBases = [
  29895. 0, 0,
  29896. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  29897. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  29898. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  29899. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  29900. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  29901. ];
  29902. BN.prototype.toString = function toString (base, padding) {
  29903. base = base || 10;
  29904. padding = padding | 0 || 1;
  29905. var out;
  29906. if (base === 16 || base === 'hex') {
  29907. out = '';
  29908. var off = 0;
  29909. var carry = 0;
  29910. for (var i = 0; i < this.length; i++) {
  29911. var w = this.words[i];
  29912. var word = (((w << off) | carry) & 0xffffff).toString(16);
  29913. carry = (w >>> (24 - off)) & 0xffffff;
  29914. if (carry !== 0 || i !== this.length - 1) {
  29915. out = zeros[6 - word.length] + word + out;
  29916. } else {
  29917. out = word + out;
  29918. }
  29919. off += 2;
  29920. if (off >= 26) {
  29921. off -= 26;
  29922. i--;
  29923. }
  29924. }
  29925. if (carry !== 0) {
  29926. out = carry.toString(16) + out;
  29927. }
  29928. while (out.length % padding !== 0) {
  29929. out = '0' + out;
  29930. }
  29931. if (this.negative !== 0) {
  29932. out = '-' + out;
  29933. }
  29934. return out;
  29935. }
  29936. if (base === (base | 0) && base >= 2 && base <= 36) {
  29937. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  29938. var groupSize = groupSizes[base];
  29939. // var groupBase = Math.pow(base, groupSize);
  29940. var groupBase = groupBases[base];
  29941. out = '';
  29942. var c = this.clone();
  29943. c.negative = 0;
  29944. while (!c.isZero()) {
  29945. var r = c.modn(groupBase).toString(base);
  29946. c = c.idivn(groupBase);
  29947. if (!c.isZero()) {
  29948. out = zeros[groupSize - r.length] + r + out;
  29949. } else {
  29950. out = r + out;
  29951. }
  29952. }
  29953. if (this.isZero()) {
  29954. out = '0' + out;
  29955. }
  29956. while (out.length % padding !== 0) {
  29957. out = '0' + out;
  29958. }
  29959. if (this.negative !== 0) {
  29960. out = '-' + out;
  29961. }
  29962. return out;
  29963. }
  29964. assert(false, 'Base should be between 2 and 36');
  29965. };
  29966. BN.prototype.toNumber = function toNumber () {
  29967. var ret = this.words[0];
  29968. if (this.length === 2) {
  29969. ret += this.words[1] * 0x4000000;
  29970. } else if (this.length === 3 && this.words[2] === 0x01) {
  29971. // NOTE: at this stage it is known that the top bit is set
  29972. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  29973. } else if (this.length > 2) {
  29974. assert(false, 'Number can only safely store up to 53 bits');
  29975. }
  29976. return (this.negative !== 0) ? -ret : ret;
  29977. };
  29978. BN.prototype.toJSON = function toJSON () {
  29979. return this.toString(16);
  29980. };
  29981. BN.prototype.toBuffer = function toBuffer (endian, length) {
  29982. assert(typeof Buffer !== 'undefined');
  29983. return this.toArrayLike(Buffer, endian, length);
  29984. };
  29985. BN.prototype.toArray = function toArray (endian, length) {
  29986. return this.toArrayLike(Array, endian, length);
  29987. };
  29988. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  29989. var byteLength = this.byteLength();
  29990. var reqLength = length || Math.max(1, byteLength);
  29991. assert(byteLength <= reqLength, 'byte array longer than desired length');
  29992. assert(reqLength > 0, 'Requested array length <= 0');
  29993. this.strip();
  29994. var littleEndian = endian === 'le';
  29995. var res = new ArrayType(reqLength);
  29996. var b, i;
  29997. var q = this.clone();
  29998. if (!littleEndian) {
  29999. // Assume big-endian
  30000. for (i = 0; i < reqLength - byteLength; i++) {
  30001. res[i] = 0;
  30002. }
  30003. for (i = 0; !q.isZero(); i++) {
  30004. b = q.andln(0xff);
  30005. q.iushrn(8);
  30006. res[reqLength - i - 1] = b;
  30007. }
  30008. } else {
  30009. for (i = 0; !q.isZero(); i++) {
  30010. b = q.andln(0xff);
  30011. q.iushrn(8);
  30012. res[i] = b;
  30013. }
  30014. for (; i < reqLength; i++) {
  30015. res[i] = 0;
  30016. }
  30017. }
  30018. return res;
  30019. };
  30020. if (Math.clz32) {
  30021. BN.prototype._countBits = function _countBits (w) {
  30022. return 32 - Math.clz32(w);
  30023. };
  30024. } else {
  30025. BN.prototype._countBits = function _countBits (w) {
  30026. var t = w;
  30027. var r = 0;
  30028. if (t >= 0x1000) {
  30029. r += 13;
  30030. t >>>= 13;
  30031. }
  30032. if (t >= 0x40) {
  30033. r += 7;
  30034. t >>>= 7;
  30035. }
  30036. if (t >= 0x8) {
  30037. r += 4;
  30038. t >>>= 4;
  30039. }
  30040. if (t >= 0x02) {
  30041. r += 2;
  30042. t >>>= 2;
  30043. }
  30044. return r + t;
  30045. };
  30046. }
  30047. BN.prototype._zeroBits = function _zeroBits (w) {
  30048. // Short-cut
  30049. if (w === 0) return 26;
  30050. var t = w;
  30051. var r = 0;
  30052. if ((t & 0x1fff) === 0) {
  30053. r += 13;
  30054. t >>>= 13;
  30055. }
  30056. if ((t & 0x7f) === 0) {
  30057. r += 7;
  30058. t >>>= 7;
  30059. }
  30060. if ((t & 0xf) === 0) {
  30061. r += 4;
  30062. t >>>= 4;
  30063. }
  30064. if ((t & 0x3) === 0) {
  30065. r += 2;
  30066. t >>>= 2;
  30067. }
  30068. if ((t & 0x1) === 0) {
  30069. r++;
  30070. }
  30071. return r;
  30072. };
  30073. // Return number of used bits in a BN
  30074. BN.prototype.bitLength = function bitLength () {
  30075. var w = this.words[this.length - 1];
  30076. var hi = this._countBits(w);
  30077. return (this.length - 1) * 26 + hi;
  30078. };
  30079. function toBitArray (num) {
  30080. var w = new Array(num.bitLength());
  30081. for (var bit = 0; bit < w.length; bit++) {
  30082. var off = (bit / 26) | 0;
  30083. var wbit = bit % 26;
  30084. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  30085. }
  30086. return w;
  30087. }
  30088. // Number of trailing zero bits
  30089. BN.prototype.zeroBits = function zeroBits () {
  30090. if (this.isZero()) return 0;
  30091. var r = 0;
  30092. for (var i = 0; i < this.length; i++) {
  30093. var b = this._zeroBits(this.words[i]);
  30094. r += b;
  30095. if (b !== 26) break;
  30096. }
  30097. return r;
  30098. };
  30099. BN.prototype.byteLength = function byteLength () {
  30100. return Math.ceil(this.bitLength() / 8);
  30101. };
  30102. BN.prototype.toTwos = function toTwos (width) {
  30103. if (this.negative !== 0) {
  30104. return this.abs().inotn(width).iaddn(1);
  30105. }
  30106. return this.clone();
  30107. };
  30108. BN.prototype.fromTwos = function fromTwos (width) {
  30109. if (this.testn(width - 1)) {
  30110. return this.notn(width).iaddn(1).ineg();
  30111. }
  30112. return this.clone();
  30113. };
  30114. BN.prototype.isNeg = function isNeg () {
  30115. return this.negative !== 0;
  30116. };
  30117. // Return negative clone of `this`
  30118. BN.prototype.neg = function neg () {
  30119. return this.clone().ineg();
  30120. };
  30121. BN.prototype.ineg = function ineg () {
  30122. if (!this.isZero()) {
  30123. this.negative ^= 1;
  30124. }
  30125. return this;
  30126. };
  30127. // Or `num` with `this` in-place
  30128. BN.prototype.iuor = function iuor (num) {
  30129. while (this.length < num.length) {
  30130. this.words[this.length++] = 0;
  30131. }
  30132. for (var i = 0; i < num.length; i++) {
  30133. this.words[i] = this.words[i] | num.words[i];
  30134. }
  30135. return this.strip();
  30136. };
  30137. BN.prototype.ior = function ior (num) {
  30138. assert((this.negative | num.negative) === 0);
  30139. return this.iuor(num);
  30140. };
  30141. // Or `num` with `this`
  30142. BN.prototype.or = function or (num) {
  30143. if (this.length > num.length) return this.clone().ior(num);
  30144. return num.clone().ior(this);
  30145. };
  30146. BN.prototype.uor = function uor (num) {
  30147. if (this.length > num.length) return this.clone().iuor(num);
  30148. return num.clone().iuor(this);
  30149. };
  30150. // And `num` with `this` in-place
  30151. BN.prototype.iuand = function iuand (num) {
  30152. // b = min-length(num, this)
  30153. var b;
  30154. if (this.length > num.length) {
  30155. b = num;
  30156. } else {
  30157. b = this;
  30158. }
  30159. for (var i = 0; i < b.length; i++) {
  30160. this.words[i] = this.words[i] & num.words[i];
  30161. }
  30162. this.length = b.length;
  30163. return this.strip();
  30164. };
  30165. BN.prototype.iand = function iand (num) {
  30166. assert((this.negative | num.negative) === 0);
  30167. return this.iuand(num);
  30168. };
  30169. // And `num` with `this`
  30170. BN.prototype.and = function and (num) {
  30171. if (this.length > num.length) return this.clone().iand(num);
  30172. return num.clone().iand(this);
  30173. };
  30174. BN.prototype.uand = function uand (num) {
  30175. if (this.length > num.length) return this.clone().iuand(num);
  30176. return num.clone().iuand(this);
  30177. };
  30178. // Xor `num` with `this` in-place
  30179. BN.prototype.iuxor = function iuxor (num) {
  30180. // a.length > b.length
  30181. var a;
  30182. var b;
  30183. if (this.length > num.length) {
  30184. a = this;
  30185. b = num;
  30186. } else {
  30187. a = num;
  30188. b = this;
  30189. }
  30190. for (var i = 0; i < b.length; i++) {
  30191. this.words[i] = a.words[i] ^ b.words[i];
  30192. }
  30193. if (this !== a) {
  30194. for (; i < a.length; i++) {
  30195. this.words[i] = a.words[i];
  30196. }
  30197. }
  30198. this.length = a.length;
  30199. return this.strip();
  30200. };
  30201. BN.prototype.ixor = function ixor (num) {
  30202. assert((this.negative | num.negative) === 0);
  30203. return this.iuxor(num);
  30204. };
  30205. // Xor `num` with `this`
  30206. BN.prototype.xor = function xor (num) {
  30207. if (this.length > num.length) return this.clone().ixor(num);
  30208. return num.clone().ixor(this);
  30209. };
  30210. BN.prototype.uxor = function uxor (num) {
  30211. if (this.length > num.length) return this.clone().iuxor(num);
  30212. return num.clone().iuxor(this);
  30213. };
  30214. // Not ``this`` with ``width`` bitwidth
  30215. BN.prototype.inotn = function inotn (width) {
  30216. assert(typeof width === 'number' && width >= 0);
  30217. var bytesNeeded = Math.ceil(width / 26) | 0;
  30218. var bitsLeft = width % 26;
  30219. // Extend the buffer with leading zeroes
  30220. this._expand(bytesNeeded);
  30221. if (bitsLeft > 0) {
  30222. bytesNeeded--;
  30223. }
  30224. // Handle complete words
  30225. for (var i = 0; i < bytesNeeded; i++) {
  30226. this.words[i] = ~this.words[i] & 0x3ffffff;
  30227. }
  30228. // Handle the residue
  30229. if (bitsLeft > 0) {
  30230. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  30231. }
  30232. // And remove leading zeroes
  30233. return this.strip();
  30234. };
  30235. BN.prototype.notn = function notn (width) {
  30236. return this.clone().inotn(width);
  30237. };
  30238. // Set `bit` of `this`
  30239. BN.prototype.setn = function setn (bit, val) {
  30240. assert(typeof bit === 'number' && bit >= 0);
  30241. var off = (bit / 26) | 0;
  30242. var wbit = bit % 26;
  30243. this._expand(off + 1);
  30244. if (val) {
  30245. this.words[off] = this.words[off] | (1 << wbit);
  30246. } else {
  30247. this.words[off] = this.words[off] & ~(1 << wbit);
  30248. }
  30249. return this.strip();
  30250. };
  30251. // Add `num` to `this` in-place
  30252. BN.prototype.iadd = function iadd (num) {
  30253. var r;
  30254. // negative + positive
  30255. if (this.negative !== 0 && num.negative === 0) {
  30256. this.negative = 0;
  30257. r = this.isub(num);
  30258. this.negative ^= 1;
  30259. return this._normSign();
  30260. // positive + negative
  30261. } else if (this.negative === 0 && num.negative !== 0) {
  30262. num.negative = 0;
  30263. r = this.isub(num);
  30264. num.negative = 1;
  30265. return r._normSign();
  30266. }
  30267. // a.length > b.length
  30268. var a, b;
  30269. if (this.length > num.length) {
  30270. a = this;
  30271. b = num;
  30272. } else {
  30273. a = num;
  30274. b = this;
  30275. }
  30276. var carry = 0;
  30277. for (var i = 0; i < b.length; i++) {
  30278. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  30279. this.words[i] = r & 0x3ffffff;
  30280. carry = r >>> 26;
  30281. }
  30282. for (; carry !== 0 && i < a.length; i++) {
  30283. r = (a.words[i] | 0) + carry;
  30284. this.words[i] = r & 0x3ffffff;
  30285. carry = r >>> 26;
  30286. }
  30287. this.length = a.length;
  30288. if (carry !== 0) {
  30289. this.words[this.length] = carry;
  30290. this.length++;
  30291. // Copy the rest of the words
  30292. } else if (a !== this) {
  30293. for (; i < a.length; i++) {
  30294. this.words[i] = a.words[i];
  30295. }
  30296. }
  30297. return this;
  30298. };
  30299. // Add `num` to `this`
  30300. BN.prototype.add = function add (num) {
  30301. var res;
  30302. if (num.negative !== 0 && this.negative === 0) {
  30303. num.negative = 0;
  30304. res = this.sub(num);
  30305. num.negative ^= 1;
  30306. return res;
  30307. } else if (num.negative === 0 && this.negative !== 0) {
  30308. this.negative = 0;
  30309. res = num.sub(this);
  30310. this.negative = 1;
  30311. return res;
  30312. }
  30313. if (this.length > num.length) return this.clone().iadd(num);
  30314. return num.clone().iadd(this);
  30315. };
  30316. // Subtract `num` from `this` in-place
  30317. BN.prototype.isub = function isub (num) {
  30318. // this - (-num) = this + num
  30319. if (num.negative !== 0) {
  30320. num.negative = 0;
  30321. var r = this.iadd(num);
  30322. num.negative = 1;
  30323. return r._normSign();
  30324. // -this - num = -(this + num)
  30325. } else if (this.negative !== 0) {
  30326. this.negative = 0;
  30327. this.iadd(num);
  30328. this.negative = 1;
  30329. return this._normSign();
  30330. }
  30331. // At this point both numbers are positive
  30332. var cmp = this.cmp(num);
  30333. // Optimization - zeroify
  30334. if (cmp === 0) {
  30335. this.negative = 0;
  30336. this.length = 1;
  30337. this.words[0] = 0;
  30338. return this;
  30339. }
  30340. // a > b
  30341. var a, b;
  30342. if (cmp > 0) {
  30343. a = this;
  30344. b = num;
  30345. } else {
  30346. a = num;
  30347. b = this;
  30348. }
  30349. var carry = 0;
  30350. for (var i = 0; i < b.length; i++) {
  30351. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  30352. carry = r >> 26;
  30353. this.words[i] = r & 0x3ffffff;
  30354. }
  30355. for (; carry !== 0 && i < a.length; i++) {
  30356. r = (a.words[i] | 0) + carry;
  30357. carry = r >> 26;
  30358. this.words[i] = r & 0x3ffffff;
  30359. }
  30360. // Copy rest of the words
  30361. if (carry === 0 && i < a.length && a !== this) {
  30362. for (; i < a.length; i++) {
  30363. this.words[i] = a.words[i];
  30364. }
  30365. }
  30366. this.length = Math.max(this.length, i);
  30367. if (a !== this) {
  30368. this.negative = 1;
  30369. }
  30370. return this.strip();
  30371. };
  30372. // Subtract `num` from `this`
  30373. BN.prototype.sub = function sub (num) {
  30374. return this.clone().isub(num);
  30375. };
  30376. function smallMulTo (self, num, out) {
  30377. out.negative = num.negative ^ self.negative;
  30378. var len = (self.length + num.length) | 0;
  30379. out.length = len;
  30380. len = (len - 1) | 0;
  30381. // Peel one iteration (compiler can't do it, because of code complexity)
  30382. var a = self.words[0] | 0;
  30383. var b = num.words[0] | 0;
  30384. var r = a * b;
  30385. var lo = r & 0x3ffffff;
  30386. var carry = (r / 0x4000000) | 0;
  30387. out.words[0] = lo;
  30388. for (var k = 1; k < len; k++) {
  30389. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  30390. // note that ncarry could be >= 0x3ffffff
  30391. var ncarry = carry >>> 26;
  30392. var rword = carry & 0x3ffffff;
  30393. var maxJ = Math.min(k, num.length - 1);
  30394. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  30395. var i = (k - j) | 0;
  30396. a = self.words[i] | 0;
  30397. b = num.words[j] | 0;
  30398. r = a * b + rword;
  30399. ncarry += (r / 0x4000000) | 0;
  30400. rword = r & 0x3ffffff;
  30401. }
  30402. out.words[k] = rword | 0;
  30403. carry = ncarry | 0;
  30404. }
  30405. if (carry !== 0) {
  30406. out.words[k] = carry | 0;
  30407. } else {
  30408. out.length--;
  30409. }
  30410. return out.strip();
  30411. }
  30412. // TODO(indutny): it may be reasonable to omit it for users who don't need
  30413. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  30414. // multiplication (like elliptic secp256k1).
  30415. var comb10MulTo = function comb10MulTo (self, num, out) {
  30416. var a = self.words;
  30417. var b = num.words;
  30418. var o = out.words;
  30419. var c = 0;
  30420. var lo;
  30421. var mid;
  30422. var hi;
  30423. var a0 = a[0] | 0;
  30424. var al0 = a0 & 0x1fff;
  30425. var ah0 = a0 >>> 13;
  30426. var a1 = a[1] | 0;
  30427. var al1 = a1 & 0x1fff;
  30428. var ah1 = a1 >>> 13;
  30429. var a2 = a[2] | 0;
  30430. var al2 = a2 & 0x1fff;
  30431. var ah2 = a2 >>> 13;
  30432. var a3 = a[3] | 0;
  30433. var al3 = a3 & 0x1fff;
  30434. var ah3 = a3 >>> 13;
  30435. var a4 = a[4] | 0;
  30436. var al4 = a4 & 0x1fff;
  30437. var ah4 = a4 >>> 13;
  30438. var a5 = a[5] | 0;
  30439. var al5 = a5 & 0x1fff;
  30440. var ah5 = a5 >>> 13;
  30441. var a6 = a[6] | 0;
  30442. var al6 = a6 & 0x1fff;
  30443. var ah6 = a6 >>> 13;
  30444. var a7 = a[7] | 0;
  30445. var al7 = a7 & 0x1fff;
  30446. var ah7 = a7 >>> 13;
  30447. var a8 = a[8] | 0;
  30448. var al8 = a8 & 0x1fff;
  30449. var ah8 = a8 >>> 13;
  30450. var a9 = a[9] | 0;
  30451. var al9 = a9 & 0x1fff;
  30452. var ah9 = a9 >>> 13;
  30453. var b0 = b[0] | 0;
  30454. var bl0 = b0 & 0x1fff;
  30455. var bh0 = b0 >>> 13;
  30456. var b1 = b[1] | 0;
  30457. var bl1 = b1 & 0x1fff;
  30458. var bh1 = b1 >>> 13;
  30459. var b2 = b[2] | 0;
  30460. var bl2 = b2 & 0x1fff;
  30461. var bh2 = b2 >>> 13;
  30462. var b3 = b[3] | 0;
  30463. var bl3 = b3 & 0x1fff;
  30464. var bh3 = b3 >>> 13;
  30465. var b4 = b[4] | 0;
  30466. var bl4 = b4 & 0x1fff;
  30467. var bh4 = b4 >>> 13;
  30468. var b5 = b[5] | 0;
  30469. var bl5 = b5 & 0x1fff;
  30470. var bh5 = b5 >>> 13;
  30471. var b6 = b[6] | 0;
  30472. var bl6 = b6 & 0x1fff;
  30473. var bh6 = b6 >>> 13;
  30474. var b7 = b[7] | 0;
  30475. var bl7 = b7 & 0x1fff;
  30476. var bh7 = b7 >>> 13;
  30477. var b8 = b[8] | 0;
  30478. var bl8 = b8 & 0x1fff;
  30479. var bh8 = b8 >>> 13;
  30480. var b9 = b[9] | 0;
  30481. var bl9 = b9 & 0x1fff;
  30482. var bh9 = b9 >>> 13;
  30483. out.negative = self.negative ^ num.negative;
  30484. out.length = 19;
  30485. /* k = 0 */
  30486. lo = Math.imul(al0, bl0);
  30487. mid = Math.imul(al0, bh0);
  30488. mid = (mid + Math.imul(ah0, bl0)) | 0;
  30489. hi = Math.imul(ah0, bh0);
  30490. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30491. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  30492. w0 &= 0x3ffffff;
  30493. /* k = 1 */
  30494. lo = Math.imul(al1, bl0);
  30495. mid = Math.imul(al1, bh0);
  30496. mid = (mid + Math.imul(ah1, bl0)) | 0;
  30497. hi = Math.imul(ah1, bh0);
  30498. lo = (lo + Math.imul(al0, bl1)) | 0;
  30499. mid = (mid + Math.imul(al0, bh1)) | 0;
  30500. mid = (mid + Math.imul(ah0, bl1)) | 0;
  30501. hi = (hi + Math.imul(ah0, bh1)) | 0;
  30502. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30503. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  30504. w1 &= 0x3ffffff;
  30505. /* k = 2 */
  30506. lo = Math.imul(al2, bl0);
  30507. mid = Math.imul(al2, bh0);
  30508. mid = (mid + Math.imul(ah2, bl0)) | 0;
  30509. hi = Math.imul(ah2, bh0);
  30510. lo = (lo + Math.imul(al1, bl1)) | 0;
  30511. mid = (mid + Math.imul(al1, bh1)) | 0;
  30512. mid = (mid + Math.imul(ah1, bl1)) | 0;
  30513. hi = (hi + Math.imul(ah1, bh1)) | 0;
  30514. lo = (lo + Math.imul(al0, bl2)) | 0;
  30515. mid = (mid + Math.imul(al0, bh2)) | 0;
  30516. mid = (mid + Math.imul(ah0, bl2)) | 0;
  30517. hi = (hi + Math.imul(ah0, bh2)) | 0;
  30518. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30519. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  30520. w2 &= 0x3ffffff;
  30521. /* k = 3 */
  30522. lo = Math.imul(al3, bl0);
  30523. mid = Math.imul(al3, bh0);
  30524. mid = (mid + Math.imul(ah3, bl0)) | 0;
  30525. hi = Math.imul(ah3, bh0);
  30526. lo = (lo + Math.imul(al2, bl1)) | 0;
  30527. mid = (mid + Math.imul(al2, bh1)) | 0;
  30528. mid = (mid + Math.imul(ah2, bl1)) | 0;
  30529. hi = (hi + Math.imul(ah2, bh1)) | 0;
  30530. lo = (lo + Math.imul(al1, bl2)) | 0;
  30531. mid = (mid + Math.imul(al1, bh2)) | 0;
  30532. mid = (mid + Math.imul(ah1, bl2)) | 0;
  30533. hi = (hi + Math.imul(ah1, bh2)) | 0;
  30534. lo = (lo + Math.imul(al0, bl3)) | 0;
  30535. mid = (mid + Math.imul(al0, bh3)) | 0;
  30536. mid = (mid + Math.imul(ah0, bl3)) | 0;
  30537. hi = (hi + Math.imul(ah0, bh3)) | 0;
  30538. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30539. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  30540. w3 &= 0x3ffffff;
  30541. /* k = 4 */
  30542. lo = Math.imul(al4, bl0);
  30543. mid = Math.imul(al4, bh0);
  30544. mid = (mid + Math.imul(ah4, bl0)) | 0;
  30545. hi = Math.imul(ah4, bh0);
  30546. lo = (lo + Math.imul(al3, bl1)) | 0;
  30547. mid = (mid + Math.imul(al3, bh1)) | 0;
  30548. mid = (mid + Math.imul(ah3, bl1)) | 0;
  30549. hi = (hi + Math.imul(ah3, bh1)) | 0;
  30550. lo = (lo + Math.imul(al2, bl2)) | 0;
  30551. mid = (mid + Math.imul(al2, bh2)) | 0;
  30552. mid = (mid + Math.imul(ah2, bl2)) | 0;
  30553. hi = (hi + Math.imul(ah2, bh2)) | 0;
  30554. lo = (lo + Math.imul(al1, bl3)) | 0;
  30555. mid = (mid + Math.imul(al1, bh3)) | 0;
  30556. mid = (mid + Math.imul(ah1, bl3)) | 0;
  30557. hi = (hi + Math.imul(ah1, bh3)) | 0;
  30558. lo = (lo + Math.imul(al0, bl4)) | 0;
  30559. mid = (mid + Math.imul(al0, bh4)) | 0;
  30560. mid = (mid + Math.imul(ah0, bl4)) | 0;
  30561. hi = (hi + Math.imul(ah0, bh4)) | 0;
  30562. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30563. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  30564. w4 &= 0x3ffffff;
  30565. /* k = 5 */
  30566. lo = Math.imul(al5, bl0);
  30567. mid = Math.imul(al5, bh0);
  30568. mid = (mid + Math.imul(ah5, bl0)) | 0;
  30569. hi = Math.imul(ah5, bh0);
  30570. lo = (lo + Math.imul(al4, bl1)) | 0;
  30571. mid = (mid + Math.imul(al4, bh1)) | 0;
  30572. mid = (mid + Math.imul(ah4, bl1)) | 0;
  30573. hi = (hi + Math.imul(ah4, bh1)) | 0;
  30574. lo = (lo + Math.imul(al3, bl2)) | 0;
  30575. mid = (mid + Math.imul(al3, bh2)) | 0;
  30576. mid = (mid + Math.imul(ah3, bl2)) | 0;
  30577. hi = (hi + Math.imul(ah3, bh2)) | 0;
  30578. lo = (lo + Math.imul(al2, bl3)) | 0;
  30579. mid = (mid + Math.imul(al2, bh3)) | 0;
  30580. mid = (mid + Math.imul(ah2, bl3)) | 0;
  30581. hi = (hi + Math.imul(ah2, bh3)) | 0;
  30582. lo = (lo + Math.imul(al1, bl4)) | 0;
  30583. mid = (mid + Math.imul(al1, bh4)) | 0;
  30584. mid = (mid + Math.imul(ah1, bl4)) | 0;
  30585. hi = (hi + Math.imul(ah1, bh4)) | 0;
  30586. lo = (lo + Math.imul(al0, bl5)) | 0;
  30587. mid = (mid + Math.imul(al0, bh5)) | 0;
  30588. mid = (mid + Math.imul(ah0, bl5)) | 0;
  30589. hi = (hi + Math.imul(ah0, bh5)) | 0;
  30590. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30591. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  30592. w5 &= 0x3ffffff;
  30593. /* k = 6 */
  30594. lo = Math.imul(al6, bl0);
  30595. mid = Math.imul(al6, bh0);
  30596. mid = (mid + Math.imul(ah6, bl0)) | 0;
  30597. hi = Math.imul(ah6, bh0);
  30598. lo = (lo + Math.imul(al5, bl1)) | 0;
  30599. mid = (mid + Math.imul(al5, bh1)) | 0;
  30600. mid = (mid + Math.imul(ah5, bl1)) | 0;
  30601. hi = (hi + Math.imul(ah5, bh1)) | 0;
  30602. lo = (lo + Math.imul(al4, bl2)) | 0;
  30603. mid = (mid + Math.imul(al4, bh2)) | 0;
  30604. mid = (mid + Math.imul(ah4, bl2)) | 0;
  30605. hi = (hi + Math.imul(ah4, bh2)) | 0;
  30606. lo = (lo + Math.imul(al3, bl3)) | 0;
  30607. mid = (mid + Math.imul(al3, bh3)) | 0;
  30608. mid = (mid + Math.imul(ah3, bl3)) | 0;
  30609. hi = (hi + Math.imul(ah3, bh3)) | 0;
  30610. lo = (lo + Math.imul(al2, bl4)) | 0;
  30611. mid = (mid + Math.imul(al2, bh4)) | 0;
  30612. mid = (mid + Math.imul(ah2, bl4)) | 0;
  30613. hi = (hi + Math.imul(ah2, bh4)) | 0;
  30614. lo = (lo + Math.imul(al1, bl5)) | 0;
  30615. mid = (mid + Math.imul(al1, bh5)) | 0;
  30616. mid = (mid + Math.imul(ah1, bl5)) | 0;
  30617. hi = (hi + Math.imul(ah1, bh5)) | 0;
  30618. lo = (lo + Math.imul(al0, bl6)) | 0;
  30619. mid = (mid + Math.imul(al0, bh6)) | 0;
  30620. mid = (mid + Math.imul(ah0, bl6)) | 0;
  30621. hi = (hi + Math.imul(ah0, bh6)) | 0;
  30622. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30623. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  30624. w6 &= 0x3ffffff;
  30625. /* k = 7 */
  30626. lo = Math.imul(al7, bl0);
  30627. mid = Math.imul(al7, bh0);
  30628. mid = (mid + Math.imul(ah7, bl0)) | 0;
  30629. hi = Math.imul(ah7, bh0);
  30630. lo = (lo + Math.imul(al6, bl1)) | 0;
  30631. mid = (mid + Math.imul(al6, bh1)) | 0;
  30632. mid = (mid + Math.imul(ah6, bl1)) | 0;
  30633. hi = (hi + Math.imul(ah6, bh1)) | 0;
  30634. lo = (lo + Math.imul(al5, bl2)) | 0;
  30635. mid = (mid + Math.imul(al5, bh2)) | 0;
  30636. mid = (mid + Math.imul(ah5, bl2)) | 0;
  30637. hi = (hi + Math.imul(ah5, bh2)) | 0;
  30638. lo = (lo + Math.imul(al4, bl3)) | 0;
  30639. mid = (mid + Math.imul(al4, bh3)) | 0;
  30640. mid = (mid + Math.imul(ah4, bl3)) | 0;
  30641. hi = (hi + Math.imul(ah4, bh3)) | 0;
  30642. lo = (lo + Math.imul(al3, bl4)) | 0;
  30643. mid = (mid + Math.imul(al3, bh4)) | 0;
  30644. mid = (mid + Math.imul(ah3, bl4)) | 0;
  30645. hi = (hi + Math.imul(ah3, bh4)) | 0;
  30646. lo = (lo + Math.imul(al2, bl5)) | 0;
  30647. mid = (mid + Math.imul(al2, bh5)) | 0;
  30648. mid = (mid + Math.imul(ah2, bl5)) | 0;
  30649. hi = (hi + Math.imul(ah2, bh5)) | 0;
  30650. lo = (lo + Math.imul(al1, bl6)) | 0;
  30651. mid = (mid + Math.imul(al1, bh6)) | 0;
  30652. mid = (mid + Math.imul(ah1, bl6)) | 0;
  30653. hi = (hi + Math.imul(ah1, bh6)) | 0;
  30654. lo = (lo + Math.imul(al0, bl7)) | 0;
  30655. mid = (mid + Math.imul(al0, bh7)) | 0;
  30656. mid = (mid + Math.imul(ah0, bl7)) | 0;
  30657. hi = (hi + Math.imul(ah0, bh7)) | 0;
  30658. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30659. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  30660. w7 &= 0x3ffffff;
  30661. /* k = 8 */
  30662. lo = Math.imul(al8, bl0);
  30663. mid = Math.imul(al8, bh0);
  30664. mid = (mid + Math.imul(ah8, bl0)) | 0;
  30665. hi = Math.imul(ah8, bh0);
  30666. lo = (lo + Math.imul(al7, bl1)) | 0;
  30667. mid = (mid + Math.imul(al7, bh1)) | 0;
  30668. mid = (mid + Math.imul(ah7, bl1)) | 0;
  30669. hi = (hi + Math.imul(ah7, bh1)) | 0;
  30670. lo = (lo + Math.imul(al6, bl2)) | 0;
  30671. mid = (mid + Math.imul(al6, bh2)) | 0;
  30672. mid = (mid + Math.imul(ah6, bl2)) | 0;
  30673. hi = (hi + Math.imul(ah6, bh2)) | 0;
  30674. lo = (lo + Math.imul(al5, bl3)) | 0;
  30675. mid = (mid + Math.imul(al5, bh3)) | 0;
  30676. mid = (mid + Math.imul(ah5, bl3)) | 0;
  30677. hi = (hi + Math.imul(ah5, bh3)) | 0;
  30678. lo = (lo + Math.imul(al4, bl4)) | 0;
  30679. mid = (mid + Math.imul(al4, bh4)) | 0;
  30680. mid = (mid + Math.imul(ah4, bl4)) | 0;
  30681. hi = (hi + Math.imul(ah4, bh4)) | 0;
  30682. lo = (lo + Math.imul(al3, bl5)) | 0;
  30683. mid = (mid + Math.imul(al3, bh5)) | 0;
  30684. mid = (mid + Math.imul(ah3, bl5)) | 0;
  30685. hi = (hi + Math.imul(ah3, bh5)) | 0;
  30686. lo = (lo + Math.imul(al2, bl6)) | 0;
  30687. mid = (mid + Math.imul(al2, bh6)) | 0;
  30688. mid = (mid + Math.imul(ah2, bl6)) | 0;
  30689. hi = (hi + Math.imul(ah2, bh6)) | 0;
  30690. lo = (lo + Math.imul(al1, bl7)) | 0;
  30691. mid = (mid + Math.imul(al1, bh7)) | 0;
  30692. mid = (mid + Math.imul(ah1, bl7)) | 0;
  30693. hi = (hi + Math.imul(ah1, bh7)) | 0;
  30694. lo = (lo + Math.imul(al0, bl8)) | 0;
  30695. mid = (mid + Math.imul(al0, bh8)) | 0;
  30696. mid = (mid + Math.imul(ah0, bl8)) | 0;
  30697. hi = (hi + Math.imul(ah0, bh8)) | 0;
  30698. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30699. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  30700. w8 &= 0x3ffffff;
  30701. /* k = 9 */
  30702. lo = Math.imul(al9, bl0);
  30703. mid = Math.imul(al9, bh0);
  30704. mid = (mid + Math.imul(ah9, bl0)) | 0;
  30705. hi = Math.imul(ah9, bh0);
  30706. lo = (lo + Math.imul(al8, bl1)) | 0;
  30707. mid = (mid + Math.imul(al8, bh1)) | 0;
  30708. mid = (mid + Math.imul(ah8, bl1)) | 0;
  30709. hi = (hi + Math.imul(ah8, bh1)) | 0;
  30710. lo = (lo + Math.imul(al7, bl2)) | 0;
  30711. mid = (mid + Math.imul(al7, bh2)) | 0;
  30712. mid = (mid + Math.imul(ah7, bl2)) | 0;
  30713. hi = (hi + Math.imul(ah7, bh2)) | 0;
  30714. lo = (lo + Math.imul(al6, bl3)) | 0;
  30715. mid = (mid + Math.imul(al6, bh3)) | 0;
  30716. mid = (mid + Math.imul(ah6, bl3)) | 0;
  30717. hi = (hi + Math.imul(ah6, bh3)) | 0;
  30718. lo = (lo + Math.imul(al5, bl4)) | 0;
  30719. mid = (mid + Math.imul(al5, bh4)) | 0;
  30720. mid = (mid + Math.imul(ah5, bl4)) | 0;
  30721. hi = (hi + Math.imul(ah5, bh4)) | 0;
  30722. lo = (lo + Math.imul(al4, bl5)) | 0;
  30723. mid = (mid + Math.imul(al4, bh5)) | 0;
  30724. mid = (mid + Math.imul(ah4, bl5)) | 0;
  30725. hi = (hi + Math.imul(ah4, bh5)) | 0;
  30726. lo = (lo + Math.imul(al3, bl6)) | 0;
  30727. mid = (mid + Math.imul(al3, bh6)) | 0;
  30728. mid = (mid + Math.imul(ah3, bl6)) | 0;
  30729. hi = (hi + Math.imul(ah3, bh6)) | 0;
  30730. lo = (lo + Math.imul(al2, bl7)) | 0;
  30731. mid = (mid + Math.imul(al2, bh7)) | 0;
  30732. mid = (mid + Math.imul(ah2, bl7)) | 0;
  30733. hi = (hi + Math.imul(ah2, bh7)) | 0;
  30734. lo = (lo + Math.imul(al1, bl8)) | 0;
  30735. mid = (mid + Math.imul(al1, bh8)) | 0;
  30736. mid = (mid + Math.imul(ah1, bl8)) | 0;
  30737. hi = (hi + Math.imul(ah1, bh8)) | 0;
  30738. lo = (lo + Math.imul(al0, bl9)) | 0;
  30739. mid = (mid + Math.imul(al0, bh9)) | 0;
  30740. mid = (mid + Math.imul(ah0, bl9)) | 0;
  30741. hi = (hi + Math.imul(ah0, bh9)) | 0;
  30742. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30743. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  30744. w9 &= 0x3ffffff;
  30745. /* k = 10 */
  30746. lo = Math.imul(al9, bl1);
  30747. mid = Math.imul(al9, bh1);
  30748. mid = (mid + Math.imul(ah9, bl1)) | 0;
  30749. hi = Math.imul(ah9, bh1);
  30750. lo = (lo + Math.imul(al8, bl2)) | 0;
  30751. mid = (mid + Math.imul(al8, bh2)) | 0;
  30752. mid = (mid + Math.imul(ah8, bl2)) | 0;
  30753. hi = (hi + Math.imul(ah8, bh2)) | 0;
  30754. lo = (lo + Math.imul(al7, bl3)) | 0;
  30755. mid = (mid + Math.imul(al7, bh3)) | 0;
  30756. mid = (mid + Math.imul(ah7, bl3)) | 0;
  30757. hi = (hi + Math.imul(ah7, bh3)) | 0;
  30758. lo = (lo + Math.imul(al6, bl4)) | 0;
  30759. mid = (mid + Math.imul(al6, bh4)) | 0;
  30760. mid = (mid + Math.imul(ah6, bl4)) | 0;
  30761. hi = (hi + Math.imul(ah6, bh4)) | 0;
  30762. lo = (lo + Math.imul(al5, bl5)) | 0;
  30763. mid = (mid + Math.imul(al5, bh5)) | 0;
  30764. mid = (mid + Math.imul(ah5, bl5)) | 0;
  30765. hi = (hi + Math.imul(ah5, bh5)) | 0;
  30766. lo = (lo + Math.imul(al4, bl6)) | 0;
  30767. mid = (mid + Math.imul(al4, bh6)) | 0;
  30768. mid = (mid + Math.imul(ah4, bl6)) | 0;
  30769. hi = (hi + Math.imul(ah4, bh6)) | 0;
  30770. lo = (lo + Math.imul(al3, bl7)) | 0;
  30771. mid = (mid + Math.imul(al3, bh7)) | 0;
  30772. mid = (mid + Math.imul(ah3, bl7)) | 0;
  30773. hi = (hi + Math.imul(ah3, bh7)) | 0;
  30774. lo = (lo + Math.imul(al2, bl8)) | 0;
  30775. mid = (mid + Math.imul(al2, bh8)) | 0;
  30776. mid = (mid + Math.imul(ah2, bl8)) | 0;
  30777. hi = (hi + Math.imul(ah2, bh8)) | 0;
  30778. lo = (lo + Math.imul(al1, bl9)) | 0;
  30779. mid = (mid + Math.imul(al1, bh9)) | 0;
  30780. mid = (mid + Math.imul(ah1, bl9)) | 0;
  30781. hi = (hi + Math.imul(ah1, bh9)) | 0;
  30782. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30783. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  30784. w10 &= 0x3ffffff;
  30785. /* k = 11 */
  30786. lo = Math.imul(al9, bl2);
  30787. mid = Math.imul(al9, bh2);
  30788. mid = (mid + Math.imul(ah9, bl2)) | 0;
  30789. hi = Math.imul(ah9, bh2);
  30790. lo = (lo + Math.imul(al8, bl3)) | 0;
  30791. mid = (mid + Math.imul(al8, bh3)) | 0;
  30792. mid = (mid + Math.imul(ah8, bl3)) | 0;
  30793. hi = (hi + Math.imul(ah8, bh3)) | 0;
  30794. lo = (lo + Math.imul(al7, bl4)) | 0;
  30795. mid = (mid + Math.imul(al7, bh4)) | 0;
  30796. mid = (mid + Math.imul(ah7, bl4)) | 0;
  30797. hi = (hi + Math.imul(ah7, bh4)) | 0;
  30798. lo = (lo + Math.imul(al6, bl5)) | 0;
  30799. mid = (mid + Math.imul(al6, bh5)) | 0;
  30800. mid = (mid + Math.imul(ah6, bl5)) | 0;
  30801. hi = (hi + Math.imul(ah6, bh5)) | 0;
  30802. lo = (lo + Math.imul(al5, bl6)) | 0;
  30803. mid = (mid + Math.imul(al5, bh6)) | 0;
  30804. mid = (mid + Math.imul(ah5, bl6)) | 0;
  30805. hi = (hi + Math.imul(ah5, bh6)) | 0;
  30806. lo = (lo + Math.imul(al4, bl7)) | 0;
  30807. mid = (mid + Math.imul(al4, bh7)) | 0;
  30808. mid = (mid + Math.imul(ah4, bl7)) | 0;
  30809. hi = (hi + Math.imul(ah4, bh7)) | 0;
  30810. lo = (lo + Math.imul(al3, bl8)) | 0;
  30811. mid = (mid + Math.imul(al3, bh8)) | 0;
  30812. mid = (mid + Math.imul(ah3, bl8)) | 0;
  30813. hi = (hi + Math.imul(ah3, bh8)) | 0;
  30814. lo = (lo + Math.imul(al2, bl9)) | 0;
  30815. mid = (mid + Math.imul(al2, bh9)) | 0;
  30816. mid = (mid + Math.imul(ah2, bl9)) | 0;
  30817. hi = (hi + Math.imul(ah2, bh9)) | 0;
  30818. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30819. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  30820. w11 &= 0x3ffffff;
  30821. /* k = 12 */
  30822. lo = Math.imul(al9, bl3);
  30823. mid = Math.imul(al9, bh3);
  30824. mid = (mid + Math.imul(ah9, bl3)) | 0;
  30825. hi = Math.imul(ah9, bh3);
  30826. lo = (lo + Math.imul(al8, bl4)) | 0;
  30827. mid = (mid + Math.imul(al8, bh4)) | 0;
  30828. mid = (mid + Math.imul(ah8, bl4)) | 0;
  30829. hi = (hi + Math.imul(ah8, bh4)) | 0;
  30830. lo = (lo + Math.imul(al7, bl5)) | 0;
  30831. mid = (mid + Math.imul(al7, bh5)) | 0;
  30832. mid = (mid + Math.imul(ah7, bl5)) | 0;
  30833. hi = (hi + Math.imul(ah7, bh5)) | 0;
  30834. lo = (lo + Math.imul(al6, bl6)) | 0;
  30835. mid = (mid + Math.imul(al6, bh6)) | 0;
  30836. mid = (mid + Math.imul(ah6, bl6)) | 0;
  30837. hi = (hi + Math.imul(ah6, bh6)) | 0;
  30838. lo = (lo + Math.imul(al5, bl7)) | 0;
  30839. mid = (mid + Math.imul(al5, bh7)) | 0;
  30840. mid = (mid + Math.imul(ah5, bl7)) | 0;
  30841. hi = (hi + Math.imul(ah5, bh7)) | 0;
  30842. lo = (lo + Math.imul(al4, bl8)) | 0;
  30843. mid = (mid + Math.imul(al4, bh8)) | 0;
  30844. mid = (mid + Math.imul(ah4, bl8)) | 0;
  30845. hi = (hi + Math.imul(ah4, bh8)) | 0;
  30846. lo = (lo + Math.imul(al3, bl9)) | 0;
  30847. mid = (mid + Math.imul(al3, bh9)) | 0;
  30848. mid = (mid + Math.imul(ah3, bl9)) | 0;
  30849. hi = (hi + Math.imul(ah3, bh9)) | 0;
  30850. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30851. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  30852. w12 &= 0x3ffffff;
  30853. /* k = 13 */
  30854. lo = Math.imul(al9, bl4);
  30855. mid = Math.imul(al9, bh4);
  30856. mid = (mid + Math.imul(ah9, bl4)) | 0;
  30857. hi = Math.imul(ah9, bh4);
  30858. lo = (lo + Math.imul(al8, bl5)) | 0;
  30859. mid = (mid + Math.imul(al8, bh5)) | 0;
  30860. mid = (mid + Math.imul(ah8, bl5)) | 0;
  30861. hi = (hi + Math.imul(ah8, bh5)) | 0;
  30862. lo = (lo + Math.imul(al7, bl6)) | 0;
  30863. mid = (mid + Math.imul(al7, bh6)) | 0;
  30864. mid = (mid + Math.imul(ah7, bl6)) | 0;
  30865. hi = (hi + Math.imul(ah7, bh6)) | 0;
  30866. lo = (lo + Math.imul(al6, bl7)) | 0;
  30867. mid = (mid + Math.imul(al6, bh7)) | 0;
  30868. mid = (mid + Math.imul(ah6, bl7)) | 0;
  30869. hi = (hi + Math.imul(ah6, bh7)) | 0;
  30870. lo = (lo + Math.imul(al5, bl8)) | 0;
  30871. mid = (mid + Math.imul(al5, bh8)) | 0;
  30872. mid = (mid + Math.imul(ah5, bl8)) | 0;
  30873. hi = (hi + Math.imul(ah5, bh8)) | 0;
  30874. lo = (lo + Math.imul(al4, bl9)) | 0;
  30875. mid = (mid + Math.imul(al4, bh9)) | 0;
  30876. mid = (mid + Math.imul(ah4, bl9)) | 0;
  30877. hi = (hi + Math.imul(ah4, bh9)) | 0;
  30878. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30879. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  30880. w13 &= 0x3ffffff;
  30881. /* k = 14 */
  30882. lo = Math.imul(al9, bl5);
  30883. mid = Math.imul(al9, bh5);
  30884. mid = (mid + Math.imul(ah9, bl5)) | 0;
  30885. hi = Math.imul(ah9, bh5);
  30886. lo = (lo + Math.imul(al8, bl6)) | 0;
  30887. mid = (mid + Math.imul(al8, bh6)) | 0;
  30888. mid = (mid + Math.imul(ah8, bl6)) | 0;
  30889. hi = (hi + Math.imul(ah8, bh6)) | 0;
  30890. lo = (lo + Math.imul(al7, bl7)) | 0;
  30891. mid = (mid + Math.imul(al7, bh7)) | 0;
  30892. mid = (mid + Math.imul(ah7, bl7)) | 0;
  30893. hi = (hi + Math.imul(ah7, bh7)) | 0;
  30894. lo = (lo + Math.imul(al6, bl8)) | 0;
  30895. mid = (mid + Math.imul(al6, bh8)) | 0;
  30896. mid = (mid + Math.imul(ah6, bl8)) | 0;
  30897. hi = (hi + Math.imul(ah6, bh8)) | 0;
  30898. lo = (lo + Math.imul(al5, bl9)) | 0;
  30899. mid = (mid + Math.imul(al5, bh9)) | 0;
  30900. mid = (mid + Math.imul(ah5, bl9)) | 0;
  30901. hi = (hi + Math.imul(ah5, bh9)) | 0;
  30902. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30903. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  30904. w14 &= 0x3ffffff;
  30905. /* k = 15 */
  30906. lo = Math.imul(al9, bl6);
  30907. mid = Math.imul(al9, bh6);
  30908. mid = (mid + Math.imul(ah9, bl6)) | 0;
  30909. hi = Math.imul(ah9, bh6);
  30910. lo = (lo + Math.imul(al8, bl7)) | 0;
  30911. mid = (mid + Math.imul(al8, bh7)) | 0;
  30912. mid = (mid + Math.imul(ah8, bl7)) | 0;
  30913. hi = (hi + Math.imul(ah8, bh7)) | 0;
  30914. lo = (lo + Math.imul(al7, bl8)) | 0;
  30915. mid = (mid + Math.imul(al7, bh8)) | 0;
  30916. mid = (mid + Math.imul(ah7, bl8)) | 0;
  30917. hi = (hi + Math.imul(ah7, bh8)) | 0;
  30918. lo = (lo + Math.imul(al6, bl9)) | 0;
  30919. mid = (mid + Math.imul(al6, bh9)) | 0;
  30920. mid = (mid + Math.imul(ah6, bl9)) | 0;
  30921. hi = (hi + Math.imul(ah6, bh9)) | 0;
  30922. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30923. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  30924. w15 &= 0x3ffffff;
  30925. /* k = 16 */
  30926. lo = Math.imul(al9, bl7);
  30927. mid = Math.imul(al9, bh7);
  30928. mid = (mid + Math.imul(ah9, bl7)) | 0;
  30929. hi = Math.imul(ah9, bh7);
  30930. lo = (lo + Math.imul(al8, bl8)) | 0;
  30931. mid = (mid + Math.imul(al8, bh8)) | 0;
  30932. mid = (mid + Math.imul(ah8, bl8)) | 0;
  30933. hi = (hi + Math.imul(ah8, bh8)) | 0;
  30934. lo = (lo + Math.imul(al7, bl9)) | 0;
  30935. mid = (mid + Math.imul(al7, bh9)) | 0;
  30936. mid = (mid + Math.imul(ah7, bl9)) | 0;
  30937. hi = (hi + Math.imul(ah7, bh9)) | 0;
  30938. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30939. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  30940. w16 &= 0x3ffffff;
  30941. /* k = 17 */
  30942. lo = Math.imul(al9, bl8);
  30943. mid = Math.imul(al9, bh8);
  30944. mid = (mid + Math.imul(ah9, bl8)) | 0;
  30945. hi = Math.imul(ah9, bh8);
  30946. lo = (lo + Math.imul(al8, bl9)) | 0;
  30947. mid = (mid + Math.imul(al8, bh9)) | 0;
  30948. mid = (mid + Math.imul(ah8, bl9)) | 0;
  30949. hi = (hi + Math.imul(ah8, bh9)) | 0;
  30950. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30951. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  30952. w17 &= 0x3ffffff;
  30953. /* k = 18 */
  30954. lo = Math.imul(al9, bl9);
  30955. mid = Math.imul(al9, bh9);
  30956. mid = (mid + Math.imul(ah9, bl9)) | 0;
  30957. hi = Math.imul(ah9, bh9);
  30958. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  30959. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  30960. w18 &= 0x3ffffff;
  30961. o[0] = w0;
  30962. o[1] = w1;
  30963. o[2] = w2;
  30964. o[3] = w3;
  30965. o[4] = w4;
  30966. o[5] = w5;
  30967. o[6] = w6;
  30968. o[7] = w7;
  30969. o[8] = w8;
  30970. o[9] = w9;
  30971. o[10] = w10;
  30972. o[11] = w11;
  30973. o[12] = w12;
  30974. o[13] = w13;
  30975. o[14] = w14;
  30976. o[15] = w15;
  30977. o[16] = w16;
  30978. o[17] = w17;
  30979. o[18] = w18;
  30980. if (c !== 0) {
  30981. o[19] = c;
  30982. out.length++;
  30983. }
  30984. return out;
  30985. };
  30986. // Polyfill comb
  30987. if (!Math.imul) {
  30988. comb10MulTo = smallMulTo;
  30989. }
  30990. function bigMulTo (self, num, out) {
  30991. out.negative = num.negative ^ self.negative;
  30992. out.length = self.length + num.length;
  30993. var carry = 0;
  30994. var hncarry = 0;
  30995. for (var k = 0; k < out.length - 1; k++) {
  30996. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  30997. // note that ncarry could be >= 0x3ffffff
  30998. var ncarry = hncarry;
  30999. hncarry = 0;
  31000. var rword = carry & 0x3ffffff;
  31001. var maxJ = Math.min(k, num.length - 1);
  31002. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  31003. var i = k - j;
  31004. var a = self.words[i] | 0;
  31005. var b = num.words[j] | 0;
  31006. var r = a * b;
  31007. var lo = r & 0x3ffffff;
  31008. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  31009. lo = (lo + rword) | 0;
  31010. rword = lo & 0x3ffffff;
  31011. ncarry = (ncarry + (lo >>> 26)) | 0;
  31012. hncarry += ncarry >>> 26;
  31013. ncarry &= 0x3ffffff;
  31014. }
  31015. out.words[k] = rword;
  31016. carry = ncarry;
  31017. ncarry = hncarry;
  31018. }
  31019. if (carry !== 0) {
  31020. out.words[k] = carry;
  31021. } else {
  31022. out.length--;
  31023. }
  31024. return out.strip();
  31025. }
  31026. function jumboMulTo (self, num, out) {
  31027. var fftm = new FFTM();
  31028. return fftm.mulp(self, num, out);
  31029. }
  31030. BN.prototype.mulTo = function mulTo (num, out) {
  31031. var res;
  31032. var len = this.length + num.length;
  31033. if (this.length === 10 && num.length === 10) {
  31034. res = comb10MulTo(this, num, out);
  31035. } else if (len < 63) {
  31036. res = smallMulTo(this, num, out);
  31037. } else if (len < 1024) {
  31038. res = bigMulTo(this, num, out);
  31039. } else {
  31040. res = jumboMulTo(this, num, out);
  31041. }
  31042. return res;
  31043. };
  31044. // Cooley-Tukey algorithm for FFT
  31045. // slightly revisited to rely on looping instead of recursion
  31046. function FFTM (x, y) {
  31047. this.x = x;
  31048. this.y = y;
  31049. }
  31050. FFTM.prototype.makeRBT = function makeRBT (N) {
  31051. var t = new Array(N);
  31052. var l = BN.prototype._countBits(N) - 1;
  31053. for (var i = 0; i < N; i++) {
  31054. t[i] = this.revBin(i, l, N);
  31055. }
  31056. return t;
  31057. };
  31058. // Returns binary-reversed representation of `x`
  31059. FFTM.prototype.revBin = function revBin (x, l, N) {
  31060. if (x === 0 || x === N - 1) return x;
  31061. var rb = 0;
  31062. for (var i = 0; i < l; i++) {
  31063. rb |= (x & 1) << (l - i - 1);
  31064. x >>= 1;
  31065. }
  31066. return rb;
  31067. };
  31068. // Performs "tweedling" phase, therefore 'emulating'
  31069. // behaviour of the recursive algorithm
  31070. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  31071. for (var i = 0; i < N; i++) {
  31072. rtws[i] = rws[rbt[i]];
  31073. itws[i] = iws[rbt[i]];
  31074. }
  31075. };
  31076. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  31077. this.permute(rbt, rws, iws, rtws, itws, N);
  31078. for (var s = 1; s < N; s <<= 1) {
  31079. var l = s << 1;
  31080. var rtwdf = Math.cos(2 * Math.PI / l);
  31081. var itwdf = Math.sin(2 * Math.PI / l);
  31082. for (var p = 0; p < N; p += l) {
  31083. var rtwdf_ = rtwdf;
  31084. var itwdf_ = itwdf;
  31085. for (var j = 0; j < s; j++) {
  31086. var re = rtws[p + j];
  31087. var ie = itws[p + j];
  31088. var ro = rtws[p + j + s];
  31089. var io = itws[p + j + s];
  31090. var rx = rtwdf_ * ro - itwdf_ * io;
  31091. io = rtwdf_ * io + itwdf_ * ro;
  31092. ro = rx;
  31093. rtws[p + j] = re + ro;
  31094. itws[p + j] = ie + io;
  31095. rtws[p + j + s] = re - ro;
  31096. itws[p + j + s] = ie - io;
  31097. /* jshint maxdepth : false */
  31098. if (j !== l) {
  31099. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  31100. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  31101. rtwdf_ = rx;
  31102. }
  31103. }
  31104. }
  31105. }
  31106. };
  31107. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  31108. var N = Math.max(m, n) | 1;
  31109. var odd = N & 1;
  31110. var i = 0;
  31111. for (N = N / 2 | 0; N; N = N >>> 1) {
  31112. i++;
  31113. }
  31114. return 1 << i + 1 + odd;
  31115. };
  31116. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  31117. if (N <= 1) return;
  31118. for (var i = 0; i < N / 2; i++) {
  31119. var t = rws[i];
  31120. rws[i] = rws[N - i - 1];
  31121. rws[N - i - 1] = t;
  31122. t = iws[i];
  31123. iws[i] = -iws[N - i - 1];
  31124. iws[N - i - 1] = -t;
  31125. }
  31126. };
  31127. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  31128. var carry = 0;
  31129. for (var i = 0; i < N / 2; i++) {
  31130. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  31131. Math.round(ws[2 * i] / N) +
  31132. carry;
  31133. ws[i] = w & 0x3ffffff;
  31134. if (w < 0x4000000) {
  31135. carry = 0;
  31136. } else {
  31137. carry = w / 0x4000000 | 0;
  31138. }
  31139. }
  31140. return ws;
  31141. };
  31142. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  31143. var carry = 0;
  31144. for (var i = 0; i < len; i++) {
  31145. carry = carry + (ws[i] | 0);
  31146. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  31147. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  31148. }
  31149. // Pad with zeroes
  31150. for (i = 2 * len; i < N; ++i) {
  31151. rws[i] = 0;
  31152. }
  31153. assert(carry === 0);
  31154. assert((carry & ~0x1fff) === 0);
  31155. };
  31156. FFTM.prototype.stub = function stub (N) {
  31157. var ph = new Array(N);
  31158. for (var i = 0; i < N; i++) {
  31159. ph[i] = 0;
  31160. }
  31161. return ph;
  31162. };
  31163. FFTM.prototype.mulp = function mulp (x, y, out) {
  31164. var N = 2 * this.guessLen13b(x.length, y.length);
  31165. var rbt = this.makeRBT(N);
  31166. var _ = this.stub(N);
  31167. var rws = new Array(N);
  31168. var rwst = new Array(N);
  31169. var iwst = new Array(N);
  31170. var nrws = new Array(N);
  31171. var nrwst = new Array(N);
  31172. var niwst = new Array(N);
  31173. var rmws = out.words;
  31174. rmws.length = N;
  31175. this.convert13b(x.words, x.length, rws, N);
  31176. this.convert13b(y.words, y.length, nrws, N);
  31177. this.transform(rws, _, rwst, iwst, N, rbt);
  31178. this.transform(nrws, _, nrwst, niwst, N, rbt);
  31179. for (var i = 0; i < N; i++) {
  31180. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  31181. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  31182. rwst[i] = rx;
  31183. }
  31184. this.conjugate(rwst, iwst, N);
  31185. this.transform(rwst, iwst, rmws, _, N, rbt);
  31186. this.conjugate(rmws, _, N);
  31187. this.normalize13b(rmws, N);
  31188. out.negative = x.negative ^ y.negative;
  31189. out.length = x.length + y.length;
  31190. return out.strip();
  31191. };
  31192. // Multiply `this` by `num`
  31193. BN.prototype.mul = function mul (num) {
  31194. var out = new BN(null);
  31195. out.words = new Array(this.length + num.length);
  31196. return this.mulTo(num, out);
  31197. };
  31198. // Multiply employing FFT
  31199. BN.prototype.mulf = function mulf (num) {
  31200. var out = new BN(null);
  31201. out.words = new Array(this.length + num.length);
  31202. return jumboMulTo(this, num, out);
  31203. };
  31204. // In-place Multiplication
  31205. BN.prototype.imul = function imul (num) {
  31206. return this.clone().mulTo(num, this);
  31207. };
  31208. BN.prototype.imuln = function imuln (num) {
  31209. assert(typeof num === 'number');
  31210. assert(num < 0x4000000);
  31211. // Carry
  31212. var carry = 0;
  31213. for (var i = 0; i < this.length; i++) {
  31214. var w = (this.words[i] | 0) * num;
  31215. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  31216. carry >>= 26;
  31217. carry += (w / 0x4000000) | 0;
  31218. // NOTE: lo is 27bit maximum
  31219. carry += lo >>> 26;
  31220. this.words[i] = lo & 0x3ffffff;
  31221. }
  31222. if (carry !== 0) {
  31223. this.words[i] = carry;
  31224. this.length++;
  31225. }
  31226. return this;
  31227. };
  31228. BN.prototype.muln = function muln (num) {
  31229. return this.clone().imuln(num);
  31230. };
  31231. // `this` * `this`
  31232. BN.prototype.sqr = function sqr () {
  31233. return this.mul(this);
  31234. };
  31235. // `this` * `this` in-place
  31236. BN.prototype.isqr = function isqr () {
  31237. return this.imul(this.clone());
  31238. };
  31239. // Math.pow(`this`, `num`)
  31240. BN.prototype.pow = function pow (num) {
  31241. var w = toBitArray(num);
  31242. if (w.length === 0) return new BN(1);
  31243. // Skip leading zeroes
  31244. var res = this;
  31245. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  31246. if (w[i] !== 0) break;
  31247. }
  31248. if (++i < w.length) {
  31249. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  31250. if (w[i] === 0) continue;
  31251. res = res.mul(q);
  31252. }
  31253. }
  31254. return res;
  31255. };
  31256. // Shift-left in-place
  31257. BN.prototype.iushln = function iushln (bits) {
  31258. assert(typeof bits === 'number' && bits >= 0);
  31259. var r = bits % 26;
  31260. var s = (bits - r) / 26;
  31261. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  31262. var i;
  31263. if (r !== 0) {
  31264. var carry = 0;
  31265. for (i = 0; i < this.length; i++) {
  31266. var newCarry = this.words[i] & carryMask;
  31267. var c = ((this.words[i] | 0) - newCarry) << r;
  31268. this.words[i] = c | carry;
  31269. carry = newCarry >>> (26 - r);
  31270. }
  31271. if (carry) {
  31272. this.words[i] = carry;
  31273. this.length++;
  31274. }
  31275. }
  31276. if (s !== 0) {
  31277. for (i = this.length - 1; i >= 0; i--) {
  31278. this.words[i + s] = this.words[i];
  31279. }
  31280. for (i = 0; i < s; i++) {
  31281. this.words[i] = 0;
  31282. }
  31283. this.length += s;
  31284. }
  31285. return this.strip();
  31286. };
  31287. BN.prototype.ishln = function ishln (bits) {
  31288. // TODO(indutny): implement me
  31289. assert(this.negative === 0);
  31290. return this.iushln(bits);
  31291. };
  31292. // Shift-right in-place
  31293. // NOTE: `hint` is a lowest bit before trailing zeroes
  31294. // NOTE: if `extended` is present - it will be filled with destroyed bits
  31295. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  31296. assert(typeof bits === 'number' && bits >= 0);
  31297. var h;
  31298. if (hint) {
  31299. h = (hint - (hint % 26)) / 26;
  31300. } else {
  31301. h = 0;
  31302. }
  31303. var r = bits % 26;
  31304. var s = Math.min((bits - r) / 26, this.length);
  31305. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  31306. var maskedWords = extended;
  31307. h -= s;
  31308. h = Math.max(0, h);
  31309. // Extended mode, copy masked part
  31310. if (maskedWords) {
  31311. for (var i = 0; i < s; i++) {
  31312. maskedWords.words[i] = this.words[i];
  31313. }
  31314. maskedWords.length = s;
  31315. }
  31316. if (s === 0) {
  31317. // No-op, we should not move anything at all
  31318. } else if (this.length > s) {
  31319. this.length -= s;
  31320. for (i = 0; i < this.length; i++) {
  31321. this.words[i] = this.words[i + s];
  31322. }
  31323. } else {
  31324. this.words[0] = 0;
  31325. this.length = 1;
  31326. }
  31327. var carry = 0;
  31328. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  31329. var word = this.words[i] | 0;
  31330. this.words[i] = (carry << (26 - r)) | (word >>> r);
  31331. carry = word & mask;
  31332. }
  31333. // Push carried bits as a mask
  31334. if (maskedWords && carry !== 0) {
  31335. maskedWords.words[maskedWords.length++] = carry;
  31336. }
  31337. if (this.length === 0) {
  31338. this.words[0] = 0;
  31339. this.length = 1;
  31340. }
  31341. return this.strip();
  31342. };
  31343. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  31344. // TODO(indutny): implement me
  31345. assert(this.negative === 0);
  31346. return this.iushrn(bits, hint, extended);
  31347. };
  31348. // Shift-left
  31349. BN.prototype.shln = function shln (bits) {
  31350. return this.clone().ishln(bits);
  31351. };
  31352. BN.prototype.ushln = function ushln (bits) {
  31353. return this.clone().iushln(bits);
  31354. };
  31355. // Shift-right
  31356. BN.prototype.shrn = function shrn (bits) {
  31357. return this.clone().ishrn(bits);
  31358. };
  31359. BN.prototype.ushrn = function ushrn (bits) {
  31360. return this.clone().iushrn(bits);
  31361. };
  31362. // Test if n bit is set
  31363. BN.prototype.testn = function testn (bit) {
  31364. assert(typeof bit === 'number' && bit >= 0);
  31365. var r = bit % 26;
  31366. var s = (bit - r) / 26;
  31367. var q = 1 << r;
  31368. // Fast case: bit is much higher than all existing words
  31369. if (this.length <= s) return false;
  31370. // Check bit and return
  31371. var w = this.words[s];
  31372. return !!(w & q);
  31373. };
  31374. // Return only lowers bits of number (in-place)
  31375. BN.prototype.imaskn = function imaskn (bits) {
  31376. assert(typeof bits === 'number' && bits >= 0);
  31377. var r = bits % 26;
  31378. var s = (bits - r) / 26;
  31379. assert(this.negative === 0, 'imaskn works only with positive numbers');
  31380. if (this.length <= s) {
  31381. return this;
  31382. }
  31383. if (r !== 0) {
  31384. s++;
  31385. }
  31386. this.length = Math.min(s, this.length);
  31387. if (r !== 0) {
  31388. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  31389. this.words[this.length - 1] &= mask;
  31390. }
  31391. return this.strip();
  31392. };
  31393. // Return only lowers bits of number
  31394. BN.prototype.maskn = function maskn (bits) {
  31395. return this.clone().imaskn(bits);
  31396. };
  31397. // Add plain number `num` to `this`
  31398. BN.prototype.iaddn = function iaddn (num) {
  31399. assert(typeof num === 'number');
  31400. assert(num < 0x4000000);
  31401. if (num < 0) return this.isubn(-num);
  31402. // Possible sign change
  31403. if (this.negative !== 0) {
  31404. if (this.length === 1 && (this.words[0] | 0) < num) {
  31405. this.words[0] = num - (this.words[0] | 0);
  31406. this.negative = 0;
  31407. return this;
  31408. }
  31409. this.negative = 0;
  31410. this.isubn(num);
  31411. this.negative = 1;
  31412. return this;
  31413. }
  31414. // Add without checks
  31415. return this._iaddn(num);
  31416. };
  31417. BN.prototype._iaddn = function _iaddn (num) {
  31418. this.words[0] += num;
  31419. // Carry
  31420. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  31421. this.words[i] -= 0x4000000;
  31422. if (i === this.length - 1) {
  31423. this.words[i + 1] = 1;
  31424. } else {
  31425. this.words[i + 1]++;
  31426. }
  31427. }
  31428. this.length = Math.max(this.length, i + 1);
  31429. return this;
  31430. };
  31431. // Subtract plain number `num` from `this`
  31432. BN.prototype.isubn = function isubn (num) {
  31433. assert(typeof num === 'number');
  31434. assert(num < 0x4000000);
  31435. if (num < 0) return this.iaddn(-num);
  31436. if (this.negative !== 0) {
  31437. this.negative = 0;
  31438. this.iaddn(num);
  31439. this.negative = 1;
  31440. return this;
  31441. }
  31442. this.words[0] -= num;
  31443. if (this.length === 1 && this.words[0] < 0) {
  31444. this.words[0] = -this.words[0];
  31445. this.negative = 1;
  31446. } else {
  31447. // Carry
  31448. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  31449. this.words[i] += 0x4000000;
  31450. this.words[i + 1] -= 1;
  31451. }
  31452. }
  31453. return this.strip();
  31454. };
  31455. BN.prototype.addn = function addn (num) {
  31456. return this.clone().iaddn(num);
  31457. };
  31458. BN.prototype.subn = function subn (num) {
  31459. return this.clone().isubn(num);
  31460. };
  31461. BN.prototype.iabs = function iabs () {
  31462. this.negative = 0;
  31463. return this;
  31464. };
  31465. BN.prototype.abs = function abs () {
  31466. return this.clone().iabs();
  31467. };
  31468. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  31469. var len = num.length + shift;
  31470. var i;
  31471. this._expand(len);
  31472. var w;
  31473. var carry = 0;
  31474. for (i = 0; i < num.length; i++) {
  31475. w = (this.words[i + shift] | 0) + carry;
  31476. var right = (num.words[i] | 0) * mul;
  31477. w -= right & 0x3ffffff;
  31478. carry = (w >> 26) - ((right / 0x4000000) | 0);
  31479. this.words[i + shift] = w & 0x3ffffff;
  31480. }
  31481. for (; i < this.length - shift; i++) {
  31482. w = (this.words[i + shift] | 0) + carry;
  31483. carry = w >> 26;
  31484. this.words[i + shift] = w & 0x3ffffff;
  31485. }
  31486. if (carry === 0) return this.strip();
  31487. // Subtraction overflow
  31488. assert(carry === -1);
  31489. carry = 0;
  31490. for (i = 0; i < this.length; i++) {
  31491. w = -(this.words[i] | 0) + carry;
  31492. carry = w >> 26;
  31493. this.words[i] = w & 0x3ffffff;
  31494. }
  31495. this.negative = 1;
  31496. return this.strip();
  31497. };
  31498. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  31499. var shift = this.length - num.length;
  31500. var a = this.clone();
  31501. var b = num;
  31502. // Normalize
  31503. var bhi = b.words[b.length - 1] | 0;
  31504. var bhiBits = this._countBits(bhi);
  31505. shift = 26 - bhiBits;
  31506. if (shift !== 0) {
  31507. b = b.ushln(shift);
  31508. a.iushln(shift);
  31509. bhi = b.words[b.length - 1] | 0;
  31510. }
  31511. // Initialize quotient
  31512. var m = a.length - b.length;
  31513. var q;
  31514. if (mode !== 'mod') {
  31515. q = new BN(null);
  31516. q.length = m + 1;
  31517. q.words = new Array(q.length);
  31518. for (var i = 0; i < q.length; i++) {
  31519. q.words[i] = 0;
  31520. }
  31521. }
  31522. var diff = a.clone()._ishlnsubmul(b, 1, m);
  31523. if (diff.negative === 0) {
  31524. a = diff;
  31525. if (q) {
  31526. q.words[m] = 1;
  31527. }
  31528. }
  31529. for (var j = m - 1; j >= 0; j--) {
  31530. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  31531. (a.words[b.length + j - 1] | 0);
  31532. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  31533. // (0x7ffffff)
  31534. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  31535. a._ishlnsubmul(b, qj, j);
  31536. while (a.negative !== 0) {
  31537. qj--;
  31538. a.negative = 0;
  31539. a._ishlnsubmul(b, 1, j);
  31540. if (!a.isZero()) {
  31541. a.negative ^= 1;
  31542. }
  31543. }
  31544. if (q) {
  31545. q.words[j] = qj;
  31546. }
  31547. }
  31548. if (q) {
  31549. q.strip();
  31550. }
  31551. a.strip();
  31552. // Denormalize
  31553. if (mode !== 'div' && shift !== 0) {
  31554. a.iushrn(shift);
  31555. }
  31556. return {
  31557. div: q || null,
  31558. mod: a
  31559. };
  31560. };
  31561. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  31562. // to `div` to request div only, or be absent to
  31563. // request both div & mod
  31564. // 2) `positive` is true if unsigned mod is requested
  31565. BN.prototype.divmod = function divmod (num, mode, positive) {
  31566. assert(!num.isZero());
  31567. if (this.isZero()) {
  31568. return {
  31569. div: new BN(0),
  31570. mod: new BN(0)
  31571. };
  31572. }
  31573. var div, mod, res;
  31574. if (this.negative !== 0 && num.negative === 0) {
  31575. res = this.neg().divmod(num, mode);
  31576. if (mode !== 'mod') {
  31577. div = res.div.neg();
  31578. }
  31579. if (mode !== 'div') {
  31580. mod = res.mod.neg();
  31581. if (positive && mod.negative !== 0) {
  31582. mod.iadd(num);
  31583. }
  31584. }
  31585. return {
  31586. div: div,
  31587. mod: mod
  31588. };
  31589. }
  31590. if (this.negative === 0 && num.negative !== 0) {
  31591. res = this.divmod(num.neg(), mode);
  31592. if (mode !== 'mod') {
  31593. div = res.div.neg();
  31594. }
  31595. return {
  31596. div: div,
  31597. mod: res.mod
  31598. };
  31599. }
  31600. if ((this.negative & num.negative) !== 0) {
  31601. res = this.neg().divmod(num.neg(), mode);
  31602. if (mode !== 'div') {
  31603. mod = res.mod.neg();
  31604. if (positive && mod.negative !== 0) {
  31605. mod.isub(num);
  31606. }
  31607. }
  31608. return {
  31609. div: res.div,
  31610. mod: mod
  31611. };
  31612. }
  31613. // Both numbers are positive at this point
  31614. // Strip both numbers to approximate shift value
  31615. if (num.length > this.length || this.cmp(num) < 0) {
  31616. return {
  31617. div: new BN(0),
  31618. mod: this
  31619. };
  31620. }
  31621. // Very short reduction
  31622. if (num.length === 1) {
  31623. if (mode === 'div') {
  31624. return {
  31625. div: this.divn(num.words[0]),
  31626. mod: null
  31627. };
  31628. }
  31629. if (mode === 'mod') {
  31630. return {
  31631. div: null,
  31632. mod: new BN(this.modn(num.words[0]))
  31633. };
  31634. }
  31635. return {
  31636. div: this.divn(num.words[0]),
  31637. mod: new BN(this.modn(num.words[0]))
  31638. };
  31639. }
  31640. return this._wordDiv(num, mode);
  31641. };
  31642. // Find `this` / `num`
  31643. BN.prototype.div = function div (num) {
  31644. return this.divmod(num, 'div', false).div;
  31645. };
  31646. // Find `this` % `num`
  31647. BN.prototype.mod = function mod (num) {
  31648. return this.divmod(num, 'mod', false).mod;
  31649. };
  31650. BN.prototype.umod = function umod (num) {
  31651. return this.divmod(num, 'mod', true).mod;
  31652. };
  31653. // Find Round(`this` / `num`)
  31654. BN.prototype.divRound = function divRound (num) {
  31655. var dm = this.divmod(num);
  31656. // Fast case - exact division
  31657. if (dm.mod.isZero()) return dm.div;
  31658. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  31659. var half = num.ushrn(1);
  31660. var r2 = num.andln(1);
  31661. var cmp = mod.cmp(half);
  31662. // Round down
  31663. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  31664. // Round up
  31665. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  31666. };
  31667. BN.prototype.modn = function modn (num) {
  31668. assert(num <= 0x3ffffff);
  31669. var p = (1 << 26) % num;
  31670. var acc = 0;
  31671. for (var i = this.length - 1; i >= 0; i--) {
  31672. acc = (p * acc + (this.words[i] | 0)) % num;
  31673. }
  31674. return acc;
  31675. };
  31676. // In-place division by number
  31677. BN.prototype.idivn = function idivn (num) {
  31678. assert(num <= 0x3ffffff);
  31679. var carry = 0;
  31680. for (var i = this.length - 1; i >= 0; i--) {
  31681. var w = (this.words[i] | 0) + carry * 0x4000000;
  31682. this.words[i] = (w / num) | 0;
  31683. carry = w % num;
  31684. }
  31685. return this.strip();
  31686. };
  31687. BN.prototype.divn = function divn (num) {
  31688. return this.clone().idivn(num);
  31689. };
  31690. BN.prototype.egcd = function egcd (p) {
  31691. assert(p.negative === 0);
  31692. assert(!p.isZero());
  31693. var x = this;
  31694. var y = p.clone();
  31695. if (x.negative !== 0) {
  31696. x = x.umod(p);
  31697. } else {
  31698. x = x.clone();
  31699. }
  31700. // A * x + B * y = x
  31701. var A = new BN(1);
  31702. var B = new BN(0);
  31703. // C * x + D * y = y
  31704. var C = new BN(0);
  31705. var D = new BN(1);
  31706. var g = 0;
  31707. while (x.isEven() && y.isEven()) {
  31708. x.iushrn(1);
  31709. y.iushrn(1);
  31710. ++g;
  31711. }
  31712. var yp = y.clone();
  31713. var xp = x.clone();
  31714. while (!x.isZero()) {
  31715. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  31716. if (i > 0) {
  31717. x.iushrn(i);
  31718. while (i-- > 0) {
  31719. if (A.isOdd() || B.isOdd()) {
  31720. A.iadd(yp);
  31721. B.isub(xp);
  31722. }
  31723. A.iushrn(1);
  31724. B.iushrn(1);
  31725. }
  31726. }
  31727. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  31728. if (j > 0) {
  31729. y.iushrn(j);
  31730. while (j-- > 0) {
  31731. if (C.isOdd() || D.isOdd()) {
  31732. C.iadd(yp);
  31733. D.isub(xp);
  31734. }
  31735. C.iushrn(1);
  31736. D.iushrn(1);
  31737. }
  31738. }
  31739. if (x.cmp(y) >= 0) {
  31740. x.isub(y);
  31741. A.isub(C);
  31742. B.isub(D);
  31743. } else {
  31744. y.isub(x);
  31745. C.isub(A);
  31746. D.isub(B);
  31747. }
  31748. }
  31749. return {
  31750. a: C,
  31751. b: D,
  31752. gcd: y.iushln(g)
  31753. };
  31754. };
  31755. // This is reduced incarnation of the binary EEA
  31756. // above, designated to invert members of the
  31757. // _prime_ fields F(p) at a maximal speed
  31758. BN.prototype._invmp = function _invmp (p) {
  31759. assert(p.negative === 0);
  31760. assert(!p.isZero());
  31761. var a = this;
  31762. var b = p.clone();
  31763. if (a.negative !== 0) {
  31764. a = a.umod(p);
  31765. } else {
  31766. a = a.clone();
  31767. }
  31768. var x1 = new BN(1);
  31769. var x2 = new BN(0);
  31770. var delta = b.clone();
  31771. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  31772. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  31773. if (i > 0) {
  31774. a.iushrn(i);
  31775. while (i-- > 0) {
  31776. if (x1.isOdd()) {
  31777. x1.iadd(delta);
  31778. }
  31779. x1.iushrn(1);
  31780. }
  31781. }
  31782. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  31783. if (j > 0) {
  31784. b.iushrn(j);
  31785. while (j-- > 0) {
  31786. if (x2.isOdd()) {
  31787. x2.iadd(delta);
  31788. }
  31789. x2.iushrn(1);
  31790. }
  31791. }
  31792. if (a.cmp(b) >= 0) {
  31793. a.isub(b);
  31794. x1.isub(x2);
  31795. } else {
  31796. b.isub(a);
  31797. x2.isub(x1);
  31798. }
  31799. }
  31800. var res;
  31801. if (a.cmpn(1) === 0) {
  31802. res = x1;
  31803. } else {
  31804. res = x2;
  31805. }
  31806. if (res.cmpn(0) < 0) {
  31807. res.iadd(p);
  31808. }
  31809. return res;
  31810. };
  31811. BN.prototype.gcd = function gcd (num) {
  31812. if (this.isZero()) return num.abs();
  31813. if (num.isZero()) return this.abs();
  31814. var a = this.clone();
  31815. var b = num.clone();
  31816. a.negative = 0;
  31817. b.negative = 0;
  31818. // Remove common factor of two
  31819. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  31820. a.iushrn(1);
  31821. b.iushrn(1);
  31822. }
  31823. do {
  31824. while (a.isEven()) {
  31825. a.iushrn(1);
  31826. }
  31827. while (b.isEven()) {
  31828. b.iushrn(1);
  31829. }
  31830. var r = a.cmp(b);
  31831. if (r < 0) {
  31832. // Swap `a` and `b` to make `a` always bigger than `b`
  31833. var t = a;
  31834. a = b;
  31835. b = t;
  31836. } else if (r === 0 || b.cmpn(1) === 0) {
  31837. break;
  31838. }
  31839. a.isub(b);
  31840. } while (true);
  31841. return b.iushln(shift);
  31842. };
  31843. // Invert number in the field F(num)
  31844. BN.prototype.invm = function invm (num) {
  31845. return this.egcd(num).a.umod(num);
  31846. };
  31847. BN.prototype.isEven = function isEven () {
  31848. return (this.words[0] & 1) === 0;
  31849. };
  31850. BN.prototype.isOdd = function isOdd () {
  31851. return (this.words[0] & 1) === 1;
  31852. };
  31853. // And first word and num
  31854. BN.prototype.andln = function andln (num) {
  31855. return this.words[0] & num;
  31856. };
  31857. // Increment at the bit position in-line
  31858. BN.prototype.bincn = function bincn (bit) {
  31859. assert(typeof bit === 'number');
  31860. var r = bit % 26;
  31861. var s = (bit - r) / 26;
  31862. var q = 1 << r;
  31863. // Fast case: bit is much higher than all existing words
  31864. if (this.length <= s) {
  31865. this._expand(s + 1);
  31866. this.words[s] |= q;
  31867. return this;
  31868. }
  31869. // Add bit and propagate, if needed
  31870. var carry = q;
  31871. for (var i = s; carry !== 0 && i < this.length; i++) {
  31872. var w = this.words[i] | 0;
  31873. w += carry;
  31874. carry = w >>> 26;
  31875. w &= 0x3ffffff;
  31876. this.words[i] = w;
  31877. }
  31878. if (carry !== 0) {
  31879. this.words[i] = carry;
  31880. this.length++;
  31881. }
  31882. return this;
  31883. };
  31884. BN.prototype.isZero = function isZero () {
  31885. return this.length === 1 && this.words[0] === 0;
  31886. };
  31887. BN.prototype.cmpn = function cmpn (num) {
  31888. var negative = num < 0;
  31889. if (this.negative !== 0 && !negative) return -1;
  31890. if (this.negative === 0 && negative) return 1;
  31891. this.strip();
  31892. var res;
  31893. if (this.length > 1) {
  31894. res = 1;
  31895. } else {
  31896. if (negative) {
  31897. num = -num;
  31898. }
  31899. assert(num <= 0x3ffffff, 'Number is too big');
  31900. var w = this.words[0] | 0;
  31901. res = w === num ? 0 : w < num ? -1 : 1;
  31902. }
  31903. if (this.negative !== 0) return -res | 0;
  31904. return res;
  31905. };
  31906. // Compare two numbers and return:
  31907. // 1 - if `this` > `num`
  31908. // 0 - if `this` == `num`
  31909. // -1 - if `this` < `num`
  31910. BN.prototype.cmp = function cmp (num) {
  31911. if (this.negative !== 0 && num.negative === 0) return -1;
  31912. if (this.negative === 0 && num.negative !== 0) return 1;
  31913. var res = this.ucmp(num);
  31914. if (this.negative !== 0) return -res | 0;
  31915. return res;
  31916. };
  31917. // Unsigned comparison
  31918. BN.prototype.ucmp = function ucmp (num) {
  31919. // At this point both numbers have the same sign
  31920. if (this.length > num.length) return 1;
  31921. if (this.length < num.length) return -1;
  31922. var res = 0;
  31923. for (var i = this.length - 1; i >= 0; i--) {
  31924. var a = this.words[i] | 0;
  31925. var b = num.words[i] | 0;
  31926. if (a === b) continue;
  31927. if (a < b) {
  31928. res = -1;
  31929. } else if (a > b) {
  31930. res = 1;
  31931. }
  31932. break;
  31933. }
  31934. return res;
  31935. };
  31936. BN.prototype.gtn = function gtn (num) {
  31937. return this.cmpn(num) === 1;
  31938. };
  31939. BN.prototype.gt = function gt (num) {
  31940. return this.cmp(num) === 1;
  31941. };
  31942. BN.prototype.gten = function gten (num) {
  31943. return this.cmpn(num) >= 0;
  31944. };
  31945. BN.prototype.gte = function gte (num) {
  31946. return this.cmp(num) >= 0;
  31947. };
  31948. BN.prototype.ltn = function ltn (num) {
  31949. return this.cmpn(num) === -1;
  31950. };
  31951. BN.prototype.lt = function lt (num) {
  31952. return this.cmp(num) === -1;
  31953. };
  31954. BN.prototype.lten = function lten (num) {
  31955. return this.cmpn(num) <= 0;
  31956. };
  31957. BN.prototype.lte = function lte (num) {
  31958. return this.cmp(num) <= 0;
  31959. };
  31960. BN.prototype.eqn = function eqn (num) {
  31961. return this.cmpn(num) === 0;
  31962. };
  31963. BN.prototype.eq = function eq (num) {
  31964. return this.cmp(num) === 0;
  31965. };
  31966. //
  31967. // A reduce context, could be using montgomery or something better, depending
  31968. // on the `m` itself.
  31969. //
  31970. BN.red = function red (num) {
  31971. return new Red(num);
  31972. };
  31973. BN.prototype.toRed = function toRed (ctx) {
  31974. assert(!this.red, 'Already a number in reduction context');
  31975. assert(this.negative === 0, 'red works only with positives');
  31976. return ctx.convertTo(this)._forceRed(ctx);
  31977. };
  31978. BN.prototype.fromRed = function fromRed () {
  31979. assert(this.red, 'fromRed works only with numbers in reduction context');
  31980. return this.red.convertFrom(this);
  31981. };
  31982. BN.prototype._forceRed = function _forceRed (ctx) {
  31983. this.red = ctx;
  31984. return this;
  31985. };
  31986. BN.prototype.forceRed = function forceRed (ctx) {
  31987. assert(!this.red, 'Already a number in reduction context');
  31988. return this._forceRed(ctx);
  31989. };
  31990. BN.prototype.redAdd = function redAdd (num) {
  31991. assert(this.red, 'redAdd works only with red numbers');
  31992. return this.red.add(this, num);
  31993. };
  31994. BN.prototype.redIAdd = function redIAdd (num) {
  31995. assert(this.red, 'redIAdd works only with red numbers');
  31996. return this.red.iadd(this, num);
  31997. };
  31998. BN.prototype.redSub = function redSub (num) {
  31999. assert(this.red, 'redSub works only with red numbers');
  32000. return this.red.sub(this, num);
  32001. };
  32002. BN.prototype.redISub = function redISub (num) {
  32003. assert(this.red, 'redISub works only with red numbers');
  32004. return this.red.isub(this, num);
  32005. };
  32006. BN.prototype.redShl = function redShl (num) {
  32007. assert(this.red, 'redShl works only with red numbers');
  32008. return this.red.shl(this, num);
  32009. };
  32010. BN.prototype.redMul = function redMul (num) {
  32011. assert(this.red, 'redMul works only with red numbers');
  32012. this.red._verify2(this, num);
  32013. return this.red.mul(this, num);
  32014. };
  32015. BN.prototype.redIMul = function redIMul (num) {
  32016. assert(this.red, 'redMul works only with red numbers');
  32017. this.red._verify2(this, num);
  32018. return this.red.imul(this, num);
  32019. };
  32020. BN.prototype.redSqr = function redSqr () {
  32021. assert(this.red, 'redSqr works only with red numbers');
  32022. this.red._verify1(this);
  32023. return this.red.sqr(this);
  32024. };
  32025. BN.prototype.redISqr = function redISqr () {
  32026. assert(this.red, 'redISqr works only with red numbers');
  32027. this.red._verify1(this);
  32028. return this.red.isqr(this);
  32029. };
  32030. // Square root over p
  32031. BN.prototype.redSqrt = function redSqrt () {
  32032. assert(this.red, 'redSqrt works only with red numbers');
  32033. this.red._verify1(this);
  32034. return this.red.sqrt(this);
  32035. };
  32036. BN.prototype.redInvm = function redInvm () {
  32037. assert(this.red, 'redInvm works only with red numbers');
  32038. this.red._verify1(this);
  32039. return this.red.invm(this);
  32040. };
  32041. // Return negative clone of `this` % `red modulo`
  32042. BN.prototype.redNeg = function redNeg () {
  32043. assert(this.red, 'redNeg works only with red numbers');
  32044. this.red._verify1(this);
  32045. return this.red.neg(this);
  32046. };
  32047. BN.prototype.redPow = function redPow (num) {
  32048. assert(this.red && !num.red, 'redPow(normalNum)');
  32049. this.red._verify1(this);
  32050. return this.red.pow(this, num);
  32051. };
  32052. // Prime numbers with efficient reduction
  32053. var primes = {
  32054. k256: null,
  32055. p224: null,
  32056. p192: null,
  32057. p25519: null
  32058. };
  32059. // Pseudo-Mersenne prime
  32060. function MPrime (name, p) {
  32061. // P = 2 ^ N - K
  32062. this.name = name;
  32063. this.p = new BN(p, 16);
  32064. this.n = this.p.bitLength();
  32065. this.k = new BN(1).iushln(this.n).isub(this.p);
  32066. this.tmp = this._tmp();
  32067. }
  32068. MPrime.prototype._tmp = function _tmp () {
  32069. var tmp = new BN(null);
  32070. tmp.words = new Array(Math.ceil(this.n / 13));
  32071. return tmp;
  32072. };
  32073. MPrime.prototype.ireduce = function ireduce (num) {
  32074. // Assumes that `num` is less than `P^2`
  32075. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  32076. var r = num;
  32077. var rlen;
  32078. do {
  32079. this.split(r, this.tmp);
  32080. r = this.imulK(r);
  32081. r = r.iadd(this.tmp);
  32082. rlen = r.bitLength();
  32083. } while (rlen > this.n);
  32084. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  32085. if (cmp === 0) {
  32086. r.words[0] = 0;
  32087. r.length = 1;
  32088. } else if (cmp > 0) {
  32089. r.isub(this.p);
  32090. } else {
  32091. if (r.strip !== undefined) {
  32092. // r is BN v4 instance
  32093. r.strip();
  32094. } else {
  32095. // r is BN v5 instance
  32096. r._strip();
  32097. }
  32098. }
  32099. return r;
  32100. };
  32101. MPrime.prototype.split = function split (input, out) {
  32102. input.iushrn(this.n, 0, out);
  32103. };
  32104. MPrime.prototype.imulK = function imulK (num) {
  32105. return num.imul(this.k);
  32106. };
  32107. function K256 () {
  32108. MPrime.call(
  32109. this,
  32110. 'k256',
  32111. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  32112. }
  32113. inherits(K256, MPrime);
  32114. K256.prototype.split = function split (input, output) {
  32115. // 256 = 9 * 26 + 22
  32116. var mask = 0x3fffff;
  32117. var outLen = Math.min(input.length, 9);
  32118. for (var i = 0; i < outLen; i++) {
  32119. output.words[i] = input.words[i];
  32120. }
  32121. output.length = outLen;
  32122. if (input.length <= 9) {
  32123. input.words[0] = 0;
  32124. input.length = 1;
  32125. return;
  32126. }
  32127. // Shift by 9 limbs
  32128. var prev = input.words[9];
  32129. output.words[output.length++] = prev & mask;
  32130. for (i = 10; i < input.length; i++) {
  32131. var next = input.words[i] | 0;
  32132. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  32133. prev = next;
  32134. }
  32135. prev >>>= 22;
  32136. input.words[i - 10] = prev;
  32137. if (prev === 0 && input.length > 10) {
  32138. input.length -= 10;
  32139. } else {
  32140. input.length -= 9;
  32141. }
  32142. };
  32143. K256.prototype.imulK = function imulK (num) {
  32144. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  32145. num.words[num.length] = 0;
  32146. num.words[num.length + 1] = 0;
  32147. num.length += 2;
  32148. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  32149. var lo = 0;
  32150. for (var i = 0; i < num.length; i++) {
  32151. var w = num.words[i] | 0;
  32152. lo += w * 0x3d1;
  32153. num.words[i] = lo & 0x3ffffff;
  32154. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  32155. }
  32156. // Fast length reduction
  32157. if (num.words[num.length - 1] === 0) {
  32158. num.length--;
  32159. if (num.words[num.length - 1] === 0) {
  32160. num.length--;
  32161. }
  32162. }
  32163. return num;
  32164. };
  32165. function P224 () {
  32166. MPrime.call(
  32167. this,
  32168. 'p224',
  32169. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  32170. }
  32171. inherits(P224, MPrime);
  32172. function P192 () {
  32173. MPrime.call(
  32174. this,
  32175. 'p192',
  32176. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  32177. }
  32178. inherits(P192, MPrime);
  32179. function P25519 () {
  32180. // 2 ^ 255 - 19
  32181. MPrime.call(
  32182. this,
  32183. '25519',
  32184. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  32185. }
  32186. inherits(P25519, MPrime);
  32187. P25519.prototype.imulK = function imulK (num) {
  32188. // K = 0x13
  32189. var carry = 0;
  32190. for (var i = 0; i < num.length; i++) {
  32191. var hi = (num.words[i] | 0) * 0x13 + carry;
  32192. var lo = hi & 0x3ffffff;
  32193. hi >>>= 26;
  32194. num.words[i] = lo;
  32195. carry = hi;
  32196. }
  32197. if (carry !== 0) {
  32198. num.words[num.length++] = carry;
  32199. }
  32200. return num;
  32201. };
  32202. // Exported mostly for testing purposes, use plain name instead
  32203. BN._prime = function prime (name) {
  32204. // Cached version of prime
  32205. if (primes[name]) return primes[name];
  32206. var prime;
  32207. if (name === 'k256') {
  32208. prime = new K256();
  32209. } else if (name === 'p224') {
  32210. prime = new P224();
  32211. } else if (name === 'p192') {
  32212. prime = new P192();
  32213. } else if (name === 'p25519') {
  32214. prime = new P25519();
  32215. } else {
  32216. throw new Error('Unknown prime ' + name);
  32217. }
  32218. primes[name] = prime;
  32219. return prime;
  32220. };
  32221. //
  32222. // Base reduction engine
  32223. //
  32224. function Red (m) {
  32225. if (typeof m === 'string') {
  32226. var prime = BN._prime(m);
  32227. this.m = prime.p;
  32228. this.prime = prime;
  32229. } else {
  32230. assert(m.gtn(1), 'modulus must be greater than 1');
  32231. this.m = m;
  32232. this.prime = null;
  32233. }
  32234. }
  32235. Red.prototype._verify1 = function _verify1 (a) {
  32236. assert(a.negative === 0, 'red works only with positives');
  32237. assert(a.red, 'red works only with red numbers');
  32238. };
  32239. Red.prototype._verify2 = function _verify2 (a, b) {
  32240. assert((a.negative | b.negative) === 0, 'red works only with positives');
  32241. assert(a.red && a.red === b.red,
  32242. 'red works only with red numbers');
  32243. };
  32244. Red.prototype.imod = function imod (a) {
  32245. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  32246. return a.umod(this.m)._forceRed(this);
  32247. };
  32248. Red.prototype.neg = function neg (a) {
  32249. if (a.isZero()) {
  32250. return a.clone();
  32251. }
  32252. return this.m.sub(a)._forceRed(this);
  32253. };
  32254. Red.prototype.add = function add (a, b) {
  32255. this._verify2(a, b);
  32256. var res = a.add(b);
  32257. if (res.cmp(this.m) >= 0) {
  32258. res.isub(this.m);
  32259. }
  32260. return res._forceRed(this);
  32261. };
  32262. Red.prototype.iadd = function iadd (a, b) {
  32263. this._verify2(a, b);
  32264. var res = a.iadd(b);
  32265. if (res.cmp(this.m) >= 0) {
  32266. res.isub(this.m);
  32267. }
  32268. return res;
  32269. };
  32270. Red.prototype.sub = function sub (a, b) {
  32271. this._verify2(a, b);
  32272. var res = a.sub(b);
  32273. if (res.cmpn(0) < 0) {
  32274. res.iadd(this.m);
  32275. }
  32276. return res._forceRed(this);
  32277. };
  32278. Red.prototype.isub = function isub (a, b) {
  32279. this._verify2(a, b);
  32280. var res = a.isub(b);
  32281. if (res.cmpn(0) < 0) {
  32282. res.iadd(this.m);
  32283. }
  32284. return res;
  32285. };
  32286. Red.prototype.shl = function shl (a, num) {
  32287. this._verify1(a);
  32288. return this.imod(a.ushln(num));
  32289. };
  32290. Red.prototype.imul = function imul (a, b) {
  32291. this._verify2(a, b);
  32292. return this.imod(a.imul(b));
  32293. };
  32294. Red.prototype.mul = function mul (a, b) {
  32295. this._verify2(a, b);
  32296. return this.imod(a.mul(b));
  32297. };
  32298. Red.prototype.isqr = function isqr (a) {
  32299. return this.imul(a, a.clone());
  32300. };
  32301. Red.prototype.sqr = function sqr (a) {
  32302. return this.mul(a, a);
  32303. };
  32304. Red.prototype.sqrt = function sqrt (a) {
  32305. if (a.isZero()) return a.clone();
  32306. var mod3 = this.m.andln(3);
  32307. assert(mod3 % 2 === 1);
  32308. // Fast case
  32309. if (mod3 === 3) {
  32310. var pow = this.m.add(new BN(1)).iushrn(2);
  32311. return this.pow(a, pow);
  32312. }
  32313. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  32314. //
  32315. // Find Q and S, that Q * 2 ^ S = (P - 1)
  32316. var q = this.m.subn(1);
  32317. var s = 0;
  32318. while (!q.isZero() && q.andln(1) === 0) {
  32319. s++;
  32320. q.iushrn(1);
  32321. }
  32322. assert(!q.isZero());
  32323. var one = new BN(1).toRed(this);
  32324. var nOne = one.redNeg();
  32325. // Find quadratic non-residue
  32326. // NOTE: Max is such because of generalized Riemann hypothesis.
  32327. var lpow = this.m.subn(1).iushrn(1);
  32328. var z = this.m.bitLength();
  32329. z = new BN(2 * z * z).toRed(this);
  32330. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  32331. z.redIAdd(nOne);
  32332. }
  32333. var c = this.pow(z, q);
  32334. var r = this.pow(a, q.addn(1).iushrn(1));
  32335. var t = this.pow(a, q);
  32336. var m = s;
  32337. while (t.cmp(one) !== 0) {
  32338. var tmp = t;
  32339. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  32340. tmp = tmp.redSqr();
  32341. }
  32342. assert(i < m);
  32343. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  32344. r = r.redMul(b);
  32345. c = b.redSqr();
  32346. t = t.redMul(c);
  32347. m = i;
  32348. }
  32349. return r;
  32350. };
  32351. Red.prototype.invm = function invm (a) {
  32352. var inv = a._invmp(this.m);
  32353. if (inv.negative !== 0) {
  32354. inv.negative = 0;
  32355. return this.imod(inv).redNeg();
  32356. } else {
  32357. return this.imod(inv);
  32358. }
  32359. };
  32360. Red.prototype.pow = function pow (a, num) {
  32361. if (num.isZero()) return new BN(1).toRed(this);
  32362. if (num.cmpn(1) === 0) return a.clone();
  32363. var windowSize = 4;
  32364. var wnd = new Array(1 << windowSize);
  32365. wnd[0] = new BN(1).toRed(this);
  32366. wnd[1] = a;
  32367. for (var i = 2; i < wnd.length; i++) {
  32368. wnd[i] = this.mul(wnd[i - 1], a);
  32369. }
  32370. var res = wnd[0];
  32371. var current = 0;
  32372. var currentLen = 0;
  32373. var start = num.bitLength() % 26;
  32374. if (start === 0) {
  32375. start = 26;
  32376. }
  32377. for (i = num.length - 1; i >= 0; i--) {
  32378. var word = num.words[i];
  32379. for (var j = start - 1; j >= 0; j--) {
  32380. var bit = (word >> j) & 1;
  32381. if (res !== wnd[0]) {
  32382. res = this.sqr(res);
  32383. }
  32384. if (bit === 0 && current === 0) {
  32385. currentLen = 0;
  32386. continue;
  32387. }
  32388. current <<= 1;
  32389. current |= bit;
  32390. currentLen++;
  32391. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  32392. res = this.mul(res, wnd[current]);
  32393. currentLen = 0;
  32394. current = 0;
  32395. }
  32396. start = 26;
  32397. }
  32398. return res;
  32399. };
  32400. Red.prototype.convertTo = function convertTo (num) {
  32401. var r = num.umod(this.m);
  32402. return r === num ? r.clone() : r;
  32403. };
  32404. Red.prototype.convertFrom = function convertFrom (num) {
  32405. var res = num.clone();
  32406. res.red = null;
  32407. return res;
  32408. };
  32409. //
  32410. // Montgomery method engine
  32411. //
  32412. BN.mont = function mont (num) {
  32413. return new Mont(num);
  32414. };
  32415. function Mont (m) {
  32416. Red.call(this, m);
  32417. this.shift = this.m.bitLength();
  32418. if (this.shift % 26 !== 0) {
  32419. this.shift += 26 - (this.shift % 26);
  32420. }
  32421. this.r = new BN(1).iushln(this.shift);
  32422. this.r2 = this.imod(this.r.sqr());
  32423. this.rinv = this.r._invmp(this.m);
  32424. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  32425. this.minv = this.minv.umod(this.r);
  32426. this.minv = this.r.sub(this.minv);
  32427. }
  32428. inherits(Mont, Red);
  32429. Mont.prototype.convertTo = function convertTo (num) {
  32430. return this.imod(num.ushln(this.shift));
  32431. };
  32432. Mont.prototype.convertFrom = function convertFrom (num) {
  32433. var r = this.imod(num.mul(this.rinv));
  32434. r.red = null;
  32435. return r;
  32436. };
  32437. Mont.prototype.imul = function imul (a, b) {
  32438. if (a.isZero() || b.isZero()) {
  32439. a.words[0] = 0;
  32440. a.length = 1;
  32441. return a;
  32442. }
  32443. var t = a.imul(b);
  32444. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  32445. var u = t.isub(c).iushrn(this.shift);
  32446. var res = u;
  32447. if (u.cmp(this.m) >= 0) {
  32448. res = u.isub(this.m);
  32449. } else if (u.cmpn(0) < 0) {
  32450. res = u.iadd(this.m);
  32451. }
  32452. return res._forceRed(this);
  32453. };
  32454. Mont.prototype.mul = function mul (a, b) {
  32455. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  32456. var t = a.mul(b);
  32457. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  32458. var u = t.isub(c).iushrn(this.shift);
  32459. var res = u;
  32460. if (u.cmp(this.m) >= 0) {
  32461. res = u.isub(this.m);
  32462. } else if (u.cmpn(0) < 0) {
  32463. res = u.iadd(this.m);
  32464. }
  32465. return res._forceRed(this);
  32466. };
  32467. Mont.prototype.invm = function invm (a) {
  32468. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  32469. var res = this.imod(a._invmp(this.m).mul(this.r2));
  32470. return res._forceRed(this);
  32471. };
  32472. })( false || module, this);
  32473. /***/ }),
  32474. /***/ "./node_modules/dot-case/dist.es2015/index.js":
  32475. /*!****************************************************!*\
  32476. !*** ./node_modules/dot-case/dist.es2015/index.js ***!
  32477. \****************************************************/
  32478. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  32479. "use strict";
  32480. __webpack_require__.r(__webpack_exports__);
  32481. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  32482. /* harmony export */ dotCase: () => (/* binding */ dotCase)
  32483. /* harmony export */ });
  32484. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  32485. /* harmony import */ var no_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! no-case */ "./node_modules/no-case/dist.es2015/index.js");
  32486. function dotCase(input, options) {
  32487. if (options === void 0) { options = {}; }
  32488. return (0,no_case__WEBPACK_IMPORTED_MODULE_0__.noCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ delimiter: "." }, options));
  32489. }
  32490. //# sourceMappingURL=index.js.map
  32491. /***/ }),
  32492. /***/ "./node_modules/elliptic/lib/elliptic.js":
  32493. /*!***********************************************!*\
  32494. !*** ./node_modules/elliptic/lib/elliptic.js ***!
  32495. \***********************************************/
  32496. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  32497. "use strict";
  32498. var elliptic = exports;
  32499. elliptic.version = (__webpack_require__(/*! ../package.json */ "./node_modules/elliptic/package.json").version);
  32500. elliptic.utils = __webpack_require__(/*! ./elliptic/utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  32501. elliptic.rand = __webpack_require__(/*! brorand */ "./node_modules/brorand/index.js");
  32502. elliptic.curve = __webpack_require__(/*! ./elliptic/curve */ "./node_modules/elliptic/lib/elliptic/curve/index.js");
  32503. elliptic.curves = __webpack_require__(/*! ./elliptic/curves */ "./node_modules/elliptic/lib/elliptic/curves.js");
  32504. // Protocols
  32505. elliptic.ec = __webpack_require__(/*! ./elliptic/ec */ "./node_modules/elliptic/lib/elliptic/ec/index.js");
  32506. elliptic.eddsa = __webpack_require__(/*! ./elliptic/eddsa */ "./node_modules/elliptic/lib/elliptic/eddsa/index.js");
  32507. /***/ }),
  32508. /***/ "./node_modules/elliptic/lib/elliptic/curve/base.js":
  32509. /*!**********************************************************!*\
  32510. !*** ./node_modules/elliptic/lib/elliptic/curve/base.js ***!
  32511. \**********************************************************/
  32512. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32513. "use strict";
  32514. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  32515. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  32516. var getNAF = utils.getNAF;
  32517. var getJSF = utils.getJSF;
  32518. var assert = utils.assert;
  32519. function BaseCurve(type, conf) {
  32520. this.type = type;
  32521. this.p = new BN(conf.p, 16);
  32522. // Use Montgomery, when there is no fast reduction for the prime
  32523. this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
  32524. // Useful for many curves
  32525. this.zero = new BN(0).toRed(this.red);
  32526. this.one = new BN(1).toRed(this.red);
  32527. this.two = new BN(2).toRed(this.red);
  32528. // Curve configuration, optional
  32529. this.n = conf.n && new BN(conf.n, 16);
  32530. this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
  32531. // Temporary arrays
  32532. this._wnafT1 = new Array(4);
  32533. this._wnafT2 = new Array(4);
  32534. this._wnafT3 = new Array(4);
  32535. this._wnafT4 = new Array(4);
  32536. this._bitLength = this.n ? this.n.bitLength() : 0;
  32537. // Generalized Greg Maxwell's trick
  32538. var adjustCount = this.n && this.p.div(this.n);
  32539. if (!adjustCount || adjustCount.cmpn(100) > 0) {
  32540. this.redN = null;
  32541. } else {
  32542. this._maxwellTrick = true;
  32543. this.redN = this.n.toRed(this.red);
  32544. }
  32545. }
  32546. module.exports = BaseCurve;
  32547. BaseCurve.prototype.point = function point() {
  32548. throw new Error('Not implemented');
  32549. };
  32550. BaseCurve.prototype.validate = function validate() {
  32551. throw new Error('Not implemented');
  32552. };
  32553. BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
  32554. assert(p.precomputed);
  32555. var doubles = p._getDoubles();
  32556. var naf = getNAF(k, 1, this._bitLength);
  32557. var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
  32558. I /= 3;
  32559. // Translate into more windowed form
  32560. var repr = [];
  32561. var j;
  32562. var nafW;
  32563. for (j = 0; j < naf.length; j += doubles.step) {
  32564. nafW = 0;
  32565. for (var l = j + doubles.step - 1; l >= j; l--)
  32566. nafW = (nafW << 1) + naf[l];
  32567. repr.push(nafW);
  32568. }
  32569. var a = this.jpoint(null, null, null);
  32570. var b = this.jpoint(null, null, null);
  32571. for (var i = I; i > 0; i--) {
  32572. for (j = 0; j < repr.length; j++) {
  32573. nafW = repr[j];
  32574. if (nafW === i)
  32575. b = b.mixedAdd(doubles.points[j]);
  32576. else if (nafW === -i)
  32577. b = b.mixedAdd(doubles.points[j].neg());
  32578. }
  32579. a = a.add(b);
  32580. }
  32581. return a.toP();
  32582. };
  32583. BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
  32584. var w = 4;
  32585. // Precompute window
  32586. var nafPoints = p._getNAFPoints(w);
  32587. w = nafPoints.wnd;
  32588. var wnd = nafPoints.points;
  32589. // Get NAF form
  32590. var naf = getNAF(k, w, this._bitLength);
  32591. // Add `this`*(N+1) for every w-NAF index
  32592. var acc = this.jpoint(null, null, null);
  32593. for (var i = naf.length - 1; i >= 0; i--) {
  32594. // Count zeroes
  32595. for (var l = 0; i >= 0 && naf[i] === 0; i--)
  32596. l++;
  32597. if (i >= 0)
  32598. l++;
  32599. acc = acc.dblp(l);
  32600. if (i < 0)
  32601. break;
  32602. var z = naf[i];
  32603. assert(z !== 0);
  32604. if (p.type === 'affine') {
  32605. // J +- P
  32606. if (z > 0)
  32607. acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
  32608. else
  32609. acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
  32610. } else {
  32611. // J +- J
  32612. if (z > 0)
  32613. acc = acc.add(wnd[(z - 1) >> 1]);
  32614. else
  32615. acc = acc.add(wnd[(-z - 1) >> 1].neg());
  32616. }
  32617. }
  32618. return p.type === 'affine' ? acc.toP() : acc;
  32619. };
  32620. BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
  32621. points,
  32622. coeffs,
  32623. len,
  32624. jacobianResult) {
  32625. var wndWidth = this._wnafT1;
  32626. var wnd = this._wnafT2;
  32627. var naf = this._wnafT3;
  32628. // Fill all arrays
  32629. var max = 0;
  32630. var i;
  32631. var j;
  32632. var p;
  32633. for (i = 0; i < len; i++) {
  32634. p = points[i];
  32635. var nafPoints = p._getNAFPoints(defW);
  32636. wndWidth[i] = nafPoints.wnd;
  32637. wnd[i] = nafPoints.points;
  32638. }
  32639. // Comb small window NAFs
  32640. for (i = len - 1; i >= 1; i -= 2) {
  32641. var a = i - 1;
  32642. var b = i;
  32643. if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
  32644. naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
  32645. naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
  32646. max = Math.max(naf[a].length, max);
  32647. max = Math.max(naf[b].length, max);
  32648. continue;
  32649. }
  32650. var comb = [
  32651. points[a], /* 1 */
  32652. null, /* 3 */
  32653. null, /* 5 */
  32654. points[b], /* 7 */
  32655. ];
  32656. // Try to avoid Projective points, if possible
  32657. if (points[a].y.cmp(points[b].y) === 0) {
  32658. comb[1] = points[a].add(points[b]);
  32659. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  32660. } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
  32661. comb[1] = points[a].toJ().mixedAdd(points[b]);
  32662. comb[2] = points[a].add(points[b].neg());
  32663. } else {
  32664. comb[1] = points[a].toJ().mixedAdd(points[b]);
  32665. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  32666. }
  32667. var index = [
  32668. -3, /* -1 -1 */
  32669. -1, /* -1 0 */
  32670. -5, /* -1 1 */
  32671. -7, /* 0 -1 */
  32672. 0, /* 0 0 */
  32673. 7, /* 0 1 */
  32674. 5, /* 1 -1 */
  32675. 1, /* 1 0 */
  32676. 3, /* 1 1 */
  32677. ];
  32678. var jsf = getJSF(coeffs[a], coeffs[b]);
  32679. max = Math.max(jsf[0].length, max);
  32680. naf[a] = new Array(max);
  32681. naf[b] = new Array(max);
  32682. for (j = 0; j < max; j++) {
  32683. var ja = jsf[0][j] | 0;
  32684. var jb = jsf[1][j] | 0;
  32685. naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
  32686. naf[b][j] = 0;
  32687. wnd[a] = comb;
  32688. }
  32689. }
  32690. var acc = this.jpoint(null, null, null);
  32691. var tmp = this._wnafT4;
  32692. for (i = max; i >= 0; i--) {
  32693. var k = 0;
  32694. while (i >= 0) {
  32695. var zero = true;
  32696. for (j = 0; j < len; j++) {
  32697. tmp[j] = naf[j][i] | 0;
  32698. if (tmp[j] !== 0)
  32699. zero = false;
  32700. }
  32701. if (!zero)
  32702. break;
  32703. k++;
  32704. i--;
  32705. }
  32706. if (i >= 0)
  32707. k++;
  32708. acc = acc.dblp(k);
  32709. if (i < 0)
  32710. break;
  32711. for (j = 0; j < len; j++) {
  32712. var z = tmp[j];
  32713. p;
  32714. if (z === 0)
  32715. continue;
  32716. else if (z > 0)
  32717. p = wnd[j][(z - 1) >> 1];
  32718. else if (z < 0)
  32719. p = wnd[j][(-z - 1) >> 1].neg();
  32720. if (p.type === 'affine')
  32721. acc = acc.mixedAdd(p);
  32722. else
  32723. acc = acc.add(p);
  32724. }
  32725. }
  32726. // Zeroify references
  32727. for (i = 0; i < len; i++)
  32728. wnd[i] = null;
  32729. if (jacobianResult)
  32730. return acc;
  32731. else
  32732. return acc.toP();
  32733. };
  32734. function BasePoint(curve, type) {
  32735. this.curve = curve;
  32736. this.type = type;
  32737. this.precomputed = null;
  32738. }
  32739. BaseCurve.BasePoint = BasePoint;
  32740. BasePoint.prototype.eq = function eq(/*other*/) {
  32741. throw new Error('Not implemented');
  32742. };
  32743. BasePoint.prototype.validate = function validate() {
  32744. return this.curve.validate(this);
  32745. };
  32746. BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  32747. bytes = utils.toArray(bytes, enc);
  32748. var len = this.p.byteLength();
  32749. // uncompressed, hybrid-odd, hybrid-even
  32750. if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
  32751. bytes.length - 1 === 2 * len) {
  32752. if (bytes[0] === 0x06)
  32753. assert(bytes[bytes.length - 1] % 2 === 0);
  32754. else if (bytes[0] === 0x07)
  32755. assert(bytes[bytes.length - 1] % 2 === 1);
  32756. var res = this.point(bytes.slice(1, 1 + len),
  32757. bytes.slice(1 + len, 1 + 2 * len));
  32758. return res;
  32759. } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
  32760. bytes.length - 1 === len) {
  32761. return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
  32762. }
  32763. throw new Error('Unknown point format');
  32764. };
  32765. BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
  32766. return this.encode(enc, true);
  32767. };
  32768. BasePoint.prototype._encode = function _encode(compact) {
  32769. var len = this.curve.p.byteLength();
  32770. var x = this.getX().toArray('be', len);
  32771. if (compact)
  32772. return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
  32773. return [ 0x04 ].concat(x, this.getY().toArray('be', len));
  32774. };
  32775. BasePoint.prototype.encode = function encode(enc, compact) {
  32776. return utils.encode(this._encode(compact), enc);
  32777. };
  32778. BasePoint.prototype.precompute = function precompute(power) {
  32779. if (this.precomputed)
  32780. return this;
  32781. var precomputed = {
  32782. doubles: null,
  32783. naf: null,
  32784. beta: null,
  32785. };
  32786. precomputed.naf = this._getNAFPoints(8);
  32787. precomputed.doubles = this._getDoubles(4, power);
  32788. precomputed.beta = this._getBeta();
  32789. this.precomputed = precomputed;
  32790. return this;
  32791. };
  32792. BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
  32793. if (!this.precomputed)
  32794. return false;
  32795. var doubles = this.precomputed.doubles;
  32796. if (!doubles)
  32797. return false;
  32798. return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
  32799. };
  32800. BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
  32801. if (this.precomputed && this.precomputed.doubles)
  32802. return this.precomputed.doubles;
  32803. var doubles = [ this ];
  32804. var acc = this;
  32805. for (var i = 0; i < power; i += step) {
  32806. for (var j = 0; j < step; j++)
  32807. acc = acc.dbl();
  32808. doubles.push(acc);
  32809. }
  32810. return {
  32811. step: step,
  32812. points: doubles,
  32813. };
  32814. };
  32815. BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
  32816. if (this.precomputed && this.precomputed.naf)
  32817. return this.precomputed.naf;
  32818. var res = [ this ];
  32819. var max = (1 << wnd) - 1;
  32820. var dbl = max === 1 ? null : this.dbl();
  32821. for (var i = 1; i < max; i++)
  32822. res[i] = res[i - 1].add(dbl);
  32823. return {
  32824. wnd: wnd,
  32825. points: res,
  32826. };
  32827. };
  32828. BasePoint.prototype._getBeta = function _getBeta() {
  32829. return null;
  32830. };
  32831. BasePoint.prototype.dblp = function dblp(k) {
  32832. var r = this;
  32833. for (var i = 0; i < k; i++)
  32834. r = r.dbl();
  32835. return r;
  32836. };
  32837. /***/ }),
  32838. /***/ "./node_modules/elliptic/lib/elliptic/curve/edwards.js":
  32839. /*!*************************************************************!*\
  32840. !*** ./node_modules/elliptic/lib/elliptic/curve/edwards.js ***!
  32841. \*************************************************************/
  32842. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32843. "use strict";
  32844. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  32845. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  32846. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  32847. var Base = __webpack_require__(/*! ./base */ "./node_modules/elliptic/lib/elliptic/curve/base.js");
  32848. var assert = utils.assert;
  32849. function EdwardsCurve(conf) {
  32850. // NOTE: Important as we are creating point in Base.call()
  32851. this.twisted = (conf.a | 0) !== 1;
  32852. this.mOneA = this.twisted && (conf.a | 0) === -1;
  32853. this.extended = this.mOneA;
  32854. Base.call(this, 'edwards', conf);
  32855. this.a = new BN(conf.a, 16).umod(this.red.m);
  32856. this.a = this.a.toRed(this.red);
  32857. this.c = new BN(conf.c, 16).toRed(this.red);
  32858. this.c2 = this.c.redSqr();
  32859. this.d = new BN(conf.d, 16).toRed(this.red);
  32860. this.dd = this.d.redAdd(this.d);
  32861. assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
  32862. this.oneC = (conf.c | 0) === 1;
  32863. }
  32864. inherits(EdwardsCurve, Base);
  32865. module.exports = EdwardsCurve;
  32866. EdwardsCurve.prototype._mulA = function _mulA(num) {
  32867. if (this.mOneA)
  32868. return num.redNeg();
  32869. else
  32870. return this.a.redMul(num);
  32871. };
  32872. EdwardsCurve.prototype._mulC = function _mulC(num) {
  32873. if (this.oneC)
  32874. return num;
  32875. else
  32876. return this.c.redMul(num);
  32877. };
  32878. // Just for compatibility with Short curve
  32879. EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
  32880. return this.point(x, y, z, t);
  32881. };
  32882. EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
  32883. x = new BN(x, 16);
  32884. if (!x.red)
  32885. x = x.toRed(this.red);
  32886. var x2 = x.redSqr();
  32887. var rhs = this.c2.redSub(this.a.redMul(x2));
  32888. var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
  32889. var y2 = rhs.redMul(lhs.redInvm());
  32890. var y = y2.redSqrt();
  32891. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  32892. throw new Error('invalid point');
  32893. var isOdd = y.fromRed().isOdd();
  32894. if (odd && !isOdd || !odd && isOdd)
  32895. y = y.redNeg();
  32896. return this.point(x, y);
  32897. };
  32898. EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
  32899. y = new BN(y, 16);
  32900. if (!y.red)
  32901. y = y.toRed(this.red);
  32902. // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
  32903. var y2 = y.redSqr();
  32904. var lhs = y2.redSub(this.c2);
  32905. var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
  32906. var x2 = lhs.redMul(rhs.redInvm());
  32907. if (x2.cmp(this.zero) === 0) {
  32908. if (odd)
  32909. throw new Error('invalid point');
  32910. else
  32911. return this.point(this.zero, y);
  32912. }
  32913. var x = x2.redSqrt();
  32914. if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
  32915. throw new Error('invalid point');
  32916. if (x.fromRed().isOdd() !== odd)
  32917. x = x.redNeg();
  32918. return this.point(x, y);
  32919. };
  32920. EdwardsCurve.prototype.validate = function validate(point) {
  32921. if (point.isInfinity())
  32922. return true;
  32923. // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
  32924. point.normalize();
  32925. var x2 = point.x.redSqr();
  32926. var y2 = point.y.redSqr();
  32927. var lhs = x2.redMul(this.a).redAdd(y2);
  32928. var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
  32929. return lhs.cmp(rhs) === 0;
  32930. };
  32931. function Point(curve, x, y, z, t) {
  32932. Base.BasePoint.call(this, curve, 'projective');
  32933. if (x === null && y === null && z === null) {
  32934. this.x = this.curve.zero;
  32935. this.y = this.curve.one;
  32936. this.z = this.curve.one;
  32937. this.t = this.curve.zero;
  32938. this.zOne = true;
  32939. } else {
  32940. this.x = new BN(x, 16);
  32941. this.y = new BN(y, 16);
  32942. this.z = z ? new BN(z, 16) : this.curve.one;
  32943. this.t = t && new BN(t, 16);
  32944. if (!this.x.red)
  32945. this.x = this.x.toRed(this.curve.red);
  32946. if (!this.y.red)
  32947. this.y = this.y.toRed(this.curve.red);
  32948. if (!this.z.red)
  32949. this.z = this.z.toRed(this.curve.red);
  32950. if (this.t && !this.t.red)
  32951. this.t = this.t.toRed(this.curve.red);
  32952. this.zOne = this.z === this.curve.one;
  32953. // Use extended coordinates
  32954. if (this.curve.extended && !this.t) {
  32955. this.t = this.x.redMul(this.y);
  32956. if (!this.zOne)
  32957. this.t = this.t.redMul(this.z.redInvm());
  32958. }
  32959. }
  32960. }
  32961. inherits(Point, Base.BasePoint);
  32962. EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  32963. return Point.fromJSON(this, obj);
  32964. };
  32965. EdwardsCurve.prototype.point = function point(x, y, z, t) {
  32966. return new Point(this, x, y, z, t);
  32967. };
  32968. Point.fromJSON = function fromJSON(curve, obj) {
  32969. return new Point(curve, obj[0], obj[1], obj[2]);
  32970. };
  32971. Point.prototype.inspect = function inspect() {
  32972. if (this.isInfinity())
  32973. return '<EC Point Infinity>';
  32974. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  32975. ' y: ' + this.y.fromRed().toString(16, 2) +
  32976. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  32977. };
  32978. Point.prototype.isInfinity = function isInfinity() {
  32979. // XXX This code assumes that zero is always zero in red
  32980. return this.x.cmpn(0) === 0 &&
  32981. (this.y.cmp(this.z) === 0 ||
  32982. (this.zOne && this.y.cmp(this.curve.c) === 0));
  32983. };
  32984. Point.prototype._extDbl = function _extDbl() {
  32985. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  32986. // #doubling-dbl-2008-hwcd
  32987. // 4M + 4S
  32988. // A = X1^2
  32989. var a = this.x.redSqr();
  32990. // B = Y1^2
  32991. var b = this.y.redSqr();
  32992. // C = 2 * Z1^2
  32993. var c = this.z.redSqr();
  32994. c = c.redIAdd(c);
  32995. // D = a * A
  32996. var d = this.curve._mulA(a);
  32997. // E = (X1 + Y1)^2 - A - B
  32998. var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
  32999. // G = D + B
  33000. var g = d.redAdd(b);
  33001. // F = G - C
  33002. var f = g.redSub(c);
  33003. // H = D - B
  33004. var h = d.redSub(b);
  33005. // X3 = E * F
  33006. var nx = e.redMul(f);
  33007. // Y3 = G * H
  33008. var ny = g.redMul(h);
  33009. // T3 = E * H
  33010. var nt = e.redMul(h);
  33011. // Z3 = F * G
  33012. var nz = f.redMul(g);
  33013. return this.curve.point(nx, ny, nz, nt);
  33014. };
  33015. Point.prototype._projDbl = function _projDbl() {
  33016. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  33017. // #doubling-dbl-2008-bbjlp
  33018. // #doubling-dbl-2007-bl
  33019. // and others
  33020. // Generally 3M + 4S or 2M + 4S
  33021. // B = (X1 + Y1)^2
  33022. var b = this.x.redAdd(this.y).redSqr();
  33023. // C = X1^2
  33024. var c = this.x.redSqr();
  33025. // D = Y1^2
  33026. var d = this.y.redSqr();
  33027. var nx;
  33028. var ny;
  33029. var nz;
  33030. var e;
  33031. var h;
  33032. var j;
  33033. if (this.curve.twisted) {
  33034. // E = a * C
  33035. e = this.curve._mulA(c);
  33036. // F = E + D
  33037. var f = e.redAdd(d);
  33038. if (this.zOne) {
  33039. // X3 = (B - C - D) * (F - 2)
  33040. nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
  33041. // Y3 = F * (E - D)
  33042. ny = f.redMul(e.redSub(d));
  33043. // Z3 = F^2 - 2 * F
  33044. nz = f.redSqr().redSub(f).redSub(f);
  33045. } else {
  33046. // H = Z1^2
  33047. h = this.z.redSqr();
  33048. // J = F - 2 * H
  33049. j = f.redSub(h).redISub(h);
  33050. // X3 = (B-C-D)*J
  33051. nx = b.redSub(c).redISub(d).redMul(j);
  33052. // Y3 = F * (E - D)
  33053. ny = f.redMul(e.redSub(d));
  33054. // Z3 = F * J
  33055. nz = f.redMul(j);
  33056. }
  33057. } else {
  33058. // E = C + D
  33059. e = c.redAdd(d);
  33060. // H = (c * Z1)^2
  33061. h = this.curve._mulC(this.z).redSqr();
  33062. // J = E - 2 * H
  33063. j = e.redSub(h).redSub(h);
  33064. // X3 = c * (B - E) * J
  33065. nx = this.curve._mulC(b.redISub(e)).redMul(j);
  33066. // Y3 = c * E * (C - D)
  33067. ny = this.curve._mulC(e).redMul(c.redISub(d));
  33068. // Z3 = E * J
  33069. nz = e.redMul(j);
  33070. }
  33071. return this.curve.point(nx, ny, nz);
  33072. };
  33073. Point.prototype.dbl = function dbl() {
  33074. if (this.isInfinity())
  33075. return this;
  33076. // Double in extended coordinates
  33077. if (this.curve.extended)
  33078. return this._extDbl();
  33079. else
  33080. return this._projDbl();
  33081. };
  33082. Point.prototype._extAdd = function _extAdd(p) {
  33083. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  33084. // #addition-add-2008-hwcd-3
  33085. // 8M
  33086. // A = (Y1 - X1) * (Y2 - X2)
  33087. var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
  33088. // B = (Y1 + X1) * (Y2 + X2)
  33089. var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
  33090. // C = T1 * k * T2
  33091. var c = this.t.redMul(this.curve.dd).redMul(p.t);
  33092. // D = Z1 * 2 * Z2
  33093. var d = this.z.redMul(p.z.redAdd(p.z));
  33094. // E = B - A
  33095. var e = b.redSub(a);
  33096. // F = D - C
  33097. var f = d.redSub(c);
  33098. // G = D + C
  33099. var g = d.redAdd(c);
  33100. // H = B + A
  33101. var h = b.redAdd(a);
  33102. // X3 = E * F
  33103. var nx = e.redMul(f);
  33104. // Y3 = G * H
  33105. var ny = g.redMul(h);
  33106. // T3 = E * H
  33107. var nt = e.redMul(h);
  33108. // Z3 = F * G
  33109. var nz = f.redMul(g);
  33110. return this.curve.point(nx, ny, nz, nt);
  33111. };
  33112. Point.prototype._projAdd = function _projAdd(p) {
  33113. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  33114. // #addition-add-2008-bbjlp
  33115. // #addition-add-2007-bl
  33116. // 10M + 1S
  33117. // A = Z1 * Z2
  33118. var a = this.z.redMul(p.z);
  33119. // B = A^2
  33120. var b = a.redSqr();
  33121. // C = X1 * X2
  33122. var c = this.x.redMul(p.x);
  33123. // D = Y1 * Y2
  33124. var d = this.y.redMul(p.y);
  33125. // E = d * C * D
  33126. var e = this.curve.d.redMul(c).redMul(d);
  33127. // F = B - E
  33128. var f = b.redSub(e);
  33129. // G = B + E
  33130. var g = b.redAdd(e);
  33131. // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
  33132. var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
  33133. var nx = a.redMul(f).redMul(tmp);
  33134. var ny;
  33135. var nz;
  33136. if (this.curve.twisted) {
  33137. // Y3 = A * G * (D - a * C)
  33138. ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
  33139. // Z3 = F * G
  33140. nz = f.redMul(g);
  33141. } else {
  33142. // Y3 = A * G * (D - C)
  33143. ny = a.redMul(g).redMul(d.redSub(c));
  33144. // Z3 = c * F * G
  33145. nz = this.curve._mulC(f).redMul(g);
  33146. }
  33147. return this.curve.point(nx, ny, nz);
  33148. };
  33149. Point.prototype.add = function add(p) {
  33150. if (this.isInfinity())
  33151. return p;
  33152. if (p.isInfinity())
  33153. return this;
  33154. if (this.curve.extended)
  33155. return this._extAdd(p);
  33156. else
  33157. return this._projAdd(p);
  33158. };
  33159. Point.prototype.mul = function mul(k) {
  33160. if (this._hasDoubles(k))
  33161. return this.curve._fixedNafMul(this, k);
  33162. else
  33163. return this.curve._wnafMul(this, k);
  33164. };
  33165. Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
  33166. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
  33167. };
  33168. Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
  33169. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
  33170. };
  33171. Point.prototype.normalize = function normalize() {
  33172. if (this.zOne)
  33173. return this;
  33174. // Normalize coordinates
  33175. var zi = this.z.redInvm();
  33176. this.x = this.x.redMul(zi);
  33177. this.y = this.y.redMul(zi);
  33178. if (this.t)
  33179. this.t = this.t.redMul(zi);
  33180. this.z = this.curve.one;
  33181. this.zOne = true;
  33182. return this;
  33183. };
  33184. Point.prototype.neg = function neg() {
  33185. return this.curve.point(this.x.redNeg(),
  33186. this.y,
  33187. this.z,
  33188. this.t && this.t.redNeg());
  33189. };
  33190. Point.prototype.getX = function getX() {
  33191. this.normalize();
  33192. return this.x.fromRed();
  33193. };
  33194. Point.prototype.getY = function getY() {
  33195. this.normalize();
  33196. return this.y.fromRed();
  33197. };
  33198. Point.prototype.eq = function eq(other) {
  33199. return this === other ||
  33200. this.getX().cmp(other.getX()) === 0 &&
  33201. this.getY().cmp(other.getY()) === 0;
  33202. };
  33203. Point.prototype.eqXToP = function eqXToP(x) {
  33204. var rx = x.toRed(this.curve.red).redMul(this.z);
  33205. if (this.x.cmp(rx) === 0)
  33206. return true;
  33207. var xc = x.clone();
  33208. var t = this.curve.redN.redMul(this.z);
  33209. for (;;) {
  33210. xc.iadd(this.curve.n);
  33211. if (xc.cmp(this.curve.p) >= 0)
  33212. return false;
  33213. rx.redIAdd(t);
  33214. if (this.x.cmp(rx) === 0)
  33215. return true;
  33216. }
  33217. };
  33218. // Compatibility with BaseCurve
  33219. Point.prototype.toP = Point.prototype.normalize;
  33220. Point.prototype.mixedAdd = Point.prototype.add;
  33221. /***/ }),
  33222. /***/ "./node_modules/elliptic/lib/elliptic/curve/index.js":
  33223. /*!***********************************************************!*\
  33224. !*** ./node_modules/elliptic/lib/elliptic/curve/index.js ***!
  33225. \***********************************************************/
  33226. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  33227. "use strict";
  33228. var curve = exports;
  33229. curve.base = __webpack_require__(/*! ./base */ "./node_modules/elliptic/lib/elliptic/curve/base.js");
  33230. curve.short = __webpack_require__(/*! ./short */ "./node_modules/elliptic/lib/elliptic/curve/short.js");
  33231. curve.mont = __webpack_require__(/*! ./mont */ "./node_modules/elliptic/lib/elliptic/curve/mont.js");
  33232. curve.edwards = __webpack_require__(/*! ./edwards */ "./node_modules/elliptic/lib/elliptic/curve/edwards.js");
  33233. /***/ }),
  33234. /***/ "./node_modules/elliptic/lib/elliptic/curve/mont.js":
  33235. /*!**********************************************************!*\
  33236. !*** ./node_modules/elliptic/lib/elliptic/curve/mont.js ***!
  33237. \**********************************************************/
  33238. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  33239. "use strict";
  33240. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  33241. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  33242. var Base = __webpack_require__(/*! ./base */ "./node_modules/elliptic/lib/elliptic/curve/base.js");
  33243. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  33244. function MontCurve(conf) {
  33245. Base.call(this, 'mont', conf);
  33246. this.a = new BN(conf.a, 16).toRed(this.red);
  33247. this.b = new BN(conf.b, 16).toRed(this.red);
  33248. this.i4 = new BN(4).toRed(this.red).redInvm();
  33249. this.two = new BN(2).toRed(this.red);
  33250. this.a24 = this.i4.redMul(this.a.redAdd(this.two));
  33251. }
  33252. inherits(MontCurve, Base);
  33253. module.exports = MontCurve;
  33254. MontCurve.prototype.validate = function validate(point) {
  33255. var x = point.normalize().x;
  33256. var x2 = x.redSqr();
  33257. var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
  33258. var y = rhs.redSqrt();
  33259. return y.redSqr().cmp(rhs) === 0;
  33260. };
  33261. function Point(curve, x, z) {
  33262. Base.BasePoint.call(this, curve, 'projective');
  33263. if (x === null && z === null) {
  33264. this.x = this.curve.one;
  33265. this.z = this.curve.zero;
  33266. } else {
  33267. this.x = new BN(x, 16);
  33268. this.z = new BN(z, 16);
  33269. if (!this.x.red)
  33270. this.x = this.x.toRed(this.curve.red);
  33271. if (!this.z.red)
  33272. this.z = this.z.toRed(this.curve.red);
  33273. }
  33274. }
  33275. inherits(Point, Base.BasePoint);
  33276. MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  33277. return this.point(utils.toArray(bytes, enc), 1);
  33278. };
  33279. MontCurve.prototype.point = function point(x, z) {
  33280. return new Point(this, x, z);
  33281. };
  33282. MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  33283. return Point.fromJSON(this, obj);
  33284. };
  33285. Point.prototype.precompute = function precompute() {
  33286. // No-op
  33287. };
  33288. Point.prototype._encode = function _encode() {
  33289. return this.getX().toArray('be', this.curve.p.byteLength());
  33290. };
  33291. Point.fromJSON = function fromJSON(curve, obj) {
  33292. return new Point(curve, obj[0], obj[1] || curve.one);
  33293. };
  33294. Point.prototype.inspect = function inspect() {
  33295. if (this.isInfinity())
  33296. return '<EC Point Infinity>';
  33297. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  33298. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  33299. };
  33300. Point.prototype.isInfinity = function isInfinity() {
  33301. // XXX This code assumes that zero is always zero in red
  33302. return this.z.cmpn(0) === 0;
  33303. };
  33304. Point.prototype.dbl = function dbl() {
  33305. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
  33306. // 2M + 2S + 4A
  33307. // A = X1 + Z1
  33308. var a = this.x.redAdd(this.z);
  33309. // AA = A^2
  33310. var aa = a.redSqr();
  33311. // B = X1 - Z1
  33312. var b = this.x.redSub(this.z);
  33313. // BB = B^2
  33314. var bb = b.redSqr();
  33315. // C = AA - BB
  33316. var c = aa.redSub(bb);
  33317. // X3 = AA * BB
  33318. var nx = aa.redMul(bb);
  33319. // Z3 = C * (BB + A24 * C)
  33320. var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
  33321. return this.curve.point(nx, nz);
  33322. };
  33323. Point.prototype.add = function add() {
  33324. throw new Error('Not supported on Montgomery curve');
  33325. };
  33326. Point.prototype.diffAdd = function diffAdd(p, diff) {
  33327. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
  33328. // 4M + 2S + 6A
  33329. // A = X2 + Z2
  33330. var a = this.x.redAdd(this.z);
  33331. // B = X2 - Z2
  33332. var b = this.x.redSub(this.z);
  33333. // C = X3 + Z3
  33334. var c = p.x.redAdd(p.z);
  33335. // D = X3 - Z3
  33336. var d = p.x.redSub(p.z);
  33337. // DA = D * A
  33338. var da = d.redMul(a);
  33339. // CB = C * B
  33340. var cb = c.redMul(b);
  33341. // X5 = Z1 * (DA + CB)^2
  33342. var nx = diff.z.redMul(da.redAdd(cb).redSqr());
  33343. // Z5 = X1 * (DA - CB)^2
  33344. var nz = diff.x.redMul(da.redISub(cb).redSqr());
  33345. return this.curve.point(nx, nz);
  33346. };
  33347. Point.prototype.mul = function mul(k) {
  33348. var t = k.clone();
  33349. var a = this; // (N / 2) * Q + Q
  33350. var b = this.curve.point(null, null); // (N / 2) * Q
  33351. var c = this; // Q
  33352. for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
  33353. bits.push(t.andln(1));
  33354. for (var i = bits.length - 1; i >= 0; i--) {
  33355. if (bits[i] === 0) {
  33356. // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
  33357. a = a.diffAdd(b, c);
  33358. // N * Q = 2 * ((N / 2) * Q + Q))
  33359. b = b.dbl();
  33360. } else {
  33361. // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
  33362. b = a.diffAdd(b, c);
  33363. // N * Q + Q = 2 * ((N / 2) * Q + Q)
  33364. a = a.dbl();
  33365. }
  33366. }
  33367. return b;
  33368. };
  33369. Point.prototype.mulAdd = function mulAdd() {
  33370. throw new Error('Not supported on Montgomery curve');
  33371. };
  33372. Point.prototype.jumlAdd = function jumlAdd() {
  33373. throw new Error('Not supported on Montgomery curve');
  33374. };
  33375. Point.prototype.eq = function eq(other) {
  33376. return this.getX().cmp(other.getX()) === 0;
  33377. };
  33378. Point.prototype.normalize = function normalize() {
  33379. this.x = this.x.redMul(this.z.redInvm());
  33380. this.z = this.curve.one;
  33381. return this;
  33382. };
  33383. Point.prototype.getX = function getX() {
  33384. // Normalize coordinates
  33385. this.normalize();
  33386. return this.x.fromRed();
  33387. };
  33388. /***/ }),
  33389. /***/ "./node_modules/elliptic/lib/elliptic/curve/short.js":
  33390. /*!***********************************************************!*\
  33391. !*** ./node_modules/elliptic/lib/elliptic/curve/short.js ***!
  33392. \***********************************************************/
  33393. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  33394. "use strict";
  33395. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  33396. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  33397. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  33398. var Base = __webpack_require__(/*! ./base */ "./node_modules/elliptic/lib/elliptic/curve/base.js");
  33399. var assert = utils.assert;
  33400. function ShortCurve(conf) {
  33401. Base.call(this, 'short', conf);
  33402. this.a = new BN(conf.a, 16).toRed(this.red);
  33403. this.b = new BN(conf.b, 16).toRed(this.red);
  33404. this.tinv = this.two.redInvm();
  33405. this.zeroA = this.a.fromRed().cmpn(0) === 0;
  33406. this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
  33407. // If the curve is endomorphic, precalculate beta and lambda
  33408. this.endo = this._getEndomorphism(conf);
  33409. this._endoWnafT1 = new Array(4);
  33410. this._endoWnafT2 = new Array(4);
  33411. }
  33412. inherits(ShortCurve, Base);
  33413. module.exports = ShortCurve;
  33414. ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
  33415. // No efficient endomorphism
  33416. if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
  33417. return;
  33418. // Compute beta and lambda, that lambda * P = (beta * Px; Py)
  33419. var beta;
  33420. var lambda;
  33421. if (conf.beta) {
  33422. beta = new BN(conf.beta, 16).toRed(this.red);
  33423. } else {
  33424. var betas = this._getEndoRoots(this.p);
  33425. // Choose the smallest beta
  33426. beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
  33427. beta = beta.toRed(this.red);
  33428. }
  33429. if (conf.lambda) {
  33430. lambda = new BN(conf.lambda, 16);
  33431. } else {
  33432. // Choose the lambda that is matching selected beta
  33433. var lambdas = this._getEndoRoots(this.n);
  33434. if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
  33435. lambda = lambdas[0];
  33436. } else {
  33437. lambda = lambdas[1];
  33438. assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
  33439. }
  33440. }
  33441. // Get basis vectors, used for balanced length-two representation
  33442. var basis;
  33443. if (conf.basis) {
  33444. basis = conf.basis.map(function(vec) {
  33445. return {
  33446. a: new BN(vec.a, 16),
  33447. b: new BN(vec.b, 16),
  33448. };
  33449. });
  33450. } else {
  33451. basis = this._getEndoBasis(lambda);
  33452. }
  33453. return {
  33454. beta: beta,
  33455. lambda: lambda,
  33456. basis: basis,
  33457. };
  33458. };
  33459. ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
  33460. // Find roots of for x^2 + x + 1 in F
  33461. // Root = (-1 +- Sqrt(-3)) / 2
  33462. //
  33463. var red = num === this.p ? this.red : BN.mont(num);
  33464. var tinv = new BN(2).toRed(red).redInvm();
  33465. var ntinv = tinv.redNeg();
  33466. var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
  33467. var l1 = ntinv.redAdd(s).fromRed();
  33468. var l2 = ntinv.redSub(s).fromRed();
  33469. return [ l1, l2 ];
  33470. };
  33471. ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
  33472. // aprxSqrt >= sqrt(this.n)
  33473. var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
  33474. // 3.74
  33475. // Run EGCD, until r(L + 1) < aprxSqrt
  33476. var u = lambda;
  33477. var v = this.n.clone();
  33478. var x1 = new BN(1);
  33479. var y1 = new BN(0);
  33480. var x2 = new BN(0);
  33481. var y2 = new BN(1);
  33482. // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
  33483. var a0;
  33484. var b0;
  33485. // First vector
  33486. var a1;
  33487. var b1;
  33488. // Second vector
  33489. var a2;
  33490. var b2;
  33491. var prevR;
  33492. var i = 0;
  33493. var r;
  33494. var x;
  33495. while (u.cmpn(0) !== 0) {
  33496. var q = v.div(u);
  33497. r = v.sub(q.mul(u));
  33498. x = x2.sub(q.mul(x1));
  33499. var y = y2.sub(q.mul(y1));
  33500. if (!a1 && r.cmp(aprxSqrt) < 0) {
  33501. a0 = prevR.neg();
  33502. b0 = x1;
  33503. a1 = r.neg();
  33504. b1 = x;
  33505. } else if (a1 && ++i === 2) {
  33506. break;
  33507. }
  33508. prevR = r;
  33509. v = u;
  33510. u = r;
  33511. x2 = x1;
  33512. x1 = x;
  33513. y2 = y1;
  33514. y1 = y;
  33515. }
  33516. a2 = r.neg();
  33517. b2 = x;
  33518. var len1 = a1.sqr().add(b1.sqr());
  33519. var len2 = a2.sqr().add(b2.sqr());
  33520. if (len2.cmp(len1) >= 0) {
  33521. a2 = a0;
  33522. b2 = b0;
  33523. }
  33524. // Normalize signs
  33525. if (a1.negative) {
  33526. a1 = a1.neg();
  33527. b1 = b1.neg();
  33528. }
  33529. if (a2.negative) {
  33530. a2 = a2.neg();
  33531. b2 = b2.neg();
  33532. }
  33533. return [
  33534. { a: a1, b: b1 },
  33535. { a: a2, b: b2 },
  33536. ];
  33537. };
  33538. ShortCurve.prototype._endoSplit = function _endoSplit(k) {
  33539. var basis = this.endo.basis;
  33540. var v1 = basis[0];
  33541. var v2 = basis[1];
  33542. var c1 = v2.b.mul(k).divRound(this.n);
  33543. var c2 = v1.b.neg().mul(k).divRound(this.n);
  33544. var p1 = c1.mul(v1.a);
  33545. var p2 = c2.mul(v2.a);
  33546. var q1 = c1.mul(v1.b);
  33547. var q2 = c2.mul(v2.b);
  33548. // Calculate answer
  33549. var k1 = k.sub(p1).sub(p2);
  33550. var k2 = q1.add(q2).neg();
  33551. return { k1: k1, k2: k2 };
  33552. };
  33553. ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
  33554. x = new BN(x, 16);
  33555. if (!x.red)
  33556. x = x.toRed(this.red);
  33557. var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
  33558. var y = y2.redSqrt();
  33559. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  33560. throw new Error('invalid point');
  33561. // XXX Is there any way to tell if the number is odd without converting it
  33562. // to non-red form?
  33563. var isOdd = y.fromRed().isOdd();
  33564. if (odd && !isOdd || !odd && isOdd)
  33565. y = y.redNeg();
  33566. return this.point(x, y);
  33567. };
  33568. ShortCurve.prototype.validate = function validate(point) {
  33569. if (point.inf)
  33570. return true;
  33571. var x = point.x;
  33572. var y = point.y;
  33573. var ax = this.a.redMul(x);
  33574. var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
  33575. return y.redSqr().redISub(rhs).cmpn(0) === 0;
  33576. };
  33577. ShortCurve.prototype._endoWnafMulAdd =
  33578. function _endoWnafMulAdd(points, coeffs, jacobianResult) {
  33579. var npoints = this._endoWnafT1;
  33580. var ncoeffs = this._endoWnafT2;
  33581. for (var i = 0; i < points.length; i++) {
  33582. var split = this._endoSplit(coeffs[i]);
  33583. var p = points[i];
  33584. var beta = p._getBeta();
  33585. if (split.k1.negative) {
  33586. split.k1.ineg();
  33587. p = p.neg(true);
  33588. }
  33589. if (split.k2.negative) {
  33590. split.k2.ineg();
  33591. beta = beta.neg(true);
  33592. }
  33593. npoints[i * 2] = p;
  33594. npoints[i * 2 + 1] = beta;
  33595. ncoeffs[i * 2] = split.k1;
  33596. ncoeffs[i * 2 + 1] = split.k2;
  33597. }
  33598. var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
  33599. // Clean-up references to points and coefficients
  33600. for (var j = 0; j < i * 2; j++) {
  33601. npoints[j] = null;
  33602. ncoeffs[j] = null;
  33603. }
  33604. return res;
  33605. };
  33606. function Point(curve, x, y, isRed) {
  33607. Base.BasePoint.call(this, curve, 'affine');
  33608. if (x === null && y === null) {
  33609. this.x = null;
  33610. this.y = null;
  33611. this.inf = true;
  33612. } else {
  33613. this.x = new BN(x, 16);
  33614. this.y = new BN(y, 16);
  33615. // Force redgomery representation when loading from JSON
  33616. if (isRed) {
  33617. this.x.forceRed(this.curve.red);
  33618. this.y.forceRed(this.curve.red);
  33619. }
  33620. if (!this.x.red)
  33621. this.x = this.x.toRed(this.curve.red);
  33622. if (!this.y.red)
  33623. this.y = this.y.toRed(this.curve.red);
  33624. this.inf = false;
  33625. }
  33626. }
  33627. inherits(Point, Base.BasePoint);
  33628. ShortCurve.prototype.point = function point(x, y, isRed) {
  33629. return new Point(this, x, y, isRed);
  33630. };
  33631. ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
  33632. return Point.fromJSON(this, obj, red);
  33633. };
  33634. Point.prototype._getBeta = function _getBeta() {
  33635. if (!this.curve.endo)
  33636. return;
  33637. var pre = this.precomputed;
  33638. if (pre && pre.beta)
  33639. return pre.beta;
  33640. var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
  33641. if (pre) {
  33642. var curve = this.curve;
  33643. var endoMul = function(p) {
  33644. return curve.point(p.x.redMul(curve.endo.beta), p.y);
  33645. };
  33646. pre.beta = beta;
  33647. beta.precomputed = {
  33648. beta: null,
  33649. naf: pre.naf && {
  33650. wnd: pre.naf.wnd,
  33651. points: pre.naf.points.map(endoMul),
  33652. },
  33653. doubles: pre.doubles && {
  33654. step: pre.doubles.step,
  33655. points: pre.doubles.points.map(endoMul),
  33656. },
  33657. };
  33658. }
  33659. return beta;
  33660. };
  33661. Point.prototype.toJSON = function toJSON() {
  33662. if (!this.precomputed)
  33663. return [ this.x, this.y ];
  33664. return [ this.x, this.y, this.precomputed && {
  33665. doubles: this.precomputed.doubles && {
  33666. step: this.precomputed.doubles.step,
  33667. points: this.precomputed.doubles.points.slice(1),
  33668. },
  33669. naf: this.precomputed.naf && {
  33670. wnd: this.precomputed.naf.wnd,
  33671. points: this.precomputed.naf.points.slice(1),
  33672. },
  33673. } ];
  33674. };
  33675. Point.fromJSON = function fromJSON(curve, obj, red) {
  33676. if (typeof obj === 'string')
  33677. obj = JSON.parse(obj);
  33678. var res = curve.point(obj[0], obj[1], red);
  33679. if (!obj[2])
  33680. return res;
  33681. function obj2point(obj) {
  33682. return curve.point(obj[0], obj[1], red);
  33683. }
  33684. var pre = obj[2];
  33685. res.precomputed = {
  33686. beta: null,
  33687. doubles: pre.doubles && {
  33688. step: pre.doubles.step,
  33689. points: [ res ].concat(pre.doubles.points.map(obj2point)),
  33690. },
  33691. naf: pre.naf && {
  33692. wnd: pre.naf.wnd,
  33693. points: [ res ].concat(pre.naf.points.map(obj2point)),
  33694. },
  33695. };
  33696. return res;
  33697. };
  33698. Point.prototype.inspect = function inspect() {
  33699. if (this.isInfinity())
  33700. return '<EC Point Infinity>';
  33701. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  33702. ' y: ' + this.y.fromRed().toString(16, 2) + '>';
  33703. };
  33704. Point.prototype.isInfinity = function isInfinity() {
  33705. return this.inf;
  33706. };
  33707. Point.prototype.add = function add(p) {
  33708. // O + P = P
  33709. if (this.inf)
  33710. return p;
  33711. // P + O = P
  33712. if (p.inf)
  33713. return this;
  33714. // P + P = 2P
  33715. if (this.eq(p))
  33716. return this.dbl();
  33717. // P + (-P) = O
  33718. if (this.neg().eq(p))
  33719. return this.curve.point(null, null);
  33720. // P + Q = O
  33721. if (this.x.cmp(p.x) === 0)
  33722. return this.curve.point(null, null);
  33723. var c = this.y.redSub(p.y);
  33724. if (c.cmpn(0) !== 0)
  33725. c = c.redMul(this.x.redSub(p.x).redInvm());
  33726. var nx = c.redSqr().redISub(this.x).redISub(p.x);
  33727. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  33728. return this.curve.point(nx, ny);
  33729. };
  33730. Point.prototype.dbl = function dbl() {
  33731. if (this.inf)
  33732. return this;
  33733. // 2P = O
  33734. var ys1 = this.y.redAdd(this.y);
  33735. if (ys1.cmpn(0) === 0)
  33736. return this.curve.point(null, null);
  33737. var a = this.curve.a;
  33738. var x2 = this.x.redSqr();
  33739. var dyinv = ys1.redInvm();
  33740. var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
  33741. var nx = c.redSqr().redISub(this.x.redAdd(this.x));
  33742. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  33743. return this.curve.point(nx, ny);
  33744. };
  33745. Point.prototype.getX = function getX() {
  33746. return this.x.fromRed();
  33747. };
  33748. Point.prototype.getY = function getY() {
  33749. return this.y.fromRed();
  33750. };
  33751. Point.prototype.mul = function mul(k) {
  33752. k = new BN(k, 16);
  33753. if (this.isInfinity())
  33754. return this;
  33755. else if (this._hasDoubles(k))
  33756. return this.curve._fixedNafMul(this, k);
  33757. else if (this.curve.endo)
  33758. return this.curve._endoWnafMulAdd([ this ], [ k ]);
  33759. else
  33760. return this.curve._wnafMul(this, k);
  33761. };
  33762. Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
  33763. var points = [ this, p2 ];
  33764. var coeffs = [ k1, k2 ];
  33765. if (this.curve.endo)
  33766. return this.curve._endoWnafMulAdd(points, coeffs);
  33767. else
  33768. return this.curve._wnafMulAdd(1, points, coeffs, 2);
  33769. };
  33770. Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
  33771. var points = [ this, p2 ];
  33772. var coeffs = [ k1, k2 ];
  33773. if (this.curve.endo)
  33774. return this.curve._endoWnafMulAdd(points, coeffs, true);
  33775. else
  33776. return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
  33777. };
  33778. Point.prototype.eq = function eq(p) {
  33779. return this === p ||
  33780. this.inf === p.inf &&
  33781. (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
  33782. };
  33783. Point.prototype.neg = function neg(_precompute) {
  33784. if (this.inf)
  33785. return this;
  33786. var res = this.curve.point(this.x, this.y.redNeg());
  33787. if (_precompute && this.precomputed) {
  33788. var pre = this.precomputed;
  33789. var negate = function(p) {
  33790. return p.neg();
  33791. };
  33792. res.precomputed = {
  33793. naf: pre.naf && {
  33794. wnd: pre.naf.wnd,
  33795. points: pre.naf.points.map(negate),
  33796. },
  33797. doubles: pre.doubles && {
  33798. step: pre.doubles.step,
  33799. points: pre.doubles.points.map(negate),
  33800. },
  33801. };
  33802. }
  33803. return res;
  33804. };
  33805. Point.prototype.toJ = function toJ() {
  33806. if (this.inf)
  33807. return this.curve.jpoint(null, null, null);
  33808. var res = this.curve.jpoint(this.x, this.y, this.curve.one);
  33809. return res;
  33810. };
  33811. function JPoint(curve, x, y, z) {
  33812. Base.BasePoint.call(this, curve, 'jacobian');
  33813. if (x === null && y === null && z === null) {
  33814. this.x = this.curve.one;
  33815. this.y = this.curve.one;
  33816. this.z = new BN(0);
  33817. } else {
  33818. this.x = new BN(x, 16);
  33819. this.y = new BN(y, 16);
  33820. this.z = new BN(z, 16);
  33821. }
  33822. if (!this.x.red)
  33823. this.x = this.x.toRed(this.curve.red);
  33824. if (!this.y.red)
  33825. this.y = this.y.toRed(this.curve.red);
  33826. if (!this.z.red)
  33827. this.z = this.z.toRed(this.curve.red);
  33828. this.zOne = this.z === this.curve.one;
  33829. }
  33830. inherits(JPoint, Base.BasePoint);
  33831. ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
  33832. return new JPoint(this, x, y, z);
  33833. };
  33834. JPoint.prototype.toP = function toP() {
  33835. if (this.isInfinity())
  33836. return this.curve.point(null, null);
  33837. var zinv = this.z.redInvm();
  33838. var zinv2 = zinv.redSqr();
  33839. var ax = this.x.redMul(zinv2);
  33840. var ay = this.y.redMul(zinv2).redMul(zinv);
  33841. return this.curve.point(ax, ay);
  33842. };
  33843. JPoint.prototype.neg = function neg() {
  33844. return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
  33845. };
  33846. JPoint.prototype.add = function add(p) {
  33847. // O + P = P
  33848. if (this.isInfinity())
  33849. return p;
  33850. // P + O = P
  33851. if (p.isInfinity())
  33852. return this;
  33853. // 12M + 4S + 7A
  33854. var pz2 = p.z.redSqr();
  33855. var z2 = this.z.redSqr();
  33856. var u1 = this.x.redMul(pz2);
  33857. var u2 = p.x.redMul(z2);
  33858. var s1 = this.y.redMul(pz2.redMul(p.z));
  33859. var s2 = p.y.redMul(z2.redMul(this.z));
  33860. var h = u1.redSub(u2);
  33861. var r = s1.redSub(s2);
  33862. if (h.cmpn(0) === 0) {
  33863. if (r.cmpn(0) !== 0)
  33864. return this.curve.jpoint(null, null, null);
  33865. else
  33866. return this.dbl();
  33867. }
  33868. var h2 = h.redSqr();
  33869. var h3 = h2.redMul(h);
  33870. var v = u1.redMul(h2);
  33871. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  33872. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  33873. var nz = this.z.redMul(p.z).redMul(h);
  33874. return this.curve.jpoint(nx, ny, nz);
  33875. };
  33876. JPoint.prototype.mixedAdd = function mixedAdd(p) {
  33877. // O + P = P
  33878. if (this.isInfinity())
  33879. return p.toJ();
  33880. // P + O = P
  33881. if (p.isInfinity())
  33882. return this;
  33883. // 8M + 3S + 7A
  33884. var z2 = this.z.redSqr();
  33885. var u1 = this.x;
  33886. var u2 = p.x.redMul(z2);
  33887. var s1 = this.y;
  33888. var s2 = p.y.redMul(z2).redMul(this.z);
  33889. var h = u1.redSub(u2);
  33890. var r = s1.redSub(s2);
  33891. if (h.cmpn(0) === 0) {
  33892. if (r.cmpn(0) !== 0)
  33893. return this.curve.jpoint(null, null, null);
  33894. else
  33895. return this.dbl();
  33896. }
  33897. var h2 = h.redSqr();
  33898. var h3 = h2.redMul(h);
  33899. var v = u1.redMul(h2);
  33900. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  33901. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  33902. var nz = this.z.redMul(h);
  33903. return this.curve.jpoint(nx, ny, nz);
  33904. };
  33905. JPoint.prototype.dblp = function dblp(pow) {
  33906. if (pow === 0)
  33907. return this;
  33908. if (this.isInfinity())
  33909. return this;
  33910. if (!pow)
  33911. return this.dbl();
  33912. var i;
  33913. if (this.curve.zeroA || this.curve.threeA) {
  33914. var r = this;
  33915. for (i = 0; i < pow; i++)
  33916. r = r.dbl();
  33917. return r;
  33918. }
  33919. // 1M + 2S + 1A + N * (4S + 5M + 8A)
  33920. // N = 1 => 6M + 6S + 9A
  33921. var a = this.curve.a;
  33922. var tinv = this.curve.tinv;
  33923. var jx = this.x;
  33924. var jy = this.y;
  33925. var jz = this.z;
  33926. var jz4 = jz.redSqr().redSqr();
  33927. // Reuse results
  33928. var jyd = jy.redAdd(jy);
  33929. for (i = 0; i < pow; i++) {
  33930. var jx2 = jx.redSqr();
  33931. var jyd2 = jyd.redSqr();
  33932. var jyd4 = jyd2.redSqr();
  33933. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  33934. var t1 = jx.redMul(jyd2);
  33935. var nx = c.redSqr().redISub(t1.redAdd(t1));
  33936. var t2 = t1.redISub(nx);
  33937. var dny = c.redMul(t2);
  33938. dny = dny.redIAdd(dny).redISub(jyd4);
  33939. var nz = jyd.redMul(jz);
  33940. if (i + 1 < pow)
  33941. jz4 = jz4.redMul(jyd4);
  33942. jx = nx;
  33943. jz = nz;
  33944. jyd = dny;
  33945. }
  33946. return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
  33947. };
  33948. JPoint.prototype.dbl = function dbl() {
  33949. if (this.isInfinity())
  33950. return this;
  33951. if (this.curve.zeroA)
  33952. return this._zeroDbl();
  33953. else if (this.curve.threeA)
  33954. return this._threeDbl();
  33955. else
  33956. return this._dbl();
  33957. };
  33958. JPoint.prototype._zeroDbl = function _zeroDbl() {
  33959. var nx;
  33960. var ny;
  33961. var nz;
  33962. // Z = 1
  33963. if (this.zOne) {
  33964. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  33965. // #doubling-mdbl-2007-bl
  33966. // 1M + 5S + 14A
  33967. // XX = X1^2
  33968. var xx = this.x.redSqr();
  33969. // YY = Y1^2
  33970. var yy = this.y.redSqr();
  33971. // YYYY = YY^2
  33972. var yyyy = yy.redSqr();
  33973. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  33974. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  33975. s = s.redIAdd(s);
  33976. // M = 3 * XX + a; a = 0
  33977. var m = xx.redAdd(xx).redIAdd(xx);
  33978. // T = M ^ 2 - 2*S
  33979. var t = m.redSqr().redISub(s).redISub(s);
  33980. // 8 * YYYY
  33981. var yyyy8 = yyyy.redIAdd(yyyy);
  33982. yyyy8 = yyyy8.redIAdd(yyyy8);
  33983. yyyy8 = yyyy8.redIAdd(yyyy8);
  33984. // X3 = T
  33985. nx = t;
  33986. // Y3 = M * (S - T) - 8 * YYYY
  33987. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  33988. // Z3 = 2*Y1
  33989. nz = this.y.redAdd(this.y);
  33990. } else {
  33991. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  33992. // #doubling-dbl-2009-l
  33993. // 2M + 5S + 13A
  33994. // A = X1^2
  33995. var a = this.x.redSqr();
  33996. // B = Y1^2
  33997. var b = this.y.redSqr();
  33998. // C = B^2
  33999. var c = b.redSqr();
  34000. // D = 2 * ((X1 + B)^2 - A - C)
  34001. var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
  34002. d = d.redIAdd(d);
  34003. // E = 3 * A
  34004. var e = a.redAdd(a).redIAdd(a);
  34005. // F = E^2
  34006. var f = e.redSqr();
  34007. // 8 * C
  34008. var c8 = c.redIAdd(c);
  34009. c8 = c8.redIAdd(c8);
  34010. c8 = c8.redIAdd(c8);
  34011. // X3 = F - 2 * D
  34012. nx = f.redISub(d).redISub(d);
  34013. // Y3 = E * (D - X3) - 8 * C
  34014. ny = e.redMul(d.redISub(nx)).redISub(c8);
  34015. // Z3 = 2 * Y1 * Z1
  34016. nz = this.y.redMul(this.z);
  34017. nz = nz.redIAdd(nz);
  34018. }
  34019. return this.curve.jpoint(nx, ny, nz);
  34020. };
  34021. JPoint.prototype._threeDbl = function _threeDbl() {
  34022. var nx;
  34023. var ny;
  34024. var nz;
  34025. // Z = 1
  34026. if (this.zOne) {
  34027. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
  34028. // #doubling-mdbl-2007-bl
  34029. // 1M + 5S + 15A
  34030. // XX = X1^2
  34031. var xx = this.x.redSqr();
  34032. // YY = Y1^2
  34033. var yy = this.y.redSqr();
  34034. // YYYY = YY^2
  34035. var yyyy = yy.redSqr();
  34036. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  34037. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  34038. s = s.redIAdd(s);
  34039. // M = 3 * XX + a
  34040. var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
  34041. // T = M^2 - 2 * S
  34042. var t = m.redSqr().redISub(s).redISub(s);
  34043. // X3 = T
  34044. nx = t;
  34045. // Y3 = M * (S - T) - 8 * YYYY
  34046. var yyyy8 = yyyy.redIAdd(yyyy);
  34047. yyyy8 = yyyy8.redIAdd(yyyy8);
  34048. yyyy8 = yyyy8.redIAdd(yyyy8);
  34049. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  34050. // Z3 = 2 * Y1
  34051. nz = this.y.redAdd(this.y);
  34052. } else {
  34053. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
  34054. // 3M + 5S
  34055. // delta = Z1^2
  34056. var delta = this.z.redSqr();
  34057. // gamma = Y1^2
  34058. var gamma = this.y.redSqr();
  34059. // beta = X1 * gamma
  34060. var beta = this.x.redMul(gamma);
  34061. // alpha = 3 * (X1 - delta) * (X1 + delta)
  34062. var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
  34063. alpha = alpha.redAdd(alpha).redIAdd(alpha);
  34064. // X3 = alpha^2 - 8 * beta
  34065. var beta4 = beta.redIAdd(beta);
  34066. beta4 = beta4.redIAdd(beta4);
  34067. var beta8 = beta4.redAdd(beta4);
  34068. nx = alpha.redSqr().redISub(beta8);
  34069. // Z3 = (Y1 + Z1)^2 - gamma - delta
  34070. nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
  34071. // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
  34072. var ggamma8 = gamma.redSqr();
  34073. ggamma8 = ggamma8.redIAdd(ggamma8);
  34074. ggamma8 = ggamma8.redIAdd(ggamma8);
  34075. ggamma8 = ggamma8.redIAdd(ggamma8);
  34076. ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
  34077. }
  34078. return this.curve.jpoint(nx, ny, nz);
  34079. };
  34080. JPoint.prototype._dbl = function _dbl() {
  34081. var a = this.curve.a;
  34082. // 4M + 6S + 10A
  34083. var jx = this.x;
  34084. var jy = this.y;
  34085. var jz = this.z;
  34086. var jz4 = jz.redSqr().redSqr();
  34087. var jx2 = jx.redSqr();
  34088. var jy2 = jy.redSqr();
  34089. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  34090. var jxd4 = jx.redAdd(jx);
  34091. jxd4 = jxd4.redIAdd(jxd4);
  34092. var t1 = jxd4.redMul(jy2);
  34093. var nx = c.redSqr().redISub(t1.redAdd(t1));
  34094. var t2 = t1.redISub(nx);
  34095. var jyd8 = jy2.redSqr();
  34096. jyd8 = jyd8.redIAdd(jyd8);
  34097. jyd8 = jyd8.redIAdd(jyd8);
  34098. jyd8 = jyd8.redIAdd(jyd8);
  34099. var ny = c.redMul(t2).redISub(jyd8);
  34100. var nz = jy.redAdd(jy).redMul(jz);
  34101. return this.curve.jpoint(nx, ny, nz);
  34102. };
  34103. JPoint.prototype.trpl = function trpl() {
  34104. if (!this.curve.zeroA)
  34105. return this.dbl().add(this);
  34106. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
  34107. // 5M + 10S + ...
  34108. // XX = X1^2
  34109. var xx = this.x.redSqr();
  34110. // YY = Y1^2
  34111. var yy = this.y.redSqr();
  34112. // ZZ = Z1^2
  34113. var zz = this.z.redSqr();
  34114. // YYYY = YY^2
  34115. var yyyy = yy.redSqr();
  34116. // M = 3 * XX + a * ZZ2; a = 0
  34117. var m = xx.redAdd(xx).redIAdd(xx);
  34118. // MM = M^2
  34119. var mm = m.redSqr();
  34120. // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
  34121. var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  34122. e = e.redIAdd(e);
  34123. e = e.redAdd(e).redIAdd(e);
  34124. e = e.redISub(mm);
  34125. // EE = E^2
  34126. var ee = e.redSqr();
  34127. // T = 16*YYYY
  34128. var t = yyyy.redIAdd(yyyy);
  34129. t = t.redIAdd(t);
  34130. t = t.redIAdd(t);
  34131. t = t.redIAdd(t);
  34132. // U = (M + E)^2 - MM - EE - T
  34133. var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
  34134. // X3 = 4 * (X1 * EE - 4 * YY * U)
  34135. var yyu4 = yy.redMul(u);
  34136. yyu4 = yyu4.redIAdd(yyu4);
  34137. yyu4 = yyu4.redIAdd(yyu4);
  34138. var nx = this.x.redMul(ee).redISub(yyu4);
  34139. nx = nx.redIAdd(nx);
  34140. nx = nx.redIAdd(nx);
  34141. // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
  34142. var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
  34143. ny = ny.redIAdd(ny);
  34144. ny = ny.redIAdd(ny);
  34145. ny = ny.redIAdd(ny);
  34146. // Z3 = (Z1 + E)^2 - ZZ - EE
  34147. var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
  34148. return this.curve.jpoint(nx, ny, nz);
  34149. };
  34150. JPoint.prototype.mul = function mul(k, kbase) {
  34151. k = new BN(k, kbase);
  34152. return this.curve._wnafMul(this, k);
  34153. };
  34154. JPoint.prototype.eq = function eq(p) {
  34155. if (p.type === 'affine')
  34156. return this.eq(p.toJ());
  34157. if (this === p)
  34158. return true;
  34159. // x1 * z2^2 == x2 * z1^2
  34160. var z2 = this.z.redSqr();
  34161. var pz2 = p.z.redSqr();
  34162. if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
  34163. return false;
  34164. // y1 * z2^3 == y2 * z1^3
  34165. var z3 = z2.redMul(this.z);
  34166. var pz3 = pz2.redMul(p.z);
  34167. return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
  34168. };
  34169. JPoint.prototype.eqXToP = function eqXToP(x) {
  34170. var zs = this.z.redSqr();
  34171. var rx = x.toRed(this.curve.red).redMul(zs);
  34172. if (this.x.cmp(rx) === 0)
  34173. return true;
  34174. var xc = x.clone();
  34175. var t = this.curve.redN.redMul(zs);
  34176. for (;;) {
  34177. xc.iadd(this.curve.n);
  34178. if (xc.cmp(this.curve.p) >= 0)
  34179. return false;
  34180. rx.redIAdd(t);
  34181. if (this.x.cmp(rx) === 0)
  34182. return true;
  34183. }
  34184. };
  34185. JPoint.prototype.inspect = function inspect() {
  34186. if (this.isInfinity())
  34187. return '<EC JPoint Infinity>';
  34188. return '<EC JPoint x: ' + this.x.toString(16, 2) +
  34189. ' y: ' + this.y.toString(16, 2) +
  34190. ' z: ' + this.z.toString(16, 2) + '>';
  34191. };
  34192. JPoint.prototype.isInfinity = function isInfinity() {
  34193. // XXX This code assumes that zero is always zero in red
  34194. return this.z.cmpn(0) === 0;
  34195. };
  34196. /***/ }),
  34197. /***/ "./node_modules/elliptic/lib/elliptic/curves.js":
  34198. /*!******************************************************!*\
  34199. !*** ./node_modules/elliptic/lib/elliptic/curves.js ***!
  34200. \******************************************************/
  34201. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  34202. "use strict";
  34203. var curves = exports;
  34204. var hash = __webpack_require__(/*! hash.js */ "./node_modules/hash.js/lib/hash.js");
  34205. var curve = __webpack_require__(/*! ./curve */ "./node_modules/elliptic/lib/elliptic/curve/index.js");
  34206. var utils = __webpack_require__(/*! ./utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  34207. var assert = utils.assert;
  34208. function PresetCurve(options) {
  34209. if (options.type === 'short')
  34210. this.curve = new curve.short(options);
  34211. else if (options.type === 'edwards')
  34212. this.curve = new curve.edwards(options);
  34213. else
  34214. this.curve = new curve.mont(options);
  34215. this.g = this.curve.g;
  34216. this.n = this.curve.n;
  34217. this.hash = options.hash;
  34218. assert(this.g.validate(), 'Invalid curve');
  34219. assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
  34220. }
  34221. curves.PresetCurve = PresetCurve;
  34222. function defineCurve(name, options) {
  34223. Object.defineProperty(curves, name, {
  34224. configurable: true,
  34225. enumerable: true,
  34226. get: function() {
  34227. var curve = new PresetCurve(options);
  34228. Object.defineProperty(curves, name, {
  34229. configurable: true,
  34230. enumerable: true,
  34231. value: curve,
  34232. });
  34233. return curve;
  34234. },
  34235. });
  34236. }
  34237. defineCurve('p192', {
  34238. type: 'short',
  34239. prime: 'p192',
  34240. p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
  34241. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
  34242. b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
  34243. n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
  34244. hash: hash.sha256,
  34245. gRed: false,
  34246. g: [
  34247. '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
  34248. '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811',
  34249. ],
  34250. });
  34251. defineCurve('p224', {
  34252. type: 'short',
  34253. prime: 'p224',
  34254. p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
  34255. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
  34256. b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
  34257. n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
  34258. hash: hash.sha256,
  34259. gRed: false,
  34260. g: [
  34261. 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
  34262. 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34',
  34263. ],
  34264. });
  34265. defineCurve('p256', {
  34266. type: 'short',
  34267. prime: null,
  34268. p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
  34269. a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
  34270. b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
  34271. n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
  34272. hash: hash.sha256,
  34273. gRed: false,
  34274. g: [
  34275. '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
  34276. '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5',
  34277. ],
  34278. });
  34279. defineCurve('p384', {
  34280. type: 'short',
  34281. prime: null,
  34282. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34283. 'fffffffe ffffffff 00000000 00000000 ffffffff',
  34284. a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34285. 'fffffffe ffffffff 00000000 00000000 fffffffc',
  34286. b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
  34287. '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
  34288. n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
  34289. 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
  34290. hash: hash.sha384,
  34291. gRed: false,
  34292. g: [
  34293. 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
  34294. '5502f25d bf55296c 3a545e38 72760ab7',
  34295. '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
  34296. '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f',
  34297. ],
  34298. });
  34299. defineCurve('p521', {
  34300. type: 'short',
  34301. prime: null,
  34302. p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34303. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34304. 'ffffffff ffffffff ffffffff ffffffff ffffffff',
  34305. a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34306. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34307. 'ffffffff ffffffff ffffffff ffffffff fffffffc',
  34308. b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
  34309. '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
  34310. '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
  34311. n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  34312. 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
  34313. 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
  34314. hash: hash.sha512,
  34315. gRed: false,
  34316. g: [
  34317. '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
  34318. '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
  34319. 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
  34320. '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
  34321. '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
  34322. '3fad0761 353c7086 a272c240 88be9476 9fd16650',
  34323. ],
  34324. });
  34325. defineCurve('curve25519', {
  34326. type: 'mont',
  34327. prime: 'p25519',
  34328. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  34329. a: '76d06',
  34330. b: '1',
  34331. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  34332. hash: hash.sha256,
  34333. gRed: false,
  34334. g: [
  34335. '9',
  34336. ],
  34337. });
  34338. defineCurve('ed25519', {
  34339. type: 'edwards',
  34340. prime: 'p25519',
  34341. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  34342. a: '-1',
  34343. c: '1',
  34344. // -121665 * (121666^(-1)) (mod P)
  34345. d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
  34346. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  34347. hash: hash.sha256,
  34348. gRed: false,
  34349. g: [
  34350. '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
  34351. // 4/5
  34352. '6666666666666666666666666666666666666666666666666666666666666658',
  34353. ],
  34354. });
  34355. var pre;
  34356. try {
  34357. pre = __webpack_require__(/*! ./precomputed/secp256k1 */ "./node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js");
  34358. } catch (e) {
  34359. pre = undefined;
  34360. }
  34361. defineCurve('secp256k1', {
  34362. type: 'short',
  34363. prime: 'k256',
  34364. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
  34365. a: '0',
  34366. b: '7',
  34367. n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
  34368. h: '1',
  34369. hash: hash.sha256,
  34370. // Precomputed endomorphism
  34371. beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
  34372. lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
  34373. basis: [
  34374. {
  34375. a: '3086d221a7d46bcde86c90e49284eb15',
  34376. b: '-e4437ed6010e88286f547fa90abfe4c3',
  34377. },
  34378. {
  34379. a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
  34380. b: '3086d221a7d46bcde86c90e49284eb15',
  34381. },
  34382. ],
  34383. gRed: false,
  34384. g: [
  34385. '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  34386. '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
  34387. pre,
  34388. ],
  34389. });
  34390. /***/ }),
  34391. /***/ "./node_modules/elliptic/lib/elliptic/ec/index.js":
  34392. /*!********************************************************!*\
  34393. !*** ./node_modules/elliptic/lib/elliptic/ec/index.js ***!
  34394. \********************************************************/
  34395. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  34396. "use strict";
  34397. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  34398. var HmacDRBG = __webpack_require__(/*! hmac-drbg */ "./node_modules/hmac-drbg/lib/hmac-drbg.js");
  34399. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  34400. var curves = __webpack_require__(/*! ../curves */ "./node_modules/elliptic/lib/elliptic/curves.js");
  34401. var rand = __webpack_require__(/*! brorand */ "./node_modules/brorand/index.js");
  34402. var assert = utils.assert;
  34403. var KeyPair = __webpack_require__(/*! ./key */ "./node_modules/elliptic/lib/elliptic/ec/key.js");
  34404. var Signature = __webpack_require__(/*! ./signature */ "./node_modules/elliptic/lib/elliptic/ec/signature.js");
  34405. function EC(options) {
  34406. if (!(this instanceof EC))
  34407. return new EC(options);
  34408. // Shortcut `elliptic.ec(curve-name)`
  34409. if (typeof options === 'string') {
  34410. assert(Object.prototype.hasOwnProperty.call(curves, options),
  34411. 'Unknown curve ' + options);
  34412. options = curves[options];
  34413. }
  34414. // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
  34415. if (options instanceof curves.PresetCurve)
  34416. options = { curve: options };
  34417. this.curve = options.curve.curve;
  34418. this.n = this.curve.n;
  34419. this.nh = this.n.ushrn(1);
  34420. this.g = this.curve.g;
  34421. // Point on curve
  34422. this.g = options.curve.g;
  34423. this.g.precompute(options.curve.n.bitLength() + 1);
  34424. // Hash for function for DRBG
  34425. this.hash = options.hash || options.curve.hash;
  34426. }
  34427. module.exports = EC;
  34428. EC.prototype.keyPair = function keyPair(options) {
  34429. return new KeyPair(this, options);
  34430. };
  34431. EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
  34432. return KeyPair.fromPrivate(this, priv, enc);
  34433. };
  34434. EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
  34435. return KeyPair.fromPublic(this, pub, enc);
  34436. };
  34437. EC.prototype.genKeyPair = function genKeyPair(options) {
  34438. if (!options)
  34439. options = {};
  34440. // Instantiate Hmac_DRBG
  34441. var drbg = new HmacDRBG({
  34442. hash: this.hash,
  34443. pers: options.pers,
  34444. persEnc: options.persEnc || 'utf8',
  34445. entropy: options.entropy || rand(this.hash.hmacStrength),
  34446. entropyEnc: options.entropy && options.entropyEnc || 'utf8',
  34447. nonce: this.n.toArray(),
  34448. });
  34449. var bytes = this.n.byteLength();
  34450. var ns2 = this.n.sub(new BN(2));
  34451. for (;;) {
  34452. var priv = new BN(drbg.generate(bytes));
  34453. if (priv.cmp(ns2) > 0)
  34454. continue;
  34455. priv.iaddn(1);
  34456. return this.keyFromPrivate(priv);
  34457. }
  34458. };
  34459. EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
  34460. var delta = msg.byteLength() * 8 - this.n.bitLength();
  34461. if (delta > 0)
  34462. msg = msg.ushrn(delta);
  34463. if (!truncOnly && msg.cmp(this.n) >= 0)
  34464. return msg.sub(this.n);
  34465. else
  34466. return msg;
  34467. };
  34468. EC.prototype.sign = function sign(msg, key, enc, options) {
  34469. if (typeof enc === 'object') {
  34470. options = enc;
  34471. enc = null;
  34472. }
  34473. if (!options)
  34474. options = {};
  34475. key = this.keyFromPrivate(key, enc);
  34476. msg = this._truncateToN(new BN(msg, 16));
  34477. // Zero-extend key to provide enough entropy
  34478. var bytes = this.n.byteLength();
  34479. var bkey = key.getPrivate().toArray('be', bytes);
  34480. // Zero-extend nonce to have the same byte size as N
  34481. var nonce = msg.toArray('be', bytes);
  34482. // Instantiate Hmac_DRBG
  34483. var drbg = new HmacDRBG({
  34484. hash: this.hash,
  34485. entropy: bkey,
  34486. nonce: nonce,
  34487. pers: options.pers,
  34488. persEnc: options.persEnc || 'utf8',
  34489. });
  34490. // Number of bytes to generate
  34491. var ns1 = this.n.sub(new BN(1));
  34492. for (var iter = 0; ; iter++) {
  34493. var k = options.k ?
  34494. options.k(iter) :
  34495. new BN(drbg.generate(this.n.byteLength()));
  34496. k = this._truncateToN(k, true);
  34497. if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
  34498. continue;
  34499. var kp = this.g.mul(k);
  34500. if (kp.isInfinity())
  34501. continue;
  34502. var kpX = kp.getX();
  34503. var r = kpX.umod(this.n);
  34504. if (r.cmpn(0) === 0)
  34505. continue;
  34506. var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
  34507. s = s.umod(this.n);
  34508. if (s.cmpn(0) === 0)
  34509. continue;
  34510. var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
  34511. (kpX.cmp(r) !== 0 ? 2 : 0);
  34512. // Use complement of `s`, if it is > `n / 2`
  34513. if (options.canonical && s.cmp(this.nh) > 0) {
  34514. s = this.n.sub(s);
  34515. recoveryParam ^= 1;
  34516. }
  34517. return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
  34518. }
  34519. };
  34520. EC.prototype.verify = function verify(msg, signature, key, enc) {
  34521. msg = this._truncateToN(new BN(msg, 16));
  34522. key = this.keyFromPublic(key, enc);
  34523. signature = new Signature(signature, 'hex');
  34524. // Perform primitive values validation
  34525. var r = signature.r;
  34526. var s = signature.s;
  34527. if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
  34528. return false;
  34529. if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
  34530. return false;
  34531. // Validate signature
  34532. var sinv = s.invm(this.n);
  34533. var u1 = sinv.mul(msg).umod(this.n);
  34534. var u2 = sinv.mul(r).umod(this.n);
  34535. var p;
  34536. if (!this.curve._maxwellTrick) {
  34537. p = this.g.mulAdd(u1, key.getPublic(), u2);
  34538. if (p.isInfinity())
  34539. return false;
  34540. return p.getX().umod(this.n).cmp(r) === 0;
  34541. }
  34542. // NOTE: Greg Maxwell's trick, inspired by:
  34543. // https://git.io/vad3K
  34544. p = this.g.jmulAdd(u1, key.getPublic(), u2);
  34545. if (p.isInfinity())
  34546. return false;
  34547. // Compare `p.x` of Jacobian point with `r`,
  34548. // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
  34549. // inverse of `p.z^2`
  34550. return p.eqXToP(r);
  34551. };
  34552. EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
  34553. assert((3 & j) === j, 'The recovery param is more than two bits');
  34554. signature = new Signature(signature, enc);
  34555. var n = this.n;
  34556. var e = new BN(msg);
  34557. var r = signature.r;
  34558. var s = signature.s;
  34559. // A set LSB signifies that the y-coordinate is odd
  34560. var isYOdd = j & 1;
  34561. var isSecondKey = j >> 1;
  34562. if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
  34563. throw new Error('Unable to find sencond key candinate');
  34564. // 1.1. Let x = r + jn.
  34565. if (isSecondKey)
  34566. r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
  34567. else
  34568. r = this.curve.pointFromX(r, isYOdd);
  34569. var rInv = signature.r.invm(n);
  34570. var s1 = n.sub(e).mul(rInv).umod(n);
  34571. var s2 = s.mul(rInv).umod(n);
  34572. // 1.6.1 Compute Q = r^-1 (sR - eG)
  34573. // Q = r^-1 (sR + -eG)
  34574. return this.g.mulAdd(s1, r, s2);
  34575. };
  34576. EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
  34577. signature = new Signature(signature, enc);
  34578. if (signature.recoveryParam !== null)
  34579. return signature.recoveryParam;
  34580. for (var i = 0; i < 4; i++) {
  34581. var Qprime;
  34582. try {
  34583. Qprime = this.recoverPubKey(e, signature, i);
  34584. } catch (e) {
  34585. continue;
  34586. }
  34587. if (Qprime.eq(Q))
  34588. return i;
  34589. }
  34590. throw new Error('Unable to find valid recovery factor');
  34591. };
  34592. /***/ }),
  34593. /***/ "./node_modules/elliptic/lib/elliptic/ec/key.js":
  34594. /*!******************************************************!*\
  34595. !*** ./node_modules/elliptic/lib/elliptic/ec/key.js ***!
  34596. \******************************************************/
  34597. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  34598. "use strict";
  34599. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  34600. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  34601. var assert = utils.assert;
  34602. function KeyPair(ec, options) {
  34603. this.ec = ec;
  34604. this.priv = null;
  34605. this.pub = null;
  34606. // KeyPair(ec, { priv: ..., pub: ... })
  34607. if (options.priv)
  34608. this._importPrivate(options.priv, options.privEnc);
  34609. if (options.pub)
  34610. this._importPublic(options.pub, options.pubEnc);
  34611. }
  34612. module.exports = KeyPair;
  34613. KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
  34614. if (pub instanceof KeyPair)
  34615. return pub;
  34616. return new KeyPair(ec, {
  34617. pub: pub,
  34618. pubEnc: enc,
  34619. });
  34620. };
  34621. KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
  34622. if (priv instanceof KeyPair)
  34623. return priv;
  34624. return new KeyPair(ec, {
  34625. priv: priv,
  34626. privEnc: enc,
  34627. });
  34628. };
  34629. KeyPair.prototype.validate = function validate() {
  34630. var pub = this.getPublic();
  34631. if (pub.isInfinity())
  34632. return { result: false, reason: 'Invalid public key' };
  34633. if (!pub.validate())
  34634. return { result: false, reason: 'Public key is not a point' };
  34635. if (!pub.mul(this.ec.curve.n).isInfinity())
  34636. return { result: false, reason: 'Public key * N != O' };
  34637. return { result: true, reason: null };
  34638. };
  34639. KeyPair.prototype.getPublic = function getPublic(compact, enc) {
  34640. // compact is optional argument
  34641. if (typeof compact === 'string') {
  34642. enc = compact;
  34643. compact = null;
  34644. }
  34645. if (!this.pub)
  34646. this.pub = this.ec.g.mul(this.priv);
  34647. if (!enc)
  34648. return this.pub;
  34649. return this.pub.encode(enc, compact);
  34650. };
  34651. KeyPair.prototype.getPrivate = function getPrivate(enc) {
  34652. if (enc === 'hex')
  34653. return this.priv.toString(16, 2);
  34654. else
  34655. return this.priv;
  34656. };
  34657. KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
  34658. this.priv = new BN(key, enc || 16);
  34659. // Ensure that the priv won't be bigger than n, otherwise we may fail
  34660. // in fixed multiplication method
  34661. this.priv = this.priv.umod(this.ec.curve.n);
  34662. };
  34663. KeyPair.prototype._importPublic = function _importPublic(key, enc) {
  34664. if (key.x || key.y) {
  34665. // Montgomery points only have an `x` coordinate.
  34666. // Weierstrass/Edwards points on the other hand have both `x` and
  34667. // `y` coordinates.
  34668. if (this.ec.curve.type === 'mont') {
  34669. assert(key.x, 'Need x coordinate');
  34670. } else if (this.ec.curve.type === 'short' ||
  34671. this.ec.curve.type === 'edwards') {
  34672. assert(key.x && key.y, 'Need both x and y coordinate');
  34673. }
  34674. this.pub = this.ec.curve.point(key.x, key.y);
  34675. return;
  34676. }
  34677. this.pub = this.ec.curve.decodePoint(key, enc);
  34678. };
  34679. // ECDH
  34680. KeyPair.prototype.derive = function derive(pub) {
  34681. if(!pub.validate()) {
  34682. assert(pub.validate(), 'public point not validated');
  34683. }
  34684. return pub.mul(this.priv).getX();
  34685. };
  34686. // ECDSA
  34687. KeyPair.prototype.sign = function sign(msg, enc, options) {
  34688. return this.ec.sign(msg, this, enc, options);
  34689. };
  34690. KeyPair.prototype.verify = function verify(msg, signature) {
  34691. return this.ec.verify(msg, signature, this);
  34692. };
  34693. KeyPair.prototype.inspect = function inspect() {
  34694. return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
  34695. ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
  34696. };
  34697. /***/ }),
  34698. /***/ "./node_modules/elliptic/lib/elliptic/ec/signature.js":
  34699. /*!************************************************************!*\
  34700. !*** ./node_modules/elliptic/lib/elliptic/ec/signature.js ***!
  34701. \************************************************************/
  34702. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  34703. "use strict";
  34704. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  34705. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  34706. var assert = utils.assert;
  34707. function Signature(options, enc) {
  34708. if (options instanceof Signature)
  34709. return options;
  34710. if (this._importDER(options, enc))
  34711. return;
  34712. assert(options.r && options.s, 'Signature without r or s');
  34713. this.r = new BN(options.r, 16);
  34714. this.s = new BN(options.s, 16);
  34715. if (options.recoveryParam === undefined)
  34716. this.recoveryParam = null;
  34717. else
  34718. this.recoveryParam = options.recoveryParam;
  34719. }
  34720. module.exports = Signature;
  34721. function Position() {
  34722. this.place = 0;
  34723. }
  34724. function getLength(buf, p) {
  34725. var initial = buf[p.place++];
  34726. if (!(initial & 0x80)) {
  34727. return initial;
  34728. }
  34729. var octetLen = initial & 0xf;
  34730. // Indefinite length or overflow
  34731. if (octetLen === 0 || octetLen > 4) {
  34732. return false;
  34733. }
  34734. var val = 0;
  34735. for (var i = 0, off = p.place; i < octetLen; i++, off++) {
  34736. val <<= 8;
  34737. val |= buf[off];
  34738. val >>>= 0;
  34739. }
  34740. // Leading zeroes
  34741. if (val <= 0x7f) {
  34742. return false;
  34743. }
  34744. p.place = off;
  34745. return val;
  34746. }
  34747. function rmPadding(buf) {
  34748. var i = 0;
  34749. var len = buf.length - 1;
  34750. while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
  34751. i++;
  34752. }
  34753. if (i === 0) {
  34754. return buf;
  34755. }
  34756. return buf.slice(i);
  34757. }
  34758. Signature.prototype._importDER = function _importDER(data, enc) {
  34759. data = utils.toArray(data, enc);
  34760. var p = new Position();
  34761. if (data[p.place++] !== 0x30) {
  34762. return false;
  34763. }
  34764. var len = getLength(data, p);
  34765. if (len === false) {
  34766. return false;
  34767. }
  34768. if ((len + p.place) !== data.length) {
  34769. return false;
  34770. }
  34771. if (data[p.place++] !== 0x02) {
  34772. return false;
  34773. }
  34774. var rlen = getLength(data, p);
  34775. if (rlen === false) {
  34776. return false;
  34777. }
  34778. var r = data.slice(p.place, rlen + p.place);
  34779. p.place += rlen;
  34780. if (data[p.place++] !== 0x02) {
  34781. return false;
  34782. }
  34783. var slen = getLength(data, p);
  34784. if (slen === false) {
  34785. return false;
  34786. }
  34787. if (data.length !== slen + p.place) {
  34788. return false;
  34789. }
  34790. var s = data.slice(p.place, slen + p.place);
  34791. if (r[0] === 0) {
  34792. if (r[1] & 0x80) {
  34793. r = r.slice(1);
  34794. } else {
  34795. // Leading zeroes
  34796. return false;
  34797. }
  34798. }
  34799. if (s[0] === 0) {
  34800. if (s[1] & 0x80) {
  34801. s = s.slice(1);
  34802. } else {
  34803. // Leading zeroes
  34804. return false;
  34805. }
  34806. }
  34807. this.r = new BN(r);
  34808. this.s = new BN(s);
  34809. this.recoveryParam = null;
  34810. return true;
  34811. };
  34812. function constructLength(arr, len) {
  34813. if (len < 0x80) {
  34814. arr.push(len);
  34815. return;
  34816. }
  34817. var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
  34818. arr.push(octets | 0x80);
  34819. while (--octets) {
  34820. arr.push((len >>> (octets << 3)) & 0xff);
  34821. }
  34822. arr.push(len);
  34823. }
  34824. Signature.prototype.toDER = function toDER(enc) {
  34825. var r = this.r.toArray();
  34826. var s = this.s.toArray();
  34827. // Pad values
  34828. if (r[0] & 0x80)
  34829. r = [ 0 ].concat(r);
  34830. // Pad values
  34831. if (s[0] & 0x80)
  34832. s = [ 0 ].concat(s);
  34833. r = rmPadding(r);
  34834. s = rmPadding(s);
  34835. while (!s[0] && !(s[1] & 0x80)) {
  34836. s = s.slice(1);
  34837. }
  34838. var arr = [ 0x02 ];
  34839. constructLength(arr, r.length);
  34840. arr = arr.concat(r);
  34841. arr.push(0x02);
  34842. constructLength(arr, s.length);
  34843. var backHalf = arr.concat(s);
  34844. var res = [ 0x30 ];
  34845. constructLength(res, backHalf.length);
  34846. res = res.concat(backHalf);
  34847. return utils.encode(res, enc);
  34848. };
  34849. /***/ }),
  34850. /***/ "./node_modules/elliptic/lib/elliptic/eddsa/index.js":
  34851. /*!***********************************************************!*\
  34852. !*** ./node_modules/elliptic/lib/elliptic/eddsa/index.js ***!
  34853. \***********************************************************/
  34854. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  34855. "use strict";
  34856. var hash = __webpack_require__(/*! hash.js */ "./node_modules/hash.js/lib/hash.js");
  34857. var curves = __webpack_require__(/*! ../curves */ "./node_modules/elliptic/lib/elliptic/curves.js");
  34858. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  34859. var assert = utils.assert;
  34860. var parseBytes = utils.parseBytes;
  34861. var KeyPair = __webpack_require__(/*! ./key */ "./node_modules/elliptic/lib/elliptic/eddsa/key.js");
  34862. var Signature = __webpack_require__(/*! ./signature */ "./node_modules/elliptic/lib/elliptic/eddsa/signature.js");
  34863. function EDDSA(curve) {
  34864. assert(curve === 'ed25519', 'only tested with ed25519 so far');
  34865. if (!(this instanceof EDDSA))
  34866. return new EDDSA(curve);
  34867. curve = curves[curve].curve;
  34868. this.curve = curve;
  34869. this.g = curve.g;
  34870. this.g.precompute(curve.n.bitLength() + 1);
  34871. this.pointClass = curve.point().constructor;
  34872. this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
  34873. this.hash = hash.sha512;
  34874. }
  34875. module.exports = EDDSA;
  34876. /**
  34877. * @param {Array|String} message - message bytes
  34878. * @param {Array|String|KeyPair} secret - secret bytes or a keypair
  34879. * @returns {Signature} - signature
  34880. */
  34881. EDDSA.prototype.sign = function sign(message, secret) {
  34882. message = parseBytes(message);
  34883. var key = this.keyFromSecret(secret);
  34884. var r = this.hashInt(key.messagePrefix(), message);
  34885. var R = this.g.mul(r);
  34886. var Rencoded = this.encodePoint(R);
  34887. var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
  34888. .mul(key.priv());
  34889. var S = r.add(s_).umod(this.curve.n);
  34890. return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
  34891. };
  34892. /**
  34893. * @param {Array} message - message bytes
  34894. * @param {Array|String|Signature} sig - sig bytes
  34895. * @param {Array|String|Point|KeyPair} pub - public key
  34896. * @returns {Boolean} - true if public key matches sig of message
  34897. */
  34898. EDDSA.prototype.verify = function verify(message, sig, pub) {
  34899. message = parseBytes(message);
  34900. sig = this.makeSignature(sig);
  34901. var key = this.keyFromPublic(pub);
  34902. var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
  34903. var SG = this.g.mul(sig.S());
  34904. var RplusAh = sig.R().add(key.pub().mul(h));
  34905. return RplusAh.eq(SG);
  34906. };
  34907. EDDSA.prototype.hashInt = function hashInt() {
  34908. var hash = this.hash();
  34909. for (var i = 0; i < arguments.length; i++)
  34910. hash.update(arguments[i]);
  34911. return utils.intFromLE(hash.digest()).umod(this.curve.n);
  34912. };
  34913. EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
  34914. return KeyPair.fromPublic(this, pub);
  34915. };
  34916. EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
  34917. return KeyPair.fromSecret(this, secret);
  34918. };
  34919. EDDSA.prototype.makeSignature = function makeSignature(sig) {
  34920. if (sig instanceof Signature)
  34921. return sig;
  34922. return new Signature(this, sig);
  34923. };
  34924. /**
  34925. * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
  34926. *
  34927. * EDDSA defines methods for encoding and decoding points and integers. These are
  34928. * helper convenience methods, that pass along to utility functions implied
  34929. * parameters.
  34930. *
  34931. */
  34932. EDDSA.prototype.encodePoint = function encodePoint(point) {
  34933. var enc = point.getY().toArray('le', this.encodingLength);
  34934. enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
  34935. return enc;
  34936. };
  34937. EDDSA.prototype.decodePoint = function decodePoint(bytes) {
  34938. bytes = utils.parseBytes(bytes);
  34939. var lastIx = bytes.length - 1;
  34940. var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
  34941. var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
  34942. var y = utils.intFromLE(normed);
  34943. return this.curve.pointFromY(y, xIsOdd);
  34944. };
  34945. EDDSA.prototype.encodeInt = function encodeInt(num) {
  34946. return num.toArray('le', this.encodingLength);
  34947. };
  34948. EDDSA.prototype.decodeInt = function decodeInt(bytes) {
  34949. return utils.intFromLE(bytes);
  34950. };
  34951. EDDSA.prototype.isPoint = function isPoint(val) {
  34952. return val instanceof this.pointClass;
  34953. };
  34954. /***/ }),
  34955. /***/ "./node_modules/elliptic/lib/elliptic/eddsa/key.js":
  34956. /*!*********************************************************!*\
  34957. !*** ./node_modules/elliptic/lib/elliptic/eddsa/key.js ***!
  34958. \*********************************************************/
  34959. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  34960. "use strict";
  34961. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  34962. var assert = utils.assert;
  34963. var parseBytes = utils.parseBytes;
  34964. var cachedProperty = utils.cachedProperty;
  34965. /**
  34966. * @param {EDDSA} eddsa - instance
  34967. * @param {Object} params - public/private key parameters
  34968. *
  34969. * @param {Array<Byte>} [params.secret] - secret seed bytes
  34970. * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
  34971. * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
  34972. *
  34973. */
  34974. function KeyPair(eddsa, params) {
  34975. this.eddsa = eddsa;
  34976. this._secret = parseBytes(params.secret);
  34977. if (eddsa.isPoint(params.pub))
  34978. this._pub = params.pub;
  34979. else
  34980. this._pubBytes = parseBytes(params.pub);
  34981. }
  34982. KeyPair.fromPublic = function fromPublic(eddsa, pub) {
  34983. if (pub instanceof KeyPair)
  34984. return pub;
  34985. return new KeyPair(eddsa, { pub: pub });
  34986. };
  34987. KeyPair.fromSecret = function fromSecret(eddsa, secret) {
  34988. if (secret instanceof KeyPair)
  34989. return secret;
  34990. return new KeyPair(eddsa, { secret: secret });
  34991. };
  34992. KeyPair.prototype.secret = function secret() {
  34993. return this._secret;
  34994. };
  34995. cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
  34996. return this.eddsa.encodePoint(this.pub());
  34997. });
  34998. cachedProperty(KeyPair, 'pub', function pub() {
  34999. if (this._pubBytes)
  35000. return this.eddsa.decodePoint(this._pubBytes);
  35001. return this.eddsa.g.mul(this.priv());
  35002. });
  35003. cachedProperty(KeyPair, 'privBytes', function privBytes() {
  35004. var eddsa = this.eddsa;
  35005. var hash = this.hash();
  35006. var lastIx = eddsa.encodingLength - 1;
  35007. var a = hash.slice(0, eddsa.encodingLength);
  35008. a[0] &= 248;
  35009. a[lastIx] &= 127;
  35010. a[lastIx] |= 64;
  35011. return a;
  35012. });
  35013. cachedProperty(KeyPair, 'priv', function priv() {
  35014. return this.eddsa.decodeInt(this.privBytes());
  35015. });
  35016. cachedProperty(KeyPair, 'hash', function hash() {
  35017. return this.eddsa.hash().update(this.secret()).digest();
  35018. });
  35019. cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
  35020. return this.hash().slice(this.eddsa.encodingLength);
  35021. });
  35022. KeyPair.prototype.sign = function sign(message) {
  35023. assert(this._secret, 'KeyPair can only verify');
  35024. return this.eddsa.sign(message, this);
  35025. };
  35026. KeyPair.prototype.verify = function verify(message, sig) {
  35027. return this.eddsa.verify(message, sig, this);
  35028. };
  35029. KeyPair.prototype.getSecret = function getSecret(enc) {
  35030. assert(this._secret, 'KeyPair is public only');
  35031. return utils.encode(this.secret(), enc);
  35032. };
  35033. KeyPair.prototype.getPublic = function getPublic(enc) {
  35034. return utils.encode(this.pubBytes(), enc);
  35035. };
  35036. module.exports = KeyPair;
  35037. /***/ }),
  35038. /***/ "./node_modules/elliptic/lib/elliptic/eddsa/signature.js":
  35039. /*!***************************************************************!*\
  35040. !*** ./node_modules/elliptic/lib/elliptic/eddsa/signature.js ***!
  35041. \***************************************************************/
  35042. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  35043. "use strict";
  35044. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  35045. var utils = __webpack_require__(/*! ../utils */ "./node_modules/elliptic/lib/elliptic/utils.js");
  35046. var assert = utils.assert;
  35047. var cachedProperty = utils.cachedProperty;
  35048. var parseBytes = utils.parseBytes;
  35049. /**
  35050. * @param {EDDSA} eddsa - eddsa instance
  35051. * @param {Array<Bytes>|Object} sig -
  35052. * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
  35053. * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
  35054. * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
  35055. * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
  35056. */
  35057. function Signature(eddsa, sig) {
  35058. this.eddsa = eddsa;
  35059. if (typeof sig !== 'object')
  35060. sig = parseBytes(sig);
  35061. if (Array.isArray(sig)) {
  35062. sig = {
  35063. R: sig.slice(0, eddsa.encodingLength),
  35064. S: sig.slice(eddsa.encodingLength),
  35065. };
  35066. }
  35067. assert(sig.R && sig.S, 'Signature without R or S');
  35068. if (eddsa.isPoint(sig.R))
  35069. this._R = sig.R;
  35070. if (sig.S instanceof BN)
  35071. this._S = sig.S;
  35072. this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
  35073. this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
  35074. }
  35075. cachedProperty(Signature, 'S', function S() {
  35076. return this.eddsa.decodeInt(this.Sencoded());
  35077. });
  35078. cachedProperty(Signature, 'R', function R() {
  35079. return this.eddsa.decodePoint(this.Rencoded());
  35080. });
  35081. cachedProperty(Signature, 'Rencoded', function Rencoded() {
  35082. return this.eddsa.encodePoint(this.R());
  35083. });
  35084. cachedProperty(Signature, 'Sencoded', function Sencoded() {
  35085. return this.eddsa.encodeInt(this.S());
  35086. });
  35087. Signature.prototype.toBytes = function toBytes() {
  35088. return this.Rencoded().concat(this.Sencoded());
  35089. };
  35090. Signature.prototype.toHex = function toHex() {
  35091. return utils.encode(this.toBytes(), 'hex').toUpperCase();
  35092. };
  35093. module.exports = Signature;
  35094. /***/ }),
  35095. /***/ "./node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js":
  35096. /*!*********************************************************************!*\
  35097. !*** ./node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js ***!
  35098. \*********************************************************************/
  35099. /***/ ((module) => {
  35100. module.exports = {
  35101. doubles: {
  35102. step: 4,
  35103. points: [
  35104. [
  35105. 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
  35106. 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821',
  35107. ],
  35108. [
  35109. '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
  35110. '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf',
  35111. ],
  35112. [
  35113. '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
  35114. 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695',
  35115. ],
  35116. [
  35117. '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
  35118. '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9',
  35119. ],
  35120. [
  35121. '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
  35122. '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36',
  35123. ],
  35124. [
  35125. '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
  35126. '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f',
  35127. ],
  35128. [
  35129. 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
  35130. '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999',
  35131. ],
  35132. [
  35133. '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
  35134. 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09',
  35135. ],
  35136. [
  35137. 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
  35138. '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d',
  35139. ],
  35140. [
  35141. 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
  35142. 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088',
  35143. ],
  35144. [
  35145. 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
  35146. '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d',
  35147. ],
  35148. [
  35149. '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
  35150. '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8',
  35151. ],
  35152. [
  35153. '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
  35154. '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a',
  35155. ],
  35156. [
  35157. '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
  35158. '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453',
  35159. ],
  35160. [
  35161. '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
  35162. '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160',
  35163. ],
  35164. [
  35165. '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
  35166. '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0',
  35167. ],
  35168. [
  35169. '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
  35170. '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6',
  35171. ],
  35172. [
  35173. '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
  35174. '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589',
  35175. ],
  35176. [
  35177. '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
  35178. 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17',
  35179. ],
  35180. [
  35181. 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
  35182. '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda',
  35183. ],
  35184. [
  35185. 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
  35186. '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd',
  35187. ],
  35188. [
  35189. '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
  35190. '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2',
  35191. ],
  35192. [
  35193. '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
  35194. '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6',
  35195. ],
  35196. [
  35197. 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
  35198. '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f',
  35199. ],
  35200. [
  35201. '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
  35202. 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01',
  35203. ],
  35204. [
  35205. 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
  35206. '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3',
  35207. ],
  35208. [
  35209. 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
  35210. 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f',
  35211. ],
  35212. [
  35213. 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
  35214. '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7',
  35215. ],
  35216. [
  35217. 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
  35218. 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78',
  35219. ],
  35220. [
  35221. 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
  35222. '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1',
  35223. ],
  35224. [
  35225. '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
  35226. 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150',
  35227. ],
  35228. [
  35229. '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
  35230. '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82',
  35231. ],
  35232. [
  35233. 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
  35234. '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc',
  35235. ],
  35236. [
  35237. '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
  35238. 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b',
  35239. ],
  35240. [
  35241. 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
  35242. '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51',
  35243. ],
  35244. [
  35245. 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
  35246. '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45',
  35247. ],
  35248. [
  35249. 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
  35250. 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120',
  35251. ],
  35252. [
  35253. '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
  35254. '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84',
  35255. ],
  35256. [
  35257. '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
  35258. '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d',
  35259. ],
  35260. [
  35261. '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
  35262. 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d',
  35263. ],
  35264. [
  35265. '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
  35266. '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8',
  35267. ],
  35268. [
  35269. 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
  35270. '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8',
  35271. ],
  35272. [
  35273. '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
  35274. '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac',
  35275. ],
  35276. [
  35277. '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
  35278. 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f',
  35279. ],
  35280. [
  35281. '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
  35282. '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962',
  35283. ],
  35284. [
  35285. 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
  35286. '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907',
  35287. ],
  35288. [
  35289. '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
  35290. 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec',
  35291. ],
  35292. [
  35293. 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
  35294. 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d',
  35295. ],
  35296. [
  35297. 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
  35298. '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414',
  35299. ],
  35300. [
  35301. '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
  35302. 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd',
  35303. ],
  35304. [
  35305. '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
  35306. 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0',
  35307. ],
  35308. [
  35309. 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
  35310. '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811',
  35311. ],
  35312. [
  35313. 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
  35314. '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1',
  35315. ],
  35316. [
  35317. 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
  35318. '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c',
  35319. ],
  35320. [
  35321. '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
  35322. 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73',
  35323. ],
  35324. [
  35325. '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
  35326. '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd',
  35327. ],
  35328. [
  35329. 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
  35330. 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405',
  35331. ],
  35332. [
  35333. '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
  35334. 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589',
  35335. ],
  35336. [
  35337. '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
  35338. '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e',
  35339. ],
  35340. [
  35341. '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
  35342. '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27',
  35343. ],
  35344. [
  35345. 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
  35346. 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1',
  35347. ],
  35348. [
  35349. '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
  35350. '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482',
  35351. ],
  35352. [
  35353. '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
  35354. '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945',
  35355. ],
  35356. [
  35357. 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
  35358. '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573',
  35359. ],
  35360. [
  35361. 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
  35362. 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82',
  35363. ],
  35364. ],
  35365. },
  35366. naf: {
  35367. wnd: 7,
  35368. points: [
  35369. [
  35370. 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
  35371. '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672',
  35372. ],
  35373. [
  35374. '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
  35375. 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6',
  35376. ],
  35377. [
  35378. '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
  35379. '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da',
  35380. ],
  35381. [
  35382. 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
  35383. 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37',
  35384. ],
  35385. [
  35386. '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
  35387. 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b',
  35388. ],
  35389. [
  35390. 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
  35391. 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81',
  35392. ],
  35393. [
  35394. 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
  35395. '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58',
  35396. ],
  35397. [
  35398. 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
  35399. '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77',
  35400. ],
  35401. [
  35402. '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
  35403. '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a',
  35404. ],
  35405. [
  35406. '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
  35407. '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c',
  35408. ],
  35409. [
  35410. '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
  35411. '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67',
  35412. ],
  35413. [
  35414. '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
  35415. '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402',
  35416. ],
  35417. [
  35418. 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
  35419. 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55',
  35420. ],
  35421. [
  35422. 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
  35423. '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482',
  35424. ],
  35425. [
  35426. '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
  35427. 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82',
  35428. ],
  35429. [
  35430. '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
  35431. 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396',
  35432. ],
  35433. [
  35434. '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
  35435. '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49',
  35436. ],
  35437. [
  35438. '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
  35439. '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf',
  35440. ],
  35441. [
  35442. '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
  35443. '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a',
  35444. ],
  35445. [
  35446. '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
  35447. 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7',
  35448. ],
  35449. [
  35450. 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
  35451. 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933',
  35452. ],
  35453. [
  35454. '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
  35455. '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a',
  35456. ],
  35457. [
  35458. '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
  35459. '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6',
  35460. ],
  35461. [
  35462. 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
  35463. 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37',
  35464. ],
  35465. [
  35466. '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
  35467. '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e',
  35468. ],
  35469. [
  35470. 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
  35471. 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6',
  35472. ],
  35473. [
  35474. 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
  35475. 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476',
  35476. ],
  35477. [
  35478. '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
  35479. '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40',
  35480. ],
  35481. [
  35482. '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
  35483. '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61',
  35484. ],
  35485. [
  35486. '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
  35487. '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683',
  35488. ],
  35489. [
  35490. 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
  35491. '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5',
  35492. ],
  35493. [
  35494. '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
  35495. '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b',
  35496. ],
  35497. [
  35498. 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
  35499. '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417',
  35500. ],
  35501. [
  35502. '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
  35503. 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868',
  35504. ],
  35505. [
  35506. '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
  35507. 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a',
  35508. ],
  35509. [
  35510. 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
  35511. 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6',
  35512. ],
  35513. [
  35514. '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
  35515. '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996',
  35516. ],
  35517. [
  35518. '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
  35519. 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e',
  35520. ],
  35521. [
  35522. 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
  35523. 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d',
  35524. ],
  35525. [
  35526. '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
  35527. '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2',
  35528. ],
  35529. [
  35530. '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
  35531. 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e',
  35532. ],
  35533. [
  35534. '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
  35535. '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437',
  35536. ],
  35537. [
  35538. '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
  35539. 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311',
  35540. ],
  35541. [
  35542. 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
  35543. '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4',
  35544. ],
  35545. [
  35546. '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
  35547. '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575',
  35548. ],
  35549. [
  35550. '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
  35551. 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d',
  35552. ],
  35553. [
  35554. '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
  35555. 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d',
  35556. ],
  35557. [
  35558. 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
  35559. 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629',
  35560. ],
  35561. [
  35562. 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
  35563. 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06',
  35564. ],
  35565. [
  35566. '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
  35567. '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374',
  35568. ],
  35569. [
  35570. '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
  35571. '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee',
  35572. ],
  35573. [
  35574. 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
  35575. '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1',
  35576. ],
  35577. [
  35578. 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
  35579. 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b',
  35580. ],
  35581. [
  35582. '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
  35583. '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661',
  35584. ],
  35585. [
  35586. '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
  35587. '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6',
  35588. ],
  35589. [
  35590. 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
  35591. '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e',
  35592. ],
  35593. [
  35594. '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
  35595. '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d',
  35596. ],
  35597. [
  35598. 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
  35599. 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc',
  35600. ],
  35601. [
  35602. '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
  35603. 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4',
  35604. ],
  35605. [
  35606. '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
  35607. '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c',
  35608. ],
  35609. [
  35610. 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
  35611. '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b',
  35612. ],
  35613. [
  35614. 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
  35615. '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913',
  35616. ],
  35617. [
  35618. '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
  35619. '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154',
  35620. ],
  35621. [
  35622. '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
  35623. '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865',
  35624. ],
  35625. [
  35626. '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
  35627. 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc',
  35628. ],
  35629. [
  35630. '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
  35631. 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224',
  35632. ],
  35633. [
  35634. '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
  35635. '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e',
  35636. ],
  35637. [
  35638. '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
  35639. '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6',
  35640. ],
  35641. [
  35642. '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
  35643. '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511',
  35644. ],
  35645. [
  35646. '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
  35647. 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b',
  35648. ],
  35649. [
  35650. 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
  35651. 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2',
  35652. ],
  35653. [
  35654. '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
  35655. 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c',
  35656. ],
  35657. [
  35658. 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
  35659. '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3',
  35660. ],
  35661. [
  35662. 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
  35663. '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d',
  35664. ],
  35665. [
  35666. 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
  35667. '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700',
  35668. ],
  35669. [
  35670. 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
  35671. '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4',
  35672. ],
  35673. [
  35674. '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
  35675. 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196',
  35676. ],
  35677. [
  35678. '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
  35679. '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4',
  35680. ],
  35681. [
  35682. '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
  35683. 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257',
  35684. ],
  35685. [
  35686. 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
  35687. 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13',
  35688. ],
  35689. [
  35690. 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
  35691. '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096',
  35692. ],
  35693. [
  35694. 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
  35695. 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38',
  35696. ],
  35697. [
  35698. 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
  35699. '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f',
  35700. ],
  35701. [
  35702. '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
  35703. '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448',
  35704. ],
  35705. [
  35706. 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
  35707. '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a',
  35708. ],
  35709. [
  35710. 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
  35711. '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4',
  35712. ],
  35713. [
  35714. '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
  35715. '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437',
  35716. ],
  35717. [
  35718. '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
  35719. 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7',
  35720. ],
  35721. [
  35722. 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
  35723. '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d',
  35724. ],
  35725. [
  35726. 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
  35727. '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a',
  35728. ],
  35729. [
  35730. 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
  35731. '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54',
  35732. ],
  35733. [
  35734. '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
  35735. '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77',
  35736. ],
  35737. [
  35738. 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
  35739. 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517',
  35740. ],
  35741. [
  35742. '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
  35743. 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10',
  35744. ],
  35745. [
  35746. 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
  35747. 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125',
  35748. ],
  35749. [
  35750. 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
  35751. '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e',
  35752. ],
  35753. [
  35754. '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
  35755. 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1',
  35756. ],
  35757. [
  35758. 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
  35759. '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2',
  35760. ],
  35761. [
  35762. 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
  35763. '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423',
  35764. ],
  35765. [
  35766. 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
  35767. '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8',
  35768. ],
  35769. [
  35770. '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
  35771. 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758',
  35772. ],
  35773. [
  35774. '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
  35775. 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375',
  35776. ],
  35777. [
  35778. 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
  35779. '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d',
  35780. ],
  35781. [
  35782. '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
  35783. 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec',
  35784. ],
  35785. [
  35786. '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
  35787. '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0',
  35788. ],
  35789. [
  35790. '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
  35791. 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c',
  35792. ],
  35793. [
  35794. 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
  35795. 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4',
  35796. ],
  35797. [
  35798. '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
  35799. 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f',
  35800. ],
  35801. [
  35802. '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
  35803. '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649',
  35804. ],
  35805. [
  35806. '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
  35807. 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826',
  35808. ],
  35809. [
  35810. '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
  35811. '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5',
  35812. ],
  35813. [
  35814. 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
  35815. 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87',
  35816. ],
  35817. [
  35818. '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
  35819. '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b',
  35820. ],
  35821. [
  35822. 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
  35823. '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc',
  35824. ],
  35825. [
  35826. '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
  35827. '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c',
  35828. ],
  35829. [
  35830. 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
  35831. 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f',
  35832. ],
  35833. [
  35834. 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
  35835. '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a',
  35836. ],
  35837. [
  35838. 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
  35839. 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46',
  35840. ],
  35841. [
  35842. '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
  35843. 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f',
  35844. ],
  35845. [
  35846. '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
  35847. '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03',
  35848. ],
  35849. [
  35850. '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
  35851. 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08',
  35852. ],
  35853. [
  35854. '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
  35855. '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8',
  35856. ],
  35857. [
  35858. '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
  35859. '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373',
  35860. ],
  35861. [
  35862. '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
  35863. 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3',
  35864. ],
  35865. [
  35866. '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
  35867. '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8',
  35868. ],
  35869. [
  35870. '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
  35871. '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1',
  35872. ],
  35873. [
  35874. '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
  35875. '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9',
  35876. ],
  35877. ],
  35878. },
  35879. };
  35880. /***/ }),
  35881. /***/ "./node_modules/elliptic/lib/elliptic/utils.js":
  35882. /*!*****************************************************!*\
  35883. !*** ./node_modules/elliptic/lib/elliptic/utils.js ***!
  35884. \*****************************************************/
  35885. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  35886. "use strict";
  35887. var utils = exports;
  35888. var BN = __webpack_require__(/*! bn.js */ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js");
  35889. var minAssert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  35890. var minUtils = __webpack_require__(/*! minimalistic-crypto-utils */ "./node_modules/minimalistic-crypto-utils/lib/utils.js");
  35891. utils.assert = minAssert;
  35892. utils.toArray = minUtils.toArray;
  35893. utils.zero2 = minUtils.zero2;
  35894. utils.toHex = minUtils.toHex;
  35895. utils.encode = minUtils.encode;
  35896. // Represent num in a w-NAF form
  35897. function getNAF(num, w, bits) {
  35898. var naf = new Array(Math.max(num.bitLength(), bits) + 1);
  35899. naf.fill(0);
  35900. var ws = 1 << (w + 1);
  35901. var k = num.clone();
  35902. for (var i = 0; i < naf.length; i++) {
  35903. var z;
  35904. var mod = k.andln(ws - 1);
  35905. if (k.isOdd()) {
  35906. if (mod > (ws >> 1) - 1)
  35907. z = (ws >> 1) - mod;
  35908. else
  35909. z = mod;
  35910. k.isubn(z);
  35911. } else {
  35912. z = 0;
  35913. }
  35914. naf[i] = z;
  35915. k.iushrn(1);
  35916. }
  35917. return naf;
  35918. }
  35919. utils.getNAF = getNAF;
  35920. // Represent k1, k2 in a Joint Sparse Form
  35921. function getJSF(k1, k2) {
  35922. var jsf = [
  35923. [],
  35924. [],
  35925. ];
  35926. k1 = k1.clone();
  35927. k2 = k2.clone();
  35928. var d1 = 0;
  35929. var d2 = 0;
  35930. var m8;
  35931. while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
  35932. // First phase
  35933. var m14 = (k1.andln(3) + d1) & 3;
  35934. var m24 = (k2.andln(3) + d2) & 3;
  35935. if (m14 === 3)
  35936. m14 = -1;
  35937. if (m24 === 3)
  35938. m24 = -1;
  35939. var u1;
  35940. if ((m14 & 1) === 0) {
  35941. u1 = 0;
  35942. } else {
  35943. m8 = (k1.andln(7) + d1) & 7;
  35944. if ((m8 === 3 || m8 === 5) && m24 === 2)
  35945. u1 = -m14;
  35946. else
  35947. u1 = m14;
  35948. }
  35949. jsf[0].push(u1);
  35950. var u2;
  35951. if ((m24 & 1) === 0) {
  35952. u2 = 0;
  35953. } else {
  35954. m8 = (k2.andln(7) + d2) & 7;
  35955. if ((m8 === 3 || m8 === 5) && m14 === 2)
  35956. u2 = -m24;
  35957. else
  35958. u2 = m24;
  35959. }
  35960. jsf[1].push(u2);
  35961. // Second phase
  35962. if (2 * d1 === u1 + 1)
  35963. d1 = 1 - d1;
  35964. if (2 * d2 === u2 + 1)
  35965. d2 = 1 - d2;
  35966. k1.iushrn(1);
  35967. k2.iushrn(1);
  35968. }
  35969. return jsf;
  35970. }
  35971. utils.getJSF = getJSF;
  35972. function cachedProperty(obj, name, computer) {
  35973. var key = '_' + name;
  35974. obj.prototype[name] = function cachedProperty() {
  35975. return this[key] !== undefined ? this[key] :
  35976. this[key] = computer.call(this);
  35977. };
  35978. }
  35979. utils.cachedProperty = cachedProperty;
  35980. function parseBytes(bytes) {
  35981. return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
  35982. bytes;
  35983. }
  35984. utils.parseBytes = parseBytes;
  35985. function intFromLE(bytes) {
  35986. return new BN(bytes, 'hex', 'le');
  35987. }
  35988. utils.intFromLE = intFromLE;
  35989. /***/ }),
  35990. /***/ "./node_modules/elliptic/node_modules/bn.js/lib/bn.js":
  35991. /*!************************************************************!*\
  35992. !*** ./node_modules/elliptic/node_modules/bn.js/lib/bn.js ***!
  35993. \************************************************************/
  35994. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  35995. /* module decorator */ module = __webpack_require__.nmd(module);
  35996. (function (module, exports) {
  35997. 'use strict';
  35998. // Utils
  35999. function assert (val, msg) {
  36000. if (!val) throw new Error(msg || 'Assertion failed');
  36001. }
  36002. // Could use `inherits` module, but don't want to move from single file
  36003. // architecture yet.
  36004. function inherits (ctor, superCtor) {
  36005. ctor.super_ = superCtor;
  36006. var TempCtor = function () {};
  36007. TempCtor.prototype = superCtor.prototype;
  36008. ctor.prototype = new TempCtor();
  36009. ctor.prototype.constructor = ctor;
  36010. }
  36011. // BN
  36012. function BN (number, base, endian) {
  36013. if (BN.isBN(number)) {
  36014. return number;
  36015. }
  36016. this.negative = 0;
  36017. this.words = null;
  36018. this.length = 0;
  36019. // Reduction context
  36020. this.red = null;
  36021. if (number !== null) {
  36022. if (base === 'le' || base === 'be') {
  36023. endian = base;
  36024. base = 10;
  36025. }
  36026. this._init(number || 0, base || 10, endian || 'be');
  36027. }
  36028. }
  36029. if (typeof module === 'object') {
  36030. module.exports = BN;
  36031. } else {
  36032. exports.BN = BN;
  36033. }
  36034. BN.BN = BN;
  36035. BN.wordSize = 26;
  36036. var Buffer;
  36037. try {
  36038. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  36039. Buffer = window.Buffer;
  36040. } else {
  36041. Buffer = (__webpack_require__(/*! buffer */ "?1fc4").Buffer);
  36042. }
  36043. } catch (e) {
  36044. }
  36045. BN.isBN = function isBN (num) {
  36046. if (num instanceof BN) {
  36047. return true;
  36048. }
  36049. return num !== null && typeof num === 'object' &&
  36050. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  36051. };
  36052. BN.max = function max (left, right) {
  36053. if (left.cmp(right) > 0) return left;
  36054. return right;
  36055. };
  36056. BN.min = function min (left, right) {
  36057. if (left.cmp(right) < 0) return left;
  36058. return right;
  36059. };
  36060. BN.prototype._init = function init (number, base, endian) {
  36061. if (typeof number === 'number') {
  36062. return this._initNumber(number, base, endian);
  36063. }
  36064. if (typeof number === 'object') {
  36065. return this._initArray(number, base, endian);
  36066. }
  36067. if (base === 'hex') {
  36068. base = 16;
  36069. }
  36070. assert(base === (base | 0) && base >= 2 && base <= 36);
  36071. number = number.toString().replace(/\s+/g, '');
  36072. var start = 0;
  36073. if (number[0] === '-') {
  36074. start++;
  36075. this.negative = 1;
  36076. }
  36077. if (start < number.length) {
  36078. if (base === 16) {
  36079. this._parseHex(number, start, endian);
  36080. } else {
  36081. this._parseBase(number, base, start);
  36082. if (endian === 'le') {
  36083. this._initArray(this.toArray(), base, endian);
  36084. }
  36085. }
  36086. }
  36087. };
  36088. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  36089. if (number < 0) {
  36090. this.negative = 1;
  36091. number = -number;
  36092. }
  36093. if (number < 0x4000000) {
  36094. this.words = [ number & 0x3ffffff ];
  36095. this.length = 1;
  36096. } else if (number < 0x10000000000000) {
  36097. this.words = [
  36098. number & 0x3ffffff,
  36099. (number / 0x4000000) & 0x3ffffff
  36100. ];
  36101. this.length = 2;
  36102. } else {
  36103. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  36104. this.words = [
  36105. number & 0x3ffffff,
  36106. (number / 0x4000000) & 0x3ffffff,
  36107. 1
  36108. ];
  36109. this.length = 3;
  36110. }
  36111. if (endian !== 'le') return;
  36112. // Reverse the bytes
  36113. this._initArray(this.toArray(), base, endian);
  36114. };
  36115. BN.prototype._initArray = function _initArray (number, base, endian) {
  36116. // Perhaps a Uint8Array
  36117. assert(typeof number.length === 'number');
  36118. if (number.length <= 0) {
  36119. this.words = [ 0 ];
  36120. this.length = 1;
  36121. return this;
  36122. }
  36123. this.length = Math.ceil(number.length / 3);
  36124. this.words = new Array(this.length);
  36125. for (var i = 0; i < this.length; i++) {
  36126. this.words[i] = 0;
  36127. }
  36128. var j, w;
  36129. var off = 0;
  36130. if (endian === 'be') {
  36131. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  36132. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  36133. this.words[j] |= (w << off) & 0x3ffffff;
  36134. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  36135. off += 24;
  36136. if (off >= 26) {
  36137. off -= 26;
  36138. j++;
  36139. }
  36140. }
  36141. } else if (endian === 'le') {
  36142. for (i = 0, j = 0; i < number.length; i += 3) {
  36143. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  36144. this.words[j] |= (w << off) & 0x3ffffff;
  36145. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  36146. off += 24;
  36147. if (off >= 26) {
  36148. off -= 26;
  36149. j++;
  36150. }
  36151. }
  36152. }
  36153. return this.strip();
  36154. };
  36155. function parseHex4Bits (string, index) {
  36156. var c = string.charCodeAt(index);
  36157. // 'A' - 'F'
  36158. if (c >= 65 && c <= 70) {
  36159. return c - 55;
  36160. // 'a' - 'f'
  36161. } else if (c >= 97 && c <= 102) {
  36162. return c - 87;
  36163. // '0' - '9'
  36164. } else {
  36165. return (c - 48) & 0xf;
  36166. }
  36167. }
  36168. function parseHexByte (string, lowerBound, index) {
  36169. var r = parseHex4Bits(string, index);
  36170. if (index - 1 >= lowerBound) {
  36171. r |= parseHex4Bits(string, index - 1) << 4;
  36172. }
  36173. return r;
  36174. }
  36175. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  36176. // Create possibly bigger array to ensure that it fits the number
  36177. this.length = Math.ceil((number.length - start) / 6);
  36178. this.words = new Array(this.length);
  36179. for (var i = 0; i < this.length; i++) {
  36180. this.words[i] = 0;
  36181. }
  36182. // 24-bits chunks
  36183. var off = 0;
  36184. var j = 0;
  36185. var w;
  36186. if (endian === 'be') {
  36187. for (i = number.length - 1; i >= start; i -= 2) {
  36188. w = parseHexByte(number, start, i) << off;
  36189. this.words[j] |= w & 0x3ffffff;
  36190. if (off >= 18) {
  36191. off -= 18;
  36192. j += 1;
  36193. this.words[j] |= w >>> 26;
  36194. } else {
  36195. off += 8;
  36196. }
  36197. }
  36198. } else {
  36199. var parseLength = number.length - start;
  36200. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  36201. w = parseHexByte(number, start, i) << off;
  36202. this.words[j] |= w & 0x3ffffff;
  36203. if (off >= 18) {
  36204. off -= 18;
  36205. j += 1;
  36206. this.words[j] |= w >>> 26;
  36207. } else {
  36208. off += 8;
  36209. }
  36210. }
  36211. }
  36212. this.strip();
  36213. };
  36214. function parseBase (str, start, end, mul) {
  36215. var r = 0;
  36216. var len = Math.min(str.length, end);
  36217. for (var i = start; i < len; i++) {
  36218. var c = str.charCodeAt(i) - 48;
  36219. r *= mul;
  36220. // 'a'
  36221. if (c >= 49) {
  36222. r += c - 49 + 0xa;
  36223. // 'A'
  36224. } else if (c >= 17) {
  36225. r += c - 17 + 0xa;
  36226. // '0' - '9'
  36227. } else {
  36228. r += c;
  36229. }
  36230. }
  36231. return r;
  36232. }
  36233. BN.prototype._parseBase = function _parseBase (number, base, start) {
  36234. // Initialize as zero
  36235. this.words = [ 0 ];
  36236. this.length = 1;
  36237. // Find length of limb in base
  36238. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  36239. limbLen++;
  36240. }
  36241. limbLen--;
  36242. limbPow = (limbPow / base) | 0;
  36243. var total = number.length - start;
  36244. var mod = total % limbLen;
  36245. var end = Math.min(total, total - mod) + start;
  36246. var word = 0;
  36247. for (var i = start; i < end; i += limbLen) {
  36248. word = parseBase(number, i, i + limbLen, base);
  36249. this.imuln(limbPow);
  36250. if (this.words[0] + word < 0x4000000) {
  36251. this.words[0] += word;
  36252. } else {
  36253. this._iaddn(word);
  36254. }
  36255. }
  36256. if (mod !== 0) {
  36257. var pow = 1;
  36258. word = parseBase(number, i, number.length, base);
  36259. for (i = 0; i < mod; i++) {
  36260. pow *= base;
  36261. }
  36262. this.imuln(pow);
  36263. if (this.words[0] + word < 0x4000000) {
  36264. this.words[0] += word;
  36265. } else {
  36266. this._iaddn(word);
  36267. }
  36268. }
  36269. this.strip();
  36270. };
  36271. BN.prototype.copy = function copy (dest) {
  36272. dest.words = new Array(this.length);
  36273. for (var i = 0; i < this.length; i++) {
  36274. dest.words[i] = this.words[i];
  36275. }
  36276. dest.length = this.length;
  36277. dest.negative = this.negative;
  36278. dest.red = this.red;
  36279. };
  36280. BN.prototype.clone = function clone () {
  36281. var r = new BN(null);
  36282. this.copy(r);
  36283. return r;
  36284. };
  36285. BN.prototype._expand = function _expand (size) {
  36286. while (this.length < size) {
  36287. this.words[this.length++] = 0;
  36288. }
  36289. return this;
  36290. };
  36291. // Remove leading `0` from `this`
  36292. BN.prototype.strip = function strip () {
  36293. while (this.length > 1 && this.words[this.length - 1] === 0) {
  36294. this.length--;
  36295. }
  36296. return this._normSign();
  36297. };
  36298. BN.prototype._normSign = function _normSign () {
  36299. // -0 = 0
  36300. if (this.length === 1 && this.words[0] === 0) {
  36301. this.negative = 0;
  36302. }
  36303. return this;
  36304. };
  36305. BN.prototype.inspect = function inspect () {
  36306. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  36307. };
  36308. /*
  36309. var zeros = [];
  36310. var groupSizes = [];
  36311. var groupBases = [];
  36312. var s = '';
  36313. var i = -1;
  36314. while (++i < BN.wordSize) {
  36315. zeros[i] = s;
  36316. s += '0';
  36317. }
  36318. groupSizes[0] = 0;
  36319. groupSizes[1] = 0;
  36320. groupBases[0] = 0;
  36321. groupBases[1] = 0;
  36322. var base = 2 - 1;
  36323. while (++base < 36 + 1) {
  36324. var groupSize = 0;
  36325. var groupBase = 1;
  36326. while (groupBase < (1 << BN.wordSize) / base) {
  36327. groupBase *= base;
  36328. groupSize += 1;
  36329. }
  36330. groupSizes[base] = groupSize;
  36331. groupBases[base] = groupBase;
  36332. }
  36333. */
  36334. var zeros = [
  36335. '',
  36336. '0',
  36337. '00',
  36338. '000',
  36339. '0000',
  36340. '00000',
  36341. '000000',
  36342. '0000000',
  36343. '00000000',
  36344. '000000000',
  36345. '0000000000',
  36346. '00000000000',
  36347. '000000000000',
  36348. '0000000000000',
  36349. '00000000000000',
  36350. '000000000000000',
  36351. '0000000000000000',
  36352. '00000000000000000',
  36353. '000000000000000000',
  36354. '0000000000000000000',
  36355. '00000000000000000000',
  36356. '000000000000000000000',
  36357. '0000000000000000000000',
  36358. '00000000000000000000000',
  36359. '000000000000000000000000',
  36360. '0000000000000000000000000'
  36361. ];
  36362. var groupSizes = [
  36363. 0, 0,
  36364. 25, 16, 12, 11, 10, 9, 8,
  36365. 8, 7, 7, 7, 7, 6, 6,
  36366. 6, 6, 6, 6, 6, 5, 5,
  36367. 5, 5, 5, 5, 5, 5, 5,
  36368. 5, 5, 5, 5, 5, 5, 5
  36369. ];
  36370. var groupBases = [
  36371. 0, 0,
  36372. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  36373. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  36374. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  36375. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  36376. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  36377. ];
  36378. BN.prototype.toString = function toString (base, padding) {
  36379. base = base || 10;
  36380. padding = padding | 0 || 1;
  36381. var out;
  36382. if (base === 16 || base === 'hex') {
  36383. out = '';
  36384. var off = 0;
  36385. var carry = 0;
  36386. for (var i = 0; i < this.length; i++) {
  36387. var w = this.words[i];
  36388. var word = (((w << off) | carry) & 0xffffff).toString(16);
  36389. carry = (w >>> (24 - off)) & 0xffffff;
  36390. if (carry !== 0 || i !== this.length - 1) {
  36391. out = zeros[6 - word.length] + word + out;
  36392. } else {
  36393. out = word + out;
  36394. }
  36395. off += 2;
  36396. if (off >= 26) {
  36397. off -= 26;
  36398. i--;
  36399. }
  36400. }
  36401. if (carry !== 0) {
  36402. out = carry.toString(16) + out;
  36403. }
  36404. while (out.length % padding !== 0) {
  36405. out = '0' + out;
  36406. }
  36407. if (this.negative !== 0) {
  36408. out = '-' + out;
  36409. }
  36410. return out;
  36411. }
  36412. if (base === (base | 0) && base >= 2 && base <= 36) {
  36413. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  36414. var groupSize = groupSizes[base];
  36415. // var groupBase = Math.pow(base, groupSize);
  36416. var groupBase = groupBases[base];
  36417. out = '';
  36418. var c = this.clone();
  36419. c.negative = 0;
  36420. while (!c.isZero()) {
  36421. var r = c.modn(groupBase).toString(base);
  36422. c = c.idivn(groupBase);
  36423. if (!c.isZero()) {
  36424. out = zeros[groupSize - r.length] + r + out;
  36425. } else {
  36426. out = r + out;
  36427. }
  36428. }
  36429. if (this.isZero()) {
  36430. out = '0' + out;
  36431. }
  36432. while (out.length % padding !== 0) {
  36433. out = '0' + out;
  36434. }
  36435. if (this.negative !== 0) {
  36436. out = '-' + out;
  36437. }
  36438. return out;
  36439. }
  36440. assert(false, 'Base should be between 2 and 36');
  36441. };
  36442. BN.prototype.toNumber = function toNumber () {
  36443. var ret = this.words[0];
  36444. if (this.length === 2) {
  36445. ret += this.words[1] * 0x4000000;
  36446. } else if (this.length === 3 && this.words[2] === 0x01) {
  36447. // NOTE: at this stage it is known that the top bit is set
  36448. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  36449. } else if (this.length > 2) {
  36450. assert(false, 'Number can only safely store up to 53 bits');
  36451. }
  36452. return (this.negative !== 0) ? -ret : ret;
  36453. };
  36454. BN.prototype.toJSON = function toJSON () {
  36455. return this.toString(16);
  36456. };
  36457. BN.prototype.toBuffer = function toBuffer (endian, length) {
  36458. assert(typeof Buffer !== 'undefined');
  36459. return this.toArrayLike(Buffer, endian, length);
  36460. };
  36461. BN.prototype.toArray = function toArray (endian, length) {
  36462. return this.toArrayLike(Array, endian, length);
  36463. };
  36464. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  36465. var byteLength = this.byteLength();
  36466. var reqLength = length || Math.max(1, byteLength);
  36467. assert(byteLength <= reqLength, 'byte array longer than desired length');
  36468. assert(reqLength > 0, 'Requested array length <= 0');
  36469. this.strip();
  36470. var littleEndian = endian === 'le';
  36471. var res = new ArrayType(reqLength);
  36472. var b, i;
  36473. var q = this.clone();
  36474. if (!littleEndian) {
  36475. // Assume big-endian
  36476. for (i = 0; i < reqLength - byteLength; i++) {
  36477. res[i] = 0;
  36478. }
  36479. for (i = 0; !q.isZero(); i++) {
  36480. b = q.andln(0xff);
  36481. q.iushrn(8);
  36482. res[reqLength - i - 1] = b;
  36483. }
  36484. } else {
  36485. for (i = 0; !q.isZero(); i++) {
  36486. b = q.andln(0xff);
  36487. q.iushrn(8);
  36488. res[i] = b;
  36489. }
  36490. for (; i < reqLength; i++) {
  36491. res[i] = 0;
  36492. }
  36493. }
  36494. return res;
  36495. };
  36496. if (Math.clz32) {
  36497. BN.prototype._countBits = function _countBits (w) {
  36498. return 32 - Math.clz32(w);
  36499. };
  36500. } else {
  36501. BN.prototype._countBits = function _countBits (w) {
  36502. var t = w;
  36503. var r = 0;
  36504. if (t >= 0x1000) {
  36505. r += 13;
  36506. t >>>= 13;
  36507. }
  36508. if (t >= 0x40) {
  36509. r += 7;
  36510. t >>>= 7;
  36511. }
  36512. if (t >= 0x8) {
  36513. r += 4;
  36514. t >>>= 4;
  36515. }
  36516. if (t >= 0x02) {
  36517. r += 2;
  36518. t >>>= 2;
  36519. }
  36520. return r + t;
  36521. };
  36522. }
  36523. BN.prototype._zeroBits = function _zeroBits (w) {
  36524. // Short-cut
  36525. if (w === 0) return 26;
  36526. var t = w;
  36527. var r = 0;
  36528. if ((t & 0x1fff) === 0) {
  36529. r += 13;
  36530. t >>>= 13;
  36531. }
  36532. if ((t & 0x7f) === 0) {
  36533. r += 7;
  36534. t >>>= 7;
  36535. }
  36536. if ((t & 0xf) === 0) {
  36537. r += 4;
  36538. t >>>= 4;
  36539. }
  36540. if ((t & 0x3) === 0) {
  36541. r += 2;
  36542. t >>>= 2;
  36543. }
  36544. if ((t & 0x1) === 0) {
  36545. r++;
  36546. }
  36547. return r;
  36548. };
  36549. // Return number of used bits in a BN
  36550. BN.prototype.bitLength = function bitLength () {
  36551. var w = this.words[this.length - 1];
  36552. var hi = this._countBits(w);
  36553. return (this.length - 1) * 26 + hi;
  36554. };
  36555. function toBitArray (num) {
  36556. var w = new Array(num.bitLength());
  36557. for (var bit = 0; bit < w.length; bit++) {
  36558. var off = (bit / 26) | 0;
  36559. var wbit = bit % 26;
  36560. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  36561. }
  36562. return w;
  36563. }
  36564. // Number of trailing zero bits
  36565. BN.prototype.zeroBits = function zeroBits () {
  36566. if (this.isZero()) return 0;
  36567. var r = 0;
  36568. for (var i = 0; i < this.length; i++) {
  36569. var b = this._zeroBits(this.words[i]);
  36570. r += b;
  36571. if (b !== 26) break;
  36572. }
  36573. return r;
  36574. };
  36575. BN.prototype.byteLength = function byteLength () {
  36576. return Math.ceil(this.bitLength() / 8);
  36577. };
  36578. BN.prototype.toTwos = function toTwos (width) {
  36579. if (this.negative !== 0) {
  36580. return this.abs().inotn(width).iaddn(1);
  36581. }
  36582. return this.clone();
  36583. };
  36584. BN.prototype.fromTwos = function fromTwos (width) {
  36585. if (this.testn(width - 1)) {
  36586. return this.notn(width).iaddn(1).ineg();
  36587. }
  36588. return this.clone();
  36589. };
  36590. BN.prototype.isNeg = function isNeg () {
  36591. return this.negative !== 0;
  36592. };
  36593. // Return negative clone of `this`
  36594. BN.prototype.neg = function neg () {
  36595. return this.clone().ineg();
  36596. };
  36597. BN.prototype.ineg = function ineg () {
  36598. if (!this.isZero()) {
  36599. this.negative ^= 1;
  36600. }
  36601. return this;
  36602. };
  36603. // Or `num` with `this` in-place
  36604. BN.prototype.iuor = function iuor (num) {
  36605. while (this.length < num.length) {
  36606. this.words[this.length++] = 0;
  36607. }
  36608. for (var i = 0; i < num.length; i++) {
  36609. this.words[i] = this.words[i] | num.words[i];
  36610. }
  36611. return this.strip();
  36612. };
  36613. BN.prototype.ior = function ior (num) {
  36614. assert((this.negative | num.negative) === 0);
  36615. return this.iuor(num);
  36616. };
  36617. // Or `num` with `this`
  36618. BN.prototype.or = function or (num) {
  36619. if (this.length > num.length) return this.clone().ior(num);
  36620. return num.clone().ior(this);
  36621. };
  36622. BN.prototype.uor = function uor (num) {
  36623. if (this.length > num.length) return this.clone().iuor(num);
  36624. return num.clone().iuor(this);
  36625. };
  36626. // And `num` with `this` in-place
  36627. BN.prototype.iuand = function iuand (num) {
  36628. // b = min-length(num, this)
  36629. var b;
  36630. if (this.length > num.length) {
  36631. b = num;
  36632. } else {
  36633. b = this;
  36634. }
  36635. for (var i = 0; i < b.length; i++) {
  36636. this.words[i] = this.words[i] & num.words[i];
  36637. }
  36638. this.length = b.length;
  36639. return this.strip();
  36640. };
  36641. BN.prototype.iand = function iand (num) {
  36642. assert((this.negative | num.negative) === 0);
  36643. return this.iuand(num);
  36644. };
  36645. // And `num` with `this`
  36646. BN.prototype.and = function and (num) {
  36647. if (this.length > num.length) return this.clone().iand(num);
  36648. return num.clone().iand(this);
  36649. };
  36650. BN.prototype.uand = function uand (num) {
  36651. if (this.length > num.length) return this.clone().iuand(num);
  36652. return num.clone().iuand(this);
  36653. };
  36654. // Xor `num` with `this` in-place
  36655. BN.prototype.iuxor = function iuxor (num) {
  36656. // a.length > b.length
  36657. var a;
  36658. var b;
  36659. if (this.length > num.length) {
  36660. a = this;
  36661. b = num;
  36662. } else {
  36663. a = num;
  36664. b = this;
  36665. }
  36666. for (var i = 0; i < b.length; i++) {
  36667. this.words[i] = a.words[i] ^ b.words[i];
  36668. }
  36669. if (this !== a) {
  36670. for (; i < a.length; i++) {
  36671. this.words[i] = a.words[i];
  36672. }
  36673. }
  36674. this.length = a.length;
  36675. return this.strip();
  36676. };
  36677. BN.prototype.ixor = function ixor (num) {
  36678. assert((this.negative | num.negative) === 0);
  36679. return this.iuxor(num);
  36680. };
  36681. // Xor `num` with `this`
  36682. BN.prototype.xor = function xor (num) {
  36683. if (this.length > num.length) return this.clone().ixor(num);
  36684. return num.clone().ixor(this);
  36685. };
  36686. BN.prototype.uxor = function uxor (num) {
  36687. if (this.length > num.length) return this.clone().iuxor(num);
  36688. return num.clone().iuxor(this);
  36689. };
  36690. // Not ``this`` with ``width`` bitwidth
  36691. BN.prototype.inotn = function inotn (width) {
  36692. assert(typeof width === 'number' && width >= 0);
  36693. var bytesNeeded = Math.ceil(width / 26) | 0;
  36694. var bitsLeft = width % 26;
  36695. // Extend the buffer with leading zeroes
  36696. this._expand(bytesNeeded);
  36697. if (bitsLeft > 0) {
  36698. bytesNeeded--;
  36699. }
  36700. // Handle complete words
  36701. for (var i = 0; i < bytesNeeded; i++) {
  36702. this.words[i] = ~this.words[i] & 0x3ffffff;
  36703. }
  36704. // Handle the residue
  36705. if (bitsLeft > 0) {
  36706. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  36707. }
  36708. // And remove leading zeroes
  36709. return this.strip();
  36710. };
  36711. BN.prototype.notn = function notn (width) {
  36712. return this.clone().inotn(width);
  36713. };
  36714. // Set `bit` of `this`
  36715. BN.prototype.setn = function setn (bit, val) {
  36716. assert(typeof bit === 'number' && bit >= 0);
  36717. var off = (bit / 26) | 0;
  36718. var wbit = bit % 26;
  36719. this._expand(off + 1);
  36720. if (val) {
  36721. this.words[off] = this.words[off] | (1 << wbit);
  36722. } else {
  36723. this.words[off] = this.words[off] & ~(1 << wbit);
  36724. }
  36725. return this.strip();
  36726. };
  36727. // Add `num` to `this` in-place
  36728. BN.prototype.iadd = function iadd (num) {
  36729. var r;
  36730. // negative + positive
  36731. if (this.negative !== 0 && num.negative === 0) {
  36732. this.negative = 0;
  36733. r = this.isub(num);
  36734. this.negative ^= 1;
  36735. return this._normSign();
  36736. // positive + negative
  36737. } else if (this.negative === 0 && num.negative !== 0) {
  36738. num.negative = 0;
  36739. r = this.isub(num);
  36740. num.negative = 1;
  36741. return r._normSign();
  36742. }
  36743. // a.length > b.length
  36744. var a, b;
  36745. if (this.length > num.length) {
  36746. a = this;
  36747. b = num;
  36748. } else {
  36749. a = num;
  36750. b = this;
  36751. }
  36752. var carry = 0;
  36753. for (var i = 0; i < b.length; i++) {
  36754. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  36755. this.words[i] = r & 0x3ffffff;
  36756. carry = r >>> 26;
  36757. }
  36758. for (; carry !== 0 && i < a.length; i++) {
  36759. r = (a.words[i] | 0) + carry;
  36760. this.words[i] = r & 0x3ffffff;
  36761. carry = r >>> 26;
  36762. }
  36763. this.length = a.length;
  36764. if (carry !== 0) {
  36765. this.words[this.length] = carry;
  36766. this.length++;
  36767. // Copy the rest of the words
  36768. } else if (a !== this) {
  36769. for (; i < a.length; i++) {
  36770. this.words[i] = a.words[i];
  36771. }
  36772. }
  36773. return this;
  36774. };
  36775. // Add `num` to `this`
  36776. BN.prototype.add = function add (num) {
  36777. var res;
  36778. if (num.negative !== 0 && this.negative === 0) {
  36779. num.negative = 0;
  36780. res = this.sub(num);
  36781. num.negative ^= 1;
  36782. return res;
  36783. } else if (num.negative === 0 && this.negative !== 0) {
  36784. this.negative = 0;
  36785. res = num.sub(this);
  36786. this.negative = 1;
  36787. return res;
  36788. }
  36789. if (this.length > num.length) return this.clone().iadd(num);
  36790. return num.clone().iadd(this);
  36791. };
  36792. // Subtract `num` from `this` in-place
  36793. BN.prototype.isub = function isub (num) {
  36794. // this - (-num) = this + num
  36795. if (num.negative !== 0) {
  36796. num.negative = 0;
  36797. var r = this.iadd(num);
  36798. num.negative = 1;
  36799. return r._normSign();
  36800. // -this - num = -(this + num)
  36801. } else if (this.negative !== 0) {
  36802. this.negative = 0;
  36803. this.iadd(num);
  36804. this.negative = 1;
  36805. return this._normSign();
  36806. }
  36807. // At this point both numbers are positive
  36808. var cmp = this.cmp(num);
  36809. // Optimization - zeroify
  36810. if (cmp === 0) {
  36811. this.negative = 0;
  36812. this.length = 1;
  36813. this.words[0] = 0;
  36814. return this;
  36815. }
  36816. // a > b
  36817. var a, b;
  36818. if (cmp > 0) {
  36819. a = this;
  36820. b = num;
  36821. } else {
  36822. a = num;
  36823. b = this;
  36824. }
  36825. var carry = 0;
  36826. for (var i = 0; i < b.length; i++) {
  36827. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  36828. carry = r >> 26;
  36829. this.words[i] = r & 0x3ffffff;
  36830. }
  36831. for (; carry !== 0 && i < a.length; i++) {
  36832. r = (a.words[i] | 0) + carry;
  36833. carry = r >> 26;
  36834. this.words[i] = r & 0x3ffffff;
  36835. }
  36836. // Copy rest of the words
  36837. if (carry === 0 && i < a.length && a !== this) {
  36838. for (; i < a.length; i++) {
  36839. this.words[i] = a.words[i];
  36840. }
  36841. }
  36842. this.length = Math.max(this.length, i);
  36843. if (a !== this) {
  36844. this.negative = 1;
  36845. }
  36846. return this.strip();
  36847. };
  36848. // Subtract `num` from `this`
  36849. BN.prototype.sub = function sub (num) {
  36850. return this.clone().isub(num);
  36851. };
  36852. function smallMulTo (self, num, out) {
  36853. out.negative = num.negative ^ self.negative;
  36854. var len = (self.length + num.length) | 0;
  36855. out.length = len;
  36856. len = (len - 1) | 0;
  36857. // Peel one iteration (compiler can't do it, because of code complexity)
  36858. var a = self.words[0] | 0;
  36859. var b = num.words[0] | 0;
  36860. var r = a * b;
  36861. var lo = r & 0x3ffffff;
  36862. var carry = (r / 0x4000000) | 0;
  36863. out.words[0] = lo;
  36864. for (var k = 1; k < len; k++) {
  36865. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  36866. // note that ncarry could be >= 0x3ffffff
  36867. var ncarry = carry >>> 26;
  36868. var rword = carry & 0x3ffffff;
  36869. var maxJ = Math.min(k, num.length - 1);
  36870. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  36871. var i = (k - j) | 0;
  36872. a = self.words[i] | 0;
  36873. b = num.words[j] | 0;
  36874. r = a * b + rword;
  36875. ncarry += (r / 0x4000000) | 0;
  36876. rword = r & 0x3ffffff;
  36877. }
  36878. out.words[k] = rword | 0;
  36879. carry = ncarry | 0;
  36880. }
  36881. if (carry !== 0) {
  36882. out.words[k] = carry | 0;
  36883. } else {
  36884. out.length--;
  36885. }
  36886. return out.strip();
  36887. }
  36888. // TODO(indutny): it may be reasonable to omit it for users who don't need
  36889. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  36890. // multiplication (like elliptic secp256k1).
  36891. var comb10MulTo = function comb10MulTo (self, num, out) {
  36892. var a = self.words;
  36893. var b = num.words;
  36894. var o = out.words;
  36895. var c = 0;
  36896. var lo;
  36897. var mid;
  36898. var hi;
  36899. var a0 = a[0] | 0;
  36900. var al0 = a0 & 0x1fff;
  36901. var ah0 = a0 >>> 13;
  36902. var a1 = a[1] | 0;
  36903. var al1 = a1 & 0x1fff;
  36904. var ah1 = a1 >>> 13;
  36905. var a2 = a[2] | 0;
  36906. var al2 = a2 & 0x1fff;
  36907. var ah2 = a2 >>> 13;
  36908. var a3 = a[3] | 0;
  36909. var al3 = a3 & 0x1fff;
  36910. var ah3 = a3 >>> 13;
  36911. var a4 = a[4] | 0;
  36912. var al4 = a4 & 0x1fff;
  36913. var ah4 = a4 >>> 13;
  36914. var a5 = a[5] | 0;
  36915. var al5 = a5 & 0x1fff;
  36916. var ah5 = a5 >>> 13;
  36917. var a6 = a[6] | 0;
  36918. var al6 = a6 & 0x1fff;
  36919. var ah6 = a6 >>> 13;
  36920. var a7 = a[7] | 0;
  36921. var al7 = a7 & 0x1fff;
  36922. var ah7 = a7 >>> 13;
  36923. var a8 = a[8] | 0;
  36924. var al8 = a8 & 0x1fff;
  36925. var ah8 = a8 >>> 13;
  36926. var a9 = a[9] | 0;
  36927. var al9 = a9 & 0x1fff;
  36928. var ah9 = a9 >>> 13;
  36929. var b0 = b[0] | 0;
  36930. var bl0 = b0 & 0x1fff;
  36931. var bh0 = b0 >>> 13;
  36932. var b1 = b[1] | 0;
  36933. var bl1 = b1 & 0x1fff;
  36934. var bh1 = b1 >>> 13;
  36935. var b2 = b[2] | 0;
  36936. var bl2 = b2 & 0x1fff;
  36937. var bh2 = b2 >>> 13;
  36938. var b3 = b[3] | 0;
  36939. var bl3 = b3 & 0x1fff;
  36940. var bh3 = b3 >>> 13;
  36941. var b4 = b[4] | 0;
  36942. var bl4 = b4 & 0x1fff;
  36943. var bh4 = b4 >>> 13;
  36944. var b5 = b[5] | 0;
  36945. var bl5 = b5 & 0x1fff;
  36946. var bh5 = b5 >>> 13;
  36947. var b6 = b[6] | 0;
  36948. var bl6 = b6 & 0x1fff;
  36949. var bh6 = b6 >>> 13;
  36950. var b7 = b[7] | 0;
  36951. var bl7 = b7 & 0x1fff;
  36952. var bh7 = b7 >>> 13;
  36953. var b8 = b[8] | 0;
  36954. var bl8 = b8 & 0x1fff;
  36955. var bh8 = b8 >>> 13;
  36956. var b9 = b[9] | 0;
  36957. var bl9 = b9 & 0x1fff;
  36958. var bh9 = b9 >>> 13;
  36959. out.negative = self.negative ^ num.negative;
  36960. out.length = 19;
  36961. /* k = 0 */
  36962. lo = Math.imul(al0, bl0);
  36963. mid = Math.imul(al0, bh0);
  36964. mid = (mid + Math.imul(ah0, bl0)) | 0;
  36965. hi = Math.imul(ah0, bh0);
  36966. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  36967. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  36968. w0 &= 0x3ffffff;
  36969. /* k = 1 */
  36970. lo = Math.imul(al1, bl0);
  36971. mid = Math.imul(al1, bh0);
  36972. mid = (mid + Math.imul(ah1, bl0)) | 0;
  36973. hi = Math.imul(ah1, bh0);
  36974. lo = (lo + Math.imul(al0, bl1)) | 0;
  36975. mid = (mid + Math.imul(al0, bh1)) | 0;
  36976. mid = (mid + Math.imul(ah0, bl1)) | 0;
  36977. hi = (hi + Math.imul(ah0, bh1)) | 0;
  36978. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  36979. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  36980. w1 &= 0x3ffffff;
  36981. /* k = 2 */
  36982. lo = Math.imul(al2, bl0);
  36983. mid = Math.imul(al2, bh0);
  36984. mid = (mid + Math.imul(ah2, bl0)) | 0;
  36985. hi = Math.imul(ah2, bh0);
  36986. lo = (lo + Math.imul(al1, bl1)) | 0;
  36987. mid = (mid + Math.imul(al1, bh1)) | 0;
  36988. mid = (mid + Math.imul(ah1, bl1)) | 0;
  36989. hi = (hi + Math.imul(ah1, bh1)) | 0;
  36990. lo = (lo + Math.imul(al0, bl2)) | 0;
  36991. mid = (mid + Math.imul(al0, bh2)) | 0;
  36992. mid = (mid + Math.imul(ah0, bl2)) | 0;
  36993. hi = (hi + Math.imul(ah0, bh2)) | 0;
  36994. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  36995. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  36996. w2 &= 0x3ffffff;
  36997. /* k = 3 */
  36998. lo = Math.imul(al3, bl0);
  36999. mid = Math.imul(al3, bh0);
  37000. mid = (mid + Math.imul(ah3, bl0)) | 0;
  37001. hi = Math.imul(ah3, bh0);
  37002. lo = (lo + Math.imul(al2, bl1)) | 0;
  37003. mid = (mid + Math.imul(al2, bh1)) | 0;
  37004. mid = (mid + Math.imul(ah2, bl1)) | 0;
  37005. hi = (hi + Math.imul(ah2, bh1)) | 0;
  37006. lo = (lo + Math.imul(al1, bl2)) | 0;
  37007. mid = (mid + Math.imul(al1, bh2)) | 0;
  37008. mid = (mid + Math.imul(ah1, bl2)) | 0;
  37009. hi = (hi + Math.imul(ah1, bh2)) | 0;
  37010. lo = (lo + Math.imul(al0, bl3)) | 0;
  37011. mid = (mid + Math.imul(al0, bh3)) | 0;
  37012. mid = (mid + Math.imul(ah0, bl3)) | 0;
  37013. hi = (hi + Math.imul(ah0, bh3)) | 0;
  37014. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37015. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  37016. w3 &= 0x3ffffff;
  37017. /* k = 4 */
  37018. lo = Math.imul(al4, bl0);
  37019. mid = Math.imul(al4, bh0);
  37020. mid = (mid + Math.imul(ah4, bl0)) | 0;
  37021. hi = Math.imul(ah4, bh0);
  37022. lo = (lo + Math.imul(al3, bl1)) | 0;
  37023. mid = (mid + Math.imul(al3, bh1)) | 0;
  37024. mid = (mid + Math.imul(ah3, bl1)) | 0;
  37025. hi = (hi + Math.imul(ah3, bh1)) | 0;
  37026. lo = (lo + Math.imul(al2, bl2)) | 0;
  37027. mid = (mid + Math.imul(al2, bh2)) | 0;
  37028. mid = (mid + Math.imul(ah2, bl2)) | 0;
  37029. hi = (hi + Math.imul(ah2, bh2)) | 0;
  37030. lo = (lo + Math.imul(al1, bl3)) | 0;
  37031. mid = (mid + Math.imul(al1, bh3)) | 0;
  37032. mid = (mid + Math.imul(ah1, bl3)) | 0;
  37033. hi = (hi + Math.imul(ah1, bh3)) | 0;
  37034. lo = (lo + Math.imul(al0, bl4)) | 0;
  37035. mid = (mid + Math.imul(al0, bh4)) | 0;
  37036. mid = (mid + Math.imul(ah0, bl4)) | 0;
  37037. hi = (hi + Math.imul(ah0, bh4)) | 0;
  37038. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37039. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  37040. w4 &= 0x3ffffff;
  37041. /* k = 5 */
  37042. lo = Math.imul(al5, bl0);
  37043. mid = Math.imul(al5, bh0);
  37044. mid = (mid + Math.imul(ah5, bl0)) | 0;
  37045. hi = Math.imul(ah5, bh0);
  37046. lo = (lo + Math.imul(al4, bl1)) | 0;
  37047. mid = (mid + Math.imul(al4, bh1)) | 0;
  37048. mid = (mid + Math.imul(ah4, bl1)) | 0;
  37049. hi = (hi + Math.imul(ah4, bh1)) | 0;
  37050. lo = (lo + Math.imul(al3, bl2)) | 0;
  37051. mid = (mid + Math.imul(al3, bh2)) | 0;
  37052. mid = (mid + Math.imul(ah3, bl2)) | 0;
  37053. hi = (hi + Math.imul(ah3, bh2)) | 0;
  37054. lo = (lo + Math.imul(al2, bl3)) | 0;
  37055. mid = (mid + Math.imul(al2, bh3)) | 0;
  37056. mid = (mid + Math.imul(ah2, bl3)) | 0;
  37057. hi = (hi + Math.imul(ah2, bh3)) | 0;
  37058. lo = (lo + Math.imul(al1, bl4)) | 0;
  37059. mid = (mid + Math.imul(al1, bh4)) | 0;
  37060. mid = (mid + Math.imul(ah1, bl4)) | 0;
  37061. hi = (hi + Math.imul(ah1, bh4)) | 0;
  37062. lo = (lo + Math.imul(al0, bl5)) | 0;
  37063. mid = (mid + Math.imul(al0, bh5)) | 0;
  37064. mid = (mid + Math.imul(ah0, bl5)) | 0;
  37065. hi = (hi + Math.imul(ah0, bh5)) | 0;
  37066. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37067. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  37068. w5 &= 0x3ffffff;
  37069. /* k = 6 */
  37070. lo = Math.imul(al6, bl0);
  37071. mid = Math.imul(al6, bh0);
  37072. mid = (mid + Math.imul(ah6, bl0)) | 0;
  37073. hi = Math.imul(ah6, bh0);
  37074. lo = (lo + Math.imul(al5, bl1)) | 0;
  37075. mid = (mid + Math.imul(al5, bh1)) | 0;
  37076. mid = (mid + Math.imul(ah5, bl1)) | 0;
  37077. hi = (hi + Math.imul(ah5, bh1)) | 0;
  37078. lo = (lo + Math.imul(al4, bl2)) | 0;
  37079. mid = (mid + Math.imul(al4, bh2)) | 0;
  37080. mid = (mid + Math.imul(ah4, bl2)) | 0;
  37081. hi = (hi + Math.imul(ah4, bh2)) | 0;
  37082. lo = (lo + Math.imul(al3, bl3)) | 0;
  37083. mid = (mid + Math.imul(al3, bh3)) | 0;
  37084. mid = (mid + Math.imul(ah3, bl3)) | 0;
  37085. hi = (hi + Math.imul(ah3, bh3)) | 0;
  37086. lo = (lo + Math.imul(al2, bl4)) | 0;
  37087. mid = (mid + Math.imul(al2, bh4)) | 0;
  37088. mid = (mid + Math.imul(ah2, bl4)) | 0;
  37089. hi = (hi + Math.imul(ah2, bh4)) | 0;
  37090. lo = (lo + Math.imul(al1, bl5)) | 0;
  37091. mid = (mid + Math.imul(al1, bh5)) | 0;
  37092. mid = (mid + Math.imul(ah1, bl5)) | 0;
  37093. hi = (hi + Math.imul(ah1, bh5)) | 0;
  37094. lo = (lo + Math.imul(al0, bl6)) | 0;
  37095. mid = (mid + Math.imul(al0, bh6)) | 0;
  37096. mid = (mid + Math.imul(ah0, bl6)) | 0;
  37097. hi = (hi + Math.imul(ah0, bh6)) | 0;
  37098. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37099. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  37100. w6 &= 0x3ffffff;
  37101. /* k = 7 */
  37102. lo = Math.imul(al7, bl0);
  37103. mid = Math.imul(al7, bh0);
  37104. mid = (mid + Math.imul(ah7, bl0)) | 0;
  37105. hi = Math.imul(ah7, bh0);
  37106. lo = (lo + Math.imul(al6, bl1)) | 0;
  37107. mid = (mid + Math.imul(al6, bh1)) | 0;
  37108. mid = (mid + Math.imul(ah6, bl1)) | 0;
  37109. hi = (hi + Math.imul(ah6, bh1)) | 0;
  37110. lo = (lo + Math.imul(al5, bl2)) | 0;
  37111. mid = (mid + Math.imul(al5, bh2)) | 0;
  37112. mid = (mid + Math.imul(ah5, bl2)) | 0;
  37113. hi = (hi + Math.imul(ah5, bh2)) | 0;
  37114. lo = (lo + Math.imul(al4, bl3)) | 0;
  37115. mid = (mid + Math.imul(al4, bh3)) | 0;
  37116. mid = (mid + Math.imul(ah4, bl3)) | 0;
  37117. hi = (hi + Math.imul(ah4, bh3)) | 0;
  37118. lo = (lo + Math.imul(al3, bl4)) | 0;
  37119. mid = (mid + Math.imul(al3, bh4)) | 0;
  37120. mid = (mid + Math.imul(ah3, bl4)) | 0;
  37121. hi = (hi + Math.imul(ah3, bh4)) | 0;
  37122. lo = (lo + Math.imul(al2, bl5)) | 0;
  37123. mid = (mid + Math.imul(al2, bh5)) | 0;
  37124. mid = (mid + Math.imul(ah2, bl5)) | 0;
  37125. hi = (hi + Math.imul(ah2, bh5)) | 0;
  37126. lo = (lo + Math.imul(al1, bl6)) | 0;
  37127. mid = (mid + Math.imul(al1, bh6)) | 0;
  37128. mid = (mid + Math.imul(ah1, bl6)) | 0;
  37129. hi = (hi + Math.imul(ah1, bh6)) | 0;
  37130. lo = (lo + Math.imul(al0, bl7)) | 0;
  37131. mid = (mid + Math.imul(al0, bh7)) | 0;
  37132. mid = (mid + Math.imul(ah0, bl7)) | 0;
  37133. hi = (hi + Math.imul(ah0, bh7)) | 0;
  37134. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37135. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  37136. w7 &= 0x3ffffff;
  37137. /* k = 8 */
  37138. lo = Math.imul(al8, bl0);
  37139. mid = Math.imul(al8, bh0);
  37140. mid = (mid + Math.imul(ah8, bl0)) | 0;
  37141. hi = Math.imul(ah8, bh0);
  37142. lo = (lo + Math.imul(al7, bl1)) | 0;
  37143. mid = (mid + Math.imul(al7, bh1)) | 0;
  37144. mid = (mid + Math.imul(ah7, bl1)) | 0;
  37145. hi = (hi + Math.imul(ah7, bh1)) | 0;
  37146. lo = (lo + Math.imul(al6, bl2)) | 0;
  37147. mid = (mid + Math.imul(al6, bh2)) | 0;
  37148. mid = (mid + Math.imul(ah6, bl2)) | 0;
  37149. hi = (hi + Math.imul(ah6, bh2)) | 0;
  37150. lo = (lo + Math.imul(al5, bl3)) | 0;
  37151. mid = (mid + Math.imul(al5, bh3)) | 0;
  37152. mid = (mid + Math.imul(ah5, bl3)) | 0;
  37153. hi = (hi + Math.imul(ah5, bh3)) | 0;
  37154. lo = (lo + Math.imul(al4, bl4)) | 0;
  37155. mid = (mid + Math.imul(al4, bh4)) | 0;
  37156. mid = (mid + Math.imul(ah4, bl4)) | 0;
  37157. hi = (hi + Math.imul(ah4, bh4)) | 0;
  37158. lo = (lo + Math.imul(al3, bl5)) | 0;
  37159. mid = (mid + Math.imul(al3, bh5)) | 0;
  37160. mid = (mid + Math.imul(ah3, bl5)) | 0;
  37161. hi = (hi + Math.imul(ah3, bh5)) | 0;
  37162. lo = (lo + Math.imul(al2, bl6)) | 0;
  37163. mid = (mid + Math.imul(al2, bh6)) | 0;
  37164. mid = (mid + Math.imul(ah2, bl6)) | 0;
  37165. hi = (hi + Math.imul(ah2, bh6)) | 0;
  37166. lo = (lo + Math.imul(al1, bl7)) | 0;
  37167. mid = (mid + Math.imul(al1, bh7)) | 0;
  37168. mid = (mid + Math.imul(ah1, bl7)) | 0;
  37169. hi = (hi + Math.imul(ah1, bh7)) | 0;
  37170. lo = (lo + Math.imul(al0, bl8)) | 0;
  37171. mid = (mid + Math.imul(al0, bh8)) | 0;
  37172. mid = (mid + Math.imul(ah0, bl8)) | 0;
  37173. hi = (hi + Math.imul(ah0, bh8)) | 0;
  37174. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37175. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  37176. w8 &= 0x3ffffff;
  37177. /* k = 9 */
  37178. lo = Math.imul(al9, bl0);
  37179. mid = Math.imul(al9, bh0);
  37180. mid = (mid + Math.imul(ah9, bl0)) | 0;
  37181. hi = Math.imul(ah9, bh0);
  37182. lo = (lo + Math.imul(al8, bl1)) | 0;
  37183. mid = (mid + Math.imul(al8, bh1)) | 0;
  37184. mid = (mid + Math.imul(ah8, bl1)) | 0;
  37185. hi = (hi + Math.imul(ah8, bh1)) | 0;
  37186. lo = (lo + Math.imul(al7, bl2)) | 0;
  37187. mid = (mid + Math.imul(al7, bh2)) | 0;
  37188. mid = (mid + Math.imul(ah7, bl2)) | 0;
  37189. hi = (hi + Math.imul(ah7, bh2)) | 0;
  37190. lo = (lo + Math.imul(al6, bl3)) | 0;
  37191. mid = (mid + Math.imul(al6, bh3)) | 0;
  37192. mid = (mid + Math.imul(ah6, bl3)) | 0;
  37193. hi = (hi + Math.imul(ah6, bh3)) | 0;
  37194. lo = (lo + Math.imul(al5, bl4)) | 0;
  37195. mid = (mid + Math.imul(al5, bh4)) | 0;
  37196. mid = (mid + Math.imul(ah5, bl4)) | 0;
  37197. hi = (hi + Math.imul(ah5, bh4)) | 0;
  37198. lo = (lo + Math.imul(al4, bl5)) | 0;
  37199. mid = (mid + Math.imul(al4, bh5)) | 0;
  37200. mid = (mid + Math.imul(ah4, bl5)) | 0;
  37201. hi = (hi + Math.imul(ah4, bh5)) | 0;
  37202. lo = (lo + Math.imul(al3, bl6)) | 0;
  37203. mid = (mid + Math.imul(al3, bh6)) | 0;
  37204. mid = (mid + Math.imul(ah3, bl6)) | 0;
  37205. hi = (hi + Math.imul(ah3, bh6)) | 0;
  37206. lo = (lo + Math.imul(al2, bl7)) | 0;
  37207. mid = (mid + Math.imul(al2, bh7)) | 0;
  37208. mid = (mid + Math.imul(ah2, bl7)) | 0;
  37209. hi = (hi + Math.imul(ah2, bh7)) | 0;
  37210. lo = (lo + Math.imul(al1, bl8)) | 0;
  37211. mid = (mid + Math.imul(al1, bh8)) | 0;
  37212. mid = (mid + Math.imul(ah1, bl8)) | 0;
  37213. hi = (hi + Math.imul(ah1, bh8)) | 0;
  37214. lo = (lo + Math.imul(al0, bl9)) | 0;
  37215. mid = (mid + Math.imul(al0, bh9)) | 0;
  37216. mid = (mid + Math.imul(ah0, bl9)) | 0;
  37217. hi = (hi + Math.imul(ah0, bh9)) | 0;
  37218. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37219. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  37220. w9 &= 0x3ffffff;
  37221. /* k = 10 */
  37222. lo = Math.imul(al9, bl1);
  37223. mid = Math.imul(al9, bh1);
  37224. mid = (mid + Math.imul(ah9, bl1)) | 0;
  37225. hi = Math.imul(ah9, bh1);
  37226. lo = (lo + Math.imul(al8, bl2)) | 0;
  37227. mid = (mid + Math.imul(al8, bh2)) | 0;
  37228. mid = (mid + Math.imul(ah8, bl2)) | 0;
  37229. hi = (hi + Math.imul(ah8, bh2)) | 0;
  37230. lo = (lo + Math.imul(al7, bl3)) | 0;
  37231. mid = (mid + Math.imul(al7, bh3)) | 0;
  37232. mid = (mid + Math.imul(ah7, bl3)) | 0;
  37233. hi = (hi + Math.imul(ah7, bh3)) | 0;
  37234. lo = (lo + Math.imul(al6, bl4)) | 0;
  37235. mid = (mid + Math.imul(al6, bh4)) | 0;
  37236. mid = (mid + Math.imul(ah6, bl4)) | 0;
  37237. hi = (hi + Math.imul(ah6, bh4)) | 0;
  37238. lo = (lo + Math.imul(al5, bl5)) | 0;
  37239. mid = (mid + Math.imul(al5, bh5)) | 0;
  37240. mid = (mid + Math.imul(ah5, bl5)) | 0;
  37241. hi = (hi + Math.imul(ah5, bh5)) | 0;
  37242. lo = (lo + Math.imul(al4, bl6)) | 0;
  37243. mid = (mid + Math.imul(al4, bh6)) | 0;
  37244. mid = (mid + Math.imul(ah4, bl6)) | 0;
  37245. hi = (hi + Math.imul(ah4, bh6)) | 0;
  37246. lo = (lo + Math.imul(al3, bl7)) | 0;
  37247. mid = (mid + Math.imul(al3, bh7)) | 0;
  37248. mid = (mid + Math.imul(ah3, bl7)) | 0;
  37249. hi = (hi + Math.imul(ah3, bh7)) | 0;
  37250. lo = (lo + Math.imul(al2, bl8)) | 0;
  37251. mid = (mid + Math.imul(al2, bh8)) | 0;
  37252. mid = (mid + Math.imul(ah2, bl8)) | 0;
  37253. hi = (hi + Math.imul(ah2, bh8)) | 0;
  37254. lo = (lo + Math.imul(al1, bl9)) | 0;
  37255. mid = (mid + Math.imul(al1, bh9)) | 0;
  37256. mid = (mid + Math.imul(ah1, bl9)) | 0;
  37257. hi = (hi + Math.imul(ah1, bh9)) | 0;
  37258. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37259. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  37260. w10 &= 0x3ffffff;
  37261. /* k = 11 */
  37262. lo = Math.imul(al9, bl2);
  37263. mid = Math.imul(al9, bh2);
  37264. mid = (mid + Math.imul(ah9, bl2)) | 0;
  37265. hi = Math.imul(ah9, bh2);
  37266. lo = (lo + Math.imul(al8, bl3)) | 0;
  37267. mid = (mid + Math.imul(al8, bh3)) | 0;
  37268. mid = (mid + Math.imul(ah8, bl3)) | 0;
  37269. hi = (hi + Math.imul(ah8, bh3)) | 0;
  37270. lo = (lo + Math.imul(al7, bl4)) | 0;
  37271. mid = (mid + Math.imul(al7, bh4)) | 0;
  37272. mid = (mid + Math.imul(ah7, bl4)) | 0;
  37273. hi = (hi + Math.imul(ah7, bh4)) | 0;
  37274. lo = (lo + Math.imul(al6, bl5)) | 0;
  37275. mid = (mid + Math.imul(al6, bh5)) | 0;
  37276. mid = (mid + Math.imul(ah6, bl5)) | 0;
  37277. hi = (hi + Math.imul(ah6, bh5)) | 0;
  37278. lo = (lo + Math.imul(al5, bl6)) | 0;
  37279. mid = (mid + Math.imul(al5, bh6)) | 0;
  37280. mid = (mid + Math.imul(ah5, bl6)) | 0;
  37281. hi = (hi + Math.imul(ah5, bh6)) | 0;
  37282. lo = (lo + Math.imul(al4, bl7)) | 0;
  37283. mid = (mid + Math.imul(al4, bh7)) | 0;
  37284. mid = (mid + Math.imul(ah4, bl7)) | 0;
  37285. hi = (hi + Math.imul(ah4, bh7)) | 0;
  37286. lo = (lo + Math.imul(al3, bl8)) | 0;
  37287. mid = (mid + Math.imul(al3, bh8)) | 0;
  37288. mid = (mid + Math.imul(ah3, bl8)) | 0;
  37289. hi = (hi + Math.imul(ah3, bh8)) | 0;
  37290. lo = (lo + Math.imul(al2, bl9)) | 0;
  37291. mid = (mid + Math.imul(al2, bh9)) | 0;
  37292. mid = (mid + Math.imul(ah2, bl9)) | 0;
  37293. hi = (hi + Math.imul(ah2, bh9)) | 0;
  37294. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37295. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  37296. w11 &= 0x3ffffff;
  37297. /* k = 12 */
  37298. lo = Math.imul(al9, bl3);
  37299. mid = Math.imul(al9, bh3);
  37300. mid = (mid + Math.imul(ah9, bl3)) | 0;
  37301. hi = Math.imul(ah9, bh3);
  37302. lo = (lo + Math.imul(al8, bl4)) | 0;
  37303. mid = (mid + Math.imul(al8, bh4)) | 0;
  37304. mid = (mid + Math.imul(ah8, bl4)) | 0;
  37305. hi = (hi + Math.imul(ah8, bh4)) | 0;
  37306. lo = (lo + Math.imul(al7, bl5)) | 0;
  37307. mid = (mid + Math.imul(al7, bh5)) | 0;
  37308. mid = (mid + Math.imul(ah7, bl5)) | 0;
  37309. hi = (hi + Math.imul(ah7, bh5)) | 0;
  37310. lo = (lo + Math.imul(al6, bl6)) | 0;
  37311. mid = (mid + Math.imul(al6, bh6)) | 0;
  37312. mid = (mid + Math.imul(ah6, bl6)) | 0;
  37313. hi = (hi + Math.imul(ah6, bh6)) | 0;
  37314. lo = (lo + Math.imul(al5, bl7)) | 0;
  37315. mid = (mid + Math.imul(al5, bh7)) | 0;
  37316. mid = (mid + Math.imul(ah5, bl7)) | 0;
  37317. hi = (hi + Math.imul(ah5, bh7)) | 0;
  37318. lo = (lo + Math.imul(al4, bl8)) | 0;
  37319. mid = (mid + Math.imul(al4, bh8)) | 0;
  37320. mid = (mid + Math.imul(ah4, bl8)) | 0;
  37321. hi = (hi + Math.imul(ah4, bh8)) | 0;
  37322. lo = (lo + Math.imul(al3, bl9)) | 0;
  37323. mid = (mid + Math.imul(al3, bh9)) | 0;
  37324. mid = (mid + Math.imul(ah3, bl9)) | 0;
  37325. hi = (hi + Math.imul(ah3, bh9)) | 0;
  37326. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37327. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  37328. w12 &= 0x3ffffff;
  37329. /* k = 13 */
  37330. lo = Math.imul(al9, bl4);
  37331. mid = Math.imul(al9, bh4);
  37332. mid = (mid + Math.imul(ah9, bl4)) | 0;
  37333. hi = Math.imul(ah9, bh4);
  37334. lo = (lo + Math.imul(al8, bl5)) | 0;
  37335. mid = (mid + Math.imul(al8, bh5)) | 0;
  37336. mid = (mid + Math.imul(ah8, bl5)) | 0;
  37337. hi = (hi + Math.imul(ah8, bh5)) | 0;
  37338. lo = (lo + Math.imul(al7, bl6)) | 0;
  37339. mid = (mid + Math.imul(al7, bh6)) | 0;
  37340. mid = (mid + Math.imul(ah7, bl6)) | 0;
  37341. hi = (hi + Math.imul(ah7, bh6)) | 0;
  37342. lo = (lo + Math.imul(al6, bl7)) | 0;
  37343. mid = (mid + Math.imul(al6, bh7)) | 0;
  37344. mid = (mid + Math.imul(ah6, bl7)) | 0;
  37345. hi = (hi + Math.imul(ah6, bh7)) | 0;
  37346. lo = (lo + Math.imul(al5, bl8)) | 0;
  37347. mid = (mid + Math.imul(al5, bh8)) | 0;
  37348. mid = (mid + Math.imul(ah5, bl8)) | 0;
  37349. hi = (hi + Math.imul(ah5, bh8)) | 0;
  37350. lo = (lo + Math.imul(al4, bl9)) | 0;
  37351. mid = (mid + Math.imul(al4, bh9)) | 0;
  37352. mid = (mid + Math.imul(ah4, bl9)) | 0;
  37353. hi = (hi + Math.imul(ah4, bh9)) | 0;
  37354. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37355. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  37356. w13 &= 0x3ffffff;
  37357. /* k = 14 */
  37358. lo = Math.imul(al9, bl5);
  37359. mid = Math.imul(al9, bh5);
  37360. mid = (mid + Math.imul(ah9, bl5)) | 0;
  37361. hi = Math.imul(ah9, bh5);
  37362. lo = (lo + Math.imul(al8, bl6)) | 0;
  37363. mid = (mid + Math.imul(al8, bh6)) | 0;
  37364. mid = (mid + Math.imul(ah8, bl6)) | 0;
  37365. hi = (hi + Math.imul(ah8, bh6)) | 0;
  37366. lo = (lo + Math.imul(al7, bl7)) | 0;
  37367. mid = (mid + Math.imul(al7, bh7)) | 0;
  37368. mid = (mid + Math.imul(ah7, bl7)) | 0;
  37369. hi = (hi + Math.imul(ah7, bh7)) | 0;
  37370. lo = (lo + Math.imul(al6, bl8)) | 0;
  37371. mid = (mid + Math.imul(al6, bh8)) | 0;
  37372. mid = (mid + Math.imul(ah6, bl8)) | 0;
  37373. hi = (hi + Math.imul(ah6, bh8)) | 0;
  37374. lo = (lo + Math.imul(al5, bl9)) | 0;
  37375. mid = (mid + Math.imul(al5, bh9)) | 0;
  37376. mid = (mid + Math.imul(ah5, bl9)) | 0;
  37377. hi = (hi + Math.imul(ah5, bh9)) | 0;
  37378. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37379. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  37380. w14 &= 0x3ffffff;
  37381. /* k = 15 */
  37382. lo = Math.imul(al9, bl6);
  37383. mid = Math.imul(al9, bh6);
  37384. mid = (mid + Math.imul(ah9, bl6)) | 0;
  37385. hi = Math.imul(ah9, bh6);
  37386. lo = (lo + Math.imul(al8, bl7)) | 0;
  37387. mid = (mid + Math.imul(al8, bh7)) | 0;
  37388. mid = (mid + Math.imul(ah8, bl7)) | 0;
  37389. hi = (hi + Math.imul(ah8, bh7)) | 0;
  37390. lo = (lo + Math.imul(al7, bl8)) | 0;
  37391. mid = (mid + Math.imul(al7, bh8)) | 0;
  37392. mid = (mid + Math.imul(ah7, bl8)) | 0;
  37393. hi = (hi + Math.imul(ah7, bh8)) | 0;
  37394. lo = (lo + Math.imul(al6, bl9)) | 0;
  37395. mid = (mid + Math.imul(al6, bh9)) | 0;
  37396. mid = (mid + Math.imul(ah6, bl9)) | 0;
  37397. hi = (hi + Math.imul(ah6, bh9)) | 0;
  37398. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37399. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  37400. w15 &= 0x3ffffff;
  37401. /* k = 16 */
  37402. lo = Math.imul(al9, bl7);
  37403. mid = Math.imul(al9, bh7);
  37404. mid = (mid + Math.imul(ah9, bl7)) | 0;
  37405. hi = Math.imul(ah9, bh7);
  37406. lo = (lo + Math.imul(al8, bl8)) | 0;
  37407. mid = (mid + Math.imul(al8, bh8)) | 0;
  37408. mid = (mid + Math.imul(ah8, bl8)) | 0;
  37409. hi = (hi + Math.imul(ah8, bh8)) | 0;
  37410. lo = (lo + Math.imul(al7, bl9)) | 0;
  37411. mid = (mid + Math.imul(al7, bh9)) | 0;
  37412. mid = (mid + Math.imul(ah7, bl9)) | 0;
  37413. hi = (hi + Math.imul(ah7, bh9)) | 0;
  37414. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37415. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  37416. w16 &= 0x3ffffff;
  37417. /* k = 17 */
  37418. lo = Math.imul(al9, bl8);
  37419. mid = Math.imul(al9, bh8);
  37420. mid = (mid + Math.imul(ah9, bl8)) | 0;
  37421. hi = Math.imul(ah9, bh8);
  37422. lo = (lo + Math.imul(al8, bl9)) | 0;
  37423. mid = (mid + Math.imul(al8, bh9)) | 0;
  37424. mid = (mid + Math.imul(ah8, bl9)) | 0;
  37425. hi = (hi + Math.imul(ah8, bh9)) | 0;
  37426. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37427. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  37428. w17 &= 0x3ffffff;
  37429. /* k = 18 */
  37430. lo = Math.imul(al9, bl9);
  37431. mid = Math.imul(al9, bh9);
  37432. mid = (mid + Math.imul(ah9, bl9)) | 0;
  37433. hi = Math.imul(ah9, bh9);
  37434. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  37435. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  37436. w18 &= 0x3ffffff;
  37437. o[0] = w0;
  37438. o[1] = w1;
  37439. o[2] = w2;
  37440. o[3] = w3;
  37441. o[4] = w4;
  37442. o[5] = w5;
  37443. o[6] = w6;
  37444. o[7] = w7;
  37445. o[8] = w8;
  37446. o[9] = w9;
  37447. o[10] = w10;
  37448. o[11] = w11;
  37449. o[12] = w12;
  37450. o[13] = w13;
  37451. o[14] = w14;
  37452. o[15] = w15;
  37453. o[16] = w16;
  37454. o[17] = w17;
  37455. o[18] = w18;
  37456. if (c !== 0) {
  37457. o[19] = c;
  37458. out.length++;
  37459. }
  37460. return out;
  37461. };
  37462. // Polyfill comb
  37463. if (!Math.imul) {
  37464. comb10MulTo = smallMulTo;
  37465. }
  37466. function bigMulTo (self, num, out) {
  37467. out.negative = num.negative ^ self.negative;
  37468. out.length = self.length + num.length;
  37469. var carry = 0;
  37470. var hncarry = 0;
  37471. for (var k = 0; k < out.length - 1; k++) {
  37472. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  37473. // note that ncarry could be >= 0x3ffffff
  37474. var ncarry = hncarry;
  37475. hncarry = 0;
  37476. var rword = carry & 0x3ffffff;
  37477. var maxJ = Math.min(k, num.length - 1);
  37478. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  37479. var i = k - j;
  37480. var a = self.words[i] | 0;
  37481. var b = num.words[j] | 0;
  37482. var r = a * b;
  37483. var lo = r & 0x3ffffff;
  37484. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  37485. lo = (lo + rword) | 0;
  37486. rword = lo & 0x3ffffff;
  37487. ncarry = (ncarry + (lo >>> 26)) | 0;
  37488. hncarry += ncarry >>> 26;
  37489. ncarry &= 0x3ffffff;
  37490. }
  37491. out.words[k] = rword;
  37492. carry = ncarry;
  37493. ncarry = hncarry;
  37494. }
  37495. if (carry !== 0) {
  37496. out.words[k] = carry;
  37497. } else {
  37498. out.length--;
  37499. }
  37500. return out.strip();
  37501. }
  37502. function jumboMulTo (self, num, out) {
  37503. var fftm = new FFTM();
  37504. return fftm.mulp(self, num, out);
  37505. }
  37506. BN.prototype.mulTo = function mulTo (num, out) {
  37507. var res;
  37508. var len = this.length + num.length;
  37509. if (this.length === 10 && num.length === 10) {
  37510. res = comb10MulTo(this, num, out);
  37511. } else if (len < 63) {
  37512. res = smallMulTo(this, num, out);
  37513. } else if (len < 1024) {
  37514. res = bigMulTo(this, num, out);
  37515. } else {
  37516. res = jumboMulTo(this, num, out);
  37517. }
  37518. return res;
  37519. };
  37520. // Cooley-Tukey algorithm for FFT
  37521. // slightly revisited to rely on looping instead of recursion
  37522. function FFTM (x, y) {
  37523. this.x = x;
  37524. this.y = y;
  37525. }
  37526. FFTM.prototype.makeRBT = function makeRBT (N) {
  37527. var t = new Array(N);
  37528. var l = BN.prototype._countBits(N) - 1;
  37529. for (var i = 0; i < N; i++) {
  37530. t[i] = this.revBin(i, l, N);
  37531. }
  37532. return t;
  37533. };
  37534. // Returns binary-reversed representation of `x`
  37535. FFTM.prototype.revBin = function revBin (x, l, N) {
  37536. if (x === 0 || x === N - 1) return x;
  37537. var rb = 0;
  37538. for (var i = 0; i < l; i++) {
  37539. rb |= (x & 1) << (l - i - 1);
  37540. x >>= 1;
  37541. }
  37542. return rb;
  37543. };
  37544. // Performs "tweedling" phase, therefore 'emulating'
  37545. // behaviour of the recursive algorithm
  37546. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  37547. for (var i = 0; i < N; i++) {
  37548. rtws[i] = rws[rbt[i]];
  37549. itws[i] = iws[rbt[i]];
  37550. }
  37551. };
  37552. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  37553. this.permute(rbt, rws, iws, rtws, itws, N);
  37554. for (var s = 1; s < N; s <<= 1) {
  37555. var l = s << 1;
  37556. var rtwdf = Math.cos(2 * Math.PI / l);
  37557. var itwdf = Math.sin(2 * Math.PI / l);
  37558. for (var p = 0; p < N; p += l) {
  37559. var rtwdf_ = rtwdf;
  37560. var itwdf_ = itwdf;
  37561. for (var j = 0; j < s; j++) {
  37562. var re = rtws[p + j];
  37563. var ie = itws[p + j];
  37564. var ro = rtws[p + j + s];
  37565. var io = itws[p + j + s];
  37566. var rx = rtwdf_ * ro - itwdf_ * io;
  37567. io = rtwdf_ * io + itwdf_ * ro;
  37568. ro = rx;
  37569. rtws[p + j] = re + ro;
  37570. itws[p + j] = ie + io;
  37571. rtws[p + j + s] = re - ro;
  37572. itws[p + j + s] = ie - io;
  37573. /* jshint maxdepth : false */
  37574. if (j !== l) {
  37575. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  37576. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  37577. rtwdf_ = rx;
  37578. }
  37579. }
  37580. }
  37581. }
  37582. };
  37583. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  37584. var N = Math.max(m, n) | 1;
  37585. var odd = N & 1;
  37586. var i = 0;
  37587. for (N = N / 2 | 0; N; N = N >>> 1) {
  37588. i++;
  37589. }
  37590. return 1 << i + 1 + odd;
  37591. };
  37592. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  37593. if (N <= 1) return;
  37594. for (var i = 0; i < N / 2; i++) {
  37595. var t = rws[i];
  37596. rws[i] = rws[N - i - 1];
  37597. rws[N - i - 1] = t;
  37598. t = iws[i];
  37599. iws[i] = -iws[N - i - 1];
  37600. iws[N - i - 1] = -t;
  37601. }
  37602. };
  37603. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  37604. var carry = 0;
  37605. for (var i = 0; i < N / 2; i++) {
  37606. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  37607. Math.round(ws[2 * i] / N) +
  37608. carry;
  37609. ws[i] = w & 0x3ffffff;
  37610. if (w < 0x4000000) {
  37611. carry = 0;
  37612. } else {
  37613. carry = w / 0x4000000 | 0;
  37614. }
  37615. }
  37616. return ws;
  37617. };
  37618. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  37619. var carry = 0;
  37620. for (var i = 0; i < len; i++) {
  37621. carry = carry + (ws[i] | 0);
  37622. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  37623. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  37624. }
  37625. // Pad with zeroes
  37626. for (i = 2 * len; i < N; ++i) {
  37627. rws[i] = 0;
  37628. }
  37629. assert(carry === 0);
  37630. assert((carry & ~0x1fff) === 0);
  37631. };
  37632. FFTM.prototype.stub = function stub (N) {
  37633. var ph = new Array(N);
  37634. for (var i = 0; i < N; i++) {
  37635. ph[i] = 0;
  37636. }
  37637. return ph;
  37638. };
  37639. FFTM.prototype.mulp = function mulp (x, y, out) {
  37640. var N = 2 * this.guessLen13b(x.length, y.length);
  37641. var rbt = this.makeRBT(N);
  37642. var _ = this.stub(N);
  37643. var rws = new Array(N);
  37644. var rwst = new Array(N);
  37645. var iwst = new Array(N);
  37646. var nrws = new Array(N);
  37647. var nrwst = new Array(N);
  37648. var niwst = new Array(N);
  37649. var rmws = out.words;
  37650. rmws.length = N;
  37651. this.convert13b(x.words, x.length, rws, N);
  37652. this.convert13b(y.words, y.length, nrws, N);
  37653. this.transform(rws, _, rwst, iwst, N, rbt);
  37654. this.transform(nrws, _, nrwst, niwst, N, rbt);
  37655. for (var i = 0; i < N; i++) {
  37656. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  37657. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  37658. rwst[i] = rx;
  37659. }
  37660. this.conjugate(rwst, iwst, N);
  37661. this.transform(rwst, iwst, rmws, _, N, rbt);
  37662. this.conjugate(rmws, _, N);
  37663. this.normalize13b(rmws, N);
  37664. out.negative = x.negative ^ y.negative;
  37665. out.length = x.length + y.length;
  37666. return out.strip();
  37667. };
  37668. // Multiply `this` by `num`
  37669. BN.prototype.mul = function mul (num) {
  37670. var out = new BN(null);
  37671. out.words = new Array(this.length + num.length);
  37672. return this.mulTo(num, out);
  37673. };
  37674. // Multiply employing FFT
  37675. BN.prototype.mulf = function mulf (num) {
  37676. var out = new BN(null);
  37677. out.words = new Array(this.length + num.length);
  37678. return jumboMulTo(this, num, out);
  37679. };
  37680. // In-place Multiplication
  37681. BN.prototype.imul = function imul (num) {
  37682. return this.clone().mulTo(num, this);
  37683. };
  37684. BN.prototype.imuln = function imuln (num) {
  37685. assert(typeof num === 'number');
  37686. assert(num < 0x4000000);
  37687. // Carry
  37688. var carry = 0;
  37689. for (var i = 0; i < this.length; i++) {
  37690. var w = (this.words[i] | 0) * num;
  37691. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  37692. carry >>= 26;
  37693. carry += (w / 0x4000000) | 0;
  37694. // NOTE: lo is 27bit maximum
  37695. carry += lo >>> 26;
  37696. this.words[i] = lo & 0x3ffffff;
  37697. }
  37698. if (carry !== 0) {
  37699. this.words[i] = carry;
  37700. this.length++;
  37701. }
  37702. return this;
  37703. };
  37704. BN.prototype.muln = function muln (num) {
  37705. return this.clone().imuln(num);
  37706. };
  37707. // `this` * `this`
  37708. BN.prototype.sqr = function sqr () {
  37709. return this.mul(this);
  37710. };
  37711. // `this` * `this` in-place
  37712. BN.prototype.isqr = function isqr () {
  37713. return this.imul(this.clone());
  37714. };
  37715. // Math.pow(`this`, `num`)
  37716. BN.prototype.pow = function pow (num) {
  37717. var w = toBitArray(num);
  37718. if (w.length === 0) return new BN(1);
  37719. // Skip leading zeroes
  37720. var res = this;
  37721. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  37722. if (w[i] !== 0) break;
  37723. }
  37724. if (++i < w.length) {
  37725. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  37726. if (w[i] === 0) continue;
  37727. res = res.mul(q);
  37728. }
  37729. }
  37730. return res;
  37731. };
  37732. // Shift-left in-place
  37733. BN.prototype.iushln = function iushln (bits) {
  37734. assert(typeof bits === 'number' && bits >= 0);
  37735. var r = bits % 26;
  37736. var s = (bits - r) / 26;
  37737. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  37738. var i;
  37739. if (r !== 0) {
  37740. var carry = 0;
  37741. for (i = 0; i < this.length; i++) {
  37742. var newCarry = this.words[i] & carryMask;
  37743. var c = ((this.words[i] | 0) - newCarry) << r;
  37744. this.words[i] = c | carry;
  37745. carry = newCarry >>> (26 - r);
  37746. }
  37747. if (carry) {
  37748. this.words[i] = carry;
  37749. this.length++;
  37750. }
  37751. }
  37752. if (s !== 0) {
  37753. for (i = this.length - 1; i >= 0; i--) {
  37754. this.words[i + s] = this.words[i];
  37755. }
  37756. for (i = 0; i < s; i++) {
  37757. this.words[i] = 0;
  37758. }
  37759. this.length += s;
  37760. }
  37761. return this.strip();
  37762. };
  37763. BN.prototype.ishln = function ishln (bits) {
  37764. // TODO(indutny): implement me
  37765. assert(this.negative === 0);
  37766. return this.iushln(bits);
  37767. };
  37768. // Shift-right in-place
  37769. // NOTE: `hint` is a lowest bit before trailing zeroes
  37770. // NOTE: if `extended` is present - it will be filled with destroyed bits
  37771. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  37772. assert(typeof bits === 'number' && bits >= 0);
  37773. var h;
  37774. if (hint) {
  37775. h = (hint - (hint % 26)) / 26;
  37776. } else {
  37777. h = 0;
  37778. }
  37779. var r = bits % 26;
  37780. var s = Math.min((bits - r) / 26, this.length);
  37781. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  37782. var maskedWords = extended;
  37783. h -= s;
  37784. h = Math.max(0, h);
  37785. // Extended mode, copy masked part
  37786. if (maskedWords) {
  37787. for (var i = 0; i < s; i++) {
  37788. maskedWords.words[i] = this.words[i];
  37789. }
  37790. maskedWords.length = s;
  37791. }
  37792. if (s === 0) {
  37793. // No-op, we should not move anything at all
  37794. } else if (this.length > s) {
  37795. this.length -= s;
  37796. for (i = 0; i < this.length; i++) {
  37797. this.words[i] = this.words[i + s];
  37798. }
  37799. } else {
  37800. this.words[0] = 0;
  37801. this.length = 1;
  37802. }
  37803. var carry = 0;
  37804. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  37805. var word = this.words[i] | 0;
  37806. this.words[i] = (carry << (26 - r)) | (word >>> r);
  37807. carry = word & mask;
  37808. }
  37809. // Push carried bits as a mask
  37810. if (maskedWords && carry !== 0) {
  37811. maskedWords.words[maskedWords.length++] = carry;
  37812. }
  37813. if (this.length === 0) {
  37814. this.words[0] = 0;
  37815. this.length = 1;
  37816. }
  37817. return this.strip();
  37818. };
  37819. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  37820. // TODO(indutny): implement me
  37821. assert(this.negative === 0);
  37822. return this.iushrn(bits, hint, extended);
  37823. };
  37824. // Shift-left
  37825. BN.prototype.shln = function shln (bits) {
  37826. return this.clone().ishln(bits);
  37827. };
  37828. BN.prototype.ushln = function ushln (bits) {
  37829. return this.clone().iushln(bits);
  37830. };
  37831. // Shift-right
  37832. BN.prototype.shrn = function shrn (bits) {
  37833. return this.clone().ishrn(bits);
  37834. };
  37835. BN.prototype.ushrn = function ushrn (bits) {
  37836. return this.clone().iushrn(bits);
  37837. };
  37838. // Test if n bit is set
  37839. BN.prototype.testn = function testn (bit) {
  37840. assert(typeof bit === 'number' && bit >= 0);
  37841. var r = bit % 26;
  37842. var s = (bit - r) / 26;
  37843. var q = 1 << r;
  37844. // Fast case: bit is much higher than all existing words
  37845. if (this.length <= s) return false;
  37846. // Check bit and return
  37847. var w = this.words[s];
  37848. return !!(w & q);
  37849. };
  37850. // Return only lowers bits of number (in-place)
  37851. BN.prototype.imaskn = function imaskn (bits) {
  37852. assert(typeof bits === 'number' && bits >= 0);
  37853. var r = bits % 26;
  37854. var s = (bits - r) / 26;
  37855. assert(this.negative === 0, 'imaskn works only with positive numbers');
  37856. if (this.length <= s) {
  37857. return this;
  37858. }
  37859. if (r !== 0) {
  37860. s++;
  37861. }
  37862. this.length = Math.min(s, this.length);
  37863. if (r !== 0) {
  37864. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  37865. this.words[this.length - 1] &= mask;
  37866. }
  37867. return this.strip();
  37868. };
  37869. // Return only lowers bits of number
  37870. BN.prototype.maskn = function maskn (bits) {
  37871. return this.clone().imaskn(bits);
  37872. };
  37873. // Add plain number `num` to `this`
  37874. BN.prototype.iaddn = function iaddn (num) {
  37875. assert(typeof num === 'number');
  37876. assert(num < 0x4000000);
  37877. if (num < 0) return this.isubn(-num);
  37878. // Possible sign change
  37879. if (this.negative !== 0) {
  37880. if (this.length === 1 && (this.words[0] | 0) < num) {
  37881. this.words[0] = num - (this.words[0] | 0);
  37882. this.negative = 0;
  37883. return this;
  37884. }
  37885. this.negative = 0;
  37886. this.isubn(num);
  37887. this.negative = 1;
  37888. return this;
  37889. }
  37890. // Add without checks
  37891. return this._iaddn(num);
  37892. };
  37893. BN.prototype._iaddn = function _iaddn (num) {
  37894. this.words[0] += num;
  37895. // Carry
  37896. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  37897. this.words[i] -= 0x4000000;
  37898. if (i === this.length - 1) {
  37899. this.words[i + 1] = 1;
  37900. } else {
  37901. this.words[i + 1]++;
  37902. }
  37903. }
  37904. this.length = Math.max(this.length, i + 1);
  37905. return this;
  37906. };
  37907. // Subtract plain number `num` from `this`
  37908. BN.prototype.isubn = function isubn (num) {
  37909. assert(typeof num === 'number');
  37910. assert(num < 0x4000000);
  37911. if (num < 0) return this.iaddn(-num);
  37912. if (this.negative !== 0) {
  37913. this.negative = 0;
  37914. this.iaddn(num);
  37915. this.negative = 1;
  37916. return this;
  37917. }
  37918. this.words[0] -= num;
  37919. if (this.length === 1 && this.words[0] < 0) {
  37920. this.words[0] = -this.words[0];
  37921. this.negative = 1;
  37922. } else {
  37923. // Carry
  37924. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  37925. this.words[i] += 0x4000000;
  37926. this.words[i + 1] -= 1;
  37927. }
  37928. }
  37929. return this.strip();
  37930. };
  37931. BN.prototype.addn = function addn (num) {
  37932. return this.clone().iaddn(num);
  37933. };
  37934. BN.prototype.subn = function subn (num) {
  37935. return this.clone().isubn(num);
  37936. };
  37937. BN.prototype.iabs = function iabs () {
  37938. this.negative = 0;
  37939. return this;
  37940. };
  37941. BN.prototype.abs = function abs () {
  37942. return this.clone().iabs();
  37943. };
  37944. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  37945. var len = num.length + shift;
  37946. var i;
  37947. this._expand(len);
  37948. var w;
  37949. var carry = 0;
  37950. for (i = 0; i < num.length; i++) {
  37951. w = (this.words[i + shift] | 0) + carry;
  37952. var right = (num.words[i] | 0) * mul;
  37953. w -= right & 0x3ffffff;
  37954. carry = (w >> 26) - ((right / 0x4000000) | 0);
  37955. this.words[i + shift] = w & 0x3ffffff;
  37956. }
  37957. for (; i < this.length - shift; i++) {
  37958. w = (this.words[i + shift] | 0) + carry;
  37959. carry = w >> 26;
  37960. this.words[i + shift] = w & 0x3ffffff;
  37961. }
  37962. if (carry === 0) return this.strip();
  37963. // Subtraction overflow
  37964. assert(carry === -1);
  37965. carry = 0;
  37966. for (i = 0; i < this.length; i++) {
  37967. w = -(this.words[i] | 0) + carry;
  37968. carry = w >> 26;
  37969. this.words[i] = w & 0x3ffffff;
  37970. }
  37971. this.negative = 1;
  37972. return this.strip();
  37973. };
  37974. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  37975. var shift = this.length - num.length;
  37976. var a = this.clone();
  37977. var b = num;
  37978. // Normalize
  37979. var bhi = b.words[b.length - 1] | 0;
  37980. var bhiBits = this._countBits(bhi);
  37981. shift = 26 - bhiBits;
  37982. if (shift !== 0) {
  37983. b = b.ushln(shift);
  37984. a.iushln(shift);
  37985. bhi = b.words[b.length - 1] | 0;
  37986. }
  37987. // Initialize quotient
  37988. var m = a.length - b.length;
  37989. var q;
  37990. if (mode !== 'mod') {
  37991. q = new BN(null);
  37992. q.length = m + 1;
  37993. q.words = new Array(q.length);
  37994. for (var i = 0; i < q.length; i++) {
  37995. q.words[i] = 0;
  37996. }
  37997. }
  37998. var diff = a.clone()._ishlnsubmul(b, 1, m);
  37999. if (diff.negative === 0) {
  38000. a = diff;
  38001. if (q) {
  38002. q.words[m] = 1;
  38003. }
  38004. }
  38005. for (var j = m - 1; j >= 0; j--) {
  38006. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  38007. (a.words[b.length + j - 1] | 0);
  38008. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  38009. // (0x7ffffff)
  38010. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  38011. a._ishlnsubmul(b, qj, j);
  38012. while (a.negative !== 0) {
  38013. qj--;
  38014. a.negative = 0;
  38015. a._ishlnsubmul(b, 1, j);
  38016. if (!a.isZero()) {
  38017. a.negative ^= 1;
  38018. }
  38019. }
  38020. if (q) {
  38021. q.words[j] = qj;
  38022. }
  38023. }
  38024. if (q) {
  38025. q.strip();
  38026. }
  38027. a.strip();
  38028. // Denormalize
  38029. if (mode !== 'div' && shift !== 0) {
  38030. a.iushrn(shift);
  38031. }
  38032. return {
  38033. div: q || null,
  38034. mod: a
  38035. };
  38036. };
  38037. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  38038. // to `div` to request div only, or be absent to
  38039. // request both div & mod
  38040. // 2) `positive` is true if unsigned mod is requested
  38041. BN.prototype.divmod = function divmod (num, mode, positive) {
  38042. assert(!num.isZero());
  38043. if (this.isZero()) {
  38044. return {
  38045. div: new BN(0),
  38046. mod: new BN(0)
  38047. };
  38048. }
  38049. var div, mod, res;
  38050. if (this.negative !== 0 && num.negative === 0) {
  38051. res = this.neg().divmod(num, mode);
  38052. if (mode !== 'mod') {
  38053. div = res.div.neg();
  38054. }
  38055. if (mode !== 'div') {
  38056. mod = res.mod.neg();
  38057. if (positive && mod.negative !== 0) {
  38058. mod.iadd(num);
  38059. }
  38060. }
  38061. return {
  38062. div: div,
  38063. mod: mod
  38064. };
  38065. }
  38066. if (this.negative === 0 && num.negative !== 0) {
  38067. res = this.divmod(num.neg(), mode);
  38068. if (mode !== 'mod') {
  38069. div = res.div.neg();
  38070. }
  38071. return {
  38072. div: div,
  38073. mod: res.mod
  38074. };
  38075. }
  38076. if ((this.negative & num.negative) !== 0) {
  38077. res = this.neg().divmod(num.neg(), mode);
  38078. if (mode !== 'div') {
  38079. mod = res.mod.neg();
  38080. if (positive && mod.negative !== 0) {
  38081. mod.isub(num);
  38082. }
  38083. }
  38084. return {
  38085. div: res.div,
  38086. mod: mod
  38087. };
  38088. }
  38089. // Both numbers are positive at this point
  38090. // Strip both numbers to approximate shift value
  38091. if (num.length > this.length || this.cmp(num) < 0) {
  38092. return {
  38093. div: new BN(0),
  38094. mod: this
  38095. };
  38096. }
  38097. // Very short reduction
  38098. if (num.length === 1) {
  38099. if (mode === 'div') {
  38100. return {
  38101. div: this.divn(num.words[0]),
  38102. mod: null
  38103. };
  38104. }
  38105. if (mode === 'mod') {
  38106. return {
  38107. div: null,
  38108. mod: new BN(this.modn(num.words[0]))
  38109. };
  38110. }
  38111. return {
  38112. div: this.divn(num.words[0]),
  38113. mod: new BN(this.modn(num.words[0]))
  38114. };
  38115. }
  38116. return this._wordDiv(num, mode);
  38117. };
  38118. // Find `this` / `num`
  38119. BN.prototype.div = function div (num) {
  38120. return this.divmod(num, 'div', false).div;
  38121. };
  38122. // Find `this` % `num`
  38123. BN.prototype.mod = function mod (num) {
  38124. return this.divmod(num, 'mod', false).mod;
  38125. };
  38126. BN.prototype.umod = function umod (num) {
  38127. return this.divmod(num, 'mod', true).mod;
  38128. };
  38129. // Find Round(`this` / `num`)
  38130. BN.prototype.divRound = function divRound (num) {
  38131. var dm = this.divmod(num);
  38132. // Fast case - exact division
  38133. if (dm.mod.isZero()) return dm.div;
  38134. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  38135. var half = num.ushrn(1);
  38136. var r2 = num.andln(1);
  38137. var cmp = mod.cmp(half);
  38138. // Round down
  38139. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  38140. // Round up
  38141. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  38142. };
  38143. BN.prototype.modn = function modn (num) {
  38144. assert(num <= 0x3ffffff);
  38145. var p = (1 << 26) % num;
  38146. var acc = 0;
  38147. for (var i = this.length - 1; i >= 0; i--) {
  38148. acc = (p * acc + (this.words[i] | 0)) % num;
  38149. }
  38150. return acc;
  38151. };
  38152. // In-place division by number
  38153. BN.prototype.idivn = function idivn (num) {
  38154. assert(num <= 0x3ffffff);
  38155. var carry = 0;
  38156. for (var i = this.length - 1; i >= 0; i--) {
  38157. var w = (this.words[i] | 0) + carry * 0x4000000;
  38158. this.words[i] = (w / num) | 0;
  38159. carry = w % num;
  38160. }
  38161. return this.strip();
  38162. };
  38163. BN.prototype.divn = function divn (num) {
  38164. return this.clone().idivn(num);
  38165. };
  38166. BN.prototype.egcd = function egcd (p) {
  38167. assert(p.negative === 0);
  38168. assert(!p.isZero());
  38169. var x = this;
  38170. var y = p.clone();
  38171. if (x.negative !== 0) {
  38172. x = x.umod(p);
  38173. } else {
  38174. x = x.clone();
  38175. }
  38176. // A * x + B * y = x
  38177. var A = new BN(1);
  38178. var B = new BN(0);
  38179. // C * x + D * y = y
  38180. var C = new BN(0);
  38181. var D = new BN(1);
  38182. var g = 0;
  38183. while (x.isEven() && y.isEven()) {
  38184. x.iushrn(1);
  38185. y.iushrn(1);
  38186. ++g;
  38187. }
  38188. var yp = y.clone();
  38189. var xp = x.clone();
  38190. while (!x.isZero()) {
  38191. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  38192. if (i > 0) {
  38193. x.iushrn(i);
  38194. while (i-- > 0) {
  38195. if (A.isOdd() || B.isOdd()) {
  38196. A.iadd(yp);
  38197. B.isub(xp);
  38198. }
  38199. A.iushrn(1);
  38200. B.iushrn(1);
  38201. }
  38202. }
  38203. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  38204. if (j > 0) {
  38205. y.iushrn(j);
  38206. while (j-- > 0) {
  38207. if (C.isOdd() || D.isOdd()) {
  38208. C.iadd(yp);
  38209. D.isub(xp);
  38210. }
  38211. C.iushrn(1);
  38212. D.iushrn(1);
  38213. }
  38214. }
  38215. if (x.cmp(y) >= 0) {
  38216. x.isub(y);
  38217. A.isub(C);
  38218. B.isub(D);
  38219. } else {
  38220. y.isub(x);
  38221. C.isub(A);
  38222. D.isub(B);
  38223. }
  38224. }
  38225. return {
  38226. a: C,
  38227. b: D,
  38228. gcd: y.iushln(g)
  38229. };
  38230. };
  38231. // This is reduced incarnation of the binary EEA
  38232. // above, designated to invert members of the
  38233. // _prime_ fields F(p) at a maximal speed
  38234. BN.prototype._invmp = function _invmp (p) {
  38235. assert(p.negative === 0);
  38236. assert(!p.isZero());
  38237. var a = this;
  38238. var b = p.clone();
  38239. if (a.negative !== 0) {
  38240. a = a.umod(p);
  38241. } else {
  38242. a = a.clone();
  38243. }
  38244. var x1 = new BN(1);
  38245. var x2 = new BN(0);
  38246. var delta = b.clone();
  38247. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  38248. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  38249. if (i > 0) {
  38250. a.iushrn(i);
  38251. while (i-- > 0) {
  38252. if (x1.isOdd()) {
  38253. x1.iadd(delta);
  38254. }
  38255. x1.iushrn(1);
  38256. }
  38257. }
  38258. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  38259. if (j > 0) {
  38260. b.iushrn(j);
  38261. while (j-- > 0) {
  38262. if (x2.isOdd()) {
  38263. x2.iadd(delta);
  38264. }
  38265. x2.iushrn(1);
  38266. }
  38267. }
  38268. if (a.cmp(b) >= 0) {
  38269. a.isub(b);
  38270. x1.isub(x2);
  38271. } else {
  38272. b.isub(a);
  38273. x2.isub(x1);
  38274. }
  38275. }
  38276. var res;
  38277. if (a.cmpn(1) === 0) {
  38278. res = x1;
  38279. } else {
  38280. res = x2;
  38281. }
  38282. if (res.cmpn(0) < 0) {
  38283. res.iadd(p);
  38284. }
  38285. return res;
  38286. };
  38287. BN.prototype.gcd = function gcd (num) {
  38288. if (this.isZero()) return num.abs();
  38289. if (num.isZero()) return this.abs();
  38290. var a = this.clone();
  38291. var b = num.clone();
  38292. a.negative = 0;
  38293. b.negative = 0;
  38294. // Remove common factor of two
  38295. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  38296. a.iushrn(1);
  38297. b.iushrn(1);
  38298. }
  38299. do {
  38300. while (a.isEven()) {
  38301. a.iushrn(1);
  38302. }
  38303. while (b.isEven()) {
  38304. b.iushrn(1);
  38305. }
  38306. var r = a.cmp(b);
  38307. if (r < 0) {
  38308. // Swap `a` and `b` to make `a` always bigger than `b`
  38309. var t = a;
  38310. a = b;
  38311. b = t;
  38312. } else if (r === 0 || b.cmpn(1) === 0) {
  38313. break;
  38314. }
  38315. a.isub(b);
  38316. } while (true);
  38317. return b.iushln(shift);
  38318. };
  38319. // Invert number in the field F(num)
  38320. BN.prototype.invm = function invm (num) {
  38321. return this.egcd(num).a.umod(num);
  38322. };
  38323. BN.prototype.isEven = function isEven () {
  38324. return (this.words[0] & 1) === 0;
  38325. };
  38326. BN.prototype.isOdd = function isOdd () {
  38327. return (this.words[0] & 1) === 1;
  38328. };
  38329. // And first word and num
  38330. BN.prototype.andln = function andln (num) {
  38331. return this.words[0] & num;
  38332. };
  38333. // Increment at the bit position in-line
  38334. BN.prototype.bincn = function bincn (bit) {
  38335. assert(typeof bit === 'number');
  38336. var r = bit % 26;
  38337. var s = (bit - r) / 26;
  38338. var q = 1 << r;
  38339. // Fast case: bit is much higher than all existing words
  38340. if (this.length <= s) {
  38341. this._expand(s + 1);
  38342. this.words[s] |= q;
  38343. return this;
  38344. }
  38345. // Add bit and propagate, if needed
  38346. var carry = q;
  38347. for (var i = s; carry !== 0 && i < this.length; i++) {
  38348. var w = this.words[i] | 0;
  38349. w += carry;
  38350. carry = w >>> 26;
  38351. w &= 0x3ffffff;
  38352. this.words[i] = w;
  38353. }
  38354. if (carry !== 0) {
  38355. this.words[i] = carry;
  38356. this.length++;
  38357. }
  38358. return this;
  38359. };
  38360. BN.prototype.isZero = function isZero () {
  38361. return this.length === 1 && this.words[0] === 0;
  38362. };
  38363. BN.prototype.cmpn = function cmpn (num) {
  38364. var negative = num < 0;
  38365. if (this.negative !== 0 && !negative) return -1;
  38366. if (this.negative === 0 && negative) return 1;
  38367. this.strip();
  38368. var res;
  38369. if (this.length > 1) {
  38370. res = 1;
  38371. } else {
  38372. if (negative) {
  38373. num = -num;
  38374. }
  38375. assert(num <= 0x3ffffff, 'Number is too big');
  38376. var w = this.words[0] | 0;
  38377. res = w === num ? 0 : w < num ? -1 : 1;
  38378. }
  38379. if (this.negative !== 0) return -res | 0;
  38380. return res;
  38381. };
  38382. // Compare two numbers and return:
  38383. // 1 - if `this` > `num`
  38384. // 0 - if `this` == `num`
  38385. // -1 - if `this` < `num`
  38386. BN.prototype.cmp = function cmp (num) {
  38387. if (this.negative !== 0 && num.negative === 0) return -1;
  38388. if (this.negative === 0 && num.negative !== 0) return 1;
  38389. var res = this.ucmp(num);
  38390. if (this.negative !== 0) return -res | 0;
  38391. return res;
  38392. };
  38393. // Unsigned comparison
  38394. BN.prototype.ucmp = function ucmp (num) {
  38395. // At this point both numbers have the same sign
  38396. if (this.length > num.length) return 1;
  38397. if (this.length < num.length) return -1;
  38398. var res = 0;
  38399. for (var i = this.length - 1; i >= 0; i--) {
  38400. var a = this.words[i] | 0;
  38401. var b = num.words[i] | 0;
  38402. if (a === b) continue;
  38403. if (a < b) {
  38404. res = -1;
  38405. } else if (a > b) {
  38406. res = 1;
  38407. }
  38408. break;
  38409. }
  38410. return res;
  38411. };
  38412. BN.prototype.gtn = function gtn (num) {
  38413. return this.cmpn(num) === 1;
  38414. };
  38415. BN.prototype.gt = function gt (num) {
  38416. return this.cmp(num) === 1;
  38417. };
  38418. BN.prototype.gten = function gten (num) {
  38419. return this.cmpn(num) >= 0;
  38420. };
  38421. BN.prototype.gte = function gte (num) {
  38422. return this.cmp(num) >= 0;
  38423. };
  38424. BN.prototype.ltn = function ltn (num) {
  38425. return this.cmpn(num) === -1;
  38426. };
  38427. BN.prototype.lt = function lt (num) {
  38428. return this.cmp(num) === -1;
  38429. };
  38430. BN.prototype.lten = function lten (num) {
  38431. return this.cmpn(num) <= 0;
  38432. };
  38433. BN.prototype.lte = function lte (num) {
  38434. return this.cmp(num) <= 0;
  38435. };
  38436. BN.prototype.eqn = function eqn (num) {
  38437. return this.cmpn(num) === 0;
  38438. };
  38439. BN.prototype.eq = function eq (num) {
  38440. return this.cmp(num) === 0;
  38441. };
  38442. //
  38443. // A reduce context, could be using montgomery or something better, depending
  38444. // on the `m` itself.
  38445. //
  38446. BN.red = function red (num) {
  38447. return new Red(num);
  38448. };
  38449. BN.prototype.toRed = function toRed (ctx) {
  38450. assert(!this.red, 'Already a number in reduction context');
  38451. assert(this.negative === 0, 'red works only with positives');
  38452. return ctx.convertTo(this)._forceRed(ctx);
  38453. };
  38454. BN.prototype.fromRed = function fromRed () {
  38455. assert(this.red, 'fromRed works only with numbers in reduction context');
  38456. return this.red.convertFrom(this);
  38457. };
  38458. BN.prototype._forceRed = function _forceRed (ctx) {
  38459. this.red = ctx;
  38460. return this;
  38461. };
  38462. BN.prototype.forceRed = function forceRed (ctx) {
  38463. assert(!this.red, 'Already a number in reduction context');
  38464. return this._forceRed(ctx);
  38465. };
  38466. BN.prototype.redAdd = function redAdd (num) {
  38467. assert(this.red, 'redAdd works only with red numbers');
  38468. return this.red.add(this, num);
  38469. };
  38470. BN.prototype.redIAdd = function redIAdd (num) {
  38471. assert(this.red, 'redIAdd works only with red numbers');
  38472. return this.red.iadd(this, num);
  38473. };
  38474. BN.prototype.redSub = function redSub (num) {
  38475. assert(this.red, 'redSub works only with red numbers');
  38476. return this.red.sub(this, num);
  38477. };
  38478. BN.prototype.redISub = function redISub (num) {
  38479. assert(this.red, 'redISub works only with red numbers');
  38480. return this.red.isub(this, num);
  38481. };
  38482. BN.prototype.redShl = function redShl (num) {
  38483. assert(this.red, 'redShl works only with red numbers');
  38484. return this.red.shl(this, num);
  38485. };
  38486. BN.prototype.redMul = function redMul (num) {
  38487. assert(this.red, 'redMul works only with red numbers');
  38488. this.red._verify2(this, num);
  38489. return this.red.mul(this, num);
  38490. };
  38491. BN.prototype.redIMul = function redIMul (num) {
  38492. assert(this.red, 'redMul works only with red numbers');
  38493. this.red._verify2(this, num);
  38494. return this.red.imul(this, num);
  38495. };
  38496. BN.prototype.redSqr = function redSqr () {
  38497. assert(this.red, 'redSqr works only with red numbers');
  38498. this.red._verify1(this);
  38499. return this.red.sqr(this);
  38500. };
  38501. BN.prototype.redISqr = function redISqr () {
  38502. assert(this.red, 'redISqr works only with red numbers');
  38503. this.red._verify1(this);
  38504. return this.red.isqr(this);
  38505. };
  38506. // Square root over p
  38507. BN.prototype.redSqrt = function redSqrt () {
  38508. assert(this.red, 'redSqrt works only with red numbers');
  38509. this.red._verify1(this);
  38510. return this.red.sqrt(this);
  38511. };
  38512. BN.prototype.redInvm = function redInvm () {
  38513. assert(this.red, 'redInvm works only with red numbers');
  38514. this.red._verify1(this);
  38515. return this.red.invm(this);
  38516. };
  38517. // Return negative clone of `this` % `red modulo`
  38518. BN.prototype.redNeg = function redNeg () {
  38519. assert(this.red, 'redNeg works only with red numbers');
  38520. this.red._verify1(this);
  38521. return this.red.neg(this);
  38522. };
  38523. BN.prototype.redPow = function redPow (num) {
  38524. assert(this.red && !num.red, 'redPow(normalNum)');
  38525. this.red._verify1(this);
  38526. return this.red.pow(this, num);
  38527. };
  38528. // Prime numbers with efficient reduction
  38529. var primes = {
  38530. k256: null,
  38531. p224: null,
  38532. p192: null,
  38533. p25519: null
  38534. };
  38535. // Pseudo-Mersenne prime
  38536. function MPrime (name, p) {
  38537. // P = 2 ^ N - K
  38538. this.name = name;
  38539. this.p = new BN(p, 16);
  38540. this.n = this.p.bitLength();
  38541. this.k = new BN(1).iushln(this.n).isub(this.p);
  38542. this.tmp = this._tmp();
  38543. }
  38544. MPrime.prototype._tmp = function _tmp () {
  38545. var tmp = new BN(null);
  38546. tmp.words = new Array(Math.ceil(this.n / 13));
  38547. return tmp;
  38548. };
  38549. MPrime.prototype.ireduce = function ireduce (num) {
  38550. // Assumes that `num` is less than `P^2`
  38551. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  38552. var r = num;
  38553. var rlen;
  38554. do {
  38555. this.split(r, this.tmp);
  38556. r = this.imulK(r);
  38557. r = r.iadd(this.tmp);
  38558. rlen = r.bitLength();
  38559. } while (rlen > this.n);
  38560. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  38561. if (cmp === 0) {
  38562. r.words[0] = 0;
  38563. r.length = 1;
  38564. } else if (cmp > 0) {
  38565. r.isub(this.p);
  38566. } else {
  38567. if (r.strip !== undefined) {
  38568. // r is BN v4 instance
  38569. r.strip();
  38570. } else {
  38571. // r is BN v5 instance
  38572. r._strip();
  38573. }
  38574. }
  38575. return r;
  38576. };
  38577. MPrime.prototype.split = function split (input, out) {
  38578. input.iushrn(this.n, 0, out);
  38579. };
  38580. MPrime.prototype.imulK = function imulK (num) {
  38581. return num.imul(this.k);
  38582. };
  38583. function K256 () {
  38584. MPrime.call(
  38585. this,
  38586. 'k256',
  38587. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  38588. }
  38589. inherits(K256, MPrime);
  38590. K256.prototype.split = function split (input, output) {
  38591. // 256 = 9 * 26 + 22
  38592. var mask = 0x3fffff;
  38593. var outLen = Math.min(input.length, 9);
  38594. for (var i = 0; i < outLen; i++) {
  38595. output.words[i] = input.words[i];
  38596. }
  38597. output.length = outLen;
  38598. if (input.length <= 9) {
  38599. input.words[0] = 0;
  38600. input.length = 1;
  38601. return;
  38602. }
  38603. // Shift by 9 limbs
  38604. var prev = input.words[9];
  38605. output.words[output.length++] = prev & mask;
  38606. for (i = 10; i < input.length; i++) {
  38607. var next = input.words[i] | 0;
  38608. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  38609. prev = next;
  38610. }
  38611. prev >>>= 22;
  38612. input.words[i - 10] = prev;
  38613. if (prev === 0 && input.length > 10) {
  38614. input.length -= 10;
  38615. } else {
  38616. input.length -= 9;
  38617. }
  38618. };
  38619. K256.prototype.imulK = function imulK (num) {
  38620. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  38621. num.words[num.length] = 0;
  38622. num.words[num.length + 1] = 0;
  38623. num.length += 2;
  38624. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  38625. var lo = 0;
  38626. for (var i = 0; i < num.length; i++) {
  38627. var w = num.words[i] | 0;
  38628. lo += w * 0x3d1;
  38629. num.words[i] = lo & 0x3ffffff;
  38630. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  38631. }
  38632. // Fast length reduction
  38633. if (num.words[num.length - 1] === 0) {
  38634. num.length--;
  38635. if (num.words[num.length - 1] === 0) {
  38636. num.length--;
  38637. }
  38638. }
  38639. return num;
  38640. };
  38641. function P224 () {
  38642. MPrime.call(
  38643. this,
  38644. 'p224',
  38645. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  38646. }
  38647. inherits(P224, MPrime);
  38648. function P192 () {
  38649. MPrime.call(
  38650. this,
  38651. 'p192',
  38652. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  38653. }
  38654. inherits(P192, MPrime);
  38655. function P25519 () {
  38656. // 2 ^ 255 - 19
  38657. MPrime.call(
  38658. this,
  38659. '25519',
  38660. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  38661. }
  38662. inherits(P25519, MPrime);
  38663. P25519.prototype.imulK = function imulK (num) {
  38664. // K = 0x13
  38665. var carry = 0;
  38666. for (var i = 0; i < num.length; i++) {
  38667. var hi = (num.words[i] | 0) * 0x13 + carry;
  38668. var lo = hi & 0x3ffffff;
  38669. hi >>>= 26;
  38670. num.words[i] = lo;
  38671. carry = hi;
  38672. }
  38673. if (carry !== 0) {
  38674. num.words[num.length++] = carry;
  38675. }
  38676. return num;
  38677. };
  38678. // Exported mostly for testing purposes, use plain name instead
  38679. BN._prime = function prime (name) {
  38680. // Cached version of prime
  38681. if (primes[name]) return primes[name];
  38682. var prime;
  38683. if (name === 'k256') {
  38684. prime = new K256();
  38685. } else if (name === 'p224') {
  38686. prime = new P224();
  38687. } else if (name === 'p192') {
  38688. prime = new P192();
  38689. } else if (name === 'p25519') {
  38690. prime = new P25519();
  38691. } else {
  38692. throw new Error('Unknown prime ' + name);
  38693. }
  38694. primes[name] = prime;
  38695. return prime;
  38696. };
  38697. //
  38698. // Base reduction engine
  38699. //
  38700. function Red (m) {
  38701. if (typeof m === 'string') {
  38702. var prime = BN._prime(m);
  38703. this.m = prime.p;
  38704. this.prime = prime;
  38705. } else {
  38706. assert(m.gtn(1), 'modulus must be greater than 1');
  38707. this.m = m;
  38708. this.prime = null;
  38709. }
  38710. }
  38711. Red.prototype._verify1 = function _verify1 (a) {
  38712. assert(a.negative === 0, 'red works only with positives');
  38713. assert(a.red, 'red works only with red numbers');
  38714. };
  38715. Red.prototype._verify2 = function _verify2 (a, b) {
  38716. assert((a.negative | b.negative) === 0, 'red works only with positives');
  38717. assert(a.red && a.red === b.red,
  38718. 'red works only with red numbers');
  38719. };
  38720. Red.prototype.imod = function imod (a) {
  38721. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  38722. return a.umod(this.m)._forceRed(this);
  38723. };
  38724. Red.prototype.neg = function neg (a) {
  38725. if (a.isZero()) {
  38726. return a.clone();
  38727. }
  38728. return this.m.sub(a)._forceRed(this);
  38729. };
  38730. Red.prototype.add = function add (a, b) {
  38731. this._verify2(a, b);
  38732. var res = a.add(b);
  38733. if (res.cmp(this.m) >= 0) {
  38734. res.isub(this.m);
  38735. }
  38736. return res._forceRed(this);
  38737. };
  38738. Red.prototype.iadd = function iadd (a, b) {
  38739. this._verify2(a, b);
  38740. var res = a.iadd(b);
  38741. if (res.cmp(this.m) >= 0) {
  38742. res.isub(this.m);
  38743. }
  38744. return res;
  38745. };
  38746. Red.prototype.sub = function sub (a, b) {
  38747. this._verify2(a, b);
  38748. var res = a.sub(b);
  38749. if (res.cmpn(0) < 0) {
  38750. res.iadd(this.m);
  38751. }
  38752. return res._forceRed(this);
  38753. };
  38754. Red.prototype.isub = function isub (a, b) {
  38755. this._verify2(a, b);
  38756. var res = a.isub(b);
  38757. if (res.cmpn(0) < 0) {
  38758. res.iadd(this.m);
  38759. }
  38760. return res;
  38761. };
  38762. Red.prototype.shl = function shl (a, num) {
  38763. this._verify1(a);
  38764. return this.imod(a.ushln(num));
  38765. };
  38766. Red.prototype.imul = function imul (a, b) {
  38767. this._verify2(a, b);
  38768. return this.imod(a.imul(b));
  38769. };
  38770. Red.prototype.mul = function mul (a, b) {
  38771. this._verify2(a, b);
  38772. return this.imod(a.mul(b));
  38773. };
  38774. Red.prototype.isqr = function isqr (a) {
  38775. return this.imul(a, a.clone());
  38776. };
  38777. Red.prototype.sqr = function sqr (a) {
  38778. return this.mul(a, a);
  38779. };
  38780. Red.prototype.sqrt = function sqrt (a) {
  38781. if (a.isZero()) return a.clone();
  38782. var mod3 = this.m.andln(3);
  38783. assert(mod3 % 2 === 1);
  38784. // Fast case
  38785. if (mod3 === 3) {
  38786. var pow = this.m.add(new BN(1)).iushrn(2);
  38787. return this.pow(a, pow);
  38788. }
  38789. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  38790. //
  38791. // Find Q and S, that Q * 2 ^ S = (P - 1)
  38792. var q = this.m.subn(1);
  38793. var s = 0;
  38794. while (!q.isZero() && q.andln(1) === 0) {
  38795. s++;
  38796. q.iushrn(1);
  38797. }
  38798. assert(!q.isZero());
  38799. var one = new BN(1).toRed(this);
  38800. var nOne = one.redNeg();
  38801. // Find quadratic non-residue
  38802. // NOTE: Max is such because of generalized Riemann hypothesis.
  38803. var lpow = this.m.subn(1).iushrn(1);
  38804. var z = this.m.bitLength();
  38805. z = new BN(2 * z * z).toRed(this);
  38806. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  38807. z.redIAdd(nOne);
  38808. }
  38809. var c = this.pow(z, q);
  38810. var r = this.pow(a, q.addn(1).iushrn(1));
  38811. var t = this.pow(a, q);
  38812. var m = s;
  38813. while (t.cmp(one) !== 0) {
  38814. var tmp = t;
  38815. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  38816. tmp = tmp.redSqr();
  38817. }
  38818. assert(i < m);
  38819. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  38820. r = r.redMul(b);
  38821. c = b.redSqr();
  38822. t = t.redMul(c);
  38823. m = i;
  38824. }
  38825. return r;
  38826. };
  38827. Red.prototype.invm = function invm (a) {
  38828. var inv = a._invmp(this.m);
  38829. if (inv.negative !== 0) {
  38830. inv.negative = 0;
  38831. return this.imod(inv).redNeg();
  38832. } else {
  38833. return this.imod(inv);
  38834. }
  38835. };
  38836. Red.prototype.pow = function pow (a, num) {
  38837. if (num.isZero()) return new BN(1).toRed(this);
  38838. if (num.cmpn(1) === 0) return a.clone();
  38839. var windowSize = 4;
  38840. var wnd = new Array(1 << windowSize);
  38841. wnd[0] = new BN(1).toRed(this);
  38842. wnd[1] = a;
  38843. for (var i = 2; i < wnd.length; i++) {
  38844. wnd[i] = this.mul(wnd[i - 1], a);
  38845. }
  38846. var res = wnd[0];
  38847. var current = 0;
  38848. var currentLen = 0;
  38849. var start = num.bitLength() % 26;
  38850. if (start === 0) {
  38851. start = 26;
  38852. }
  38853. for (i = num.length - 1; i >= 0; i--) {
  38854. var word = num.words[i];
  38855. for (var j = start - 1; j >= 0; j--) {
  38856. var bit = (word >> j) & 1;
  38857. if (res !== wnd[0]) {
  38858. res = this.sqr(res);
  38859. }
  38860. if (bit === 0 && current === 0) {
  38861. currentLen = 0;
  38862. continue;
  38863. }
  38864. current <<= 1;
  38865. current |= bit;
  38866. currentLen++;
  38867. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  38868. res = this.mul(res, wnd[current]);
  38869. currentLen = 0;
  38870. current = 0;
  38871. }
  38872. start = 26;
  38873. }
  38874. return res;
  38875. };
  38876. Red.prototype.convertTo = function convertTo (num) {
  38877. var r = num.umod(this.m);
  38878. return r === num ? r.clone() : r;
  38879. };
  38880. Red.prototype.convertFrom = function convertFrom (num) {
  38881. var res = num.clone();
  38882. res.red = null;
  38883. return res;
  38884. };
  38885. //
  38886. // Montgomery method engine
  38887. //
  38888. BN.mont = function mont (num) {
  38889. return new Mont(num);
  38890. };
  38891. function Mont (m) {
  38892. Red.call(this, m);
  38893. this.shift = this.m.bitLength();
  38894. if (this.shift % 26 !== 0) {
  38895. this.shift += 26 - (this.shift % 26);
  38896. }
  38897. this.r = new BN(1).iushln(this.shift);
  38898. this.r2 = this.imod(this.r.sqr());
  38899. this.rinv = this.r._invmp(this.m);
  38900. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  38901. this.minv = this.minv.umod(this.r);
  38902. this.minv = this.r.sub(this.minv);
  38903. }
  38904. inherits(Mont, Red);
  38905. Mont.prototype.convertTo = function convertTo (num) {
  38906. return this.imod(num.ushln(this.shift));
  38907. };
  38908. Mont.prototype.convertFrom = function convertFrom (num) {
  38909. var r = this.imod(num.mul(this.rinv));
  38910. r.red = null;
  38911. return r;
  38912. };
  38913. Mont.prototype.imul = function imul (a, b) {
  38914. if (a.isZero() || b.isZero()) {
  38915. a.words[0] = 0;
  38916. a.length = 1;
  38917. return a;
  38918. }
  38919. var t = a.imul(b);
  38920. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  38921. var u = t.isub(c).iushrn(this.shift);
  38922. var res = u;
  38923. if (u.cmp(this.m) >= 0) {
  38924. res = u.isub(this.m);
  38925. } else if (u.cmpn(0) < 0) {
  38926. res = u.iadd(this.m);
  38927. }
  38928. return res._forceRed(this);
  38929. };
  38930. Mont.prototype.mul = function mul (a, b) {
  38931. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  38932. var t = a.mul(b);
  38933. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  38934. var u = t.isub(c).iushrn(this.shift);
  38935. var res = u;
  38936. if (u.cmp(this.m) >= 0) {
  38937. res = u.isub(this.m);
  38938. } else if (u.cmpn(0) < 0) {
  38939. res = u.iadd(this.m);
  38940. }
  38941. return res._forceRed(this);
  38942. };
  38943. Mont.prototype.invm = function invm (a) {
  38944. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  38945. var res = this.imod(a._invmp(this.m).mul(this.r2));
  38946. return res._forceRed(this);
  38947. };
  38948. })( false || module, this);
  38949. /***/ }),
  38950. /***/ "./node_modules/events/events.js":
  38951. /*!***************************************!*\
  38952. !*** ./node_modules/events/events.js ***!
  38953. \***************************************/
  38954. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  38955. "use strict";
  38956. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  38957. // Copyright Joyent, Inc. and other Node contributors.
  38958. //
  38959. // Permission is hereby granted, free of charge, to any person obtaining a
  38960. // copy of this software and associated documentation files (the
  38961. // "Software"), to deal in the Software without restriction, including
  38962. // without limitation the rights to use, copy, modify, merge, publish,
  38963. // distribute, sublicense, and/or sell copies of the Software, and to permit
  38964. // persons to whom the Software is furnished to do so, subject to the
  38965. // following conditions:
  38966. //
  38967. // The above copyright notice and this permission notice shall be included
  38968. // in all copies or substantial portions of the Software.
  38969. //
  38970. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  38971. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  38972. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  38973. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  38974. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  38975. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  38976. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  38977. var R = typeof Reflect === 'object' ? Reflect : null
  38978. var ReflectApply = R && typeof R.apply === 'function'
  38979. ? R.apply
  38980. : function ReflectApply(target, receiver, args) {
  38981. return Function.prototype.apply.call(target, receiver, args);
  38982. }
  38983. var ReflectOwnKeys
  38984. if (R && typeof R.ownKeys === 'function') {
  38985. ReflectOwnKeys = R.ownKeys
  38986. } else if (Object.getOwnPropertySymbols) {
  38987. ReflectOwnKeys = function ReflectOwnKeys(target) {
  38988. return Object.getOwnPropertyNames(target)
  38989. .concat(Object.getOwnPropertySymbols(target));
  38990. };
  38991. } else {
  38992. ReflectOwnKeys = function ReflectOwnKeys(target) {
  38993. return Object.getOwnPropertyNames(target);
  38994. };
  38995. }
  38996. function ProcessEmitWarning(warning) {
  38997. if (console && console.warn) console.warn(warning);
  38998. }
  38999. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  39000. return value !== value;
  39001. }
  39002. function EventEmitter() {
  39003. EventEmitter.init.call(this);
  39004. }
  39005. module.exports = EventEmitter;
  39006. module.exports.once = once;
  39007. // Backwards-compat with node 0.10.x
  39008. EventEmitter.EventEmitter = EventEmitter;
  39009. EventEmitter.prototype._events = undefined;
  39010. EventEmitter.prototype._eventsCount = 0;
  39011. EventEmitter.prototype._maxListeners = undefined;
  39012. // By default EventEmitters will print a warning if more than 10 listeners are
  39013. // added to it. This is a useful default which helps finding memory leaks.
  39014. var defaultMaxListeners = 10;
  39015. function checkListener(listener) {
  39016. if (typeof listener !== 'function') {
  39017. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  39018. }
  39019. }
  39020. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  39021. enumerable: true,
  39022. get: function() {
  39023. return defaultMaxListeners;
  39024. },
  39025. set: function(arg) {
  39026. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  39027. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  39028. }
  39029. defaultMaxListeners = arg;
  39030. }
  39031. });
  39032. EventEmitter.init = function() {
  39033. if (this._events === undefined ||
  39034. this._events === Object.getPrototypeOf(this)._events) {
  39035. this._events = Object.create(null);
  39036. this._eventsCount = 0;
  39037. }
  39038. this._maxListeners = this._maxListeners || undefined;
  39039. };
  39040. // Obviously not all Emitters should be limited to 10. This function allows
  39041. // that to be increased. Set to zero for unlimited.
  39042. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  39043. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  39044. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  39045. }
  39046. this._maxListeners = n;
  39047. return this;
  39048. };
  39049. function _getMaxListeners(that) {
  39050. if (that._maxListeners === undefined)
  39051. return EventEmitter.defaultMaxListeners;
  39052. return that._maxListeners;
  39053. }
  39054. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  39055. return _getMaxListeners(this);
  39056. };
  39057. EventEmitter.prototype.emit = function emit(type) {
  39058. var args = [];
  39059. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  39060. var doError = (type === 'error');
  39061. var events = this._events;
  39062. if (events !== undefined)
  39063. doError = (doError && events.error === undefined);
  39064. else if (!doError)
  39065. return false;
  39066. // If there is no 'error' event listener then throw.
  39067. if (doError) {
  39068. var er;
  39069. if (args.length > 0)
  39070. er = args[0];
  39071. if (er instanceof Error) {
  39072. // Note: The comments on the `throw` lines are intentional, they show
  39073. // up in Node's output if this results in an unhandled exception.
  39074. throw er; // Unhandled 'error' event
  39075. }
  39076. // At least give some kind of context to the user
  39077. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  39078. err.context = er;
  39079. throw err; // Unhandled 'error' event
  39080. }
  39081. var handler = events[type];
  39082. if (handler === undefined)
  39083. return false;
  39084. if (typeof handler === 'function') {
  39085. ReflectApply(handler, this, args);
  39086. } else {
  39087. var len = handler.length;
  39088. var listeners = arrayClone(handler, len);
  39089. for (var i = 0; i < len; ++i)
  39090. ReflectApply(listeners[i], this, args);
  39091. }
  39092. return true;
  39093. };
  39094. function _addListener(target, type, listener, prepend) {
  39095. var m;
  39096. var events;
  39097. var existing;
  39098. checkListener(listener);
  39099. events = target._events;
  39100. if (events === undefined) {
  39101. events = target._events = Object.create(null);
  39102. target._eventsCount = 0;
  39103. } else {
  39104. // To avoid recursion in the case that type === "newListener"! Before
  39105. // adding it to the listeners, first emit "newListener".
  39106. if (events.newListener !== undefined) {
  39107. target.emit('newListener', type,
  39108. listener.listener ? listener.listener : listener);
  39109. // Re-assign `events` because a newListener handler could have caused the
  39110. // this._events to be assigned to a new object
  39111. events = target._events;
  39112. }
  39113. existing = events[type];
  39114. }
  39115. if (existing === undefined) {
  39116. // Optimize the case of one listener. Don't need the extra array object.
  39117. existing = events[type] = listener;
  39118. ++target._eventsCount;
  39119. } else {
  39120. if (typeof existing === 'function') {
  39121. // Adding the second element, need to change to array.
  39122. existing = events[type] =
  39123. prepend ? [listener, existing] : [existing, listener];
  39124. // If we've already got an array, just append.
  39125. } else if (prepend) {
  39126. existing.unshift(listener);
  39127. } else {
  39128. existing.push(listener);
  39129. }
  39130. // Check for listener leak
  39131. m = _getMaxListeners(target);
  39132. if (m > 0 && existing.length > m && !existing.warned) {
  39133. existing.warned = true;
  39134. // No error code for this since it is a Warning
  39135. // eslint-disable-next-line no-restricted-syntax
  39136. var w = new Error('Possible EventEmitter memory leak detected. ' +
  39137. existing.length + ' ' + String(type) + ' listeners ' +
  39138. 'added. Use emitter.setMaxListeners() to ' +
  39139. 'increase limit');
  39140. w.name = 'MaxListenersExceededWarning';
  39141. w.emitter = target;
  39142. w.type = type;
  39143. w.count = existing.length;
  39144. ProcessEmitWarning(w);
  39145. }
  39146. }
  39147. return target;
  39148. }
  39149. EventEmitter.prototype.addListener = function addListener(type, listener) {
  39150. return _addListener(this, type, listener, false);
  39151. };
  39152. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  39153. EventEmitter.prototype.prependListener =
  39154. function prependListener(type, listener) {
  39155. return _addListener(this, type, listener, true);
  39156. };
  39157. function onceWrapper() {
  39158. if (!this.fired) {
  39159. this.target.removeListener(this.type, this.wrapFn);
  39160. this.fired = true;
  39161. if (arguments.length === 0)
  39162. return this.listener.call(this.target);
  39163. return this.listener.apply(this.target, arguments);
  39164. }
  39165. }
  39166. function _onceWrap(target, type, listener) {
  39167. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  39168. var wrapped = onceWrapper.bind(state);
  39169. wrapped.listener = listener;
  39170. state.wrapFn = wrapped;
  39171. return wrapped;
  39172. }
  39173. EventEmitter.prototype.once = function once(type, listener) {
  39174. checkListener(listener);
  39175. this.on(type, _onceWrap(this, type, listener));
  39176. return this;
  39177. };
  39178. EventEmitter.prototype.prependOnceListener =
  39179. function prependOnceListener(type, listener) {
  39180. checkListener(listener);
  39181. this.prependListener(type, _onceWrap(this, type, listener));
  39182. return this;
  39183. };
  39184. // Emits a 'removeListener' event if and only if the listener was removed.
  39185. EventEmitter.prototype.removeListener =
  39186. function removeListener(type, listener) {
  39187. var list, events, position, i, originalListener;
  39188. checkListener(listener);
  39189. events = this._events;
  39190. if (events === undefined)
  39191. return this;
  39192. list = events[type];
  39193. if (list === undefined)
  39194. return this;
  39195. if (list === listener || list.listener === listener) {
  39196. if (--this._eventsCount === 0)
  39197. this._events = Object.create(null);
  39198. else {
  39199. delete events[type];
  39200. if (events.removeListener)
  39201. this.emit('removeListener', type, list.listener || listener);
  39202. }
  39203. } else if (typeof list !== 'function') {
  39204. position = -1;
  39205. for (i = list.length - 1; i >= 0; i--) {
  39206. if (list[i] === listener || list[i].listener === listener) {
  39207. originalListener = list[i].listener;
  39208. position = i;
  39209. break;
  39210. }
  39211. }
  39212. if (position < 0)
  39213. return this;
  39214. if (position === 0)
  39215. list.shift();
  39216. else {
  39217. spliceOne(list, position);
  39218. }
  39219. if (list.length === 1)
  39220. events[type] = list[0];
  39221. if (events.removeListener !== undefined)
  39222. this.emit('removeListener', type, originalListener || listener);
  39223. }
  39224. return this;
  39225. };
  39226. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  39227. EventEmitter.prototype.removeAllListeners =
  39228. function removeAllListeners(type) {
  39229. var listeners, events, i;
  39230. events = this._events;
  39231. if (events === undefined)
  39232. return this;
  39233. // not listening for removeListener, no need to emit
  39234. if (events.removeListener === undefined) {
  39235. if (arguments.length === 0) {
  39236. this._events = Object.create(null);
  39237. this._eventsCount = 0;
  39238. } else if (events[type] !== undefined) {
  39239. if (--this._eventsCount === 0)
  39240. this._events = Object.create(null);
  39241. else
  39242. delete events[type];
  39243. }
  39244. return this;
  39245. }
  39246. // emit removeListener for all listeners on all events
  39247. if (arguments.length === 0) {
  39248. var keys = Object.keys(events);
  39249. var key;
  39250. for (i = 0; i < keys.length; ++i) {
  39251. key = keys[i];
  39252. if (key === 'removeListener') continue;
  39253. this.removeAllListeners(key);
  39254. }
  39255. this.removeAllListeners('removeListener');
  39256. this._events = Object.create(null);
  39257. this._eventsCount = 0;
  39258. return this;
  39259. }
  39260. listeners = events[type];
  39261. if (typeof listeners === 'function') {
  39262. this.removeListener(type, listeners);
  39263. } else if (listeners !== undefined) {
  39264. // LIFO order
  39265. for (i = listeners.length - 1; i >= 0; i--) {
  39266. this.removeListener(type, listeners[i]);
  39267. }
  39268. }
  39269. return this;
  39270. };
  39271. function _listeners(target, type, unwrap) {
  39272. var events = target._events;
  39273. if (events === undefined)
  39274. return [];
  39275. var evlistener = events[type];
  39276. if (evlistener === undefined)
  39277. return [];
  39278. if (typeof evlistener === 'function')
  39279. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  39280. return unwrap ?
  39281. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  39282. }
  39283. EventEmitter.prototype.listeners = function listeners(type) {
  39284. return _listeners(this, type, true);
  39285. };
  39286. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  39287. return _listeners(this, type, false);
  39288. };
  39289. EventEmitter.listenerCount = function(emitter, type) {
  39290. if (typeof emitter.listenerCount === 'function') {
  39291. return emitter.listenerCount(type);
  39292. } else {
  39293. return listenerCount.call(emitter, type);
  39294. }
  39295. };
  39296. EventEmitter.prototype.listenerCount = listenerCount;
  39297. function listenerCount(type) {
  39298. var events = this._events;
  39299. if (events !== undefined) {
  39300. var evlistener = events[type];
  39301. if (typeof evlistener === 'function') {
  39302. return 1;
  39303. } else if (evlistener !== undefined) {
  39304. return evlistener.length;
  39305. }
  39306. }
  39307. return 0;
  39308. }
  39309. EventEmitter.prototype.eventNames = function eventNames() {
  39310. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  39311. };
  39312. function arrayClone(arr, n) {
  39313. var copy = new Array(n);
  39314. for (var i = 0; i < n; ++i)
  39315. copy[i] = arr[i];
  39316. return copy;
  39317. }
  39318. function spliceOne(list, index) {
  39319. for (; index + 1 < list.length; index++)
  39320. list[index] = list[index + 1];
  39321. list.pop();
  39322. }
  39323. function unwrapListeners(arr) {
  39324. var ret = new Array(arr.length);
  39325. for (var i = 0; i < ret.length; ++i) {
  39326. ret[i] = arr[i].listener || arr[i];
  39327. }
  39328. return ret;
  39329. }
  39330. function once(emitter, name) {
  39331. return new Promise(function (resolve, reject) {
  39332. function errorListener(err) {
  39333. emitter.removeListener(name, resolver);
  39334. reject(err);
  39335. }
  39336. function resolver() {
  39337. if (typeof emitter.removeListener === 'function') {
  39338. emitter.removeListener('error', errorListener);
  39339. }
  39340. resolve([].slice.call(arguments));
  39341. };
  39342. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  39343. if (name !== 'error') {
  39344. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  39345. }
  39346. });
  39347. }
  39348. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  39349. if (typeof emitter.on === 'function') {
  39350. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  39351. }
  39352. }
  39353. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  39354. if (typeof emitter.on === 'function') {
  39355. if (flags.once) {
  39356. emitter.once(name, listener);
  39357. } else {
  39358. emitter.on(name, listener);
  39359. }
  39360. } else if (typeof emitter.addEventListener === 'function') {
  39361. // EventTarget does not have `error` event semantics like Node
  39362. // EventEmitters, we do not listen for `error` events here.
  39363. emitter.addEventListener(name, function wrapListener(arg) {
  39364. // IE does not have builtin `{ once: true }` support so we
  39365. // have to do it manually.
  39366. if (flags.once) {
  39367. emitter.removeEventListener(name, wrapListener);
  39368. }
  39369. listener(arg);
  39370. });
  39371. } else {
  39372. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  39373. }
  39374. }
  39375. /***/ }),
  39376. /***/ "./node_modules/evp_bytestokey/index.js":
  39377. /*!**********************************************!*\
  39378. !*** ./node_modules/evp_bytestokey/index.js ***!
  39379. \**********************************************/
  39380. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  39381. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  39382. var MD5 = __webpack_require__(/*! md5.js */ "./node_modules/md5.js/index.js")
  39383. /* eslint-disable camelcase */
  39384. function EVP_BytesToKey (password, salt, keyBits, ivLen) {
  39385. if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
  39386. if (salt) {
  39387. if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
  39388. if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
  39389. }
  39390. var keyLen = keyBits / 8
  39391. var key = Buffer.alloc(keyLen)
  39392. var iv = Buffer.alloc(ivLen || 0)
  39393. var tmp = Buffer.alloc(0)
  39394. while (keyLen > 0 || ivLen > 0) {
  39395. var hash = new MD5()
  39396. hash.update(tmp)
  39397. hash.update(password)
  39398. if (salt) hash.update(salt)
  39399. tmp = hash.digest()
  39400. var used = 0
  39401. if (keyLen > 0) {
  39402. var keyStart = key.length - keyLen
  39403. used = Math.min(keyLen, tmp.length)
  39404. tmp.copy(key, keyStart, 0, used)
  39405. keyLen -= used
  39406. }
  39407. if (used < tmp.length && ivLen > 0) {
  39408. var ivStart = iv.length - ivLen
  39409. var length = Math.min(ivLen, tmp.length - used)
  39410. tmp.copy(iv, ivStart, used, used + length)
  39411. ivLen -= length
  39412. }
  39413. }
  39414. tmp.fill(0)
  39415. return { key: key, iv: iv }
  39416. }
  39417. module.exports = EVP_BytesToKey
  39418. /***/ }),
  39419. /***/ "./node_modules/hash-base/index.js":
  39420. /*!*****************************************!*\
  39421. !*** ./node_modules/hash-base/index.js ***!
  39422. \*****************************************/
  39423. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  39424. "use strict";
  39425. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/hash-base/node_modules/safe-buffer/index.js").Buffer)
  39426. var Transform = (__webpack_require__(/*! readable-stream */ "./node_modules/hash-base/node_modules/readable-stream/readable-browser.js").Transform)
  39427. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  39428. function throwIfNotStringOrBuffer (val, prefix) {
  39429. if (!Buffer.isBuffer(val) && typeof val !== 'string') {
  39430. throw new TypeError(prefix + ' must be a string or a buffer')
  39431. }
  39432. }
  39433. function HashBase (blockSize) {
  39434. Transform.call(this)
  39435. this._block = Buffer.allocUnsafe(blockSize)
  39436. this._blockSize = blockSize
  39437. this._blockOffset = 0
  39438. this._length = [0, 0, 0, 0]
  39439. this._finalized = false
  39440. }
  39441. inherits(HashBase, Transform)
  39442. HashBase.prototype._transform = function (chunk, encoding, callback) {
  39443. var error = null
  39444. try {
  39445. this.update(chunk, encoding)
  39446. } catch (err) {
  39447. error = err
  39448. }
  39449. callback(error)
  39450. }
  39451. HashBase.prototype._flush = function (callback) {
  39452. var error = null
  39453. try {
  39454. this.push(this.digest())
  39455. } catch (err) {
  39456. error = err
  39457. }
  39458. callback(error)
  39459. }
  39460. HashBase.prototype.update = function (data, encoding) {
  39461. throwIfNotStringOrBuffer(data, 'Data')
  39462. if (this._finalized) throw new Error('Digest already called')
  39463. if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
  39464. // consume data
  39465. var block = this._block
  39466. var offset = 0
  39467. while (this._blockOffset + data.length - offset >= this._blockSize) {
  39468. for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
  39469. this._update()
  39470. this._blockOffset = 0
  39471. }
  39472. while (offset < data.length) block[this._blockOffset++] = data[offset++]
  39473. // update length
  39474. for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
  39475. this._length[j] += carry
  39476. carry = (this._length[j] / 0x0100000000) | 0
  39477. if (carry > 0) this._length[j] -= 0x0100000000 * carry
  39478. }
  39479. return this
  39480. }
  39481. HashBase.prototype._update = function () {
  39482. throw new Error('_update is not implemented')
  39483. }
  39484. HashBase.prototype.digest = function (encoding) {
  39485. if (this._finalized) throw new Error('Digest already called')
  39486. this._finalized = true
  39487. var digest = this._digest()
  39488. if (encoding !== undefined) digest = digest.toString(encoding)
  39489. // reset state
  39490. this._block.fill(0)
  39491. this._blockOffset = 0
  39492. for (var i = 0; i < 4; ++i) this._length[i] = 0
  39493. return digest
  39494. }
  39495. HashBase.prototype._digest = function () {
  39496. throw new Error('_digest is not implemented')
  39497. }
  39498. module.exports = HashBase
  39499. /***/ }),
  39500. /***/ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js":
  39501. /*!*******************************************************************************!*\
  39502. !*** ./node_modules/hash-base/node_modules/readable-stream/errors-browser.js ***!
  39503. \*******************************************************************************/
  39504. /***/ ((module) => {
  39505. "use strict";
  39506. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  39507. var codes = {};
  39508. function createErrorType(code, message, Base) {
  39509. if (!Base) {
  39510. Base = Error;
  39511. }
  39512. function getMessage(arg1, arg2, arg3) {
  39513. if (typeof message === 'string') {
  39514. return message;
  39515. } else {
  39516. return message(arg1, arg2, arg3);
  39517. }
  39518. }
  39519. var NodeError =
  39520. /*#__PURE__*/
  39521. function (_Base) {
  39522. _inheritsLoose(NodeError, _Base);
  39523. function NodeError(arg1, arg2, arg3) {
  39524. return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
  39525. }
  39526. return NodeError;
  39527. }(Base);
  39528. NodeError.prototype.name = Base.name;
  39529. NodeError.prototype.code = code;
  39530. codes[code] = NodeError;
  39531. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  39532. function oneOf(expected, thing) {
  39533. if (Array.isArray(expected)) {
  39534. var len = expected.length;
  39535. expected = expected.map(function (i) {
  39536. return String(i);
  39537. });
  39538. if (len > 2) {
  39539. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  39540. } else if (len === 2) {
  39541. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  39542. } else {
  39543. return "of ".concat(thing, " ").concat(expected[0]);
  39544. }
  39545. } else {
  39546. return "of ".concat(thing, " ").concat(String(expected));
  39547. }
  39548. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  39549. function startsWith(str, search, pos) {
  39550. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  39551. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  39552. function endsWith(str, search, this_len) {
  39553. if (this_len === undefined || this_len > str.length) {
  39554. this_len = str.length;
  39555. }
  39556. return str.substring(this_len - search.length, this_len) === search;
  39557. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  39558. function includes(str, search, start) {
  39559. if (typeof start !== 'number') {
  39560. start = 0;
  39561. }
  39562. if (start + search.length > str.length) {
  39563. return false;
  39564. } else {
  39565. return str.indexOf(search, start) !== -1;
  39566. }
  39567. }
  39568. createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
  39569. return 'The value "' + value + '" is invalid for option "' + name + '"';
  39570. }, TypeError);
  39571. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  39572. // determiner: 'must be' or 'must not be'
  39573. var determiner;
  39574. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  39575. determiner = 'must not be';
  39576. expected = expected.replace(/^not /, '');
  39577. } else {
  39578. determiner = 'must be';
  39579. }
  39580. var msg;
  39581. if (endsWith(name, ' argument')) {
  39582. // For cases like 'first argument'
  39583. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  39584. } else {
  39585. var type = includes(name, '.') ? 'property' : 'argument';
  39586. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  39587. }
  39588. msg += ". Received type ".concat(typeof actual);
  39589. return msg;
  39590. }, TypeError);
  39591. createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
  39592. createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
  39593. return 'The ' + name + ' method is not implemented';
  39594. });
  39595. createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
  39596. createErrorType('ERR_STREAM_DESTROYED', function (name) {
  39597. return 'Cannot call ' + name + ' after a stream was destroyed';
  39598. });
  39599. createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
  39600. createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
  39601. createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
  39602. createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
  39603. createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
  39604. return 'Unknown encoding: ' + arg;
  39605. }, TypeError);
  39606. createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
  39607. module.exports.codes = codes;
  39608. /***/ }),
  39609. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js":
  39610. /*!***********************************************************************************!*\
  39611. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js ***!
  39612. \***********************************************************************************/
  39613. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  39614. "use strict";
  39615. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  39616. // Copyright Joyent, Inc. and other Node contributors.
  39617. //
  39618. // Permission is hereby granted, free of charge, to any person obtaining a
  39619. // copy of this software and associated documentation files (the
  39620. // "Software"), to deal in the Software without restriction, including
  39621. // without limitation the rights to use, copy, modify, merge, publish,
  39622. // distribute, sublicense, and/or sell copies of the Software, and to permit
  39623. // persons to whom the Software is furnished to do so, subject to the
  39624. // following conditions:
  39625. //
  39626. // The above copyright notice and this permission notice shall be included
  39627. // in all copies or substantial portions of the Software.
  39628. //
  39629. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  39630. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39631. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  39632. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  39633. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  39634. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  39635. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  39636. // a duplex stream is just a stream that is both readable and writable.
  39637. // Since JS doesn't have multiple prototypal inheritance, this class
  39638. // prototypally inherits from Readable, and then parasitically from
  39639. // Writable.
  39640. /*<replacement>*/
  39641. var objectKeys = Object.keys || function (obj) {
  39642. var keys = [];
  39643. for (var key in obj) {
  39644. keys.push(key);
  39645. }
  39646. return keys;
  39647. };
  39648. /*</replacement>*/
  39649. module.exports = Duplex;
  39650. var Readable = __webpack_require__(/*! ./_stream_readable */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js");
  39651. var Writable = __webpack_require__(/*! ./_stream_writable */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js");
  39652. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Duplex, Readable);
  39653. {
  39654. // Allow the keys array to be GC'ed.
  39655. var keys = objectKeys(Writable.prototype);
  39656. for (var v = 0; v < keys.length; v++) {
  39657. var method = keys[v];
  39658. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  39659. }
  39660. }
  39661. function Duplex(options) {
  39662. if (!(this instanceof Duplex)) return new Duplex(options);
  39663. Readable.call(this, options);
  39664. Writable.call(this, options);
  39665. this.allowHalfOpen = true;
  39666. if (options) {
  39667. if (options.readable === false) this.readable = false;
  39668. if (options.writable === false) this.writable = false;
  39669. if (options.allowHalfOpen === false) {
  39670. this.allowHalfOpen = false;
  39671. this.once('end', onend);
  39672. }
  39673. }
  39674. }
  39675. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  39676. // making it explicit this property is not enumerable
  39677. // because otherwise some prototype manipulation in
  39678. // userland will fail
  39679. enumerable: false,
  39680. get: function get() {
  39681. return this._writableState.highWaterMark;
  39682. }
  39683. });
  39684. Object.defineProperty(Duplex.prototype, 'writableBuffer', {
  39685. // making it explicit this property is not enumerable
  39686. // because otherwise some prototype manipulation in
  39687. // userland will fail
  39688. enumerable: false,
  39689. get: function get() {
  39690. return this._writableState && this._writableState.getBuffer();
  39691. }
  39692. });
  39693. Object.defineProperty(Duplex.prototype, 'writableLength', {
  39694. // making it explicit this property is not enumerable
  39695. // because otherwise some prototype manipulation in
  39696. // userland will fail
  39697. enumerable: false,
  39698. get: function get() {
  39699. return this._writableState.length;
  39700. }
  39701. }); // the no-half-open enforcer
  39702. function onend() {
  39703. // If the writable side ended, then we're ok.
  39704. if (this._writableState.ended) return; // no more data can be written.
  39705. // But allow more writes to happen in this tick.
  39706. process.nextTick(onEndNT, this);
  39707. }
  39708. function onEndNT(self) {
  39709. self.end();
  39710. }
  39711. Object.defineProperty(Duplex.prototype, 'destroyed', {
  39712. // making it explicit this property is not enumerable
  39713. // because otherwise some prototype manipulation in
  39714. // userland will fail
  39715. enumerable: false,
  39716. get: function get() {
  39717. if (this._readableState === undefined || this._writableState === undefined) {
  39718. return false;
  39719. }
  39720. return this._readableState.destroyed && this._writableState.destroyed;
  39721. },
  39722. set: function set(value) {
  39723. // we ignore the value if the stream
  39724. // has not been initialized yet
  39725. if (this._readableState === undefined || this._writableState === undefined) {
  39726. return;
  39727. } // backward compatibility, the user is explicitly
  39728. // managing destroyed
  39729. this._readableState.destroyed = value;
  39730. this._writableState.destroyed = value;
  39731. }
  39732. });
  39733. /***/ }),
  39734. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_passthrough.js":
  39735. /*!****************************************************************************************!*\
  39736. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_passthrough.js ***!
  39737. \****************************************************************************************/
  39738. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  39739. "use strict";
  39740. // Copyright Joyent, Inc. and other Node contributors.
  39741. //
  39742. // Permission is hereby granted, free of charge, to any person obtaining a
  39743. // copy of this software and associated documentation files (the
  39744. // "Software"), to deal in the Software without restriction, including
  39745. // without limitation the rights to use, copy, modify, merge, publish,
  39746. // distribute, sublicense, and/or sell copies of the Software, and to permit
  39747. // persons to whom the Software is furnished to do so, subject to the
  39748. // following conditions:
  39749. //
  39750. // The above copyright notice and this permission notice shall be included
  39751. // in all copies or substantial portions of the Software.
  39752. //
  39753. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  39754. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39755. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  39756. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  39757. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  39758. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  39759. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  39760. // a passthrough stream.
  39761. // basically just the most minimal sort of Transform stream.
  39762. // Every written chunk gets output as-is.
  39763. module.exports = PassThrough;
  39764. var Transform = __webpack_require__(/*! ./_stream_transform */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_transform.js");
  39765. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(PassThrough, Transform);
  39766. function PassThrough(options) {
  39767. if (!(this instanceof PassThrough)) return new PassThrough(options);
  39768. Transform.call(this, options);
  39769. }
  39770. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  39771. cb(null, chunk);
  39772. };
  39773. /***/ }),
  39774. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js":
  39775. /*!*************************************************************************************!*\
  39776. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js ***!
  39777. \*************************************************************************************/
  39778. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  39779. "use strict";
  39780. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  39781. // Copyright Joyent, Inc. and other Node contributors.
  39782. //
  39783. // Permission is hereby granted, free of charge, to any person obtaining a
  39784. // copy of this software and associated documentation files (the
  39785. // "Software"), to deal in the Software without restriction, including
  39786. // without limitation the rights to use, copy, modify, merge, publish,
  39787. // distribute, sublicense, and/or sell copies of the Software, and to permit
  39788. // persons to whom the Software is furnished to do so, subject to the
  39789. // following conditions:
  39790. //
  39791. // The above copyright notice and this permission notice shall be included
  39792. // in all copies or substantial portions of the Software.
  39793. //
  39794. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  39795. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39796. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  39797. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  39798. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  39799. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  39800. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  39801. module.exports = Readable;
  39802. /*<replacement>*/
  39803. var Duplex;
  39804. /*</replacement>*/
  39805. Readable.ReadableState = ReadableState;
  39806. /*<replacement>*/
  39807. var EE = (__webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter);
  39808. var EElistenerCount = function EElistenerCount(emitter, type) {
  39809. return emitter.listeners(type).length;
  39810. };
  39811. /*</replacement>*/
  39812. /*<replacement>*/
  39813. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  39814. /*</replacement>*/
  39815. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/buffer/index.js").Buffer);
  39816. var OurUint8Array = __webpack_require__.g.Uint8Array || function () {};
  39817. function _uint8ArrayToBuffer(chunk) {
  39818. return Buffer.from(chunk);
  39819. }
  39820. function _isUint8Array(obj) {
  39821. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  39822. }
  39823. /*<replacement>*/
  39824. var debugUtil = __webpack_require__(/*! util */ "?11f8");
  39825. var debug;
  39826. if (debugUtil && debugUtil.debuglog) {
  39827. debug = debugUtil.debuglog('stream');
  39828. } else {
  39829. debug = function debug() {};
  39830. }
  39831. /*</replacement>*/
  39832. var BufferList = __webpack_require__(/*! ./internal/streams/buffer_list */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/buffer_list.js");
  39833. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/destroy.js");
  39834. var _require = __webpack_require__(/*! ./internal/streams/state */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/state.js"),
  39835. getHighWaterMark = _require.getHighWaterMark;
  39836. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js").codes),
  39837. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  39838. ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
  39839. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  39840. ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
  39841. var StringDecoder;
  39842. var createReadableStreamAsyncIterator;
  39843. var from;
  39844. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Readable, Stream);
  39845. var errorOrDestroy = destroyImpl.errorOrDestroy;
  39846. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  39847. function prependListener(emitter, event, fn) {
  39848. // Sadly this is not cacheable as some libraries bundle their own
  39849. // event emitter implementation with them.
  39850. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
  39851. // userland ones. NEVER DO THIS. This is here only because this code needs
  39852. // to continue to work with older versions of Node.js that do not include
  39853. // the prependListener() method. The goal is to eventually remove this hack.
  39854. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  39855. }
  39856. function ReadableState(options, stream, isDuplex) {
  39857. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js");
  39858. options = options || {}; // Duplex streams are both readable and writable, but share
  39859. // the same options object.
  39860. // However, some cases require setting options to different
  39861. // values for the readable and the writable sides of the duplex stream.
  39862. // These options can be provided separately as readableXXX and writableXXX.
  39863. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
  39864. // make all the buffer merging and length checks go away
  39865. this.objectMode = !!options.objectMode;
  39866. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
  39867. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  39868. this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the
  39869. // linked list can remove elements from the beginning faster than
  39870. // array.shift()
  39871. this.buffer = new BufferList();
  39872. this.length = 0;
  39873. this.pipes = null;
  39874. this.pipesCount = 0;
  39875. this.flowing = null;
  39876. this.ended = false;
  39877. this.endEmitted = false;
  39878. this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
  39879. // immediately, or on a later tick. We set this to true at first, because
  39880. // any actions that shouldn't happen until "later" should generally also
  39881. // not happen before the first read call.
  39882. this.sync = true; // whenever we return null, then we set a flag to say
  39883. // that we're awaiting a 'readable' event emission.
  39884. this.needReadable = false;
  39885. this.emittedReadable = false;
  39886. this.readableListening = false;
  39887. this.resumeScheduled = false;
  39888. this.paused = true; // Should close be emitted on destroy. Defaults to true.
  39889. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
  39890. this.autoDestroy = !!options.autoDestroy; // has it been destroyed
  39891. this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
  39892. // encoding is 'binary' so we have to make this configurable.
  39893. // Everything else in the universe uses 'utf8', though.
  39894. this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
  39895. this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
  39896. this.readingMore = false;
  39897. this.decoder = null;
  39898. this.encoding = null;
  39899. if (options.encoding) {
  39900. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  39901. this.decoder = new StringDecoder(options.encoding);
  39902. this.encoding = options.encoding;
  39903. }
  39904. }
  39905. function Readable(options) {
  39906. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js");
  39907. if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
  39908. // the ReadableState constructor, at least with V8 6.5
  39909. var isDuplex = this instanceof Duplex;
  39910. this._readableState = new ReadableState(options, this, isDuplex); // legacy
  39911. this.readable = true;
  39912. if (options) {
  39913. if (typeof options.read === 'function') this._read = options.read;
  39914. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  39915. }
  39916. Stream.call(this);
  39917. }
  39918. Object.defineProperty(Readable.prototype, 'destroyed', {
  39919. // making it explicit this property is not enumerable
  39920. // because otherwise some prototype manipulation in
  39921. // userland will fail
  39922. enumerable: false,
  39923. get: function get() {
  39924. if (this._readableState === undefined) {
  39925. return false;
  39926. }
  39927. return this._readableState.destroyed;
  39928. },
  39929. set: function set(value) {
  39930. // we ignore the value if the stream
  39931. // has not been initialized yet
  39932. if (!this._readableState) {
  39933. return;
  39934. } // backward compatibility, the user is explicitly
  39935. // managing destroyed
  39936. this._readableState.destroyed = value;
  39937. }
  39938. });
  39939. Readable.prototype.destroy = destroyImpl.destroy;
  39940. Readable.prototype._undestroy = destroyImpl.undestroy;
  39941. Readable.prototype._destroy = function (err, cb) {
  39942. cb(err);
  39943. }; // Manually shove something into the read() buffer.
  39944. // This returns true if the highWaterMark has not been hit yet,
  39945. // similar to how Writable.write() returns true if you should
  39946. // write() some more.
  39947. Readable.prototype.push = function (chunk, encoding) {
  39948. var state = this._readableState;
  39949. var skipChunkCheck;
  39950. if (!state.objectMode) {
  39951. if (typeof chunk === 'string') {
  39952. encoding = encoding || state.defaultEncoding;
  39953. if (encoding !== state.encoding) {
  39954. chunk = Buffer.from(chunk, encoding);
  39955. encoding = '';
  39956. }
  39957. skipChunkCheck = true;
  39958. }
  39959. } else {
  39960. skipChunkCheck = true;
  39961. }
  39962. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  39963. }; // Unshift should *always* be something directly out of read()
  39964. Readable.prototype.unshift = function (chunk) {
  39965. return readableAddChunk(this, chunk, null, true, false);
  39966. };
  39967. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  39968. debug('readableAddChunk', chunk);
  39969. var state = stream._readableState;
  39970. if (chunk === null) {
  39971. state.reading = false;
  39972. onEofChunk(stream, state);
  39973. } else {
  39974. var er;
  39975. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  39976. if (er) {
  39977. errorOrDestroy(stream, er);
  39978. } else if (state.objectMode || chunk && chunk.length > 0) {
  39979. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  39980. chunk = _uint8ArrayToBuffer(chunk);
  39981. }
  39982. if (addToFront) {
  39983. if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
  39984. } else if (state.ended) {
  39985. errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
  39986. } else if (state.destroyed) {
  39987. return false;
  39988. } else {
  39989. state.reading = false;
  39990. if (state.decoder && !encoding) {
  39991. chunk = state.decoder.write(chunk);
  39992. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  39993. } else {
  39994. addChunk(stream, state, chunk, false);
  39995. }
  39996. }
  39997. } else if (!addToFront) {
  39998. state.reading = false;
  39999. maybeReadMore(stream, state);
  40000. }
  40001. } // We can push more data if we are below the highWaterMark.
  40002. // Also, if we have no data yet, we can stand some more bytes.
  40003. // This is to work around cases where hwm=0, such as the repl.
  40004. return !state.ended && (state.length < state.highWaterMark || state.length === 0);
  40005. }
  40006. function addChunk(stream, state, chunk, addToFront) {
  40007. if (state.flowing && state.length === 0 && !state.sync) {
  40008. state.awaitDrain = 0;
  40009. stream.emit('data', chunk);
  40010. } else {
  40011. // update the buffer info.
  40012. state.length += state.objectMode ? 1 : chunk.length;
  40013. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  40014. if (state.needReadable) emitReadable(stream);
  40015. }
  40016. maybeReadMore(stream, state);
  40017. }
  40018. function chunkInvalid(state, chunk) {
  40019. var er;
  40020. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  40021. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
  40022. }
  40023. return er;
  40024. }
  40025. Readable.prototype.isPaused = function () {
  40026. return this._readableState.flowing === false;
  40027. }; // backwards compatibility.
  40028. Readable.prototype.setEncoding = function (enc) {
  40029. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  40030. var decoder = new StringDecoder(enc);
  40031. this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
  40032. this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
  40033. var p = this._readableState.buffer.head;
  40034. var content = '';
  40035. while (p !== null) {
  40036. content += decoder.write(p.data);
  40037. p = p.next;
  40038. }
  40039. this._readableState.buffer.clear();
  40040. if (content !== '') this._readableState.buffer.push(content);
  40041. this._readableState.length = content.length;
  40042. return this;
  40043. }; // Don't raise the hwm > 1GB
  40044. var MAX_HWM = 0x40000000;
  40045. function computeNewHighWaterMark(n) {
  40046. if (n >= MAX_HWM) {
  40047. // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
  40048. n = MAX_HWM;
  40049. } else {
  40050. // Get the next highest power of 2 to prevent increasing hwm excessively in
  40051. // tiny amounts
  40052. n--;
  40053. n |= n >>> 1;
  40054. n |= n >>> 2;
  40055. n |= n >>> 4;
  40056. n |= n >>> 8;
  40057. n |= n >>> 16;
  40058. n++;
  40059. }
  40060. return n;
  40061. } // This function is designed to be inlinable, so please take care when making
  40062. // changes to the function body.
  40063. function howMuchToRead(n, state) {
  40064. if (n <= 0 || state.length === 0 && state.ended) return 0;
  40065. if (state.objectMode) return 1;
  40066. if (n !== n) {
  40067. // Only flow one buffer at a time
  40068. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  40069. } // If we're asking for more than the current hwm, then raise the hwm.
  40070. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  40071. if (n <= state.length) return n; // Don't have enough
  40072. if (!state.ended) {
  40073. state.needReadable = true;
  40074. return 0;
  40075. }
  40076. return state.length;
  40077. } // you can override either this method, or the async _read(n) below.
  40078. Readable.prototype.read = function (n) {
  40079. debug('read', n);
  40080. n = parseInt(n, 10);
  40081. var state = this._readableState;
  40082. var nOrig = n;
  40083. if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
  40084. // already have a bunch of data in the buffer, then just trigger
  40085. // the 'readable' event and move on.
  40086. if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
  40087. debug('read: emitReadable', state.length, state.ended);
  40088. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  40089. return null;
  40090. }
  40091. n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
  40092. if (n === 0 && state.ended) {
  40093. if (state.length === 0) endReadable(this);
  40094. return null;
  40095. } // All the actual chunk generation logic needs to be
  40096. // *below* the call to _read. The reason is that in certain
  40097. // synthetic stream cases, such as passthrough streams, _read
  40098. // may be a completely synchronous operation which may change
  40099. // the state of the read buffer, providing enough data when
  40100. // before there was *not* enough.
  40101. //
  40102. // So, the steps are:
  40103. // 1. Figure out what the state of things will be after we do
  40104. // a read from the buffer.
  40105. //
  40106. // 2. If that resulting state will trigger a _read, then call _read.
  40107. // Note that this may be asynchronous, or synchronous. Yes, it is
  40108. // deeply ugly to write APIs this way, but that still doesn't mean
  40109. // that the Readable class should behave improperly, as streams are
  40110. // designed to be sync/async agnostic.
  40111. // Take note if the _read call is sync or async (ie, if the read call
  40112. // has returned yet), so that we know whether or not it's safe to emit
  40113. // 'readable' etc.
  40114. //
  40115. // 3. Actually pull the requested chunks out of the buffer and return.
  40116. // if we need a readable event, then we need to do some reading.
  40117. var doRead = state.needReadable;
  40118. debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
  40119. if (state.length === 0 || state.length - n < state.highWaterMark) {
  40120. doRead = true;
  40121. debug('length less than watermark', doRead);
  40122. } // however, if we've ended, then there's no point, and if we're already
  40123. // reading, then it's unnecessary.
  40124. if (state.ended || state.reading) {
  40125. doRead = false;
  40126. debug('reading or ended', doRead);
  40127. } else if (doRead) {
  40128. debug('do read');
  40129. state.reading = true;
  40130. state.sync = true; // if the length is currently zero, then we *need* a readable event.
  40131. if (state.length === 0) state.needReadable = true; // call internal read method
  40132. this._read(state.highWaterMark);
  40133. state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
  40134. // and we need to re-evaluate how much data we can return to the user.
  40135. if (!state.reading) n = howMuchToRead(nOrig, state);
  40136. }
  40137. var ret;
  40138. if (n > 0) ret = fromList(n, state);else ret = null;
  40139. if (ret === null) {
  40140. state.needReadable = state.length <= state.highWaterMark;
  40141. n = 0;
  40142. } else {
  40143. state.length -= n;
  40144. state.awaitDrain = 0;
  40145. }
  40146. if (state.length === 0) {
  40147. // If we have nothing in the buffer, then we want to know
  40148. // as soon as we *do* get something into the buffer.
  40149. if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
  40150. if (nOrig !== n && state.ended) endReadable(this);
  40151. }
  40152. if (ret !== null) this.emit('data', ret);
  40153. return ret;
  40154. };
  40155. function onEofChunk(stream, state) {
  40156. debug('onEofChunk');
  40157. if (state.ended) return;
  40158. if (state.decoder) {
  40159. var chunk = state.decoder.end();
  40160. if (chunk && chunk.length) {
  40161. state.buffer.push(chunk);
  40162. state.length += state.objectMode ? 1 : chunk.length;
  40163. }
  40164. }
  40165. state.ended = true;
  40166. if (state.sync) {
  40167. // if we are sync, wait until next tick to emit the data.
  40168. // Otherwise we risk emitting data in the flow()
  40169. // the readable code triggers during a read() call
  40170. emitReadable(stream);
  40171. } else {
  40172. // emit 'readable' now to make sure it gets picked up.
  40173. state.needReadable = false;
  40174. if (!state.emittedReadable) {
  40175. state.emittedReadable = true;
  40176. emitReadable_(stream);
  40177. }
  40178. }
  40179. } // Don't emit readable right away in sync mode, because this can trigger
  40180. // another read() call => stack overflow. This way, it might trigger
  40181. // a nextTick recursion warning, but that's not so bad.
  40182. function emitReadable(stream) {
  40183. var state = stream._readableState;
  40184. debug('emitReadable', state.needReadable, state.emittedReadable);
  40185. state.needReadable = false;
  40186. if (!state.emittedReadable) {
  40187. debug('emitReadable', state.flowing);
  40188. state.emittedReadable = true;
  40189. process.nextTick(emitReadable_, stream);
  40190. }
  40191. }
  40192. function emitReadable_(stream) {
  40193. var state = stream._readableState;
  40194. debug('emitReadable_', state.destroyed, state.length, state.ended);
  40195. if (!state.destroyed && (state.length || state.ended)) {
  40196. stream.emit('readable');
  40197. state.emittedReadable = false;
  40198. } // The stream needs another readable event if
  40199. // 1. It is not flowing, as the flow mechanism will take
  40200. // care of it.
  40201. // 2. It is not ended.
  40202. // 3. It is below the highWaterMark, so we can schedule
  40203. // another readable later.
  40204. state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
  40205. flow(stream);
  40206. } // at this point, the user has presumably seen the 'readable' event,
  40207. // and called read() to consume some data. that may have triggered
  40208. // in turn another _read(n) call, in which case reading = true if
  40209. // it's in progress.
  40210. // However, if we're not ended, or reading, and the length < hwm,
  40211. // then go ahead and try to read some more preemptively.
  40212. function maybeReadMore(stream, state) {
  40213. if (!state.readingMore) {
  40214. state.readingMore = true;
  40215. process.nextTick(maybeReadMore_, stream, state);
  40216. }
  40217. }
  40218. function maybeReadMore_(stream, state) {
  40219. // Attempt to read more data if we should.
  40220. //
  40221. // The conditions for reading more data are (one of):
  40222. // - Not enough data buffered (state.length < state.highWaterMark). The loop
  40223. // is responsible for filling the buffer with enough data if such data
  40224. // is available. If highWaterMark is 0 and we are not in the flowing mode
  40225. // we should _not_ attempt to buffer any extra data. We'll get more data
  40226. // when the stream consumer calls read() instead.
  40227. // - No data in the buffer, and the stream is in flowing mode. In this mode
  40228. // the loop below is responsible for ensuring read() is called. Failing to
  40229. // call read here would abort the flow and there's no other mechanism for
  40230. // continuing the flow if the stream consumer has just subscribed to the
  40231. // 'data' event.
  40232. //
  40233. // In addition to the above conditions to keep reading data, the following
  40234. // conditions prevent the data from being read:
  40235. // - The stream has ended (state.ended).
  40236. // - There is already a pending 'read' operation (state.reading). This is a
  40237. // case where the the stream has called the implementation defined _read()
  40238. // method, but they are processing the call asynchronously and have _not_
  40239. // called push() with new data. In this case we skip performing more
  40240. // read()s. The execution ends in this method again after the _read() ends
  40241. // up calling push() with more data.
  40242. while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
  40243. var len = state.length;
  40244. debug('maybeReadMore read 0');
  40245. stream.read(0);
  40246. if (len === state.length) // didn't get any data, stop spinning.
  40247. break;
  40248. }
  40249. state.readingMore = false;
  40250. } // abstract method. to be overridden in specific implementation classes.
  40251. // call cb(er, data) where data is <= n in length.
  40252. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  40253. // arbitrary, and perhaps not very meaningful.
  40254. Readable.prototype._read = function (n) {
  40255. errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
  40256. };
  40257. Readable.prototype.pipe = function (dest, pipeOpts) {
  40258. var src = this;
  40259. var state = this._readableState;
  40260. switch (state.pipesCount) {
  40261. case 0:
  40262. state.pipes = dest;
  40263. break;
  40264. case 1:
  40265. state.pipes = [state.pipes, dest];
  40266. break;
  40267. default:
  40268. state.pipes.push(dest);
  40269. break;
  40270. }
  40271. state.pipesCount += 1;
  40272. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  40273. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  40274. var endFn = doEnd ? onend : unpipe;
  40275. if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
  40276. dest.on('unpipe', onunpipe);
  40277. function onunpipe(readable, unpipeInfo) {
  40278. debug('onunpipe');
  40279. if (readable === src) {
  40280. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  40281. unpipeInfo.hasUnpiped = true;
  40282. cleanup();
  40283. }
  40284. }
  40285. }
  40286. function onend() {
  40287. debug('onend');
  40288. dest.end();
  40289. } // when the dest drains, it reduces the awaitDrain counter
  40290. // on the source. This would be more elegant with a .once()
  40291. // handler in flow(), but adding and removing repeatedly is
  40292. // too slow.
  40293. var ondrain = pipeOnDrain(src);
  40294. dest.on('drain', ondrain);
  40295. var cleanedUp = false;
  40296. function cleanup() {
  40297. debug('cleanup'); // cleanup event handlers once the pipe is broken
  40298. dest.removeListener('close', onclose);
  40299. dest.removeListener('finish', onfinish);
  40300. dest.removeListener('drain', ondrain);
  40301. dest.removeListener('error', onerror);
  40302. dest.removeListener('unpipe', onunpipe);
  40303. src.removeListener('end', onend);
  40304. src.removeListener('end', unpipe);
  40305. src.removeListener('data', ondata);
  40306. cleanedUp = true; // if the reader is waiting for a drain event from this
  40307. // specific writer, then it would cause it to never start
  40308. // flowing again.
  40309. // So, if this is awaiting a drain, then we just call it now.
  40310. // If we don't know, then assume that we are waiting for one.
  40311. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  40312. }
  40313. src.on('data', ondata);
  40314. function ondata(chunk) {
  40315. debug('ondata');
  40316. var ret = dest.write(chunk);
  40317. debug('dest.write', ret);
  40318. if (ret === false) {
  40319. // If the user unpiped during `dest.write()`, it is possible
  40320. // to get stuck in a permanently paused state if that write
  40321. // also returned false.
  40322. // => Check whether `dest` is still a piping destination.
  40323. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  40324. debug('false write response, pause', state.awaitDrain);
  40325. state.awaitDrain++;
  40326. }
  40327. src.pause();
  40328. }
  40329. } // if the dest has an error, then stop piping into it.
  40330. // however, don't suppress the throwing behavior for this.
  40331. function onerror(er) {
  40332. debug('onerror', er);
  40333. unpipe();
  40334. dest.removeListener('error', onerror);
  40335. if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
  40336. } // Make sure our error handler is attached before userland ones.
  40337. prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
  40338. function onclose() {
  40339. dest.removeListener('finish', onfinish);
  40340. unpipe();
  40341. }
  40342. dest.once('close', onclose);
  40343. function onfinish() {
  40344. debug('onfinish');
  40345. dest.removeListener('close', onclose);
  40346. unpipe();
  40347. }
  40348. dest.once('finish', onfinish);
  40349. function unpipe() {
  40350. debug('unpipe');
  40351. src.unpipe(dest);
  40352. } // tell the dest that it's being piped to
  40353. dest.emit('pipe', src); // start the flow if it hasn't been started already.
  40354. if (!state.flowing) {
  40355. debug('pipe resume');
  40356. src.resume();
  40357. }
  40358. return dest;
  40359. };
  40360. function pipeOnDrain(src) {
  40361. return function pipeOnDrainFunctionResult() {
  40362. var state = src._readableState;
  40363. debug('pipeOnDrain', state.awaitDrain);
  40364. if (state.awaitDrain) state.awaitDrain--;
  40365. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  40366. state.flowing = true;
  40367. flow(src);
  40368. }
  40369. };
  40370. }
  40371. Readable.prototype.unpipe = function (dest) {
  40372. var state = this._readableState;
  40373. var unpipeInfo = {
  40374. hasUnpiped: false
  40375. }; // if we're not piping anywhere, then do nothing.
  40376. if (state.pipesCount === 0) return this; // just one destination. most common case.
  40377. if (state.pipesCount === 1) {
  40378. // passed in one, but it's not the right one.
  40379. if (dest && dest !== state.pipes) return this;
  40380. if (!dest) dest = state.pipes; // got a match.
  40381. state.pipes = null;
  40382. state.pipesCount = 0;
  40383. state.flowing = false;
  40384. if (dest) dest.emit('unpipe', this, unpipeInfo);
  40385. return this;
  40386. } // slow case. multiple pipe destinations.
  40387. if (!dest) {
  40388. // remove all.
  40389. var dests = state.pipes;
  40390. var len = state.pipesCount;
  40391. state.pipes = null;
  40392. state.pipesCount = 0;
  40393. state.flowing = false;
  40394. for (var i = 0; i < len; i++) {
  40395. dests[i].emit('unpipe', this, {
  40396. hasUnpiped: false
  40397. });
  40398. }
  40399. return this;
  40400. } // try to find the right one.
  40401. var index = indexOf(state.pipes, dest);
  40402. if (index === -1) return this;
  40403. state.pipes.splice(index, 1);
  40404. state.pipesCount -= 1;
  40405. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  40406. dest.emit('unpipe', this, unpipeInfo);
  40407. return this;
  40408. }; // set up data events if they are asked for
  40409. // Ensure readable listeners eventually get something
  40410. Readable.prototype.on = function (ev, fn) {
  40411. var res = Stream.prototype.on.call(this, ev, fn);
  40412. var state = this._readableState;
  40413. if (ev === 'data') {
  40414. // update readableListening so that resume() may be a no-op
  40415. // a few lines down. This is needed to support once('readable').
  40416. state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused
  40417. if (state.flowing !== false) this.resume();
  40418. } else if (ev === 'readable') {
  40419. if (!state.endEmitted && !state.readableListening) {
  40420. state.readableListening = state.needReadable = true;
  40421. state.flowing = false;
  40422. state.emittedReadable = false;
  40423. debug('on readable', state.length, state.reading);
  40424. if (state.length) {
  40425. emitReadable(this);
  40426. } else if (!state.reading) {
  40427. process.nextTick(nReadingNextTick, this);
  40428. }
  40429. }
  40430. }
  40431. return res;
  40432. };
  40433. Readable.prototype.addListener = Readable.prototype.on;
  40434. Readable.prototype.removeListener = function (ev, fn) {
  40435. var res = Stream.prototype.removeListener.call(this, ev, fn);
  40436. if (ev === 'readable') {
  40437. // We need to check if there is someone still listening to
  40438. // readable and reset the state. However this needs to happen
  40439. // after readable has been emitted but before I/O (nextTick) to
  40440. // support once('readable', fn) cycles. This means that calling
  40441. // resume within the same tick will have no
  40442. // effect.
  40443. process.nextTick(updateReadableListening, this);
  40444. }
  40445. return res;
  40446. };
  40447. Readable.prototype.removeAllListeners = function (ev) {
  40448. var res = Stream.prototype.removeAllListeners.apply(this, arguments);
  40449. if (ev === 'readable' || ev === undefined) {
  40450. // We need to check if there is someone still listening to
  40451. // readable and reset the state. However this needs to happen
  40452. // after readable has been emitted but before I/O (nextTick) to
  40453. // support once('readable', fn) cycles. This means that calling
  40454. // resume within the same tick will have no
  40455. // effect.
  40456. process.nextTick(updateReadableListening, this);
  40457. }
  40458. return res;
  40459. };
  40460. function updateReadableListening(self) {
  40461. var state = self._readableState;
  40462. state.readableListening = self.listenerCount('readable') > 0;
  40463. if (state.resumeScheduled && !state.paused) {
  40464. // flowing needs to be set to true now, otherwise
  40465. // the upcoming resume will not flow.
  40466. state.flowing = true; // crude way to check if we should resume
  40467. } else if (self.listenerCount('data') > 0) {
  40468. self.resume();
  40469. }
  40470. }
  40471. function nReadingNextTick(self) {
  40472. debug('readable nexttick read 0');
  40473. self.read(0);
  40474. } // pause() and resume() are remnants of the legacy readable stream API
  40475. // If the user uses them, then switch into old mode.
  40476. Readable.prototype.resume = function () {
  40477. var state = this._readableState;
  40478. if (!state.flowing) {
  40479. debug('resume'); // we flow only if there is no one listening
  40480. // for readable, but we still have to call
  40481. // resume()
  40482. state.flowing = !state.readableListening;
  40483. resume(this, state);
  40484. }
  40485. state.paused = false;
  40486. return this;
  40487. };
  40488. function resume(stream, state) {
  40489. if (!state.resumeScheduled) {
  40490. state.resumeScheduled = true;
  40491. process.nextTick(resume_, stream, state);
  40492. }
  40493. }
  40494. function resume_(stream, state) {
  40495. debug('resume', state.reading);
  40496. if (!state.reading) {
  40497. stream.read(0);
  40498. }
  40499. state.resumeScheduled = false;
  40500. stream.emit('resume');
  40501. flow(stream);
  40502. if (state.flowing && !state.reading) stream.read(0);
  40503. }
  40504. Readable.prototype.pause = function () {
  40505. debug('call pause flowing=%j', this._readableState.flowing);
  40506. if (this._readableState.flowing !== false) {
  40507. debug('pause');
  40508. this._readableState.flowing = false;
  40509. this.emit('pause');
  40510. }
  40511. this._readableState.paused = true;
  40512. return this;
  40513. };
  40514. function flow(stream) {
  40515. var state = stream._readableState;
  40516. debug('flow', state.flowing);
  40517. while (state.flowing && stream.read() !== null) {
  40518. ;
  40519. }
  40520. } // wrap an old-style stream as the async data source.
  40521. // This is *not* part of the readable stream interface.
  40522. // It is an ugly unfortunate mess of history.
  40523. Readable.prototype.wrap = function (stream) {
  40524. var _this = this;
  40525. var state = this._readableState;
  40526. var paused = false;
  40527. stream.on('end', function () {
  40528. debug('wrapped end');
  40529. if (state.decoder && !state.ended) {
  40530. var chunk = state.decoder.end();
  40531. if (chunk && chunk.length) _this.push(chunk);
  40532. }
  40533. _this.push(null);
  40534. });
  40535. stream.on('data', function (chunk) {
  40536. debug('wrapped data');
  40537. if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
  40538. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  40539. var ret = _this.push(chunk);
  40540. if (!ret) {
  40541. paused = true;
  40542. stream.pause();
  40543. }
  40544. }); // proxy all the other methods.
  40545. // important when wrapping filters and duplexes.
  40546. for (var i in stream) {
  40547. if (this[i] === undefined && typeof stream[i] === 'function') {
  40548. this[i] = function methodWrap(method) {
  40549. return function methodWrapReturnFunction() {
  40550. return stream[method].apply(stream, arguments);
  40551. };
  40552. }(i);
  40553. }
  40554. } // proxy certain important events.
  40555. for (var n = 0; n < kProxyEvents.length; n++) {
  40556. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  40557. } // when we try to consume some more bytes, simply unpause the
  40558. // underlying stream.
  40559. this._read = function (n) {
  40560. debug('wrapped _read', n);
  40561. if (paused) {
  40562. paused = false;
  40563. stream.resume();
  40564. }
  40565. };
  40566. return this;
  40567. };
  40568. if (typeof Symbol === 'function') {
  40569. Readable.prototype[Symbol.asyncIterator] = function () {
  40570. if (createReadableStreamAsyncIterator === undefined) {
  40571. createReadableStreamAsyncIterator = __webpack_require__(/*! ./internal/streams/async_iterator */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/async_iterator.js");
  40572. }
  40573. return createReadableStreamAsyncIterator(this);
  40574. };
  40575. }
  40576. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  40577. // making it explicit this property is not enumerable
  40578. // because otherwise some prototype manipulation in
  40579. // userland will fail
  40580. enumerable: false,
  40581. get: function get() {
  40582. return this._readableState.highWaterMark;
  40583. }
  40584. });
  40585. Object.defineProperty(Readable.prototype, 'readableBuffer', {
  40586. // making it explicit this property is not enumerable
  40587. // because otherwise some prototype manipulation in
  40588. // userland will fail
  40589. enumerable: false,
  40590. get: function get() {
  40591. return this._readableState && this._readableState.buffer;
  40592. }
  40593. });
  40594. Object.defineProperty(Readable.prototype, 'readableFlowing', {
  40595. // making it explicit this property is not enumerable
  40596. // because otherwise some prototype manipulation in
  40597. // userland will fail
  40598. enumerable: false,
  40599. get: function get() {
  40600. return this._readableState.flowing;
  40601. },
  40602. set: function set(state) {
  40603. if (this._readableState) {
  40604. this._readableState.flowing = state;
  40605. }
  40606. }
  40607. }); // exposed for testing purposes only.
  40608. Readable._fromList = fromList;
  40609. Object.defineProperty(Readable.prototype, 'readableLength', {
  40610. // making it explicit this property is not enumerable
  40611. // because otherwise some prototype manipulation in
  40612. // userland will fail
  40613. enumerable: false,
  40614. get: function get() {
  40615. return this._readableState.length;
  40616. }
  40617. }); // Pluck off n bytes from an array of buffers.
  40618. // Length is the combined lengths of all the buffers in the list.
  40619. // This function is designed to be inlinable, so please take care when making
  40620. // changes to the function body.
  40621. function fromList(n, state) {
  40622. // nothing buffered
  40623. if (state.length === 0) return null;
  40624. var ret;
  40625. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  40626. // read it all, truncate the list
  40627. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
  40628. state.buffer.clear();
  40629. } else {
  40630. // read part of list
  40631. ret = state.buffer.consume(n, state.decoder);
  40632. }
  40633. return ret;
  40634. }
  40635. function endReadable(stream) {
  40636. var state = stream._readableState;
  40637. debug('endReadable', state.endEmitted);
  40638. if (!state.endEmitted) {
  40639. state.ended = true;
  40640. process.nextTick(endReadableNT, state, stream);
  40641. }
  40642. }
  40643. function endReadableNT(state, stream) {
  40644. debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.
  40645. if (!state.endEmitted && state.length === 0) {
  40646. state.endEmitted = true;
  40647. stream.readable = false;
  40648. stream.emit('end');
  40649. if (state.autoDestroy) {
  40650. // In case of duplex streams we need a way to detect
  40651. // if the writable side is ready for autoDestroy as well
  40652. var wState = stream._writableState;
  40653. if (!wState || wState.autoDestroy && wState.finished) {
  40654. stream.destroy();
  40655. }
  40656. }
  40657. }
  40658. }
  40659. if (typeof Symbol === 'function') {
  40660. Readable.from = function (iterable, opts) {
  40661. if (from === undefined) {
  40662. from = __webpack_require__(/*! ./internal/streams/from */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/from-browser.js");
  40663. }
  40664. return from(Readable, iterable, opts);
  40665. };
  40666. }
  40667. function indexOf(xs, x) {
  40668. for (var i = 0, l = xs.length; i < l; i++) {
  40669. if (xs[i] === x) return i;
  40670. }
  40671. return -1;
  40672. }
  40673. /***/ }),
  40674. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_transform.js":
  40675. /*!**************************************************************************************!*\
  40676. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_transform.js ***!
  40677. \**************************************************************************************/
  40678. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  40679. "use strict";
  40680. // Copyright Joyent, Inc. and other Node contributors.
  40681. //
  40682. // Permission is hereby granted, free of charge, to any person obtaining a
  40683. // copy of this software and associated documentation files (the
  40684. // "Software"), to deal in the Software without restriction, including
  40685. // without limitation the rights to use, copy, modify, merge, publish,
  40686. // distribute, sublicense, and/or sell copies of the Software, and to permit
  40687. // persons to whom the Software is furnished to do so, subject to the
  40688. // following conditions:
  40689. //
  40690. // The above copyright notice and this permission notice shall be included
  40691. // in all copies or substantial portions of the Software.
  40692. //
  40693. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  40694. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  40695. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  40696. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  40697. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  40698. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  40699. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  40700. // a transform stream is a readable/writable stream where you do
  40701. // something with the data. Sometimes it's called a "filter",
  40702. // but that's not a great name for it, since that implies a thing where
  40703. // some bits pass through, and others are simply ignored. (That would
  40704. // be a valid example of a transform, of course.)
  40705. //
  40706. // While the output is causally related to the input, it's not a
  40707. // necessarily symmetric or synchronous transformation. For example,
  40708. // a zlib stream might take multiple plain-text writes(), and then
  40709. // emit a single compressed chunk some time in the future.
  40710. //
  40711. // Here's how this works:
  40712. //
  40713. // The Transform stream has all the aspects of the readable and writable
  40714. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  40715. // internally, and returns false if there's a lot of pending writes
  40716. // buffered up. When you call read(), that calls _read(n) until
  40717. // there's enough pending readable data buffered up.
  40718. //
  40719. // In a transform stream, the written data is placed in a buffer. When
  40720. // _read(n) is called, it transforms the queued up data, calling the
  40721. // buffered _write cb's as it consumes chunks. If consuming a single
  40722. // written chunk would result in multiple output chunks, then the first
  40723. // outputted bit calls the readcb, and subsequent chunks just go into
  40724. // the read buffer, and will cause it to emit 'readable' if necessary.
  40725. //
  40726. // This way, back-pressure is actually determined by the reading side,
  40727. // since _read has to be called to start processing a new chunk. However,
  40728. // a pathological inflate type of transform can cause excessive buffering
  40729. // here. For example, imagine a stream where every byte of input is
  40730. // interpreted as an integer from 0-255, and then results in that many
  40731. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  40732. // 1kb of data being output. In this case, you could write a very small
  40733. // amount of input, and end up with a very large amount of output. In
  40734. // such a pathological inflating mechanism, there'd be no way to tell
  40735. // the system to stop doing the transform. A single 4MB write could
  40736. // cause the system to run out of memory.
  40737. //
  40738. // However, even in such a pathological case, only a single written chunk
  40739. // would be consumed, and then the rest would wait (un-transformed) until
  40740. // the results of the previous transformed chunk were consumed.
  40741. module.exports = Transform;
  40742. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js").codes),
  40743. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  40744. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  40745. ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
  40746. ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
  40747. var Duplex = __webpack_require__(/*! ./_stream_duplex */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js");
  40748. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Transform, Duplex);
  40749. function afterTransform(er, data) {
  40750. var ts = this._transformState;
  40751. ts.transforming = false;
  40752. var cb = ts.writecb;
  40753. if (cb === null) {
  40754. return this.emit('error', new ERR_MULTIPLE_CALLBACK());
  40755. }
  40756. ts.writechunk = null;
  40757. ts.writecb = null;
  40758. if (data != null) // single equals check for both `null` and `undefined`
  40759. this.push(data);
  40760. cb(er);
  40761. var rs = this._readableState;
  40762. rs.reading = false;
  40763. if (rs.needReadable || rs.length < rs.highWaterMark) {
  40764. this._read(rs.highWaterMark);
  40765. }
  40766. }
  40767. function Transform(options) {
  40768. if (!(this instanceof Transform)) return new Transform(options);
  40769. Duplex.call(this, options);
  40770. this._transformState = {
  40771. afterTransform: afterTransform.bind(this),
  40772. needTransform: false,
  40773. transforming: false,
  40774. writecb: null,
  40775. writechunk: null,
  40776. writeencoding: null
  40777. }; // start out asking for a readable event once data is transformed.
  40778. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
  40779. // that Readable wants before the first _read call, so unset the
  40780. // sync guard flag.
  40781. this._readableState.sync = false;
  40782. if (options) {
  40783. if (typeof options.transform === 'function') this._transform = options.transform;
  40784. if (typeof options.flush === 'function') this._flush = options.flush;
  40785. } // When the writable side finishes, then flush out anything remaining.
  40786. this.on('prefinish', prefinish);
  40787. }
  40788. function prefinish() {
  40789. var _this = this;
  40790. if (typeof this._flush === 'function' && !this._readableState.destroyed) {
  40791. this._flush(function (er, data) {
  40792. done(_this, er, data);
  40793. });
  40794. } else {
  40795. done(this, null, null);
  40796. }
  40797. }
  40798. Transform.prototype.push = function (chunk, encoding) {
  40799. this._transformState.needTransform = false;
  40800. return Duplex.prototype.push.call(this, chunk, encoding);
  40801. }; // This is the part where you do stuff!
  40802. // override this function in implementation classes.
  40803. // 'chunk' is an input chunk.
  40804. //
  40805. // Call `push(newChunk)` to pass along transformed output
  40806. // to the readable side. You may call 'push' zero or more times.
  40807. //
  40808. // Call `cb(err)` when you are done with this chunk. If you pass
  40809. // an error, then that'll put the hurt on the whole operation. If you
  40810. // never call cb(), then you'll never get another chunk.
  40811. Transform.prototype._transform = function (chunk, encoding, cb) {
  40812. cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
  40813. };
  40814. Transform.prototype._write = function (chunk, encoding, cb) {
  40815. var ts = this._transformState;
  40816. ts.writecb = cb;
  40817. ts.writechunk = chunk;
  40818. ts.writeencoding = encoding;
  40819. if (!ts.transforming) {
  40820. var rs = this._readableState;
  40821. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  40822. }
  40823. }; // Doesn't matter what the args are here.
  40824. // _transform does all the work.
  40825. // That we got here means that the readable side wants more data.
  40826. Transform.prototype._read = function (n) {
  40827. var ts = this._transformState;
  40828. if (ts.writechunk !== null && !ts.transforming) {
  40829. ts.transforming = true;
  40830. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  40831. } else {
  40832. // mark that we need a transform, so that any data that comes in
  40833. // will get processed, now that we've asked for it.
  40834. ts.needTransform = true;
  40835. }
  40836. };
  40837. Transform.prototype._destroy = function (err, cb) {
  40838. Duplex.prototype._destroy.call(this, err, function (err2) {
  40839. cb(err2);
  40840. });
  40841. };
  40842. function done(stream, er, data) {
  40843. if (er) return stream.emit('error', er);
  40844. if (data != null) // single equals check for both `null` and `undefined`
  40845. stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
  40846. // if there's nothing in the write buffer, then that means
  40847. // that nothing more will ever be provided
  40848. if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
  40849. if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
  40850. return stream.push(null);
  40851. }
  40852. /***/ }),
  40853. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js":
  40854. /*!*************************************************************************************!*\
  40855. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js ***!
  40856. \*************************************************************************************/
  40857. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  40858. "use strict";
  40859. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  40860. // Copyright Joyent, Inc. and other Node contributors.
  40861. //
  40862. // Permission is hereby granted, free of charge, to any person obtaining a
  40863. // copy of this software and associated documentation files (the
  40864. // "Software"), to deal in the Software without restriction, including
  40865. // without limitation the rights to use, copy, modify, merge, publish,
  40866. // distribute, sublicense, and/or sell copies of the Software, and to permit
  40867. // persons to whom the Software is furnished to do so, subject to the
  40868. // following conditions:
  40869. //
  40870. // The above copyright notice and this permission notice shall be included
  40871. // in all copies or substantial portions of the Software.
  40872. //
  40873. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  40874. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  40875. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  40876. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  40877. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  40878. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  40879. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  40880. // A bit simpler than readable streams.
  40881. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  40882. // the drain event emission and buffering.
  40883. module.exports = Writable;
  40884. /* <replacement> */
  40885. function WriteReq(chunk, encoding, cb) {
  40886. this.chunk = chunk;
  40887. this.encoding = encoding;
  40888. this.callback = cb;
  40889. this.next = null;
  40890. } // It seems a linked list but it is not
  40891. // there will be only 2 of these for each stream
  40892. function CorkedRequest(state) {
  40893. var _this = this;
  40894. this.next = null;
  40895. this.entry = null;
  40896. this.finish = function () {
  40897. onCorkedFinish(_this, state);
  40898. };
  40899. }
  40900. /* </replacement> */
  40901. /*<replacement>*/
  40902. var Duplex;
  40903. /*</replacement>*/
  40904. Writable.WritableState = WritableState;
  40905. /*<replacement>*/
  40906. var internalUtil = {
  40907. deprecate: __webpack_require__(/*! util-deprecate */ "./node_modules/util-deprecate/browser.js")
  40908. };
  40909. /*</replacement>*/
  40910. /*<replacement>*/
  40911. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  40912. /*</replacement>*/
  40913. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/buffer/index.js").Buffer);
  40914. var OurUint8Array = __webpack_require__.g.Uint8Array || function () {};
  40915. function _uint8ArrayToBuffer(chunk) {
  40916. return Buffer.from(chunk);
  40917. }
  40918. function _isUint8Array(obj) {
  40919. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  40920. }
  40921. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/destroy.js");
  40922. var _require = __webpack_require__(/*! ./internal/streams/state */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/state.js"),
  40923. getHighWaterMark = _require.getHighWaterMark;
  40924. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js").codes),
  40925. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  40926. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  40927. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  40928. ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
  40929. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
  40930. ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
  40931. ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
  40932. ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
  40933. var errorOrDestroy = destroyImpl.errorOrDestroy;
  40934. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Writable, Stream);
  40935. function nop() {}
  40936. function WritableState(options, stream, isDuplex) {
  40937. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js");
  40938. options = options || {}; // Duplex streams are both readable and writable, but share
  40939. // the same options object.
  40940. // However, some cases require setting options to different
  40941. // values for the readable and the writable sides of the duplex stream,
  40942. // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
  40943. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  40944. // contains buffers or objects.
  40945. this.objectMode = !!options.objectMode;
  40946. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  40947. // Note: 0 is a valid value, means that we always return false if
  40948. // the entire buffer is not flushed immediately on write()
  40949. this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
  40950. this.finalCalled = false; // drain event flag.
  40951. this.needDrain = false; // at the start of calling end()
  40952. this.ending = false; // when end() has been called, and returned
  40953. this.ended = false; // when 'finish' is emitted
  40954. this.finished = false; // has it been destroyed
  40955. this.destroyed = false; // should we decode strings into buffers before passing to _write?
  40956. // this is here so that some node-core streams can optimize string
  40957. // handling at a lower level.
  40958. var noDecode = options.decodeStrings === false;
  40959. this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
  40960. // encoding is 'binary' so we have to make this configurable.
  40961. // Everything else in the universe uses 'utf8', though.
  40962. this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  40963. // of how much we're waiting to get pushed to some underlying
  40964. // socket or file.
  40965. this.length = 0; // a flag to see when we're in the middle of a write.
  40966. this.writing = false; // when true all writes will be buffered until .uncork() call
  40967. this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  40968. // or on a later tick. We set this to true at first, because any
  40969. // actions that shouldn't happen until "later" should generally also
  40970. // not happen before the first write call.
  40971. this.sync = true; // a flag to know if we're processing previously buffered items, which
  40972. // may call the _write() callback in the same tick, so that we don't
  40973. // end up in an overlapped onwrite situation.
  40974. this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
  40975. this.onwrite = function (er) {
  40976. onwrite(stream, er);
  40977. }; // the callback that the user supplies to write(chunk,encoding,cb)
  40978. this.writecb = null; // the amount that is being written when _write is called.
  40979. this.writelen = 0;
  40980. this.bufferedRequest = null;
  40981. this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  40982. // this must be 0 before 'finish' can be emitted
  40983. this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  40984. // This is relevant for synchronous Transform streams
  40985. this.prefinished = false; // True if the error was already emitted and should not be thrown again
  40986. this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
  40987. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
  40988. this.autoDestroy = !!options.autoDestroy; // count buffered requests
  40989. this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  40990. // one allocated and free to use, and we maintain at most two
  40991. this.corkedRequestsFree = new CorkedRequest(this);
  40992. }
  40993. WritableState.prototype.getBuffer = function getBuffer() {
  40994. var current = this.bufferedRequest;
  40995. var out = [];
  40996. while (current) {
  40997. out.push(current);
  40998. current = current.next;
  40999. }
  41000. return out;
  41001. };
  41002. (function () {
  41003. try {
  41004. Object.defineProperty(WritableState.prototype, 'buffer', {
  41005. get: internalUtil.deprecate(function writableStateBufferGetter() {
  41006. return this.getBuffer();
  41007. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  41008. });
  41009. } catch (_) {}
  41010. })(); // Test _writableState for inheritance to account for Duplex streams,
  41011. // whose prototype chain only points to Readable.
  41012. var realHasInstance;
  41013. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  41014. realHasInstance = Function.prototype[Symbol.hasInstance];
  41015. Object.defineProperty(Writable, Symbol.hasInstance, {
  41016. value: function value(object) {
  41017. if (realHasInstance.call(this, object)) return true;
  41018. if (this !== Writable) return false;
  41019. return object && object._writableState instanceof WritableState;
  41020. }
  41021. });
  41022. } else {
  41023. realHasInstance = function realHasInstance(object) {
  41024. return object instanceof this;
  41025. };
  41026. }
  41027. function Writable(options) {
  41028. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js"); // Writable ctor is applied to Duplexes, too.
  41029. // `realHasInstance` is necessary because using plain `instanceof`
  41030. // would return false, as no `_writableState` property is attached.
  41031. // Trying to use the custom `instanceof` for Writable here will also break the
  41032. // Node.js LazyTransform implementation, which has a non-trivial getter for
  41033. // `_writableState` that would lead to infinite recursion.
  41034. // Checking for a Stream.Duplex instance is faster here instead of inside
  41035. // the WritableState constructor, at least with V8 6.5
  41036. var isDuplex = this instanceof Duplex;
  41037. if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  41038. this._writableState = new WritableState(options, this, isDuplex); // legacy.
  41039. this.writable = true;
  41040. if (options) {
  41041. if (typeof options.write === 'function') this._write = options.write;
  41042. if (typeof options.writev === 'function') this._writev = options.writev;
  41043. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  41044. if (typeof options.final === 'function') this._final = options.final;
  41045. }
  41046. Stream.call(this);
  41047. } // Otherwise people can pipe Writable streams, which is just wrong.
  41048. Writable.prototype.pipe = function () {
  41049. errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
  41050. };
  41051. function writeAfterEnd(stream, cb) {
  41052. var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
  41053. errorOrDestroy(stream, er);
  41054. process.nextTick(cb, er);
  41055. } // Checks that a user-supplied chunk is valid, especially for the particular
  41056. // mode the stream is in. Currently this means that `null` is never accepted
  41057. // and undefined/non-string values are only allowed in object mode.
  41058. function validChunk(stream, state, chunk, cb) {
  41059. var er;
  41060. if (chunk === null) {
  41061. er = new ERR_STREAM_NULL_VALUES();
  41062. } else if (typeof chunk !== 'string' && !state.objectMode) {
  41063. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  41064. }
  41065. if (er) {
  41066. errorOrDestroy(stream, er);
  41067. process.nextTick(cb, er);
  41068. return false;
  41069. }
  41070. return true;
  41071. }
  41072. Writable.prototype.write = function (chunk, encoding, cb) {
  41073. var state = this._writableState;
  41074. var ret = false;
  41075. var isBuf = !state.objectMode && _isUint8Array(chunk);
  41076. if (isBuf && !Buffer.isBuffer(chunk)) {
  41077. chunk = _uint8ArrayToBuffer(chunk);
  41078. }
  41079. if (typeof encoding === 'function') {
  41080. cb = encoding;
  41081. encoding = null;
  41082. }
  41083. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  41084. if (typeof cb !== 'function') cb = nop;
  41085. if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  41086. state.pendingcb++;
  41087. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  41088. }
  41089. return ret;
  41090. };
  41091. Writable.prototype.cork = function () {
  41092. this._writableState.corked++;
  41093. };
  41094. Writable.prototype.uncork = function () {
  41095. var state = this._writableState;
  41096. if (state.corked) {
  41097. state.corked--;
  41098. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  41099. }
  41100. };
  41101. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  41102. // node::ParseEncoding() requires lower case.
  41103. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  41104. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  41105. this._writableState.defaultEncoding = encoding;
  41106. return this;
  41107. };
  41108. Object.defineProperty(Writable.prototype, 'writableBuffer', {
  41109. // making it explicit this property is not enumerable
  41110. // because otherwise some prototype manipulation in
  41111. // userland will fail
  41112. enumerable: false,
  41113. get: function get() {
  41114. return this._writableState && this._writableState.getBuffer();
  41115. }
  41116. });
  41117. function decodeChunk(state, chunk, encoding) {
  41118. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  41119. chunk = Buffer.from(chunk, encoding);
  41120. }
  41121. return chunk;
  41122. }
  41123. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  41124. // making it explicit this property is not enumerable
  41125. // because otherwise some prototype manipulation in
  41126. // userland will fail
  41127. enumerable: false,
  41128. get: function get() {
  41129. return this._writableState.highWaterMark;
  41130. }
  41131. }); // if we're already writing something, then just put this
  41132. // in the queue, and wait our turn. Otherwise, call _write
  41133. // If we return false, then we need a drain event, so set that flag.
  41134. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  41135. if (!isBuf) {
  41136. var newChunk = decodeChunk(state, chunk, encoding);
  41137. if (chunk !== newChunk) {
  41138. isBuf = true;
  41139. encoding = 'buffer';
  41140. chunk = newChunk;
  41141. }
  41142. }
  41143. var len = state.objectMode ? 1 : chunk.length;
  41144. state.length += len;
  41145. var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
  41146. if (!ret) state.needDrain = true;
  41147. if (state.writing || state.corked) {
  41148. var last = state.lastBufferedRequest;
  41149. state.lastBufferedRequest = {
  41150. chunk: chunk,
  41151. encoding: encoding,
  41152. isBuf: isBuf,
  41153. callback: cb,
  41154. next: null
  41155. };
  41156. if (last) {
  41157. last.next = state.lastBufferedRequest;
  41158. } else {
  41159. state.bufferedRequest = state.lastBufferedRequest;
  41160. }
  41161. state.bufferedRequestCount += 1;
  41162. } else {
  41163. doWrite(stream, state, false, len, chunk, encoding, cb);
  41164. }
  41165. return ret;
  41166. }
  41167. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  41168. state.writelen = len;
  41169. state.writecb = cb;
  41170. state.writing = true;
  41171. state.sync = true;
  41172. if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  41173. state.sync = false;
  41174. }
  41175. function onwriteError(stream, state, sync, er, cb) {
  41176. --state.pendingcb;
  41177. if (sync) {
  41178. // defer the callback if we are being called synchronously
  41179. // to avoid piling up things on the stack
  41180. process.nextTick(cb, er); // this can emit finish, and it will always happen
  41181. // after error
  41182. process.nextTick(finishMaybe, stream, state);
  41183. stream._writableState.errorEmitted = true;
  41184. errorOrDestroy(stream, er);
  41185. } else {
  41186. // the caller expect this to happen before if
  41187. // it is async
  41188. cb(er);
  41189. stream._writableState.errorEmitted = true;
  41190. errorOrDestroy(stream, er); // this can emit finish, but finish must
  41191. // always follow error
  41192. finishMaybe(stream, state);
  41193. }
  41194. }
  41195. function onwriteStateUpdate(state) {
  41196. state.writing = false;
  41197. state.writecb = null;
  41198. state.length -= state.writelen;
  41199. state.writelen = 0;
  41200. }
  41201. function onwrite(stream, er) {
  41202. var state = stream._writableState;
  41203. var sync = state.sync;
  41204. var cb = state.writecb;
  41205. if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  41206. onwriteStateUpdate(state);
  41207. if (er) onwriteError(stream, state, sync, er, cb);else {
  41208. // Check if we're actually ready to finish, but don't emit yet
  41209. var finished = needFinish(state) || stream.destroyed;
  41210. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  41211. clearBuffer(stream, state);
  41212. }
  41213. if (sync) {
  41214. process.nextTick(afterWrite, stream, state, finished, cb);
  41215. } else {
  41216. afterWrite(stream, state, finished, cb);
  41217. }
  41218. }
  41219. }
  41220. function afterWrite(stream, state, finished, cb) {
  41221. if (!finished) onwriteDrain(stream, state);
  41222. state.pendingcb--;
  41223. cb();
  41224. finishMaybe(stream, state);
  41225. } // Must force callback to be called on nextTick, so that we don't
  41226. // emit 'drain' before the write() consumer gets the 'false' return
  41227. // value, and has a chance to attach a 'drain' listener.
  41228. function onwriteDrain(stream, state) {
  41229. if (state.length === 0 && state.needDrain) {
  41230. state.needDrain = false;
  41231. stream.emit('drain');
  41232. }
  41233. } // if there's something in the buffer waiting, then process it
  41234. function clearBuffer(stream, state) {
  41235. state.bufferProcessing = true;
  41236. var entry = state.bufferedRequest;
  41237. if (stream._writev && entry && entry.next) {
  41238. // Fast case, write everything using _writev()
  41239. var l = state.bufferedRequestCount;
  41240. var buffer = new Array(l);
  41241. var holder = state.corkedRequestsFree;
  41242. holder.entry = entry;
  41243. var count = 0;
  41244. var allBuffers = true;
  41245. while (entry) {
  41246. buffer[count] = entry;
  41247. if (!entry.isBuf) allBuffers = false;
  41248. entry = entry.next;
  41249. count += 1;
  41250. }
  41251. buffer.allBuffers = allBuffers;
  41252. doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
  41253. // as the hot path ends with doWrite
  41254. state.pendingcb++;
  41255. state.lastBufferedRequest = null;
  41256. if (holder.next) {
  41257. state.corkedRequestsFree = holder.next;
  41258. holder.next = null;
  41259. } else {
  41260. state.corkedRequestsFree = new CorkedRequest(state);
  41261. }
  41262. state.bufferedRequestCount = 0;
  41263. } else {
  41264. // Slow case, write chunks one-by-one
  41265. while (entry) {
  41266. var chunk = entry.chunk;
  41267. var encoding = entry.encoding;
  41268. var cb = entry.callback;
  41269. var len = state.objectMode ? 1 : chunk.length;
  41270. doWrite(stream, state, false, len, chunk, encoding, cb);
  41271. entry = entry.next;
  41272. state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
  41273. // it means that we need to wait until it does.
  41274. // also, that means that the chunk and cb are currently
  41275. // being processed, so move the buffer counter past them.
  41276. if (state.writing) {
  41277. break;
  41278. }
  41279. }
  41280. if (entry === null) state.lastBufferedRequest = null;
  41281. }
  41282. state.bufferedRequest = entry;
  41283. state.bufferProcessing = false;
  41284. }
  41285. Writable.prototype._write = function (chunk, encoding, cb) {
  41286. cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
  41287. };
  41288. Writable.prototype._writev = null;
  41289. Writable.prototype.end = function (chunk, encoding, cb) {
  41290. var state = this._writableState;
  41291. if (typeof chunk === 'function') {
  41292. cb = chunk;
  41293. chunk = null;
  41294. encoding = null;
  41295. } else if (typeof encoding === 'function') {
  41296. cb = encoding;
  41297. encoding = null;
  41298. }
  41299. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
  41300. if (state.corked) {
  41301. state.corked = 1;
  41302. this.uncork();
  41303. } // ignore unnecessary end() calls.
  41304. if (!state.ending) endWritable(this, state, cb);
  41305. return this;
  41306. };
  41307. Object.defineProperty(Writable.prototype, 'writableLength', {
  41308. // making it explicit this property is not enumerable
  41309. // because otherwise some prototype manipulation in
  41310. // userland will fail
  41311. enumerable: false,
  41312. get: function get() {
  41313. return this._writableState.length;
  41314. }
  41315. });
  41316. function needFinish(state) {
  41317. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  41318. }
  41319. function callFinal(stream, state) {
  41320. stream._final(function (err) {
  41321. state.pendingcb--;
  41322. if (err) {
  41323. errorOrDestroy(stream, err);
  41324. }
  41325. state.prefinished = true;
  41326. stream.emit('prefinish');
  41327. finishMaybe(stream, state);
  41328. });
  41329. }
  41330. function prefinish(stream, state) {
  41331. if (!state.prefinished && !state.finalCalled) {
  41332. if (typeof stream._final === 'function' && !state.destroyed) {
  41333. state.pendingcb++;
  41334. state.finalCalled = true;
  41335. process.nextTick(callFinal, stream, state);
  41336. } else {
  41337. state.prefinished = true;
  41338. stream.emit('prefinish');
  41339. }
  41340. }
  41341. }
  41342. function finishMaybe(stream, state) {
  41343. var need = needFinish(state);
  41344. if (need) {
  41345. prefinish(stream, state);
  41346. if (state.pendingcb === 0) {
  41347. state.finished = true;
  41348. stream.emit('finish');
  41349. if (state.autoDestroy) {
  41350. // In case of duplex streams we need a way to detect
  41351. // if the readable side is ready for autoDestroy as well
  41352. var rState = stream._readableState;
  41353. if (!rState || rState.autoDestroy && rState.endEmitted) {
  41354. stream.destroy();
  41355. }
  41356. }
  41357. }
  41358. }
  41359. return need;
  41360. }
  41361. function endWritable(stream, state, cb) {
  41362. state.ending = true;
  41363. finishMaybe(stream, state);
  41364. if (cb) {
  41365. if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
  41366. }
  41367. state.ended = true;
  41368. stream.writable = false;
  41369. }
  41370. function onCorkedFinish(corkReq, state, err) {
  41371. var entry = corkReq.entry;
  41372. corkReq.entry = null;
  41373. while (entry) {
  41374. var cb = entry.callback;
  41375. state.pendingcb--;
  41376. cb(err);
  41377. entry = entry.next;
  41378. } // reuse the free corkReq.
  41379. state.corkedRequestsFree.next = corkReq;
  41380. }
  41381. Object.defineProperty(Writable.prototype, 'destroyed', {
  41382. // making it explicit this property is not enumerable
  41383. // because otherwise some prototype manipulation in
  41384. // userland will fail
  41385. enumerable: false,
  41386. get: function get() {
  41387. if (this._writableState === undefined) {
  41388. return false;
  41389. }
  41390. return this._writableState.destroyed;
  41391. },
  41392. set: function set(value) {
  41393. // we ignore the value if the stream
  41394. // has not been initialized yet
  41395. if (!this._writableState) {
  41396. return;
  41397. } // backward compatibility, the user is explicitly
  41398. // managing destroyed
  41399. this._writableState.destroyed = value;
  41400. }
  41401. });
  41402. Writable.prototype.destroy = destroyImpl.destroy;
  41403. Writable.prototype._undestroy = destroyImpl.undestroy;
  41404. Writable.prototype._destroy = function (err, cb) {
  41405. cb(err);
  41406. };
  41407. /***/ }),
  41408. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/async_iterator.js":
  41409. /*!****************************************************************************************************!*\
  41410. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/async_iterator.js ***!
  41411. \****************************************************************************************************/
  41412. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  41413. "use strict";
  41414. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  41415. var _Object$setPrototypeO;
  41416. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  41417. var finished = __webpack_require__(/*! ./end-of-stream */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  41418. var kLastResolve = Symbol('lastResolve');
  41419. var kLastReject = Symbol('lastReject');
  41420. var kError = Symbol('error');
  41421. var kEnded = Symbol('ended');
  41422. var kLastPromise = Symbol('lastPromise');
  41423. var kHandlePromise = Symbol('handlePromise');
  41424. var kStream = Symbol('stream');
  41425. function createIterResult(value, done) {
  41426. return {
  41427. value: value,
  41428. done: done
  41429. };
  41430. }
  41431. function readAndResolve(iter) {
  41432. var resolve = iter[kLastResolve];
  41433. if (resolve !== null) {
  41434. var data = iter[kStream].read(); // we defer if data is null
  41435. // we can be expecting either 'end' or
  41436. // 'error'
  41437. if (data !== null) {
  41438. iter[kLastPromise] = null;
  41439. iter[kLastResolve] = null;
  41440. iter[kLastReject] = null;
  41441. resolve(createIterResult(data, false));
  41442. }
  41443. }
  41444. }
  41445. function onReadable(iter) {
  41446. // we wait for the next tick, because it might
  41447. // emit an error with process.nextTick
  41448. process.nextTick(readAndResolve, iter);
  41449. }
  41450. function wrapForNext(lastPromise, iter) {
  41451. return function (resolve, reject) {
  41452. lastPromise.then(function () {
  41453. if (iter[kEnded]) {
  41454. resolve(createIterResult(undefined, true));
  41455. return;
  41456. }
  41457. iter[kHandlePromise](resolve, reject);
  41458. }, reject);
  41459. };
  41460. }
  41461. var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
  41462. var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
  41463. get stream() {
  41464. return this[kStream];
  41465. },
  41466. next: function next() {
  41467. var _this = this;
  41468. // if we have detected an error in the meanwhile
  41469. // reject straight away
  41470. var error = this[kError];
  41471. if (error !== null) {
  41472. return Promise.reject(error);
  41473. }
  41474. if (this[kEnded]) {
  41475. return Promise.resolve(createIterResult(undefined, true));
  41476. }
  41477. if (this[kStream].destroyed) {
  41478. // We need to defer via nextTick because if .destroy(err) is
  41479. // called, the error will be emitted via nextTick, and
  41480. // we cannot guarantee that there is no error lingering around
  41481. // waiting to be emitted.
  41482. return new Promise(function (resolve, reject) {
  41483. process.nextTick(function () {
  41484. if (_this[kError]) {
  41485. reject(_this[kError]);
  41486. } else {
  41487. resolve(createIterResult(undefined, true));
  41488. }
  41489. });
  41490. });
  41491. } // if we have multiple next() calls
  41492. // we will wait for the previous Promise to finish
  41493. // this logic is optimized to support for await loops,
  41494. // where next() is only called once at a time
  41495. var lastPromise = this[kLastPromise];
  41496. var promise;
  41497. if (lastPromise) {
  41498. promise = new Promise(wrapForNext(lastPromise, this));
  41499. } else {
  41500. // fast path needed to support multiple this.push()
  41501. // without triggering the next() queue
  41502. var data = this[kStream].read();
  41503. if (data !== null) {
  41504. return Promise.resolve(createIterResult(data, false));
  41505. }
  41506. promise = new Promise(this[kHandlePromise]);
  41507. }
  41508. this[kLastPromise] = promise;
  41509. return promise;
  41510. }
  41511. }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
  41512. return this;
  41513. }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
  41514. var _this2 = this;
  41515. // destroy(err, cb) is a private API
  41516. // we can guarantee we have that here, because we control the
  41517. // Readable class this is attached to
  41518. return new Promise(function (resolve, reject) {
  41519. _this2[kStream].destroy(null, function (err) {
  41520. if (err) {
  41521. reject(err);
  41522. return;
  41523. }
  41524. resolve(createIterResult(undefined, true));
  41525. });
  41526. });
  41527. }), _Object$setPrototypeO), AsyncIteratorPrototype);
  41528. var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
  41529. var _Object$create;
  41530. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
  41531. value: stream,
  41532. writable: true
  41533. }), _defineProperty(_Object$create, kLastResolve, {
  41534. value: null,
  41535. writable: true
  41536. }), _defineProperty(_Object$create, kLastReject, {
  41537. value: null,
  41538. writable: true
  41539. }), _defineProperty(_Object$create, kError, {
  41540. value: null,
  41541. writable: true
  41542. }), _defineProperty(_Object$create, kEnded, {
  41543. value: stream._readableState.endEmitted,
  41544. writable: true
  41545. }), _defineProperty(_Object$create, kHandlePromise, {
  41546. value: function value(resolve, reject) {
  41547. var data = iterator[kStream].read();
  41548. if (data) {
  41549. iterator[kLastPromise] = null;
  41550. iterator[kLastResolve] = null;
  41551. iterator[kLastReject] = null;
  41552. resolve(createIterResult(data, false));
  41553. } else {
  41554. iterator[kLastResolve] = resolve;
  41555. iterator[kLastReject] = reject;
  41556. }
  41557. },
  41558. writable: true
  41559. }), _Object$create));
  41560. iterator[kLastPromise] = null;
  41561. finished(stream, function (err) {
  41562. if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
  41563. var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
  41564. // returned by next() and store the error
  41565. if (reject !== null) {
  41566. iterator[kLastPromise] = null;
  41567. iterator[kLastResolve] = null;
  41568. iterator[kLastReject] = null;
  41569. reject(err);
  41570. }
  41571. iterator[kError] = err;
  41572. return;
  41573. }
  41574. var resolve = iterator[kLastResolve];
  41575. if (resolve !== null) {
  41576. iterator[kLastPromise] = null;
  41577. iterator[kLastResolve] = null;
  41578. iterator[kLastReject] = null;
  41579. resolve(createIterResult(undefined, true));
  41580. }
  41581. iterator[kEnded] = true;
  41582. });
  41583. stream.on('readable', onReadable.bind(null, iterator));
  41584. return iterator;
  41585. };
  41586. module.exports = createReadableStreamAsyncIterator;
  41587. /***/ }),
  41588. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/buffer_list.js":
  41589. /*!*************************************************************************************************!*\
  41590. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/buffer_list.js ***!
  41591. \*************************************************************************************************/
  41592. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  41593. "use strict";
  41594. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  41595. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  41596. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  41597. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  41598. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  41599. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  41600. var _require = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"),
  41601. Buffer = _require.Buffer;
  41602. var _require2 = __webpack_require__(/*! util */ "?f84a"),
  41603. inspect = _require2.inspect;
  41604. var custom = inspect && inspect.custom || 'inspect';
  41605. function copyBuffer(src, target, offset) {
  41606. Buffer.prototype.copy.call(src, target, offset);
  41607. }
  41608. module.exports =
  41609. /*#__PURE__*/
  41610. function () {
  41611. function BufferList() {
  41612. _classCallCheck(this, BufferList);
  41613. this.head = null;
  41614. this.tail = null;
  41615. this.length = 0;
  41616. }
  41617. _createClass(BufferList, [{
  41618. key: "push",
  41619. value: function push(v) {
  41620. var entry = {
  41621. data: v,
  41622. next: null
  41623. };
  41624. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  41625. this.tail = entry;
  41626. ++this.length;
  41627. }
  41628. }, {
  41629. key: "unshift",
  41630. value: function unshift(v) {
  41631. var entry = {
  41632. data: v,
  41633. next: this.head
  41634. };
  41635. if (this.length === 0) this.tail = entry;
  41636. this.head = entry;
  41637. ++this.length;
  41638. }
  41639. }, {
  41640. key: "shift",
  41641. value: function shift() {
  41642. if (this.length === 0) return;
  41643. var ret = this.head.data;
  41644. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  41645. --this.length;
  41646. return ret;
  41647. }
  41648. }, {
  41649. key: "clear",
  41650. value: function clear() {
  41651. this.head = this.tail = null;
  41652. this.length = 0;
  41653. }
  41654. }, {
  41655. key: "join",
  41656. value: function join(s) {
  41657. if (this.length === 0) return '';
  41658. var p = this.head;
  41659. var ret = '' + p.data;
  41660. while (p = p.next) {
  41661. ret += s + p.data;
  41662. }
  41663. return ret;
  41664. }
  41665. }, {
  41666. key: "concat",
  41667. value: function concat(n) {
  41668. if (this.length === 0) return Buffer.alloc(0);
  41669. var ret = Buffer.allocUnsafe(n >>> 0);
  41670. var p = this.head;
  41671. var i = 0;
  41672. while (p) {
  41673. copyBuffer(p.data, ret, i);
  41674. i += p.data.length;
  41675. p = p.next;
  41676. }
  41677. return ret;
  41678. } // Consumes a specified amount of bytes or characters from the buffered data.
  41679. }, {
  41680. key: "consume",
  41681. value: function consume(n, hasStrings) {
  41682. var ret;
  41683. if (n < this.head.data.length) {
  41684. // `slice` is the same for buffers and strings.
  41685. ret = this.head.data.slice(0, n);
  41686. this.head.data = this.head.data.slice(n);
  41687. } else if (n === this.head.data.length) {
  41688. // First chunk is a perfect match.
  41689. ret = this.shift();
  41690. } else {
  41691. // Result spans more than one buffer.
  41692. ret = hasStrings ? this._getString(n) : this._getBuffer(n);
  41693. }
  41694. return ret;
  41695. }
  41696. }, {
  41697. key: "first",
  41698. value: function first() {
  41699. return this.head.data;
  41700. } // Consumes a specified amount of characters from the buffered data.
  41701. }, {
  41702. key: "_getString",
  41703. value: function _getString(n) {
  41704. var p = this.head;
  41705. var c = 1;
  41706. var ret = p.data;
  41707. n -= ret.length;
  41708. while (p = p.next) {
  41709. var str = p.data;
  41710. var nb = n > str.length ? str.length : n;
  41711. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  41712. n -= nb;
  41713. if (n === 0) {
  41714. if (nb === str.length) {
  41715. ++c;
  41716. if (p.next) this.head = p.next;else this.head = this.tail = null;
  41717. } else {
  41718. this.head = p;
  41719. p.data = str.slice(nb);
  41720. }
  41721. break;
  41722. }
  41723. ++c;
  41724. }
  41725. this.length -= c;
  41726. return ret;
  41727. } // Consumes a specified amount of bytes from the buffered data.
  41728. }, {
  41729. key: "_getBuffer",
  41730. value: function _getBuffer(n) {
  41731. var ret = Buffer.allocUnsafe(n);
  41732. var p = this.head;
  41733. var c = 1;
  41734. p.data.copy(ret);
  41735. n -= p.data.length;
  41736. while (p = p.next) {
  41737. var buf = p.data;
  41738. var nb = n > buf.length ? buf.length : n;
  41739. buf.copy(ret, ret.length - n, 0, nb);
  41740. n -= nb;
  41741. if (n === 0) {
  41742. if (nb === buf.length) {
  41743. ++c;
  41744. if (p.next) this.head = p.next;else this.head = this.tail = null;
  41745. } else {
  41746. this.head = p;
  41747. p.data = buf.slice(nb);
  41748. }
  41749. break;
  41750. }
  41751. ++c;
  41752. }
  41753. this.length -= c;
  41754. return ret;
  41755. } // Make sure the linked list only shows the minimal necessary information.
  41756. }, {
  41757. key: custom,
  41758. value: function value(_, options) {
  41759. return inspect(this, _objectSpread({}, options, {
  41760. // Only inspect one level.
  41761. depth: 0,
  41762. // It should not recurse.
  41763. customInspect: false
  41764. }));
  41765. }
  41766. }]);
  41767. return BufferList;
  41768. }();
  41769. /***/ }),
  41770. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/destroy.js":
  41771. /*!*********************************************************************************************!*\
  41772. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/destroy.js ***!
  41773. \*********************************************************************************************/
  41774. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  41775. "use strict";
  41776. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  41777. // undocumented cb() API, needed for core, not for public API
  41778. function destroy(err, cb) {
  41779. var _this = this;
  41780. var readableDestroyed = this._readableState && this._readableState.destroyed;
  41781. var writableDestroyed = this._writableState && this._writableState.destroyed;
  41782. if (readableDestroyed || writableDestroyed) {
  41783. if (cb) {
  41784. cb(err);
  41785. } else if (err) {
  41786. if (!this._writableState) {
  41787. process.nextTick(emitErrorNT, this, err);
  41788. } else if (!this._writableState.errorEmitted) {
  41789. this._writableState.errorEmitted = true;
  41790. process.nextTick(emitErrorNT, this, err);
  41791. }
  41792. }
  41793. return this;
  41794. } // we set destroyed to true before firing error callbacks in order
  41795. // to make it re-entrance safe in case destroy() is called within callbacks
  41796. if (this._readableState) {
  41797. this._readableState.destroyed = true;
  41798. } // if this is a duplex stream mark the writable part as destroyed as well
  41799. if (this._writableState) {
  41800. this._writableState.destroyed = true;
  41801. }
  41802. this._destroy(err || null, function (err) {
  41803. if (!cb && err) {
  41804. if (!_this._writableState) {
  41805. process.nextTick(emitErrorAndCloseNT, _this, err);
  41806. } else if (!_this._writableState.errorEmitted) {
  41807. _this._writableState.errorEmitted = true;
  41808. process.nextTick(emitErrorAndCloseNT, _this, err);
  41809. } else {
  41810. process.nextTick(emitCloseNT, _this);
  41811. }
  41812. } else if (cb) {
  41813. process.nextTick(emitCloseNT, _this);
  41814. cb(err);
  41815. } else {
  41816. process.nextTick(emitCloseNT, _this);
  41817. }
  41818. });
  41819. return this;
  41820. }
  41821. function emitErrorAndCloseNT(self, err) {
  41822. emitErrorNT(self, err);
  41823. emitCloseNT(self);
  41824. }
  41825. function emitCloseNT(self) {
  41826. if (self._writableState && !self._writableState.emitClose) return;
  41827. if (self._readableState && !self._readableState.emitClose) return;
  41828. self.emit('close');
  41829. }
  41830. function undestroy() {
  41831. if (this._readableState) {
  41832. this._readableState.destroyed = false;
  41833. this._readableState.reading = false;
  41834. this._readableState.ended = false;
  41835. this._readableState.endEmitted = false;
  41836. }
  41837. if (this._writableState) {
  41838. this._writableState.destroyed = false;
  41839. this._writableState.ended = false;
  41840. this._writableState.ending = false;
  41841. this._writableState.finalCalled = false;
  41842. this._writableState.prefinished = false;
  41843. this._writableState.finished = false;
  41844. this._writableState.errorEmitted = false;
  41845. }
  41846. }
  41847. function emitErrorNT(self, err) {
  41848. self.emit('error', err);
  41849. }
  41850. function errorOrDestroy(stream, err) {
  41851. // We have tests that rely on errors being emitted
  41852. // in the same tick, so changing this is semver major.
  41853. // For now when you opt-in to autoDestroy we allow
  41854. // the error to be emitted nextTick. In a future
  41855. // semver major update we should change the default to this.
  41856. var rState = stream._readableState;
  41857. var wState = stream._writableState;
  41858. if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
  41859. }
  41860. module.exports = {
  41861. destroy: destroy,
  41862. undestroy: undestroy,
  41863. errorOrDestroy: errorOrDestroy
  41864. };
  41865. /***/ }),
  41866. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/end-of-stream.js":
  41867. /*!***************************************************************************************************!*\
  41868. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/end-of-stream.js ***!
  41869. \***************************************************************************************************/
  41870. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  41871. "use strict";
  41872. // Ported from https://github.com/mafintosh/end-of-stream with
  41873. // permission from the author, Mathias Buus (@mafintosh).
  41874. var ERR_STREAM_PREMATURE_CLOSE = (__webpack_require__(/*! ../../../errors */ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js").codes.ERR_STREAM_PREMATURE_CLOSE);
  41875. function once(callback) {
  41876. var called = false;
  41877. return function () {
  41878. if (called) return;
  41879. called = true;
  41880. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  41881. args[_key] = arguments[_key];
  41882. }
  41883. callback.apply(this, args);
  41884. };
  41885. }
  41886. function noop() {}
  41887. function isRequest(stream) {
  41888. return stream.setHeader && typeof stream.abort === 'function';
  41889. }
  41890. function eos(stream, opts, callback) {
  41891. if (typeof opts === 'function') return eos(stream, null, opts);
  41892. if (!opts) opts = {};
  41893. callback = once(callback || noop);
  41894. var readable = opts.readable || opts.readable !== false && stream.readable;
  41895. var writable = opts.writable || opts.writable !== false && stream.writable;
  41896. var onlegacyfinish = function onlegacyfinish() {
  41897. if (!stream.writable) onfinish();
  41898. };
  41899. var writableEnded = stream._writableState && stream._writableState.finished;
  41900. var onfinish = function onfinish() {
  41901. writable = false;
  41902. writableEnded = true;
  41903. if (!readable) callback.call(stream);
  41904. };
  41905. var readableEnded = stream._readableState && stream._readableState.endEmitted;
  41906. var onend = function onend() {
  41907. readable = false;
  41908. readableEnded = true;
  41909. if (!writable) callback.call(stream);
  41910. };
  41911. var onerror = function onerror(err) {
  41912. callback.call(stream, err);
  41913. };
  41914. var onclose = function onclose() {
  41915. var err;
  41916. if (readable && !readableEnded) {
  41917. if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  41918. return callback.call(stream, err);
  41919. }
  41920. if (writable && !writableEnded) {
  41921. if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  41922. return callback.call(stream, err);
  41923. }
  41924. };
  41925. var onrequest = function onrequest() {
  41926. stream.req.on('finish', onfinish);
  41927. };
  41928. if (isRequest(stream)) {
  41929. stream.on('complete', onfinish);
  41930. stream.on('abort', onclose);
  41931. if (stream.req) onrequest();else stream.on('request', onrequest);
  41932. } else if (writable && !stream._writableState) {
  41933. // legacy streams
  41934. stream.on('end', onlegacyfinish);
  41935. stream.on('close', onlegacyfinish);
  41936. }
  41937. stream.on('end', onend);
  41938. stream.on('finish', onfinish);
  41939. if (opts.error !== false) stream.on('error', onerror);
  41940. stream.on('close', onclose);
  41941. return function () {
  41942. stream.removeListener('complete', onfinish);
  41943. stream.removeListener('abort', onclose);
  41944. stream.removeListener('request', onrequest);
  41945. if (stream.req) stream.req.removeListener('finish', onfinish);
  41946. stream.removeListener('end', onlegacyfinish);
  41947. stream.removeListener('close', onlegacyfinish);
  41948. stream.removeListener('finish', onfinish);
  41949. stream.removeListener('end', onend);
  41950. stream.removeListener('error', onerror);
  41951. stream.removeListener('close', onclose);
  41952. };
  41953. }
  41954. module.exports = eos;
  41955. /***/ }),
  41956. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/from-browser.js":
  41957. /*!**************************************************************************************************!*\
  41958. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/from-browser.js ***!
  41959. \**************************************************************************************************/
  41960. /***/ ((module) => {
  41961. module.exports = function () {
  41962. throw new Error('Readable.from is not available in the browser')
  41963. };
  41964. /***/ }),
  41965. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/pipeline.js":
  41966. /*!**********************************************************************************************!*\
  41967. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/pipeline.js ***!
  41968. \**********************************************************************************************/
  41969. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  41970. "use strict";
  41971. // Ported from https://github.com/mafintosh/pump with
  41972. // permission from the author, Mathias Buus (@mafintosh).
  41973. var eos;
  41974. function once(callback) {
  41975. var called = false;
  41976. return function () {
  41977. if (called) return;
  41978. called = true;
  41979. callback.apply(void 0, arguments);
  41980. };
  41981. }
  41982. var _require$codes = (__webpack_require__(/*! ../../../errors */ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js").codes),
  41983. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
  41984. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
  41985. function noop(err) {
  41986. // Rethrow the error if it exists to avoid swallowing it
  41987. if (err) throw err;
  41988. }
  41989. function isRequest(stream) {
  41990. return stream.setHeader && typeof stream.abort === 'function';
  41991. }
  41992. function destroyer(stream, reading, writing, callback) {
  41993. callback = once(callback);
  41994. var closed = false;
  41995. stream.on('close', function () {
  41996. closed = true;
  41997. });
  41998. if (eos === undefined) eos = __webpack_require__(/*! ./end-of-stream */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  41999. eos(stream, {
  42000. readable: reading,
  42001. writable: writing
  42002. }, function (err) {
  42003. if (err) return callback(err);
  42004. closed = true;
  42005. callback();
  42006. });
  42007. var destroyed = false;
  42008. return function (err) {
  42009. if (closed) return;
  42010. if (destroyed) return;
  42011. destroyed = true; // request.destroy just do .end - .abort is what we want
  42012. if (isRequest(stream)) return stream.abort();
  42013. if (typeof stream.destroy === 'function') return stream.destroy();
  42014. callback(err || new ERR_STREAM_DESTROYED('pipe'));
  42015. };
  42016. }
  42017. function call(fn) {
  42018. fn();
  42019. }
  42020. function pipe(from, to) {
  42021. return from.pipe(to);
  42022. }
  42023. function popCallback(streams) {
  42024. if (!streams.length) return noop;
  42025. if (typeof streams[streams.length - 1] !== 'function') return noop;
  42026. return streams.pop();
  42027. }
  42028. function pipeline() {
  42029. for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
  42030. streams[_key] = arguments[_key];
  42031. }
  42032. var callback = popCallback(streams);
  42033. if (Array.isArray(streams[0])) streams = streams[0];
  42034. if (streams.length < 2) {
  42035. throw new ERR_MISSING_ARGS('streams');
  42036. }
  42037. var error;
  42038. var destroys = streams.map(function (stream, i) {
  42039. var reading = i < streams.length - 1;
  42040. var writing = i > 0;
  42041. return destroyer(stream, reading, writing, function (err) {
  42042. if (!error) error = err;
  42043. if (err) destroys.forEach(call);
  42044. if (reading) return;
  42045. destroys.forEach(call);
  42046. callback(error);
  42047. });
  42048. });
  42049. return streams.reduce(pipe);
  42050. }
  42051. module.exports = pipeline;
  42052. /***/ }),
  42053. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/state.js":
  42054. /*!*******************************************************************************************!*\
  42055. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/state.js ***!
  42056. \*******************************************************************************************/
  42057. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42058. "use strict";
  42059. var ERR_INVALID_OPT_VALUE = (__webpack_require__(/*! ../../../errors */ "./node_modules/hash-base/node_modules/readable-stream/errors-browser.js").codes.ERR_INVALID_OPT_VALUE);
  42060. function highWaterMarkFrom(options, isDuplex, duplexKey) {
  42061. return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
  42062. }
  42063. function getHighWaterMark(state, options, duplexKey, isDuplex) {
  42064. var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
  42065. if (hwm != null) {
  42066. if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
  42067. var name = isDuplex ? duplexKey : 'highWaterMark';
  42068. throw new ERR_INVALID_OPT_VALUE(name, hwm);
  42069. }
  42070. return Math.floor(hwm);
  42071. } // Default value
  42072. return state.objectMode ? 16 : 16 * 1024;
  42073. }
  42074. module.exports = {
  42075. getHighWaterMark: getHighWaterMark
  42076. };
  42077. /***/ }),
  42078. /***/ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/stream-browser.js":
  42079. /*!****************************************************************************************************!*\
  42080. !*** ./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/stream-browser.js ***!
  42081. \****************************************************************************************************/
  42082. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42083. module.exports = __webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter;
  42084. /***/ }),
  42085. /***/ "./node_modules/hash-base/node_modules/readable-stream/readable-browser.js":
  42086. /*!*********************************************************************************!*\
  42087. !*** ./node_modules/hash-base/node_modules/readable-stream/readable-browser.js ***!
  42088. \*********************************************************************************/
  42089. /***/ ((module, exports, __webpack_require__) => {
  42090. exports = module.exports = __webpack_require__(/*! ./lib/_stream_readable.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js");
  42091. exports.Stream = exports;
  42092. exports.Readable = exports;
  42093. exports.Writable = __webpack_require__(/*! ./lib/_stream_writable.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js");
  42094. exports.Duplex = __webpack_require__(/*! ./lib/_stream_duplex.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js");
  42095. exports.Transform = __webpack_require__(/*! ./lib/_stream_transform.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_transform.js");
  42096. exports.PassThrough = __webpack_require__(/*! ./lib/_stream_passthrough.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/_stream_passthrough.js");
  42097. exports.finished = __webpack_require__(/*! ./lib/internal/streams/end-of-stream.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  42098. exports.pipeline = __webpack_require__(/*! ./lib/internal/streams/pipeline.js */ "./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/pipeline.js");
  42099. /***/ }),
  42100. /***/ "./node_modules/hash-base/node_modules/safe-buffer/index.js":
  42101. /*!******************************************************************!*\
  42102. !*** ./node_modules/hash-base/node_modules/safe-buffer/index.js ***!
  42103. \******************************************************************/
  42104. /***/ ((module, exports, __webpack_require__) => {
  42105. /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  42106. /* eslint-disable node/no-deprecated-api */
  42107. var buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")
  42108. var Buffer = buffer.Buffer
  42109. // alternative to using Object.keys for old browsers
  42110. function copyProps (src, dst) {
  42111. for (var key in src) {
  42112. dst[key] = src[key]
  42113. }
  42114. }
  42115. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  42116. module.exports = buffer
  42117. } else {
  42118. // Copy properties from require('buffer')
  42119. copyProps(buffer, exports)
  42120. exports.Buffer = SafeBuffer
  42121. }
  42122. function SafeBuffer (arg, encodingOrOffset, length) {
  42123. return Buffer(arg, encodingOrOffset, length)
  42124. }
  42125. SafeBuffer.prototype = Object.create(Buffer.prototype)
  42126. // Copy static methods from Buffer
  42127. copyProps(Buffer, SafeBuffer)
  42128. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  42129. if (typeof arg === 'number') {
  42130. throw new TypeError('Argument must not be a number')
  42131. }
  42132. return Buffer(arg, encodingOrOffset, length)
  42133. }
  42134. SafeBuffer.alloc = function (size, fill, encoding) {
  42135. if (typeof size !== 'number') {
  42136. throw new TypeError('Argument must be a number')
  42137. }
  42138. var buf = Buffer(size)
  42139. if (fill !== undefined) {
  42140. if (typeof encoding === 'string') {
  42141. buf.fill(fill, encoding)
  42142. } else {
  42143. buf.fill(fill)
  42144. }
  42145. } else {
  42146. buf.fill(0)
  42147. }
  42148. return buf
  42149. }
  42150. SafeBuffer.allocUnsafe = function (size) {
  42151. if (typeof size !== 'number') {
  42152. throw new TypeError('Argument must be a number')
  42153. }
  42154. return Buffer(size)
  42155. }
  42156. SafeBuffer.allocUnsafeSlow = function (size) {
  42157. if (typeof size !== 'number') {
  42158. throw new TypeError('Argument must be a number')
  42159. }
  42160. return buffer.SlowBuffer(size)
  42161. }
  42162. /***/ }),
  42163. /***/ "./node_modules/hash.js/lib/hash.js":
  42164. /*!******************************************!*\
  42165. !*** ./node_modules/hash.js/lib/hash.js ***!
  42166. \******************************************/
  42167. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  42168. var hash = exports;
  42169. hash.utils = __webpack_require__(/*! ./hash/utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42170. hash.common = __webpack_require__(/*! ./hash/common */ "./node_modules/hash.js/lib/hash/common.js");
  42171. hash.sha = __webpack_require__(/*! ./hash/sha */ "./node_modules/hash.js/lib/hash/sha.js");
  42172. hash.ripemd = __webpack_require__(/*! ./hash/ripemd */ "./node_modules/hash.js/lib/hash/ripemd.js");
  42173. hash.hmac = __webpack_require__(/*! ./hash/hmac */ "./node_modules/hash.js/lib/hash/hmac.js");
  42174. // Proxy hash functions to the main object
  42175. hash.sha1 = hash.sha.sha1;
  42176. hash.sha256 = hash.sha.sha256;
  42177. hash.sha224 = hash.sha.sha224;
  42178. hash.sha384 = hash.sha.sha384;
  42179. hash.sha512 = hash.sha.sha512;
  42180. hash.ripemd160 = hash.ripemd.ripemd160;
  42181. /***/ }),
  42182. /***/ "./node_modules/hash.js/lib/hash/common.js":
  42183. /*!*************************************************!*\
  42184. !*** ./node_modules/hash.js/lib/hash/common.js ***!
  42185. \*************************************************/
  42186. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  42187. "use strict";
  42188. var utils = __webpack_require__(/*! ./utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42189. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  42190. function BlockHash() {
  42191. this.pending = null;
  42192. this.pendingTotal = 0;
  42193. this.blockSize = this.constructor.blockSize;
  42194. this.outSize = this.constructor.outSize;
  42195. this.hmacStrength = this.constructor.hmacStrength;
  42196. this.padLength = this.constructor.padLength / 8;
  42197. this.endian = 'big';
  42198. this._delta8 = this.blockSize / 8;
  42199. this._delta32 = this.blockSize / 32;
  42200. }
  42201. exports.BlockHash = BlockHash;
  42202. BlockHash.prototype.update = function update(msg, enc) {
  42203. // Convert message to array, pad it, and join into 32bit blocks
  42204. msg = utils.toArray(msg, enc);
  42205. if (!this.pending)
  42206. this.pending = msg;
  42207. else
  42208. this.pending = this.pending.concat(msg);
  42209. this.pendingTotal += msg.length;
  42210. // Enough data, try updating
  42211. if (this.pending.length >= this._delta8) {
  42212. msg = this.pending;
  42213. // Process pending data in blocks
  42214. var r = msg.length % this._delta8;
  42215. this.pending = msg.slice(msg.length - r, msg.length);
  42216. if (this.pending.length === 0)
  42217. this.pending = null;
  42218. msg = utils.join32(msg, 0, msg.length - r, this.endian);
  42219. for (var i = 0; i < msg.length; i += this._delta32)
  42220. this._update(msg, i, i + this._delta32);
  42221. }
  42222. return this;
  42223. };
  42224. BlockHash.prototype.digest = function digest(enc) {
  42225. this.update(this._pad());
  42226. assert(this.pending === null);
  42227. return this._digest(enc);
  42228. };
  42229. BlockHash.prototype._pad = function pad() {
  42230. var len = this.pendingTotal;
  42231. var bytes = this._delta8;
  42232. var k = bytes - ((len + this.padLength) % bytes);
  42233. var res = new Array(k + this.padLength);
  42234. res[0] = 0x80;
  42235. for (var i = 1; i < k; i++)
  42236. res[i] = 0;
  42237. // Append length
  42238. len <<= 3;
  42239. if (this.endian === 'big') {
  42240. for (var t = 8; t < this.padLength; t++)
  42241. res[i++] = 0;
  42242. res[i++] = 0;
  42243. res[i++] = 0;
  42244. res[i++] = 0;
  42245. res[i++] = 0;
  42246. res[i++] = (len >>> 24) & 0xff;
  42247. res[i++] = (len >>> 16) & 0xff;
  42248. res[i++] = (len >>> 8) & 0xff;
  42249. res[i++] = len & 0xff;
  42250. } else {
  42251. res[i++] = len & 0xff;
  42252. res[i++] = (len >>> 8) & 0xff;
  42253. res[i++] = (len >>> 16) & 0xff;
  42254. res[i++] = (len >>> 24) & 0xff;
  42255. res[i++] = 0;
  42256. res[i++] = 0;
  42257. res[i++] = 0;
  42258. res[i++] = 0;
  42259. for (t = 8; t < this.padLength; t++)
  42260. res[i++] = 0;
  42261. }
  42262. return res;
  42263. };
  42264. /***/ }),
  42265. /***/ "./node_modules/hash.js/lib/hash/hmac.js":
  42266. /*!***********************************************!*\
  42267. !*** ./node_modules/hash.js/lib/hash/hmac.js ***!
  42268. \***********************************************/
  42269. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42270. "use strict";
  42271. var utils = __webpack_require__(/*! ./utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42272. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  42273. function Hmac(hash, key, enc) {
  42274. if (!(this instanceof Hmac))
  42275. return new Hmac(hash, key, enc);
  42276. this.Hash = hash;
  42277. this.blockSize = hash.blockSize / 8;
  42278. this.outSize = hash.outSize / 8;
  42279. this.inner = null;
  42280. this.outer = null;
  42281. this._init(utils.toArray(key, enc));
  42282. }
  42283. module.exports = Hmac;
  42284. Hmac.prototype._init = function init(key) {
  42285. // Shorten key, if needed
  42286. if (key.length > this.blockSize)
  42287. key = new this.Hash().update(key).digest();
  42288. assert(key.length <= this.blockSize);
  42289. // Add padding to key
  42290. for (var i = key.length; i < this.blockSize; i++)
  42291. key.push(0);
  42292. for (i = 0; i < key.length; i++)
  42293. key[i] ^= 0x36;
  42294. this.inner = new this.Hash().update(key);
  42295. // 0x36 ^ 0x5c = 0x6a
  42296. for (i = 0; i < key.length; i++)
  42297. key[i] ^= 0x6a;
  42298. this.outer = new this.Hash().update(key);
  42299. };
  42300. Hmac.prototype.update = function update(msg, enc) {
  42301. this.inner.update(msg, enc);
  42302. return this;
  42303. };
  42304. Hmac.prototype.digest = function digest(enc) {
  42305. this.outer.update(this.inner.digest());
  42306. return this.outer.digest(enc);
  42307. };
  42308. /***/ }),
  42309. /***/ "./node_modules/hash.js/lib/hash/ripemd.js":
  42310. /*!*************************************************!*\
  42311. !*** ./node_modules/hash.js/lib/hash/ripemd.js ***!
  42312. \*************************************************/
  42313. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  42314. "use strict";
  42315. var utils = __webpack_require__(/*! ./utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42316. var common = __webpack_require__(/*! ./common */ "./node_modules/hash.js/lib/hash/common.js");
  42317. var rotl32 = utils.rotl32;
  42318. var sum32 = utils.sum32;
  42319. var sum32_3 = utils.sum32_3;
  42320. var sum32_4 = utils.sum32_4;
  42321. var BlockHash = common.BlockHash;
  42322. function RIPEMD160() {
  42323. if (!(this instanceof RIPEMD160))
  42324. return new RIPEMD160();
  42325. BlockHash.call(this);
  42326. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
  42327. this.endian = 'little';
  42328. }
  42329. utils.inherits(RIPEMD160, BlockHash);
  42330. exports.ripemd160 = RIPEMD160;
  42331. RIPEMD160.blockSize = 512;
  42332. RIPEMD160.outSize = 160;
  42333. RIPEMD160.hmacStrength = 192;
  42334. RIPEMD160.padLength = 64;
  42335. RIPEMD160.prototype._update = function update(msg, start) {
  42336. var A = this.h[0];
  42337. var B = this.h[1];
  42338. var C = this.h[2];
  42339. var D = this.h[3];
  42340. var E = this.h[4];
  42341. var Ah = A;
  42342. var Bh = B;
  42343. var Ch = C;
  42344. var Dh = D;
  42345. var Eh = E;
  42346. for (var j = 0; j < 80; j++) {
  42347. var T = sum32(
  42348. rotl32(
  42349. sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
  42350. s[j]),
  42351. E);
  42352. A = E;
  42353. E = D;
  42354. D = rotl32(C, 10);
  42355. C = B;
  42356. B = T;
  42357. T = sum32(
  42358. rotl32(
  42359. sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
  42360. sh[j]),
  42361. Eh);
  42362. Ah = Eh;
  42363. Eh = Dh;
  42364. Dh = rotl32(Ch, 10);
  42365. Ch = Bh;
  42366. Bh = T;
  42367. }
  42368. T = sum32_3(this.h[1], C, Dh);
  42369. this.h[1] = sum32_3(this.h[2], D, Eh);
  42370. this.h[2] = sum32_3(this.h[3], E, Ah);
  42371. this.h[3] = sum32_3(this.h[4], A, Bh);
  42372. this.h[4] = sum32_3(this.h[0], B, Ch);
  42373. this.h[0] = T;
  42374. };
  42375. RIPEMD160.prototype._digest = function digest(enc) {
  42376. if (enc === 'hex')
  42377. return utils.toHex32(this.h, 'little');
  42378. else
  42379. return utils.split32(this.h, 'little');
  42380. };
  42381. function f(j, x, y, z) {
  42382. if (j <= 15)
  42383. return x ^ y ^ z;
  42384. else if (j <= 31)
  42385. return (x & y) | ((~x) & z);
  42386. else if (j <= 47)
  42387. return (x | (~y)) ^ z;
  42388. else if (j <= 63)
  42389. return (x & z) | (y & (~z));
  42390. else
  42391. return x ^ (y | (~z));
  42392. }
  42393. function K(j) {
  42394. if (j <= 15)
  42395. return 0x00000000;
  42396. else if (j <= 31)
  42397. return 0x5a827999;
  42398. else if (j <= 47)
  42399. return 0x6ed9eba1;
  42400. else if (j <= 63)
  42401. return 0x8f1bbcdc;
  42402. else
  42403. return 0xa953fd4e;
  42404. }
  42405. function Kh(j) {
  42406. if (j <= 15)
  42407. return 0x50a28be6;
  42408. else if (j <= 31)
  42409. return 0x5c4dd124;
  42410. else if (j <= 47)
  42411. return 0x6d703ef3;
  42412. else if (j <= 63)
  42413. return 0x7a6d76e9;
  42414. else
  42415. return 0x00000000;
  42416. }
  42417. var r = [
  42418. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  42419. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  42420. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  42421. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  42422. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  42423. ];
  42424. var rh = [
  42425. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  42426. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  42427. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  42428. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  42429. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  42430. ];
  42431. var s = [
  42432. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  42433. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  42434. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  42435. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  42436. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  42437. ];
  42438. var sh = [
  42439. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  42440. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  42441. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  42442. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  42443. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  42444. ];
  42445. /***/ }),
  42446. /***/ "./node_modules/hash.js/lib/hash/sha.js":
  42447. /*!**********************************************!*\
  42448. !*** ./node_modules/hash.js/lib/hash/sha.js ***!
  42449. \**********************************************/
  42450. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  42451. "use strict";
  42452. exports.sha1 = __webpack_require__(/*! ./sha/1 */ "./node_modules/hash.js/lib/hash/sha/1.js");
  42453. exports.sha224 = __webpack_require__(/*! ./sha/224 */ "./node_modules/hash.js/lib/hash/sha/224.js");
  42454. exports.sha256 = __webpack_require__(/*! ./sha/256 */ "./node_modules/hash.js/lib/hash/sha/256.js");
  42455. exports.sha384 = __webpack_require__(/*! ./sha/384 */ "./node_modules/hash.js/lib/hash/sha/384.js");
  42456. exports.sha512 = __webpack_require__(/*! ./sha/512 */ "./node_modules/hash.js/lib/hash/sha/512.js");
  42457. /***/ }),
  42458. /***/ "./node_modules/hash.js/lib/hash/sha/1.js":
  42459. /*!************************************************!*\
  42460. !*** ./node_modules/hash.js/lib/hash/sha/1.js ***!
  42461. \************************************************/
  42462. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42463. "use strict";
  42464. var utils = __webpack_require__(/*! ../utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42465. var common = __webpack_require__(/*! ../common */ "./node_modules/hash.js/lib/hash/common.js");
  42466. var shaCommon = __webpack_require__(/*! ./common */ "./node_modules/hash.js/lib/hash/sha/common.js");
  42467. var rotl32 = utils.rotl32;
  42468. var sum32 = utils.sum32;
  42469. var sum32_5 = utils.sum32_5;
  42470. var ft_1 = shaCommon.ft_1;
  42471. var BlockHash = common.BlockHash;
  42472. var sha1_K = [
  42473. 0x5A827999, 0x6ED9EBA1,
  42474. 0x8F1BBCDC, 0xCA62C1D6
  42475. ];
  42476. function SHA1() {
  42477. if (!(this instanceof SHA1))
  42478. return new SHA1();
  42479. BlockHash.call(this);
  42480. this.h = [
  42481. 0x67452301, 0xefcdab89, 0x98badcfe,
  42482. 0x10325476, 0xc3d2e1f0 ];
  42483. this.W = new Array(80);
  42484. }
  42485. utils.inherits(SHA1, BlockHash);
  42486. module.exports = SHA1;
  42487. SHA1.blockSize = 512;
  42488. SHA1.outSize = 160;
  42489. SHA1.hmacStrength = 80;
  42490. SHA1.padLength = 64;
  42491. SHA1.prototype._update = function _update(msg, start) {
  42492. var W = this.W;
  42493. for (var i = 0; i < 16; i++)
  42494. W[i] = msg[start + i];
  42495. for(; i < W.length; i++)
  42496. W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
  42497. var a = this.h[0];
  42498. var b = this.h[1];
  42499. var c = this.h[2];
  42500. var d = this.h[3];
  42501. var e = this.h[4];
  42502. for (i = 0; i < W.length; i++) {
  42503. var s = ~~(i / 20);
  42504. var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
  42505. e = d;
  42506. d = c;
  42507. c = rotl32(b, 30);
  42508. b = a;
  42509. a = t;
  42510. }
  42511. this.h[0] = sum32(this.h[0], a);
  42512. this.h[1] = sum32(this.h[1], b);
  42513. this.h[2] = sum32(this.h[2], c);
  42514. this.h[3] = sum32(this.h[3], d);
  42515. this.h[4] = sum32(this.h[4], e);
  42516. };
  42517. SHA1.prototype._digest = function digest(enc) {
  42518. if (enc === 'hex')
  42519. return utils.toHex32(this.h, 'big');
  42520. else
  42521. return utils.split32(this.h, 'big');
  42522. };
  42523. /***/ }),
  42524. /***/ "./node_modules/hash.js/lib/hash/sha/224.js":
  42525. /*!**************************************************!*\
  42526. !*** ./node_modules/hash.js/lib/hash/sha/224.js ***!
  42527. \**************************************************/
  42528. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42529. "use strict";
  42530. var utils = __webpack_require__(/*! ../utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42531. var SHA256 = __webpack_require__(/*! ./256 */ "./node_modules/hash.js/lib/hash/sha/256.js");
  42532. function SHA224() {
  42533. if (!(this instanceof SHA224))
  42534. return new SHA224();
  42535. SHA256.call(this);
  42536. this.h = [
  42537. 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  42538. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
  42539. }
  42540. utils.inherits(SHA224, SHA256);
  42541. module.exports = SHA224;
  42542. SHA224.blockSize = 512;
  42543. SHA224.outSize = 224;
  42544. SHA224.hmacStrength = 192;
  42545. SHA224.padLength = 64;
  42546. SHA224.prototype._digest = function digest(enc) {
  42547. // Just truncate output
  42548. if (enc === 'hex')
  42549. return utils.toHex32(this.h.slice(0, 7), 'big');
  42550. else
  42551. return utils.split32(this.h.slice(0, 7), 'big');
  42552. };
  42553. /***/ }),
  42554. /***/ "./node_modules/hash.js/lib/hash/sha/256.js":
  42555. /*!**************************************************!*\
  42556. !*** ./node_modules/hash.js/lib/hash/sha/256.js ***!
  42557. \**************************************************/
  42558. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42559. "use strict";
  42560. var utils = __webpack_require__(/*! ../utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42561. var common = __webpack_require__(/*! ../common */ "./node_modules/hash.js/lib/hash/common.js");
  42562. var shaCommon = __webpack_require__(/*! ./common */ "./node_modules/hash.js/lib/hash/sha/common.js");
  42563. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  42564. var sum32 = utils.sum32;
  42565. var sum32_4 = utils.sum32_4;
  42566. var sum32_5 = utils.sum32_5;
  42567. var ch32 = shaCommon.ch32;
  42568. var maj32 = shaCommon.maj32;
  42569. var s0_256 = shaCommon.s0_256;
  42570. var s1_256 = shaCommon.s1_256;
  42571. var g0_256 = shaCommon.g0_256;
  42572. var g1_256 = shaCommon.g1_256;
  42573. var BlockHash = common.BlockHash;
  42574. var sha256_K = [
  42575. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  42576. 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  42577. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  42578. 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  42579. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  42580. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  42581. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  42582. 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  42583. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  42584. 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  42585. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  42586. 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  42587. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  42588. 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  42589. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  42590. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  42591. ];
  42592. function SHA256() {
  42593. if (!(this instanceof SHA256))
  42594. return new SHA256();
  42595. BlockHash.call(this);
  42596. this.h = [
  42597. 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  42598. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
  42599. ];
  42600. this.k = sha256_K;
  42601. this.W = new Array(64);
  42602. }
  42603. utils.inherits(SHA256, BlockHash);
  42604. module.exports = SHA256;
  42605. SHA256.blockSize = 512;
  42606. SHA256.outSize = 256;
  42607. SHA256.hmacStrength = 192;
  42608. SHA256.padLength = 64;
  42609. SHA256.prototype._update = function _update(msg, start) {
  42610. var W = this.W;
  42611. for (var i = 0; i < 16; i++)
  42612. W[i] = msg[start + i];
  42613. for (; i < W.length; i++)
  42614. W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
  42615. var a = this.h[0];
  42616. var b = this.h[1];
  42617. var c = this.h[2];
  42618. var d = this.h[3];
  42619. var e = this.h[4];
  42620. var f = this.h[5];
  42621. var g = this.h[6];
  42622. var h = this.h[7];
  42623. assert(this.k.length === W.length);
  42624. for (i = 0; i < W.length; i++) {
  42625. var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
  42626. var T2 = sum32(s0_256(a), maj32(a, b, c));
  42627. h = g;
  42628. g = f;
  42629. f = e;
  42630. e = sum32(d, T1);
  42631. d = c;
  42632. c = b;
  42633. b = a;
  42634. a = sum32(T1, T2);
  42635. }
  42636. this.h[0] = sum32(this.h[0], a);
  42637. this.h[1] = sum32(this.h[1], b);
  42638. this.h[2] = sum32(this.h[2], c);
  42639. this.h[3] = sum32(this.h[3], d);
  42640. this.h[4] = sum32(this.h[4], e);
  42641. this.h[5] = sum32(this.h[5], f);
  42642. this.h[6] = sum32(this.h[6], g);
  42643. this.h[7] = sum32(this.h[7], h);
  42644. };
  42645. SHA256.prototype._digest = function digest(enc) {
  42646. if (enc === 'hex')
  42647. return utils.toHex32(this.h, 'big');
  42648. else
  42649. return utils.split32(this.h, 'big');
  42650. };
  42651. /***/ }),
  42652. /***/ "./node_modules/hash.js/lib/hash/sha/384.js":
  42653. /*!**************************************************!*\
  42654. !*** ./node_modules/hash.js/lib/hash/sha/384.js ***!
  42655. \**************************************************/
  42656. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42657. "use strict";
  42658. var utils = __webpack_require__(/*! ../utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42659. var SHA512 = __webpack_require__(/*! ./512 */ "./node_modules/hash.js/lib/hash/sha/512.js");
  42660. function SHA384() {
  42661. if (!(this instanceof SHA384))
  42662. return new SHA384();
  42663. SHA512.call(this);
  42664. this.h = [
  42665. 0xcbbb9d5d, 0xc1059ed8,
  42666. 0x629a292a, 0x367cd507,
  42667. 0x9159015a, 0x3070dd17,
  42668. 0x152fecd8, 0xf70e5939,
  42669. 0x67332667, 0xffc00b31,
  42670. 0x8eb44a87, 0x68581511,
  42671. 0xdb0c2e0d, 0x64f98fa7,
  42672. 0x47b5481d, 0xbefa4fa4 ];
  42673. }
  42674. utils.inherits(SHA384, SHA512);
  42675. module.exports = SHA384;
  42676. SHA384.blockSize = 1024;
  42677. SHA384.outSize = 384;
  42678. SHA384.hmacStrength = 192;
  42679. SHA384.padLength = 128;
  42680. SHA384.prototype._digest = function digest(enc) {
  42681. if (enc === 'hex')
  42682. return utils.toHex32(this.h.slice(0, 12), 'big');
  42683. else
  42684. return utils.split32(this.h.slice(0, 12), 'big');
  42685. };
  42686. /***/ }),
  42687. /***/ "./node_modules/hash.js/lib/hash/sha/512.js":
  42688. /*!**************************************************!*\
  42689. !*** ./node_modules/hash.js/lib/hash/sha/512.js ***!
  42690. \**************************************************/
  42691. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  42692. "use strict";
  42693. var utils = __webpack_require__(/*! ../utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42694. var common = __webpack_require__(/*! ../common */ "./node_modules/hash.js/lib/hash/common.js");
  42695. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  42696. var rotr64_hi = utils.rotr64_hi;
  42697. var rotr64_lo = utils.rotr64_lo;
  42698. var shr64_hi = utils.shr64_hi;
  42699. var shr64_lo = utils.shr64_lo;
  42700. var sum64 = utils.sum64;
  42701. var sum64_hi = utils.sum64_hi;
  42702. var sum64_lo = utils.sum64_lo;
  42703. var sum64_4_hi = utils.sum64_4_hi;
  42704. var sum64_4_lo = utils.sum64_4_lo;
  42705. var sum64_5_hi = utils.sum64_5_hi;
  42706. var sum64_5_lo = utils.sum64_5_lo;
  42707. var BlockHash = common.BlockHash;
  42708. var sha512_K = [
  42709. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  42710. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  42711. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  42712. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  42713. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  42714. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  42715. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  42716. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  42717. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  42718. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  42719. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  42720. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  42721. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  42722. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  42723. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  42724. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  42725. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  42726. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  42727. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  42728. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  42729. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  42730. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  42731. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  42732. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  42733. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  42734. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  42735. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  42736. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  42737. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  42738. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  42739. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  42740. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  42741. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  42742. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  42743. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  42744. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  42745. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  42746. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  42747. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  42748. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  42749. ];
  42750. function SHA512() {
  42751. if (!(this instanceof SHA512))
  42752. return new SHA512();
  42753. BlockHash.call(this);
  42754. this.h = [
  42755. 0x6a09e667, 0xf3bcc908,
  42756. 0xbb67ae85, 0x84caa73b,
  42757. 0x3c6ef372, 0xfe94f82b,
  42758. 0xa54ff53a, 0x5f1d36f1,
  42759. 0x510e527f, 0xade682d1,
  42760. 0x9b05688c, 0x2b3e6c1f,
  42761. 0x1f83d9ab, 0xfb41bd6b,
  42762. 0x5be0cd19, 0x137e2179 ];
  42763. this.k = sha512_K;
  42764. this.W = new Array(160);
  42765. }
  42766. utils.inherits(SHA512, BlockHash);
  42767. module.exports = SHA512;
  42768. SHA512.blockSize = 1024;
  42769. SHA512.outSize = 512;
  42770. SHA512.hmacStrength = 192;
  42771. SHA512.padLength = 128;
  42772. SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
  42773. var W = this.W;
  42774. // 32 x 32bit words
  42775. for (var i = 0; i < 32; i++)
  42776. W[i] = msg[start + i];
  42777. for (; i < W.length; i += 2) {
  42778. var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
  42779. var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
  42780. var c1_hi = W[i - 14]; // i - 7
  42781. var c1_lo = W[i - 13];
  42782. var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
  42783. var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
  42784. var c3_hi = W[i - 32]; // i - 16
  42785. var c3_lo = W[i - 31];
  42786. W[i] = sum64_4_hi(
  42787. c0_hi, c0_lo,
  42788. c1_hi, c1_lo,
  42789. c2_hi, c2_lo,
  42790. c3_hi, c3_lo);
  42791. W[i + 1] = sum64_4_lo(
  42792. c0_hi, c0_lo,
  42793. c1_hi, c1_lo,
  42794. c2_hi, c2_lo,
  42795. c3_hi, c3_lo);
  42796. }
  42797. };
  42798. SHA512.prototype._update = function _update(msg, start) {
  42799. this._prepareBlock(msg, start);
  42800. var W = this.W;
  42801. var ah = this.h[0];
  42802. var al = this.h[1];
  42803. var bh = this.h[2];
  42804. var bl = this.h[3];
  42805. var ch = this.h[4];
  42806. var cl = this.h[5];
  42807. var dh = this.h[6];
  42808. var dl = this.h[7];
  42809. var eh = this.h[8];
  42810. var el = this.h[9];
  42811. var fh = this.h[10];
  42812. var fl = this.h[11];
  42813. var gh = this.h[12];
  42814. var gl = this.h[13];
  42815. var hh = this.h[14];
  42816. var hl = this.h[15];
  42817. assert(this.k.length === W.length);
  42818. for (var i = 0; i < W.length; i += 2) {
  42819. var c0_hi = hh;
  42820. var c0_lo = hl;
  42821. var c1_hi = s1_512_hi(eh, el);
  42822. var c1_lo = s1_512_lo(eh, el);
  42823. var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
  42824. var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
  42825. var c3_hi = this.k[i];
  42826. var c3_lo = this.k[i + 1];
  42827. var c4_hi = W[i];
  42828. var c4_lo = W[i + 1];
  42829. var T1_hi = sum64_5_hi(
  42830. c0_hi, c0_lo,
  42831. c1_hi, c1_lo,
  42832. c2_hi, c2_lo,
  42833. c3_hi, c3_lo,
  42834. c4_hi, c4_lo);
  42835. var T1_lo = sum64_5_lo(
  42836. c0_hi, c0_lo,
  42837. c1_hi, c1_lo,
  42838. c2_hi, c2_lo,
  42839. c3_hi, c3_lo,
  42840. c4_hi, c4_lo);
  42841. c0_hi = s0_512_hi(ah, al);
  42842. c0_lo = s0_512_lo(ah, al);
  42843. c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
  42844. c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
  42845. var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
  42846. var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
  42847. hh = gh;
  42848. hl = gl;
  42849. gh = fh;
  42850. gl = fl;
  42851. fh = eh;
  42852. fl = el;
  42853. eh = sum64_hi(dh, dl, T1_hi, T1_lo);
  42854. el = sum64_lo(dl, dl, T1_hi, T1_lo);
  42855. dh = ch;
  42856. dl = cl;
  42857. ch = bh;
  42858. cl = bl;
  42859. bh = ah;
  42860. bl = al;
  42861. ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
  42862. al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
  42863. }
  42864. sum64(this.h, 0, ah, al);
  42865. sum64(this.h, 2, bh, bl);
  42866. sum64(this.h, 4, ch, cl);
  42867. sum64(this.h, 6, dh, dl);
  42868. sum64(this.h, 8, eh, el);
  42869. sum64(this.h, 10, fh, fl);
  42870. sum64(this.h, 12, gh, gl);
  42871. sum64(this.h, 14, hh, hl);
  42872. };
  42873. SHA512.prototype._digest = function digest(enc) {
  42874. if (enc === 'hex')
  42875. return utils.toHex32(this.h, 'big');
  42876. else
  42877. return utils.split32(this.h, 'big');
  42878. };
  42879. function ch64_hi(xh, xl, yh, yl, zh) {
  42880. var r = (xh & yh) ^ ((~xh) & zh);
  42881. if (r < 0)
  42882. r += 0x100000000;
  42883. return r;
  42884. }
  42885. function ch64_lo(xh, xl, yh, yl, zh, zl) {
  42886. var r = (xl & yl) ^ ((~xl) & zl);
  42887. if (r < 0)
  42888. r += 0x100000000;
  42889. return r;
  42890. }
  42891. function maj64_hi(xh, xl, yh, yl, zh) {
  42892. var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
  42893. if (r < 0)
  42894. r += 0x100000000;
  42895. return r;
  42896. }
  42897. function maj64_lo(xh, xl, yh, yl, zh, zl) {
  42898. var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
  42899. if (r < 0)
  42900. r += 0x100000000;
  42901. return r;
  42902. }
  42903. function s0_512_hi(xh, xl) {
  42904. var c0_hi = rotr64_hi(xh, xl, 28);
  42905. var c1_hi = rotr64_hi(xl, xh, 2); // 34
  42906. var c2_hi = rotr64_hi(xl, xh, 7); // 39
  42907. var r = c0_hi ^ c1_hi ^ c2_hi;
  42908. if (r < 0)
  42909. r += 0x100000000;
  42910. return r;
  42911. }
  42912. function s0_512_lo(xh, xl) {
  42913. var c0_lo = rotr64_lo(xh, xl, 28);
  42914. var c1_lo = rotr64_lo(xl, xh, 2); // 34
  42915. var c2_lo = rotr64_lo(xl, xh, 7); // 39
  42916. var r = c0_lo ^ c1_lo ^ c2_lo;
  42917. if (r < 0)
  42918. r += 0x100000000;
  42919. return r;
  42920. }
  42921. function s1_512_hi(xh, xl) {
  42922. var c0_hi = rotr64_hi(xh, xl, 14);
  42923. var c1_hi = rotr64_hi(xh, xl, 18);
  42924. var c2_hi = rotr64_hi(xl, xh, 9); // 41
  42925. var r = c0_hi ^ c1_hi ^ c2_hi;
  42926. if (r < 0)
  42927. r += 0x100000000;
  42928. return r;
  42929. }
  42930. function s1_512_lo(xh, xl) {
  42931. var c0_lo = rotr64_lo(xh, xl, 14);
  42932. var c1_lo = rotr64_lo(xh, xl, 18);
  42933. var c2_lo = rotr64_lo(xl, xh, 9); // 41
  42934. var r = c0_lo ^ c1_lo ^ c2_lo;
  42935. if (r < 0)
  42936. r += 0x100000000;
  42937. return r;
  42938. }
  42939. function g0_512_hi(xh, xl) {
  42940. var c0_hi = rotr64_hi(xh, xl, 1);
  42941. var c1_hi = rotr64_hi(xh, xl, 8);
  42942. var c2_hi = shr64_hi(xh, xl, 7);
  42943. var r = c0_hi ^ c1_hi ^ c2_hi;
  42944. if (r < 0)
  42945. r += 0x100000000;
  42946. return r;
  42947. }
  42948. function g0_512_lo(xh, xl) {
  42949. var c0_lo = rotr64_lo(xh, xl, 1);
  42950. var c1_lo = rotr64_lo(xh, xl, 8);
  42951. var c2_lo = shr64_lo(xh, xl, 7);
  42952. var r = c0_lo ^ c1_lo ^ c2_lo;
  42953. if (r < 0)
  42954. r += 0x100000000;
  42955. return r;
  42956. }
  42957. function g1_512_hi(xh, xl) {
  42958. var c0_hi = rotr64_hi(xh, xl, 19);
  42959. var c1_hi = rotr64_hi(xl, xh, 29); // 61
  42960. var c2_hi = shr64_hi(xh, xl, 6);
  42961. var r = c0_hi ^ c1_hi ^ c2_hi;
  42962. if (r < 0)
  42963. r += 0x100000000;
  42964. return r;
  42965. }
  42966. function g1_512_lo(xh, xl) {
  42967. var c0_lo = rotr64_lo(xh, xl, 19);
  42968. var c1_lo = rotr64_lo(xl, xh, 29); // 61
  42969. var c2_lo = shr64_lo(xh, xl, 6);
  42970. var r = c0_lo ^ c1_lo ^ c2_lo;
  42971. if (r < 0)
  42972. r += 0x100000000;
  42973. return r;
  42974. }
  42975. /***/ }),
  42976. /***/ "./node_modules/hash.js/lib/hash/sha/common.js":
  42977. /*!*****************************************************!*\
  42978. !*** ./node_modules/hash.js/lib/hash/sha/common.js ***!
  42979. \*****************************************************/
  42980. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  42981. "use strict";
  42982. var utils = __webpack_require__(/*! ../utils */ "./node_modules/hash.js/lib/hash/utils.js");
  42983. var rotr32 = utils.rotr32;
  42984. function ft_1(s, x, y, z) {
  42985. if (s === 0)
  42986. return ch32(x, y, z);
  42987. if (s === 1 || s === 3)
  42988. return p32(x, y, z);
  42989. if (s === 2)
  42990. return maj32(x, y, z);
  42991. }
  42992. exports.ft_1 = ft_1;
  42993. function ch32(x, y, z) {
  42994. return (x & y) ^ ((~x) & z);
  42995. }
  42996. exports.ch32 = ch32;
  42997. function maj32(x, y, z) {
  42998. return (x & y) ^ (x & z) ^ (y & z);
  42999. }
  43000. exports.maj32 = maj32;
  43001. function p32(x, y, z) {
  43002. return x ^ y ^ z;
  43003. }
  43004. exports.p32 = p32;
  43005. function s0_256(x) {
  43006. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  43007. }
  43008. exports.s0_256 = s0_256;
  43009. function s1_256(x) {
  43010. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  43011. }
  43012. exports.s1_256 = s1_256;
  43013. function g0_256(x) {
  43014. return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
  43015. }
  43016. exports.g0_256 = g0_256;
  43017. function g1_256(x) {
  43018. return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
  43019. }
  43020. exports.g1_256 = g1_256;
  43021. /***/ }),
  43022. /***/ "./node_modules/hash.js/lib/hash/utils.js":
  43023. /*!************************************************!*\
  43024. !*** ./node_modules/hash.js/lib/hash/utils.js ***!
  43025. \************************************************/
  43026. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  43027. "use strict";
  43028. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  43029. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  43030. exports.inherits = inherits;
  43031. function isSurrogatePair(msg, i) {
  43032. if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
  43033. return false;
  43034. }
  43035. if (i < 0 || i + 1 >= msg.length) {
  43036. return false;
  43037. }
  43038. return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
  43039. }
  43040. function toArray(msg, enc) {
  43041. if (Array.isArray(msg))
  43042. return msg.slice();
  43043. if (!msg)
  43044. return [];
  43045. var res = [];
  43046. if (typeof msg === 'string') {
  43047. if (!enc) {
  43048. // Inspired by stringToUtf8ByteArray() in closure-library by Google
  43049. // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
  43050. // Apache License 2.0
  43051. // https://github.com/google/closure-library/blob/master/LICENSE
  43052. var p = 0;
  43053. for (var i = 0; i < msg.length; i++) {
  43054. var c = msg.charCodeAt(i);
  43055. if (c < 128) {
  43056. res[p++] = c;
  43057. } else if (c < 2048) {
  43058. res[p++] = (c >> 6) | 192;
  43059. res[p++] = (c & 63) | 128;
  43060. } else if (isSurrogatePair(msg, i)) {
  43061. c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
  43062. res[p++] = (c >> 18) | 240;
  43063. res[p++] = ((c >> 12) & 63) | 128;
  43064. res[p++] = ((c >> 6) & 63) | 128;
  43065. res[p++] = (c & 63) | 128;
  43066. } else {
  43067. res[p++] = (c >> 12) | 224;
  43068. res[p++] = ((c >> 6) & 63) | 128;
  43069. res[p++] = (c & 63) | 128;
  43070. }
  43071. }
  43072. } else if (enc === 'hex') {
  43073. msg = msg.replace(/[^a-z0-9]+/ig, '');
  43074. if (msg.length % 2 !== 0)
  43075. msg = '0' + msg;
  43076. for (i = 0; i < msg.length; i += 2)
  43077. res.push(parseInt(msg[i] + msg[i + 1], 16));
  43078. }
  43079. } else {
  43080. for (i = 0; i < msg.length; i++)
  43081. res[i] = msg[i] | 0;
  43082. }
  43083. return res;
  43084. }
  43085. exports.toArray = toArray;
  43086. function toHex(msg) {
  43087. var res = '';
  43088. for (var i = 0; i < msg.length; i++)
  43089. res += zero2(msg[i].toString(16));
  43090. return res;
  43091. }
  43092. exports.toHex = toHex;
  43093. function htonl(w) {
  43094. var res = (w >>> 24) |
  43095. ((w >>> 8) & 0xff00) |
  43096. ((w << 8) & 0xff0000) |
  43097. ((w & 0xff) << 24);
  43098. return res >>> 0;
  43099. }
  43100. exports.htonl = htonl;
  43101. function toHex32(msg, endian) {
  43102. var res = '';
  43103. for (var i = 0; i < msg.length; i++) {
  43104. var w = msg[i];
  43105. if (endian === 'little')
  43106. w = htonl(w);
  43107. res += zero8(w.toString(16));
  43108. }
  43109. return res;
  43110. }
  43111. exports.toHex32 = toHex32;
  43112. function zero2(word) {
  43113. if (word.length === 1)
  43114. return '0' + word;
  43115. else
  43116. return word;
  43117. }
  43118. exports.zero2 = zero2;
  43119. function zero8(word) {
  43120. if (word.length === 7)
  43121. return '0' + word;
  43122. else if (word.length === 6)
  43123. return '00' + word;
  43124. else if (word.length === 5)
  43125. return '000' + word;
  43126. else if (word.length === 4)
  43127. return '0000' + word;
  43128. else if (word.length === 3)
  43129. return '00000' + word;
  43130. else if (word.length === 2)
  43131. return '000000' + word;
  43132. else if (word.length === 1)
  43133. return '0000000' + word;
  43134. else
  43135. return word;
  43136. }
  43137. exports.zero8 = zero8;
  43138. function join32(msg, start, end, endian) {
  43139. var len = end - start;
  43140. assert(len % 4 === 0);
  43141. var res = new Array(len / 4);
  43142. for (var i = 0, k = start; i < res.length; i++, k += 4) {
  43143. var w;
  43144. if (endian === 'big')
  43145. w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
  43146. else
  43147. w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
  43148. res[i] = w >>> 0;
  43149. }
  43150. return res;
  43151. }
  43152. exports.join32 = join32;
  43153. function split32(msg, endian) {
  43154. var res = new Array(msg.length * 4);
  43155. for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
  43156. var m = msg[i];
  43157. if (endian === 'big') {
  43158. res[k] = m >>> 24;
  43159. res[k + 1] = (m >>> 16) & 0xff;
  43160. res[k + 2] = (m >>> 8) & 0xff;
  43161. res[k + 3] = m & 0xff;
  43162. } else {
  43163. res[k + 3] = m >>> 24;
  43164. res[k + 2] = (m >>> 16) & 0xff;
  43165. res[k + 1] = (m >>> 8) & 0xff;
  43166. res[k] = m & 0xff;
  43167. }
  43168. }
  43169. return res;
  43170. }
  43171. exports.split32 = split32;
  43172. function rotr32(w, b) {
  43173. return (w >>> b) | (w << (32 - b));
  43174. }
  43175. exports.rotr32 = rotr32;
  43176. function rotl32(w, b) {
  43177. return (w << b) | (w >>> (32 - b));
  43178. }
  43179. exports.rotl32 = rotl32;
  43180. function sum32(a, b) {
  43181. return (a + b) >>> 0;
  43182. }
  43183. exports.sum32 = sum32;
  43184. function sum32_3(a, b, c) {
  43185. return (a + b + c) >>> 0;
  43186. }
  43187. exports.sum32_3 = sum32_3;
  43188. function sum32_4(a, b, c, d) {
  43189. return (a + b + c + d) >>> 0;
  43190. }
  43191. exports.sum32_4 = sum32_4;
  43192. function sum32_5(a, b, c, d, e) {
  43193. return (a + b + c + d + e) >>> 0;
  43194. }
  43195. exports.sum32_5 = sum32_5;
  43196. function sum64(buf, pos, ah, al) {
  43197. var bh = buf[pos];
  43198. var bl = buf[pos + 1];
  43199. var lo = (al + bl) >>> 0;
  43200. var hi = (lo < al ? 1 : 0) + ah + bh;
  43201. buf[pos] = hi >>> 0;
  43202. buf[pos + 1] = lo;
  43203. }
  43204. exports.sum64 = sum64;
  43205. function sum64_hi(ah, al, bh, bl) {
  43206. var lo = (al + bl) >>> 0;
  43207. var hi = (lo < al ? 1 : 0) + ah + bh;
  43208. return hi >>> 0;
  43209. }
  43210. exports.sum64_hi = sum64_hi;
  43211. function sum64_lo(ah, al, bh, bl) {
  43212. var lo = al + bl;
  43213. return lo >>> 0;
  43214. }
  43215. exports.sum64_lo = sum64_lo;
  43216. function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
  43217. var carry = 0;
  43218. var lo = al;
  43219. lo = (lo + bl) >>> 0;
  43220. carry += lo < al ? 1 : 0;
  43221. lo = (lo + cl) >>> 0;
  43222. carry += lo < cl ? 1 : 0;
  43223. lo = (lo + dl) >>> 0;
  43224. carry += lo < dl ? 1 : 0;
  43225. var hi = ah + bh + ch + dh + carry;
  43226. return hi >>> 0;
  43227. }
  43228. exports.sum64_4_hi = sum64_4_hi;
  43229. function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
  43230. var lo = al + bl + cl + dl;
  43231. return lo >>> 0;
  43232. }
  43233. exports.sum64_4_lo = sum64_4_lo;
  43234. function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  43235. var carry = 0;
  43236. var lo = al;
  43237. lo = (lo + bl) >>> 0;
  43238. carry += lo < al ? 1 : 0;
  43239. lo = (lo + cl) >>> 0;
  43240. carry += lo < cl ? 1 : 0;
  43241. lo = (lo + dl) >>> 0;
  43242. carry += lo < dl ? 1 : 0;
  43243. lo = (lo + el) >>> 0;
  43244. carry += lo < el ? 1 : 0;
  43245. var hi = ah + bh + ch + dh + eh + carry;
  43246. return hi >>> 0;
  43247. }
  43248. exports.sum64_5_hi = sum64_5_hi;
  43249. function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  43250. var lo = al + bl + cl + dl + el;
  43251. return lo >>> 0;
  43252. }
  43253. exports.sum64_5_lo = sum64_5_lo;
  43254. function rotr64_hi(ah, al, num) {
  43255. var r = (al << (32 - num)) | (ah >>> num);
  43256. return r >>> 0;
  43257. }
  43258. exports.rotr64_hi = rotr64_hi;
  43259. function rotr64_lo(ah, al, num) {
  43260. var r = (ah << (32 - num)) | (al >>> num);
  43261. return r >>> 0;
  43262. }
  43263. exports.rotr64_lo = rotr64_lo;
  43264. function shr64_hi(ah, al, num) {
  43265. return ah >>> num;
  43266. }
  43267. exports.shr64_hi = shr64_hi;
  43268. function shr64_lo(ah, al, num) {
  43269. var r = (ah << (32 - num)) | (al >>> num);
  43270. return r >>> 0;
  43271. }
  43272. exports.shr64_lo = shr64_lo;
  43273. /***/ }),
  43274. /***/ "./node_modules/hmac-drbg/lib/hmac-drbg.js":
  43275. /*!*************************************************!*\
  43276. !*** ./node_modules/hmac-drbg/lib/hmac-drbg.js ***!
  43277. \*************************************************/
  43278. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  43279. "use strict";
  43280. var hash = __webpack_require__(/*! hash.js */ "./node_modules/hash.js/lib/hash.js");
  43281. var utils = __webpack_require__(/*! minimalistic-crypto-utils */ "./node_modules/minimalistic-crypto-utils/lib/utils.js");
  43282. var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
  43283. function HmacDRBG(options) {
  43284. if (!(this instanceof HmacDRBG))
  43285. return new HmacDRBG(options);
  43286. this.hash = options.hash;
  43287. this.predResist = !!options.predResist;
  43288. this.outLen = this.hash.outSize;
  43289. this.minEntropy = options.minEntropy || this.hash.hmacStrength;
  43290. this._reseed = null;
  43291. this.reseedInterval = null;
  43292. this.K = null;
  43293. this.V = null;
  43294. var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
  43295. var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
  43296. var pers = utils.toArray(options.pers, options.persEnc || 'hex');
  43297. assert(entropy.length >= (this.minEntropy / 8),
  43298. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  43299. this._init(entropy, nonce, pers);
  43300. }
  43301. module.exports = HmacDRBG;
  43302. HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
  43303. var seed = entropy.concat(nonce).concat(pers);
  43304. this.K = new Array(this.outLen / 8);
  43305. this.V = new Array(this.outLen / 8);
  43306. for (var i = 0; i < this.V.length; i++) {
  43307. this.K[i] = 0x00;
  43308. this.V[i] = 0x01;
  43309. }
  43310. this._update(seed);
  43311. this._reseed = 1;
  43312. this.reseedInterval = 0x1000000000000; // 2^48
  43313. };
  43314. HmacDRBG.prototype._hmac = function hmac() {
  43315. return new hash.hmac(this.hash, this.K);
  43316. };
  43317. HmacDRBG.prototype._update = function update(seed) {
  43318. var kmac = this._hmac()
  43319. .update(this.V)
  43320. .update([ 0x00 ]);
  43321. if (seed)
  43322. kmac = kmac.update(seed);
  43323. this.K = kmac.digest();
  43324. this.V = this._hmac().update(this.V).digest();
  43325. if (!seed)
  43326. return;
  43327. this.K = this._hmac()
  43328. .update(this.V)
  43329. .update([ 0x01 ])
  43330. .update(seed)
  43331. .digest();
  43332. this.V = this._hmac().update(this.V).digest();
  43333. };
  43334. HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
  43335. // Optional entropy enc
  43336. if (typeof entropyEnc !== 'string') {
  43337. addEnc = add;
  43338. add = entropyEnc;
  43339. entropyEnc = null;
  43340. }
  43341. entropy = utils.toArray(entropy, entropyEnc);
  43342. add = utils.toArray(add, addEnc);
  43343. assert(entropy.length >= (this.minEntropy / 8),
  43344. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  43345. this._update(entropy.concat(add || []));
  43346. this._reseed = 1;
  43347. };
  43348. HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
  43349. if (this._reseed > this.reseedInterval)
  43350. throw new Error('Reseed is required');
  43351. // Optional encoding
  43352. if (typeof enc !== 'string') {
  43353. addEnc = add;
  43354. add = enc;
  43355. enc = null;
  43356. }
  43357. // Optional additional data
  43358. if (add) {
  43359. add = utils.toArray(add, addEnc || 'hex');
  43360. this._update(add);
  43361. }
  43362. var temp = [];
  43363. while (temp.length < len) {
  43364. this.V = this._hmac().update(this.V).digest();
  43365. temp = temp.concat(this.V);
  43366. }
  43367. var res = temp.slice(0, len);
  43368. this._update(add);
  43369. this._reseed++;
  43370. return utils.encode(res, enc);
  43371. };
  43372. /***/ }),
  43373. /***/ "./node_modules/ieee754/index.js":
  43374. /*!***************************************!*\
  43375. !*** ./node_modules/ieee754/index.js ***!
  43376. \***************************************/
  43377. /***/ ((__unused_webpack_module, exports) => {
  43378. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  43379. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  43380. var e, m
  43381. var eLen = (nBytes * 8) - mLen - 1
  43382. var eMax = (1 << eLen) - 1
  43383. var eBias = eMax >> 1
  43384. var nBits = -7
  43385. var i = isLE ? (nBytes - 1) : 0
  43386. var d = isLE ? -1 : 1
  43387. var s = buffer[offset + i]
  43388. i += d
  43389. e = s & ((1 << (-nBits)) - 1)
  43390. s >>= (-nBits)
  43391. nBits += eLen
  43392. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  43393. m = e & ((1 << (-nBits)) - 1)
  43394. e >>= (-nBits)
  43395. nBits += mLen
  43396. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  43397. if (e === 0) {
  43398. e = 1 - eBias
  43399. } else if (e === eMax) {
  43400. return m ? NaN : ((s ? -1 : 1) * Infinity)
  43401. } else {
  43402. m = m + Math.pow(2, mLen)
  43403. e = e - eBias
  43404. }
  43405. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  43406. }
  43407. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  43408. var e, m, c
  43409. var eLen = (nBytes * 8) - mLen - 1
  43410. var eMax = (1 << eLen) - 1
  43411. var eBias = eMax >> 1
  43412. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  43413. var i = isLE ? 0 : (nBytes - 1)
  43414. var d = isLE ? 1 : -1
  43415. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  43416. value = Math.abs(value)
  43417. if (isNaN(value) || value === Infinity) {
  43418. m = isNaN(value) ? 1 : 0
  43419. e = eMax
  43420. } else {
  43421. e = Math.floor(Math.log(value) / Math.LN2)
  43422. if (value * (c = Math.pow(2, -e)) < 1) {
  43423. e--
  43424. c *= 2
  43425. }
  43426. if (e + eBias >= 1) {
  43427. value += rt / c
  43428. } else {
  43429. value += rt * Math.pow(2, 1 - eBias)
  43430. }
  43431. if (value * c >= 2) {
  43432. e++
  43433. c /= 2
  43434. }
  43435. if (e + eBias >= eMax) {
  43436. m = 0
  43437. e = eMax
  43438. } else if (e + eBias >= 1) {
  43439. m = ((value * c) - 1) * Math.pow(2, mLen)
  43440. e = e + eBias
  43441. } else {
  43442. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  43443. e = 0
  43444. }
  43445. }
  43446. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  43447. e = (e << mLen) | m
  43448. eLen += mLen
  43449. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  43450. buffer[offset + i - d] |= s * 128
  43451. }
  43452. /***/ }),
  43453. /***/ "./node_modules/inherits/inherits_browser.js":
  43454. /*!***************************************************!*\
  43455. !*** ./node_modules/inherits/inherits_browser.js ***!
  43456. \***************************************************/
  43457. /***/ ((module) => {
  43458. if (typeof Object.create === 'function') {
  43459. // implementation from standard node.js 'util' module
  43460. module.exports = function inherits(ctor, superCtor) {
  43461. if (superCtor) {
  43462. ctor.super_ = superCtor
  43463. ctor.prototype = Object.create(superCtor.prototype, {
  43464. constructor: {
  43465. value: ctor,
  43466. enumerable: false,
  43467. writable: true,
  43468. configurable: true
  43469. }
  43470. })
  43471. }
  43472. };
  43473. } else {
  43474. // old school shim for old browsers
  43475. module.exports = function inherits(ctor, superCtor) {
  43476. if (superCtor) {
  43477. ctor.super_ = superCtor
  43478. var TempCtor = function () {}
  43479. TempCtor.prototype = superCtor.prototype
  43480. ctor.prototype = new TempCtor()
  43481. ctor.prototype.constructor = ctor
  43482. }
  43483. }
  43484. }
  43485. /***/ }),
  43486. /***/ "./node_modules/isarray/index.js":
  43487. /*!***************************************!*\
  43488. !*** ./node_modules/isarray/index.js ***!
  43489. \***************************************/
  43490. /***/ ((module) => {
  43491. var toString = {}.toString;
  43492. module.exports = Array.isArray || function (arr) {
  43493. return toString.call(arr) == '[object Array]';
  43494. };
  43495. /***/ }),
  43496. /***/ "./node_modules/izitoast/dist/js/iziToast.js":
  43497. /*!***************************************************!*\
  43498. !*** ./node_modules/izitoast/dist/js/iziToast.js ***!
  43499. \***************************************************/
  43500. /***/ (function(module, exports, __webpack_require__) {
  43501. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  43502. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*
  43503. * iziToast | v1.4.0
  43504. * http://izitoast.marcelodolce.com
  43505. * by Marcelo Dolce.
  43506. */
  43507. (function (root, factory) {
  43508. if(true) {
  43509. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory(root)),
  43510. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  43511. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  43512. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  43513. } else {}
  43514. })(typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : window || this.window || this.global, function (root) {
  43515. 'use strict';
  43516. //
  43517. // Variables
  43518. //
  43519. var $iziToast = {},
  43520. PLUGIN_NAME = 'iziToast',
  43521. BODY = document.querySelector('body'),
  43522. ISMOBILE = (/Mobi/.test(navigator.userAgent)) ? true : false,
  43523. ISCHROME = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor),
  43524. ISFIREFOX = typeof InstallTrigger !== 'undefined',
  43525. ACCEPTSTOUCH = 'ontouchstart' in document.documentElement,
  43526. POSITIONS = ['bottomRight','bottomLeft','bottomCenter','topRight','topLeft','topCenter','center'],
  43527. THEMES = {
  43528. info: {
  43529. color: 'blue',
  43530. icon: 'ico-info'
  43531. },
  43532. success: {
  43533. color: 'green',
  43534. icon: 'ico-success'
  43535. },
  43536. warning: {
  43537. color: 'orange',
  43538. icon: 'ico-warning'
  43539. },
  43540. error: {
  43541. color: 'red',
  43542. icon: 'ico-error'
  43543. },
  43544. question: {
  43545. color: 'yellow',
  43546. icon: 'ico-question'
  43547. }
  43548. },
  43549. MOBILEWIDTH = 568,
  43550. CONFIG = {};
  43551. $iziToast.children = {};
  43552. // Default settings
  43553. var defaults = {
  43554. id: null,
  43555. class: '',
  43556. title: '',
  43557. titleColor: '',
  43558. titleSize: '',
  43559. titleLineHeight: '',
  43560. message: '',
  43561. messageColor: '',
  43562. messageSize: '',
  43563. messageLineHeight: '',
  43564. backgroundColor: '',
  43565. theme: 'light', // dark
  43566. color: '', // blue, red, green, yellow
  43567. icon: '',
  43568. iconText: '',
  43569. iconColor: '',
  43570. iconUrl: null,
  43571. image: '',
  43572. imageWidth: 50,
  43573. maxWidth: null,
  43574. zindex: null,
  43575. layout: 1,
  43576. balloon: false,
  43577. close: true,
  43578. closeOnEscape: false,
  43579. closeOnClick: false,
  43580. displayMode: 0,
  43581. position: 'bottomRight', // bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter, center
  43582. target: '',
  43583. targetFirst: true,
  43584. timeout: 5000,
  43585. rtl: false,
  43586. animateInside: true,
  43587. drag: true,
  43588. pauseOnHover: true,
  43589. resetOnHover: false,
  43590. progressBar: true,
  43591. progressBarColor: '',
  43592. progressBarEasing: 'linear',
  43593. overlay: false,
  43594. overlayClose: false,
  43595. overlayColor: 'rgba(0, 0, 0, 0.6)',
  43596. transitionIn: 'fadeInUp', // bounceInLeft, bounceInRight, bounceInUp, bounceInDown, fadeIn, fadeInDown, fadeInUp, fadeInLeft, fadeInRight, flipInX
  43597. transitionOut: 'fadeOut', // fadeOut, fadeOutUp, fadeOutDown, fadeOutLeft, fadeOutRight, flipOutX
  43598. transitionInMobile: 'fadeInUp',
  43599. transitionOutMobile: 'fadeOutDown',
  43600. buttons: {},
  43601. inputs: {},
  43602. onOpening: function () {},
  43603. onOpened: function () {},
  43604. onClosing: function () {},
  43605. onClosed: function () {}
  43606. };
  43607. //
  43608. // Methods
  43609. //
  43610. /**
  43611. * Polyfill for remove() method
  43612. */
  43613. if(!('remove' in Element.prototype)) {
  43614. Element.prototype.remove = function() {
  43615. if(this.parentNode) {
  43616. this.parentNode.removeChild(this);
  43617. }
  43618. };
  43619. }
  43620. /*
  43621. * Polyfill for CustomEvent for IE >= 9
  43622. * https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
  43623. */
  43624. if(typeof window.CustomEvent !== 'function') {
  43625. var CustomEventPolyfill = function (event, params) {
  43626. params = params || { bubbles: false, cancelable: false, detail: undefined };
  43627. var evt = document.createEvent('CustomEvent');
  43628. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  43629. return evt;
  43630. };
  43631. CustomEventPolyfill.prototype = window.Event.prototype;
  43632. window.CustomEvent = CustomEventPolyfill;
  43633. }
  43634. /**
  43635. * A simple forEach() implementation for Arrays, Objects and NodeLists
  43636. * @private
  43637. * @param {Array|Object|NodeList} collection Collection of items to iterate
  43638. * @param {Function} callback Callback function for each iteration
  43639. * @param {Array|Object|NodeList} scope Object/NodeList/Array that forEach is iterating over (aka `this`)
  43640. */
  43641. var forEach = function (collection, callback, scope) {
  43642. if(Object.prototype.toString.call(collection) === '[object Object]') {
  43643. for (var prop in collection) {
  43644. if(Object.prototype.hasOwnProperty.call(collection, prop)) {
  43645. callback.call(scope, collection[prop], prop, collection);
  43646. }
  43647. }
  43648. } else {
  43649. if(collection){
  43650. for (var i = 0, len = collection.length; i < len; i++) {
  43651. callback.call(scope, collection[i], i, collection);
  43652. }
  43653. }
  43654. }
  43655. };
  43656. /**
  43657. * Merge defaults with user options
  43658. * @private
  43659. * @param {Object} defaults Default settings
  43660. * @param {Object} options User options
  43661. * @returns {Object} Merged values of defaults and options
  43662. */
  43663. var extend = function (defaults, options) {
  43664. var extended = {};
  43665. forEach(defaults, function (value, prop) {
  43666. extended[prop] = defaults[prop];
  43667. });
  43668. forEach(options, function (value, prop) {
  43669. extended[prop] = options[prop];
  43670. });
  43671. return extended;
  43672. };
  43673. /**
  43674. * Create a fragment DOM elements
  43675. * @private
  43676. */
  43677. var createFragElem = function(htmlStr) {
  43678. var frag = document.createDocumentFragment(),
  43679. temp = document.createElement('div');
  43680. temp.innerHTML = htmlStr;
  43681. while (temp.firstChild) {
  43682. frag.appendChild(temp.firstChild);
  43683. }
  43684. return frag;
  43685. };
  43686. /**
  43687. * Generate new ID
  43688. * @private
  43689. */
  43690. var generateId = function(params) {
  43691. var newId = btoa(encodeURIComponent(params));
  43692. return newId.replace(/=/g, "");
  43693. };
  43694. /**
  43695. * Check if is a color
  43696. * @private
  43697. */
  43698. var isColor = function(color){
  43699. if( color.substring(0,1) == '#' || color.substring(0,3) == 'rgb' || color.substring(0,3) == 'hsl' ){
  43700. return true;
  43701. } else {
  43702. return false;
  43703. }
  43704. };
  43705. /**
  43706. * Check if is a Base64 string
  43707. * @private
  43708. */
  43709. var isBase64 = function(str) {
  43710. try {
  43711. return btoa(atob(str)) == str;
  43712. } catch (err) {
  43713. return false;
  43714. }
  43715. };
  43716. /**
  43717. * Drag method of toasts
  43718. * @private
  43719. */
  43720. var drag = function() {
  43721. return {
  43722. move: function(toast, instance, settings, xpos) {
  43723. var opacity,
  43724. opacityRange = 0.3,
  43725. distance = 180;
  43726. if(xpos !== 0){
  43727. toast.classList.add(PLUGIN_NAME+'-dragged');
  43728. toast.style.transform = 'translateX('+xpos + 'px)';
  43729. if(xpos > 0){
  43730. opacity = (distance-xpos) / distance;
  43731. if(opacity < opacityRange){
  43732. instance.hide(extend(settings, { transitionOut: 'fadeOutRight', transitionOutMobile: 'fadeOutRight' }), toast, 'drag');
  43733. }
  43734. } else {
  43735. opacity = (distance+xpos) / distance;
  43736. if(opacity < opacityRange){
  43737. instance.hide(extend(settings, { transitionOut: 'fadeOutLeft', transitionOutMobile: 'fadeOutLeft' }), toast, 'drag');
  43738. }
  43739. }
  43740. toast.style.opacity = opacity;
  43741. if(opacity < opacityRange){
  43742. if(ISCHROME || ISFIREFOX)
  43743. toast.style.left = xpos+'px';
  43744. toast.parentNode.style.opacity = opacityRange;
  43745. this.stopMoving(toast, null);
  43746. }
  43747. }
  43748. },
  43749. startMoving: function(toast, instance, settings, e) {
  43750. e = e || window.event;
  43751. var posX = ((ACCEPTSTOUCH) ? e.touches[0].clientX : e.clientX),
  43752. toastLeft = toast.style.transform.replace('px)', '');
  43753. toastLeft = toastLeft.replace('translateX(', '');
  43754. var offsetX = posX - toastLeft;
  43755. if(settings.transitionIn){
  43756. toast.classList.remove(settings.transitionIn);
  43757. }
  43758. if(settings.transitionInMobile){
  43759. toast.classList.remove(settings.transitionInMobile);
  43760. }
  43761. toast.style.transition = '';
  43762. if(ACCEPTSTOUCH) {
  43763. document.ontouchmove = function(e) {
  43764. e.preventDefault();
  43765. e = e || window.event;
  43766. var posX = e.touches[0].clientX,
  43767. finalX = posX - offsetX;
  43768. drag.move(toast, instance, settings, finalX);
  43769. };
  43770. } else {
  43771. document.onmousemove = function(e) {
  43772. e.preventDefault();
  43773. e = e || window.event;
  43774. var posX = e.clientX,
  43775. finalX = posX - offsetX;
  43776. drag.move(toast, instance, settings, finalX);
  43777. };
  43778. }
  43779. },
  43780. stopMoving: function(toast, e) {
  43781. if(ACCEPTSTOUCH) {
  43782. document.ontouchmove = function() {};
  43783. } else {
  43784. document.onmousemove = function() {};
  43785. }
  43786. toast.style.opacity = '';
  43787. toast.style.transform = '';
  43788. if(toast.classList.contains(PLUGIN_NAME+'-dragged')){
  43789. toast.classList.remove(PLUGIN_NAME+'-dragged');
  43790. toast.style.transition = 'transform 0.4s ease, opacity 0.4s ease';
  43791. setTimeout(function() {
  43792. toast.style.transition = '';
  43793. }, 400);
  43794. }
  43795. }
  43796. };
  43797. }();
  43798. $iziToast.setSetting = function (ref, option, value) {
  43799. $iziToast.children[ref][option] = value;
  43800. };
  43801. $iziToast.getSetting = function (ref, option) {
  43802. return $iziToast.children[ref][option];
  43803. };
  43804. /**
  43805. * Destroy the current initialization.
  43806. * @public
  43807. */
  43808. $iziToast.destroy = function () {
  43809. forEach(document.querySelectorAll('.'+PLUGIN_NAME+'-overlay'), function(element, index) {
  43810. element.remove();
  43811. });
  43812. forEach(document.querySelectorAll('.'+PLUGIN_NAME+'-wrapper'), function(element, index) {
  43813. element.remove();
  43814. });
  43815. forEach(document.querySelectorAll('.'+PLUGIN_NAME), function(element, index) {
  43816. element.remove();
  43817. });
  43818. this.children = {};
  43819. // Remove event listeners
  43820. document.removeEventListener(PLUGIN_NAME+'-opened', {}, false);
  43821. document.removeEventListener(PLUGIN_NAME+'-opening', {}, false);
  43822. document.removeEventListener(PLUGIN_NAME+'-closing', {}, false);
  43823. document.removeEventListener(PLUGIN_NAME+'-closed', {}, false);
  43824. document.removeEventListener('keyup', {}, false);
  43825. // Reset variables
  43826. CONFIG = {};
  43827. };
  43828. /**
  43829. * Initialize Plugin
  43830. * @public
  43831. * @param {Object} options User settings
  43832. */
  43833. $iziToast.settings = function (options) {
  43834. // Destroy any existing initializations
  43835. $iziToast.destroy();
  43836. CONFIG = options;
  43837. defaults = extend(defaults, options || {});
  43838. };
  43839. /**
  43840. * Building themes functions.
  43841. * @public
  43842. * @param {Object} options User settings
  43843. */
  43844. forEach(THEMES, function (theme, name) {
  43845. $iziToast[name] = function (options) {
  43846. var settings = extend(CONFIG, options || {});
  43847. settings = extend(theme, settings || {});
  43848. this.show(settings);
  43849. };
  43850. });
  43851. /**
  43852. * Do the calculation to move the progress bar
  43853. * @private
  43854. */
  43855. $iziToast.progress = function (options, $toast, callback) {
  43856. var that = this,
  43857. ref = $toast.getAttribute('data-iziToast-ref'),
  43858. settings = extend(this.children[ref], options || {}),
  43859. $elem = $toast.querySelector('.'+PLUGIN_NAME+'-progressbar div');
  43860. return {
  43861. start: function() {
  43862. if(typeof settings.time.REMAINING == 'undefined'){
  43863. $toast.classList.remove(PLUGIN_NAME+'-reseted');
  43864. if($elem !== null){
  43865. $elem.style.transition = 'width '+ settings.timeout +'ms '+settings.progressBarEasing;
  43866. $elem.style.width = '0%';
  43867. }
  43868. settings.time.START = new Date().getTime();
  43869. settings.time.END = settings.time.START + settings.timeout;
  43870. settings.time.TIMER = setTimeout(function() {
  43871. clearTimeout(settings.time.TIMER);
  43872. if(!$toast.classList.contains(PLUGIN_NAME+'-closing')){
  43873. that.hide(settings, $toast, 'timeout');
  43874. if(typeof callback === 'function'){
  43875. callback.apply(that);
  43876. }
  43877. }
  43878. }, settings.timeout);
  43879. that.setSetting(ref, 'time', settings.time);
  43880. }
  43881. },
  43882. pause: function() {
  43883. if(typeof settings.time.START !== 'undefined' && !$toast.classList.contains(PLUGIN_NAME+'-paused') && !$toast.classList.contains(PLUGIN_NAME+'-reseted')){
  43884. $toast.classList.add(PLUGIN_NAME+'-paused');
  43885. settings.time.REMAINING = settings.time.END - new Date().getTime();
  43886. clearTimeout(settings.time.TIMER);
  43887. that.setSetting(ref, 'time', settings.time);
  43888. if($elem !== null){
  43889. var computedStyle = window.getComputedStyle($elem),
  43890. propertyWidth = computedStyle.getPropertyValue('width');
  43891. $elem.style.transition = 'none';
  43892. $elem.style.width = propertyWidth;
  43893. }
  43894. if(typeof callback === 'function'){
  43895. setTimeout(function() {
  43896. callback.apply(that);
  43897. }, 10);
  43898. }
  43899. }
  43900. },
  43901. resume: function() {
  43902. if(typeof settings.time.REMAINING !== 'undefined'){
  43903. $toast.classList.remove(PLUGIN_NAME+'-paused');
  43904. if($elem !== null){
  43905. $elem.style.transition = 'width '+ settings.time.REMAINING +'ms '+settings.progressBarEasing;
  43906. $elem.style.width = '0%';
  43907. }
  43908. settings.time.END = new Date().getTime() + settings.time.REMAINING;
  43909. settings.time.TIMER = setTimeout(function() {
  43910. clearTimeout(settings.time.TIMER);
  43911. if(!$toast.classList.contains(PLUGIN_NAME+'-closing')){
  43912. that.hide(settings, $toast, 'timeout');
  43913. if(typeof callback === 'function'){
  43914. callback.apply(that);
  43915. }
  43916. }
  43917. }, settings.time.REMAINING);
  43918. that.setSetting(ref, 'time', settings.time);
  43919. } else {
  43920. this.start();
  43921. }
  43922. },
  43923. reset: function(){
  43924. clearTimeout(settings.time.TIMER);
  43925. delete settings.time.REMAINING;
  43926. that.setSetting(ref, 'time', settings.time);
  43927. $toast.classList.add(PLUGIN_NAME+'-reseted');
  43928. $toast.classList.remove(PLUGIN_NAME+'-paused');
  43929. if($elem !== null){
  43930. $elem.style.transition = 'none';
  43931. $elem.style.width = '100%';
  43932. }
  43933. if(typeof callback === 'function'){
  43934. setTimeout(function() {
  43935. callback.apply(that);
  43936. }, 10);
  43937. }
  43938. }
  43939. };
  43940. };
  43941. /**
  43942. * Close the specific Toast
  43943. * @public
  43944. * @param {Object} options User settings
  43945. */
  43946. $iziToast.hide = function (options, $toast, closedBy) {
  43947. if(typeof $toast != 'object'){
  43948. $toast = document.querySelector($toast);
  43949. }
  43950. var that = this,
  43951. settings = extend(this.children[$toast.getAttribute('data-iziToast-ref')], options || {});
  43952. settings.closedBy = closedBy || null;
  43953. delete settings.time.REMAINING;
  43954. $toast.classList.add(PLUGIN_NAME+'-closing');
  43955. // Overlay
  43956. (function(){
  43957. var $overlay = document.querySelector('.'+PLUGIN_NAME+'-overlay');
  43958. if($overlay !== null){
  43959. var refs = $overlay.getAttribute('data-iziToast-ref');
  43960. refs = refs.split(',');
  43961. var index = refs.indexOf(String(settings.ref));
  43962. if(index !== -1){
  43963. refs.splice(index, 1);
  43964. }
  43965. $overlay.setAttribute('data-iziToast-ref', refs.join());
  43966. if(refs.length === 0){
  43967. $overlay.classList.remove('fadeIn');
  43968. $overlay.classList.add('fadeOut');
  43969. setTimeout(function() {
  43970. $overlay.remove();
  43971. }, 700);
  43972. }
  43973. }
  43974. })();
  43975. if(settings.transitionIn){
  43976. $toast.classList.remove(settings.transitionIn);
  43977. }
  43978. if(settings.transitionInMobile){
  43979. $toast.classList.remove(settings.transitionInMobile);
  43980. }
  43981. if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){
  43982. if(settings.transitionOutMobile)
  43983. $toast.classList.add(settings.transitionOutMobile);
  43984. } else {
  43985. if(settings.transitionOut)
  43986. $toast.classList.add(settings.transitionOut);
  43987. }
  43988. var H = $toast.parentNode.offsetHeight;
  43989. $toast.parentNode.style.height = H+'px';
  43990. $toast.style.pointerEvents = 'none';
  43991. if(!ISMOBILE || window.innerWidth > MOBILEWIDTH){
  43992. $toast.parentNode.style.transitionDelay = '0.2s';
  43993. }
  43994. try {
  43995. var event = new CustomEvent(PLUGIN_NAME+'-closing', {detail: settings, bubbles: true, cancelable: true});
  43996. document.dispatchEvent(event);
  43997. } catch(ex){
  43998. console.warn(ex);
  43999. }
  44000. setTimeout(function() {
  44001. $toast.parentNode.style.height = '0px';
  44002. $toast.parentNode.style.overflow = '';
  44003. setTimeout(function(){
  44004. delete that.children[settings.ref];
  44005. $toast.parentNode.remove();
  44006. try {
  44007. var event = new CustomEvent(PLUGIN_NAME+'-closed', {detail: settings, bubbles: true, cancelable: true});
  44008. document.dispatchEvent(event);
  44009. } catch(ex){
  44010. console.warn(ex);
  44011. }
  44012. if(typeof settings.onClosed !== 'undefined'){
  44013. settings.onClosed.apply(null, [settings, $toast, closedBy]);
  44014. }
  44015. }, 1000);
  44016. }, 200);
  44017. if(typeof settings.onClosing !== 'undefined'){
  44018. settings.onClosing.apply(null, [settings, $toast, closedBy]);
  44019. }
  44020. };
  44021. /**
  44022. * Create and show the Toast
  44023. * @public
  44024. * @param {Object} options User settings
  44025. */
  44026. $iziToast.show = function (options) {
  44027. var that = this;
  44028. // Merge user options with defaults
  44029. var settings = extend(CONFIG, options || {});
  44030. settings = extend(defaults, settings);
  44031. settings.time = {};
  44032. if(settings.id === null){
  44033. settings.id = generateId(settings.title+settings.message+settings.color);
  44034. }
  44035. if(settings.displayMode === 1 || settings.displayMode == 'once'){
  44036. try {
  44037. if(document.querySelectorAll('.'+PLUGIN_NAME+'#'+settings.id).length > 0){
  44038. return false;
  44039. }
  44040. } catch (exc) {
  44041. console.warn('['+PLUGIN_NAME+'] Could not find an element with this selector: '+'#'+settings.id+'. Try to set an valid id.');
  44042. }
  44043. }
  44044. if(settings.displayMode === 2 || settings.displayMode == 'replace'){
  44045. try {
  44046. forEach(document.querySelectorAll('.'+PLUGIN_NAME+'#'+settings.id), function(element, index) {
  44047. that.hide(settings, element, 'replaced');
  44048. });
  44049. } catch (exc) {
  44050. console.warn('['+PLUGIN_NAME+'] Could not find an element with this selector: '+'#'+settings.id+'. Try to set an valid id.');
  44051. }
  44052. }
  44053. settings.ref = new Date().getTime() + Math.floor((Math.random() * 10000000) + 1);
  44054. $iziToast.children[settings.ref] = settings;
  44055. var $DOM = {
  44056. body: document.querySelector('body'),
  44057. overlay: document.createElement('div'),
  44058. toast: document.createElement('div'),
  44059. toastBody: document.createElement('div'),
  44060. toastTexts: document.createElement('div'),
  44061. toastCapsule: document.createElement('div'),
  44062. cover: document.createElement('div'),
  44063. buttons: document.createElement('div'),
  44064. inputs: document.createElement('div'),
  44065. icon: !settings.iconUrl ? document.createElement('i') : document.createElement('img'),
  44066. wrapper: null
  44067. };
  44068. $DOM.toast.setAttribute('data-iziToast-ref', settings.ref);
  44069. $DOM.toast.appendChild($DOM.toastBody);
  44070. $DOM.toastCapsule.appendChild($DOM.toast);
  44071. // CSS Settings
  44072. (function(){
  44073. $DOM.toast.classList.add(PLUGIN_NAME);
  44074. $DOM.toast.classList.add(PLUGIN_NAME+'-opening');
  44075. $DOM.toastCapsule.classList.add(PLUGIN_NAME+'-capsule');
  44076. $DOM.toastBody.classList.add(PLUGIN_NAME + '-body');
  44077. $DOM.toastTexts.classList.add(PLUGIN_NAME + '-texts');
  44078. if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){
  44079. if(settings.transitionInMobile)
  44080. $DOM.toast.classList.add(settings.transitionInMobile);
  44081. } else {
  44082. if(settings.transitionIn)
  44083. $DOM.toast.classList.add(settings.transitionIn);
  44084. }
  44085. if(settings.class){
  44086. var classes = settings.class.split(' ');
  44087. forEach(classes, function (value, index) {
  44088. $DOM.toast.classList.add(value);
  44089. });
  44090. }
  44091. if(settings.id){ $DOM.toast.id = settings.id; }
  44092. if(settings.rtl){
  44093. $DOM.toast.classList.add(PLUGIN_NAME + '-rtl');
  44094. $DOM.toast.setAttribute('dir', 'rtl');
  44095. }
  44096. if(settings.layout > 1){ $DOM.toast.classList.add(PLUGIN_NAME+'-layout'+settings.layout); }
  44097. if(settings.balloon){ $DOM.toast.classList.add(PLUGIN_NAME+'-balloon'); }
  44098. if(settings.maxWidth){
  44099. if( !isNaN(settings.maxWidth) ){
  44100. $DOM.toast.style.maxWidth = settings.maxWidth+'px';
  44101. } else {
  44102. $DOM.toast.style.maxWidth = settings.maxWidth;
  44103. }
  44104. }
  44105. if(settings.theme !== '' || settings.theme !== 'light') {
  44106. $DOM.toast.classList.add(PLUGIN_NAME+'-theme-'+settings.theme);
  44107. }
  44108. if(settings.color) { //#, rgb, rgba, hsl
  44109. if( isColor(settings.color) ){
  44110. $DOM.toast.style.background = settings.color;
  44111. } else {
  44112. $DOM.toast.classList.add(PLUGIN_NAME+'-color-'+settings.color);
  44113. }
  44114. }
  44115. if(settings.backgroundColor) {
  44116. $DOM.toast.style.background = settings.backgroundColor;
  44117. if(settings.balloon){
  44118. $DOM.toast.style.borderColor = settings.backgroundColor;
  44119. }
  44120. }
  44121. })();
  44122. // Cover image
  44123. (function(){
  44124. if(settings.image) {
  44125. $DOM.cover.classList.add(PLUGIN_NAME + '-cover');
  44126. $DOM.cover.style.width = settings.imageWidth + 'px';
  44127. if(isBase64(settings.image.replace(/ /g,''))){
  44128. $DOM.cover.style.backgroundImage = 'url(data:image/png;base64,' + settings.image.replace(/ /g,'') + ')';
  44129. } else {
  44130. $DOM.cover.style.backgroundImage = 'url(' + settings.image + ')';
  44131. }
  44132. if(settings.rtl){
  44133. $DOM.toastBody.style.marginRight = (settings.imageWidth + 10) + 'px';
  44134. } else {
  44135. $DOM.toastBody.style.marginLeft = (settings.imageWidth + 10) + 'px';
  44136. }
  44137. $DOM.toast.appendChild($DOM.cover);
  44138. }
  44139. })();
  44140. // Button close
  44141. (function(){
  44142. if(settings.close){
  44143. $DOM.buttonClose = document.createElement('button');
  44144. $DOM.buttonClose.type = 'button';
  44145. $DOM.buttonClose.classList.add(PLUGIN_NAME + '-close');
  44146. $DOM.buttonClose.addEventListener('click', function (e) {
  44147. var button = e.target;
  44148. that.hide(settings, $DOM.toast, 'button');
  44149. });
  44150. $DOM.toast.appendChild($DOM.buttonClose);
  44151. } else {
  44152. if(settings.rtl){
  44153. $DOM.toast.style.paddingLeft = '18px';
  44154. } else {
  44155. $DOM.toast.style.paddingRight = '18px';
  44156. }
  44157. }
  44158. })();
  44159. // Progress Bar & Timeout
  44160. (function(){
  44161. if(settings.progressBar){
  44162. $DOM.progressBar = document.createElement('div');
  44163. $DOM.progressBarDiv = document.createElement('div');
  44164. $DOM.progressBar.classList.add(PLUGIN_NAME + '-progressbar');
  44165. $DOM.progressBarDiv.style.background = settings.progressBarColor;
  44166. $DOM.progressBar.appendChild($DOM.progressBarDiv);
  44167. $DOM.toast.appendChild($DOM.progressBar);
  44168. }
  44169. if(settings.timeout) {
  44170. if(settings.pauseOnHover && !settings.resetOnHover){
  44171. $DOM.toast.addEventListener('mouseenter', function (e) {
  44172. that.progress(settings, $DOM.toast).pause();
  44173. });
  44174. $DOM.toast.addEventListener('mouseleave', function (e) {
  44175. that.progress(settings, $DOM.toast).resume();
  44176. });
  44177. }
  44178. if(settings.resetOnHover){
  44179. $DOM.toast.addEventListener('mouseenter', function (e) {
  44180. that.progress(settings, $DOM.toast).reset();
  44181. });
  44182. $DOM.toast.addEventListener('mouseleave', function (e) {
  44183. that.progress(settings, $DOM.toast).start();
  44184. });
  44185. }
  44186. }
  44187. })();
  44188. // Icon
  44189. (function(){
  44190. if(settings.iconUrl) {
  44191. $DOM.icon.setAttribute('class', PLUGIN_NAME + '-icon');
  44192. $DOM.icon.setAttribute('src', settings.iconUrl);
  44193. } else if(settings.icon) {
  44194. $DOM.icon.setAttribute('class', PLUGIN_NAME + '-icon ' + settings.icon);
  44195. if(settings.iconText){
  44196. $DOM.icon.appendChild(document.createTextNode(settings.iconText));
  44197. }
  44198. if(settings.iconColor){
  44199. $DOM.icon.style.color = settings.iconColor;
  44200. }
  44201. }
  44202. if(settings.icon || settings.iconUrl) {
  44203. if(settings.rtl){
  44204. $DOM.toastBody.style.paddingRight = '33px';
  44205. } else {
  44206. $DOM.toastBody.style.paddingLeft = '33px';
  44207. }
  44208. $DOM.toastBody.appendChild($DOM.icon);
  44209. }
  44210. })();
  44211. // Title & Message
  44212. (function(){
  44213. if(settings.title.length > 0) {
  44214. $DOM.strong = document.createElement('strong');
  44215. $DOM.strong.classList.add(PLUGIN_NAME + '-title');
  44216. $DOM.strong.appendChild(createFragElem(settings.title));
  44217. $DOM.toastTexts.appendChild($DOM.strong);
  44218. if(settings.titleColor) {
  44219. $DOM.strong.style.color = settings.titleColor;
  44220. }
  44221. if(settings.titleSize) {
  44222. if( !isNaN(settings.titleSize) ){
  44223. $DOM.strong.style.fontSize = settings.titleSize+'px';
  44224. } else {
  44225. $DOM.strong.style.fontSize = settings.titleSize;
  44226. }
  44227. }
  44228. if(settings.titleLineHeight) {
  44229. if( !isNaN(settings.titleSize) ){
  44230. $DOM.strong.style.lineHeight = settings.titleLineHeight+'px';
  44231. } else {
  44232. $DOM.strong.style.lineHeight = settings.titleLineHeight;
  44233. }
  44234. }
  44235. }
  44236. if(settings.message.length > 0) {
  44237. $DOM.p = document.createElement('p');
  44238. $DOM.p.classList.add(PLUGIN_NAME + '-message');
  44239. $DOM.p.appendChild(createFragElem(settings.message));
  44240. $DOM.toastTexts.appendChild($DOM.p);
  44241. if(settings.messageColor) {
  44242. $DOM.p.style.color = settings.messageColor;
  44243. }
  44244. if(settings.messageSize) {
  44245. if( !isNaN(settings.titleSize) ){
  44246. $DOM.p.style.fontSize = settings.messageSize+'px';
  44247. } else {
  44248. $DOM.p.style.fontSize = settings.messageSize;
  44249. }
  44250. }
  44251. if(settings.messageLineHeight) {
  44252. if( !isNaN(settings.titleSize) ){
  44253. $DOM.p.style.lineHeight = settings.messageLineHeight+'px';
  44254. } else {
  44255. $DOM.p.style.lineHeight = settings.messageLineHeight;
  44256. }
  44257. }
  44258. }
  44259. if(settings.title.length > 0 && settings.message.length > 0) {
  44260. if(settings.rtl){
  44261. $DOM.strong.style.marginLeft = '10px';
  44262. } else if(settings.layout !== 2 && !settings.rtl) {
  44263. $DOM.strong.style.marginRight = '10px';
  44264. }
  44265. }
  44266. })();
  44267. $DOM.toastBody.appendChild($DOM.toastTexts);
  44268. // Inputs
  44269. var $inputs;
  44270. (function(){
  44271. if(settings.inputs.length > 0) {
  44272. $DOM.inputs.classList.add(PLUGIN_NAME + '-inputs');
  44273. forEach(settings.inputs, function (value, index) {
  44274. $DOM.inputs.appendChild(createFragElem(value[0]));
  44275. $inputs = $DOM.inputs.childNodes;
  44276. $inputs[index].classList.add(PLUGIN_NAME + '-inputs-child');
  44277. if(value[3]){
  44278. setTimeout(function() {
  44279. $inputs[index].focus();
  44280. }, 300);
  44281. }
  44282. $inputs[index].addEventListener(value[1], function (e) {
  44283. var ts = value[2];
  44284. return ts(that, $DOM.toast, this, e);
  44285. });
  44286. });
  44287. $DOM.toastBody.appendChild($DOM.inputs);
  44288. }
  44289. })();
  44290. // Buttons
  44291. (function(){
  44292. if(settings.buttons.length > 0) {
  44293. $DOM.buttons.classList.add(PLUGIN_NAME + '-buttons');
  44294. forEach(settings.buttons, function (value, index) {
  44295. $DOM.buttons.appendChild(createFragElem(value[0]));
  44296. var $btns = $DOM.buttons.childNodes;
  44297. $btns[index].classList.add(PLUGIN_NAME + '-buttons-child');
  44298. if(value[2]){
  44299. setTimeout(function() {
  44300. $btns[index].focus();
  44301. }, 300);
  44302. }
  44303. $btns[index].addEventListener('click', function (e) {
  44304. e.preventDefault();
  44305. var ts = value[1];
  44306. return ts(that, $DOM.toast, this, e, $inputs);
  44307. });
  44308. });
  44309. }
  44310. $DOM.toastBody.appendChild($DOM.buttons);
  44311. })();
  44312. if(settings.message.length > 0 && (settings.inputs.length > 0 || settings.buttons.length > 0)) {
  44313. $DOM.p.style.marginBottom = '0';
  44314. }
  44315. if(settings.inputs.length > 0 || settings.buttons.length > 0){
  44316. if(settings.rtl){
  44317. $DOM.toastTexts.style.marginLeft = '10px';
  44318. } else {
  44319. $DOM.toastTexts.style.marginRight = '10px';
  44320. }
  44321. if(settings.inputs.length > 0 && settings.buttons.length > 0){
  44322. if(settings.rtl){
  44323. $DOM.inputs.style.marginLeft = '8px';
  44324. } else {
  44325. $DOM.inputs.style.marginRight = '8px';
  44326. }
  44327. }
  44328. }
  44329. // Wrap
  44330. (function(){
  44331. $DOM.toastCapsule.style.visibility = 'hidden';
  44332. setTimeout(function() {
  44333. var H = $DOM.toast.offsetHeight;
  44334. var style = $DOM.toast.currentStyle || window.getComputedStyle($DOM.toast);
  44335. var marginTop = style.marginTop;
  44336. marginTop = marginTop.split('px');
  44337. marginTop = parseInt(marginTop[0]);
  44338. var marginBottom = style.marginBottom;
  44339. marginBottom = marginBottom.split('px');
  44340. marginBottom = parseInt(marginBottom[0]);
  44341. $DOM.toastCapsule.style.visibility = '';
  44342. $DOM.toastCapsule.style.height = (H+marginBottom+marginTop)+'px';
  44343. setTimeout(function() {
  44344. $DOM.toastCapsule.style.height = 'auto';
  44345. if(settings.target){
  44346. $DOM.toastCapsule.style.overflow = 'visible';
  44347. }
  44348. }, 500);
  44349. if(settings.timeout) {
  44350. that.progress(settings, $DOM.toast).start();
  44351. }
  44352. }, 100);
  44353. })();
  44354. // Target
  44355. (function(){
  44356. var position = settings.position;
  44357. if(settings.target){
  44358. $DOM.wrapper = document.querySelector(settings.target);
  44359. $DOM.wrapper.classList.add(PLUGIN_NAME + '-target');
  44360. if(settings.targetFirst) {
  44361. $DOM.wrapper.insertBefore($DOM.toastCapsule, $DOM.wrapper.firstChild);
  44362. } else {
  44363. $DOM.wrapper.appendChild($DOM.toastCapsule);
  44364. }
  44365. } else {
  44366. if( POSITIONS.indexOf(settings.position) == -1 ){
  44367. console.warn('['+PLUGIN_NAME+'] Incorrect position.\nIt can be › ' + POSITIONS);
  44368. return;
  44369. }
  44370. if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){
  44371. if(settings.position == 'bottomLeft' || settings.position == 'bottomRight' || settings.position == 'bottomCenter'){
  44372. position = PLUGIN_NAME+'-wrapper-bottomCenter';
  44373. }
  44374. else if(settings.position == 'topLeft' || settings.position == 'topRight' || settings.position == 'topCenter'){
  44375. position = PLUGIN_NAME+'-wrapper-topCenter';
  44376. }
  44377. else {
  44378. position = PLUGIN_NAME+'-wrapper-center';
  44379. }
  44380. } else {
  44381. position = PLUGIN_NAME+'-wrapper-'+position;
  44382. }
  44383. $DOM.wrapper = document.querySelector('.' + PLUGIN_NAME + '-wrapper.'+position);
  44384. if(!$DOM.wrapper) {
  44385. $DOM.wrapper = document.createElement('div');
  44386. $DOM.wrapper.classList.add(PLUGIN_NAME + '-wrapper');
  44387. $DOM.wrapper.classList.add(position);
  44388. document.body.appendChild($DOM.wrapper);
  44389. }
  44390. if(settings.position == 'topLeft' || settings.position == 'topCenter' || settings.position == 'topRight'){
  44391. $DOM.wrapper.insertBefore($DOM.toastCapsule, $DOM.wrapper.firstChild);
  44392. } else {
  44393. $DOM.wrapper.appendChild($DOM.toastCapsule);
  44394. }
  44395. }
  44396. if(!isNaN(settings.zindex)) {
  44397. $DOM.wrapper.style.zIndex = settings.zindex;
  44398. } else {
  44399. console.warn('['+PLUGIN_NAME+'] Invalid zIndex.');
  44400. }
  44401. })();
  44402. // Overlay
  44403. (function(){
  44404. if(settings.overlay) {
  44405. if( document.querySelector('.'+PLUGIN_NAME+'-overlay.fadeIn') !== null ){
  44406. $DOM.overlay = document.querySelector('.'+PLUGIN_NAME+'-overlay');
  44407. $DOM.overlay.setAttribute('data-iziToast-ref', $DOM.overlay.getAttribute('data-iziToast-ref') + ',' + settings.ref);
  44408. if(!isNaN(settings.zindex) && settings.zindex !== null) {
  44409. $DOM.overlay.style.zIndex = settings.zindex-1;
  44410. }
  44411. } else {
  44412. $DOM.overlay.classList.add(PLUGIN_NAME+'-overlay');
  44413. $DOM.overlay.classList.add('fadeIn');
  44414. $DOM.overlay.style.background = settings.overlayColor;
  44415. $DOM.overlay.setAttribute('data-iziToast-ref', settings.ref);
  44416. if(!isNaN(settings.zindex) && settings.zindex !== null) {
  44417. $DOM.overlay.style.zIndex = settings.zindex-1;
  44418. }
  44419. document.querySelector('body').appendChild($DOM.overlay);
  44420. }
  44421. if(settings.overlayClose) {
  44422. $DOM.overlay.removeEventListener('click', {});
  44423. $DOM.overlay.addEventListener('click', function (e) {
  44424. that.hide(settings, $DOM.toast, 'overlay');
  44425. });
  44426. } else {
  44427. $DOM.overlay.removeEventListener('click', {});
  44428. }
  44429. }
  44430. })();
  44431. // Inside animations
  44432. (function(){
  44433. if(settings.animateInside){
  44434. $DOM.toast.classList.add(PLUGIN_NAME+'-animateInside');
  44435. var animationTimes = [200, 100, 300];
  44436. if(settings.transitionIn == 'bounceInLeft' || settings.transitionIn == 'bounceInRight'){
  44437. animationTimes = [400, 200, 400];
  44438. }
  44439. if(settings.title.length > 0) {
  44440. setTimeout(function(){
  44441. $DOM.strong.classList.add('slideIn');
  44442. }, animationTimes[0]);
  44443. }
  44444. if(settings.message.length > 0) {
  44445. setTimeout(function(){
  44446. $DOM.p.classList.add('slideIn');
  44447. }, animationTimes[1]);
  44448. }
  44449. if(settings.icon || settings.iconUrl) {
  44450. setTimeout(function(){
  44451. $DOM.icon.classList.add('revealIn');
  44452. }, animationTimes[2]);
  44453. }
  44454. var counter = 150;
  44455. if(settings.buttons.length > 0 && $DOM.buttons) {
  44456. setTimeout(function(){
  44457. forEach($DOM.buttons.childNodes, function(element, index) {
  44458. setTimeout(function(){
  44459. element.classList.add('revealIn');
  44460. }, counter);
  44461. counter = counter + 150;
  44462. });
  44463. }, settings.inputs.length > 0 ? 150 : 0);
  44464. }
  44465. if(settings.inputs.length > 0 && $DOM.inputs) {
  44466. counter = 150;
  44467. forEach($DOM.inputs.childNodes, function(element, index) {
  44468. setTimeout(function(){
  44469. element.classList.add('revealIn');
  44470. }, counter);
  44471. counter = counter + 150;
  44472. });
  44473. }
  44474. }
  44475. })();
  44476. settings.onOpening.apply(null, [settings, $DOM.toast]);
  44477. try {
  44478. var event = new CustomEvent(PLUGIN_NAME + '-opening', {detail: settings, bubbles: true, cancelable: true});
  44479. document.dispatchEvent(event);
  44480. } catch(ex){
  44481. console.warn(ex);
  44482. }
  44483. setTimeout(function() {
  44484. $DOM.toast.classList.remove(PLUGIN_NAME+'-opening');
  44485. $DOM.toast.classList.add(PLUGIN_NAME+'-opened');
  44486. try {
  44487. var event = new CustomEvent(PLUGIN_NAME + '-opened', {detail: settings, bubbles: true, cancelable: true});
  44488. document.dispatchEvent(event);
  44489. } catch(ex){
  44490. console.warn(ex);
  44491. }
  44492. settings.onOpened.apply(null, [settings, $DOM.toast]);
  44493. }, 1000);
  44494. if(settings.drag){
  44495. if(ACCEPTSTOUCH) {
  44496. $DOM.toast.addEventListener('touchstart', function(e) {
  44497. drag.startMoving(this, that, settings, e);
  44498. }, false);
  44499. $DOM.toast.addEventListener('touchend', function(e) {
  44500. drag.stopMoving(this, e);
  44501. }, false);
  44502. } else {
  44503. $DOM.toast.addEventListener('mousedown', function(e) {
  44504. e.preventDefault();
  44505. drag.startMoving(this, that, settings, e);
  44506. }, false);
  44507. $DOM.toast.addEventListener('mouseup', function(e) {
  44508. e.preventDefault();
  44509. drag.stopMoving(this, e);
  44510. }, false);
  44511. }
  44512. }
  44513. if(settings.closeOnEscape) {
  44514. document.addEventListener('keyup', function (evt) {
  44515. evt = evt || window.event;
  44516. if(evt.keyCode == 27) {
  44517. that.hide(settings, $DOM.toast, 'esc');
  44518. }
  44519. });
  44520. }
  44521. if(settings.closeOnClick) {
  44522. $DOM.toast.addEventListener('click', function (evt) {
  44523. that.hide(settings, $DOM.toast, 'toast');
  44524. });
  44525. }
  44526. that.toast = $DOM.toast;
  44527. };
  44528. return $iziToast;
  44529. });
  44530. /***/ }),
  44531. /***/ "./node_modules/json-to-pivot-json/index.js":
  44532. /*!**************************************************!*\
  44533. !*** ./node_modules/json-to-pivot-json/index.js ***!
  44534. \**************************************************/
  44535. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  44536. var crossfilter = __webpack_require__(/*! crossfilter */ "./node_modules/crossfilter/index.js");
  44537. var jsonToPivotjson = function (data, options) {
  44538. var ndx = crossfilter(data);
  44539. var pivotCol = options.column
  44540. var pivotVal = options.value;
  44541. var pivotRow = options.row;
  44542. var out = [];
  44543. var pivotRowDimension = ndx.dimension(function(d){
  44544. return d[pivotRow];
  44545. });
  44546. var pivotColDimension = ndx.dimension(function(d){
  44547. return d[pivotCol];
  44548. });
  44549. var totalByPivotRow = pivotRowDimension.group().reduceSum(function(d){
  44550. return d[pivotVal]
  44551. });
  44552. var allRecs = totalByPivotRow.all();
  44553. allRecs.forEach(function(rec){
  44554. pivotRowDimension.filter();
  44555. pivotRowDimension.filter(rec.key);
  44556. var totalByPivotCol = pivotColDimension.group().reduceSum(function(d){
  44557. return d[pivotVal]
  44558. });
  44559. var data = totalByPivotCol.all();
  44560. var doc = {};
  44561. doc[pivotRow] = rec.key;
  44562. data.forEach(function(d){
  44563. doc[d.key] = d.value;
  44564. });
  44565. out.push(doc);
  44566. });
  44567. return out;
  44568. }
  44569. module.exports = jsonToPivotjson;
  44570. /***/ }),
  44571. /***/ "./node_modules/lodash/lodash.js":
  44572. /*!***************************************!*\
  44573. !*** ./node_modules/lodash/lodash.js ***!
  44574. \***************************************/
  44575. /***/ (function(module, exports, __webpack_require__) {
  44576. /* module decorator */ module = __webpack_require__.nmd(module);
  44577. var __WEBPACK_AMD_DEFINE_RESULT__;/**
  44578. * @license
  44579. * Lodash <https://lodash.com/>
  44580. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  44581. * Released under MIT license <https://lodash.com/license>
  44582. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  44583. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  44584. */
  44585. ;(function() {
  44586. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  44587. var undefined;
  44588. /** Used as the semantic version number. */
  44589. var VERSION = '4.17.21';
  44590. /** Used as the size to enable large array optimizations. */
  44591. var LARGE_ARRAY_SIZE = 200;
  44592. /** Error message constants. */
  44593. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  44594. FUNC_ERROR_TEXT = 'Expected a function',
  44595. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  44596. /** Used to stand-in for `undefined` hash values. */
  44597. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  44598. /** Used as the maximum memoize cache size. */
  44599. var MAX_MEMOIZE_SIZE = 500;
  44600. /** Used as the internal argument placeholder. */
  44601. var PLACEHOLDER = '__lodash_placeholder__';
  44602. /** Used to compose bitmasks for cloning. */
  44603. var CLONE_DEEP_FLAG = 1,
  44604. CLONE_FLAT_FLAG = 2,
  44605. CLONE_SYMBOLS_FLAG = 4;
  44606. /** Used to compose bitmasks for value comparisons. */
  44607. var COMPARE_PARTIAL_FLAG = 1,
  44608. COMPARE_UNORDERED_FLAG = 2;
  44609. /** Used to compose bitmasks for function metadata. */
  44610. var WRAP_BIND_FLAG = 1,
  44611. WRAP_BIND_KEY_FLAG = 2,
  44612. WRAP_CURRY_BOUND_FLAG = 4,
  44613. WRAP_CURRY_FLAG = 8,
  44614. WRAP_CURRY_RIGHT_FLAG = 16,
  44615. WRAP_PARTIAL_FLAG = 32,
  44616. WRAP_PARTIAL_RIGHT_FLAG = 64,
  44617. WRAP_ARY_FLAG = 128,
  44618. WRAP_REARG_FLAG = 256,
  44619. WRAP_FLIP_FLAG = 512;
  44620. /** Used as default options for `_.truncate`. */
  44621. var DEFAULT_TRUNC_LENGTH = 30,
  44622. DEFAULT_TRUNC_OMISSION = '...';
  44623. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  44624. var HOT_COUNT = 800,
  44625. HOT_SPAN = 16;
  44626. /** Used to indicate the type of lazy iteratees. */
  44627. var LAZY_FILTER_FLAG = 1,
  44628. LAZY_MAP_FLAG = 2,
  44629. LAZY_WHILE_FLAG = 3;
  44630. /** Used as references for various `Number` constants. */
  44631. var INFINITY = 1 / 0,
  44632. MAX_SAFE_INTEGER = 9007199254740991,
  44633. MAX_INTEGER = 1.7976931348623157e+308,
  44634. NAN = 0 / 0;
  44635. /** Used as references for the maximum length and index of an array. */
  44636. var MAX_ARRAY_LENGTH = 4294967295,
  44637. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  44638. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  44639. /** Used to associate wrap methods with their bit flags. */
  44640. var wrapFlags = [
  44641. ['ary', WRAP_ARY_FLAG],
  44642. ['bind', WRAP_BIND_FLAG],
  44643. ['bindKey', WRAP_BIND_KEY_FLAG],
  44644. ['curry', WRAP_CURRY_FLAG],
  44645. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  44646. ['flip', WRAP_FLIP_FLAG],
  44647. ['partial', WRAP_PARTIAL_FLAG],
  44648. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  44649. ['rearg', WRAP_REARG_FLAG]
  44650. ];
  44651. /** `Object#toString` result references. */
  44652. var argsTag = '[object Arguments]',
  44653. arrayTag = '[object Array]',
  44654. asyncTag = '[object AsyncFunction]',
  44655. boolTag = '[object Boolean]',
  44656. dateTag = '[object Date]',
  44657. domExcTag = '[object DOMException]',
  44658. errorTag = '[object Error]',
  44659. funcTag = '[object Function]',
  44660. genTag = '[object GeneratorFunction]',
  44661. mapTag = '[object Map]',
  44662. numberTag = '[object Number]',
  44663. nullTag = '[object Null]',
  44664. objectTag = '[object Object]',
  44665. promiseTag = '[object Promise]',
  44666. proxyTag = '[object Proxy]',
  44667. regexpTag = '[object RegExp]',
  44668. setTag = '[object Set]',
  44669. stringTag = '[object String]',
  44670. symbolTag = '[object Symbol]',
  44671. undefinedTag = '[object Undefined]',
  44672. weakMapTag = '[object WeakMap]',
  44673. weakSetTag = '[object WeakSet]';
  44674. var arrayBufferTag = '[object ArrayBuffer]',
  44675. dataViewTag = '[object DataView]',
  44676. float32Tag = '[object Float32Array]',
  44677. float64Tag = '[object Float64Array]',
  44678. int8Tag = '[object Int8Array]',
  44679. int16Tag = '[object Int16Array]',
  44680. int32Tag = '[object Int32Array]',
  44681. uint8Tag = '[object Uint8Array]',
  44682. uint8ClampedTag = '[object Uint8ClampedArray]',
  44683. uint16Tag = '[object Uint16Array]',
  44684. uint32Tag = '[object Uint32Array]';
  44685. /** Used to match empty string literals in compiled template source. */
  44686. var reEmptyStringLeading = /\b__p \+= '';/g,
  44687. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  44688. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  44689. /** Used to match HTML entities and HTML characters. */
  44690. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  44691. reUnescapedHtml = /[&<>"']/g,
  44692. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  44693. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  44694. /** Used to match template delimiters. */
  44695. var reEscape = /<%-([\s\S]+?)%>/g,
  44696. reEvaluate = /<%([\s\S]+?)%>/g,
  44697. reInterpolate = /<%=([\s\S]+?)%>/g;
  44698. /** Used to match property names within property paths. */
  44699. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  44700. reIsPlainProp = /^\w*$/,
  44701. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  44702. /**
  44703. * Used to match `RegExp`
  44704. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  44705. */
  44706. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  44707. reHasRegExpChar = RegExp(reRegExpChar.source);
  44708. /** Used to match leading whitespace. */
  44709. var reTrimStart = /^\s+/;
  44710. /** Used to match a single whitespace character. */
  44711. var reWhitespace = /\s/;
  44712. /** Used to match wrap detail comments. */
  44713. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  44714. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  44715. reSplitDetails = /,? & /;
  44716. /** Used to match words composed of alphanumeric characters. */
  44717. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  44718. /**
  44719. * Used to validate the `validate` option in `_.template` variable.
  44720. *
  44721. * Forbids characters which could potentially change the meaning of the function argument definition:
  44722. * - "()," (modification of function parameters)
  44723. * - "=" (default value)
  44724. * - "[]{}" (destructuring of function parameters)
  44725. * - "/" (beginning of a comment)
  44726. * - whitespace
  44727. */
  44728. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  44729. /** Used to match backslashes in property paths. */
  44730. var reEscapeChar = /\\(\\)?/g;
  44731. /**
  44732. * Used to match
  44733. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  44734. */
  44735. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  44736. /** Used to match `RegExp` flags from their coerced string values. */
  44737. var reFlags = /\w*$/;
  44738. /** Used to detect bad signed hexadecimal string values. */
  44739. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  44740. /** Used to detect binary string values. */
  44741. var reIsBinary = /^0b[01]+$/i;
  44742. /** Used to detect host constructors (Safari). */
  44743. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  44744. /** Used to detect octal string values. */
  44745. var reIsOctal = /^0o[0-7]+$/i;
  44746. /** Used to detect unsigned integer values. */
  44747. var reIsUint = /^(?:0|[1-9]\d*)$/;
  44748. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  44749. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  44750. /** Used to ensure capturing order of template delimiters. */
  44751. var reNoMatch = /($^)/;
  44752. /** Used to match unescaped characters in compiled string literals. */
  44753. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  44754. /** Used to compose unicode character classes. */
  44755. var rsAstralRange = '\\ud800-\\udfff',
  44756. rsComboMarksRange = '\\u0300-\\u036f',
  44757. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  44758. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  44759. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  44760. rsDingbatRange = '\\u2700-\\u27bf',
  44761. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  44762. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  44763. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  44764. rsPunctuationRange = '\\u2000-\\u206f',
  44765. rsSpaceRange = ' \\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',
  44766. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  44767. rsVarRange = '\\ufe0e\\ufe0f',
  44768. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  44769. /** Used to compose unicode capture groups. */
  44770. var rsApos = "['\u2019]",
  44771. rsAstral = '[' + rsAstralRange + ']',
  44772. rsBreak = '[' + rsBreakRange + ']',
  44773. rsCombo = '[' + rsComboRange + ']',
  44774. rsDigits = '\\d+',
  44775. rsDingbat = '[' + rsDingbatRange + ']',
  44776. rsLower = '[' + rsLowerRange + ']',
  44777. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  44778. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  44779. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  44780. rsNonAstral = '[^' + rsAstralRange + ']',
  44781. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  44782. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  44783. rsUpper = '[' + rsUpperRange + ']',
  44784. rsZWJ = '\\u200d';
  44785. /** Used to compose unicode regexes. */
  44786. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  44787. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  44788. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  44789. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  44790. reOptMod = rsModifier + '?',
  44791. rsOptVar = '[' + rsVarRange + ']?',
  44792. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  44793. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  44794. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  44795. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  44796. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  44797. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  44798. /** Used to match apostrophes. */
  44799. var reApos = RegExp(rsApos, 'g');
  44800. /**
  44801. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  44802. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  44803. */
  44804. var reComboMark = RegExp(rsCombo, 'g');
  44805. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  44806. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  44807. /** Used to match complex or compound words. */
  44808. var reUnicodeWord = RegExp([
  44809. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  44810. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  44811. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  44812. rsUpper + '+' + rsOptContrUpper,
  44813. rsOrdUpper,
  44814. rsOrdLower,
  44815. rsDigits,
  44816. rsEmoji
  44817. ].join('|'), 'g');
  44818. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  44819. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  44820. /** Used to detect strings that need a more robust regexp to match words. */
  44821. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  44822. /** Used to assign default `context` object properties. */
  44823. var contextProps = [
  44824. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  44825. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  44826. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  44827. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  44828. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  44829. ];
  44830. /** Used to make template sourceURLs easier to identify. */
  44831. var templateCounter = -1;
  44832. /** Used to identify `toStringTag` values of typed arrays. */
  44833. var typedArrayTags = {};
  44834. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  44835. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  44836. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  44837. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  44838. typedArrayTags[uint32Tag] = true;
  44839. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  44840. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  44841. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  44842. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  44843. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  44844. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  44845. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  44846. typedArrayTags[weakMapTag] = false;
  44847. /** Used to identify `toStringTag` values supported by `_.clone`. */
  44848. var cloneableTags = {};
  44849. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  44850. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  44851. cloneableTags[boolTag] = cloneableTags[dateTag] =
  44852. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  44853. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  44854. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  44855. cloneableTags[numberTag] = cloneableTags[objectTag] =
  44856. cloneableTags[regexpTag] = cloneableTags[setTag] =
  44857. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  44858. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  44859. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  44860. cloneableTags[errorTag] = cloneableTags[funcTag] =
  44861. cloneableTags[weakMapTag] = false;
  44862. /** Used to map Latin Unicode letters to basic Latin letters. */
  44863. var deburredLetters = {
  44864. // Latin-1 Supplement block.
  44865. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  44866. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  44867. '\xc7': 'C', '\xe7': 'c',
  44868. '\xd0': 'D', '\xf0': 'd',
  44869. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  44870. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  44871. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  44872. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  44873. '\xd1': 'N', '\xf1': 'n',
  44874. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  44875. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  44876. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  44877. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  44878. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  44879. '\xc6': 'Ae', '\xe6': 'ae',
  44880. '\xde': 'Th', '\xfe': 'th',
  44881. '\xdf': 'ss',
  44882. // Latin Extended-A block.
  44883. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  44884. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  44885. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  44886. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  44887. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  44888. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  44889. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  44890. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  44891. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  44892. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  44893. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  44894. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  44895. '\u0134': 'J', '\u0135': 'j',
  44896. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  44897. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  44898. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  44899. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  44900. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  44901. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  44902. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  44903. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  44904. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  44905. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  44906. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  44907. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  44908. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  44909. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  44910. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  44911. '\u0174': 'W', '\u0175': 'w',
  44912. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  44913. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  44914. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  44915. '\u0132': 'IJ', '\u0133': 'ij',
  44916. '\u0152': 'Oe', '\u0153': 'oe',
  44917. '\u0149': "'n", '\u017f': 's'
  44918. };
  44919. /** Used to map characters to HTML entities. */
  44920. var htmlEscapes = {
  44921. '&': '&amp;',
  44922. '<': '&lt;',
  44923. '>': '&gt;',
  44924. '"': '&quot;',
  44925. "'": '&#39;'
  44926. };
  44927. /** Used to map HTML entities to characters. */
  44928. var htmlUnescapes = {
  44929. '&amp;': '&',
  44930. '&lt;': '<',
  44931. '&gt;': '>',
  44932. '&quot;': '"',
  44933. '&#39;': "'"
  44934. };
  44935. /** Used to escape characters for inclusion in compiled string literals. */
  44936. var stringEscapes = {
  44937. '\\': '\\',
  44938. "'": "'",
  44939. '\n': 'n',
  44940. '\r': 'r',
  44941. '\u2028': 'u2028',
  44942. '\u2029': 'u2029'
  44943. };
  44944. /** Built-in method references without a dependency on `root`. */
  44945. var freeParseFloat = parseFloat,
  44946. freeParseInt = parseInt;
  44947. /** Detect free variable `global` from Node.js. */
  44948. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  44949. /** Detect free variable `self`. */
  44950. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  44951. /** Used as a reference to the global object. */
  44952. var root = freeGlobal || freeSelf || Function('return this')();
  44953. /** Detect free variable `exports`. */
  44954. var freeExports = true && exports && !exports.nodeType && exports;
  44955. /** Detect free variable `module`. */
  44956. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  44957. /** Detect the popular CommonJS extension `module.exports`. */
  44958. var moduleExports = freeModule && freeModule.exports === freeExports;
  44959. /** Detect free variable `process` from Node.js. */
  44960. var freeProcess = moduleExports && freeGlobal.process;
  44961. /** Used to access faster Node.js helpers. */
  44962. var nodeUtil = (function() {
  44963. try {
  44964. // Use `util.types` for Node.js 10+.
  44965. var types = freeModule && freeModule.require && freeModule.require('util').types;
  44966. if (types) {
  44967. return types;
  44968. }
  44969. // Legacy `process.binding('util')` for Node.js < 10.
  44970. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  44971. } catch (e) {}
  44972. }());
  44973. /* Node.js helper references. */
  44974. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  44975. nodeIsDate = nodeUtil && nodeUtil.isDate,
  44976. nodeIsMap = nodeUtil && nodeUtil.isMap,
  44977. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  44978. nodeIsSet = nodeUtil && nodeUtil.isSet,
  44979. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  44980. /*--------------------------------------------------------------------------*/
  44981. /**
  44982. * A faster alternative to `Function#apply`, this function invokes `func`
  44983. * with the `this` binding of `thisArg` and the arguments of `args`.
  44984. *
  44985. * @private
  44986. * @param {Function} func The function to invoke.
  44987. * @param {*} thisArg The `this` binding of `func`.
  44988. * @param {Array} args The arguments to invoke `func` with.
  44989. * @returns {*} Returns the result of `func`.
  44990. */
  44991. function apply(func, thisArg, args) {
  44992. switch (args.length) {
  44993. case 0: return func.call(thisArg);
  44994. case 1: return func.call(thisArg, args[0]);
  44995. case 2: return func.call(thisArg, args[0], args[1]);
  44996. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  44997. }
  44998. return func.apply(thisArg, args);
  44999. }
  45000. /**
  45001. * A specialized version of `baseAggregator` for arrays.
  45002. *
  45003. * @private
  45004. * @param {Array} [array] The array to iterate over.
  45005. * @param {Function} setter The function to set `accumulator` values.
  45006. * @param {Function} iteratee The iteratee to transform keys.
  45007. * @param {Object} accumulator The initial aggregated object.
  45008. * @returns {Function} Returns `accumulator`.
  45009. */
  45010. function arrayAggregator(array, setter, iteratee, accumulator) {
  45011. var index = -1,
  45012. length = array == null ? 0 : array.length;
  45013. while (++index < length) {
  45014. var value = array[index];
  45015. setter(accumulator, value, iteratee(value), array);
  45016. }
  45017. return accumulator;
  45018. }
  45019. /**
  45020. * A specialized version of `_.forEach` for arrays without support for
  45021. * iteratee shorthands.
  45022. *
  45023. * @private
  45024. * @param {Array} [array] The array to iterate over.
  45025. * @param {Function} iteratee The function invoked per iteration.
  45026. * @returns {Array} Returns `array`.
  45027. */
  45028. function arrayEach(array, iteratee) {
  45029. var index = -1,
  45030. length = array == null ? 0 : array.length;
  45031. while (++index < length) {
  45032. if (iteratee(array[index], index, array) === false) {
  45033. break;
  45034. }
  45035. }
  45036. return array;
  45037. }
  45038. /**
  45039. * A specialized version of `_.forEachRight` for arrays without support for
  45040. * iteratee shorthands.
  45041. *
  45042. * @private
  45043. * @param {Array} [array] The array to iterate over.
  45044. * @param {Function} iteratee The function invoked per iteration.
  45045. * @returns {Array} Returns `array`.
  45046. */
  45047. function arrayEachRight(array, iteratee) {
  45048. var length = array == null ? 0 : array.length;
  45049. while (length--) {
  45050. if (iteratee(array[length], length, array) === false) {
  45051. break;
  45052. }
  45053. }
  45054. return array;
  45055. }
  45056. /**
  45057. * A specialized version of `_.every` for arrays without support for
  45058. * iteratee shorthands.
  45059. *
  45060. * @private
  45061. * @param {Array} [array] The array to iterate over.
  45062. * @param {Function} predicate The function invoked per iteration.
  45063. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  45064. * else `false`.
  45065. */
  45066. function arrayEvery(array, predicate) {
  45067. var index = -1,
  45068. length = array == null ? 0 : array.length;
  45069. while (++index < length) {
  45070. if (!predicate(array[index], index, array)) {
  45071. return false;
  45072. }
  45073. }
  45074. return true;
  45075. }
  45076. /**
  45077. * A specialized version of `_.filter` for arrays without support for
  45078. * iteratee shorthands.
  45079. *
  45080. * @private
  45081. * @param {Array} [array] The array to iterate over.
  45082. * @param {Function} predicate The function invoked per iteration.
  45083. * @returns {Array} Returns the new filtered array.
  45084. */
  45085. function arrayFilter(array, predicate) {
  45086. var index = -1,
  45087. length = array == null ? 0 : array.length,
  45088. resIndex = 0,
  45089. result = [];
  45090. while (++index < length) {
  45091. var value = array[index];
  45092. if (predicate(value, index, array)) {
  45093. result[resIndex++] = value;
  45094. }
  45095. }
  45096. return result;
  45097. }
  45098. /**
  45099. * A specialized version of `_.includes` for arrays without support for
  45100. * specifying an index to search from.
  45101. *
  45102. * @private
  45103. * @param {Array} [array] The array to inspect.
  45104. * @param {*} target The value to search for.
  45105. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  45106. */
  45107. function arrayIncludes(array, value) {
  45108. var length = array == null ? 0 : array.length;
  45109. return !!length && baseIndexOf(array, value, 0) > -1;
  45110. }
  45111. /**
  45112. * This function is like `arrayIncludes` except that it accepts a comparator.
  45113. *
  45114. * @private
  45115. * @param {Array} [array] The array to inspect.
  45116. * @param {*} target The value to search for.
  45117. * @param {Function} comparator The comparator invoked per element.
  45118. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  45119. */
  45120. function arrayIncludesWith(array, value, comparator) {
  45121. var index = -1,
  45122. length = array == null ? 0 : array.length;
  45123. while (++index < length) {
  45124. if (comparator(value, array[index])) {
  45125. return true;
  45126. }
  45127. }
  45128. return false;
  45129. }
  45130. /**
  45131. * A specialized version of `_.map` for arrays without support for iteratee
  45132. * shorthands.
  45133. *
  45134. * @private
  45135. * @param {Array} [array] The array to iterate over.
  45136. * @param {Function} iteratee The function invoked per iteration.
  45137. * @returns {Array} Returns the new mapped array.
  45138. */
  45139. function arrayMap(array, iteratee) {
  45140. var index = -1,
  45141. length = array == null ? 0 : array.length,
  45142. result = Array(length);
  45143. while (++index < length) {
  45144. result[index] = iteratee(array[index], index, array);
  45145. }
  45146. return result;
  45147. }
  45148. /**
  45149. * Appends the elements of `values` to `array`.
  45150. *
  45151. * @private
  45152. * @param {Array} array The array to modify.
  45153. * @param {Array} values The values to append.
  45154. * @returns {Array} Returns `array`.
  45155. */
  45156. function arrayPush(array, values) {
  45157. var index = -1,
  45158. length = values.length,
  45159. offset = array.length;
  45160. while (++index < length) {
  45161. array[offset + index] = values[index];
  45162. }
  45163. return array;
  45164. }
  45165. /**
  45166. * A specialized version of `_.reduce` for arrays without support for
  45167. * iteratee shorthands.
  45168. *
  45169. * @private
  45170. * @param {Array} [array] The array to iterate over.
  45171. * @param {Function} iteratee The function invoked per iteration.
  45172. * @param {*} [accumulator] The initial value.
  45173. * @param {boolean} [initAccum] Specify using the first element of `array` as
  45174. * the initial value.
  45175. * @returns {*} Returns the accumulated value.
  45176. */
  45177. function arrayReduce(array, iteratee, accumulator, initAccum) {
  45178. var index = -1,
  45179. length = array == null ? 0 : array.length;
  45180. if (initAccum && length) {
  45181. accumulator = array[++index];
  45182. }
  45183. while (++index < length) {
  45184. accumulator = iteratee(accumulator, array[index], index, array);
  45185. }
  45186. return accumulator;
  45187. }
  45188. /**
  45189. * A specialized version of `_.reduceRight` for arrays without support for
  45190. * iteratee shorthands.
  45191. *
  45192. * @private
  45193. * @param {Array} [array] The array to iterate over.
  45194. * @param {Function} iteratee The function invoked per iteration.
  45195. * @param {*} [accumulator] The initial value.
  45196. * @param {boolean} [initAccum] Specify using the last element of `array` as
  45197. * the initial value.
  45198. * @returns {*} Returns the accumulated value.
  45199. */
  45200. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  45201. var length = array == null ? 0 : array.length;
  45202. if (initAccum && length) {
  45203. accumulator = array[--length];
  45204. }
  45205. while (length--) {
  45206. accumulator = iteratee(accumulator, array[length], length, array);
  45207. }
  45208. return accumulator;
  45209. }
  45210. /**
  45211. * A specialized version of `_.some` for arrays without support for iteratee
  45212. * shorthands.
  45213. *
  45214. * @private
  45215. * @param {Array} [array] The array to iterate over.
  45216. * @param {Function} predicate The function invoked per iteration.
  45217. * @returns {boolean} Returns `true` if any element passes the predicate check,
  45218. * else `false`.
  45219. */
  45220. function arraySome(array, predicate) {
  45221. var index = -1,
  45222. length = array == null ? 0 : array.length;
  45223. while (++index < length) {
  45224. if (predicate(array[index], index, array)) {
  45225. return true;
  45226. }
  45227. }
  45228. return false;
  45229. }
  45230. /**
  45231. * Gets the size of an ASCII `string`.
  45232. *
  45233. * @private
  45234. * @param {string} string The string inspect.
  45235. * @returns {number} Returns the string size.
  45236. */
  45237. var asciiSize = baseProperty('length');
  45238. /**
  45239. * Converts an ASCII `string` to an array.
  45240. *
  45241. * @private
  45242. * @param {string} string The string to convert.
  45243. * @returns {Array} Returns the converted array.
  45244. */
  45245. function asciiToArray(string) {
  45246. return string.split('');
  45247. }
  45248. /**
  45249. * Splits an ASCII `string` into an array of its words.
  45250. *
  45251. * @private
  45252. * @param {string} The string to inspect.
  45253. * @returns {Array} Returns the words of `string`.
  45254. */
  45255. function asciiWords(string) {
  45256. return string.match(reAsciiWord) || [];
  45257. }
  45258. /**
  45259. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  45260. * without support for iteratee shorthands, which iterates over `collection`
  45261. * using `eachFunc`.
  45262. *
  45263. * @private
  45264. * @param {Array|Object} collection The collection to inspect.
  45265. * @param {Function} predicate The function invoked per iteration.
  45266. * @param {Function} eachFunc The function to iterate over `collection`.
  45267. * @returns {*} Returns the found element or its key, else `undefined`.
  45268. */
  45269. function baseFindKey(collection, predicate, eachFunc) {
  45270. var result;
  45271. eachFunc(collection, function(value, key, collection) {
  45272. if (predicate(value, key, collection)) {
  45273. result = key;
  45274. return false;
  45275. }
  45276. });
  45277. return result;
  45278. }
  45279. /**
  45280. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  45281. * support for iteratee shorthands.
  45282. *
  45283. * @private
  45284. * @param {Array} array The array to inspect.
  45285. * @param {Function} predicate The function invoked per iteration.
  45286. * @param {number} fromIndex The index to search from.
  45287. * @param {boolean} [fromRight] Specify iterating from right to left.
  45288. * @returns {number} Returns the index of the matched value, else `-1`.
  45289. */
  45290. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  45291. var length = array.length,
  45292. index = fromIndex + (fromRight ? 1 : -1);
  45293. while ((fromRight ? index-- : ++index < length)) {
  45294. if (predicate(array[index], index, array)) {
  45295. return index;
  45296. }
  45297. }
  45298. return -1;
  45299. }
  45300. /**
  45301. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  45302. *
  45303. * @private
  45304. * @param {Array} array The array to inspect.
  45305. * @param {*} value The value to search for.
  45306. * @param {number} fromIndex The index to search from.
  45307. * @returns {number} Returns the index of the matched value, else `-1`.
  45308. */
  45309. function baseIndexOf(array, value, fromIndex) {
  45310. return value === value
  45311. ? strictIndexOf(array, value, fromIndex)
  45312. : baseFindIndex(array, baseIsNaN, fromIndex);
  45313. }
  45314. /**
  45315. * This function is like `baseIndexOf` except that it accepts a comparator.
  45316. *
  45317. * @private
  45318. * @param {Array} array The array to inspect.
  45319. * @param {*} value The value to search for.
  45320. * @param {number} fromIndex The index to search from.
  45321. * @param {Function} comparator The comparator invoked per element.
  45322. * @returns {number} Returns the index of the matched value, else `-1`.
  45323. */
  45324. function baseIndexOfWith(array, value, fromIndex, comparator) {
  45325. var index = fromIndex - 1,
  45326. length = array.length;
  45327. while (++index < length) {
  45328. if (comparator(array[index], value)) {
  45329. return index;
  45330. }
  45331. }
  45332. return -1;
  45333. }
  45334. /**
  45335. * The base implementation of `_.isNaN` without support for number objects.
  45336. *
  45337. * @private
  45338. * @param {*} value The value to check.
  45339. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  45340. */
  45341. function baseIsNaN(value) {
  45342. return value !== value;
  45343. }
  45344. /**
  45345. * The base implementation of `_.mean` and `_.meanBy` without support for
  45346. * iteratee shorthands.
  45347. *
  45348. * @private
  45349. * @param {Array} array The array to iterate over.
  45350. * @param {Function} iteratee The function invoked per iteration.
  45351. * @returns {number} Returns the mean.
  45352. */
  45353. function baseMean(array, iteratee) {
  45354. var length = array == null ? 0 : array.length;
  45355. return length ? (baseSum(array, iteratee) / length) : NAN;
  45356. }
  45357. /**
  45358. * The base implementation of `_.property` without support for deep paths.
  45359. *
  45360. * @private
  45361. * @param {string} key The key of the property to get.
  45362. * @returns {Function} Returns the new accessor function.
  45363. */
  45364. function baseProperty(key) {
  45365. return function(object) {
  45366. return object == null ? undefined : object[key];
  45367. };
  45368. }
  45369. /**
  45370. * The base implementation of `_.propertyOf` without support for deep paths.
  45371. *
  45372. * @private
  45373. * @param {Object} object The object to query.
  45374. * @returns {Function} Returns the new accessor function.
  45375. */
  45376. function basePropertyOf(object) {
  45377. return function(key) {
  45378. return object == null ? undefined : object[key];
  45379. };
  45380. }
  45381. /**
  45382. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  45383. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  45384. *
  45385. * @private
  45386. * @param {Array|Object} collection The collection to iterate over.
  45387. * @param {Function} iteratee The function invoked per iteration.
  45388. * @param {*} accumulator The initial value.
  45389. * @param {boolean} initAccum Specify using the first or last element of
  45390. * `collection` as the initial value.
  45391. * @param {Function} eachFunc The function to iterate over `collection`.
  45392. * @returns {*} Returns the accumulated value.
  45393. */
  45394. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  45395. eachFunc(collection, function(value, index, collection) {
  45396. accumulator = initAccum
  45397. ? (initAccum = false, value)
  45398. : iteratee(accumulator, value, index, collection);
  45399. });
  45400. return accumulator;
  45401. }
  45402. /**
  45403. * The base implementation of `_.sortBy` which uses `comparer` to define the
  45404. * sort order of `array` and replaces criteria objects with their corresponding
  45405. * values.
  45406. *
  45407. * @private
  45408. * @param {Array} array The array to sort.
  45409. * @param {Function} comparer The function to define sort order.
  45410. * @returns {Array} Returns `array`.
  45411. */
  45412. function baseSortBy(array, comparer) {
  45413. var length = array.length;
  45414. array.sort(comparer);
  45415. while (length--) {
  45416. array[length] = array[length].value;
  45417. }
  45418. return array;
  45419. }
  45420. /**
  45421. * The base implementation of `_.sum` and `_.sumBy` without support for
  45422. * iteratee shorthands.
  45423. *
  45424. * @private
  45425. * @param {Array} array The array to iterate over.
  45426. * @param {Function} iteratee The function invoked per iteration.
  45427. * @returns {number} Returns the sum.
  45428. */
  45429. function baseSum(array, iteratee) {
  45430. var result,
  45431. index = -1,
  45432. length = array.length;
  45433. while (++index < length) {
  45434. var current = iteratee(array[index]);
  45435. if (current !== undefined) {
  45436. result = result === undefined ? current : (result + current);
  45437. }
  45438. }
  45439. return result;
  45440. }
  45441. /**
  45442. * The base implementation of `_.times` without support for iteratee shorthands
  45443. * or max array length checks.
  45444. *
  45445. * @private
  45446. * @param {number} n The number of times to invoke `iteratee`.
  45447. * @param {Function} iteratee The function invoked per iteration.
  45448. * @returns {Array} Returns the array of results.
  45449. */
  45450. function baseTimes(n, iteratee) {
  45451. var index = -1,
  45452. result = Array(n);
  45453. while (++index < n) {
  45454. result[index] = iteratee(index);
  45455. }
  45456. return result;
  45457. }
  45458. /**
  45459. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  45460. * of key-value pairs for `object` corresponding to the property names of `props`.
  45461. *
  45462. * @private
  45463. * @param {Object} object The object to query.
  45464. * @param {Array} props The property names to get values for.
  45465. * @returns {Object} Returns the key-value pairs.
  45466. */
  45467. function baseToPairs(object, props) {
  45468. return arrayMap(props, function(key) {
  45469. return [key, object[key]];
  45470. });
  45471. }
  45472. /**
  45473. * The base implementation of `_.trim`.
  45474. *
  45475. * @private
  45476. * @param {string} string The string to trim.
  45477. * @returns {string} Returns the trimmed string.
  45478. */
  45479. function baseTrim(string) {
  45480. return string
  45481. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  45482. : string;
  45483. }
  45484. /**
  45485. * The base implementation of `_.unary` without support for storing metadata.
  45486. *
  45487. * @private
  45488. * @param {Function} func The function to cap arguments for.
  45489. * @returns {Function} Returns the new capped function.
  45490. */
  45491. function baseUnary(func) {
  45492. return function(value) {
  45493. return func(value);
  45494. };
  45495. }
  45496. /**
  45497. * The base implementation of `_.values` and `_.valuesIn` which creates an
  45498. * array of `object` property values corresponding to the property names
  45499. * of `props`.
  45500. *
  45501. * @private
  45502. * @param {Object} object The object to query.
  45503. * @param {Array} props The property names to get values for.
  45504. * @returns {Object} Returns the array of property values.
  45505. */
  45506. function baseValues(object, props) {
  45507. return arrayMap(props, function(key) {
  45508. return object[key];
  45509. });
  45510. }
  45511. /**
  45512. * Checks if a `cache` value for `key` exists.
  45513. *
  45514. * @private
  45515. * @param {Object} cache The cache to query.
  45516. * @param {string} key The key of the entry to check.
  45517. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  45518. */
  45519. function cacheHas(cache, key) {
  45520. return cache.has(key);
  45521. }
  45522. /**
  45523. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  45524. * that is not found in the character symbols.
  45525. *
  45526. * @private
  45527. * @param {Array} strSymbols The string symbols to inspect.
  45528. * @param {Array} chrSymbols The character symbols to find.
  45529. * @returns {number} Returns the index of the first unmatched string symbol.
  45530. */
  45531. function charsStartIndex(strSymbols, chrSymbols) {
  45532. var index = -1,
  45533. length = strSymbols.length;
  45534. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  45535. return index;
  45536. }
  45537. /**
  45538. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  45539. * that is not found in the character symbols.
  45540. *
  45541. * @private
  45542. * @param {Array} strSymbols The string symbols to inspect.
  45543. * @param {Array} chrSymbols The character symbols to find.
  45544. * @returns {number} Returns the index of the last unmatched string symbol.
  45545. */
  45546. function charsEndIndex(strSymbols, chrSymbols) {
  45547. var index = strSymbols.length;
  45548. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  45549. return index;
  45550. }
  45551. /**
  45552. * Gets the number of `placeholder` occurrences in `array`.
  45553. *
  45554. * @private
  45555. * @param {Array} array The array to inspect.
  45556. * @param {*} placeholder The placeholder to search for.
  45557. * @returns {number} Returns the placeholder count.
  45558. */
  45559. function countHolders(array, placeholder) {
  45560. var length = array.length,
  45561. result = 0;
  45562. while (length--) {
  45563. if (array[length] === placeholder) {
  45564. ++result;
  45565. }
  45566. }
  45567. return result;
  45568. }
  45569. /**
  45570. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  45571. * letters to basic Latin letters.
  45572. *
  45573. * @private
  45574. * @param {string} letter The matched letter to deburr.
  45575. * @returns {string} Returns the deburred letter.
  45576. */
  45577. var deburrLetter = basePropertyOf(deburredLetters);
  45578. /**
  45579. * Used by `_.escape` to convert characters to HTML entities.
  45580. *
  45581. * @private
  45582. * @param {string} chr The matched character to escape.
  45583. * @returns {string} Returns the escaped character.
  45584. */
  45585. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  45586. /**
  45587. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  45588. *
  45589. * @private
  45590. * @param {string} chr The matched character to escape.
  45591. * @returns {string} Returns the escaped character.
  45592. */
  45593. function escapeStringChar(chr) {
  45594. return '\\' + stringEscapes[chr];
  45595. }
  45596. /**
  45597. * Gets the value at `key` of `object`.
  45598. *
  45599. * @private
  45600. * @param {Object} [object] The object to query.
  45601. * @param {string} key The key of the property to get.
  45602. * @returns {*} Returns the property value.
  45603. */
  45604. function getValue(object, key) {
  45605. return object == null ? undefined : object[key];
  45606. }
  45607. /**
  45608. * Checks if `string` contains Unicode symbols.
  45609. *
  45610. * @private
  45611. * @param {string} string The string to inspect.
  45612. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  45613. */
  45614. function hasUnicode(string) {
  45615. return reHasUnicode.test(string);
  45616. }
  45617. /**
  45618. * Checks if `string` contains a word composed of Unicode symbols.
  45619. *
  45620. * @private
  45621. * @param {string} string The string to inspect.
  45622. * @returns {boolean} Returns `true` if a word is found, else `false`.
  45623. */
  45624. function hasUnicodeWord(string) {
  45625. return reHasUnicodeWord.test(string);
  45626. }
  45627. /**
  45628. * Converts `iterator` to an array.
  45629. *
  45630. * @private
  45631. * @param {Object} iterator The iterator to convert.
  45632. * @returns {Array} Returns the converted array.
  45633. */
  45634. function iteratorToArray(iterator) {
  45635. var data,
  45636. result = [];
  45637. while (!(data = iterator.next()).done) {
  45638. result.push(data.value);
  45639. }
  45640. return result;
  45641. }
  45642. /**
  45643. * Converts `map` to its key-value pairs.
  45644. *
  45645. * @private
  45646. * @param {Object} map The map to convert.
  45647. * @returns {Array} Returns the key-value pairs.
  45648. */
  45649. function mapToArray(map) {
  45650. var index = -1,
  45651. result = Array(map.size);
  45652. map.forEach(function(value, key) {
  45653. result[++index] = [key, value];
  45654. });
  45655. return result;
  45656. }
  45657. /**
  45658. * Creates a unary function that invokes `func` with its argument transformed.
  45659. *
  45660. * @private
  45661. * @param {Function} func The function to wrap.
  45662. * @param {Function} transform The argument transform.
  45663. * @returns {Function} Returns the new function.
  45664. */
  45665. function overArg(func, transform) {
  45666. return function(arg) {
  45667. return func(transform(arg));
  45668. };
  45669. }
  45670. /**
  45671. * Replaces all `placeholder` elements in `array` with an internal placeholder
  45672. * and returns an array of their indexes.
  45673. *
  45674. * @private
  45675. * @param {Array} array The array to modify.
  45676. * @param {*} placeholder The placeholder to replace.
  45677. * @returns {Array} Returns the new array of placeholder indexes.
  45678. */
  45679. function replaceHolders(array, placeholder) {
  45680. var index = -1,
  45681. length = array.length,
  45682. resIndex = 0,
  45683. result = [];
  45684. while (++index < length) {
  45685. var value = array[index];
  45686. if (value === placeholder || value === PLACEHOLDER) {
  45687. array[index] = PLACEHOLDER;
  45688. result[resIndex++] = index;
  45689. }
  45690. }
  45691. return result;
  45692. }
  45693. /**
  45694. * Converts `set` to an array of its values.
  45695. *
  45696. * @private
  45697. * @param {Object} set The set to convert.
  45698. * @returns {Array} Returns the values.
  45699. */
  45700. function setToArray(set) {
  45701. var index = -1,
  45702. result = Array(set.size);
  45703. set.forEach(function(value) {
  45704. result[++index] = value;
  45705. });
  45706. return result;
  45707. }
  45708. /**
  45709. * Converts `set` to its value-value pairs.
  45710. *
  45711. * @private
  45712. * @param {Object} set The set to convert.
  45713. * @returns {Array} Returns the value-value pairs.
  45714. */
  45715. function setToPairs(set) {
  45716. var index = -1,
  45717. result = Array(set.size);
  45718. set.forEach(function(value) {
  45719. result[++index] = [value, value];
  45720. });
  45721. return result;
  45722. }
  45723. /**
  45724. * A specialized version of `_.indexOf` which performs strict equality
  45725. * comparisons of values, i.e. `===`.
  45726. *
  45727. * @private
  45728. * @param {Array} array The array to inspect.
  45729. * @param {*} value The value to search for.
  45730. * @param {number} fromIndex The index to search from.
  45731. * @returns {number} Returns the index of the matched value, else `-1`.
  45732. */
  45733. function strictIndexOf(array, value, fromIndex) {
  45734. var index = fromIndex - 1,
  45735. length = array.length;
  45736. while (++index < length) {
  45737. if (array[index] === value) {
  45738. return index;
  45739. }
  45740. }
  45741. return -1;
  45742. }
  45743. /**
  45744. * A specialized version of `_.lastIndexOf` which performs strict equality
  45745. * comparisons of values, i.e. `===`.
  45746. *
  45747. * @private
  45748. * @param {Array} array The array to inspect.
  45749. * @param {*} value The value to search for.
  45750. * @param {number} fromIndex The index to search from.
  45751. * @returns {number} Returns the index of the matched value, else `-1`.
  45752. */
  45753. function strictLastIndexOf(array, value, fromIndex) {
  45754. var index = fromIndex + 1;
  45755. while (index--) {
  45756. if (array[index] === value) {
  45757. return index;
  45758. }
  45759. }
  45760. return index;
  45761. }
  45762. /**
  45763. * Gets the number of symbols in `string`.
  45764. *
  45765. * @private
  45766. * @param {string} string The string to inspect.
  45767. * @returns {number} Returns the string size.
  45768. */
  45769. function stringSize(string) {
  45770. return hasUnicode(string)
  45771. ? unicodeSize(string)
  45772. : asciiSize(string);
  45773. }
  45774. /**
  45775. * Converts `string` to an array.
  45776. *
  45777. * @private
  45778. * @param {string} string The string to convert.
  45779. * @returns {Array} Returns the converted array.
  45780. */
  45781. function stringToArray(string) {
  45782. return hasUnicode(string)
  45783. ? unicodeToArray(string)
  45784. : asciiToArray(string);
  45785. }
  45786. /**
  45787. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  45788. * character of `string`.
  45789. *
  45790. * @private
  45791. * @param {string} string The string to inspect.
  45792. * @returns {number} Returns the index of the last non-whitespace character.
  45793. */
  45794. function trimmedEndIndex(string) {
  45795. var index = string.length;
  45796. while (index-- && reWhitespace.test(string.charAt(index))) {}
  45797. return index;
  45798. }
  45799. /**
  45800. * Used by `_.unescape` to convert HTML entities to characters.
  45801. *
  45802. * @private
  45803. * @param {string} chr The matched character to unescape.
  45804. * @returns {string} Returns the unescaped character.
  45805. */
  45806. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  45807. /**
  45808. * Gets the size of a Unicode `string`.
  45809. *
  45810. * @private
  45811. * @param {string} string The string inspect.
  45812. * @returns {number} Returns the string size.
  45813. */
  45814. function unicodeSize(string) {
  45815. var result = reUnicode.lastIndex = 0;
  45816. while (reUnicode.test(string)) {
  45817. ++result;
  45818. }
  45819. return result;
  45820. }
  45821. /**
  45822. * Converts a Unicode `string` to an array.
  45823. *
  45824. * @private
  45825. * @param {string} string The string to convert.
  45826. * @returns {Array} Returns the converted array.
  45827. */
  45828. function unicodeToArray(string) {
  45829. return string.match(reUnicode) || [];
  45830. }
  45831. /**
  45832. * Splits a Unicode `string` into an array of its words.
  45833. *
  45834. * @private
  45835. * @param {string} The string to inspect.
  45836. * @returns {Array} Returns the words of `string`.
  45837. */
  45838. function unicodeWords(string) {
  45839. return string.match(reUnicodeWord) || [];
  45840. }
  45841. /*--------------------------------------------------------------------------*/
  45842. /**
  45843. * Create a new pristine `lodash` function using the `context` object.
  45844. *
  45845. * @static
  45846. * @memberOf _
  45847. * @since 1.1.0
  45848. * @category Util
  45849. * @param {Object} [context=root] The context object.
  45850. * @returns {Function} Returns a new `lodash` function.
  45851. * @example
  45852. *
  45853. * _.mixin({ 'foo': _.constant('foo') });
  45854. *
  45855. * var lodash = _.runInContext();
  45856. * lodash.mixin({ 'bar': lodash.constant('bar') });
  45857. *
  45858. * _.isFunction(_.foo);
  45859. * // => true
  45860. * _.isFunction(_.bar);
  45861. * // => false
  45862. *
  45863. * lodash.isFunction(lodash.foo);
  45864. * // => false
  45865. * lodash.isFunction(lodash.bar);
  45866. * // => true
  45867. *
  45868. * // Create a suped-up `defer` in Node.js.
  45869. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  45870. */
  45871. var runInContext = (function runInContext(context) {
  45872. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  45873. /** Built-in constructor references. */
  45874. var Array = context.Array,
  45875. Date = context.Date,
  45876. Error = context.Error,
  45877. Function = context.Function,
  45878. Math = context.Math,
  45879. Object = context.Object,
  45880. RegExp = context.RegExp,
  45881. String = context.String,
  45882. TypeError = context.TypeError;
  45883. /** Used for built-in method references. */
  45884. var arrayProto = Array.prototype,
  45885. funcProto = Function.prototype,
  45886. objectProto = Object.prototype;
  45887. /** Used to detect overreaching core-js shims. */
  45888. var coreJsData = context['__core-js_shared__'];
  45889. /** Used to resolve the decompiled source of functions. */
  45890. var funcToString = funcProto.toString;
  45891. /** Used to check objects for own properties. */
  45892. var hasOwnProperty = objectProto.hasOwnProperty;
  45893. /** Used to generate unique IDs. */
  45894. var idCounter = 0;
  45895. /** Used to detect methods masquerading as native. */
  45896. var maskSrcKey = (function() {
  45897. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  45898. return uid ? ('Symbol(src)_1.' + uid) : '';
  45899. }());
  45900. /**
  45901. * Used to resolve the
  45902. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  45903. * of values.
  45904. */
  45905. var nativeObjectToString = objectProto.toString;
  45906. /** Used to infer the `Object` constructor. */
  45907. var objectCtorString = funcToString.call(Object);
  45908. /** Used to restore the original `_` reference in `_.noConflict`. */
  45909. var oldDash = root._;
  45910. /** Used to detect if a method is native. */
  45911. var reIsNative = RegExp('^' +
  45912. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  45913. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  45914. );
  45915. /** Built-in value references. */
  45916. var Buffer = moduleExports ? context.Buffer : undefined,
  45917. Symbol = context.Symbol,
  45918. Uint8Array = context.Uint8Array,
  45919. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  45920. getPrototype = overArg(Object.getPrototypeOf, Object),
  45921. objectCreate = Object.create,
  45922. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  45923. splice = arrayProto.splice,
  45924. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  45925. symIterator = Symbol ? Symbol.iterator : undefined,
  45926. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  45927. var defineProperty = (function() {
  45928. try {
  45929. var func = getNative(Object, 'defineProperty');
  45930. func({}, '', {});
  45931. return func;
  45932. } catch (e) {}
  45933. }());
  45934. /** Mocked built-ins. */
  45935. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  45936. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  45937. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  45938. /* Built-in method references for those with the same name as other `lodash` methods. */
  45939. var nativeCeil = Math.ceil,
  45940. nativeFloor = Math.floor,
  45941. nativeGetSymbols = Object.getOwnPropertySymbols,
  45942. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  45943. nativeIsFinite = context.isFinite,
  45944. nativeJoin = arrayProto.join,
  45945. nativeKeys = overArg(Object.keys, Object),
  45946. nativeMax = Math.max,
  45947. nativeMin = Math.min,
  45948. nativeNow = Date.now,
  45949. nativeParseInt = context.parseInt,
  45950. nativeRandom = Math.random,
  45951. nativeReverse = arrayProto.reverse;
  45952. /* Built-in method references that are verified to be native. */
  45953. var DataView = getNative(context, 'DataView'),
  45954. Map = getNative(context, 'Map'),
  45955. Promise = getNative(context, 'Promise'),
  45956. Set = getNative(context, 'Set'),
  45957. WeakMap = getNative(context, 'WeakMap'),
  45958. nativeCreate = getNative(Object, 'create');
  45959. /** Used to store function metadata. */
  45960. var metaMap = WeakMap && new WeakMap;
  45961. /** Used to lookup unminified function names. */
  45962. var realNames = {};
  45963. /** Used to detect maps, sets, and weakmaps. */
  45964. var dataViewCtorString = toSource(DataView),
  45965. mapCtorString = toSource(Map),
  45966. promiseCtorString = toSource(Promise),
  45967. setCtorString = toSource(Set),
  45968. weakMapCtorString = toSource(WeakMap);
  45969. /** Used to convert symbols to primitives and strings. */
  45970. var symbolProto = Symbol ? Symbol.prototype : undefined,
  45971. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  45972. symbolToString = symbolProto ? symbolProto.toString : undefined;
  45973. /*------------------------------------------------------------------------*/
  45974. /**
  45975. * Creates a `lodash` object which wraps `value` to enable implicit method
  45976. * chain sequences. Methods that operate on and return arrays, collections,
  45977. * and functions can be chained together. Methods that retrieve a single value
  45978. * or may return a primitive value will automatically end the chain sequence
  45979. * and return the unwrapped value. Otherwise, the value must be unwrapped
  45980. * with `_#value`.
  45981. *
  45982. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  45983. * enabled using `_.chain`.
  45984. *
  45985. * The execution of chained methods is lazy, that is, it's deferred until
  45986. * `_#value` is implicitly or explicitly called.
  45987. *
  45988. * Lazy evaluation allows several methods to support shortcut fusion.
  45989. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  45990. * the creation of intermediate arrays and can greatly reduce the number of
  45991. * iteratee executions. Sections of a chain sequence qualify for shortcut
  45992. * fusion if the section is applied to an array and iteratees accept only
  45993. * one argument. The heuristic for whether a section qualifies for shortcut
  45994. * fusion is subject to change.
  45995. *
  45996. * Chaining is supported in custom builds as long as the `_#value` method is
  45997. * directly or indirectly included in the build.
  45998. *
  45999. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  46000. *
  46001. * The wrapper `Array` methods are:
  46002. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  46003. *
  46004. * The wrapper `String` methods are:
  46005. * `replace` and `split`
  46006. *
  46007. * The wrapper methods that support shortcut fusion are:
  46008. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  46009. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  46010. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  46011. *
  46012. * The chainable wrapper methods are:
  46013. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  46014. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  46015. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  46016. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  46017. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  46018. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  46019. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  46020. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  46021. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  46022. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  46023. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  46024. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  46025. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  46026. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  46027. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  46028. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  46029. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  46030. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  46031. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  46032. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  46033. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  46034. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  46035. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  46036. * `zipObject`, `zipObjectDeep`, and `zipWith`
  46037. *
  46038. * The wrapper methods that are **not** chainable by default are:
  46039. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  46040. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  46041. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  46042. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  46043. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  46044. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  46045. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  46046. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  46047. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  46048. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  46049. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  46050. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  46051. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  46052. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  46053. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  46054. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  46055. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  46056. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  46057. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  46058. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  46059. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  46060. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  46061. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  46062. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  46063. * `upperFirst`, `value`, and `words`
  46064. *
  46065. * @name _
  46066. * @constructor
  46067. * @category Seq
  46068. * @param {*} value The value to wrap in a `lodash` instance.
  46069. * @returns {Object} Returns the new `lodash` wrapper instance.
  46070. * @example
  46071. *
  46072. * function square(n) {
  46073. * return n * n;
  46074. * }
  46075. *
  46076. * var wrapped = _([1, 2, 3]);
  46077. *
  46078. * // Returns an unwrapped value.
  46079. * wrapped.reduce(_.add);
  46080. * // => 6
  46081. *
  46082. * // Returns a wrapped value.
  46083. * var squares = wrapped.map(square);
  46084. *
  46085. * _.isArray(squares);
  46086. * // => false
  46087. *
  46088. * _.isArray(squares.value());
  46089. * // => true
  46090. */
  46091. function lodash(value) {
  46092. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  46093. if (value instanceof LodashWrapper) {
  46094. return value;
  46095. }
  46096. if (hasOwnProperty.call(value, '__wrapped__')) {
  46097. return wrapperClone(value);
  46098. }
  46099. }
  46100. return new LodashWrapper(value);
  46101. }
  46102. /**
  46103. * The base implementation of `_.create` without support for assigning
  46104. * properties to the created object.
  46105. *
  46106. * @private
  46107. * @param {Object} proto The object to inherit from.
  46108. * @returns {Object} Returns the new object.
  46109. */
  46110. var baseCreate = (function() {
  46111. function object() {}
  46112. return function(proto) {
  46113. if (!isObject(proto)) {
  46114. return {};
  46115. }
  46116. if (objectCreate) {
  46117. return objectCreate(proto);
  46118. }
  46119. object.prototype = proto;
  46120. var result = new object;
  46121. object.prototype = undefined;
  46122. return result;
  46123. };
  46124. }());
  46125. /**
  46126. * The function whose prototype chain sequence wrappers inherit from.
  46127. *
  46128. * @private
  46129. */
  46130. function baseLodash() {
  46131. // No operation performed.
  46132. }
  46133. /**
  46134. * The base constructor for creating `lodash` wrapper objects.
  46135. *
  46136. * @private
  46137. * @param {*} value The value to wrap.
  46138. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  46139. */
  46140. function LodashWrapper(value, chainAll) {
  46141. this.__wrapped__ = value;
  46142. this.__actions__ = [];
  46143. this.__chain__ = !!chainAll;
  46144. this.__index__ = 0;
  46145. this.__values__ = undefined;
  46146. }
  46147. /**
  46148. * By default, the template delimiters used by lodash are like those in
  46149. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  46150. * following template settings to use alternative delimiters.
  46151. *
  46152. * @static
  46153. * @memberOf _
  46154. * @type {Object}
  46155. */
  46156. lodash.templateSettings = {
  46157. /**
  46158. * Used to detect `data` property values to be HTML-escaped.
  46159. *
  46160. * @memberOf _.templateSettings
  46161. * @type {RegExp}
  46162. */
  46163. 'escape': reEscape,
  46164. /**
  46165. * Used to detect code to be evaluated.
  46166. *
  46167. * @memberOf _.templateSettings
  46168. * @type {RegExp}
  46169. */
  46170. 'evaluate': reEvaluate,
  46171. /**
  46172. * Used to detect `data` property values to inject.
  46173. *
  46174. * @memberOf _.templateSettings
  46175. * @type {RegExp}
  46176. */
  46177. 'interpolate': reInterpolate,
  46178. /**
  46179. * Used to reference the data object in the template text.
  46180. *
  46181. * @memberOf _.templateSettings
  46182. * @type {string}
  46183. */
  46184. 'variable': '',
  46185. /**
  46186. * Used to import variables into the compiled template.
  46187. *
  46188. * @memberOf _.templateSettings
  46189. * @type {Object}
  46190. */
  46191. 'imports': {
  46192. /**
  46193. * A reference to the `lodash` function.
  46194. *
  46195. * @memberOf _.templateSettings.imports
  46196. * @type {Function}
  46197. */
  46198. '_': lodash
  46199. }
  46200. };
  46201. // Ensure wrappers are instances of `baseLodash`.
  46202. lodash.prototype = baseLodash.prototype;
  46203. lodash.prototype.constructor = lodash;
  46204. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  46205. LodashWrapper.prototype.constructor = LodashWrapper;
  46206. /*------------------------------------------------------------------------*/
  46207. /**
  46208. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  46209. *
  46210. * @private
  46211. * @constructor
  46212. * @param {*} value The value to wrap.
  46213. */
  46214. function LazyWrapper(value) {
  46215. this.__wrapped__ = value;
  46216. this.__actions__ = [];
  46217. this.__dir__ = 1;
  46218. this.__filtered__ = false;
  46219. this.__iteratees__ = [];
  46220. this.__takeCount__ = MAX_ARRAY_LENGTH;
  46221. this.__views__ = [];
  46222. }
  46223. /**
  46224. * Creates a clone of the lazy wrapper object.
  46225. *
  46226. * @private
  46227. * @name clone
  46228. * @memberOf LazyWrapper
  46229. * @returns {Object} Returns the cloned `LazyWrapper` object.
  46230. */
  46231. function lazyClone() {
  46232. var result = new LazyWrapper(this.__wrapped__);
  46233. result.__actions__ = copyArray(this.__actions__);
  46234. result.__dir__ = this.__dir__;
  46235. result.__filtered__ = this.__filtered__;
  46236. result.__iteratees__ = copyArray(this.__iteratees__);
  46237. result.__takeCount__ = this.__takeCount__;
  46238. result.__views__ = copyArray(this.__views__);
  46239. return result;
  46240. }
  46241. /**
  46242. * Reverses the direction of lazy iteration.
  46243. *
  46244. * @private
  46245. * @name reverse
  46246. * @memberOf LazyWrapper
  46247. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  46248. */
  46249. function lazyReverse() {
  46250. if (this.__filtered__) {
  46251. var result = new LazyWrapper(this);
  46252. result.__dir__ = -1;
  46253. result.__filtered__ = true;
  46254. } else {
  46255. result = this.clone();
  46256. result.__dir__ *= -1;
  46257. }
  46258. return result;
  46259. }
  46260. /**
  46261. * Extracts the unwrapped value from its lazy wrapper.
  46262. *
  46263. * @private
  46264. * @name value
  46265. * @memberOf LazyWrapper
  46266. * @returns {*} Returns the unwrapped value.
  46267. */
  46268. function lazyValue() {
  46269. var array = this.__wrapped__.value(),
  46270. dir = this.__dir__,
  46271. isArr = isArray(array),
  46272. isRight = dir < 0,
  46273. arrLength = isArr ? array.length : 0,
  46274. view = getView(0, arrLength, this.__views__),
  46275. start = view.start,
  46276. end = view.end,
  46277. length = end - start,
  46278. index = isRight ? end : (start - 1),
  46279. iteratees = this.__iteratees__,
  46280. iterLength = iteratees.length,
  46281. resIndex = 0,
  46282. takeCount = nativeMin(length, this.__takeCount__);
  46283. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  46284. return baseWrapperValue(array, this.__actions__);
  46285. }
  46286. var result = [];
  46287. outer:
  46288. while (length-- && resIndex < takeCount) {
  46289. index += dir;
  46290. var iterIndex = -1,
  46291. value = array[index];
  46292. while (++iterIndex < iterLength) {
  46293. var data = iteratees[iterIndex],
  46294. iteratee = data.iteratee,
  46295. type = data.type,
  46296. computed = iteratee(value);
  46297. if (type == LAZY_MAP_FLAG) {
  46298. value = computed;
  46299. } else if (!computed) {
  46300. if (type == LAZY_FILTER_FLAG) {
  46301. continue outer;
  46302. } else {
  46303. break outer;
  46304. }
  46305. }
  46306. }
  46307. result[resIndex++] = value;
  46308. }
  46309. return result;
  46310. }
  46311. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  46312. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  46313. LazyWrapper.prototype.constructor = LazyWrapper;
  46314. /*------------------------------------------------------------------------*/
  46315. /**
  46316. * Creates a hash object.
  46317. *
  46318. * @private
  46319. * @constructor
  46320. * @param {Array} [entries] The key-value pairs to cache.
  46321. */
  46322. function Hash(entries) {
  46323. var index = -1,
  46324. length = entries == null ? 0 : entries.length;
  46325. this.clear();
  46326. while (++index < length) {
  46327. var entry = entries[index];
  46328. this.set(entry[0], entry[1]);
  46329. }
  46330. }
  46331. /**
  46332. * Removes all key-value entries from the hash.
  46333. *
  46334. * @private
  46335. * @name clear
  46336. * @memberOf Hash
  46337. */
  46338. function hashClear() {
  46339. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  46340. this.size = 0;
  46341. }
  46342. /**
  46343. * Removes `key` and its value from the hash.
  46344. *
  46345. * @private
  46346. * @name delete
  46347. * @memberOf Hash
  46348. * @param {Object} hash The hash to modify.
  46349. * @param {string} key The key of the value to remove.
  46350. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  46351. */
  46352. function hashDelete(key) {
  46353. var result = this.has(key) && delete this.__data__[key];
  46354. this.size -= result ? 1 : 0;
  46355. return result;
  46356. }
  46357. /**
  46358. * Gets the hash value for `key`.
  46359. *
  46360. * @private
  46361. * @name get
  46362. * @memberOf Hash
  46363. * @param {string} key The key of the value to get.
  46364. * @returns {*} Returns the entry value.
  46365. */
  46366. function hashGet(key) {
  46367. var data = this.__data__;
  46368. if (nativeCreate) {
  46369. var result = data[key];
  46370. return result === HASH_UNDEFINED ? undefined : result;
  46371. }
  46372. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  46373. }
  46374. /**
  46375. * Checks if a hash value for `key` exists.
  46376. *
  46377. * @private
  46378. * @name has
  46379. * @memberOf Hash
  46380. * @param {string} key The key of the entry to check.
  46381. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  46382. */
  46383. function hashHas(key) {
  46384. var data = this.__data__;
  46385. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  46386. }
  46387. /**
  46388. * Sets the hash `key` to `value`.
  46389. *
  46390. * @private
  46391. * @name set
  46392. * @memberOf Hash
  46393. * @param {string} key The key of the value to set.
  46394. * @param {*} value The value to set.
  46395. * @returns {Object} Returns the hash instance.
  46396. */
  46397. function hashSet(key, value) {
  46398. var data = this.__data__;
  46399. this.size += this.has(key) ? 0 : 1;
  46400. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  46401. return this;
  46402. }
  46403. // Add methods to `Hash`.
  46404. Hash.prototype.clear = hashClear;
  46405. Hash.prototype['delete'] = hashDelete;
  46406. Hash.prototype.get = hashGet;
  46407. Hash.prototype.has = hashHas;
  46408. Hash.prototype.set = hashSet;
  46409. /*------------------------------------------------------------------------*/
  46410. /**
  46411. * Creates an list cache object.
  46412. *
  46413. * @private
  46414. * @constructor
  46415. * @param {Array} [entries] The key-value pairs to cache.
  46416. */
  46417. function ListCache(entries) {
  46418. var index = -1,
  46419. length = entries == null ? 0 : entries.length;
  46420. this.clear();
  46421. while (++index < length) {
  46422. var entry = entries[index];
  46423. this.set(entry[0], entry[1]);
  46424. }
  46425. }
  46426. /**
  46427. * Removes all key-value entries from the list cache.
  46428. *
  46429. * @private
  46430. * @name clear
  46431. * @memberOf ListCache
  46432. */
  46433. function listCacheClear() {
  46434. this.__data__ = [];
  46435. this.size = 0;
  46436. }
  46437. /**
  46438. * Removes `key` and its value from the list cache.
  46439. *
  46440. * @private
  46441. * @name delete
  46442. * @memberOf ListCache
  46443. * @param {string} key The key of the value to remove.
  46444. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  46445. */
  46446. function listCacheDelete(key) {
  46447. var data = this.__data__,
  46448. index = assocIndexOf(data, key);
  46449. if (index < 0) {
  46450. return false;
  46451. }
  46452. var lastIndex = data.length - 1;
  46453. if (index == lastIndex) {
  46454. data.pop();
  46455. } else {
  46456. splice.call(data, index, 1);
  46457. }
  46458. --this.size;
  46459. return true;
  46460. }
  46461. /**
  46462. * Gets the list cache value for `key`.
  46463. *
  46464. * @private
  46465. * @name get
  46466. * @memberOf ListCache
  46467. * @param {string} key The key of the value to get.
  46468. * @returns {*} Returns the entry value.
  46469. */
  46470. function listCacheGet(key) {
  46471. var data = this.__data__,
  46472. index = assocIndexOf(data, key);
  46473. return index < 0 ? undefined : data[index][1];
  46474. }
  46475. /**
  46476. * Checks if a list cache value for `key` exists.
  46477. *
  46478. * @private
  46479. * @name has
  46480. * @memberOf ListCache
  46481. * @param {string} key The key of the entry to check.
  46482. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  46483. */
  46484. function listCacheHas(key) {
  46485. return assocIndexOf(this.__data__, key) > -1;
  46486. }
  46487. /**
  46488. * Sets the list cache `key` to `value`.
  46489. *
  46490. * @private
  46491. * @name set
  46492. * @memberOf ListCache
  46493. * @param {string} key The key of the value to set.
  46494. * @param {*} value The value to set.
  46495. * @returns {Object} Returns the list cache instance.
  46496. */
  46497. function listCacheSet(key, value) {
  46498. var data = this.__data__,
  46499. index = assocIndexOf(data, key);
  46500. if (index < 0) {
  46501. ++this.size;
  46502. data.push([key, value]);
  46503. } else {
  46504. data[index][1] = value;
  46505. }
  46506. return this;
  46507. }
  46508. // Add methods to `ListCache`.
  46509. ListCache.prototype.clear = listCacheClear;
  46510. ListCache.prototype['delete'] = listCacheDelete;
  46511. ListCache.prototype.get = listCacheGet;
  46512. ListCache.prototype.has = listCacheHas;
  46513. ListCache.prototype.set = listCacheSet;
  46514. /*------------------------------------------------------------------------*/
  46515. /**
  46516. * Creates a map cache object to store key-value pairs.
  46517. *
  46518. * @private
  46519. * @constructor
  46520. * @param {Array} [entries] The key-value pairs to cache.
  46521. */
  46522. function MapCache(entries) {
  46523. var index = -1,
  46524. length = entries == null ? 0 : entries.length;
  46525. this.clear();
  46526. while (++index < length) {
  46527. var entry = entries[index];
  46528. this.set(entry[0], entry[1]);
  46529. }
  46530. }
  46531. /**
  46532. * Removes all key-value entries from the map.
  46533. *
  46534. * @private
  46535. * @name clear
  46536. * @memberOf MapCache
  46537. */
  46538. function mapCacheClear() {
  46539. this.size = 0;
  46540. this.__data__ = {
  46541. 'hash': new Hash,
  46542. 'map': new (Map || ListCache),
  46543. 'string': new Hash
  46544. };
  46545. }
  46546. /**
  46547. * Removes `key` and its value from the map.
  46548. *
  46549. * @private
  46550. * @name delete
  46551. * @memberOf MapCache
  46552. * @param {string} key The key of the value to remove.
  46553. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  46554. */
  46555. function mapCacheDelete(key) {
  46556. var result = getMapData(this, key)['delete'](key);
  46557. this.size -= result ? 1 : 0;
  46558. return result;
  46559. }
  46560. /**
  46561. * Gets the map value for `key`.
  46562. *
  46563. * @private
  46564. * @name get
  46565. * @memberOf MapCache
  46566. * @param {string} key The key of the value to get.
  46567. * @returns {*} Returns the entry value.
  46568. */
  46569. function mapCacheGet(key) {
  46570. return getMapData(this, key).get(key);
  46571. }
  46572. /**
  46573. * Checks if a map value for `key` exists.
  46574. *
  46575. * @private
  46576. * @name has
  46577. * @memberOf MapCache
  46578. * @param {string} key The key of the entry to check.
  46579. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  46580. */
  46581. function mapCacheHas(key) {
  46582. return getMapData(this, key).has(key);
  46583. }
  46584. /**
  46585. * Sets the map `key` to `value`.
  46586. *
  46587. * @private
  46588. * @name set
  46589. * @memberOf MapCache
  46590. * @param {string} key The key of the value to set.
  46591. * @param {*} value The value to set.
  46592. * @returns {Object} Returns the map cache instance.
  46593. */
  46594. function mapCacheSet(key, value) {
  46595. var data = getMapData(this, key),
  46596. size = data.size;
  46597. data.set(key, value);
  46598. this.size += data.size == size ? 0 : 1;
  46599. return this;
  46600. }
  46601. // Add methods to `MapCache`.
  46602. MapCache.prototype.clear = mapCacheClear;
  46603. MapCache.prototype['delete'] = mapCacheDelete;
  46604. MapCache.prototype.get = mapCacheGet;
  46605. MapCache.prototype.has = mapCacheHas;
  46606. MapCache.prototype.set = mapCacheSet;
  46607. /*------------------------------------------------------------------------*/
  46608. /**
  46609. *
  46610. * Creates an array cache object to store unique values.
  46611. *
  46612. * @private
  46613. * @constructor
  46614. * @param {Array} [values] The values to cache.
  46615. */
  46616. function SetCache(values) {
  46617. var index = -1,
  46618. length = values == null ? 0 : values.length;
  46619. this.__data__ = new MapCache;
  46620. while (++index < length) {
  46621. this.add(values[index]);
  46622. }
  46623. }
  46624. /**
  46625. * Adds `value` to the array cache.
  46626. *
  46627. * @private
  46628. * @name add
  46629. * @memberOf SetCache
  46630. * @alias push
  46631. * @param {*} value The value to cache.
  46632. * @returns {Object} Returns the cache instance.
  46633. */
  46634. function setCacheAdd(value) {
  46635. this.__data__.set(value, HASH_UNDEFINED);
  46636. return this;
  46637. }
  46638. /**
  46639. * Checks if `value` is in the array cache.
  46640. *
  46641. * @private
  46642. * @name has
  46643. * @memberOf SetCache
  46644. * @param {*} value The value to search for.
  46645. * @returns {number} Returns `true` if `value` is found, else `false`.
  46646. */
  46647. function setCacheHas(value) {
  46648. return this.__data__.has(value);
  46649. }
  46650. // Add methods to `SetCache`.
  46651. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  46652. SetCache.prototype.has = setCacheHas;
  46653. /*------------------------------------------------------------------------*/
  46654. /**
  46655. * Creates a stack cache object to store key-value pairs.
  46656. *
  46657. * @private
  46658. * @constructor
  46659. * @param {Array} [entries] The key-value pairs to cache.
  46660. */
  46661. function Stack(entries) {
  46662. var data = this.__data__ = new ListCache(entries);
  46663. this.size = data.size;
  46664. }
  46665. /**
  46666. * Removes all key-value entries from the stack.
  46667. *
  46668. * @private
  46669. * @name clear
  46670. * @memberOf Stack
  46671. */
  46672. function stackClear() {
  46673. this.__data__ = new ListCache;
  46674. this.size = 0;
  46675. }
  46676. /**
  46677. * Removes `key` and its value from the stack.
  46678. *
  46679. * @private
  46680. * @name delete
  46681. * @memberOf Stack
  46682. * @param {string} key The key of the value to remove.
  46683. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  46684. */
  46685. function stackDelete(key) {
  46686. var data = this.__data__,
  46687. result = data['delete'](key);
  46688. this.size = data.size;
  46689. return result;
  46690. }
  46691. /**
  46692. * Gets the stack value for `key`.
  46693. *
  46694. * @private
  46695. * @name get
  46696. * @memberOf Stack
  46697. * @param {string} key The key of the value to get.
  46698. * @returns {*} Returns the entry value.
  46699. */
  46700. function stackGet(key) {
  46701. return this.__data__.get(key);
  46702. }
  46703. /**
  46704. * Checks if a stack value for `key` exists.
  46705. *
  46706. * @private
  46707. * @name has
  46708. * @memberOf Stack
  46709. * @param {string} key The key of the entry to check.
  46710. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  46711. */
  46712. function stackHas(key) {
  46713. return this.__data__.has(key);
  46714. }
  46715. /**
  46716. * Sets the stack `key` to `value`.
  46717. *
  46718. * @private
  46719. * @name set
  46720. * @memberOf Stack
  46721. * @param {string} key The key of the value to set.
  46722. * @param {*} value The value to set.
  46723. * @returns {Object} Returns the stack cache instance.
  46724. */
  46725. function stackSet(key, value) {
  46726. var data = this.__data__;
  46727. if (data instanceof ListCache) {
  46728. var pairs = data.__data__;
  46729. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  46730. pairs.push([key, value]);
  46731. this.size = ++data.size;
  46732. return this;
  46733. }
  46734. data = this.__data__ = new MapCache(pairs);
  46735. }
  46736. data.set(key, value);
  46737. this.size = data.size;
  46738. return this;
  46739. }
  46740. // Add methods to `Stack`.
  46741. Stack.prototype.clear = stackClear;
  46742. Stack.prototype['delete'] = stackDelete;
  46743. Stack.prototype.get = stackGet;
  46744. Stack.prototype.has = stackHas;
  46745. Stack.prototype.set = stackSet;
  46746. /*------------------------------------------------------------------------*/
  46747. /**
  46748. * Creates an array of the enumerable property names of the array-like `value`.
  46749. *
  46750. * @private
  46751. * @param {*} value The value to query.
  46752. * @param {boolean} inherited Specify returning inherited property names.
  46753. * @returns {Array} Returns the array of property names.
  46754. */
  46755. function arrayLikeKeys(value, inherited) {
  46756. var isArr = isArray(value),
  46757. isArg = !isArr && isArguments(value),
  46758. isBuff = !isArr && !isArg && isBuffer(value),
  46759. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  46760. skipIndexes = isArr || isArg || isBuff || isType,
  46761. result = skipIndexes ? baseTimes(value.length, String) : [],
  46762. length = result.length;
  46763. for (var key in value) {
  46764. if ((inherited || hasOwnProperty.call(value, key)) &&
  46765. !(skipIndexes && (
  46766. // Safari 9 has enumerable `arguments.length` in strict mode.
  46767. key == 'length' ||
  46768. // Node.js 0.10 has enumerable non-index properties on buffers.
  46769. (isBuff && (key == 'offset' || key == 'parent')) ||
  46770. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  46771. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  46772. // Skip index properties.
  46773. isIndex(key, length)
  46774. ))) {
  46775. result.push(key);
  46776. }
  46777. }
  46778. return result;
  46779. }
  46780. /**
  46781. * A specialized version of `_.sample` for arrays.
  46782. *
  46783. * @private
  46784. * @param {Array} array The array to sample.
  46785. * @returns {*} Returns the random element.
  46786. */
  46787. function arraySample(array) {
  46788. var length = array.length;
  46789. return length ? array[baseRandom(0, length - 1)] : undefined;
  46790. }
  46791. /**
  46792. * A specialized version of `_.sampleSize` for arrays.
  46793. *
  46794. * @private
  46795. * @param {Array} array The array to sample.
  46796. * @param {number} n The number of elements to sample.
  46797. * @returns {Array} Returns the random elements.
  46798. */
  46799. function arraySampleSize(array, n) {
  46800. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  46801. }
  46802. /**
  46803. * A specialized version of `_.shuffle` for arrays.
  46804. *
  46805. * @private
  46806. * @param {Array} array The array to shuffle.
  46807. * @returns {Array} Returns the new shuffled array.
  46808. */
  46809. function arrayShuffle(array) {
  46810. return shuffleSelf(copyArray(array));
  46811. }
  46812. /**
  46813. * This function is like `assignValue` except that it doesn't assign
  46814. * `undefined` values.
  46815. *
  46816. * @private
  46817. * @param {Object} object The object to modify.
  46818. * @param {string} key The key of the property to assign.
  46819. * @param {*} value The value to assign.
  46820. */
  46821. function assignMergeValue(object, key, value) {
  46822. if ((value !== undefined && !eq(object[key], value)) ||
  46823. (value === undefined && !(key in object))) {
  46824. baseAssignValue(object, key, value);
  46825. }
  46826. }
  46827. /**
  46828. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  46829. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  46830. * for equality comparisons.
  46831. *
  46832. * @private
  46833. * @param {Object} object The object to modify.
  46834. * @param {string} key The key of the property to assign.
  46835. * @param {*} value The value to assign.
  46836. */
  46837. function assignValue(object, key, value) {
  46838. var objValue = object[key];
  46839. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  46840. (value === undefined && !(key in object))) {
  46841. baseAssignValue(object, key, value);
  46842. }
  46843. }
  46844. /**
  46845. * Gets the index at which the `key` is found in `array` of key-value pairs.
  46846. *
  46847. * @private
  46848. * @param {Array} array The array to inspect.
  46849. * @param {*} key The key to search for.
  46850. * @returns {number} Returns the index of the matched value, else `-1`.
  46851. */
  46852. function assocIndexOf(array, key) {
  46853. var length = array.length;
  46854. while (length--) {
  46855. if (eq(array[length][0], key)) {
  46856. return length;
  46857. }
  46858. }
  46859. return -1;
  46860. }
  46861. /**
  46862. * Aggregates elements of `collection` on `accumulator` with keys transformed
  46863. * by `iteratee` and values set by `setter`.
  46864. *
  46865. * @private
  46866. * @param {Array|Object} collection The collection to iterate over.
  46867. * @param {Function} setter The function to set `accumulator` values.
  46868. * @param {Function} iteratee The iteratee to transform keys.
  46869. * @param {Object} accumulator The initial aggregated object.
  46870. * @returns {Function} Returns `accumulator`.
  46871. */
  46872. function baseAggregator(collection, setter, iteratee, accumulator) {
  46873. baseEach(collection, function(value, key, collection) {
  46874. setter(accumulator, value, iteratee(value), collection);
  46875. });
  46876. return accumulator;
  46877. }
  46878. /**
  46879. * The base implementation of `_.assign` without support for multiple sources
  46880. * or `customizer` functions.
  46881. *
  46882. * @private
  46883. * @param {Object} object The destination object.
  46884. * @param {Object} source The source object.
  46885. * @returns {Object} Returns `object`.
  46886. */
  46887. function baseAssign(object, source) {
  46888. return object && copyObject(source, keys(source), object);
  46889. }
  46890. /**
  46891. * The base implementation of `_.assignIn` without support for multiple sources
  46892. * or `customizer` functions.
  46893. *
  46894. * @private
  46895. * @param {Object} object The destination object.
  46896. * @param {Object} source The source object.
  46897. * @returns {Object} Returns `object`.
  46898. */
  46899. function baseAssignIn(object, source) {
  46900. return object && copyObject(source, keysIn(source), object);
  46901. }
  46902. /**
  46903. * The base implementation of `assignValue` and `assignMergeValue` without
  46904. * value checks.
  46905. *
  46906. * @private
  46907. * @param {Object} object The object to modify.
  46908. * @param {string} key The key of the property to assign.
  46909. * @param {*} value The value to assign.
  46910. */
  46911. function baseAssignValue(object, key, value) {
  46912. if (key == '__proto__' && defineProperty) {
  46913. defineProperty(object, key, {
  46914. 'configurable': true,
  46915. 'enumerable': true,
  46916. 'value': value,
  46917. 'writable': true
  46918. });
  46919. } else {
  46920. object[key] = value;
  46921. }
  46922. }
  46923. /**
  46924. * The base implementation of `_.at` without support for individual paths.
  46925. *
  46926. * @private
  46927. * @param {Object} object The object to iterate over.
  46928. * @param {string[]} paths The property paths to pick.
  46929. * @returns {Array} Returns the picked elements.
  46930. */
  46931. function baseAt(object, paths) {
  46932. var index = -1,
  46933. length = paths.length,
  46934. result = Array(length),
  46935. skip = object == null;
  46936. while (++index < length) {
  46937. result[index] = skip ? undefined : get(object, paths[index]);
  46938. }
  46939. return result;
  46940. }
  46941. /**
  46942. * The base implementation of `_.clamp` which doesn't coerce arguments.
  46943. *
  46944. * @private
  46945. * @param {number} number The number to clamp.
  46946. * @param {number} [lower] The lower bound.
  46947. * @param {number} upper The upper bound.
  46948. * @returns {number} Returns the clamped number.
  46949. */
  46950. function baseClamp(number, lower, upper) {
  46951. if (number === number) {
  46952. if (upper !== undefined) {
  46953. number = number <= upper ? number : upper;
  46954. }
  46955. if (lower !== undefined) {
  46956. number = number >= lower ? number : lower;
  46957. }
  46958. }
  46959. return number;
  46960. }
  46961. /**
  46962. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  46963. * traversed objects.
  46964. *
  46965. * @private
  46966. * @param {*} value The value to clone.
  46967. * @param {boolean} bitmask The bitmask flags.
  46968. * 1 - Deep clone
  46969. * 2 - Flatten inherited properties
  46970. * 4 - Clone symbols
  46971. * @param {Function} [customizer] The function to customize cloning.
  46972. * @param {string} [key] The key of `value`.
  46973. * @param {Object} [object] The parent object of `value`.
  46974. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  46975. * @returns {*} Returns the cloned value.
  46976. */
  46977. function baseClone(value, bitmask, customizer, key, object, stack) {
  46978. var result,
  46979. isDeep = bitmask & CLONE_DEEP_FLAG,
  46980. isFlat = bitmask & CLONE_FLAT_FLAG,
  46981. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  46982. if (customizer) {
  46983. result = object ? customizer(value, key, object, stack) : customizer(value);
  46984. }
  46985. if (result !== undefined) {
  46986. return result;
  46987. }
  46988. if (!isObject(value)) {
  46989. return value;
  46990. }
  46991. var isArr = isArray(value);
  46992. if (isArr) {
  46993. result = initCloneArray(value);
  46994. if (!isDeep) {
  46995. return copyArray(value, result);
  46996. }
  46997. } else {
  46998. var tag = getTag(value),
  46999. isFunc = tag == funcTag || tag == genTag;
  47000. if (isBuffer(value)) {
  47001. return cloneBuffer(value, isDeep);
  47002. }
  47003. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  47004. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  47005. if (!isDeep) {
  47006. return isFlat
  47007. ? copySymbolsIn(value, baseAssignIn(result, value))
  47008. : copySymbols(value, baseAssign(result, value));
  47009. }
  47010. } else {
  47011. if (!cloneableTags[tag]) {
  47012. return object ? value : {};
  47013. }
  47014. result = initCloneByTag(value, tag, isDeep);
  47015. }
  47016. }
  47017. // Check for circular references and return its corresponding clone.
  47018. stack || (stack = new Stack);
  47019. var stacked = stack.get(value);
  47020. if (stacked) {
  47021. return stacked;
  47022. }
  47023. stack.set(value, result);
  47024. if (isSet(value)) {
  47025. value.forEach(function(subValue) {
  47026. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  47027. });
  47028. } else if (isMap(value)) {
  47029. value.forEach(function(subValue, key) {
  47030. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  47031. });
  47032. }
  47033. var keysFunc = isFull
  47034. ? (isFlat ? getAllKeysIn : getAllKeys)
  47035. : (isFlat ? keysIn : keys);
  47036. var props = isArr ? undefined : keysFunc(value);
  47037. arrayEach(props || value, function(subValue, key) {
  47038. if (props) {
  47039. key = subValue;
  47040. subValue = value[key];
  47041. }
  47042. // Recursively populate clone (susceptible to call stack limits).
  47043. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  47044. });
  47045. return result;
  47046. }
  47047. /**
  47048. * The base implementation of `_.conforms` which doesn't clone `source`.
  47049. *
  47050. * @private
  47051. * @param {Object} source The object of property predicates to conform to.
  47052. * @returns {Function} Returns the new spec function.
  47053. */
  47054. function baseConforms(source) {
  47055. var props = keys(source);
  47056. return function(object) {
  47057. return baseConformsTo(object, source, props);
  47058. };
  47059. }
  47060. /**
  47061. * The base implementation of `_.conformsTo` which accepts `props` to check.
  47062. *
  47063. * @private
  47064. * @param {Object} object The object to inspect.
  47065. * @param {Object} source The object of property predicates to conform to.
  47066. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  47067. */
  47068. function baseConformsTo(object, source, props) {
  47069. var length = props.length;
  47070. if (object == null) {
  47071. return !length;
  47072. }
  47073. object = Object(object);
  47074. while (length--) {
  47075. var key = props[length],
  47076. predicate = source[key],
  47077. value = object[key];
  47078. if ((value === undefined && !(key in object)) || !predicate(value)) {
  47079. return false;
  47080. }
  47081. }
  47082. return true;
  47083. }
  47084. /**
  47085. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  47086. * to provide to `func`.
  47087. *
  47088. * @private
  47089. * @param {Function} func The function to delay.
  47090. * @param {number} wait The number of milliseconds to delay invocation.
  47091. * @param {Array} args The arguments to provide to `func`.
  47092. * @returns {number|Object} Returns the timer id or timeout object.
  47093. */
  47094. function baseDelay(func, wait, args) {
  47095. if (typeof func != 'function') {
  47096. throw new TypeError(FUNC_ERROR_TEXT);
  47097. }
  47098. return setTimeout(function() { func.apply(undefined, args); }, wait);
  47099. }
  47100. /**
  47101. * The base implementation of methods like `_.difference` without support
  47102. * for excluding multiple arrays or iteratee shorthands.
  47103. *
  47104. * @private
  47105. * @param {Array} array The array to inspect.
  47106. * @param {Array} values The values to exclude.
  47107. * @param {Function} [iteratee] The iteratee invoked per element.
  47108. * @param {Function} [comparator] The comparator invoked per element.
  47109. * @returns {Array} Returns the new array of filtered values.
  47110. */
  47111. function baseDifference(array, values, iteratee, comparator) {
  47112. var index = -1,
  47113. includes = arrayIncludes,
  47114. isCommon = true,
  47115. length = array.length,
  47116. result = [],
  47117. valuesLength = values.length;
  47118. if (!length) {
  47119. return result;
  47120. }
  47121. if (iteratee) {
  47122. values = arrayMap(values, baseUnary(iteratee));
  47123. }
  47124. if (comparator) {
  47125. includes = arrayIncludesWith;
  47126. isCommon = false;
  47127. }
  47128. else if (values.length >= LARGE_ARRAY_SIZE) {
  47129. includes = cacheHas;
  47130. isCommon = false;
  47131. values = new SetCache(values);
  47132. }
  47133. outer:
  47134. while (++index < length) {
  47135. var value = array[index],
  47136. computed = iteratee == null ? value : iteratee(value);
  47137. value = (comparator || value !== 0) ? value : 0;
  47138. if (isCommon && computed === computed) {
  47139. var valuesIndex = valuesLength;
  47140. while (valuesIndex--) {
  47141. if (values[valuesIndex] === computed) {
  47142. continue outer;
  47143. }
  47144. }
  47145. result.push(value);
  47146. }
  47147. else if (!includes(values, computed, comparator)) {
  47148. result.push(value);
  47149. }
  47150. }
  47151. return result;
  47152. }
  47153. /**
  47154. * The base implementation of `_.forEach` without support for iteratee shorthands.
  47155. *
  47156. * @private
  47157. * @param {Array|Object} collection The collection to iterate over.
  47158. * @param {Function} iteratee The function invoked per iteration.
  47159. * @returns {Array|Object} Returns `collection`.
  47160. */
  47161. var baseEach = createBaseEach(baseForOwn);
  47162. /**
  47163. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  47164. *
  47165. * @private
  47166. * @param {Array|Object} collection The collection to iterate over.
  47167. * @param {Function} iteratee The function invoked per iteration.
  47168. * @returns {Array|Object} Returns `collection`.
  47169. */
  47170. var baseEachRight = createBaseEach(baseForOwnRight, true);
  47171. /**
  47172. * The base implementation of `_.every` without support for iteratee shorthands.
  47173. *
  47174. * @private
  47175. * @param {Array|Object} collection The collection to iterate over.
  47176. * @param {Function} predicate The function invoked per iteration.
  47177. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  47178. * else `false`
  47179. */
  47180. function baseEvery(collection, predicate) {
  47181. var result = true;
  47182. baseEach(collection, function(value, index, collection) {
  47183. result = !!predicate(value, index, collection);
  47184. return result;
  47185. });
  47186. return result;
  47187. }
  47188. /**
  47189. * The base implementation of methods like `_.max` and `_.min` which accepts a
  47190. * `comparator` to determine the extremum value.
  47191. *
  47192. * @private
  47193. * @param {Array} array The array to iterate over.
  47194. * @param {Function} iteratee The iteratee invoked per iteration.
  47195. * @param {Function} comparator The comparator used to compare values.
  47196. * @returns {*} Returns the extremum value.
  47197. */
  47198. function baseExtremum(array, iteratee, comparator) {
  47199. var index = -1,
  47200. length = array.length;
  47201. while (++index < length) {
  47202. var value = array[index],
  47203. current = iteratee(value);
  47204. if (current != null && (computed === undefined
  47205. ? (current === current && !isSymbol(current))
  47206. : comparator(current, computed)
  47207. )) {
  47208. var computed = current,
  47209. result = value;
  47210. }
  47211. }
  47212. return result;
  47213. }
  47214. /**
  47215. * The base implementation of `_.fill` without an iteratee call guard.
  47216. *
  47217. * @private
  47218. * @param {Array} array The array to fill.
  47219. * @param {*} value The value to fill `array` with.
  47220. * @param {number} [start=0] The start position.
  47221. * @param {number} [end=array.length] The end position.
  47222. * @returns {Array} Returns `array`.
  47223. */
  47224. function baseFill(array, value, start, end) {
  47225. var length = array.length;
  47226. start = toInteger(start);
  47227. if (start < 0) {
  47228. start = -start > length ? 0 : (length + start);
  47229. }
  47230. end = (end === undefined || end > length) ? length : toInteger(end);
  47231. if (end < 0) {
  47232. end += length;
  47233. }
  47234. end = start > end ? 0 : toLength(end);
  47235. while (start < end) {
  47236. array[start++] = value;
  47237. }
  47238. return array;
  47239. }
  47240. /**
  47241. * The base implementation of `_.filter` without support for iteratee shorthands.
  47242. *
  47243. * @private
  47244. * @param {Array|Object} collection The collection to iterate over.
  47245. * @param {Function} predicate The function invoked per iteration.
  47246. * @returns {Array} Returns the new filtered array.
  47247. */
  47248. function baseFilter(collection, predicate) {
  47249. var result = [];
  47250. baseEach(collection, function(value, index, collection) {
  47251. if (predicate(value, index, collection)) {
  47252. result.push(value);
  47253. }
  47254. });
  47255. return result;
  47256. }
  47257. /**
  47258. * The base implementation of `_.flatten` with support for restricting flattening.
  47259. *
  47260. * @private
  47261. * @param {Array} array The array to flatten.
  47262. * @param {number} depth The maximum recursion depth.
  47263. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  47264. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  47265. * @param {Array} [result=[]] The initial result value.
  47266. * @returns {Array} Returns the new flattened array.
  47267. */
  47268. function baseFlatten(array, depth, predicate, isStrict, result) {
  47269. var index = -1,
  47270. length = array.length;
  47271. predicate || (predicate = isFlattenable);
  47272. result || (result = []);
  47273. while (++index < length) {
  47274. var value = array[index];
  47275. if (depth > 0 && predicate(value)) {
  47276. if (depth > 1) {
  47277. // Recursively flatten arrays (susceptible to call stack limits).
  47278. baseFlatten(value, depth - 1, predicate, isStrict, result);
  47279. } else {
  47280. arrayPush(result, value);
  47281. }
  47282. } else if (!isStrict) {
  47283. result[result.length] = value;
  47284. }
  47285. }
  47286. return result;
  47287. }
  47288. /**
  47289. * The base implementation of `baseForOwn` which iterates over `object`
  47290. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  47291. * Iteratee functions may exit iteration early by explicitly returning `false`.
  47292. *
  47293. * @private
  47294. * @param {Object} object The object to iterate over.
  47295. * @param {Function} iteratee The function invoked per iteration.
  47296. * @param {Function} keysFunc The function to get the keys of `object`.
  47297. * @returns {Object} Returns `object`.
  47298. */
  47299. var baseFor = createBaseFor();
  47300. /**
  47301. * This function is like `baseFor` except that it iterates over properties
  47302. * in the opposite order.
  47303. *
  47304. * @private
  47305. * @param {Object} object The object to iterate over.
  47306. * @param {Function} iteratee The function invoked per iteration.
  47307. * @param {Function} keysFunc The function to get the keys of `object`.
  47308. * @returns {Object} Returns `object`.
  47309. */
  47310. var baseForRight = createBaseFor(true);
  47311. /**
  47312. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  47313. *
  47314. * @private
  47315. * @param {Object} object The object to iterate over.
  47316. * @param {Function} iteratee The function invoked per iteration.
  47317. * @returns {Object} Returns `object`.
  47318. */
  47319. function baseForOwn(object, iteratee) {
  47320. return object && baseFor(object, iteratee, keys);
  47321. }
  47322. /**
  47323. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  47324. *
  47325. * @private
  47326. * @param {Object} object The object to iterate over.
  47327. * @param {Function} iteratee The function invoked per iteration.
  47328. * @returns {Object} Returns `object`.
  47329. */
  47330. function baseForOwnRight(object, iteratee) {
  47331. return object && baseForRight(object, iteratee, keys);
  47332. }
  47333. /**
  47334. * The base implementation of `_.functions` which creates an array of
  47335. * `object` function property names filtered from `props`.
  47336. *
  47337. * @private
  47338. * @param {Object} object The object to inspect.
  47339. * @param {Array} props The property names to filter.
  47340. * @returns {Array} Returns the function names.
  47341. */
  47342. function baseFunctions(object, props) {
  47343. return arrayFilter(props, function(key) {
  47344. return isFunction(object[key]);
  47345. });
  47346. }
  47347. /**
  47348. * The base implementation of `_.get` without support for default values.
  47349. *
  47350. * @private
  47351. * @param {Object} object The object to query.
  47352. * @param {Array|string} path The path of the property to get.
  47353. * @returns {*} Returns the resolved value.
  47354. */
  47355. function baseGet(object, path) {
  47356. path = castPath(path, object);
  47357. var index = 0,
  47358. length = path.length;
  47359. while (object != null && index < length) {
  47360. object = object[toKey(path[index++])];
  47361. }
  47362. return (index && index == length) ? object : undefined;
  47363. }
  47364. /**
  47365. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  47366. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  47367. * symbols of `object`.
  47368. *
  47369. * @private
  47370. * @param {Object} object The object to query.
  47371. * @param {Function} keysFunc The function to get the keys of `object`.
  47372. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  47373. * @returns {Array} Returns the array of property names and symbols.
  47374. */
  47375. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  47376. var result = keysFunc(object);
  47377. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  47378. }
  47379. /**
  47380. * The base implementation of `getTag` without fallbacks for buggy environments.
  47381. *
  47382. * @private
  47383. * @param {*} value The value to query.
  47384. * @returns {string} Returns the `toStringTag`.
  47385. */
  47386. function baseGetTag(value) {
  47387. if (value == null) {
  47388. return value === undefined ? undefinedTag : nullTag;
  47389. }
  47390. return (symToStringTag && symToStringTag in Object(value))
  47391. ? getRawTag(value)
  47392. : objectToString(value);
  47393. }
  47394. /**
  47395. * The base implementation of `_.gt` which doesn't coerce arguments.
  47396. *
  47397. * @private
  47398. * @param {*} value The value to compare.
  47399. * @param {*} other The other value to compare.
  47400. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  47401. * else `false`.
  47402. */
  47403. function baseGt(value, other) {
  47404. return value > other;
  47405. }
  47406. /**
  47407. * The base implementation of `_.has` without support for deep paths.
  47408. *
  47409. * @private
  47410. * @param {Object} [object] The object to query.
  47411. * @param {Array|string} key The key to check.
  47412. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  47413. */
  47414. function baseHas(object, key) {
  47415. return object != null && hasOwnProperty.call(object, key);
  47416. }
  47417. /**
  47418. * The base implementation of `_.hasIn` without support for deep paths.
  47419. *
  47420. * @private
  47421. * @param {Object} [object] The object to query.
  47422. * @param {Array|string} key The key to check.
  47423. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  47424. */
  47425. function baseHasIn(object, key) {
  47426. return object != null && key in Object(object);
  47427. }
  47428. /**
  47429. * The base implementation of `_.inRange` which doesn't coerce arguments.
  47430. *
  47431. * @private
  47432. * @param {number} number The number to check.
  47433. * @param {number} start The start of the range.
  47434. * @param {number} end The end of the range.
  47435. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  47436. */
  47437. function baseInRange(number, start, end) {
  47438. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  47439. }
  47440. /**
  47441. * The base implementation of methods like `_.intersection`, without support
  47442. * for iteratee shorthands, that accepts an array of arrays to inspect.
  47443. *
  47444. * @private
  47445. * @param {Array} arrays The arrays to inspect.
  47446. * @param {Function} [iteratee] The iteratee invoked per element.
  47447. * @param {Function} [comparator] The comparator invoked per element.
  47448. * @returns {Array} Returns the new array of shared values.
  47449. */
  47450. function baseIntersection(arrays, iteratee, comparator) {
  47451. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  47452. length = arrays[0].length,
  47453. othLength = arrays.length,
  47454. othIndex = othLength,
  47455. caches = Array(othLength),
  47456. maxLength = Infinity,
  47457. result = [];
  47458. while (othIndex--) {
  47459. var array = arrays[othIndex];
  47460. if (othIndex && iteratee) {
  47461. array = arrayMap(array, baseUnary(iteratee));
  47462. }
  47463. maxLength = nativeMin(array.length, maxLength);
  47464. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  47465. ? new SetCache(othIndex && array)
  47466. : undefined;
  47467. }
  47468. array = arrays[0];
  47469. var index = -1,
  47470. seen = caches[0];
  47471. outer:
  47472. while (++index < length && result.length < maxLength) {
  47473. var value = array[index],
  47474. computed = iteratee ? iteratee(value) : value;
  47475. value = (comparator || value !== 0) ? value : 0;
  47476. if (!(seen
  47477. ? cacheHas(seen, computed)
  47478. : includes(result, computed, comparator)
  47479. )) {
  47480. othIndex = othLength;
  47481. while (--othIndex) {
  47482. var cache = caches[othIndex];
  47483. if (!(cache
  47484. ? cacheHas(cache, computed)
  47485. : includes(arrays[othIndex], computed, comparator))
  47486. ) {
  47487. continue outer;
  47488. }
  47489. }
  47490. if (seen) {
  47491. seen.push(computed);
  47492. }
  47493. result.push(value);
  47494. }
  47495. }
  47496. return result;
  47497. }
  47498. /**
  47499. * The base implementation of `_.invert` and `_.invertBy` which inverts
  47500. * `object` with values transformed by `iteratee` and set by `setter`.
  47501. *
  47502. * @private
  47503. * @param {Object} object The object to iterate over.
  47504. * @param {Function} setter The function to set `accumulator` values.
  47505. * @param {Function} iteratee The iteratee to transform values.
  47506. * @param {Object} accumulator The initial inverted object.
  47507. * @returns {Function} Returns `accumulator`.
  47508. */
  47509. function baseInverter(object, setter, iteratee, accumulator) {
  47510. baseForOwn(object, function(value, key, object) {
  47511. setter(accumulator, iteratee(value), key, object);
  47512. });
  47513. return accumulator;
  47514. }
  47515. /**
  47516. * The base implementation of `_.invoke` without support for individual
  47517. * method arguments.
  47518. *
  47519. * @private
  47520. * @param {Object} object The object to query.
  47521. * @param {Array|string} path The path of the method to invoke.
  47522. * @param {Array} args The arguments to invoke the method with.
  47523. * @returns {*} Returns the result of the invoked method.
  47524. */
  47525. function baseInvoke(object, path, args) {
  47526. path = castPath(path, object);
  47527. object = parent(object, path);
  47528. var func = object == null ? object : object[toKey(last(path))];
  47529. return func == null ? undefined : apply(func, object, args);
  47530. }
  47531. /**
  47532. * The base implementation of `_.isArguments`.
  47533. *
  47534. * @private
  47535. * @param {*} value The value to check.
  47536. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  47537. */
  47538. function baseIsArguments(value) {
  47539. return isObjectLike(value) && baseGetTag(value) == argsTag;
  47540. }
  47541. /**
  47542. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  47543. *
  47544. * @private
  47545. * @param {*} value The value to check.
  47546. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  47547. */
  47548. function baseIsArrayBuffer(value) {
  47549. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  47550. }
  47551. /**
  47552. * The base implementation of `_.isDate` without Node.js optimizations.
  47553. *
  47554. * @private
  47555. * @param {*} value The value to check.
  47556. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  47557. */
  47558. function baseIsDate(value) {
  47559. return isObjectLike(value) && baseGetTag(value) == dateTag;
  47560. }
  47561. /**
  47562. * The base implementation of `_.isEqual` which supports partial comparisons
  47563. * and tracks traversed objects.
  47564. *
  47565. * @private
  47566. * @param {*} value The value to compare.
  47567. * @param {*} other The other value to compare.
  47568. * @param {boolean} bitmask The bitmask flags.
  47569. * 1 - Unordered comparison
  47570. * 2 - Partial comparison
  47571. * @param {Function} [customizer] The function to customize comparisons.
  47572. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  47573. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  47574. */
  47575. function baseIsEqual(value, other, bitmask, customizer, stack) {
  47576. if (value === other) {
  47577. return true;
  47578. }
  47579. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  47580. return value !== value && other !== other;
  47581. }
  47582. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  47583. }
  47584. /**
  47585. * A specialized version of `baseIsEqual` for arrays and objects which performs
  47586. * deep comparisons and tracks traversed objects enabling objects with circular
  47587. * references to be compared.
  47588. *
  47589. * @private
  47590. * @param {Object} object The object to compare.
  47591. * @param {Object} other The other object to compare.
  47592. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  47593. * @param {Function} customizer The function to customize comparisons.
  47594. * @param {Function} equalFunc The function to determine equivalents of values.
  47595. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  47596. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  47597. */
  47598. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  47599. var objIsArr = isArray(object),
  47600. othIsArr = isArray(other),
  47601. objTag = objIsArr ? arrayTag : getTag(object),
  47602. othTag = othIsArr ? arrayTag : getTag(other);
  47603. objTag = objTag == argsTag ? objectTag : objTag;
  47604. othTag = othTag == argsTag ? objectTag : othTag;
  47605. var objIsObj = objTag == objectTag,
  47606. othIsObj = othTag == objectTag,
  47607. isSameTag = objTag == othTag;
  47608. if (isSameTag && isBuffer(object)) {
  47609. if (!isBuffer(other)) {
  47610. return false;
  47611. }
  47612. objIsArr = true;
  47613. objIsObj = false;
  47614. }
  47615. if (isSameTag && !objIsObj) {
  47616. stack || (stack = new Stack);
  47617. return (objIsArr || isTypedArray(object))
  47618. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  47619. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  47620. }
  47621. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  47622. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  47623. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  47624. if (objIsWrapped || othIsWrapped) {
  47625. var objUnwrapped = objIsWrapped ? object.value() : object,
  47626. othUnwrapped = othIsWrapped ? other.value() : other;
  47627. stack || (stack = new Stack);
  47628. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  47629. }
  47630. }
  47631. if (!isSameTag) {
  47632. return false;
  47633. }
  47634. stack || (stack = new Stack);
  47635. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  47636. }
  47637. /**
  47638. * The base implementation of `_.isMap` without Node.js optimizations.
  47639. *
  47640. * @private
  47641. * @param {*} value The value to check.
  47642. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  47643. */
  47644. function baseIsMap(value) {
  47645. return isObjectLike(value) && getTag(value) == mapTag;
  47646. }
  47647. /**
  47648. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  47649. *
  47650. * @private
  47651. * @param {Object} object The object to inspect.
  47652. * @param {Object} source The object of property values to match.
  47653. * @param {Array} matchData The property names, values, and compare flags to match.
  47654. * @param {Function} [customizer] The function to customize comparisons.
  47655. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  47656. */
  47657. function baseIsMatch(object, source, matchData, customizer) {
  47658. var index = matchData.length,
  47659. length = index,
  47660. noCustomizer = !customizer;
  47661. if (object == null) {
  47662. return !length;
  47663. }
  47664. object = Object(object);
  47665. while (index--) {
  47666. var data = matchData[index];
  47667. if ((noCustomizer && data[2])
  47668. ? data[1] !== object[data[0]]
  47669. : !(data[0] in object)
  47670. ) {
  47671. return false;
  47672. }
  47673. }
  47674. while (++index < length) {
  47675. data = matchData[index];
  47676. var key = data[0],
  47677. objValue = object[key],
  47678. srcValue = data[1];
  47679. if (noCustomizer && data[2]) {
  47680. if (objValue === undefined && !(key in object)) {
  47681. return false;
  47682. }
  47683. } else {
  47684. var stack = new Stack;
  47685. if (customizer) {
  47686. var result = customizer(objValue, srcValue, key, object, source, stack);
  47687. }
  47688. if (!(result === undefined
  47689. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  47690. : result
  47691. )) {
  47692. return false;
  47693. }
  47694. }
  47695. }
  47696. return true;
  47697. }
  47698. /**
  47699. * The base implementation of `_.isNative` without bad shim checks.
  47700. *
  47701. * @private
  47702. * @param {*} value The value to check.
  47703. * @returns {boolean} Returns `true` if `value` is a native function,
  47704. * else `false`.
  47705. */
  47706. function baseIsNative(value) {
  47707. if (!isObject(value) || isMasked(value)) {
  47708. return false;
  47709. }
  47710. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  47711. return pattern.test(toSource(value));
  47712. }
  47713. /**
  47714. * The base implementation of `_.isRegExp` without Node.js optimizations.
  47715. *
  47716. * @private
  47717. * @param {*} value The value to check.
  47718. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  47719. */
  47720. function baseIsRegExp(value) {
  47721. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  47722. }
  47723. /**
  47724. * The base implementation of `_.isSet` without Node.js optimizations.
  47725. *
  47726. * @private
  47727. * @param {*} value The value to check.
  47728. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  47729. */
  47730. function baseIsSet(value) {
  47731. return isObjectLike(value) && getTag(value) == setTag;
  47732. }
  47733. /**
  47734. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  47735. *
  47736. * @private
  47737. * @param {*} value The value to check.
  47738. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  47739. */
  47740. function baseIsTypedArray(value) {
  47741. return isObjectLike(value) &&
  47742. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  47743. }
  47744. /**
  47745. * The base implementation of `_.iteratee`.
  47746. *
  47747. * @private
  47748. * @param {*} [value=_.identity] The value to convert to an iteratee.
  47749. * @returns {Function} Returns the iteratee.
  47750. */
  47751. function baseIteratee(value) {
  47752. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  47753. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  47754. if (typeof value == 'function') {
  47755. return value;
  47756. }
  47757. if (value == null) {
  47758. return identity;
  47759. }
  47760. if (typeof value == 'object') {
  47761. return isArray(value)
  47762. ? baseMatchesProperty(value[0], value[1])
  47763. : baseMatches(value);
  47764. }
  47765. return property(value);
  47766. }
  47767. /**
  47768. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  47769. *
  47770. * @private
  47771. * @param {Object} object The object to query.
  47772. * @returns {Array} Returns the array of property names.
  47773. */
  47774. function baseKeys(object) {
  47775. if (!isPrototype(object)) {
  47776. return nativeKeys(object);
  47777. }
  47778. var result = [];
  47779. for (var key in Object(object)) {
  47780. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  47781. result.push(key);
  47782. }
  47783. }
  47784. return result;
  47785. }
  47786. /**
  47787. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  47788. *
  47789. * @private
  47790. * @param {Object} object The object to query.
  47791. * @returns {Array} Returns the array of property names.
  47792. */
  47793. function baseKeysIn(object) {
  47794. if (!isObject(object)) {
  47795. return nativeKeysIn(object);
  47796. }
  47797. var isProto = isPrototype(object),
  47798. result = [];
  47799. for (var key in object) {
  47800. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  47801. result.push(key);
  47802. }
  47803. }
  47804. return result;
  47805. }
  47806. /**
  47807. * The base implementation of `_.lt` which doesn't coerce arguments.
  47808. *
  47809. * @private
  47810. * @param {*} value The value to compare.
  47811. * @param {*} other The other value to compare.
  47812. * @returns {boolean} Returns `true` if `value` is less than `other`,
  47813. * else `false`.
  47814. */
  47815. function baseLt(value, other) {
  47816. return value < other;
  47817. }
  47818. /**
  47819. * The base implementation of `_.map` without support for iteratee shorthands.
  47820. *
  47821. * @private
  47822. * @param {Array|Object} collection The collection to iterate over.
  47823. * @param {Function} iteratee The function invoked per iteration.
  47824. * @returns {Array} Returns the new mapped array.
  47825. */
  47826. function baseMap(collection, iteratee) {
  47827. var index = -1,
  47828. result = isArrayLike(collection) ? Array(collection.length) : [];
  47829. baseEach(collection, function(value, key, collection) {
  47830. result[++index] = iteratee(value, key, collection);
  47831. });
  47832. return result;
  47833. }
  47834. /**
  47835. * The base implementation of `_.matches` which doesn't clone `source`.
  47836. *
  47837. * @private
  47838. * @param {Object} source The object of property values to match.
  47839. * @returns {Function} Returns the new spec function.
  47840. */
  47841. function baseMatches(source) {
  47842. var matchData = getMatchData(source);
  47843. if (matchData.length == 1 && matchData[0][2]) {
  47844. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  47845. }
  47846. return function(object) {
  47847. return object === source || baseIsMatch(object, source, matchData);
  47848. };
  47849. }
  47850. /**
  47851. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  47852. *
  47853. * @private
  47854. * @param {string} path The path of the property to get.
  47855. * @param {*} srcValue The value to match.
  47856. * @returns {Function} Returns the new spec function.
  47857. */
  47858. function baseMatchesProperty(path, srcValue) {
  47859. if (isKey(path) && isStrictComparable(srcValue)) {
  47860. return matchesStrictComparable(toKey(path), srcValue);
  47861. }
  47862. return function(object) {
  47863. var objValue = get(object, path);
  47864. return (objValue === undefined && objValue === srcValue)
  47865. ? hasIn(object, path)
  47866. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  47867. };
  47868. }
  47869. /**
  47870. * The base implementation of `_.merge` without support for multiple sources.
  47871. *
  47872. * @private
  47873. * @param {Object} object The destination object.
  47874. * @param {Object} source The source object.
  47875. * @param {number} srcIndex The index of `source`.
  47876. * @param {Function} [customizer] The function to customize merged values.
  47877. * @param {Object} [stack] Tracks traversed source values and their merged
  47878. * counterparts.
  47879. */
  47880. function baseMerge(object, source, srcIndex, customizer, stack) {
  47881. if (object === source) {
  47882. return;
  47883. }
  47884. baseFor(source, function(srcValue, key) {
  47885. stack || (stack = new Stack);
  47886. if (isObject(srcValue)) {
  47887. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  47888. }
  47889. else {
  47890. var newValue = customizer
  47891. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  47892. : undefined;
  47893. if (newValue === undefined) {
  47894. newValue = srcValue;
  47895. }
  47896. assignMergeValue(object, key, newValue);
  47897. }
  47898. }, keysIn);
  47899. }
  47900. /**
  47901. * A specialized version of `baseMerge` for arrays and objects which performs
  47902. * deep merges and tracks traversed objects enabling objects with circular
  47903. * references to be merged.
  47904. *
  47905. * @private
  47906. * @param {Object} object The destination object.
  47907. * @param {Object} source The source object.
  47908. * @param {string} key The key of the value to merge.
  47909. * @param {number} srcIndex The index of `source`.
  47910. * @param {Function} mergeFunc The function to merge values.
  47911. * @param {Function} [customizer] The function to customize assigned values.
  47912. * @param {Object} [stack] Tracks traversed source values and their merged
  47913. * counterparts.
  47914. */
  47915. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  47916. var objValue = safeGet(object, key),
  47917. srcValue = safeGet(source, key),
  47918. stacked = stack.get(srcValue);
  47919. if (stacked) {
  47920. assignMergeValue(object, key, stacked);
  47921. return;
  47922. }
  47923. var newValue = customizer
  47924. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  47925. : undefined;
  47926. var isCommon = newValue === undefined;
  47927. if (isCommon) {
  47928. var isArr = isArray(srcValue),
  47929. isBuff = !isArr && isBuffer(srcValue),
  47930. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  47931. newValue = srcValue;
  47932. if (isArr || isBuff || isTyped) {
  47933. if (isArray(objValue)) {
  47934. newValue = objValue;
  47935. }
  47936. else if (isArrayLikeObject(objValue)) {
  47937. newValue = copyArray(objValue);
  47938. }
  47939. else if (isBuff) {
  47940. isCommon = false;
  47941. newValue = cloneBuffer(srcValue, true);
  47942. }
  47943. else if (isTyped) {
  47944. isCommon = false;
  47945. newValue = cloneTypedArray(srcValue, true);
  47946. }
  47947. else {
  47948. newValue = [];
  47949. }
  47950. }
  47951. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  47952. newValue = objValue;
  47953. if (isArguments(objValue)) {
  47954. newValue = toPlainObject(objValue);
  47955. }
  47956. else if (!isObject(objValue) || isFunction(objValue)) {
  47957. newValue = initCloneObject(srcValue);
  47958. }
  47959. }
  47960. else {
  47961. isCommon = false;
  47962. }
  47963. }
  47964. if (isCommon) {
  47965. // Recursively merge objects and arrays (susceptible to call stack limits).
  47966. stack.set(srcValue, newValue);
  47967. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  47968. stack['delete'](srcValue);
  47969. }
  47970. assignMergeValue(object, key, newValue);
  47971. }
  47972. /**
  47973. * The base implementation of `_.nth` which doesn't coerce arguments.
  47974. *
  47975. * @private
  47976. * @param {Array} array The array to query.
  47977. * @param {number} n The index of the element to return.
  47978. * @returns {*} Returns the nth element of `array`.
  47979. */
  47980. function baseNth(array, n) {
  47981. var length = array.length;
  47982. if (!length) {
  47983. return;
  47984. }
  47985. n += n < 0 ? length : 0;
  47986. return isIndex(n, length) ? array[n] : undefined;
  47987. }
  47988. /**
  47989. * The base implementation of `_.orderBy` without param guards.
  47990. *
  47991. * @private
  47992. * @param {Array|Object} collection The collection to iterate over.
  47993. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  47994. * @param {string[]} orders The sort orders of `iteratees`.
  47995. * @returns {Array} Returns the new sorted array.
  47996. */
  47997. function baseOrderBy(collection, iteratees, orders) {
  47998. if (iteratees.length) {
  47999. iteratees = arrayMap(iteratees, function(iteratee) {
  48000. if (isArray(iteratee)) {
  48001. return function(value) {
  48002. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  48003. }
  48004. }
  48005. return iteratee;
  48006. });
  48007. } else {
  48008. iteratees = [identity];
  48009. }
  48010. var index = -1;
  48011. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  48012. var result = baseMap(collection, function(value, key, collection) {
  48013. var criteria = arrayMap(iteratees, function(iteratee) {
  48014. return iteratee(value);
  48015. });
  48016. return { 'criteria': criteria, 'index': ++index, 'value': value };
  48017. });
  48018. return baseSortBy(result, function(object, other) {
  48019. return compareMultiple(object, other, orders);
  48020. });
  48021. }
  48022. /**
  48023. * The base implementation of `_.pick` without support for individual
  48024. * property identifiers.
  48025. *
  48026. * @private
  48027. * @param {Object} object The source object.
  48028. * @param {string[]} paths The property paths to pick.
  48029. * @returns {Object} Returns the new object.
  48030. */
  48031. function basePick(object, paths) {
  48032. return basePickBy(object, paths, function(value, path) {
  48033. return hasIn(object, path);
  48034. });
  48035. }
  48036. /**
  48037. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  48038. *
  48039. * @private
  48040. * @param {Object} object The source object.
  48041. * @param {string[]} paths The property paths to pick.
  48042. * @param {Function} predicate The function invoked per property.
  48043. * @returns {Object} Returns the new object.
  48044. */
  48045. function basePickBy(object, paths, predicate) {
  48046. var index = -1,
  48047. length = paths.length,
  48048. result = {};
  48049. while (++index < length) {
  48050. var path = paths[index],
  48051. value = baseGet(object, path);
  48052. if (predicate(value, path)) {
  48053. baseSet(result, castPath(path, object), value);
  48054. }
  48055. }
  48056. return result;
  48057. }
  48058. /**
  48059. * A specialized version of `baseProperty` which supports deep paths.
  48060. *
  48061. * @private
  48062. * @param {Array|string} path The path of the property to get.
  48063. * @returns {Function} Returns the new accessor function.
  48064. */
  48065. function basePropertyDeep(path) {
  48066. return function(object) {
  48067. return baseGet(object, path);
  48068. };
  48069. }
  48070. /**
  48071. * The base implementation of `_.pullAllBy` without support for iteratee
  48072. * shorthands.
  48073. *
  48074. * @private
  48075. * @param {Array} array The array to modify.
  48076. * @param {Array} values The values to remove.
  48077. * @param {Function} [iteratee] The iteratee invoked per element.
  48078. * @param {Function} [comparator] The comparator invoked per element.
  48079. * @returns {Array} Returns `array`.
  48080. */
  48081. function basePullAll(array, values, iteratee, comparator) {
  48082. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  48083. index = -1,
  48084. length = values.length,
  48085. seen = array;
  48086. if (array === values) {
  48087. values = copyArray(values);
  48088. }
  48089. if (iteratee) {
  48090. seen = arrayMap(array, baseUnary(iteratee));
  48091. }
  48092. while (++index < length) {
  48093. var fromIndex = 0,
  48094. value = values[index],
  48095. computed = iteratee ? iteratee(value) : value;
  48096. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  48097. if (seen !== array) {
  48098. splice.call(seen, fromIndex, 1);
  48099. }
  48100. splice.call(array, fromIndex, 1);
  48101. }
  48102. }
  48103. return array;
  48104. }
  48105. /**
  48106. * The base implementation of `_.pullAt` without support for individual
  48107. * indexes or capturing the removed elements.
  48108. *
  48109. * @private
  48110. * @param {Array} array The array to modify.
  48111. * @param {number[]} indexes The indexes of elements to remove.
  48112. * @returns {Array} Returns `array`.
  48113. */
  48114. function basePullAt(array, indexes) {
  48115. var length = array ? indexes.length : 0,
  48116. lastIndex = length - 1;
  48117. while (length--) {
  48118. var index = indexes[length];
  48119. if (length == lastIndex || index !== previous) {
  48120. var previous = index;
  48121. if (isIndex(index)) {
  48122. splice.call(array, index, 1);
  48123. } else {
  48124. baseUnset(array, index);
  48125. }
  48126. }
  48127. }
  48128. return array;
  48129. }
  48130. /**
  48131. * The base implementation of `_.random` without support for returning
  48132. * floating-point numbers.
  48133. *
  48134. * @private
  48135. * @param {number} lower The lower bound.
  48136. * @param {number} upper The upper bound.
  48137. * @returns {number} Returns the random number.
  48138. */
  48139. function baseRandom(lower, upper) {
  48140. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  48141. }
  48142. /**
  48143. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  48144. * coerce arguments.
  48145. *
  48146. * @private
  48147. * @param {number} start The start of the range.
  48148. * @param {number} end The end of the range.
  48149. * @param {number} step The value to increment or decrement by.
  48150. * @param {boolean} [fromRight] Specify iterating from right to left.
  48151. * @returns {Array} Returns the range of numbers.
  48152. */
  48153. function baseRange(start, end, step, fromRight) {
  48154. var index = -1,
  48155. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  48156. result = Array(length);
  48157. while (length--) {
  48158. result[fromRight ? length : ++index] = start;
  48159. start += step;
  48160. }
  48161. return result;
  48162. }
  48163. /**
  48164. * The base implementation of `_.repeat` which doesn't coerce arguments.
  48165. *
  48166. * @private
  48167. * @param {string} string The string to repeat.
  48168. * @param {number} n The number of times to repeat the string.
  48169. * @returns {string} Returns the repeated string.
  48170. */
  48171. function baseRepeat(string, n) {
  48172. var result = '';
  48173. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  48174. return result;
  48175. }
  48176. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  48177. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  48178. do {
  48179. if (n % 2) {
  48180. result += string;
  48181. }
  48182. n = nativeFloor(n / 2);
  48183. if (n) {
  48184. string += string;
  48185. }
  48186. } while (n);
  48187. return result;
  48188. }
  48189. /**
  48190. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  48191. *
  48192. * @private
  48193. * @param {Function} func The function to apply a rest parameter to.
  48194. * @param {number} [start=func.length-1] The start position of the rest parameter.
  48195. * @returns {Function} Returns the new function.
  48196. */
  48197. function baseRest(func, start) {
  48198. return setToString(overRest(func, start, identity), func + '');
  48199. }
  48200. /**
  48201. * The base implementation of `_.sample`.
  48202. *
  48203. * @private
  48204. * @param {Array|Object} collection The collection to sample.
  48205. * @returns {*} Returns the random element.
  48206. */
  48207. function baseSample(collection) {
  48208. return arraySample(values(collection));
  48209. }
  48210. /**
  48211. * The base implementation of `_.sampleSize` without param guards.
  48212. *
  48213. * @private
  48214. * @param {Array|Object} collection The collection to sample.
  48215. * @param {number} n The number of elements to sample.
  48216. * @returns {Array} Returns the random elements.
  48217. */
  48218. function baseSampleSize(collection, n) {
  48219. var array = values(collection);
  48220. return shuffleSelf(array, baseClamp(n, 0, array.length));
  48221. }
  48222. /**
  48223. * The base implementation of `_.set`.
  48224. *
  48225. * @private
  48226. * @param {Object} object The object to modify.
  48227. * @param {Array|string} path The path of the property to set.
  48228. * @param {*} value The value to set.
  48229. * @param {Function} [customizer] The function to customize path creation.
  48230. * @returns {Object} Returns `object`.
  48231. */
  48232. function baseSet(object, path, value, customizer) {
  48233. if (!isObject(object)) {
  48234. return object;
  48235. }
  48236. path = castPath(path, object);
  48237. var index = -1,
  48238. length = path.length,
  48239. lastIndex = length - 1,
  48240. nested = object;
  48241. while (nested != null && ++index < length) {
  48242. var key = toKey(path[index]),
  48243. newValue = value;
  48244. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  48245. return object;
  48246. }
  48247. if (index != lastIndex) {
  48248. var objValue = nested[key];
  48249. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  48250. if (newValue === undefined) {
  48251. newValue = isObject(objValue)
  48252. ? objValue
  48253. : (isIndex(path[index + 1]) ? [] : {});
  48254. }
  48255. }
  48256. assignValue(nested, key, newValue);
  48257. nested = nested[key];
  48258. }
  48259. return object;
  48260. }
  48261. /**
  48262. * The base implementation of `setData` without support for hot loop shorting.
  48263. *
  48264. * @private
  48265. * @param {Function} func The function to associate metadata with.
  48266. * @param {*} data The metadata.
  48267. * @returns {Function} Returns `func`.
  48268. */
  48269. var baseSetData = !metaMap ? identity : function(func, data) {
  48270. metaMap.set(func, data);
  48271. return func;
  48272. };
  48273. /**
  48274. * The base implementation of `setToString` without support for hot loop shorting.
  48275. *
  48276. * @private
  48277. * @param {Function} func The function to modify.
  48278. * @param {Function} string The `toString` result.
  48279. * @returns {Function} Returns `func`.
  48280. */
  48281. var baseSetToString = !defineProperty ? identity : function(func, string) {
  48282. return defineProperty(func, 'toString', {
  48283. 'configurable': true,
  48284. 'enumerable': false,
  48285. 'value': constant(string),
  48286. 'writable': true
  48287. });
  48288. };
  48289. /**
  48290. * The base implementation of `_.shuffle`.
  48291. *
  48292. * @private
  48293. * @param {Array|Object} collection The collection to shuffle.
  48294. * @returns {Array} Returns the new shuffled array.
  48295. */
  48296. function baseShuffle(collection) {
  48297. return shuffleSelf(values(collection));
  48298. }
  48299. /**
  48300. * The base implementation of `_.slice` without an iteratee call guard.
  48301. *
  48302. * @private
  48303. * @param {Array} array The array to slice.
  48304. * @param {number} [start=0] The start position.
  48305. * @param {number} [end=array.length] The end position.
  48306. * @returns {Array} Returns the slice of `array`.
  48307. */
  48308. function baseSlice(array, start, end) {
  48309. var index = -1,
  48310. length = array.length;
  48311. if (start < 0) {
  48312. start = -start > length ? 0 : (length + start);
  48313. }
  48314. end = end > length ? length : end;
  48315. if (end < 0) {
  48316. end += length;
  48317. }
  48318. length = start > end ? 0 : ((end - start) >>> 0);
  48319. start >>>= 0;
  48320. var result = Array(length);
  48321. while (++index < length) {
  48322. result[index] = array[index + start];
  48323. }
  48324. return result;
  48325. }
  48326. /**
  48327. * The base implementation of `_.some` without support for iteratee shorthands.
  48328. *
  48329. * @private
  48330. * @param {Array|Object} collection The collection to iterate over.
  48331. * @param {Function} predicate The function invoked per iteration.
  48332. * @returns {boolean} Returns `true` if any element passes the predicate check,
  48333. * else `false`.
  48334. */
  48335. function baseSome(collection, predicate) {
  48336. var result;
  48337. baseEach(collection, function(value, index, collection) {
  48338. result = predicate(value, index, collection);
  48339. return !result;
  48340. });
  48341. return !!result;
  48342. }
  48343. /**
  48344. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  48345. * performs a binary search of `array` to determine the index at which `value`
  48346. * should be inserted into `array` in order to maintain its sort order.
  48347. *
  48348. * @private
  48349. * @param {Array} array The sorted array to inspect.
  48350. * @param {*} value The value to evaluate.
  48351. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  48352. * @returns {number} Returns the index at which `value` should be inserted
  48353. * into `array`.
  48354. */
  48355. function baseSortedIndex(array, value, retHighest) {
  48356. var low = 0,
  48357. high = array == null ? low : array.length;
  48358. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  48359. while (low < high) {
  48360. var mid = (low + high) >>> 1,
  48361. computed = array[mid];
  48362. if (computed !== null && !isSymbol(computed) &&
  48363. (retHighest ? (computed <= value) : (computed < value))) {
  48364. low = mid + 1;
  48365. } else {
  48366. high = mid;
  48367. }
  48368. }
  48369. return high;
  48370. }
  48371. return baseSortedIndexBy(array, value, identity, retHighest);
  48372. }
  48373. /**
  48374. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  48375. * which invokes `iteratee` for `value` and each element of `array` to compute
  48376. * their sort ranking. The iteratee is invoked with one argument; (value).
  48377. *
  48378. * @private
  48379. * @param {Array} array The sorted array to inspect.
  48380. * @param {*} value The value to evaluate.
  48381. * @param {Function} iteratee The iteratee invoked per element.
  48382. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  48383. * @returns {number} Returns the index at which `value` should be inserted
  48384. * into `array`.
  48385. */
  48386. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  48387. var low = 0,
  48388. high = array == null ? 0 : array.length;
  48389. if (high === 0) {
  48390. return 0;
  48391. }
  48392. value = iteratee(value);
  48393. var valIsNaN = value !== value,
  48394. valIsNull = value === null,
  48395. valIsSymbol = isSymbol(value),
  48396. valIsUndefined = value === undefined;
  48397. while (low < high) {
  48398. var mid = nativeFloor((low + high) / 2),
  48399. computed = iteratee(array[mid]),
  48400. othIsDefined = computed !== undefined,
  48401. othIsNull = computed === null,
  48402. othIsReflexive = computed === computed,
  48403. othIsSymbol = isSymbol(computed);
  48404. if (valIsNaN) {
  48405. var setLow = retHighest || othIsReflexive;
  48406. } else if (valIsUndefined) {
  48407. setLow = othIsReflexive && (retHighest || othIsDefined);
  48408. } else if (valIsNull) {
  48409. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  48410. } else if (valIsSymbol) {
  48411. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  48412. } else if (othIsNull || othIsSymbol) {
  48413. setLow = false;
  48414. } else {
  48415. setLow = retHighest ? (computed <= value) : (computed < value);
  48416. }
  48417. if (setLow) {
  48418. low = mid + 1;
  48419. } else {
  48420. high = mid;
  48421. }
  48422. }
  48423. return nativeMin(high, MAX_ARRAY_INDEX);
  48424. }
  48425. /**
  48426. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  48427. * support for iteratee shorthands.
  48428. *
  48429. * @private
  48430. * @param {Array} array The array to inspect.
  48431. * @param {Function} [iteratee] The iteratee invoked per element.
  48432. * @returns {Array} Returns the new duplicate free array.
  48433. */
  48434. function baseSortedUniq(array, iteratee) {
  48435. var index = -1,
  48436. length = array.length,
  48437. resIndex = 0,
  48438. result = [];
  48439. while (++index < length) {
  48440. var value = array[index],
  48441. computed = iteratee ? iteratee(value) : value;
  48442. if (!index || !eq(computed, seen)) {
  48443. var seen = computed;
  48444. result[resIndex++] = value === 0 ? 0 : value;
  48445. }
  48446. }
  48447. return result;
  48448. }
  48449. /**
  48450. * The base implementation of `_.toNumber` which doesn't ensure correct
  48451. * conversions of binary, hexadecimal, or octal string values.
  48452. *
  48453. * @private
  48454. * @param {*} value The value to process.
  48455. * @returns {number} Returns the number.
  48456. */
  48457. function baseToNumber(value) {
  48458. if (typeof value == 'number') {
  48459. return value;
  48460. }
  48461. if (isSymbol(value)) {
  48462. return NAN;
  48463. }
  48464. return +value;
  48465. }
  48466. /**
  48467. * The base implementation of `_.toString` which doesn't convert nullish
  48468. * values to empty strings.
  48469. *
  48470. * @private
  48471. * @param {*} value The value to process.
  48472. * @returns {string} Returns the string.
  48473. */
  48474. function baseToString(value) {
  48475. // Exit early for strings to avoid a performance hit in some environments.
  48476. if (typeof value == 'string') {
  48477. return value;
  48478. }
  48479. if (isArray(value)) {
  48480. // Recursively convert values (susceptible to call stack limits).
  48481. return arrayMap(value, baseToString) + '';
  48482. }
  48483. if (isSymbol(value)) {
  48484. return symbolToString ? symbolToString.call(value) : '';
  48485. }
  48486. var result = (value + '');
  48487. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  48488. }
  48489. /**
  48490. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  48491. *
  48492. * @private
  48493. * @param {Array} array The array to inspect.
  48494. * @param {Function} [iteratee] The iteratee invoked per element.
  48495. * @param {Function} [comparator] The comparator invoked per element.
  48496. * @returns {Array} Returns the new duplicate free array.
  48497. */
  48498. function baseUniq(array, iteratee, comparator) {
  48499. var index = -1,
  48500. includes = arrayIncludes,
  48501. length = array.length,
  48502. isCommon = true,
  48503. result = [],
  48504. seen = result;
  48505. if (comparator) {
  48506. isCommon = false;
  48507. includes = arrayIncludesWith;
  48508. }
  48509. else if (length >= LARGE_ARRAY_SIZE) {
  48510. var set = iteratee ? null : createSet(array);
  48511. if (set) {
  48512. return setToArray(set);
  48513. }
  48514. isCommon = false;
  48515. includes = cacheHas;
  48516. seen = new SetCache;
  48517. }
  48518. else {
  48519. seen = iteratee ? [] : result;
  48520. }
  48521. outer:
  48522. while (++index < length) {
  48523. var value = array[index],
  48524. computed = iteratee ? iteratee(value) : value;
  48525. value = (comparator || value !== 0) ? value : 0;
  48526. if (isCommon && computed === computed) {
  48527. var seenIndex = seen.length;
  48528. while (seenIndex--) {
  48529. if (seen[seenIndex] === computed) {
  48530. continue outer;
  48531. }
  48532. }
  48533. if (iteratee) {
  48534. seen.push(computed);
  48535. }
  48536. result.push(value);
  48537. }
  48538. else if (!includes(seen, computed, comparator)) {
  48539. if (seen !== result) {
  48540. seen.push(computed);
  48541. }
  48542. result.push(value);
  48543. }
  48544. }
  48545. return result;
  48546. }
  48547. /**
  48548. * The base implementation of `_.unset`.
  48549. *
  48550. * @private
  48551. * @param {Object} object The object to modify.
  48552. * @param {Array|string} path The property path to unset.
  48553. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  48554. */
  48555. function baseUnset(object, path) {
  48556. path = castPath(path, object);
  48557. object = parent(object, path);
  48558. return object == null || delete object[toKey(last(path))];
  48559. }
  48560. /**
  48561. * The base implementation of `_.update`.
  48562. *
  48563. * @private
  48564. * @param {Object} object The object to modify.
  48565. * @param {Array|string} path The path of the property to update.
  48566. * @param {Function} updater The function to produce the updated value.
  48567. * @param {Function} [customizer] The function to customize path creation.
  48568. * @returns {Object} Returns `object`.
  48569. */
  48570. function baseUpdate(object, path, updater, customizer) {
  48571. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  48572. }
  48573. /**
  48574. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  48575. * without support for iteratee shorthands.
  48576. *
  48577. * @private
  48578. * @param {Array} array The array to query.
  48579. * @param {Function} predicate The function invoked per iteration.
  48580. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  48581. * @param {boolean} [fromRight] Specify iterating from right to left.
  48582. * @returns {Array} Returns the slice of `array`.
  48583. */
  48584. function baseWhile(array, predicate, isDrop, fromRight) {
  48585. var length = array.length,
  48586. index = fromRight ? length : -1;
  48587. while ((fromRight ? index-- : ++index < length) &&
  48588. predicate(array[index], index, array)) {}
  48589. return isDrop
  48590. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  48591. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  48592. }
  48593. /**
  48594. * The base implementation of `wrapperValue` which returns the result of
  48595. * performing a sequence of actions on the unwrapped `value`, where each
  48596. * successive action is supplied the return value of the previous.
  48597. *
  48598. * @private
  48599. * @param {*} value The unwrapped value.
  48600. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  48601. * @returns {*} Returns the resolved value.
  48602. */
  48603. function baseWrapperValue(value, actions) {
  48604. var result = value;
  48605. if (result instanceof LazyWrapper) {
  48606. result = result.value();
  48607. }
  48608. return arrayReduce(actions, function(result, action) {
  48609. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  48610. }, result);
  48611. }
  48612. /**
  48613. * The base implementation of methods like `_.xor`, without support for
  48614. * iteratee shorthands, that accepts an array of arrays to inspect.
  48615. *
  48616. * @private
  48617. * @param {Array} arrays The arrays to inspect.
  48618. * @param {Function} [iteratee] The iteratee invoked per element.
  48619. * @param {Function} [comparator] The comparator invoked per element.
  48620. * @returns {Array} Returns the new array of values.
  48621. */
  48622. function baseXor(arrays, iteratee, comparator) {
  48623. var length = arrays.length;
  48624. if (length < 2) {
  48625. return length ? baseUniq(arrays[0]) : [];
  48626. }
  48627. var index = -1,
  48628. result = Array(length);
  48629. while (++index < length) {
  48630. var array = arrays[index],
  48631. othIndex = -1;
  48632. while (++othIndex < length) {
  48633. if (othIndex != index) {
  48634. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  48635. }
  48636. }
  48637. }
  48638. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  48639. }
  48640. /**
  48641. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  48642. *
  48643. * @private
  48644. * @param {Array} props The property identifiers.
  48645. * @param {Array} values The property values.
  48646. * @param {Function} assignFunc The function to assign values.
  48647. * @returns {Object} Returns the new object.
  48648. */
  48649. function baseZipObject(props, values, assignFunc) {
  48650. var index = -1,
  48651. length = props.length,
  48652. valsLength = values.length,
  48653. result = {};
  48654. while (++index < length) {
  48655. var value = index < valsLength ? values[index] : undefined;
  48656. assignFunc(result, props[index], value);
  48657. }
  48658. return result;
  48659. }
  48660. /**
  48661. * Casts `value` to an empty array if it's not an array like object.
  48662. *
  48663. * @private
  48664. * @param {*} value The value to inspect.
  48665. * @returns {Array|Object} Returns the cast array-like object.
  48666. */
  48667. function castArrayLikeObject(value) {
  48668. return isArrayLikeObject(value) ? value : [];
  48669. }
  48670. /**
  48671. * Casts `value` to `identity` if it's not a function.
  48672. *
  48673. * @private
  48674. * @param {*} value The value to inspect.
  48675. * @returns {Function} Returns cast function.
  48676. */
  48677. function castFunction(value) {
  48678. return typeof value == 'function' ? value : identity;
  48679. }
  48680. /**
  48681. * Casts `value` to a path array if it's not one.
  48682. *
  48683. * @private
  48684. * @param {*} value The value to inspect.
  48685. * @param {Object} [object] The object to query keys on.
  48686. * @returns {Array} Returns the cast property path array.
  48687. */
  48688. function castPath(value, object) {
  48689. if (isArray(value)) {
  48690. return value;
  48691. }
  48692. return isKey(value, object) ? [value] : stringToPath(toString(value));
  48693. }
  48694. /**
  48695. * A `baseRest` alias which can be replaced with `identity` by module
  48696. * replacement plugins.
  48697. *
  48698. * @private
  48699. * @type {Function}
  48700. * @param {Function} func The function to apply a rest parameter to.
  48701. * @returns {Function} Returns the new function.
  48702. */
  48703. var castRest = baseRest;
  48704. /**
  48705. * Casts `array` to a slice if it's needed.
  48706. *
  48707. * @private
  48708. * @param {Array} array The array to inspect.
  48709. * @param {number} start The start position.
  48710. * @param {number} [end=array.length] The end position.
  48711. * @returns {Array} Returns the cast slice.
  48712. */
  48713. function castSlice(array, start, end) {
  48714. var length = array.length;
  48715. end = end === undefined ? length : end;
  48716. return (!start && end >= length) ? array : baseSlice(array, start, end);
  48717. }
  48718. /**
  48719. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  48720. *
  48721. * @private
  48722. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  48723. */
  48724. var clearTimeout = ctxClearTimeout || function(id) {
  48725. return root.clearTimeout(id);
  48726. };
  48727. /**
  48728. * Creates a clone of `buffer`.
  48729. *
  48730. * @private
  48731. * @param {Buffer} buffer The buffer to clone.
  48732. * @param {boolean} [isDeep] Specify a deep clone.
  48733. * @returns {Buffer} Returns the cloned buffer.
  48734. */
  48735. function cloneBuffer(buffer, isDeep) {
  48736. if (isDeep) {
  48737. return buffer.slice();
  48738. }
  48739. var length = buffer.length,
  48740. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  48741. buffer.copy(result);
  48742. return result;
  48743. }
  48744. /**
  48745. * Creates a clone of `arrayBuffer`.
  48746. *
  48747. * @private
  48748. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  48749. * @returns {ArrayBuffer} Returns the cloned array buffer.
  48750. */
  48751. function cloneArrayBuffer(arrayBuffer) {
  48752. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  48753. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  48754. return result;
  48755. }
  48756. /**
  48757. * Creates a clone of `dataView`.
  48758. *
  48759. * @private
  48760. * @param {Object} dataView The data view to clone.
  48761. * @param {boolean} [isDeep] Specify a deep clone.
  48762. * @returns {Object} Returns the cloned data view.
  48763. */
  48764. function cloneDataView(dataView, isDeep) {
  48765. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  48766. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  48767. }
  48768. /**
  48769. * Creates a clone of `regexp`.
  48770. *
  48771. * @private
  48772. * @param {Object} regexp The regexp to clone.
  48773. * @returns {Object} Returns the cloned regexp.
  48774. */
  48775. function cloneRegExp(regexp) {
  48776. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  48777. result.lastIndex = regexp.lastIndex;
  48778. return result;
  48779. }
  48780. /**
  48781. * Creates a clone of the `symbol` object.
  48782. *
  48783. * @private
  48784. * @param {Object} symbol The symbol object to clone.
  48785. * @returns {Object} Returns the cloned symbol object.
  48786. */
  48787. function cloneSymbol(symbol) {
  48788. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  48789. }
  48790. /**
  48791. * Creates a clone of `typedArray`.
  48792. *
  48793. * @private
  48794. * @param {Object} typedArray The typed array to clone.
  48795. * @param {boolean} [isDeep] Specify a deep clone.
  48796. * @returns {Object} Returns the cloned typed array.
  48797. */
  48798. function cloneTypedArray(typedArray, isDeep) {
  48799. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  48800. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  48801. }
  48802. /**
  48803. * Compares values to sort them in ascending order.
  48804. *
  48805. * @private
  48806. * @param {*} value The value to compare.
  48807. * @param {*} other The other value to compare.
  48808. * @returns {number} Returns the sort order indicator for `value`.
  48809. */
  48810. function compareAscending(value, other) {
  48811. if (value !== other) {
  48812. var valIsDefined = value !== undefined,
  48813. valIsNull = value === null,
  48814. valIsReflexive = value === value,
  48815. valIsSymbol = isSymbol(value);
  48816. var othIsDefined = other !== undefined,
  48817. othIsNull = other === null,
  48818. othIsReflexive = other === other,
  48819. othIsSymbol = isSymbol(other);
  48820. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  48821. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  48822. (valIsNull && othIsDefined && othIsReflexive) ||
  48823. (!valIsDefined && othIsReflexive) ||
  48824. !valIsReflexive) {
  48825. return 1;
  48826. }
  48827. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  48828. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  48829. (othIsNull && valIsDefined && valIsReflexive) ||
  48830. (!othIsDefined && valIsReflexive) ||
  48831. !othIsReflexive) {
  48832. return -1;
  48833. }
  48834. }
  48835. return 0;
  48836. }
  48837. /**
  48838. * Used by `_.orderBy` to compare multiple properties of a value to another
  48839. * and stable sort them.
  48840. *
  48841. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  48842. * specify an order of "desc" for descending or "asc" for ascending sort order
  48843. * of corresponding values.
  48844. *
  48845. * @private
  48846. * @param {Object} object The object to compare.
  48847. * @param {Object} other The other object to compare.
  48848. * @param {boolean[]|string[]} orders The order to sort by for each property.
  48849. * @returns {number} Returns the sort order indicator for `object`.
  48850. */
  48851. function compareMultiple(object, other, orders) {
  48852. var index = -1,
  48853. objCriteria = object.criteria,
  48854. othCriteria = other.criteria,
  48855. length = objCriteria.length,
  48856. ordersLength = orders.length;
  48857. while (++index < length) {
  48858. var result = compareAscending(objCriteria[index], othCriteria[index]);
  48859. if (result) {
  48860. if (index >= ordersLength) {
  48861. return result;
  48862. }
  48863. var order = orders[index];
  48864. return result * (order == 'desc' ? -1 : 1);
  48865. }
  48866. }
  48867. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  48868. // that causes it, under certain circumstances, to provide the same value for
  48869. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  48870. // for more details.
  48871. //
  48872. // This also ensures a stable sort in V8 and other engines.
  48873. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  48874. return object.index - other.index;
  48875. }
  48876. /**
  48877. * Creates an array that is the composition of partially applied arguments,
  48878. * placeholders, and provided arguments into a single array of arguments.
  48879. *
  48880. * @private
  48881. * @param {Array} args The provided arguments.
  48882. * @param {Array} partials The arguments to prepend to those provided.
  48883. * @param {Array} holders The `partials` placeholder indexes.
  48884. * @params {boolean} [isCurried] Specify composing for a curried function.
  48885. * @returns {Array} Returns the new array of composed arguments.
  48886. */
  48887. function composeArgs(args, partials, holders, isCurried) {
  48888. var argsIndex = -1,
  48889. argsLength = args.length,
  48890. holdersLength = holders.length,
  48891. leftIndex = -1,
  48892. leftLength = partials.length,
  48893. rangeLength = nativeMax(argsLength - holdersLength, 0),
  48894. result = Array(leftLength + rangeLength),
  48895. isUncurried = !isCurried;
  48896. while (++leftIndex < leftLength) {
  48897. result[leftIndex] = partials[leftIndex];
  48898. }
  48899. while (++argsIndex < holdersLength) {
  48900. if (isUncurried || argsIndex < argsLength) {
  48901. result[holders[argsIndex]] = args[argsIndex];
  48902. }
  48903. }
  48904. while (rangeLength--) {
  48905. result[leftIndex++] = args[argsIndex++];
  48906. }
  48907. return result;
  48908. }
  48909. /**
  48910. * This function is like `composeArgs` except that the arguments composition
  48911. * is tailored for `_.partialRight`.
  48912. *
  48913. * @private
  48914. * @param {Array} args The provided arguments.
  48915. * @param {Array} partials The arguments to append to those provided.
  48916. * @param {Array} holders The `partials` placeholder indexes.
  48917. * @params {boolean} [isCurried] Specify composing for a curried function.
  48918. * @returns {Array} Returns the new array of composed arguments.
  48919. */
  48920. function composeArgsRight(args, partials, holders, isCurried) {
  48921. var argsIndex = -1,
  48922. argsLength = args.length,
  48923. holdersIndex = -1,
  48924. holdersLength = holders.length,
  48925. rightIndex = -1,
  48926. rightLength = partials.length,
  48927. rangeLength = nativeMax(argsLength - holdersLength, 0),
  48928. result = Array(rangeLength + rightLength),
  48929. isUncurried = !isCurried;
  48930. while (++argsIndex < rangeLength) {
  48931. result[argsIndex] = args[argsIndex];
  48932. }
  48933. var offset = argsIndex;
  48934. while (++rightIndex < rightLength) {
  48935. result[offset + rightIndex] = partials[rightIndex];
  48936. }
  48937. while (++holdersIndex < holdersLength) {
  48938. if (isUncurried || argsIndex < argsLength) {
  48939. result[offset + holders[holdersIndex]] = args[argsIndex++];
  48940. }
  48941. }
  48942. return result;
  48943. }
  48944. /**
  48945. * Copies the values of `source` to `array`.
  48946. *
  48947. * @private
  48948. * @param {Array} source The array to copy values from.
  48949. * @param {Array} [array=[]] The array to copy values to.
  48950. * @returns {Array} Returns `array`.
  48951. */
  48952. function copyArray(source, array) {
  48953. var index = -1,
  48954. length = source.length;
  48955. array || (array = Array(length));
  48956. while (++index < length) {
  48957. array[index] = source[index];
  48958. }
  48959. return array;
  48960. }
  48961. /**
  48962. * Copies properties of `source` to `object`.
  48963. *
  48964. * @private
  48965. * @param {Object} source The object to copy properties from.
  48966. * @param {Array} props The property identifiers to copy.
  48967. * @param {Object} [object={}] The object to copy properties to.
  48968. * @param {Function} [customizer] The function to customize copied values.
  48969. * @returns {Object} Returns `object`.
  48970. */
  48971. function copyObject(source, props, object, customizer) {
  48972. var isNew = !object;
  48973. object || (object = {});
  48974. var index = -1,
  48975. length = props.length;
  48976. while (++index < length) {
  48977. var key = props[index];
  48978. var newValue = customizer
  48979. ? customizer(object[key], source[key], key, object, source)
  48980. : undefined;
  48981. if (newValue === undefined) {
  48982. newValue = source[key];
  48983. }
  48984. if (isNew) {
  48985. baseAssignValue(object, key, newValue);
  48986. } else {
  48987. assignValue(object, key, newValue);
  48988. }
  48989. }
  48990. return object;
  48991. }
  48992. /**
  48993. * Copies own symbols of `source` to `object`.
  48994. *
  48995. * @private
  48996. * @param {Object} source The object to copy symbols from.
  48997. * @param {Object} [object={}] The object to copy symbols to.
  48998. * @returns {Object} Returns `object`.
  48999. */
  49000. function copySymbols(source, object) {
  49001. return copyObject(source, getSymbols(source), object);
  49002. }
  49003. /**
  49004. * Copies own and inherited symbols of `source` to `object`.
  49005. *
  49006. * @private
  49007. * @param {Object} source The object to copy symbols from.
  49008. * @param {Object} [object={}] The object to copy symbols to.
  49009. * @returns {Object} Returns `object`.
  49010. */
  49011. function copySymbolsIn(source, object) {
  49012. return copyObject(source, getSymbolsIn(source), object);
  49013. }
  49014. /**
  49015. * Creates a function like `_.groupBy`.
  49016. *
  49017. * @private
  49018. * @param {Function} setter The function to set accumulator values.
  49019. * @param {Function} [initializer] The accumulator object initializer.
  49020. * @returns {Function} Returns the new aggregator function.
  49021. */
  49022. function createAggregator(setter, initializer) {
  49023. return function(collection, iteratee) {
  49024. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  49025. accumulator = initializer ? initializer() : {};
  49026. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  49027. };
  49028. }
  49029. /**
  49030. * Creates a function like `_.assign`.
  49031. *
  49032. * @private
  49033. * @param {Function} assigner The function to assign values.
  49034. * @returns {Function} Returns the new assigner function.
  49035. */
  49036. function createAssigner(assigner) {
  49037. return baseRest(function(object, sources) {
  49038. var index = -1,
  49039. length = sources.length,
  49040. customizer = length > 1 ? sources[length - 1] : undefined,
  49041. guard = length > 2 ? sources[2] : undefined;
  49042. customizer = (assigner.length > 3 && typeof customizer == 'function')
  49043. ? (length--, customizer)
  49044. : undefined;
  49045. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  49046. customizer = length < 3 ? undefined : customizer;
  49047. length = 1;
  49048. }
  49049. object = Object(object);
  49050. while (++index < length) {
  49051. var source = sources[index];
  49052. if (source) {
  49053. assigner(object, source, index, customizer);
  49054. }
  49055. }
  49056. return object;
  49057. });
  49058. }
  49059. /**
  49060. * Creates a `baseEach` or `baseEachRight` function.
  49061. *
  49062. * @private
  49063. * @param {Function} eachFunc The function to iterate over a collection.
  49064. * @param {boolean} [fromRight] Specify iterating from right to left.
  49065. * @returns {Function} Returns the new base function.
  49066. */
  49067. function createBaseEach(eachFunc, fromRight) {
  49068. return function(collection, iteratee) {
  49069. if (collection == null) {
  49070. return collection;
  49071. }
  49072. if (!isArrayLike(collection)) {
  49073. return eachFunc(collection, iteratee);
  49074. }
  49075. var length = collection.length,
  49076. index = fromRight ? length : -1,
  49077. iterable = Object(collection);
  49078. while ((fromRight ? index-- : ++index < length)) {
  49079. if (iteratee(iterable[index], index, iterable) === false) {
  49080. break;
  49081. }
  49082. }
  49083. return collection;
  49084. };
  49085. }
  49086. /**
  49087. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  49088. *
  49089. * @private
  49090. * @param {boolean} [fromRight] Specify iterating from right to left.
  49091. * @returns {Function} Returns the new base function.
  49092. */
  49093. function createBaseFor(fromRight) {
  49094. return function(object, iteratee, keysFunc) {
  49095. var index = -1,
  49096. iterable = Object(object),
  49097. props = keysFunc(object),
  49098. length = props.length;
  49099. while (length--) {
  49100. var key = props[fromRight ? length : ++index];
  49101. if (iteratee(iterable[key], key, iterable) === false) {
  49102. break;
  49103. }
  49104. }
  49105. return object;
  49106. };
  49107. }
  49108. /**
  49109. * Creates a function that wraps `func` to invoke it with the optional `this`
  49110. * binding of `thisArg`.
  49111. *
  49112. * @private
  49113. * @param {Function} func The function to wrap.
  49114. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  49115. * @param {*} [thisArg] The `this` binding of `func`.
  49116. * @returns {Function} Returns the new wrapped function.
  49117. */
  49118. function createBind(func, bitmask, thisArg) {
  49119. var isBind = bitmask & WRAP_BIND_FLAG,
  49120. Ctor = createCtor(func);
  49121. function wrapper() {
  49122. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  49123. return fn.apply(isBind ? thisArg : this, arguments);
  49124. }
  49125. return wrapper;
  49126. }
  49127. /**
  49128. * Creates a function like `_.lowerFirst`.
  49129. *
  49130. * @private
  49131. * @param {string} methodName The name of the `String` case method to use.
  49132. * @returns {Function} Returns the new case function.
  49133. */
  49134. function createCaseFirst(methodName) {
  49135. return function(string) {
  49136. string = toString(string);
  49137. var strSymbols = hasUnicode(string)
  49138. ? stringToArray(string)
  49139. : undefined;
  49140. var chr = strSymbols
  49141. ? strSymbols[0]
  49142. : string.charAt(0);
  49143. var trailing = strSymbols
  49144. ? castSlice(strSymbols, 1).join('')
  49145. : string.slice(1);
  49146. return chr[methodName]() + trailing;
  49147. };
  49148. }
  49149. /**
  49150. * Creates a function like `_.camelCase`.
  49151. *
  49152. * @private
  49153. * @param {Function} callback The function to combine each word.
  49154. * @returns {Function} Returns the new compounder function.
  49155. */
  49156. function createCompounder(callback) {
  49157. return function(string) {
  49158. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  49159. };
  49160. }
  49161. /**
  49162. * Creates a function that produces an instance of `Ctor` regardless of
  49163. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  49164. *
  49165. * @private
  49166. * @param {Function} Ctor The constructor to wrap.
  49167. * @returns {Function} Returns the new wrapped function.
  49168. */
  49169. function createCtor(Ctor) {
  49170. return function() {
  49171. // Use a `switch` statement to work with class constructors. See
  49172. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  49173. // for more details.
  49174. var args = arguments;
  49175. switch (args.length) {
  49176. case 0: return new Ctor;
  49177. case 1: return new Ctor(args[0]);
  49178. case 2: return new Ctor(args[0], args[1]);
  49179. case 3: return new Ctor(args[0], args[1], args[2]);
  49180. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  49181. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  49182. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  49183. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  49184. }
  49185. var thisBinding = baseCreate(Ctor.prototype),
  49186. result = Ctor.apply(thisBinding, args);
  49187. // Mimic the constructor's `return` behavior.
  49188. // See https://es5.github.io/#x13.2.2 for more details.
  49189. return isObject(result) ? result : thisBinding;
  49190. };
  49191. }
  49192. /**
  49193. * Creates a function that wraps `func` to enable currying.
  49194. *
  49195. * @private
  49196. * @param {Function} func The function to wrap.
  49197. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  49198. * @param {number} arity The arity of `func`.
  49199. * @returns {Function} Returns the new wrapped function.
  49200. */
  49201. function createCurry(func, bitmask, arity) {
  49202. var Ctor = createCtor(func);
  49203. function wrapper() {
  49204. var length = arguments.length,
  49205. args = Array(length),
  49206. index = length,
  49207. placeholder = getHolder(wrapper);
  49208. while (index--) {
  49209. args[index] = arguments[index];
  49210. }
  49211. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  49212. ? []
  49213. : replaceHolders(args, placeholder);
  49214. length -= holders.length;
  49215. if (length < arity) {
  49216. return createRecurry(
  49217. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  49218. args, holders, undefined, undefined, arity - length);
  49219. }
  49220. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  49221. return apply(fn, this, args);
  49222. }
  49223. return wrapper;
  49224. }
  49225. /**
  49226. * Creates a `_.find` or `_.findLast` function.
  49227. *
  49228. * @private
  49229. * @param {Function} findIndexFunc The function to find the collection index.
  49230. * @returns {Function} Returns the new find function.
  49231. */
  49232. function createFind(findIndexFunc) {
  49233. return function(collection, predicate, fromIndex) {
  49234. var iterable = Object(collection);
  49235. if (!isArrayLike(collection)) {
  49236. var iteratee = getIteratee(predicate, 3);
  49237. collection = keys(collection);
  49238. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  49239. }
  49240. var index = findIndexFunc(collection, predicate, fromIndex);
  49241. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  49242. };
  49243. }
  49244. /**
  49245. * Creates a `_.flow` or `_.flowRight` function.
  49246. *
  49247. * @private
  49248. * @param {boolean} [fromRight] Specify iterating from right to left.
  49249. * @returns {Function} Returns the new flow function.
  49250. */
  49251. function createFlow(fromRight) {
  49252. return flatRest(function(funcs) {
  49253. var length = funcs.length,
  49254. index = length,
  49255. prereq = LodashWrapper.prototype.thru;
  49256. if (fromRight) {
  49257. funcs.reverse();
  49258. }
  49259. while (index--) {
  49260. var func = funcs[index];
  49261. if (typeof func != 'function') {
  49262. throw new TypeError(FUNC_ERROR_TEXT);
  49263. }
  49264. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  49265. var wrapper = new LodashWrapper([], true);
  49266. }
  49267. }
  49268. index = wrapper ? index : length;
  49269. while (++index < length) {
  49270. func = funcs[index];
  49271. var funcName = getFuncName(func),
  49272. data = funcName == 'wrapper' ? getData(func) : undefined;
  49273. if (data && isLaziable(data[0]) &&
  49274. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  49275. !data[4].length && data[9] == 1
  49276. ) {
  49277. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  49278. } else {
  49279. wrapper = (func.length == 1 && isLaziable(func))
  49280. ? wrapper[funcName]()
  49281. : wrapper.thru(func);
  49282. }
  49283. }
  49284. return function() {
  49285. var args = arguments,
  49286. value = args[0];
  49287. if (wrapper && args.length == 1 && isArray(value)) {
  49288. return wrapper.plant(value).value();
  49289. }
  49290. var index = 0,
  49291. result = length ? funcs[index].apply(this, args) : value;
  49292. while (++index < length) {
  49293. result = funcs[index].call(this, result);
  49294. }
  49295. return result;
  49296. };
  49297. });
  49298. }
  49299. /**
  49300. * Creates a function that wraps `func` to invoke it with optional `this`
  49301. * binding of `thisArg`, partial application, and currying.
  49302. *
  49303. * @private
  49304. * @param {Function|string} func The function or method name to wrap.
  49305. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  49306. * @param {*} [thisArg] The `this` binding of `func`.
  49307. * @param {Array} [partials] The arguments to prepend to those provided to
  49308. * the new function.
  49309. * @param {Array} [holders] The `partials` placeholder indexes.
  49310. * @param {Array} [partialsRight] The arguments to append to those provided
  49311. * to the new function.
  49312. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  49313. * @param {Array} [argPos] The argument positions of the new function.
  49314. * @param {number} [ary] The arity cap of `func`.
  49315. * @param {number} [arity] The arity of `func`.
  49316. * @returns {Function} Returns the new wrapped function.
  49317. */
  49318. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  49319. var isAry = bitmask & WRAP_ARY_FLAG,
  49320. isBind = bitmask & WRAP_BIND_FLAG,
  49321. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  49322. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  49323. isFlip = bitmask & WRAP_FLIP_FLAG,
  49324. Ctor = isBindKey ? undefined : createCtor(func);
  49325. function wrapper() {
  49326. var length = arguments.length,
  49327. args = Array(length),
  49328. index = length;
  49329. while (index--) {
  49330. args[index] = arguments[index];
  49331. }
  49332. if (isCurried) {
  49333. var placeholder = getHolder(wrapper),
  49334. holdersCount = countHolders(args, placeholder);
  49335. }
  49336. if (partials) {
  49337. args = composeArgs(args, partials, holders, isCurried);
  49338. }
  49339. if (partialsRight) {
  49340. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  49341. }
  49342. length -= holdersCount;
  49343. if (isCurried && length < arity) {
  49344. var newHolders = replaceHolders(args, placeholder);
  49345. return createRecurry(
  49346. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  49347. args, newHolders, argPos, ary, arity - length
  49348. );
  49349. }
  49350. var thisBinding = isBind ? thisArg : this,
  49351. fn = isBindKey ? thisBinding[func] : func;
  49352. length = args.length;
  49353. if (argPos) {
  49354. args = reorder(args, argPos);
  49355. } else if (isFlip && length > 1) {
  49356. args.reverse();
  49357. }
  49358. if (isAry && ary < length) {
  49359. args.length = ary;
  49360. }
  49361. if (this && this !== root && this instanceof wrapper) {
  49362. fn = Ctor || createCtor(fn);
  49363. }
  49364. return fn.apply(thisBinding, args);
  49365. }
  49366. return wrapper;
  49367. }
  49368. /**
  49369. * Creates a function like `_.invertBy`.
  49370. *
  49371. * @private
  49372. * @param {Function} setter The function to set accumulator values.
  49373. * @param {Function} toIteratee The function to resolve iteratees.
  49374. * @returns {Function} Returns the new inverter function.
  49375. */
  49376. function createInverter(setter, toIteratee) {
  49377. return function(object, iteratee) {
  49378. return baseInverter(object, setter, toIteratee(iteratee), {});
  49379. };
  49380. }
  49381. /**
  49382. * Creates a function that performs a mathematical operation on two values.
  49383. *
  49384. * @private
  49385. * @param {Function} operator The function to perform the operation.
  49386. * @param {number} [defaultValue] The value used for `undefined` arguments.
  49387. * @returns {Function} Returns the new mathematical operation function.
  49388. */
  49389. function createMathOperation(operator, defaultValue) {
  49390. return function(value, other) {
  49391. var result;
  49392. if (value === undefined && other === undefined) {
  49393. return defaultValue;
  49394. }
  49395. if (value !== undefined) {
  49396. result = value;
  49397. }
  49398. if (other !== undefined) {
  49399. if (result === undefined) {
  49400. return other;
  49401. }
  49402. if (typeof value == 'string' || typeof other == 'string') {
  49403. value = baseToString(value);
  49404. other = baseToString(other);
  49405. } else {
  49406. value = baseToNumber(value);
  49407. other = baseToNumber(other);
  49408. }
  49409. result = operator(value, other);
  49410. }
  49411. return result;
  49412. };
  49413. }
  49414. /**
  49415. * Creates a function like `_.over`.
  49416. *
  49417. * @private
  49418. * @param {Function} arrayFunc The function to iterate over iteratees.
  49419. * @returns {Function} Returns the new over function.
  49420. */
  49421. function createOver(arrayFunc) {
  49422. return flatRest(function(iteratees) {
  49423. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  49424. return baseRest(function(args) {
  49425. var thisArg = this;
  49426. return arrayFunc(iteratees, function(iteratee) {
  49427. return apply(iteratee, thisArg, args);
  49428. });
  49429. });
  49430. });
  49431. }
  49432. /**
  49433. * Creates the padding for `string` based on `length`. The `chars` string
  49434. * is truncated if the number of characters exceeds `length`.
  49435. *
  49436. * @private
  49437. * @param {number} length The padding length.
  49438. * @param {string} [chars=' '] The string used as padding.
  49439. * @returns {string} Returns the padding for `string`.
  49440. */
  49441. function createPadding(length, chars) {
  49442. chars = chars === undefined ? ' ' : baseToString(chars);
  49443. var charsLength = chars.length;
  49444. if (charsLength < 2) {
  49445. return charsLength ? baseRepeat(chars, length) : chars;
  49446. }
  49447. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  49448. return hasUnicode(chars)
  49449. ? castSlice(stringToArray(result), 0, length).join('')
  49450. : result.slice(0, length);
  49451. }
  49452. /**
  49453. * Creates a function that wraps `func` to invoke it with the `this` binding
  49454. * of `thisArg` and `partials` prepended to the arguments it receives.
  49455. *
  49456. * @private
  49457. * @param {Function} func The function to wrap.
  49458. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  49459. * @param {*} thisArg The `this` binding of `func`.
  49460. * @param {Array} partials The arguments to prepend to those provided to
  49461. * the new function.
  49462. * @returns {Function} Returns the new wrapped function.
  49463. */
  49464. function createPartial(func, bitmask, thisArg, partials) {
  49465. var isBind = bitmask & WRAP_BIND_FLAG,
  49466. Ctor = createCtor(func);
  49467. function wrapper() {
  49468. var argsIndex = -1,
  49469. argsLength = arguments.length,
  49470. leftIndex = -1,
  49471. leftLength = partials.length,
  49472. args = Array(leftLength + argsLength),
  49473. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  49474. while (++leftIndex < leftLength) {
  49475. args[leftIndex] = partials[leftIndex];
  49476. }
  49477. while (argsLength--) {
  49478. args[leftIndex++] = arguments[++argsIndex];
  49479. }
  49480. return apply(fn, isBind ? thisArg : this, args);
  49481. }
  49482. return wrapper;
  49483. }
  49484. /**
  49485. * Creates a `_.range` or `_.rangeRight` function.
  49486. *
  49487. * @private
  49488. * @param {boolean} [fromRight] Specify iterating from right to left.
  49489. * @returns {Function} Returns the new range function.
  49490. */
  49491. function createRange(fromRight) {
  49492. return function(start, end, step) {
  49493. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  49494. end = step = undefined;
  49495. }
  49496. // Ensure the sign of `-0` is preserved.
  49497. start = toFinite(start);
  49498. if (end === undefined) {
  49499. end = start;
  49500. start = 0;
  49501. } else {
  49502. end = toFinite(end);
  49503. }
  49504. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  49505. return baseRange(start, end, step, fromRight);
  49506. };
  49507. }
  49508. /**
  49509. * Creates a function that performs a relational operation on two values.
  49510. *
  49511. * @private
  49512. * @param {Function} operator The function to perform the operation.
  49513. * @returns {Function} Returns the new relational operation function.
  49514. */
  49515. function createRelationalOperation(operator) {
  49516. return function(value, other) {
  49517. if (!(typeof value == 'string' && typeof other == 'string')) {
  49518. value = toNumber(value);
  49519. other = toNumber(other);
  49520. }
  49521. return operator(value, other);
  49522. };
  49523. }
  49524. /**
  49525. * Creates a function that wraps `func` to continue currying.
  49526. *
  49527. * @private
  49528. * @param {Function} func The function to wrap.
  49529. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  49530. * @param {Function} wrapFunc The function to create the `func` wrapper.
  49531. * @param {*} placeholder The placeholder value.
  49532. * @param {*} [thisArg] The `this` binding of `func`.
  49533. * @param {Array} [partials] The arguments to prepend to those provided to
  49534. * the new function.
  49535. * @param {Array} [holders] The `partials` placeholder indexes.
  49536. * @param {Array} [argPos] The argument positions of the new function.
  49537. * @param {number} [ary] The arity cap of `func`.
  49538. * @param {number} [arity] The arity of `func`.
  49539. * @returns {Function} Returns the new wrapped function.
  49540. */
  49541. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  49542. var isCurry = bitmask & WRAP_CURRY_FLAG,
  49543. newHolders = isCurry ? holders : undefined,
  49544. newHoldersRight = isCurry ? undefined : holders,
  49545. newPartials = isCurry ? partials : undefined,
  49546. newPartialsRight = isCurry ? undefined : partials;
  49547. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  49548. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  49549. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  49550. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  49551. }
  49552. var newData = [
  49553. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  49554. newHoldersRight, argPos, ary, arity
  49555. ];
  49556. var result = wrapFunc.apply(undefined, newData);
  49557. if (isLaziable(func)) {
  49558. setData(result, newData);
  49559. }
  49560. result.placeholder = placeholder;
  49561. return setWrapToString(result, func, bitmask);
  49562. }
  49563. /**
  49564. * Creates a function like `_.round`.
  49565. *
  49566. * @private
  49567. * @param {string} methodName The name of the `Math` method to use when rounding.
  49568. * @returns {Function} Returns the new round function.
  49569. */
  49570. function createRound(methodName) {
  49571. var func = Math[methodName];
  49572. return function(number, precision) {
  49573. number = toNumber(number);
  49574. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  49575. if (precision && nativeIsFinite(number)) {
  49576. // Shift with exponential notation to avoid floating-point issues.
  49577. // See [MDN](https://mdn.io/round#Examples) for more details.
  49578. var pair = (toString(number) + 'e').split('e'),
  49579. value = func(pair[0] + 'e' + (+pair[1] + precision));
  49580. pair = (toString(value) + 'e').split('e');
  49581. return +(pair[0] + 'e' + (+pair[1] - precision));
  49582. }
  49583. return func(number);
  49584. };
  49585. }
  49586. /**
  49587. * Creates a set object of `values`.
  49588. *
  49589. * @private
  49590. * @param {Array} values The values to add to the set.
  49591. * @returns {Object} Returns the new set.
  49592. */
  49593. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  49594. return new Set(values);
  49595. };
  49596. /**
  49597. * Creates a `_.toPairs` or `_.toPairsIn` function.
  49598. *
  49599. * @private
  49600. * @param {Function} keysFunc The function to get the keys of a given object.
  49601. * @returns {Function} Returns the new pairs function.
  49602. */
  49603. function createToPairs(keysFunc) {
  49604. return function(object) {
  49605. var tag = getTag(object);
  49606. if (tag == mapTag) {
  49607. return mapToArray(object);
  49608. }
  49609. if (tag == setTag) {
  49610. return setToPairs(object);
  49611. }
  49612. return baseToPairs(object, keysFunc(object));
  49613. };
  49614. }
  49615. /**
  49616. * Creates a function that either curries or invokes `func` with optional
  49617. * `this` binding and partially applied arguments.
  49618. *
  49619. * @private
  49620. * @param {Function|string} func The function or method name to wrap.
  49621. * @param {number} bitmask The bitmask flags.
  49622. * 1 - `_.bind`
  49623. * 2 - `_.bindKey`
  49624. * 4 - `_.curry` or `_.curryRight` of a bound function
  49625. * 8 - `_.curry`
  49626. * 16 - `_.curryRight`
  49627. * 32 - `_.partial`
  49628. * 64 - `_.partialRight`
  49629. * 128 - `_.rearg`
  49630. * 256 - `_.ary`
  49631. * 512 - `_.flip`
  49632. * @param {*} [thisArg] The `this` binding of `func`.
  49633. * @param {Array} [partials] The arguments to be partially applied.
  49634. * @param {Array} [holders] The `partials` placeholder indexes.
  49635. * @param {Array} [argPos] The argument positions of the new function.
  49636. * @param {number} [ary] The arity cap of `func`.
  49637. * @param {number} [arity] The arity of `func`.
  49638. * @returns {Function} Returns the new wrapped function.
  49639. */
  49640. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  49641. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  49642. if (!isBindKey && typeof func != 'function') {
  49643. throw new TypeError(FUNC_ERROR_TEXT);
  49644. }
  49645. var length = partials ? partials.length : 0;
  49646. if (!length) {
  49647. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  49648. partials = holders = undefined;
  49649. }
  49650. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  49651. arity = arity === undefined ? arity : toInteger(arity);
  49652. length -= holders ? holders.length : 0;
  49653. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  49654. var partialsRight = partials,
  49655. holdersRight = holders;
  49656. partials = holders = undefined;
  49657. }
  49658. var data = isBindKey ? undefined : getData(func);
  49659. var newData = [
  49660. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  49661. argPos, ary, arity
  49662. ];
  49663. if (data) {
  49664. mergeData(newData, data);
  49665. }
  49666. func = newData[0];
  49667. bitmask = newData[1];
  49668. thisArg = newData[2];
  49669. partials = newData[3];
  49670. holders = newData[4];
  49671. arity = newData[9] = newData[9] === undefined
  49672. ? (isBindKey ? 0 : func.length)
  49673. : nativeMax(newData[9] - length, 0);
  49674. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  49675. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  49676. }
  49677. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  49678. var result = createBind(func, bitmask, thisArg);
  49679. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  49680. result = createCurry(func, bitmask, arity);
  49681. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  49682. result = createPartial(func, bitmask, thisArg, partials);
  49683. } else {
  49684. result = createHybrid.apply(undefined, newData);
  49685. }
  49686. var setter = data ? baseSetData : setData;
  49687. return setWrapToString(setter(result, newData), func, bitmask);
  49688. }
  49689. /**
  49690. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  49691. * of source objects to the destination object for all destination properties
  49692. * that resolve to `undefined`.
  49693. *
  49694. * @private
  49695. * @param {*} objValue The destination value.
  49696. * @param {*} srcValue The source value.
  49697. * @param {string} key The key of the property to assign.
  49698. * @param {Object} object The parent object of `objValue`.
  49699. * @returns {*} Returns the value to assign.
  49700. */
  49701. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  49702. if (objValue === undefined ||
  49703. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  49704. return srcValue;
  49705. }
  49706. return objValue;
  49707. }
  49708. /**
  49709. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  49710. * objects into destination objects that are passed thru.
  49711. *
  49712. * @private
  49713. * @param {*} objValue The destination value.
  49714. * @param {*} srcValue The source value.
  49715. * @param {string} key The key of the property to merge.
  49716. * @param {Object} object The parent object of `objValue`.
  49717. * @param {Object} source The parent object of `srcValue`.
  49718. * @param {Object} [stack] Tracks traversed source values and their merged
  49719. * counterparts.
  49720. * @returns {*} Returns the value to assign.
  49721. */
  49722. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  49723. if (isObject(objValue) && isObject(srcValue)) {
  49724. // Recursively merge objects and arrays (susceptible to call stack limits).
  49725. stack.set(srcValue, objValue);
  49726. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  49727. stack['delete'](srcValue);
  49728. }
  49729. return objValue;
  49730. }
  49731. /**
  49732. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  49733. * objects.
  49734. *
  49735. * @private
  49736. * @param {*} value The value to inspect.
  49737. * @param {string} key The key of the property to inspect.
  49738. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  49739. */
  49740. function customOmitClone(value) {
  49741. return isPlainObject(value) ? undefined : value;
  49742. }
  49743. /**
  49744. * A specialized version of `baseIsEqualDeep` for arrays with support for
  49745. * partial deep comparisons.
  49746. *
  49747. * @private
  49748. * @param {Array} array The array to compare.
  49749. * @param {Array} other The other array to compare.
  49750. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  49751. * @param {Function} customizer The function to customize comparisons.
  49752. * @param {Function} equalFunc The function to determine equivalents of values.
  49753. * @param {Object} stack Tracks traversed `array` and `other` objects.
  49754. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  49755. */
  49756. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  49757. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  49758. arrLength = array.length,
  49759. othLength = other.length;
  49760. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  49761. return false;
  49762. }
  49763. // Check that cyclic values are equal.
  49764. var arrStacked = stack.get(array);
  49765. var othStacked = stack.get(other);
  49766. if (arrStacked && othStacked) {
  49767. return arrStacked == other && othStacked == array;
  49768. }
  49769. var index = -1,
  49770. result = true,
  49771. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  49772. stack.set(array, other);
  49773. stack.set(other, array);
  49774. // Ignore non-index properties.
  49775. while (++index < arrLength) {
  49776. var arrValue = array[index],
  49777. othValue = other[index];
  49778. if (customizer) {
  49779. var compared = isPartial
  49780. ? customizer(othValue, arrValue, index, other, array, stack)
  49781. : customizer(arrValue, othValue, index, array, other, stack);
  49782. }
  49783. if (compared !== undefined) {
  49784. if (compared) {
  49785. continue;
  49786. }
  49787. result = false;
  49788. break;
  49789. }
  49790. // Recursively compare arrays (susceptible to call stack limits).
  49791. if (seen) {
  49792. if (!arraySome(other, function(othValue, othIndex) {
  49793. if (!cacheHas(seen, othIndex) &&
  49794. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  49795. return seen.push(othIndex);
  49796. }
  49797. })) {
  49798. result = false;
  49799. break;
  49800. }
  49801. } else if (!(
  49802. arrValue === othValue ||
  49803. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  49804. )) {
  49805. result = false;
  49806. break;
  49807. }
  49808. }
  49809. stack['delete'](array);
  49810. stack['delete'](other);
  49811. return result;
  49812. }
  49813. /**
  49814. * A specialized version of `baseIsEqualDeep` for comparing objects of
  49815. * the same `toStringTag`.
  49816. *
  49817. * **Note:** This function only supports comparing values with tags of
  49818. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  49819. *
  49820. * @private
  49821. * @param {Object} object The object to compare.
  49822. * @param {Object} other The other object to compare.
  49823. * @param {string} tag The `toStringTag` of the objects to compare.
  49824. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  49825. * @param {Function} customizer The function to customize comparisons.
  49826. * @param {Function} equalFunc The function to determine equivalents of values.
  49827. * @param {Object} stack Tracks traversed `object` and `other` objects.
  49828. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  49829. */
  49830. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  49831. switch (tag) {
  49832. case dataViewTag:
  49833. if ((object.byteLength != other.byteLength) ||
  49834. (object.byteOffset != other.byteOffset)) {
  49835. return false;
  49836. }
  49837. object = object.buffer;
  49838. other = other.buffer;
  49839. case arrayBufferTag:
  49840. if ((object.byteLength != other.byteLength) ||
  49841. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  49842. return false;
  49843. }
  49844. return true;
  49845. case boolTag:
  49846. case dateTag:
  49847. case numberTag:
  49848. // Coerce booleans to `1` or `0` and dates to milliseconds.
  49849. // Invalid dates are coerced to `NaN`.
  49850. return eq(+object, +other);
  49851. case errorTag:
  49852. return object.name == other.name && object.message == other.message;
  49853. case regexpTag:
  49854. case stringTag:
  49855. // Coerce regexes to strings and treat strings, primitives and objects,
  49856. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  49857. // for more details.
  49858. return object == (other + '');
  49859. case mapTag:
  49860. var convert = mapToArray;
  49861. case setTag:
  49862. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  49863. convert || (convert = setToArray);
  49864. if (object.size != other.size && !isPartial) {
  49865. return false;
  49866. }
  49867. // Assume cyclic values are equal.
  49868. var stacked = stack.get(object);
  49869. if (stacked) {
  49870. return stacked == other;
  49871. }
  49872. bitmask |= COMPARE_UNORDERED_FLAG;
  49873. // Recursively compare objects (susceptible to call stack limits).
  49874. stack.set(object, other);
  49875. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  49876. stack['delete'](object);
  49877. return result;
  49878. case symbolTag:
  49879. if (symbolValueOf) {
  49880. return symbolValueOf.call(object) == symbolValueOf.call(other);
  49881. }
  49882. }
  49883. return false;
  49884. }
  49885. /**
  49886. * A specialized version of `baseIsEqualDeep` for objects with support for
  49887. * partial deep comparisons.
  49888. *
  49889. * @private
  49890. * @param {Object} object The object to compare.
  49891. * @param {Object} other The other object to compare.
  49892. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  49893. * @param {Function} customizer The function to customize comparisons.
  49894. * @param {Function} equalFunc The function to determine equivalents of values.
  49895. * @param {Object} stack Tracks traversed `object` and `other` objects.
  49896. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  49897. */
  49898. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  49899. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  49900. objProps = getAllKeys(object),
  49901. objLength = objProps.length,
  49902. othProps = getAllKeys(other),
  49903. othLength = othProps.length;
  49904. if (objLength != othLength && !isPartial) {
  49905. return false;
  49906. }
  49907. var index = objLength;
  49908. while (index--) {
  49909. var key = objProps[index];
  49910. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  49911. return false;
  49912. }
  49913. }
  49914. // Check that cyclic values are equal.
  49915. var objStacked = stack.get(object);
  49916. var othStacked = stack.get(other);
  49917. if (objStacked && othStacked) {
  49918. return objStacked == other && othStacked == object;
  49919. }
  49920. var result = true;
  49921. stack.set(object, other);
  49922. stack.set(other, object);
  49923. var skipCtor = isPartial;
  49924. while (++index < objLength) {
  49925. key = objProps[index];
  49926. var objValue = object[key],
  49927. othValue = other[key];
  49928. if (customizer) {
  49929. var compared = isPartial
  49930. ? customizer(othValue, objValue, key, other, object, stack)
  49931. : customizer(objValue, othValue, key, object, other, stack);
  49932. }
  49933. // Recursively compare objects (susceptible to call stack limits).
  49934. if (!(compared === undefined
  49935. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  49936. : compared
  49937. )) {
  49938. result = false;
  49939. break;
  49940. }
  49941. skipCtor || (skipCtor = key == 'constructor');
  49942. }
  49943. if (result && !skipCtor) {
  49944. var objCtor = object.constructor,
  49945. othCtor = other.constructor;
  49946. // Non `Object` object instances with different constructors are not equal.
  49947. if (objCtor != othCtor &&
  49948. ('constructor' in object && 'constructor' in other) &&
  49949. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  49950. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  49951. result = false;
  49952. }
  49953. }
  49954. stack['delete'](object);
  49955. stack['delete'](other);
  49956. return result;
  49957. }
  49958. /**
  49959. * A specialized version of `baseRest` which flattens the rest array.
  49960. *
  49961. * @private
  49962. * @param {Function} func The function to apply a rest parameter to.
  49963. * @returns {Function} Returns the new function.
  49964. */
  49965. function flatRest(func) {
  49966. return setToString(overRest(func, undefined, flatten), func + '');
  49967. }
  49968. /**
  49969. * Creates an array of own enumerable property names and symbols of `object`.
  49970. *
  49971. * @private
  49972. * @param {Object} object The object to query.
  49973. * @returns {Array} Returns the array of property names and symbols.
  49974. */
  49975. function getAllKeys(object) {
  49976. return baseGetAllKeys(object, keys, getSymbols);
  49977. }
  49978. /**
  49979. * Creates an array of own and inherited enumerable property names and
  49980. * symbols of `object`.
  49981. *
  49982. * @private
  49983. * @param {Object} object The object to query.
  49984. * @returns {Array} Returns the array of property names and symbols.
  49985. */
  49986. function getAllKeysIn(object) {
  49987. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  49988. }
  49989. /**
  49990. * Gets metadata for `func`.
  49991. *
  49992. * @private
  49993. * @param {Function} func The function to query.
  49994. * @returns {*} Returns the metadata for `func`.
  49995. */
  49996. var getData = !metaMap ? noop : function(func) {
  49997. return metaMap.get(func);
  49998. };
  49999. /**
  50000. * Gets the name of `func`.
  50001. *
  50002. * @private
  50003. * @param {Function} func The function to query.
  50004. * @returns {string} Returns the function name.
  50005. */
  50006. function getFuncName(func) {
  50007. var result = (func.name + ''),
  50008. array = realNames[result],
  50009. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  50010. while (length--) {
  50011. var data = array[length],
  50012. otherFunc = data.func;
  50013. if (otherFunc == null || otherFunc == func) {
  50014. return data.name;
  50015. }
  50016. }
  50017. return result;
  50018. }
  50019. /**
  50020. * Gets the argument placeholder value for `func`.
  50021. *
  50022. * @private
  50023. * @param {Function} func The function to inspect.
  50024. * @returns {*} Returns the placeholder value.
  50025. */
  50026. function getHolder(func) {
  50027. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  50028. return object.placeholder;
  50029. }
  50030. /**
  50031. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  50032. * this function returns the custom method, otherwise it returns `baseIteratee`.
  50033. * If arguments are provided, the chosen function is invoked with them and
  50034. * its result is returned.
  50035. *
  50036. * @private
  50037. * @param {*} [value] The value to convert to an iteratee.
  50038. * @param {number} [arity] The arity of the created iteratee.
  50039. * @returns {Function} Returns the chosen function or its result.
  50040. */
  50041. function getIteratee() {
  50042. var result = lodash.iteratee || iteratee;
  50043. result = result === iteratee ? baseIteratee : result;
  50044. return arguments.length ? result(arguments[0], arguments[1]) : result;
  50045. }
  50046. /**
  50047. * Gets the data for `map`.
  50048. *
  50049. * @private
  50050. * @param {Object} map The map to query.
  50051. * @param {string} key The reference key.
  50052. * @returns {*} Returns the map data.
  50053. */
  50054. function getMapData(map, key) {
  50055. var data = map.__data__;
  50056. return isKeyable(key)
  50057. ? data[typeof key == 'string' ? 'string' : 'hash']
  50058. : data.map;
  50059. }
  50060. /**
  50061. * Gets the property names, values, and compare flags of `object`.
  50062. *
  50063. * @private
  50064. * @param {Object} object The object to query.
  50065. * @returns {Array} Returns the match data of `object`.
  50066. */
  50067. function getMatchData(object) {
  50068. var result = keys(object),
  50069. length = result.length;
  50070. while (length--) {
  50071. var key = result[length],
  50072. value = object[key];
  50073. result[length] = [key, value, isStrictComparable(value)];
  50074. }
  50075. return result;
  50076. }
  50077. /**
  50078. * Gets the native function at `key` of `object`.
  50079. *
  50080. * @private
  50081. * @param {Object} object The object to query.
  50082. * @param {string} key The key of the method to get.
  50083. * @returns {*} Returns the function if it's native, else `undefined`.
  50084. */
  50085. function getNative(object, key) {
  50086. var value = getValue(object, key);
  50087. return baseIsNative(value) ? value : undefined;
  50088. }
  50089. /**
  50090. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  50091. *
  50092. * @private
  50093. * @param {*} value The value to query.
  50094. * @returns {string} Returns the raw `toStringTag`.
  50095. */
  50096. function getRawTag(value) {
  50097. var isOwn = hasOwnProperty.call(value, symToStringTag),
  50098. tag = value[symToStringTag];
  50099. try {
  50100. value[symToStringTag] = undefined;
  50101. var unmasked = true;
  50102. } catch (e) {}
  50103. var result = nativeObjectToString.call(value);
  50104. if (unmasked) {
  50105. if (isOwn) {
  50106. value[symToStringTag] = tag;
  50107. } else {
  50108. delete value[symToStringTag];
  50109. }
  50110. }
  50111. return result;
  50112. }
  50113. /**
  50114. * Creates an array of the own enumerable symbols of `object`.
  50115. *
  50116. * @private
  50117. * @param {Object} object The object to query.
  50118. * @returns {Array} Returns the array of symbols.
  50119. */
  50120. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  50121. if (object == null) {
  50122. return [];
  50123. }
  50124. object = Object(object);
  50125. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  50126. return propertyIsEnumerable.call(object, symbol);
  50127. });
  50128. };
  50129. /**
  50130. * Creates an array of the own and inherited enumerable symbols of `object`.
  50131. *
  50132. * @private
  50133. * @param {Object} object The object to query.
  50134. * @returns {Array} Returns the array of symbols.
  50135. */
  50136. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  50137. var result = [];
  50138. while (object) {
  50139. arrayPush(result, getSymbols(object));
  50140. object = getPrototype(object);
  50141. }
  50142. return result;
  50143. };
  50144. /**
  50145. * Gets the `toStringTag` of `value`.
  50146. *
  50147. * @private
  50148. * @param {*} value The value to query.
  50149. * @returns {string} Returns the `toStringTag`.
  50150. */
  50151. var getTag = baseGetTag;
  50152. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  50153. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  50154. (Map && getTag(new Map) != mapTag) ||
  50155. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  50156. (Set && getTag(new Set) != setTag) ||
  50157. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  50158. getTag = function(value) {
  50159. var result = baseGetTag(value),
  50160. Ctor = result == objectTag ? value.constructor : undefined,
  50161. ctorString = Ctor ? toSource(Ctor) : '';
  50162. if (ctorString) {
  50163. switch (ctorString) {
  50164. case dataViewCtorString: return dataViewTag;
  50165. case mapCtorString: return mapTag;
  50166. case promiseCtorString: return promiseTag;
  50167. case setCtorString: return setTag;
  50168. case weakMapCtorString: return weakMapTag;
  50169. }
  50170. }
  50171. return result;
  50172. };
  50173. }
  50174. /**
  50175. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  50176. *
  50177. * @private
  50178. * @param {number} start The start of the view.
  50179. * @param {number} end The end of the view.
  50180. * @param {Array} transforms The transformations to apply to the view.
  50181. * @returns {Object} Returns an object containing the `start` and `end`
  50182. * positions of the view.
  50183. */
  50184. function getView(start, end, transforms) {
  50185. var index = -1,
  50186. length = transforms.length;
  50187. while (++index < length) {
  50188. var data = transforms[index],
  50189. size = data.size;
  50190. switch (data.type) {
  50191. case 'drop': start += size; break;
  50192. case 'dropRight': end -= size; break;
  50193. case 'take': end = nativeMin(end, start + size); break;
  50194. case 'takeRight': start = nativeMax(start, end - size); break;
  50195. }
  50196. }
  50197. return { 'start': start, 'end': end };
  50198. }
  50199. /**
  50200. * Extracts wrapper details from the `source` body comment.
  50201. *
  50202. * @private
  50203. * @param {string} source The source to inspect.
  50204. * @returns {Array} Returns the wrapper details.
  50205. */
  50206. function getWrapDetails(source) {
  50207. var match = source.match(reWrapDetails);
  50208. return match ? match[1].split(reSplitDetails) : [];
  50209. }
  50210. /**
  50211. * Checks if `path` exists on `object`.
  50212. *
  50213. * @private
  50214. * @param {Object} object The object to query.
  50215. * @param {Array|string} path The path to check.
  50216. * @param {Function} hasFunc The function to check properties.
  50217. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  50218. */
  50219. function hasPath(object, path, hasFunc) {
  50220. path = castPath(path, object);
  50221. var index = -1,
  50222. length = path.length,
  50223. result = false;
  50224. while (++index < length) {
  50225. var key = toKey(path[index]);
  50226. if (!(result = object != null && hasFunc(object, key))) {
  50227. break;
  50228. }
  50229. object = object[key];
  50230. }
  50231. if (result || ++index != length) {
  50232. return result;
  50233. }
  50234. length = object == null ? 0 : object.length;
  50235. return !!length && isLength(length) && isIndex(key, length) &&
  50236. (isArray(object) || isArguments(object));
  50237. }
  50238. /**
  50239. * Initializes an array clone.
  50240. *
  50241. * @private
  50242. * @param {Array} array The array to clone.
  50243. * @returns {Array} Returns the initialized clone.
  50244. */
  50245. function initCloneArray(array) {
  50246. var length = array.length,
  50247. result = new array.constructor(length);
  50248. // Add properties assigned by `RegExp#exec`.
  50249. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  50250. result.index = array.index;
  50251. result.input = array.input;
  50252. }
  50253. return result;
  50254. }
  50255. /**
  50256. * Initializes an object clone.
  50257. *
  50258. * @private
  50259. * @param {Object} object The object to clone.
  50260. * @returns {Object} Returns the initialized clone.
  50261. */
  50262. function initCloneObject(object) {
  50263. return (typeof object.constructor == 'function' && !isPrototype(object))
  50264. ? baseCreate(getPrototype(object))
  50265. : {};
  50266. }
  50267. /**
  50268. * Initializes an object clone based on its `toStringTag`.
  50269. *
  50270. * **Note:** This function only supports cloning values with tags of
  50271. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  50272. *
  50273. * @private
  50274. * @param {Object} object The object to clone.
  50275. * @param {string} tag The `toStringTag` of the object to clone.
  50276. * @param {boolean} [isDeep] Specify a deep clone.
  50277. * @returns {Object} Returns the initialized clone.
  50278. */
  50279. function initCloneByTag(object, tag, isDeep) {
  50280. var Ctor = object.constructor;
  50281. switch (tag) {
  50282. case arrayBufferTag:
  50283. return cloneArrayBuffer(object);
  50284. case boolTag:
  50285. case dateTag:
  50286. return new Ctor(+object);
  50287. case dataViewTag:
  50288. return cloneDataView(object, isDeep);
  50289. case float32Tag: case float64Tag:
  50290. case int8Tag: case int16Tag: case int32Tag:
  50291. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  50292. return cloneTypedArray(object, isDeep);
  50293. case mapTag:
  50294. return new Ctor;
  50295. case numberTag:
  50296. case stringTag:
  50297. return new Ctor(object);
  50298. case regexpTag:
  50299. return cloneRegExp(object);
  50300. case setTag:
  50301. return new Ctor;
  50302. case symbolTag:
  50303. return cloneSymbol(object);
  50304. }
  50305. }
  50306. /**
  50307. * Inserts wrapper `details` in a comment at the top of the `source` body.
  50308. *
  50309. * @private
  50310. * @param {string} source The source to modify.
  50311. * @returns {Array} details The details to insert.
  50312. * @returns {string} Returns the modified source.
  50313. */
  50314. function insertWrapDetails(source, details) {
  50315. var length = details.length;
  50316. if (!length) {
  50317. return source;
  50318. }
  50319. var lastIndex = length - 1;
  50320. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  50321. details = details.join(length > 2 ? ', ' : ' ');
  50322. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  50323. }
  50324. /**
  50325. * Checks if `value` is a flattenable `arguments` object or array.
  50326. *
  50327. * @private
  50328. * @param {*} value The value to check.
  50329. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  50330. */
  50331. function isFlattenable(value) {
  50332. return isArray(value) || isArguments(value) ||
  50333. !!(spreadableSymbol && value && value[spreadableSymbol]);
  50334. }
  50335. /**
  50336. * Checks if `value` is a valid array-like index.
  50337. *
  50338. * @private
  50339. * @param {*} value The value to check.
  50340. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  50341. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  50342. */
  50343. function isIndex(value, length) {
  50344. var type = typeof value;
  50345. length = length == null ? MAX_SAFE_INTEGER : length;
  50346. return !!length &&
  50347. (type == 'number' ||
  50348. (type != 'symbol' && reIsUint.test(value))) &&
  50349. (value > -1 && value % 1 == 0 && value < length);
  50350. }
  50351. /**
  50352. * Checks if the given arguments are from an iteratee call.
  50353. *
  50354. * @private
  50355. * @param {*} value The potential iteratee value argument.
  50356. * @param {*} index The potential iteratee index or key argument.
  50357. * @param {*} object The potential iteratee object argument.
  50358. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  50359. * else `false`.
  50360. */
  50361. function isIterateeCall(value, index, object) {
  50362. if (!isObject(object)) {
  50363. return false;
  50364. }
  50365. var type = typeof index;
  50366. if (type == 'number'
  50367. ? (isArrayLike(object) && isIndex(index, object.length))
  50368. : (type == 'string' && index in object)
  50369. ) {
  50370. return eq(object[index], value);
  50371. }
  50372. return false;
  50373. }
  50374. /**
  50375. * Checks if `value` is a property name and not a property path.
  50376. *
  50377. * @private
  50378. * @param {*} value The value to check.
  50379. * @param {Object} [object] The object to query keys on.
  50380. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  50381. */
  50382. function isKey(value, object) {
  50383. if (isArray(value)) {
  50384. return false;
  50385. }
  50386. var type = typeof value;
  50387. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  50388. value == null || isSymbol(value)) {
  50389. return true;
  50390. }
  50391. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  50392. (object != null && value in Object(object));
  50393. }
  50394. /**
  50395. * Checks if `value` is suitable for use as unique object key.
  50396. *
  50397. * @private
  50398. * @param {*} value The value to check.
  50399. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  50400. */
  50401. function isKeyable(value) {
  50402. var type = typeof value;
  50403. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  50404. ? (value !== '__proto__')
  50405. : (value === null);
  50406. }
  50407. /**
  50408. * Checks if `func` has a lazy counterpart.
  50409. *
  50410. * @private
  50411. * @param {Function} func The function to check.
  50412. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  50413. * else `false`.
  50414. */
  50415. function isLaziable(func) {
  50416. var funcName = getFuncName(func),
  50417. other = lodash[funcName];
  50418. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  50419. return false;
  50420. }
  50421. if (func === other) {
  50422. return true;
  50423. }
  50424. var data = getData(other);
  50425. return !!data && func === data[0];
  50426. }
  50427. /**
  50428. * Checks if `func` has its source masked.
  50429. *
  50430. * @private
  50431. * @param {Function} func The function to check.
  50432. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  50433. */
  50434. function isMasked(func) {
  50435. return !!maskSrcKey && (maskSrcKey in func);
  50436. }
  50437. /**
  50438. * Checks if `func` is capable of being masked.
  50439. *
  50440. * @private
  50441. * @param {*} value The value to check.
  50442. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  50443. */
  50444. var isMaskable = coreJsData ? isFunction : stubFalse;
  50445. /**
  50446. * Checks if `value` is likely a prototype object.
  50447. *
  50448. * @private
  50449. * @param {*} value The value to check.
  50450. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  50451. */
  50452. function isPrototype(value) {
  50453. var Ctor = value && value.constructor,
  50454. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  50455. return value === proto;
  50456. }
  50457. /**
  50458. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  50459. *
  50460. * @private
  50461. * @param {*} value The value to check.
  50462. * @returns {boolean} Returns `true` if `value` if suitable for strict
  50463. * equality comparisons, else `false`.
  50464. */
  50465. function isStrictComparable(value) {
  50466. return value === value && !isObject(value);
  50467. }
  50468. /**
  50469. * A specialized version of `matchesProperty` for source values suitable
  50470. * for strict equality comparisons, i.e. `===`.
  50471. *
  50472. * @private
  50473. * @param {string} key The key of the property to get.
  50474. * @param {*} srcValue The value to match.
  50475. * @returns {Function} Returns the new spec function.
  50476. */
  50477. function matchesStrictComparable(key, srcValue) {
  50478. return function(object) {
  50479. if (object == null) {
  50480. return false;
  50481. }
  50482. return object[key] === srcValue &&
  50483. (srcValue !== undefined || (key in Object(object)));
  50484. };
  50485. }
  50486. /**
  50487. * A specialized version of `_.memoize` which clears the memoized function's
  50488. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  50489. *
  50490. * @private
  50491. * @param {Function} func The function to have its output memoized.
  50492. * @returns {Function} Returns the new memoized function.
  50493. */
  50494. function memoizeCapped(func) {
  50495. var result = memoize(func, function(key) {
  50496. if (cache.size === MAX_MEMOIZE_SIZE) {
  50497. cache.clear();
  50498. }
  50499. return key;
  50500. });
  50501. var cache = result.cache;
  50502. return result;
  50503. }
  50504. /**
  50505. * Merges the function metadata of `source` into `data`.
  50506. *
  50507. * Merging metadata reduces the number of wrappers used to invoke a function.
  50508. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  50509. * may be applied regardless of execution order. Methods like `_.ary` and
  50510. * `_.rearg` modify function arguments, making the order in which they are
  50511. * executed important, preventing the merging of metadata. However, we make
  50512. * an exception for a safe combined case where curried functions have `_.ary`
  50513. * and or `_.rearg` applied.
  50514. *
  50515. * @private
  50516. * @param {Array} data The destination metadata.
  50517. * @param {Array} source The source metadata.
  50518. * @returns {Array} Returns `data`.
  50519. */
  50520. function mergeData(data, source) {
  50521. var bitmask = data[1],
  50522. srcBitmask = source[1],
  50523. newBitmask = bitmask | srcBitmask,
  50524. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  50525. var isCombo =
  50526. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  50527. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  50528. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  50529. // Exit early if metadata can't be merged.
  50530. if (!(isCommon || isCombo)) {
  50531. return data;
  50532. }
  50533. // Use source `thisArg` if available.
  50534. if (srcBitmask & WRAP_BIND_FLAG) {
  50535. data[2] = source[2];
  50536. // Set when currying a bound function.
  50537. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  50538. }
  50539. // Compose partial arguments.
  50540. var value = source[3];
  50541. if (value) {
  50542. var partials = data[3];
  50543. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  50544. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  50545. }
  50546. // Compose partial right arguments.
  50547. value = source[5];
  50548. if (value) {
  50549. partials = data[5];
  50550. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  50551. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  50552. }
  50553. // Use source `argPos` if available.
  50554. value = source[7];
  50555. if (value) {
  50556. data[7] = value;
  50557. }
  50558. // Use source `ary` if it's smaller.
  50559. if (srcBitmask & WRAP_ARY_FLAG) {
  50560. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  50561. }
  50562. // Use source `arity` if one is not provided.
  50563. if (data[9] == null) {
  50564. data[9] = source[9];
  50565. }
  50566. // Use source `func` and merge bitmasks.
  50567. data[0] = source[0];
  50568. data[1] = newBitmask;
  50569. return data;
  50570. }
  50571. /**
  50572. * This function is like
  50573. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  50574. * except that it includes inherited enumerable properties.
  50575. *
  50576. * @private
  50577. * @param {Object} object The object to query.
  50578. * @returns {Array} Returns the array of property names.
  50579. */
  50580. function nativeKeysIn(object) {
  50581. var result = [];
  50582. if (object != null) {
  50583. for (var key in Object(object)) {
  50584. result.push(key);
  50585. }
  50586. }
  50587. return result;
  50588. }
  50589. /**
  50590. * Converts `value` to a string using `Object.prototype.toString`.
  50591. *
  50592. * @private
  50593. * @param {*} value The value to convert.
  50594. * @returns {string} Returns the converted string.
  50595. */
  50596. function objectToString(value) {
  50597. return nativeObjectToString.call(value);
  50598. }
  50599. /**
  50600. * A specialized version of `baseRest` which transforms the rest array.
  50601. *
  50602. * @private
  50603. * @param {Function} func The function to apply a rest parameter to.
  50604. * @param {number} [start=func.length-1] The start position of the rest parameter.
  50605. * @param {Function} transform The rest array transform.
  50606. * @returns {Function} Returns the new function.
  50607. */
  50608. function overRest(func, start, transform) {
  50609. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  50610. return function() {
  50611. var args = arguments,
  50612. index = -1,
  50613. length = nativeMax(args.length - start, 0),
  50614. array = Array(length);
  50615. while (++index < length) {
  50616. array[index] = args[start + index];
  50617. }
  50618. index = -1;
  50619. var otherArgs = Array(start + 1);
  50620. while (++index < start) {
  50621. otherArgs[index] = args[index];
  50622. }
  50623. otherArgs[start] = transform(array);
  50624. return apply(func, this, otherArgs);
  50625. };
  50626. }
  50627. /**
  50628. * Gets the parent value at `path` of `object`.
  50629. *
  50630. * @private
  50631. * @param {Object} object The object to query.
  50632. * @param {Array} path The path to get the parent value of.
  50633. * @returns {*} Returns the parent value.
  50634. */
  50635. function parent(object, path) {
  50636. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  50637. }
  50638. /**
  50639. * Reorder `array` according to the specified indexes where the element at
  50640. * the first index is assigned as the first element, the element at
  50641. * the second index is assigned as the second element, and so on.
  50642. *
  50643. * @private
  50644. * @param {Array} array The array to reorder.
  50645. * @param {Array} indexes The arranged array indexes.
  50646. * @returns {Array} Returns `array`.
  50647. */
  50648. function reorder(array, indexes) {
  50649. var arrLength = array.length,
  50650. length = nativeMin(indexes.length, arrLength),
  50651. oldArray = copyArray(array);
  50652. while (length--) {
  50653. var index = indexes[length];
  50654. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  50655. }
  50656. return array;
  50657. }
  50658. /**
  50659. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  50660. *
  50661. * @private
  50662. * @param {Object} object The object to query.
  50663. * @param {string} key The key of the property to get.
  50664. * @returns {*} Returns the property value.
  50665. */
  50666. function safeGet(object, key) {
  50667. if (key === 'constructor' && typeof object[key] === 'function') {
  50668. return;
  50669. }
  50670. if (key == '__proto__') {
  50671. return;
  50672. }
  50673. return object[key];
  50674. }
  50675. /**
  50676. * Sets metadata for `func`.
  50677. *
  50678. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  50679. * period of time, it will trip its breaker and transition to an identity
  50680. * function to avoid garbage collection pauses in V8. See
  50681. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  50682. * for more details.
  50683. *
  50684. * @private
  50685. * @param {Function} func The function to associate metadata with.
  50686. * @param {*} data The metadata.
  50687. * @returns {Function} Returns `func`.
  50688. */
  50689. var setData = shortOut(baseSetData);
  50690. /**
  50691. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  50692. *
  50693. * @private
  50694. * @param {Function} func The function to delay.
  50695. * @param {number} wait The number of milliseconds to delay invocation.
  50696. * @returns {number|Object} Returns the timer id or timeout object.
  50697. */
  50698. var setTimeout = ctxSetTimeout || function(func, wait) {
  50699. return root.setTimeout(func, wait);
  50700. };
  50701. /**
  50702. * Sets the `toString` method of `func` to return `string`.
  50703. *
  50704. * @private
  50705. * @param {Function} func The function to modify.
  50706. * @param {Function} string The `toString` result.
  50707. * @returns {Function} Returns `func`.
  50708. */
  50709. var setToString = shortOut(baseSetToString);
  50710. /**
  50711. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  50712. * with wrapper details in a comment at the top of the source body.
  50713. *
  50714. * @private
  50715. * @param {Function} wrapper The function to modify.
  50716. * @param {Function} reference The reference function.
  50717. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  50718. * @returns {Function} Returns `wrapper`.
  50719. */
  50720. function setWrapToString(wrapper, reference, bitmask) {
  50721. var source = (reference + '');
  50722. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  50723. }
  50724. /**
  50725. * Creates a function that'll short out and invoke `identity` instead
  50726. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  50727. * milliseconds.
  50728. *
  50729. * @private
  50730. * @param {Function} func The function to restrict.
  50731. * @returns {Function} Returns the new shortable function.
  50732. */
  50733. function shortOut(func) {
  50734. var count = 0,
  50735. lastCalled = 0;
  50736. return function() {
  50737. var stamp = nativeNow(),
  50738. remaining = HOT_SPAN - (stamp - lastCalled);
  50739. lastCalled = stamp;
  50740. if (remaining > 0) {
  50741. if (++count >= HOT_COUNT) {
  50742. return arguments[0];
  50743. }
  50744. } else {
  50745. count = 0;
  50746. }
  50747. return func.apply(undefined, arguments);
  50748. };
  50749. }
  50750. /**
  50751. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  50752. *
  50753. * @private
  50754. * @param {Array} array The array to shuffle.
  50755. * @param {number} [size=array.length] The size of `array`.
  50756. * @returns {Array} Returns `array`.
  50757. */
  50758. function shuffleSelf(array, size) {
  50759. var index = -1,
  50760. length = array.length,
  50761. lastIndex = length - 1;
  50762. size = size === undefined ? length : size;
  50763. while (++index < size) {
  50764. var rand = baseRandom(index, lastIndex),
  50765. value = array[rand];
  50766. array[rand] = array[index];
  50767. array[index] = value;
  50768. }
  50769. array.length = size;
  50770. return array;
  50771. }
  50772. /**
  50773. * Converts `string` to a property path array.
  50774. *
  50775. * @private
  50776. * @param {string} string The string to convert.
  50777. * @returns {Array} Returns the property path array.
  50778. */
  50779. var stringToPath = memoizeCapped(function(string) {
  50780. var result = [];
  50781. if (string.charCodeAt(0) === 46 /* . */) {
  50782. result.push('');
  50783. }
  50784. string.replace(rePropName, function(match, number, quote, subString) {
  50785. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  50786. });
  50787. return result;
  50788. });
  50789. /**
  50790. * Converts `value` to a string key if it's not a string or symbol.
  50791. *
  50792. * @private
  50793. * @param {*} value The value to inspect.
  50794. * @returns {string|symbol} Returns the key.
  50795. */
  50796. function toKey(value) {
  50797. if (typeof value == 'string' || isSymbol(value)) {
  50798. return value;
  50799. }
  50800. var result = (value + '');
  50801. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  50802. }
  50803. /**
  50804. * Converts `func` to its source code.
  50805. *
  50806. * @private
  50807. * @param {Function} func The function to convert.
  50808. * @returns {string} Returns the source code.
  50809. */
  50810. function toSource(func) {
  50811. if (func != null) {
  50812. try {
  50813. return funcToString.call(func);
  50814. } catch (e) {}
  50815. try {
  50816. return (func + '');
  50817. } catch (e) {}
  50818. }
  50819. return '';
  50820. }
  50821. /**
  50822. * Updates wrapper `details` based on `bitmask` flags.
  50823. *
  50824. * @private
  50825. * @returns {Array} details The details to modify.
  50826. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  50827. * @returns {Array} Returns `details`.
  50828. */
  50829. function updateWrapDetails(details, bitmask) {
  50830. arrayEach(wrapFlags, function(pair) {
  50831. var value = '_.' + pair[0];
  50832. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  50833. details.push(value);
  50834. }
  50835. });
  50836. return details.sort();
  50837. }
  50838. /**
  50839. * Creates a clone of `wrapper`.
  50840. *
  50841. * @private
  50842. * @param {Object} wrapper The wrapper to clone.
  50843. * @returns {Object} Returns the cloned wrapper.
  50844. */
  50845. function wrapperClone(wrapper) {
  50846. if (wrapper instanceof LazyWrapper) {
  50847. return wrapper.clone();
  50848. }
  50849. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  50850. result.__actions__ = copyArray(wrapper.__actions__);
  50851. result.__index__ = wrapper.__index__;
  50852. result.__values__ = wrapper.__values__;
  50853. return result;
  50854. }
  50855. /*------------------------------------------------------------------------*/
  50856. /**
  50857. * Creates an array of elements split into groups the length of `size`.
  50858. * If `array` can't be split evenly, the final chunk will be the remaining
  50859. * elements.
  50860. *
  50861. * @static
  50862. * @memberOf _
  50863. * @since 3.0.0
  50864. * @category Array
  50865. * @param {Array} array The array to process.
  50866. * @param {number} [size=1] The length of each chunk
  50867. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  50868. * @returns {Array} Returns the new array of chunks.
  50869. * @example
  50870. *
  50871. * _.chunk(['a', 'b', 'c', 'd'], 2);
  50872. * // => [['a', 'b'], ['c', 'd']]
  50873. *
  50874. * _.chunk(['a', 'b', 'c', 'd'], 3);
  50875. * // => [['a', 'b', 'c'], ['d']]
  50876. */
  50877. function chunk(array, size, guard) {
  50878. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  50879. size = 1;
  50880. } else {
  50881. size = nativeMax(toInteger(size), 0);
  50882. }
  50883. var length = array == null ? 0 : array.length;
  50884. if (!length || size < 1) {
  50885. return [];
  50886. }
  50887. var index = 0,
  50888. resIndex = 0,
  50889. result = Array(nativeCeil(length / size));
  50890. while (index < length) {
  50891. result[resIndex++] = baseSlice(array, index, (index += size));
  50892. }
  50893. return result;
  50894. }
  50895. /**
  50896. * Creates an array with all falsey values removed. The values `false`, `null`,
  50897. * `0`, `""`, `undefined`, and `NaN` are falsey.
  50898. *
  50899. * @static
  50900. * @memberOf _
  50901. * @since 0.1.0
  50902. * @category Array
  50903. * @param {Array} array The array to compact.
  50904. * @returns {Array} Returns the new array of filtered values.
  50905. * @example
  50906. *
  50907. * _.compact([0, 1, false, 2, '', 3]);
  50908. * // => [1, 2, 3]
  50909. */
  50910. function compact(array) {
  50911. var index = -1,
  50912. length = array == null ? 0 : array.length,
  50913. resIndex = 0,
  50914. result = [];
  50915. while (++index < length) {
  50916. var value = array[index];
  50917. if (value) {
  50918. result[resIndex++] = value;
  50919. }
  50920. }
  50921. return result;
  50922. }
  50923. /**
  50924. * Creates a new array concatenating `array` with any additional arrays
  50925. * and/or values.
  50926. *
  50927. * @static
  50928. * @memberOf _
  50929. * @since 4.0.0
  50930. * @category Array
  50931. * @param {Array} array The array to concatenate.
  50932. * @param {...*} [values] The values to concatenate.
  50933. * @returns {Array} Returns the new concatenated array.
  50934. * @example
  50935. *
  50936. * var array = [1];
  50937. * var other = _.concat(array, 2, [3], [[4]]);
  50938. *
  50939. * console.log(other);
  50940. * // => [1, 2, 3, [4]]
  50941. *
  50942. * console.log(array);
  50943. * // => [1]
  50944. */
  50945. function concat() {
  50946. var length = arguments.length;
  50947. if (!length) {
  50948. return [];
  50949. }
  50950. var args = Array(length - 1),
  50951. array = arguments[0],
  50952. index = length;
  50953. while (index--) {
  50954. args[index - 1] = arguments[index];
  50955. }
  50956. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  50957. }
  50958. /**
  50959. * Creates an array of `array` values not included in the other given arrays
  50960. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  50961. * for equality comparisons. The order and references of result values are
  50962. * determined by the first array.
  50963. *
  50964. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  50965. *
  50966. * @static
  50967. * @memberOf _
  50968. * @since 0.1.0
  50969. * @category Array
  50970. * @param {Array} array The array to inspect.
  50971. * @param {...Array} [values] The values to exclude.
  50972. * @returns {Array} Returns the new array of filtered values.
  50973. * @see _.without, _.xor
  50974. * @example
  50975. *
  50976. * _.difference([2, 1], [2, 3]);
  50977. * // => [1]
  50978. */
  50979. var difference = baseRest(function(array, values) {
  50980. return isArrayLikeObject(array)
  50981. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  50982. : [];
  50983. });
  50984. /**
  50985. * This method is like `_.difference` except that it accepts `iteratee` which
  50986. * is invoked for each element of `array` and `values` to generate the criterion
  50987. * by which they're compared. The order and references of result values are
  50988. * determined by the first array. The iteratee is invoked with one argument:
  50989. * (value).
  50990. *
  50991. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  50992. *
  50993. * @static
  50994. * @memberOf _
  50995. * @since 4.0.0
  50996. * @category Array
  50997. * @param {Array} array The array to inspect.
  50998. * @param {...Array} [values] The values to exclude.
  50999. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  51000. * @returns {Array} Returns the new array of filtered values.
  51001. * @example
  51002. *
  51003. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  51004. * // => [1.2]
  51005. *
  51006. * // The `_.property` iteratee shorthand.
  51007. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  51008. * // => [{ 'x': 2 }]
  51009. */
  51010. var differenceBy = baseRest(function(array, values) {
  51011. var iteratee = last(values);
  51012. if (isArrayLikeObject(iteratee)) {
  51013. iteratee = undefined;
  51014. }
  51015. return isArrayLikeObject(array)
  51016. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  51017. : [];
  51018. });
  51019. /**
  51020. * This method is like `_.difference` except that it accepts `comparator`
  51021. * which is invoked to compare elements of `array` to `values`. The order and
  51022. * references of result values are determined by the first array. The comparator
  51023. * is invoked with two arguments: (arrVal, othVal).
  51024. *
  51025. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  51026. *
  51027. * @static
  51028. * @memberOf _
  51029. * @since 4.0.0
  51030. * @category Array
  51031. * @param {Array} array The array to inspect.
  51032. * @param {...Array} [values] The values to exclude.
  51033. * @param {Function} [comparator] The comparator invoked per element.
  51034. * @returns {Array} Returns the new array of filtered values.
  51035. * @example
  51036. *
  51037. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  51038. *
  51039. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  51040. * // => [{ 'x': 2, 'y': 1 }]
  51041. */
  51042. var differenceWith = baseRest(function(array, values) {
  51043. var comparator = last(values);
  51044. if (isArrayLikeObject(comparator)) {
  51045. comparator = undefined;
  51046. }
  51047. return isArrayLikeObject(array)
  51048. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  51049. : [];
  51050. });
  51051. /**
  51052. * Creates a slice of `array` with `n` elements dropped from the beginning.
  51053. *
  51054. * @static
  51055. * @memberOf _
  51056. * @since 0.5.0
  51057. * @category Array
  51058. * @param {Array} array The array to query.
  51059. * @param {number} [n=1] The number of elements to drop.
  51060. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  51061. * @returns {Array} Returns the slice of `array`.
  51062. * @example
  51063. *
  51064. * _.drop([1, 2, 3]);
  51065. * // => [2, 3]
  51066. *
  51067. * _.drop([1, 2, 3], 2);
  51068. * // => [3]
  51069. *
  51070. * _.drop([1, 2, 3], 5);
  51071. * // => []
  51072. *
  51073. * _.drop([1, 2, 3], 0);
  51074. * // => [1, 2, 3]
  51075. */
  51076. function drop(array, n, guard) {
  51077. var length = array == null ? 0 : array.length;
  51078. if (!length) {
  51079. return [];
  51080. }
  51081. n = (guard || n === undefined) ? 1 : toInteger(n);
  51082. return baseSlice(array, n < 0 ? 0 : n, length);
  51083. }
  51084. /**
  51085. * Creates a slice of `array` with `n` elements dropped from the end.
  51086. *
  51087. * @static
  51088. * @memberOf _
  51089. * @since 3.0.0
  51090. * @category Array
  51091. * @param {Array} array The array to query.
  51092. * @param {number} [n=1] The number of elements to drop.
  51093. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  51094. * @returns {Array} Returns the slice of `array`.
  51095. * @example
  51096. *
  51097. * _.dropRight([1, 2, 3]);
  51098. * // => [1, 2]
  51099. *
  51100. * _.dropRight([1, 2, 3], 2);
  51101. * // => [1]
  51102. *
  51103. * _.dropRight([1, 2, 3], 5);
  51104. * // => []
  51105. *
  51106. * _.dropRight([1, 2, 3], 0);
  51107. * // => [1, 2, 3]
  51108. */
  51109. function dropRight(array, n, guard) {
  51110. var length = array == null ? 0 : array.length;
  51111. if (!length) {
  51112. return [];
  51113. }
  51114. n = (guard || n === undefined) ? 1 : toInteger(n);
  51115. n = length - n;
  51116. return baseSlice(array, 0, n < 0 ? 0 : n);
  51117. }
  51118. /**
  51119. * Creates a slice of `array` excluding elements dropped from the end.
  51120. * Elements are dropped until `predicate` returns falsey. The predicate is
  51121. * invoked with three arguments: (value, index, array).
  51122. *
  51123. * @static
  51124. * @memberOf _
  51125. * @since 3.0.0
  51126. * @category Array
  51127. * @param {Array} array The array to query.
  51128. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  51129. * @returns {Array} Returns the slice of `array`.
  51130. * @example
  51131. *
  51132. * var users = [
  51133. * { 'user': 'barney', 'active': true },
  51134. * { 'user': 'fred', 'active': false },
  51135. * { 'user': 'pebbles', 'active': false }
  51136. * ];
  51137. *
  51138. * _.dropRightWhile(users, function(o) { return !o.active; });
  51139. * // => objects for ['barney']
  51140. *
  51141. * // The `_.matches` iteratee shorthand.
  51142. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  51143. * // => objects for ['barney', 'fred']
  51144. *
  51145. * // The `_.matchesProperty` iteratee shorthand.
  51146. * _.dropRightWhile(users, ['active', false]);
  51147. * // => objects for ['barney']
  51148. *
  51149. * // The `_.property` iteratee shorthand.
  51150. * _.dropRightWhile(users, 'active');
  51151. * // => objects for ['barney', 'fred', 'pebbles']
  51152. */
  51153. function dropRightWhile(array, predicate) {
  51154. return (array && array.length)
  51155. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  51156. : [];
  51157. }
  51158. /**
  51159. * Creates a slice of `array` excluding elements dropped from the beginning.
  51160. * Elements are dropped until `predicate` returns falsey. The predicate is
  51161. * invoked with three arguments: (value, index, array).
  51162. *
  51163. * @static
  51164. * @memberOf _
  51165. * @since 3.0.0
  51166. * @category Array
  51167. * @param {Array} array The array to query.
  51168. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  51169. * @returns {Array} Returns the slice of `array`.
  51170. * @example
  51171. *
  51172. * var users = [
  51173. * { 'user': 'barney', 'active': false },
  51174. * { 'user': 'fred', 'active': false },
  51175. * { 'user': 'pebbles', 'active': true }
  51176. * ];
  51177. *
  51178. * _.dropWhile(users, function(o) { return !o.active; });
  51179. * // => objects for ['pebbles']
  51180. *
  51181. * // The `_.matches` iteratee shorthand.
  51182. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  51183. * // => objects for ['fred', 'pebbles']
  51184. *
  51185. * // The `_.matchesProperty` iteratee shorthand.
  51186. * _.dropWhile(users, ['active', false]);
  51187. * // => objects for ['pebbles']
  51188. *
  51189. * // The `_.property` iteratee shorthand.
  51190. * _.dropWhile(users, 'active');
  51191. * // => objects for ['barney', 'fred', 'pebbles']
  51192. */
  51193. function dropWhile(array, predicate) {
  51194. return (array && array.length)
  51195. ? baseWhile(array, getIteratee(predicate, 3), true)
  51196. : [];
  51197. }
  51198. /**
  51199. * Fills elements of `array` with `value` from `start` up to, but not
  51200. * including, `end`.
  51201. *
  51202. * **Note:** This method mutates `array`.
  51203. *
  51204. * @static
  51205. * @memberOf _
  51206. * @since 3.2.0
  51207. * @category Array
  51208. * @param {Array} array The array to fill.
  51209. * @param {*} value The value to fill `array` with.
  51210. * @param {number} [start=0] The start position.
  51211. * @param {number} [end=array.length] The end position.
  51212. * @returns {Array} Returns `array`.
  51213. * @example
  51214. *
  51215. * var array = [1, 2, 3];
  51216. *
  51217. * _.fill(array, 'a');
  51218. * console.log(array);
  51219. * // => ['a', 'a', 'a']
  51220. *
  51221. * _.fill(Array(3), 2);
  51222. * // => [2, 2, 2]
  51223. *
  51224. * _.fill([4, 6, 8, 10], '*', 1, 3);
  51225. * // => [4, '*', '*', 10]
  51226. */
  51227. function fill(array, value, start, end) {
  51228. var length = array == null ? 0 : array.length;
  51229. if (!length) {
  51230. return [];
  51231. }
  51232. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  51233. start = 0;
  51234. end = length;
  51235. }
  51236. return baseFill(array, value, start, end);
  51237. }
  51238. /**
  51239. * This method is like `_.find` except that it returns the index of the first
  51240. * element `predicate` returns truthy for instead of the element itself.
  51241. *
  51242. * @static
  51243. * @memberOf _
  51244. * @since 1.1.0
  51245. * @category Array
  51246. * @param {Array} array The array to inspect.
  51247. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  51248. * @param {number} [fromIndex=0] The index to search from.
  51249. * @returns {number} Returns the index of the found element, else `-1`.
  51250. * @example
  51251. *
  51252. * var users = [
  51253. * { 'user': 'barney', 'active': false },
  51254. * { 'user': 'fred', 'active': false },
  51255. * { 'user': 'pebbles', 'active': true }
  51256. * ];
  51257. *
  51258. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  51259. * // => 0
  51260. *
  51261. * // The `_.matches` iteratee shorthand.
  51262. * _.findIndex(users, { 'user': 'fred', 'active': false });
  51263. * // => 1
  51264. *
  51265. * // The `_.matchesProperty` iteratee shorthand.
  51266. * _.findIndex(users, ['active', false]);
  51267. * // => 0
  51268. *
  51269. * // The `_.property` iteratee shorthand.
  51270. * _.findIndex(users, 'active');
  51271. * // => 2
  51272. */
  51273. function findIndex(array, predicate, fromIndex) {
  51274. var length = array == null ? 0 : array.length;
  51275. if (!length) {
  51276. return -1;
  51277. }
  51278. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  51279. if (index < 0) {
  51280. index = nativeMax(length + index, 0);
  51281. }
  51282. return baseFindIndex(array, getIteratee(predicate, 3), index);
  51283. }
  51284. /**
  51285. * This method is like `_.findIndex` except that it iterates over elements
  51286. * of `collection` from right to left.
  51287. *
  51288. * @static
  51289. * @memberOf _
  51290. * @since 2.0.0
  51291. * @category Array
  51292. * @param {Array} array The array to inspect.
  51293. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  51294. * @param {number} [fromIndex=array.length-1] The index to search from.
  51295. * @returns {number} Returns the index of the found element, else `-1`.
  51296. * @example
  51297. *
  51298. * var users = [
  51299. * { 'user': 'barney', 'active': true },
  51300. * { 'user': 'fred', 'active': false },
  51301. * { 'user': 'pebbles', 'active': false }
  51302. * ];
  51303. *
  51304. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  51305. * // => 2
  51306. *
  51307. * // The `_.matches` iteratee shorthand.
  51308. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  51309. * // => 0
  51310. *
  51311. * // The `_.matchesProperty` iteratee shorthand.
  51312. * _.findLastIndex(users, ['active', false]);
  51313. * // => 2
  51314. *
  51315. * // The `_.property` iteratee shorthand.
  51316. * _.findLastIndex(users, 'active');
  51317. * // => 0
  51318. */
  51319. function findLastIndex(array, predicate, fromIndex) {
  51320. var length = array == null ? 0 : array.length;
  51321. if (!length) {
  51322. return -1;
  51323. }
  51324. var index = length - 1;
  51325. if (fromIndex !== undefined) {
  51326. index = toInteger(fromIndex);
  51327. index = fromIndex < 0
  51328. ? nativeMax(length + index, 0)
  51329. : nativeMin(index, length - 1);
  51330. }
  51331. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  51332. }
  51333. /**
  51334. * Flattens `array` a single level deep.
  51335. *
  51336. * @static
  51337. * @memberOf _
  51338. * @since 0.1.0
  51339. * @category Array
  51340. * @param {Array} array The array to flatten.
  51341. * @returns {Array} Returns the new flattened array.
  51342. * @example
  51343. *
  51344. * _.flatten([1, [2, [3, [4]], 5]]);
  51345. * // => [1, 2, [3, [4]], 5]
  51346. */
  51347. function flatten(array) {
  51348. var length = array == null ? 0 : array.length;
  51349. return length ? baseFlatten(array, 1) : [];
  51350. }
  51351. /**
  51352. * Recursively flattens `array`.
  51353. *
  51354. * @static
  51355. * @memberOf _
  51356. * @since 3.0.0
  51357. * @category Array
  51358. * @param {Array} array The array to flatten.
  51359. * @returns {Array} Returns the new flattened array.
  51360. * @example
  51361. *
  51362. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  51363. * // => [1, 2, 3, 4, 5]
  51364. */
  51365. function flattenDeep(array) {
  51366. var length = array == null ? 0 : array.length;
  51367. return length ? baseFlatten(array, INFINITY) : [];
  51368. }
  51369. /**
  51370. * Recursively flatten `array` up to `depth` times.
  51371. *
  51372. * @static
  51373. * @memberOf _
  51374. * @since 4.4.0
  51375. * @category Array
  51376. * @param {Array} array The array to flatten.
  51377. * @param {number} [depth=1] The maximum recursion depth.
  51378. * @returns {Array} Returns the new flattened array.
  51379. * @example
  51380. *
  51381. * var array = [1, [2, [3, [4]], 5]];
  51382. *
  51383. * _.flattenDepth(array, 1);
  51384. * // => [1, 2, [3, [4]], 5]
  51385. *
  51386. * _.flattenDepth(array, 2);
  51387. * // => [1, 2, 3, [4], 5]
  51388. */
  51389. function flattenDepth(array, depth) {
  51390. var length = array == null ? 0 : array.length;
  51391. if (!length) {
  51392. return [];
  51393. }
  51394. depth = depth === undefined ? 1 : toInteger(depth);
  51395. return baseFlatten(array, depth);
  51396. }
  51397. /**
  51398. * The inverse of `_.toPairs`; this method returns an object composed
  51399. * from key-value `pairs`.
  51400. *
  51401. * @static
  51402. * @memberOf _
  51403. * @since 4.0.0
  51404. * @category Array
  51405. * @param {Array} pairs The key-value pairs.
  51406. * @returns {Object} Returns the new object.
  51407. * @example
  51408. *
  51409. * _.fromPairs([['a', 1], ['b', 2]]);
  51410. * // => { 'a': 1, 'b': 2 }
  51411. */
  51412. function fromPairs(pairs) {
  51413. var index = -1,
  51414. length = pairs == null ? 0 : pairs.length,
  51415. result = {};
  51416. while (++index < length) {
  51417. var pair = pairs[index];
  51418. result[pair[0]] = pair[1];
  51419. }
  51420. return result;
  51421. }
  51422. /**
  51423. * Gets the first element of `array`.
  51424. *
  51425. * @static
  51426. * @memberOf _
  51427. * @since 0.1.0
  51428. * @alias first
  51429. * @category Array
  51430. * @param {Array} array The array to query.
  51431. * @returns {*} Returns the first element of `array`.
  51432. * @example
  51433. *
  51434. * _.head([1, 2, 3]);
  51435. * // => 1
  51436. *
  51437. * _.head([]);
  51438. * // => undefined
  51439. */
  51440. function head(array) {
  51441. return (array && array.length) ? array[0] : undefined;
  51442. }
  51443. /**
  51444. * Gets the index at which the first occurrence of `value` is found in `array`
  51445. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  51446. * for equality comparisons. If `fromIndex` is negative, it's used as the
  51447. * offset from the end of `array`.
  51448. *
  51449. * @static
  51450. * @memberOf _
  51451. * @since 0.1.0
  51452. * @category Array
  51453. * @param {Array} array The array to inspect.
  51454. * @param {*} value The value to search for.
  51455. * @param {number} [fromIndex=0] The index to search from.
  51456. * @returns {number} Returns the index of the matched value, else `-1`.
  51457. * @example
  51458. *
  51459. * _.indexOf([1, 2, 1, 2], 2);
  51460. * // => 1
  51461. *
  51462. * // Search from the `fromIndex`.
  51463. * _.indexOf([1, 2, 1, 2], 2, 2);
  51464. * // => 3
  51465. */
  51466. function indexOf(array, value, fromIndex) {
  51467. var length = array == null ? 0 : array.length;
  51468. if (!length) {
  51469. return -1;
  51470. }
  51471. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  51472. if (index < 0) {
  51473. index = nativeMax(length + index, 0);
  51474. }
  51475. return baseIndexOf(array, value, index);
  51476. }
  51477. /**
  51478. * Gets all but the last element of `array`.
  51479. *
  51480. * @static
  51481. * @memberOf _
  51482. * @since 0.1.0
  51483. * @category Array
  51484. * @param {Array} array The array to query.
  51485. * @returns {Array} Returns the slice of `array`.
  51486. * @example
  51487. *
  51488. * _.initial([1, 2, 3]);
  51489. * // => [1, 2]
  51490. */
  51491. function initial(array) {
  51492. var length = array == null ? 0 : array.length;
  51493. return length ? baseSlice(array, 0, -1) : [];
  51494. }
  51495. /**
  51496. * Creates an array of unique values that are included in all given arrays
  51497. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  51498. * for equality comparisons. The order and references of result values are
  51499. * determined by the first array.
  51500. *
  51501. * @static
  51502. * @memberOf _
  51503. * @since 0.1.0
  51504. * @category Array
  51505. * @param {...Array} [arrays] The arrays to inspect.
  51506. * @returns {Array} Returns the new array of intersecting values.
  51507. * @example
  51508. *
  51509. * _.intersection([2, 1], [2, 3]);
  51510. * // => [2]
  51511. */
  51512. var intersection = baseRest(function(arrays) {
  51513. var mapped = arrayMap(arrays, castArrayLikeObject);
  51514. return (mapped.length && mapped[0] === arrays[0])
  51515. ? baseIntersection(mapped)
  51516. : [];
  51517. });
  51518. /**
  51519. * This method is like `_.intersection` except that it accepts `iteratee`
  51520. * which is invoked for each element of each `arrays` to generate the criterion
  51521. * by which they're compared. The order and references of result values are
  51522. * determined by the first array. The iteratee is invoked with one argument:
  51523. * (value).
  51524. *
  51525. * @static
  51526. * @memberOf _
  51527. * @since 4.0.0
  51528. * @category Array
  51529. * @param {...Array} [arrays] The arrays to inspect.
  51530. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  51531. * @returns {Array} Returns the new array of intersecting values.
  51532. * @example
  51533. *
  51534. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  51535. * // => [2.1]
  51536. *
  51537. * // The `_.property` iteratee shorthand.
  51538. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  51539. * // => [{ 'x': 1 }]
  51540. */
  51541. var intersectionBy = baseRest(function(arrays) {
  51542. var iteratee = last(arrays),
  51543. mapped = arrayMap(arrays, castArrayLikeObject);
  51544. if (iteratee === last(mapped)) {
  51545. iteratee = undefined;
  51546. } else {
  51547. mapped.pop();
  51548. }
  51549. return (mapped.length && mapped[0] === arrays[0])
  51550. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  51551. : [];
  51552. });
  51553. /**
  51554. * This method is like `_.intersection` except that it accepts `comparator`
  51555. * which is invoked to compare elements of `arrays`. The order and references
  51556. * of result values are determined by the first array. The comparator is
  51557. * invoked with two arguments: (arrVal, othVal).
  51558. *
  51559. * @static
  51560. * @memberOf _
  51561. * @since 4.0.0
  51562. * @category Array
  51563. * @param {...Array} [arrays] The arrays to inspect.
  51564. * @param {Function} [comparator] The comparator invoked per element.
  51565. * @returns {Array} Returns the new array of intersecting values.
  51566. * @example
  51567. *
  51568. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  51569. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  51570. *
  51571. * _.intersectionWith(objects, others, _.isEqual);
  51572. * // => [{ 'x': 1, 'y': 2 }]
  51573. */
  51574. var intersectionWith = baseRest(function(arrays) {
  51575. var comparator = last(arrays),
  51576. mapped = arrayMap(arrays, castArrayLikeObject);
  51577. comparator = typeof comparator == 'function' ? comparator : undefined;
  51578. if (comparator) {
  51579. mapped.pop();
  51580. }
  51581. return (mapped.length && mapped[0] === arrays[0])
  51582. ? baseIntersection(mapped, undefined, comparator)
  51583. : [];
  51584. });
  51585. /**
  51586. * Converts all elements in `array` into a string separated by `separator`.
  51587. *
  51588. * @static
  51589. * @memberOf _
  51590. * @since 4.0.0
  51591. * @category Array
  51592. * @param {Array} array The array to convert.
  51593. * @param {string} [separator=','] The element separator.
  51594. * @returns {string} Returns the joined string.
  51595. * @example
  51596. *
  51597. * _.join(['a', 'b', 'c'], '~');
  51598. * // => 'a~b~c'
  51599. */
  51600. function join(array, separator) {
  51601. return array == null ? '' : nativeJoin.call(array, separator);
  51602. }
  51603. /**
  51604. * Gets the last element of `array`.
  51605. *
  51606. * @static
  51607. * @memberOf _
  51608. * @since 0.1.0
  51609. * @category Array
  51610. * @param {Array} array The array to query.
  51611. * @returns {*} Returns the last element of `array`.
  51612. * @example
  51613. *
  51614. * _.last([1, 2, 3]);
  51615. * // => 3
  51616. */
  51617. function last(array) {
  51618. var length = array == null ? 0 : array.length;
  51619. return length ? array[length - 1] : undefined;
  51620. }
  51621. /**
  51622. * This method is like `_.indexOf` except that it iterates over elements of
  51623. * `array` from right to left.
  51624. *
  51625. * @static
  51626. * @memberOf _
  51627. * @since 0.1.0
  51628. * @category Array
  51629. * @param {Array} array The array to inspect.
  51630. * @param {*} value The value to search for.
  51631. * @param {number} [fromIndex=array.length-1] The index to search from.
  51632. * @returns {number} Returns the index of the matched value, else `-1`.
  51633. * @example
  51634. *
  51635. * _.lastIndexOf([1, 2, 1, 2], 2);
  51636. * // => 3
  51637. *
  51638. * // Search from the `fromIndex`.
  51639. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  51640. * // => 1
  51641. */
  51642. function lastIndexOf(array, value, fromIndex) {
  51643. var length = array == null ? 0 : array.length;
  51644. if (!length) {
  51645. return -1;
  51646. }
  51647. var index = length;
  51648. if (fromIndex !== undefined) {
  51649. index = toInteger(fromIndex);
  51650. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  51651. }
  51652. return value === value
  51653. ? strictLastIndexOf(array, value, index)
  51654. : baseFindIndex(array, baseIsNaN, index, true);
  51655. }
  51656. /**
  51657. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  51658. * element from the end is returned.
  51659. *
  51660. * @static
  51661. * @memberOf _
  51662. * @since 4.11.0
  51663. * @category Array
  51664. * @param {Array} array The array to query.
  51665. * @param {number} [n=0] The index of the element to return.
  51666. * @returns {*} Returns the nth element of `array`.
  51667. * @example
  51668. *
  51669. * var array = ['a', 'b', 'c', 'd'];
  51670. *
  51671. * _.nth(array, 1);
  51672. * // => 'b'
  51673. *
  51674. * _.nth(array, -2);
  51675. * // => 'c';
  51676. */
  51677. function nth(array, n) {
  51678. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  51679. }
  51680. /**
  51681. * Removes all given values from `array` using
  51682. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  51683. * for equality comparisons.
  51684. *
  51685. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  51686. * to remove elements from an array by predicate.
  51687. *
  51688. * @static
  51689. * @memberOf _
  51690. * @since 2.0.0
  51691. * @category Array
  51692. * @param {Array} array The array to modify.
  51693. * @param {...*} [values] The values to remove.
  51694. * @returns {Array} Returns `array`.
  51695. * @example
  51696. *
  51697. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  51698. *
  51699. * _.pull(array, 'a', 'c');
  51700. * console.log(array);
  51701. * // => ['b', 'b']
  51702. */
  51703. var pull = baseRest(pullAll);
  51704. /**
  51705. * This method is like `_.pull` except that it accepts an array of values to remove.
  51706. *
  51707. * **Note:** Unlike `_.difference`, this method mutates `array`.
  51708. *
  51709. * @static
  51710. * @memberOf _
  51711. * @since 4.0.0
  51712. * @category Array
  51713. * @param {Array} array The array to modify.
  51714. * @param {Array} values The values to remove.
  51715. * @returns {Array} Returns `array`.
  51716. * @example
  51717. *
  51718. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  51719. *
  51720. * _.pullAll(array, ['a', 'c']);
  51721. * console.log(array);
  51722. * // => ['b', 'b']
  51723. */
  51724. function pullAll(array, values) {
  51725. return (array && array.length && values && values.length)
  51726. ? basePullAll(array, values)
  51727. : array;
  51728. }
  51729. /**
  51730. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  51731. * invoked for each element of `array` and `values` to generate the criterion
  51732. * by which they're compared. The iteratee is invoked with one argument: (value).
  51733. *
  51734. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  51735. *
  51736. * @static
  51737. * @memberOf _
  51738. * @since 4.0.0
  51739. * @category Array
  51740. * @param {Array} array The array to modify.
  51741. * @param {Array} values The values to remove.
  51742. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  51743. * @returns {Array} Returns `array`.
  51744. * @example
  51745. *
  51746. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  51747. *
  51748. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  51749. * console.log(array);
  51750. * // => [{ 'x': 2 }]
  51751. */
  51752. function pullAllBy(array, values, iteratee) {
  51753. return (array && array.length && values && values.length)
  51754. ? basePullAll(array, values, getIteratee(iteratee, 2))
  51755. : array;
  51756. }
  51757. /**
  51758. * This method is like `_.pullAll` except that it accepts `comparator` which
  51759. * is invoked to compare elements of `array` to `values`. The comparator is
  51760. * invoked with two arguments: (arrVal, othVal).
  51761. *
  51762. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  51763. *
  51764. * @static
  51765. * @memberOf _
  51766. * @since 4.6.0
  51767. * @category Array
  51768. * @param {Array} array The array to modify.
  51769. * @param {Array} values The values to remove.
  51770. * @param {Function} [comparator] The comparator invoked per element.
  51771. * @returns {Array} Returns `array`.
  51772. * @example
  51773. *
  51774. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  51775. *
  51776. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  51777. * console.log(array);
  51778. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  51779. */
  51780. function pullAllWith(array, values, comparator) {
  51781. return (array && array.length && values && values.length)
  51782. ? basePullAll(array, values, undefined, comparator)
  51783. : array;
  51784. }
  51785. /**
  51786. * Removes elements from `array` corresponding to `indexes` and returns an
  51787. * array of removed elements.
  51788. *
  51789. * **Note:** Unlike `_.at`, this method mutates `array`.
  51790. *
  51791. * @static
  51792. * @memberOf _
  51793. * @since 3.0.0
  51794. * @category Array
  51795. * @param {Array} array The array to modify.
  51796. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  51797. * @returns {Array} Returns the new array of removed elements.
  51798. * @example
  51799. *
  51800. * var array = ['a', 'b', 'c', 'd'];
  51801. * var pulled = _.pullAt(array, [1, 3]);
  51802. *
  51803. * console.log(array);
  51804. * // => ['a', 'c']
  51805. *
  51806. * console.log(pulled);
  51807. * // => ['b', 'd']
  51808. */
  51809. var pullAt = flatRest(function(array, indexes) {
  51810. var length = array == null ? 0 : array.length,
  51811. result = baseAt(array, indexes);
  51812. basePullAt(array, arrayMap(indexes, function(index) {
  51813. return isIndex(index, length) ? +index : index;
  51814. }).sort(compareAscending));
  51815. return result;
  51816. });
  51817. /**
  51818. * Removes all elements from `array` that `predicate` returns truthy for
  51819. * and returns an array of the removed elements. The predicate is invoked
  51820. * with three arguments: (value, index, array).
  51821. *
  51822. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  51823. * to pull elements from an array by value.
  51824. *
  51825. * @static
  51826. * @memberOf _
  51827. * @since 2.0.0
  51828. * @category Array
  51829. * @param {Array} array The array to modify.
  51830. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  51831. * @returns {Array} Returns the new array of removed elements.
  51832. * @example
  51833. *
  51834. * var array = [1, 2, 3, 4];
  51835. * var evens = _.remove(array, function(n) {
  51836. * return n % 2 == 0;
  51837. * });
  51838. *
  51839. * console.log(array);
  51840. * // => [1, 3]
  51841. *
  51842. * console.log(evens);
  51843. * // => [2, 4]
  51844. */
  51845. function remove(array, predicate) {
  51846. var result = [];
  51847. if (!(array && array.length)) {
  51848. return result;
  51849. }
  51850. var index = -1,
  51851. indexes = [],
  51852. length = array.length;
  51853. predicate = getIteratee(predicate, 3);
  51854. while (++index < length) {
  51855. var value = array[index];
  51856. if (predicate(value, index, array)) {
  51857. result.push(value);
  51858. indexes.push(index);
  51859. }
  51860. }
  51861. basePullAt(array, indexes);
  51862. return result;
  51863. }
  51864. /**
  51865. * Reverses `array` so that the first element becomes the last, the second
  51866. * element becomes the second to last, and so on.
  51867. *
  51868. * **Note:** This method mutates `array` and is based on
  51869. * [`Array#reverse`](https://mdn.io/Array/reverse).
  51870. *
  51871. * @static
  51872. * @memberOf _
  51873. * @since 4.0.0
  51874. * @category Array
  51875. * @param {Array} array The array to modify.
  51876. * @returns {Array} Returns `array`.
  51877. * @example
  51878. *
  51879. * var array = [1, 2, 3];
  51880. *
  51881. * _.reverse(array);
  51882. * // => [3, 2, 1]
  51883. *
  51884. * console.log(array);
  51885. * // => [3, 2, 1]
  51886. */
  51887. function reverse(array) {
  51888. return array == null ? array : nativeReverse.call(array);
  51889. }
  51890. /**
  51891. * Creates a slice of `array` from `start` up to, but not including, `end`.
  51892. *
  51893. * **Note:** This method is used instead of
  51894. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  51895. * returned.
  51896. *
  51897. * @static
  51898. * @memberOf _
  51899. * @since 3.0.0
  51900. * @category Array
  51901. * @param {Array} array The array to slice.
  51902. * @param {number} [start=0] The start position.
  51903. * @param {number} [end=array.length] The end position.
  51904. * @returns {Array} Returns the slice of `array`.
  51905. */
  51906. function slice(array, start, end) {
  51907. var length = array == null ? 0 : array.length;
  51908. if (!length) {
  51909. return [];
  51910. }
  51911. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  51912. start = 0;
  51913. end = length;
  51914. }
  51915. else {
  51916. start = start == null ? 0 : toInteger(start);
  51917. end = end === undefined ? length : toInteger(end);
  51918. }
  51919. return baseSlice(array, start, end);
  51920. }
  51921. /**
  51922. * Uses a binary search to determine the lowest index at which `value`
  51923. * should be inserted into `array` in order to maintain its sort order.
  51924. *
  51925. * @static
  51926. * @memberOf _
  51927. * @since 0.1.0
  51928. * @category Array
  51929. * @param {Array} array The sorted array to inspect.
  51930. * @param {*} value The value to evaluate.
  51931. * @returns {number} Returns the index at which `value` should be inserted
  51932. * into `array`.
  51933. * @example
  51934. *
  51935. * _.sortedIndex([30, 50], 40);
  51936. * // => 1
  51937. */
  51938. function sortedIndex(array, value) {
  51939. return baseSortedIndex(array, value);
  51940. }
  51941. /**
  51942. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  51943. * which is invoked for `value` and each element of `array` to compute their
  51944. * sort ranking. The iteratee is invoked with one argument: (value).
  51945. *
  51946. * @static
  51947. * @memberOf _
  51948. * @since 4.0.0
  51949. * @category Array
  51950. * @param {Array} array The sorted array to inspect.
  51951. * @param {*} value The value to evaluate.
  51952. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  51953. * @returns {number} Returns the index at which `value` should be inserted
  51954. * into `array`.
  51955. * @example
  51956. *
  51957. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  51958. *
  51959. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  51960. * // => 0
  51961. *
  51962. * // The `_.property` iteratee shorthand.
  51963. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  51964. * // => 0
  51965. */
  51966. function sortedIndexBy(array, value, iteratee) {
  51967. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  51968. }
  51969. /**
  51970. * This method is like `_.indexOf` except that it performs a binary
  51971. * search on a sorted `array`.
  51972. *
  51973. * @static
  51974. * @memberOf _
  51975. * @since 4.0.0
  51976. * @category Array
  51977. * @param {Array} array The array to inspect.
  51978. * @param {*} value The value to search for.
  51979. * @returns {number} Returns the index of the matched value, else `-1`.
  51980. * @example
  51981. *
  51982. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  51983. * // => 1
  51984. */
  51985. function sortedIndexOf(array, value) {
  51986. var length = array == null ? 0 : array.length;
  51987. if (length) {
  51988. var index = baseSortedIndex(array, value);
  51989. if (index < length && eq(array[index], value)) {
  51990. return index;
  51991. }
  51992. }
  51993. return -1;
  51994. }
  51995. /**
  51996. * This method is like `_.sortedIndex` except that it returns the highest
  51997. * index at which `value` should be inserted into `array` in order to
  51998. * maintain its sort order.
  51999. *
  52000. * @static
  52001. * @memberOf _
  52002. * @since 3.0.0
  52003. * @category Array
  52004. * @param {Array} array The sorted array to inspect.
  52005. * @param {*} value The value to evaluate.
  52006. * @returns {number} Returns the index at which `value` should be inserted
  52007. * into `array`.
  52008. * @example
  52009. *
  52010. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  52011. * // => 4
  52012. */
  52013. function sortedLastIndex(array, value) {
  52014. return baseSortedIndex(array, value, true);
  52015. }
  52016. /**
  52017. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  52018. * which is invoked for `value` and each element of `array` to compute their
  52019. * sort ranking. The iteratee is invoked with one argument: (value).
  52020. *
  52021. * @static
  52022. * @memberOf _
  52023. * @since 4.0.0
  52024. * @category Array
  52025. * @param {Array} array The sorted array to inspect.
  52026. * @param {*} value The value to evaluate.
  52027. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  52028. * @returns {number} Returns the index at which `value` should be inserted
  52029. * into `array`.
  52030. * @example
  52031. *
  52032. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  52033. *
  52034. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  52035. * // => 1
  52036. *
  52037. * // The `_.property` iteratee shorthand.
  52038. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  52039. * // => 1
  52040. */
  52041. function sortedLastIndexBy(array, value, iteratee) {
  52042. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  52043. }
  52044. /**
  52045. * This method is like `_.lastIndexOf` except that it performs a binary
  52046. * search on a sorted `array`.
  52047. *
  52048. * @static
  52049. * @memberOf _
  52050. * @since 4.0.0
  52051. * @category Array
  52052. * @param {Array} array The array to inspect.
  52053. * @param {*} value The value to search for.
  52054. * @returns {number} Returns the index of the matched value, else `-1`.
  52055. * @example
  52056. *
  52057. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  52058. * // => 3
  52059. */
  52060. function sortedLastIndexOf(array, value) {
  52061. var length = array == null ? 0 : array.length;
  52062. if (length) {
  52063. var index = baseSortedIndex(array, value, true) - 1;
  52064. if (eq(array[index], value)) {
  52065. return index;
  52066. }
  52067. }
  52068. return -1;
  52069. }
  52070. /**
  52071. * This method is like `_.uniq` except that it's designed and optimized
  52072. * for sorted arrays.
  52073. *
  52074. * @static
  52075. * @memberOf _
  52076. * @since 4.0.0
  52077. * @category Array
  52078. * @param {Array} array The array to inspect.
  52079. * @returns {Array} Returns the new duplicate free array.
  52080. * @example
  52081. *
  52082. * _.sortedUniq([1, 1, 2]);
  52083. * // => [1, 2]
  52084. */
  52085. function sortedUniq(array) {
  52086. return (array && array.length)
  52087. ? baseSortedUniq(array)
  52088. : [];
  52089. }
  52090. /**
  52091. * This method is like `_.uniqBy` except that it's designed and optimized
  52092. * for sorted arrays.
  52093. *
  52094. * @static
  52095. * @memberOf _
  52096. * @since 4.0.0
  52097. * @category Array
  52098. * @param {Array} array The array to inspect.
  52099. * @param {Function} [iteratee] The iteratee invoked per element.
  52100. * @returns {Array} Returns the new duplicate free array.
  52101. * @example
  52102. *
  52103. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  52104. * // => [1.1, 2.3]
  52105. */
  52106. function sortedUniqBy(array, iteratee) {
  52107. return (array && array.length)
  52108. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  52109. : [];
  52110. }
  52111. /**
  52112. * Gets all but the first element of `array`.
  52113. *
  52114. * @static
  52115. * @memberOf _
  52116. * @since 4.0.0
  52117. * @category Array
  52118. * @param {Array} array The array to query.
  52119. * @returns {Array} Returns the slice of `array`.
  52120. * @example
  52121. *
  52122. * _.tail([1, 2, 3]);
  52123. * // => [2, 3]
  52124. */
  52125. function tail(array) {
  52126. var length = array == null ? 0 : array.length;
  52127. return length ? baseSlice(array, 1, length) : [];
  52128. }
  52129. /**
  52130. * Creates a slice of `array` with `n` elements taken from the beginning.
  52131. *
  52132. * @static
  52133. * @memberOf _
  52134. * @since 0.1.0
  52135. * @category Array
  52136. * @param {Array} array The array to query.
  52137. * @param {number} [n=1] The number of elements to take.
  52138. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  52139. * @returns {Array} Returns the slice of `array`.
  52140. * @example
  52141. *
  52142. * _.take([1, 2, 3]);
  52143. * // => [1]
  52144. *
  52145. * _.take([1, 2, 3], 2);
  52146. * // => [1, 2]
  52147. *
  52148. * _.take([1, 2, 3], 5);
  52149. * // => [1, 2, 3]
  52150. *
  52151. * _.take([1, 2, 3], 0);
  52152. * // => []
  52153. */
  52154. function take(array, n, guard) {
  52155. if (!(array && array.length)) {
  52156. return [];
  52157. }
  52158. n = (guard || n === undefined) ? 1 : toInteger(n);
  52159. return baseSlice(array, 0, n < 0 ? 0 : n);
  52160. }
  52161. /**
  52162. * Creates a slice of `array` with `n` elements taken from the end.
  52163. *
  52164. * @static
  52165. * @memberOf _
  52166. * @since 3.0.0
  52167. * @category Array
  52168. * @param {Array} array The array to query.
  52169. * @param {number} [n=1] The number of elements to take.
  52170. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  52171. * @returns {Array} Returns the slice of `array`.
  52172. * @example
  52173. *
  52174. * _.takeRight([1, 2, 3]);
  52175. * // => [3]
  52176. *
  52177. * _.takeRight([1, 2, 3], 2);
  52178. * // => [2, 3]
  52179. *
  52180. * _.takeRight([1, 2, 3], 5);
  52181. * // => [1, 2, 3]
  52182. *
  52183. * _.takeRight([1, 2, 3], 0);
  52184. * // => []
  52185. */
  52186. function takeRight(array, n, guard) {
  52187. var length = array == null ? 0 : array.length;
  52188. if (!length) {
  52189. return [];
  52190. }
  52191. n = (guard || n === undefined) ? 1 : toInteger(n);
  52192. n = length - n;
  52193. return baseSlice(array, n < 0 ? 0 : n, length);
  52194. }
  52195. /**
  52196. * Creates a slice of `array` with elements taken from the end. Elements are
  52197. * taken until `predicate` returns falsey. The predicate is invoked with
  52198. * three arguments: (value, index, array).
  52199. *
  52200. * @static
  52201. * @memberOf _
  52202. * @since 3.0.0
  52203. * @category Array
  52204. * @param {Array} array The array to query.
  52205. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  52206. * @returns {Array} Returns the slice of `array`.
  52207. * @example
  52208. *
  52209. * var users = [
  52210. * { 'user': 'barney', 'active': true },
  52211. * { 'user': 'fred', 'active': false },
  52212. * { 'user': 'pebbles', 'active': false }
  52213. * ];
  52214. *
  52215. * _.takeRightWhile(users, function(o) { return !o.active; });
  52216. * // => objects for ['fred', 'pebbles']
  52217. *
  52218. * // The `_.matches` iteratee shorthand.
  52219. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  52220. * // => objects for ['pebbles']
  52221. *
  52222. * // The `_.matchesProperty` iteratee shorthand.
  52223. * _.takeRightWhile(users, ['active', false]);
  52224. * // => objects for ['fred', 'pebbles']
  52225. *
  52226. * // The `_.property` iteratee shorthand.
  52227. * _.takeRightWhile(users, 'active');
  52228. * // => []
  52229. */
  52230. function takeRightWhile(array, predicate) {
  52231. return (array && array.length)
  52232. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  52233. : [];
  52234. }
  52235. /**
  52236. * Creates a slice of `array` with elements taken from the beginning. Elements
  52237. * are taken until `predicate` returns falsey. The predicate is invoked with
  52238. * three arguments: (value, index, array).
  52239. *
  52240. * @static
  52241. * @memberOf _
  52242. * @since 3.0.0
  52243. * @category Array
  52244. * @param {Array} array The array to query.
  52245. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  52246. * @returns {Array} Returns the slice of `array`.
  52247. * @example
  52248. *
  52249. * var users = [
  52250. * { 'user': 'barney', 'active': false },
  52251. * { 'user': 'fred', 'active': false },
  52252. * { 'user': 'pebbles', 'active': true }
  52253. * ];
  52254. *
  52255. * _.takeWhile(users, function(o) { return !o.active; });
  52256. * // => objects for ['barney', 'fred']
  52257. *
  52258. * // The `_.matches` iteratee shorthand.
  52259. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  52260. * // => objects for ['barney']
  52261. *
  52262. * // The `_.matchesProperty` iteratee shorthand.
  52263. * _.takeWhile(users, ['active', false]);
  52264. * // => objects for ['barney', 'fred']
  52265. *
  52266. * // The `_.property` iteratee shorthand.
  52267. * _.takeWhile(users, 'active');
  52268. * // => []
  52269. */
  52270. function takeWhile(array, predicate) {
  52271. return (array && array.length)
  52272. ? baseWhile(array, getIteratee(predicate, 3))
  52273. : [];
  52274. }
  52275. /**
  52276. * Creates an array of unique values, in order, from all given arrays using
  52277. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  52278. * for equality comparisons.
  52279. *
  52280. * @static
  52281. * @memberOf _
  52282. * @since 0.1.0
  52283. * @category Array
  52284. * @param {...Array} [arrays] The arrays to inspect.
  52285. * @returns {Array} Returns the new array of combined values.
  52286. * @example
  52287. *
  52288. * _.union([2], [1, 2]);
  52289. * // => [2, 1]
  52290. */
  52291. var union = baseRest(function(arrays) {
  52292. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  52293. });
  52294. /**
  52295. * This method is like `_.union` except that it accepts `iteratee` which is
  52296. * invoked for each element of each `arrays` to generate the criterion by
  52297. * which uniqueness is computed. Result values are chosen from the first
  52298. * array in which the value occurs. The iteratee is invoked with one argument:
  52299. * (value).
  52300. *
  52301. * @static
  52302. * @memberOf _
  52303. * @since 4.0.0
  52304. * @category Array
  52305. * @param {...Array} [arrays] The arrays to inspect.
  52306. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  52307. * @returns {Array} Returns the new array of combined values.
  52308. * @example
  52309. *
  52310. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  52311. * // => [2.1, 1.2]
  52312. *
  52313. * // The `_.property` iteratee shorthand.
  52314. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  52315. * // => [{ 'x': 1 }, { 'x': 2 }]
  52316. */
  52317. var unionBy = baseRest(function(arrays) {
  52318. var iteratee = last(arrays);
  52319. if (isArrayLikeObject(iteratee)) {
  52320. iteratee = undefined;
  52321. }
  52322. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  52323. });
  52324. /**
  52325. * This method is like `_.union` except that it accepts `comparator` which
  52326. * is invoked to compare elements of `arrays`. Result values are chosen from
  52327. * the first array in which the value occurs. The comparator is invoked
  52328. * with two arguments: (arrVal, othVal).
  52329. *
  52330. * @static
  52331. * @memberOf _
  52332. * @since 4.0.0
  52333. * @category Array
  52334. * @param {...Array} [arrays] The arrays to inspect.
  52335. * @param {Function} [comparator] The comparator invoked per element.
  52336. * @returns {Array} Returns the new array of combined values.
  52337. * @example
  52338. *
  52339. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  52340. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  52341. *
  52342. * _.unionWith(objects, others, _.isEqual);
  52343. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  52344. */
  52345. var unionWith = baseRest(function(arrays) {
  52346. var comparator = last(arrays);
  52347. comparator = typeof comparator == 'function' ? comparator : undefined;
  52348. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  52349. });
  52350. /**
  52351. * Creates a duplicate-free version of an array, using
  52352. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  52353. * for equality comparisons, in which only the first occurrence of each element
  52354. * is kept. The order of result values is determined by the order they occur
  52355. * in the array.
  52356. *
  52357. * @static
  52358. * @memberOf _
  52359. * @since 0.1.0
  52360. * @category Array
  52361. * @param {Array} array The array to inspect.
  52362. * @returns {Array} Returns the new duplicate free array.
  52363. * @example
  52364. *
  52365. * _.uniq([2, 1, 2]);
  52366. * // => [2, 1]
  52367. */
  52368. function uniq(array) {
  52369. return (array && array.length) ? baseUniq(array) : [];
  52370. }
  52371. /**
  52372. * This method is like `_.uniq` except that it accepts `iteratee` which is
  52373. * invoked for each element in `array` to generate the criterion by which
  52374. * uniqueness is computed. The order of result values is determined by the
  52375. * order they occur in the array. The iteratee is invoked with one argument:
  52376. * (value).
  52377. *
  52378. * @static
  52379. * @memberOf _
  52380. * @since 4.0.0
  52381. * @category Array
  52382. * @param {Array} array The array to inspect.
  52383. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  52384. * @returns {Array} Returns the new duplicate free array.
  52385. * @example
  52386. *
  52387. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  52388. * // => [2.1, 1.2]
  52389. *
  52390. * // The `_.property` iteratee shorthand.
  52391. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  52392. * // => [{ 'x': 1 }, { 'x': 2 }]
  52393. */
  52394. function uniqBy(array, iteratee) {
  52395. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  52396. }
  52397. /**
  52398. * This method is like `_.uniq` except that it accepts `comparator` which
  52399. * is invoked to compare elements of `array`. The order of result values is
  52400. * determined by the order they occur in the array.The comparator is invoked
  52401. * with two arguments: (arrVal, othVal).
  52402. *
  52403. * @static
  52404. * @memberOf _
  52405. * @since 4.0.0
  52406. * @category Array
  52407. * @param {Array} array The array to inspect.
  52408. * @param {Function} [comparator] The comparator invoked per element.
  52409. * @returns {Array} Returns the new duplicate free array.
  52410. * @example
  52411. *
  52412. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  52413. *
  52414. * _.uniqWith(objects, _.isEqual);
  52415. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  52416. */
  52417. function uniqWith(array, comparator) {
  52418. comparator = typeof comparator == 'function' ? comparator : undefined;
  52419. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  52420. }
  52421. /**
  52422. * This method is like `_.zip` except that it accepts an array of grouped
  52423. * elements and creates an array regrouping the elements to their pre-zip
  52424. * configuration.
  52425. *
  52426. * @static
  52427. * @memberOf _
  52428. * @since 1.2.0
  52429. * @category Array
  52430. * @param {Array} array The array of grouped elements to process.
  52431. * @returns {Array} Returns the new array of regrouped elements.
  52432. * @example
  52433. *
  52434. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  52435. * // => [['a', 1, true], ['b', 2, false]]
  52436. *
  52437. * _.unzip(zipped);
  52438. * // => [['a', 'b'], [1, 2], [true, false]]
  52439. */
  52440. function unzip(array) {
  52441. if (!(array && array.length)) {
  52442. return [];
  52443. }
  52444. var length = 0;
  52445. array = arrayFilter(array, function(group) {
  52446. if (isArrayLikeObject(group)) {
  52447. length = nativeMax(group.length, length);
  52448. return true;
  52449. }
  52450. });
  52451. return baseTimes(length, function(index) {
  52452. return arrayMap(array, baseProperty(index));
  52453. });
  52454. }
  52455. /**
  52456. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  52457. * how regrouped values should be combined. The iteratee is invoked with the
  52458. * elements of each group: (...group).
  52459. *
  52460. * @static
  52461. * @memberOf _
  52462. * @since 3.8.0
  52463. * @category Array
  52464. * @param {Array} array The array of grouped elements to process.
  52465. * @param {Function} [iteratee=_.identity] The function to combine
  52466. * regrouped values.
  52467. * @returns {Array} Returns the new array of regrouped elements.
  52468. * @example
  52469. *
  52470. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  52471. * // => [[1, 10, 100], [2, 20, 200]]
  52472. *
  52473. * _.unzipWith(zipped, _.add);
  52474. * // => [3, 30, 300]
  52475. */
  52476. function unzipWith(array, iteratee) {
  52477. if (!(array && array.length)) {
  52478. return [];
  52479. }
  52480. var result = unzip(array);
  52481. if (iteratee == null) {
  52482. return result;
  52483. }
  52484. return arrayMap(result, function(group) {
  52485. return apply(iteratee, undefined, group);
  52486. });
  52487. }
  52488. /**
  52489. * Creates an array excluding all given values using
  52490. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  52491. * for equality comparisons.
  52492. *
  52493. * **Note:** Unlike `_.pull`, this method returns a new array.
  52494. *
  52495. * @static
  52496. * @memberOf _
  52497. * @since 0.1.0
  52498. * @category Array
  52499. * @param {Array} array The array to inspect.
  52500. * @param {...*} [values] The values to exclude.
  52501. * @returns {Array} Returns the new array of filtered values.
  52502. * @see _.difference, _.xor
  52503. * @example
  52504. *
  52505. * _.without([2, 1, 2, 3], 1, 2);
  52506. * // => [3]
  52507. */
  52508. var without = baseRest(function(array, values) {
  52509. return isArrayLikeObject(array)
  52510. ? baseDifference(array, values)
  52511. : [];
  52512. });
  52513. /**
  52514. * Creates an array of unique values that is the
  52515. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  52516. * of the given arrays. The order of result values is determined by the order
  52517. * they occur in the arrays.
  52518. *
  52519. * @static
  52520. * @memberOf _
  52521. * @since 2.4.0
  52522. * @category Array
  52523. * @param {...Array} [arrays] The arrays to inspect.
  52524. * @returns {Array} Returns the new array of filtered values.
  52525. * @see _.difference, _.without
  52526. * @example
  52527. *
  52528. * _.xor([2, 1], [2, 3]);
  52529. * // => [1, 3]
  52530. */
  52531. var xor = baseRest(function(arrays) {
  52532. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  52533. });
  52534. /**
  52535. * This method is like `_.xor` except that it accepts `iteratee` which is
  52536. * invoked for each element of each `arrays` to generate the criterion by
  52537. * which by which they're compared. The order of result values is determined
  52538. * by the order they occur in the arrays. The iteratee is invoked with one
  52539. * argument: (value).
  52540. *
  52541. * @static
  52542. * @memberOf _
  52543. * @since 4.0.0
  52544. * @category Array
  52545. * @param {...Array} [arrays] The arrays to inspect.
  52546. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  52547. * @returns {Array} Returns the new array of filtered values.
  52548. * @example
  52549. *
  52550. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  52551. * // => [1.2, 3.4]
  52552. *
  52553. * // The `_.property` iteratee shorthand.
  52554. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  52555. * // => [{ 'x': 2 }]
  52556. */
  52557. var xorBy = baseRest(function(arrays) {
  52558. var iteratee = last(arrays);
  52559. if (isArrayLikeObject(iteratee)) {
  52560. iteratee = undefined;
  52561. }
  52562. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  52563. });
  52564. /**
  52565. * This method is like `_.xor` except that it accepts `comparator` which is
  52566. * invoked to compare elements of `arrays`. The order of result values is
  52567. * determined by the order they occur in the arrays. The comparator is invoked
  52568. * with two arguments: (arrVal, othVal).
  52569. *
  52570. * @static
  52571. * @memberOf _
  52572. * @since 4.0.0
  52573. * @category Array
  52574. * @param {...Array} [arrays] The arrays to inspect.
  52575. * @param {Function} [comparator] The comparator invoked per element.
  52576. * @returns {Array} Returns the new array of filtered values.
  52577. * @example
  52578. *
  52579. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  52580. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  52581. *
  52582. * _.xorWith(objects, others, _.isEqual);
  52583. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  52584. */
  52585. var xorWith = baseRest(function(arrays) {
  52586. var comparator = last(arrays);
  52587. comparator = typeof comparator == 'function' ? comparator : undefined;
  52588. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  52589. });
  52590. /**
  52591. * Creates an array of grouped elements, the first of which contains the
  52592. * first elements of the given arrays, the second of which contains the
  52593. * second elements of the given arrays, and so on.
  52594. *
  52595. * @static
  52596. * @memberOf _
  52597. * @since 0.1.0
  52598. * @category Array
  52599. * @param {...Array} [arrays] The arrays to process.
  52600. * @returns {Array} Returns the new array of grouped elements.
  52601. * @example
  52602. *
  52603. * _.zip(['a', 'b'], [1, 2], [true, false]);
  52604. * // => [['a', 1, true], ['b', 2, false]]
  52605. */
  52606. var zip = baseRest(unzip);
  52607. /**
  52608. * This method is like `_.fromPairs` except that it accepts two arrays,
  52609. * one of property identifiers and one of corresponding values.
  52610. *
  52611. * @static
  52612. * @memberOf _
  52613. * @since 0.4.0
  52614. * @category Array
  52615. * @param {Array} [props=[]] The property identifiers.
  52616. * @param {Array} [values=[]] The property values.
  52617. * @returns {Object} Returns the new object.
  52618. * @example
  52619. *
  52620. * _.zipObject(['a', 'b'], [1, 2]);
  52621. * // => { 'a': 1, 'b': 2 }
  52622. */
  52623. function zipObject(props, values) {
  52624. return baseZipObject(props || [], values || [], assignValue);
  52625. }
  52626. /**
  52627. * This method is like `_.zipObject` except that it supports property paths.
  52628. *
  52629. * @static
  52630. * @memberOf _
  52631. * @since 4.1.0
  52632. * @category Array
  52633. * @param {Array} [props=[]] The property identifiers.
  52634. * @param {Array} [values=[]] The property values.
  52635. * @returns {Object} Returns the new object.
  52636. * @example
  52637. *
  52638. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  52639. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  52640. */
  52641. function zipObjectDeep(props, values) {
  52642. return baseZipObject(props || [], values || [], baseSet);
  52643. }
  52644. /**
  52645. * This method is like `_.zip` except that it accepts `iteratee` to specify
  52646. * how grouped values should be combined. The iteratee is invoked with the
  52647. * elements of each group: (...group).
  52648. *
  52649. * @static
  52650. * @memberOf _
  52651. * @since 3.8.0
  52652. * @category Array
  52653. * @param {...Array} [arrays] The arrays to process.
  52654. * @param {Function} [iteratee=_.identity] The function to combine
  52655. * grouped values.
  52656. * @returns {Array} Returns the new array of grouped elements.
  52657. * @example
  52658. *
  52659. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  52660. * return a + b + c;
  52661. * });
  52662. * // => [111, 222]
  52663. */
  52664. var zipWith = baseRest(function(arrays) {
  52665. var length = arrays.length,
  52666. iteratee = length > 1 ? arrays[length - 1] : undefined;
  52667. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  52668. return unzipWith(arrays, iteratee);
  52669. });
  52670. /*------------------------------------------------------------------------*/
  52671. /**
  52672. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  52673. * chain sequences enabled. The result of such sequences must be unwrapped
  52674. * with `_#value`.
  52675. *
  52676. * @static
  52677. * @memberOf _
  52678. * @since 1.3.0
  52679. * @category Seq
  52680. * @param {*} value The value to wrap.
  52681. * @returns {Object} Returns the new `lodash` wrapper instance.
  52682. * @example
  52683. *
  52684. * var users = [
  52685. * { 'user': 'barney', 'age': 36 },
  52686. * { 'user': 'fred', 'age': 40 },
  52687. * { 'user': 'pebbles', 'age': 1 }
  52688. * ];
  52689. *
  52690. * var youngest = _
  52691. * .chain(users)
  52692. * .sortBy('age')
  52693. * .map(function(o) {
  52694. * return o.user + ' is ' + o.age;
  52695. * })
  52696. * .head()
  52697. * .value();
  52698. * // => 'pebbles is 1'
  52699. */
  52700. function chain(value) {
  52701. var result = lodash(value);
  52702. result.__chain__ = true;
  52703. return result;
  52704. }
  52705. /**
  52706. * This method invokes `interceptor` and returns `value`. The interceptor
  52707. * is invoked with one argument; (value). The purpose of this method is to
  52708. * "tap into" a method chain sequence in order to modify intermediate results.
  52709. *
  52710. * @static
  52711. * @memberOf _
  52712. * @since 0.1.0
  52713. * @category Seq
  52714. * @param {*} value The value to provide to `interceptor`.
  52715. * @param {Function} interceptor The function to invoke.
  52716. * @returns {*} Returns `value`.
  52717. * @example
  52718. *
  52719. * _([1, 2, 3])
  52720. * .tap(function(array) {
  52721. * // Mutate input array.
  52722. * array.pop();
  52723. * })
  52724. * .reverse()
  52725. * .value();
  52726. * // => [2, 1]
  52727. */
  52728. function tap(value, interceptor) {
  52729. interceptor(value);
  52730. return value;
  52731. }
  52732. /**
  52733. * This method is like `_.tap` except that it returns the result of `interceptor`.
  52734. * The purpose of this method is to "pass thru" values replacing intermediate
  52735. * results in a method chain sequence.
  52736. *
  52737. * @static
  52738. * @memberOf _
  52739. * @since 3.0.0
  52740. * @category Seq
  52741. * @param {*} value The value to provide to `interceptor`.
  52742. * @param {Function} interceptor The function to invoke.
  52743. * @returns {*} Returns the result of `interceptor`.
  52744. * @example
  52745. *
  52746. * _(' abc ')
  52747. * .chain()
  52748. * .trim()
  52749. * .thru(function(value) {
  52750. * return [value];
  52751. * })
  52752. * .value();
  52753. * // => ['abc']
  52754. */
  52755. function thru(value, interceptor) {
  52756. return interceptor(value);
  52757. }
  52758. /**
  52759. * This method is the wrapper version of `_.at`.
  52760. *
  52761. * @name at
  52762. * @memberOf _
  52763. * @since 1.0.0
  52764. * @category Seq
  52765. * @param {...(string|string[])} [paths] The property paths to pick.
  52766. * @returns {Object} Returns the new `lodash` wrapper instance.
  52767. * @example
  52768. *
  52769. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  52770. *
  52771. * _(object).at(['a[0].b.c', 'a[1]']).value();
  52772. * // => [3, 4]
  52773. */
  52774. var wrapperAt = flatRest(function(paths) {
  52775. var length = paths.length,
  52776. start = length ? paths[0] : 0,
  52777. value = this.__wrapped__,
  52778. interceptor = function(object) { return baseAt(object, paths); };
  52779. if (length > 1 || this.__actions__.length ||
  52780. !(value instanceof LazyWrapper) || !isIndex(start)) {
  52781. return this.thru(interceptor);
  52782. }
  52783. value = value.slice(start, +start + (length ? 1 : 0));
  52784. value.__actions__.push({
  52785. 'func': thru,
  52786. 'args': [interceptor],
  52787. 'thisArg': undefined
  52788. });
  52789. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  52790. if (length && !array.length) {
  52791. array.push(undefined);
  52792. }
  52793. return array;
  52794. });
  52795. });
  52796. /**
  52797. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  52798. *
  52799. * @name chain
  52800. * @memberOf _
  52801. * @since 0.1.0
  52802. * @category Seq
  52803. * @returns {Object} Returns the new `lodash` wrapper instance.
  52804. * @example
  52805. *
  52806. * var users = [
  52807. * { 'user': 'barney', 'age': 36 },
  52808. * { 'user': 'fred', 'age': 40 }
  52809. * ];
  52810. *
  52811. * // A sequence without explicit chaining.
  52812. * _(users).head();
  52813. * // => { 'user': 'barney', 'age': 36 }
  52814. *
  52815. * // A sequence with explicit chaining.
  52816. * _(users)
  52817. * .chain()
  52818. * .head()
  52819. * .pick('user')
  52820. * .value();
  52821. * // => { 'user': 'barney' }
  52822. */
  52823. function wrapperChain() {
  52824. return chain(this);
  52825. }
  52826. /**
  52827. * Executes the chain sequence and returns the wrapped result.
  52828. *
  52829. * @name commit
  52830. * @memberOf _
  52831. * @since 3.2.0
  52832. * @category Seq
  52833. * @returns {Object} Returns the new `lodash` wrapper instance.
  52834. * @example
  52835. *
  52836. * var array = [1, 2];
  52837. * var wrapped = _(array).push(3);
  52838. *
  52839. * console.log(array);
  52840. * // => [1, 2]
  52841. *
  52842. * wrapped = wrapped.commit();
  52843. * console.log(array);
  52844. * // => [1, 2, 3]
  52845. *
  52846. * wrapped.last();
  52847. * // => 3
  52848. *
  52849. * console.log(array);
  52850. * // => [1, 2, 3]
  52851. */
  52852. function wrapperCommit() {
  52853. return new LodashWrapper(this.value(), this.__chain__);
  52854. }
  52855. /**
  52856. * Gets the next value on a wrapped object following the
  52857. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  52858. *
  52859. * @name next
  52860. * @memberOf _
  52861. * @since 4.0.0
  52862. * @category Seq
  52863. * @returns {Object} Returns the next iterator value.
  52864. * @example
  52865. *
  52866. * var wrapped = _([1, 2]);
  52867. *
  52868. * wrapped.next();
  52869. * // => { 'done': false, 'value': 1 }
  52870. *
  52871. * wrapped.next();
  52872. * // => { 'done': false, 'value': 2 }
  52873. *
  52874. * wrapped.next();
  52875. * // => { 'done': true, 'value': undefined }
  52876. */
  52877. function wrapperNext() {
  52878. if (this.__values__ === undefined) {
  52879. this.__values__ = toArray(this.value());
  52880. }
  52881. var done = this.__index__ >= this.__values__.length,
  52882. value = done ? undefined : this.__values__[this.__index__++];
  52883. return { 'done': done, 'value': value };
  52884. }
  52885. /**
  52886. * Enables the wrapper to be iterable.
  52887. *
  52888. * @name Symbol.iterator
  52889. * @memberOf _
  52890. * @since 4.0.0
  52891. * @category Seq
  52892. * @returns {Object} Returns the wrapper object.
  52893. * @example
  52894. *
  52895. * var wrapped = _([1, 2]);
  52896. *
  52897. * wrapped[Symbol.iterator]() === wrapped;
  52898. * // => true
  52899. *
  52900. * Array.from(wrapped);
  52901. * // => [1, 2]
  52902. */
  52903. function wrapperToIterator() {
  52904. return this;
  52905. }
  52906. /**
  52907. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  52908. *
  52909. * @name plant
  52910. * @memberOf _
  52911. * @since 3.2.0
  52912. * @category Seq
  52913. * @param {*} value The value to plant.
  52914. * @returns {Object} Returns the new `lodash` wrapper instance.
  52915. * @example
  52916. *
  52917. * function square(n) {
  52918. * return n * n;
  52919. * }
  52920. *
  52921. * var wrapped = _([1, 2]).map(square);
  52922. * var other = wrapped.plant([3, 4]);
  52923. *
  52924. * other.value();
  52925. * // => [9, 16]
  52926. *
  52927. * wrapped.value();
  52928. * // => [1, 4]
  52929. */
  52930. function wrapperPlant(value) {
  52931. var result,
  52932. parent = this;
  52933. while (parent instanceof baseLodash) {
  52934. var clone = wrapperClone(parent);
  52935. clone.__index__ = 0;
  52936. clone.__values__ = undefined;
  52937. if (result) {
  52938. previous.__wrapped__ = clone;
  52939. } else {
  52940. result = clone;
  52941. }
  52942. var previous = clone;
  52943. parent = parent.__wrapped__;
  52944. }
  52945. previous.__wrapped__ = value;
  52946. return result;
  52947. }
  52948. /**
  52949. * This method is the wrapper version of `_.reverse`.
  52950. *
  52951. * **Note:** This method mutates the wrapped array.
  52952. *
  52953. * @name reverse
  52954. * @memberOf _
  52955. * @since 0.1.0
  52956. * @category Seq
  52957. * @returns {Object} Returns the new `lodash` wrapper instance.
  52958. * @example
  52959. *
  52960. * var array = [1, 2, 3];
  52961. *
  52962. * _(array).reverse().value()
  52963. * // => [3, 2, 1]
  52964. *
  52965. * console.log(array);
  52966. * // => [3, 2, 1]
  52967. */
  52968. function wrapperReverse() {
  52969. var value = this.__wrapped__;
  52970. if (value instanceof LazyWrapper) {
  52971. var wrapped = value;
  52972. if (this.__actions__.length) {
  52973. wrapped = new LazyWrapper(this);
  52974. }
  52975. wrapped = wrapped.reverse();
  52976. wrapped.__actions__.push({
  52977. 'func': thru,
  52978. 'args': [reverse],
  52979. 'thisArg': undefined
  52980. });
  52981. return new LodashWrapper(wrapped, this.__chain__);
  52982. }
  52983. return this.thru(reverse);
  52984. }
  52985. /**
  52986. * Executes the chain sequence to resolve the unwrapped value.
  52987. *
  52988. * @name value
  52989. * @memberOf _
  52990. * @since 0.1.0
  52991. * @alias toJSON, valueOf
  52992. * @category Seq
  52993. * @returns {*} Returns the resolved unwrapped value.
  52994. * @example
  52995. *
  52996. * _([1, 2, 3]).value();
  52997. * // => [1, 2, 3]
  52998. */
  52999. function wrapperValue() {
  53000. return baseWrapperValue(this.__wrapped__, this.__actions__);
  53001. }
  53002. /*------------------------------------------------------------------------*/
  53003. /**
  53004. * Creates an object composed of keys generated from the results of running
  53005. * each element of `collection` thru `iteratee`. The corresponding value of
  53006. * each key is the number of times the key was returned by `iteratee`. The
  53007. * iteratee is invoked with one argument: (value).
  53008. *
  53009. * @static
  53010. * @memberOf _
  53011. * @since 0.5.0
  53012. * @category Collection
  53013. * @param {Array|Object} collection The collection to iterate over.
  53014. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  53015. * @returns {Object} Returns the composed aggregate object.
  53016. * @example
  53017. *
  53018. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  53019. * // => { '4': 1, '6': 2 }
  53020. *
  53021. * // The `_.property` iteratee shorthand.
  53022. * _.countBy(['one', 'two', 'three'], 'length');
  53023. * // => { '3': 2, '5': 1 }
  53024. */
  53025. var countBy = createAggregator(function(result, value, key) {
  53026. if (hasOwnProperty.call(result, key)) {
  53027. ++result[key];
  53028. } else {
  53029. baseAssignValue(result, key, 1);
  53030. }
  53031. });
  53032. /**
  53033. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  53034. * Iteration is stopped once `predicate` returns falsey. The predicate is
  53035. * invoked with three arguments: (value, index|key, collection).
  53036. *
  53037. * **Note:** This method returns `true` for
  53038. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  53039. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  53040. * elements of empty collections.
  53041. *
  53042. * @static
  53043. * @memberOf _
  53044. * @since 0.1.0
  53045. * @category Collection
  53046. * @param {Array|Object} collection The collection to iterate over.
  53047. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53048. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  53049. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  53050. * else `false`.
  53051. * @example
  53052. *
  53053. * _.every([true, 1, null, 'yes'], Boolean);
  53054. * // => false
  53055. *
  53056. * var users = [
  53057. * { 'user': 'barney', 'age': 36, 'active': false },
  53058. * { 'user': 'fred', 'age': 40, 'active': false }
  53059. * ];
  53060. *
  53061. * // The `_.matches` iteratee shorthand.
  53062. * _.every(users, { 'user': 'barney', 'active': false });
  53063. * // => false
  53064. *
  53065. * // The `_.matchesProperty` iteratee shorthand.
  53066. * _.every(users, ['active', false]);
  53067. * // => true
  53068. *
  53069. * // The `_.property` iteratee shorthand.
  53070. * _.every(users, 'active');
  53071. * // => false
  53072. */
  53073. function every(collection, predicate, guard) {
  53074. var func = isArray(collection) ? arrayEvery : baseEvery;
  53075. if (guard && isIterateeCall(collection, predicate, guard)) {
  53076. predicate = undefined;
  53077. }
  53078. return func(collection, getIteratee(predicate, 3));
  53079. }
  53080. /**
  53081. * Iterates over elements of `collection`, returning an array of all elements
  53082. * `predicate` returns truthy for. The predicate is invoked with three
  53083. * arguments: (value, index|key, collection).
  53084. *
  53085. * **Note:** Unlike `_.remove`, this method returns a new array.
  53086. *
  53087. * @static
  53088. * @memberOf _
  53089. * @since 0.1.0
  53090. * @category Collection
  53091. * @param {Array|Object} collection The collection to iterate over.
  53092. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53093. * @returns {Array} Returns the new filtered array.
  53094. * @see _.reject
  53095. * @example
  53096. *
  53097. * var users = [
  53098. * { 'user': 'barney', 'age': 36, 'active': true },
  53099. * { 'user': 'fred', 'age': 40, 'active': false }
  53100. * ];
  53101. *
  53102. * _.filter(users, function(o) { return !o.active; });
  53103. * // => objects for ['fred']
  53104. *
  53105. * // The `_.matches` iteratee shorthand.
  53106. * _.filter(users, { 'age': 36, 'active': true });
  53107. * // => objects for ['barney']
  53108. *
  53109. * // The `_.matchesProperty` iteratee shorthand.
  53110. * _.filter(users, ['active', false]);
  53111. * // => objects for ['fred']
  53112. *
  53113. * // The `_.property` iteratee shorthand.
  53114. * _.filter(users, 'active');
  53115. * // => objects for ['barney']
  53116. *
  53117. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  53118. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  53119. * // => objects for ['fred', 'barney']
  53120. */
  53121. function filter(collection, predicate) {
  53122. var func = isArray(collection) ? arrayFilter : baseFilter;
  53123. return func(collection, getIteratee(predicate, 3));
  53124. }
  53125. /**
  53126. * Iterates over elements of `collection`, returning the first element
  53127. * `predicate` returns truthy for. The predicate is invoked with three
  53128. * arguments: (value, index|key, collection).
  53129. *
  53130. * @static
  53131. * @memberOf _
  53132. * @since 0.1.0
  53133. * @category Collection
  53134. * @param {Array|Object} collection The collection to inspect.
  53135. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53136. * @param {number} [fromIndex=0] The index to search from.
  53137. * @returns {*} Returns the matched element, else `undefined`.
  53138. * @example
  53139. *
  53140. * var users = [
  53141. * { 'user': 'barney', 'age': 36, 'active': true },
  53142. * { 'user': 'fred', 'age': 40, 'active': false },
  53143. * { 'user': 'pebbles', 'age': 1, 'active': true }
  53144. * ];
  53145. *
  53146. * _.find(users, function(o) { return o.age < 40; });
  53147. * // => object for 'barney'
  53148. *
  53149. * // The `_.matches` iteratee shorthand.
  53150. * _.find(users, { 'age': 1, 'active': true });
  53151. * // => object for 'pebbles'
  53152. *
  53153. * // The `_.matchesProperty` iteratee shorthand.
  53154. * _.find(users, ['active', false]);
  53155. * // => object for 'fred'
  53156. *
  53157. * // The `_.property` iteratee shorthand.
  53158. * _.find(users, 'active');
  53159. * // => object for 'barney'
  53160. */
  53161. var find = createFind(findIndex);
  53162. /**
  53163. * This method is like `_.find` except that it iterates over elements of
  53164. * `collection` from right to left.
  53165. *
  53166. * @static
  53167. * @memberOf _
  53168. * @since 2.0.0
  53169. * @category Collection
  53170. * @param {Array|Object} collection The collection to inspect.
  53171. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53172. * @param {number} [fromIndex=collection.length-1] The index to search from.
  53173. * @returns {*} Returns the matched element, else `undefined`.
  53174. * @example
  53175. *
  53176. * _.findLast([1, 2, 3, 4], function(n) {
  53177. * return n % 2 == 1;
  53178. * });
  53179. * // => 3
  53180. */
  53181. var findLast = createFind(findLastIndex);
  53182. /**
  53183. * Creates a flattened array of values by running each element in `collection`
  53184. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  53185. * with three arguments: (value, index|key, collection).
  53186. *
  53187. * @static
  53188. * @memberOf _
  53189. * @since 4.0.0
  53190. * @category Collection
  53191. * @param {Array|Object} collection The collection to iterate over.
  53192. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53193. * @returns {Array} Returns the new flattened array.
  53194. * @example
  53195. *
  53196. * function duplicate(n) {
  53197. * return [n, n];
  53198. * }
  53199. *
  53200. * _.flatMap([1, 2], duplicate);
  53201. * // => [1, 1, 2, 2]
  53202. */
  53203. function flatMap(collection, iteratee) {
  53204. return baseFlatten(map(collection, iteratee), 1);
  53205. }
  53206. /**
  53207. * This method is like `_.flatMap` except that it recursively flattens the
  53208. * mapped results.
  53209. *
  53210. * @static
  53211. * @memberOf _
  53212. * @since 4.7.0
  53213. * @category Collection
  53214. * @param {Array|Object} collection The collection to iterate over.
  53215. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53216. * @returns {Array} Returns the new flattened array.
  53217. * @example
  53218. *
  53219. * function duplicate(n) {
  53220. * return [[[n, n]]];
  53221. * }
  53222. *
  53223. * _.flatMapDeep([1, 2], duplicate);
  53224. * // => [1, 1, 2, 2]
  53225. */
  53226. function flatMapDeep(collection, iteratee) {
  53227. return baseFlatten(map(collection, iteratee), INFINITY);
  53228. }
  53229. /**
  53230. * This method is like `_.flatMap` except that it recursively flattens the
  53231. * mapped results up to `depth` times.
  53232. *
  53233. * @static
  53234. * @memberOf _
  53235. * @since 4.7.0
  53236. * @category Collection
  53237. * @param {Array|Object} collection The collection to iterate over.
  53238. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53239. * @param {number} [depth=1] The maximum recursion depth.
  53240. * @returns {Array} Returns the new flattened array.
  53241. * @example
  53242. *
  53243. * function duplicate(n) {
  53244. * return [[[n, n]]];
  53245. * }
  53246. *
  53247. * _.flatMapDepth([1, 2], duplicate, 2);
  53248. * // => [[1, 1], [2, 2]]
  53249. */
  53250. function flatMapDepth(collection, iteratee, depth) {
  53251. depth = depth === undefined ? 1 : toInteger(depth);
  53252. return baseFlatten(map(collection, iteratee), depth);
  53253. }
  53254. /**
  53255. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  53256. * The iteratee is invoked with three arguments: (value, index|key, collection).
  53257. * Iteratee functions may exit iteration early by explicitly returning `false`.
  53258. *
  53259. * **Note:** As with other "Collections" methods, objects with a "length"
  53260. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  53261. * or `_.forOwn` for object iteration.
  53262. *
  53263. * @static
  53264. * @memberOf _
  53265. * @since 0.1.0
  53266. * @alias each
  53267. * @category Collection
  53268. * @param {Array|Object} collection The collection to iterate over.
  53269. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53270. * @returns {Array|Object} Returns `collection`.
  53271. * @see _.forEachRight
  53272. * @example
  53273. *
  53274. * _.forEach([1, 2], function(value) {
  53275. * console.log(value);
  53276. * });
  53277. * // => Logs `1` then `2`.
  53278. *
  53279. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  53280. * console.log(key);
  53281. * });
  53282. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  53283. */
  53284. function forEach(collection, iteratee) {
  53285. var func = isArray(collection) ? arrayEach : baseEach;
  53286. return func(collection, getIteratee(iteratee, 3));
  53287. }
  53288. /**
  53289. * This method is like `_.forEach` except that it iterates over elements of
  53290. * `collection` from right to left.
  53291. *
  53292. * @static
  53293. * @memberOf _
  53294. * @since 2.0.0
  53295. * @alias eachRight
  53296. * @category Collection
  53297. * @param {Array|Object} collection The collection to iterate over.
  53298. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53299. * @returns {Array|Object} Returns `collection`.
  53300. * @see _.forEach
  53301. * @example
  53302. *
  53303. * _.forEachRight([1, 2], function(value) {
  53304. * console.log(value);
  53305. * });
  53306. * // => Logs `2` then `1`.
  53307. */
  53308. function forEachRight(collection, iteratee) {
  53309. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  53310. return func(collection, getIteratee(iteratee, 3));
  53311. }
  53312. /**
  53313. * Creates an object composed of keys generated from the results of running
  53314. * each element of `collection` thru `iteratee`. The order of grouped values
  53315. * is determined by the order they occur in `collection`. The corresponding
  53316. * value of each key is an array of elements responsible for generating the
  53317. * key. The iteratee is invoked with one argument: (value).
  53318. *
  53319. * @static
  53320. * @memberOf _
  53321. * @since 0.1.0
  53322. * @category Collection
  53323. * @param {Array|Object} collection The collection to iterate over.
  53324. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  53325. * @returns {Object} Returns the composed aggregate object.
  53326. * @example
  53327. *
  53328. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  53329. * // => { '4': [4.2], '6': [6.1, 6.3] }
  53330. *
  53331. * // The `_.property` iteratee shorthand.
  53332. * _.groupBy(['one', 'two', 'three'], 'length');
  53333. * // => { '3': ['one', 'two'], '5': ['three'] }
  53334. */
  53335. var groupBy = createAggregator(function(result, value, key) {
  53336. if (hasOwnProperty.call(result, key)) {
  53337. result[key].push(value);
  53338. } else {
  53339. baseAssignValue(result, key, [value]);
  53340. }
  53341. });
  53342. /**
  53343. * Checks if `value` is in `collection`. If `collection` is a string, it's
  53344. * checked for a substring of `value`, otherwise
  53345. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  53346. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  53347. * the offset from the end of `collection`.
  53348. *
  53349. * @static
  53350. * @memberOf _
  53351. * @since 0.1.0
  53352. * @category Collection
  53353. * @param {Array|Object|string} collection The collection to inspect.
  53354. * @param {*} value The value to search for.
  53355. * @param {number} [fromIndex=0] The index to search from.
  53356. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  53357. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  53358. * @example
  53359. *
  53360. * _.includes([1, 2, 3], 1);
  53361. * // => true
  53362. *
  53363. * _.includes([1, 2, 3], 1, 2);
  53364. * // => false
  53365. *
  53366. * _.includes({ 'a': 1, 'b': 2 }, 1);
  53367. * // => true
  53368. *
  53369. * _.includes('abcd', 'bc');
  53370. * // => true
  53371. */
  53372. function includes(collection, value, fromIndex, guard) {
  53373. collection = isArrayLike(collection) ? collection : values(collection);
  53374. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  53375. var length = collection.length;
  53376. if (fromIndex < 0) {
  53377. fromIndex = nativeMax(length + fromIndex, 0);
  53378. }
  53379. return isString(collection)
  53380. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  53381. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  53382. }
  53383. /**
  53384. * Invokes the method at `path` of each element in `collection`, returning
  53385. * an array of the results of each invoked method. Any additional arguments
  53386. * are provided to each invoked method. If `path` is a function, it's invoked
  53387. * for, and `this` bound to, each element in `collection`.
  53388. *
  53389. * @static
  53390. * @memberOf _
  53391. * @since 4.0.0
  53392. * @category Collection
  53393. * @param {Array|Object} collection The collection to iterate over.
  53394. * @param {Array|Function|string} path The path of the method to invoke or
  53395. * the function invoked per iteration.
  53396. * @param {...*} [args] The arguments to invoke each method with.
  53397. * @returns {Array} Returns the array of results.
  53398. * @example
  53399. *
  53400. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  53401. * // => [[1, 5, 7], [1, 2, 3]]
  53402. *
  53403. * _.invokeMap([123, 456], String.prototype.split, '');
  53404. * // => [['1', '2', '3'], ['4', '5', '6']]
  53405. */
  53406. var invokeMap = baseRest(function(collection, path, args) {
  53407. var index = -1,
  53408. isFunc = typeof path == 'function',
  53409. result = isArrayLike(collection) ? Array(collection.length) : [];
  53410. baseEach(collection, function(value) {
  53411. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  53412. });
  53413. return result;
  53414. });
  53415. /**
  53416. * Creates an object composed of keys generated from the results of running
  53417. * each element of `collection` thru `iteratee`. The corresponding value of
  53418. * each key is the last element responsible for generating the key. The
  53419. * iteratee is invoked with one argument: (value).
  53420. *
  53421. * @static
  53422. * @memberOf _
  53423. * @since 4.0.0
  53424. * @category Collection
  53425. * @param {Array|Object} collection The collection to iterate over.
  53426. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  53427. * @returns {Object} Returns the composed aggregate object.
  53428. * @example
  53429. *
  53430. * var array = [
  53431. * { 'dir': 'left', 'code': 97 },
  53432. * { 'dir': 'right', 'code': 100 }
  53433. * ];
  53434. *
  53435. * _.keyBy(array, function(o) {
  53436. * return String.fromCharCode(o.code);
  53437. * });
  53438. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  53439. *
  53440. * _.keyBy(array, 'dir');
  53441. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  53442. */
  53443. var keyBy = createAggregator(function(result, value, key) {
  53444. baseAssignValue(result, key, value);
  53445. });
  53446. /**
  53447. * Creates an array of values by running each element in `collection` thru
  53448. * `iteratee`. The iteratee is invoked with three arguments:
  53449. * (value, index|key, collection).
  53450. *
  53451. * Many lodash methods are guarded to work as iteratees for methods like
  53452. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  53453. *
  53454. * The guarded methods are:
  53455. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  53456. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  53457. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  53458. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  53459. *
  53460. * @static
  53461. * @memberOf _
  53462. * @since 0.1.0
  53463. * @category Collection
  53464. * @param {Array|Object} collection The collection to iterate over.
  53465. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53466. * @returns {Array} Returns the new mapped array.
  53467. * @example
  53468. *
  53469. * function square(n) {
  53470. * return n * n;
  53471. * }
  53472. *
  53473. * _.map([4, 8], square);
  53474. * // => [16, 64]
  53475. *
  53476. * _.map({ 'a': 4, 'b': 8 }, square);
  53477. * // => [16, 64] (iteration order is not guaranteed)
  53478. *
  53479. * var users = [
  53480. * { 'user': 'barney' },
  53481. * { 'user': 'fred' }
  53482. * ];
  53483. *
  53484. * // The `_.property` iteratee shorthand.
  53485. * _.map(users, 'user');
  53486. * // => ['barney', 'fred']
  53487. */
  53488. function map(collection, iteratee) {
  53489. var func = isArray(collection) ? arrayMap : baseMap;
  53490. return func(collection, getIteratee(iteratee, 3));
  53491. }
  53492. /**
  53493. * This method is like `_.sortBy` except that it allows specifying the sort
  53494. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  53495. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  53496. * descending or "asc" for ascending sort order of corresponding values.
  53497. *
  53498. * @static
  53499. * @memberOf _
  53500. * @since 4.0.0
  53501. * @category Collection
  53502. * @param {Array|Object} collection The collection to iterate over.
  53503. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  53504. * The iteratees to sort by.
  53505. * @param {string[]} [orders] The sort orders of `iteratees`.
  53506. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  53507. * @returns {Array} Returns the new sorted array.
  53508. * @example
  53509. *
  53510. * var users = [
  53511. * { 'user': 'fred', 'age': 48 },
  53512. * { 'user': 'barney', 'age': 34 },
  53513. * { 'user': 'fred', 'age': 40 },
  53514. * { 'user': 'barney', 'age': 36 }
  53515. * ];
  53516. *
  53517. * // Sort by `user` in ascending order and by `age` in descending order.
  53518. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  53519. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  53520. */
  53521. function orderBy(collection, iteratees, orders, guard) {
  53522. if (collection == null) {
  53523. return [];
  53524. }
  53525. if (!isArray(iteratees)) {
  53526. iteratees = iteratees == null ? [] : [iteratees];
  53527. }
  53528. orders = guard ? undefined : orders;
  53529. if (!isArray(orders)) {
  53530. orders = orders == null ? [] : [orders];
  53531. }
  53532. return baseOrderBy(collection, iteratees, orders);
  53533. }
  53534. /**
  53535. * Creates an array of elements split into two groups, the first of which
  53536. * contains elements `predicate` returns truthy for, the second of which
  53537. * contains elements `predicate` returns falsey for. The predicate is
  53538. * invoked with one argument: (value).
  53539. *
  53540. * @static
  53541. * @memberOf _
  53542. * @since 3.0.0
  53543. * @category Collection
  53544. * @param {Array|Object} collection The collection to iterate over.
  53545. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53546. * @returns {Array} Returns the array of grouped elements.
  53547. * @example
  53548. *
  53549. * var users = [
  53550. * { 'user': 'barney', 'age': 36, 'active': false },
  53551. * { 'user': 'fred', 'age': 40, 'active': true },
  53552. * { 'user': 'pebbles', 'age': 1, 'active': false }
  53553. * ];
  53554. *
  53555. * _.partition(users, function(o) { return o.active; });
  53556. * // => objects for [['fred'], ['barney', 'pebbles']]
  53557. *
  53558. * // The `_.matches` iteratee shorthand.
  53559. * _.partition(users, { 'age': 1, 'active': false });
  53560. * // => objects for [['pebbles'], ['barney', 'fred']]
  53561. *
  53562. * // The `_.matchesProperty` iteratee shorthand.
  53563. * _.partition(users, ['active', false]);
  53564. * // => objects for [['barney', 'pebbles'], ['fred']]
  53565. *
  53566. * // The `_.property` iteratee shorthand.
  53567. * _.partition(users, 'active');
  53568. * // => objects for [['fred'], ['barney', 'pebbles']]
  53569. */
  53570. var partition = createAggregator(function(result, value, key) {
  53571. result[key ? 0 : 1].push(value);
  53572. }, function() { return [[], []]; });
  53573. /**
  53574. * Reduces `collection` to a value which is the accumulated result of running
  53575. * each element in `collection` thru `iteratee`, where each successive
  53576. * invocation is supplied the return value of the previous. If `accumulator`
  53577. * is not given, the first element of `collection` is used as the initial
  53578. * value. The iteratee is invoked with four arguments:
  53579. * (accumulator, value, index|key, collection).
  53580. *
  53581. * Many lodash methods are guarded to work as iteratees for methods like
  53582. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  53583. *
  53584. * The guarded methods are:
  53585. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  53586. * and `sortBy`
  53587. *
  53588. * @static
  53589. * @memberOf _
  53590. * @since 0.1.0
  53591. * @category Collection
  53592. * @param {Array|Object} collection The collection to iterate over.
  53593. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53594. * @param {*} [accumulator] The initial value.
  53595. * @returns {*} Returns the accumulated value.
  53596. * @see _.reduceRight
  53597. * @example
  53598. *
  53599. * _.reduce([1, 2], function(sum, n) {
  53600. * return sum + n;
  53601. * }, 0);
  53602. * // => 3
  53603. *
  53604. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  53605. * (result[value] || (result[value] = [])).push(key);
  53606. * return result;
  53607. * }, {});
  53608. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  53609. */
  53610. function reduce(collection, iteratee, accumulator) {
  53611. var func = isArray(collection) ? arrayReduce : baseReduce,
  53612. initAccum = arguments.length < 3;
  53613. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  53614. }
  53615. /**
  53616. * This method is like `_.reduce` except that it iterates over elements of
  53617. * `collection` from right to left.
  53618. *
  53619. * @static
  53620. * @memberOf _
  53621. * @since 0.1.0
  53622. * @category Collection
  53623. * @param {Array|Object} collection The collection to iterate over.
  53624. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  53625. * @param {*} [accumulator] The initial value.
  53626. * @returns {*} Returns the accumulated value.
  53627. * @see _.reduce
  53628. * @example
  53629. *
  53630. * var array = [[0, 1], [2, 3], [4, 5]];
  53631. *
  53632. * _.reduceRight(array, function(flattened, other) {
  53633. * return flattened.concat(other);
  53634. * }, []);
  53635. * // => [4, 5, 2, 3, 0, 1]
  53636. */
  53637. function reduceRight(collection, iteratee, accumulator) {
  53638. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  53639. initAccum = arguments.length < 3;
  53640. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  53641. }
  53642. /**
  53643. * The opposite of `_.filter`; this method returns the elements of `collection`
  53644. * that `predicate` does **not** return truthy for.
  53645. *
  53646. * @static
  53647. * @memberOf _
  53648. * @since 0.1.0
  53649. * @category Collection
  53650. * @param {Array|Object} collection The collection to iterate over.
  53651. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53652. * @returns {Array} Returns the new filtered array.
  53653. * @see _.filter
  53654. * @example
  53655. *
  53656. * var users = [
  53657. * { 'user': 'barney', 'age': 36, 'active': false },
  53658. * { 'user': 'fred', 'age': 40, 'active': true }
  53659. * ];
  53660. *
  53661. * _.reject(users, function(o) { return !o.active; });
  53662. * // => objects for ['fred']
  53663. *
  53664. * // The `_.matches` iteratee shorthand.
  53665. * _.reject(users, { 'age': 40, 'active': true });
  53666. * // => objects for ['barney']
  53667. *
  53668. * // The `_.matchesProperty` iteratee shorthand.
  53669. * _.reject(users, ['active', false]);
  53670. * // => objects for ['fred']
  53671. *
  53672. * // The `_.property` iteratee shorthand.
  53673. * _.reject(users, 'active');
  53674. * // => objects for ['barney']
  53675. */
  53676. function reject(collection, predicate) {
  53677. var func = isArray(collection) ? arrayFilter : baseFilter;
  53678. return func(collection, negate(getIteratee(predicate, 3)));
  53679. }
  53680. /**
  53681. * Gets a random element from `collection`.
  53682. *
  53683. * @static
  53684. * @memberOf _
  53685. * @since 2.0.0
  53686. * @category Collection
  53687. * @param {Array|Object} collection The collection to sample.
  53688. * @returns {*} Returns the random element.
  53689. * @example
  53690. *
  53691. * _.sample([1, 2, 3, 4]);
  53692. * // => 2
  53693. */
  53694. function sample(collection) {
  53695. var func = isArray(collection) ? arraySample : baseSample;
  53696. return func(collection);
  53697. }
  53698. /**
  53699. * Gets `n` random elements at unique keys from `collection` up to the
  53700. * size of `collection`.
  53701. *
  53702. * @static
  53703. * @memberOf _
  53704. * @since 4.0.0
  53705. * @category Collection
  53706. * @param {Array|Object} collection The collection to sample.
  53707. * @param {number} [n=1] The number of elements to sample.
  53708. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  53709. * @returns {Array} Returns the random elements.
  53710. * @example
  53711. *
  53712. * _.sampleSize([1, 2, 3], 2);
  53713. * // => [3, 1]
  53714. *
  53715. * _.sampleSize([1, 2, 3], 4);
  53716. * // => [2, 3, 1]
  53717. */
  53718. function sampleSize(collection, n, guard) {
  53719. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  53720. n = 1;
  53721. } else {
  53722. n = toInteger(n);
  53723. }
  53724. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  53725. return func(collection, n);
  53726. }
  53727. /**
  53728. * Creates an array of shuffled values, using a version of the
  53729. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  53730. *
  53731. * @static
  53732. * @memberOf _
  53733. * @since 0.1.0
  53734. * @category Collection
  53735. * @param {Array|Object} collection The collection to shuffle.
  53736. * @returns {Array} Returns the new shuffled array.
  53737. * @example
  53738. *
  53739. * _.shuffle([1, 2, 3, 4]);
  53740. * // => [4, 1, 3, 2]
  53741. */
  53742. function shuffle(collection) {
  53743. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  53744. return func(collection);
  53745. }
  53746. /**
  53747. * Gets the size of `collection` by returning its length for array-like
  53748. * values or the number of own enumerable string keyed properties for objects.
  53749. *
  53750. * @static
  53751. * @memberOf _
  53752. * @since 0.1.0
  53753. * @category Collection
  53754. * @param {Array|Object|string} collection The collection to inspect.
  53755. * @returns {number} Returns the collection size.
  53756. * @example
  53757. *
  53758. * _.size([1, 2, 3]);
  53759. * // => 3
  53760. *
  53761. * _.size({ 'a': 1, 'b': 2 });
  53762. * // => 2
  53763. *
  53764. * _.size('pebbles');
  53765. * // => 7
  53766. */
  53767. function size(collection) {
  53768. if (collection == null) {
  53769. return 0;
  53770. }
  53771. if (isArrayLike(collection)) {
  53772. return isString(collection) ? stringSize(collection) : collection.length;
  53773. }
  53774. var tag = getTag(collection);
  53775. if (tag == mapTag || tag == setTag) {
  53776. return collection.size;
  53777. }
  53778. return baseKeys(collection).length;
  53779. }
  53780. /**
  53781. * Checks if `predicate` returns truthy for **any** element of `collection`.
  53782. * Iteration is stopped once `predicate` returns truthy. The predicate is
  53783. * invoked with three arguments: (value, index|key, collection).
  53784. *
  53785. * @static
  53786. * @memberOf _
  53787. * @since 0.1.0
  53788. * @category Collection
  53789. * @param {Array|Object} collection The collection to iterate over.
  53790. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  53791. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  53792. * @returns {boolean} Returns `true` if any element passes the predicate check,
  53793. * else `false`.
  53794. * @example
  53795. *
  53796. * _.some([null, 0, 'yes', false], Boolean);
  53797. * // => true
  53798. *
  53799. * var users = [
  53800. * { 'user': 'barney', 'active': true },
  53801. * { 'user': 'fred', 'active': false }
  53802. * ];
  53803. *
  53804. * // The `_.matches` iteratee shorthand.
  53805. * _.some(users, { 'user': 'barney', 'active': false });
  53806. * // => false
  53807. *
  53808. * // The `_.matchesProperty` iteratee shorthand.
  53809. * _.some(users, ['active', false]);
  53810. * // => true
  53811. *
  53812. * // The `_.property` iteratee shorthand.
  53813. * _.some(users, 'active');
  53814. * // => true
  53815. */
  53816. function some(collection, predicate, guard) {
  53817. var func = isArray(collection) ? arraySome : baseSome;
  53818. if (guard && isIterateeCall(collection, predicate, guard)) {
  53819. predicate = undefined;
  53820. }
  53821. return func(collection, getIteratee(predicate, 3));
  53822. }
  53823. /**
  53824. * Creates an array of elements, sorted in ascending order by the results of
  53825. * running each element in a collection thru each iteratee. This method
  53826. * performs a stable sort, that is, it preserves the original sort order of
  53827. * equal elements. The iteratees are invoked with one argument: (value).
  53828. *
  53829. * @static
  53830. * @memberOf _
  53831. * @since 0.1.0
  53832. * @category Collection
  53833. * @param {Array|Object} collection The collection to iterate over.
  53834. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  53835. * The iteratees to sort by.
  53836. * @returns {Array} Returns the new sorted array.
  53837. * @example
  53838. *
  53839. * var users = [
  53840. * { 'user': 'fred', 'age': 48 },
  53841. * { 'user': 'barney', 'age': 36 },
  53842. * { 'user': 'fred', 'age': 30 },
  53843. * { 'user': 'barney', 'age': 34 }
  53844. * ];
  53845. *
  53846. * _.sortBy(users, [function(o) { return o.user; }]);
  53847. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  53848. *
  53849. * _.sortBy(users, ['user', 'age']);
  53850. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  53851. */
  53852. var sortBy = baseRest(function(collection, iteratees) {
  53853. if (collection == null) {
  53854. return [];
  53855. }
  53856. var length = iteratees.length;
  53857. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  53858. iteratees = [];
  53859. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  53860. iteratees = [iteratees[0]];
  53861. }
  53862. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  53863. });
  53864. /*------------------------------------------------------------------------*/
  53865. /**
  53866. * Gets the timestamp of the number of milliseconds that have elapsed since
  53867. * the Unix epoch (1 January 1970 00:00:00 UTC).
  53868. *
  53869. * @static
  53870. * @memberOf _
  53871. * @since 2.4.0
  53872. * @category Date
  53873. * @returns {number} Returns the timestamp.
  53874. * @example
  53875. *
  53876. * _.defer(function(stamp) {
  53877. * console.log(_.now() - stamp);
  53878. * }, _.now());
  53879. * // => Logs the number of milliseconds it took for the deferred invocation.
  53880. */
  53881. var now = ctxNow || function() {
  53882. return root.Date.now();
  53883. };
  53884. /*------------------------------------------------------------------------*/
  53885. /**
  53886. * The opposite of `_.before`; this method creates a function that invokes
  53887. * `func` once it's called `n` or more times.
  53888. *
  53889. * @static
  53890. * @memberOf _
  53891. * @since 0.1.0
  53892. * @category Function
  53893. * @param {number} n The number of calls before `func` is invoked.
  53894. * @param {Function} func The function to restrict.
  53895. * @returns {Function} Returns the new restricted function.
  53896. * @example
  53897. *
  53898. * var saves = ['profile', 'settings'];
  53899. *
  53900. * var done = _.after(saves.length, function() {
  53901. * console.log('done saving!');
  53902. * });
  53903. *
  53904. * _.forEach(saves, function(type) {
  53905. * asyncSave({ 'type': type, 'complete': done });
  53906. * });
  53907. * // => Logs 'done saving!' after the two async saves have completed.
  53908. */
  53909. function after(n, func) {
  53910. if (typeof func != 'function') {
  53911. throw new TypeError(FUNC_ERROR_TEXT);
  53912. }
  53913. n = toInteger(n);
  53914. return function() {
  53915. if (--n < 1) {
  53916. return func.apply(this, arguments);
  53917. }
  53918. };
  53919. }
  53920. /**
  53921. * Creates a function that invokes `func`, with up to `n` arguments,
  53922. * ignoring any additional arguments.
  53923. *
  53924. * @static
  53925. * @memberOf _
  53926. * @since 3.0.0
  53927. * @category Function
  53928. * @param {Function} func The function to cap arguments for.
  53929. * @param {number} [n=func.length] The arity cap.
  53930. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  53931. * @returns {Function} Returns the new capped function.
  53932. * @example
  53933. *
  53934. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  53935. * // => [6, 8, 10]
  53936. */
  53937. function ary(func, n, guard) {
  53938. n = guard ? undefined : n;
  53939. n = (func && n == null) ? func.length : n;
  53940. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  53941. }
  53942. /**
  53943. * Creates a function that invokes `func`, with the `this` binding and arguments
  53944. * of the created function, while it's called less than `n` times. Subsequent
  53945. * calls to the created function return the result of the last `func` invocation.
  53946. *
  53947. * @static
  53948. * @memberOf _
  53949. * @since 3.0.0
  53950. * @category Function
  53951. * @param {number} n The number of calls at which `func` is no longer invoked.
  53952. * @param {Function} func The function to restrict.
  53953. * @returns {Function} Returns the new restricted function.
  53954. * @example
  53955. *
  53956. * jQuery(element).on('click', _.before(5, addContactToList));
  53957. * // => Allows adding up to 4 contacts to the list.
  53958. */
  53959. function before(n, func) {
  53960. var result;
  53961. if (typeof func != 'function') {
  53962. throw new TypeError(FUNC_ERROR_TEXT);
  53963. }
  53964. n = toInteger(n);
  53965. return function() {
  53966. if (--n > 0) {
  53967. result = func.apply(this, arguments);
  53968. }
  53969. if (n <= 1) {
  53970. func = undefined;
  53971. }
  53972. return result;
  53973. };
  53974. }
  53975. /**
  53976. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  53977. * and `partials` prepended to the arguments it receives.
  53978. *
  53979. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  53980. * may be used as a placeholder for partially applied arguments.
  53981. *
  53982. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  53983. * property of bound functions.
  53984. *
  53985. * @static
  53986. * @memberOf _
  53987. * @since 0.1.0
  53988. * @category Function
  53989. * @param {Function} func The function to bind.
  53990. * @param {*} thisArg The `this` binding of `func`.
  53991. * @param {...*} [partials] The arguments to be partially applied.
  53992. * @returns {Function} Returns the new bound function.
  53993. * @example
  53994. *
  53995. * function greet(greeting, punctuation) {
  53996. * return greeting + ' ' + this.user + punctuation;
  53997. * }
  53998. *
  53999. * var object = { 'user': 'fred' };
  54000. *
  54001. * var bound = _.bind(greet, object, 'hi');
  54002. * bound('!');
  54003. * // => 'hi fred!'
  54004. *
  54005. * // Bound with placeholders.
  54006. * var bound = _.bind(greet, object, _, '!');
  54007. * bound('hi');
  54008. * // => 'hi fred!'
  54009. */
  54010. var bind = baseRest(function(func, thisArg, partials) {
  54011. var bitmask = WRAP_BIND_FLAG;
  54012. if (partials.length) {
  54013. var holders = replaceHolders(partials, getHolder(bind));
  54014. bitmask |= WRAP_PARTIAL_FLAG;
  54015. }
  54016. return createWrap(func, bitmask, thisArg, partials, holders);
  54017. });
  54018. /**
  54019. * Creates a function that invokes the method at `object[key]` with `partials`
  54020. * prepended to the arguments it receives.
  54021. *
  54022. * This method differs from `_.bind` by allowing bound functions to reference
  54023. * methods that may be redefined or don't yet exist. See
  54024. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  54025. * for more details.
  54026. *
  54027. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  54028. * builds, may be used as a placeholder for partially applied arguments.
  54029. *
  54030. * @static
  54031. * @memberOf _
  54032. * @since 0.10.0
  54033. * @category Function
  54034. * @param {Object} object The object to invoke the method on.
  54035. * @param {string} key The key of the method.
  54036. * @param {...*} [partials] The arguments to be partially applied.
  54037. * @returns {Function} Returns the new bound function.
  54038. * @example
  54039. *
  54040. * var object = {
  54041. * 'user': 'fred',
  54042. * 'greet': function(greeting, punctuation) {
  54043. * return greeting + ' ' + this.user + punctuation;
  54044. * }
  54045. * };
  54046. *
  54047. * var bound = _.bindKey(object, 'greet', 'hi');
  54048. * bound('!');
  54049. * // => 'hi fred!'
  54050. *
  54051. * object.greet = function(greeting, punctuation) {
  54052. * return greeting + 'ya ' + this.user + punctuation;
  54053. * };
  54054. *
  54055. * bound('!');
  54056. * // => 'hiya fred!'
  54057. *
  54058. * // Bound with placeholders.
  54059. * var bound = _.bindKey(object, 'greet', _, '!');
  54060. * bound('hi');
  54061. * // => 'hiya fred!'
  54062. */
  54063. var bindKey = baseRest(function(object, key, partials) {
  54064. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  54065. if (partials.length) {
  54066. var holders = replaceHolders(partials, getHolder(bindKey));
  54067. bitmask |= WRAP_PARTIAL_FLAG;
  54068. }
  54069. return createWrap(key, bitmask, object, partials, holders);
  54070. });
  54071. /**
  54072. * Creates a function that accepts arguments of `func` and either invokes
  54073. * `func` returning its result, if at least `arity` number of arguments have
  54074. * been provided, or returns a function that accepts the remaining `func`
  54075. * arguments, and so on. The arity of `func` may be specified if `func.length`
  54076. * is not sufficient.
  54077. *
  54078. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  54079. * may be used as a placeholder for provided arguments.
  54080. *
  54081. * **Note:** This method doesn't set the "length" property of curried functions.
  54082. *
  54083. * @static
  54084. * @memberOf _
  54085. * @since 2.0.0
  54086. * @category Function
  54087. * @param {Function} func The function to curry.
  54088. * @param {number} [arity=func.length] The arity of `func`.
  54089. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  54090. * @returns {Function} Returns the new curried function.
  54091. * @example
  54092. *
  54093. * var abc = function(a, b, c) {
  54094. * return [a, b, c];
  54095. * };
  54096. *
  54097. * var curried = _.curry(abc);
  54098. *
  54099. * curried(1)(2)(3);
  54100. * // => [1, 2, 3]
  54101. *
  54102. * curried(1, 2)(3);
  54103. * // => [1, 2, 3]
  54104. *
  54105. * curried(1, 2, 3);
  54106. * // => [1, 2, 3]
  54107. *
  54108. * // Curried with placeholders.
  54109. * curried(1)(_, 3)(2);
  54110. * // => [1, 2, 3]
  54111. */
  54112. function curry(func, arity, guard) {
  54113. arity = guard ? undefined : arity;
  54114. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  54115. result.placeholder = curry.placeholder;
  54116. return result;
  54117. }
  54118. /**
  54119. * This method is like `_.curry` except that arguments are applied to `func`
  54120. * in the manner of `_.partialRight` instead of `_.partial`.
  54121. *
  54122. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  54123. * builds, may be used as a placeholder for provided arguments.
  54124. *
  54125. * **Note:** This method doesn't set the "length" property of curried functions.
  54126. *
  54127. * @static
  54128. * @memberOf _
  54129. * @since 3.0.0
  54130. * @category Function
  54131. * @param {Function} func The function to curry.
  54132. * @param {number} [arity=func.length] The arity of `func`.
  54133. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  54134. * @returns {Function} Returns the new curried function.
  54135. * @example
  54136. *
  54137. * var abc = function(a, b, c) {
  54138. * return [a, b, c];
  54139. * };
  54140. *
  54141. * var curried = _.curryRight(abc);
  54142. *
  54143. * curried(3)(2)(1);
  54144. * // => [1, 2, 3]
  54145. *
  54146. * curried(2, 3)(1);
  54147. * // => [1, 2, 3]
  54148. *
  54149. * curried(1, 2, 3);
  54150. * // => [1, 2, 3]
  54151. *
  54152. * // Curried with placeholders.
  54153. * curried(3)(1, _)(2);
  54154. * // => [1, 2, 3]
  54155. */
  54156. function curryRight(func, arity, guard) {
  54157. arity = guard ? undefined : arity;
  54158. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  54159. result.placeholder = curryRight.placeholder;
  54160. return result;
  54161. }
  54162. /**
  54163. * Creates a debounced function that delays invoking `func` until after `wait`
  54164. * milliseconds have elapsed since the last time the debounced function was
  54165. * invoked. The debounced function comes with a `cancel` method to cancel
  54166. * delayed `func` invocations and a `flush` method to immediately invoke them.
  54167. * Provide `options` to indicate whether `func` should be invoked on the
  54168. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  54169. * with the last arguments provided to the debounced function. Subsequent
  54170. * calls to the debounced function return the result of the last `func`
  54171. * invocation.
  54172. *
  54173. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  54174. * invoked on the trailing edge of the timeout only if the debounced function
  54175. * is invoked more than once during the `wait` timeout.
  54176. *
  54177. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  54178. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  54179. *
  54180. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  54181. * for details over the differences between `_.debounce` and `_.throttle`.
  54182. *
  54183. * @static
  54184. * @memberOf _
  54185. * @since 0.1.0
  54186. * @category Function
  54187. * @param {Function} func The function to debounce.
  54188. * @param {number} [wait=0] The number of milliseconds to delay.
  54189. * @param {Object} [options={}] The options object.
  54190. * @param {boolean} [options.leading=false]
  54191. * Specify invoking on the leading edge of the timeout.
  54192. * @param {number} [options.maxWait]
  54193. * The maximum time `func` is allowed to be delayed before it's invoked.
  54194. * @param {boolean} [options.trailing=true]
  54195. * Specify invoking on the trailing edge of the timeout.
  54196. * @returns {Function} Returns the new debounced function.
  54197. * @example
  54198. *
  54199. * // Avoid costly calculations while the window size is in flux.
  54200. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  54201. *
  54202. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  54203. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  54204. * 'leading': true,
  54205. * 'trailing': false
  54206. * }));
  54207. *
  54208. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  54209. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  54210. * var source = new EventSource('/stream');
  54211. * jQuery(source).on('message', debounced);
  54212. *
  54213. * // Cancel the trailing debounced invocation.
  54214. * jQuery(window).on('popstate', debounced.cancel);
  54215. */
  54216. function debounce(func, wait, options) {
  54217. var lastArgs,
  54218. lastThis,
  54219. maxWait,
  54220. result,
  54221. timerId,
  54222. lastCallTime,
  54223. lastInvokeTime = 0,
  54224. leading = false,
  54225. maxing = false,
  54226. trailing = true;
  54227. if (typeof func != 'function') {
  54228. throw new TypeError(FUNC_ERROR_TEXT);
  54229. }
  54230. wait = toNumber(wait) || 0;
  54231. if (isObject(options)) {
  54232. leading = !!options.leading;
  54233. maxing = 'maxWait' in options;
  54234. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  54235. trailing = 'trailing' in options ? !!options.trailing : trailing;
  54236. }
  54237. function invokeFunc(time) {
  54238. var args = lastArgs,
  54239. thisArg = lastThis;
  54240. lastArgs = lastThis = undefined;
  54241. lastInvokeTime = time;
  54242. result = func.apply(thisArg, args);
  54243. return result;
  54244. }
  54245. function leadingEdge(time) {
  54246. // Reset any `maxWait` timer.
  54247. lastInvokeTime = time;
  54248. // Start the timer for the trailing edge.
  54249. timerId = setTimeout(timerExpired, wait);
  54250. // Invoke the leading edge.
  54251. return leading ? invokeFunc(time) : result;
  54252. }
  54253. function remainingWait(time) {
  54254. var timeSinceLastCall = time - lastCallTime,
  54255. timeSinceLastInvoke = time - lastInvokeTime,
  54256. timeWaiting = wait - timeSinceLastCall;
  54257. return maxing
  54258. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  54259. : timeWaiting;
  54260. }
  54261. function shouldInvoke(time) {
  54262. var timeSinceLastCall = time - lastCallTime,
  54263. timeSinceLastInvoke = time - lastInvokeTime;
  54264. // Either this is the first call, activity has stopped and we're at the
  54265. // trailing edge, the system time has gone backwards and we're treating
  54266. // it as the trailing edge, or we've hit the `maxWait` limit.
  54267. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  54268. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  54269. }
  54270. function timerExpired() {
  54271. var time = now();
  54272. if (shouldInvoke(time)) {
  54273. return trailingEdge(time);
  54274. }
  54275. // Restart the timer.
  54276. timerId = setTimeout(timerExpired, remainingWait(time));
  54277. }
  54278. function trailingEdge(time) {
  54279. timerId = undefined;
  54280. // Only invoke if we have `lastArgs` which means `func` has been
  54281. // debounced at least once.
  54282. if (trailing && lastArgs) {
  54283. return invokeFunc(time);
  54284. }
  54285. lastArgs = lastThis = undefined;
  54286. return result;
  54287. }
  54288. function cancel() {
  54289. if (timerId !== undefined) {
  54290. clearTimeout(timerId);
  54291. }
  54292. lastInvokeTime = 0;
  54293. lastArgs = lastCallTime = lastThis = timerId = undefined;
  54294. }
  54295. function flush() {
  54296. return timerId === undefined ? result : trailingEdge(now());
  54297. }
  54298. function debounced() {
  54299. var time = now(),
  54300. isInvoking = shouldInvoke(time);
  54301. lastArgs = arguments;
  54302. lastThis = this;
  54303. lastCallTime = time;
  54304. if (isInvoking) {
  54305. if (timerId === undefined) {
  54306. return leadingEdge(lastCallTime);
  54307. }
  54308. if (maxing) {
  54309. // Handle invocations in a tight loop.
  54310. clearTimeout(timerId);
  54311. timerId = setTimeout(timerExpired, wait);
  54312. return invokeFunc(lastCallTime);
  54313. }
  54314. }
  54315. if (timerId === undefined) {
  54316. timerId = setTimeout(timerExpired, wait);
  54317. }
  54318. return result;
  54319. }
  54320. debounced.cancel = cancel;
  54321. debounced.flush = flush;
  54322. return debounced;
  54323. }
  54324. /**
  54325. * Defers invoking the `func` until the current call stack has cleared. Any
  54326. * additional arguments are provided to `func` when it's invoked.
  54327. *
  54328. * @static
  54329. * @memberOf _
  54330. * @since 0.1.0
  54331. * @category Function
  54332. * @param {Function} func The function to defer.
  54333. * @param {...*} [args] The arguments to invoke `func` with.
  54334. * @returns {number} Returns the timer id.
  54335. * @example
  54336. *
  54337. * _.defer(function(text) {
  54338. * console.log(text);
  54339. * }, 'deferred');
  54340. * // => Logs 'deferred' after one millisecond.
  54341. */
  54342. var defer = baseRest(function(func, args) {
  54343. return baseDelay(func, 1, args);
  54344. });
  54345. /**
  54346. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  54347. * provided to `func` when it's invoked.
  54348. *
  54349. * @static
  54350. * @memberOf _
  54351. * @since 0.1.0
  54352. * @category Function
  54353. * @param {Function} func The function to delay.
  54354. * @param {number} wait The number of milliseconds to delay invocation.
  54355. * @param {...*} [args] The arguments to invoke `func` with.
  54356. * @returns {number} Returns the timer id.
  54357. * @example
  54358. *
  54359. * _.delay(function(text) {
  54360. * console.log(text);
  54361. * }, 1000, 'later');
  54362. * // => Logs 'later' after one second.
  54363. */
  54364. var delay = baseRest(function(func, wait, args) {
  54365. return baseDelay(func, toNumber(wait) || 0, args);
  54366. });
  54367. /**
  54368. * Creates a function that invokes `func` with arguments reversed.
  54369. *
  54370. * @static
  54371. * @memberOf _
  54372. * @since 4.0.0
  54373. * @category Function
  54374. * @param {Function} func The function to flip arguments for.
  54375. * @returns {Function} Returns the new flipped function.
  54376. * @example
  54377. *
  54378. * var flipped = _.flip(function() {
  54379. * return _.toArray(arguments);
  54380. * });
  54381. *
  54382. * flipped('a', 'b', 'c', 'd');
  54383. * // => ['d', 'c', 'b', 'a']
  54384. */
  54385. function flip(func) {
  54386. return createWrap(func, WRAP_FLIP_FLAG);
  54387. }
  54388. /**
  54389. * Creates a function that memoizes the result of `func`. If `resolver` is
  54390. * provided, it determines the cache key for storing the result based on the
  54391. * arguments provided to the memoized function. By default, the first argument
  54392. * provided to the memoized function is used as the map cache key. The `func`
  54393. * is invoked with the `this` binding of the memoized function.
  54394. *
  54395. * **Note:** The cache is exposed as the `cache` property on the memoized
  54396. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  54397. * constructor with one whose instances implement the
  54398. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  54399. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  54400. *
  54401. * @static
  54402. * @memberOf _
  54403. * @since 0.1.0
  54404. * @category Function
  54405. * @param {Function} func The function to have its output memoized.
  54406. * @param {Function} [resolver] The function to resolve the cache key.
  54407. * @returns {Function} Returns the new memoized function.
  54408. * @example
  54409. *
  54410. * var object = { 'a': 1, 'b': 2 };
  54411. * var other = { 'c': 3, 'd': 4 };
  54412. *
  54413. * var values = _.memoize(_.values);
  54414. * values(object);
  54415. * // => [1, 2]
  54416. *
  54417. * values(other);
  54418. * // => [3, 4]
  54419. *
  54420. * object.a = 2;
  54421. * values(object);
  54422. * // => [1, 2]
  54423. *
  54424. * // Modify the result cache.
  54425. * values.cache.set(object, ['a', 'b']);
  54426. * values(object);
  54427. * // => ['a', 'b']
  54428. *
  54429. * // Replace `_.memoize.Cache`.
  54430. * _.memoize.Cache = WeakMap;
  54431. */
  54432. function memoize(func, resolver) {
  54433. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  54434. throw new TypeError(FUNC_ERROR_TEXT);
  54435. }
  54436. var memoized = function() {
  54437. var args = arguments,
  54438. key = resolver ? resolver.apply(this, args) : args[0],
  54439. cache = memoized.cache;
  54440. if (cache.has(key)) {
  54441. return cache.get(key);
  54442. }
  54443. var result = func.apply(this, args);
  54444. memoized.cache = cache.set(key, result) || cache;
  54445. return result;
  54446. };
  54447. memoized.cache = new (memoize.Cache || MapCache);
  54448. return memoized;
  54449. }
  54450. // Expose `MapCache`.
  54451. memoize.Cache = MapCache;
  54452. /**
  54453. * Creates a function that negates the result of the predicate `func`. The
  54454. * `func` predicate is invoked with the `this` binding and arguments of the
  54455. * created function.
  54456. *
  54457. * @static
  54458. * @memberOf _
  54459. * @since 3.0.0
  54460. * @category Function
  54461. * @param {Function} predicate The predicate to negate.
  54462. * @returns {Function} Returns the new negated function.
  54463. * @example
  54464. *
  54465. * function isEven(n) {
  54466. * return n % 2 == 0;
  54467. * }
  54468. *
  54469. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  54470. * // => [1, 3, 5]
  54471. */
  54472. function negate(predicate) {
  54473. if (typeof predicate != 'function') {
  54474. throw new TypeError(FUNC_ERROR_TEXT);
  54475. }
  54476. return function() {
  54477. var args = arguments;
  54478. switch (args.length) {
  54479. case 0: return !predicate.call(this);
  54480. case 1: return !predicate.call(this, args[0]);
  54481. case 2: return !predicate.call(this, args[0], args[1]);
  54482. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  54483. }
  54484. return !predicate.apply(this, args);
  54485. };
  54486. }
  54487. /**
  54488. * Creates a function that is restricted to invoking `func` once. Repeat calls
  54489. * to the function return the value of the first invocation. The `func` is
  54490. * invoked with the `this` binding and arguments of the created function.
  54491. *
  54492. * @static
  54493. * @memberOf _
  54494. * @since 0.1.0
  54495. * @category Function
  54496. * @param {Function} func The function to restrict.
  54497. * @returns {Function} Returns the new restricted function.
  54498. * @example
  54499. *
  54500. * var initialize = _.once(createApplication);
  54501. * initialize();
  54502. * initialize();
  54503. * // => `createApplication` is invoked once
  54504. */
  54505. function once(func) {
  54506. return before(2, func);
  54507. }
  54508. /**
  54509. * Creates a function that invokes `func` with its arguments transformed.
  54510. *
  54511. * @static
  54512. * @since 4.0.0
  54513. * @memberOf _
  54514. * @category Function
  54515. * @param {Function} func The function to wrap.
  54516. * @param {...(Function|Function[])} [transforms=[_.identity]]
  54517. * The argument transforms.
  54518. * @returns {Function} Returns the new function.
  54519. * @example
  54520. *
  54521. * function doubled(n) {
  54522. * return n * 2;
  54523. * }
  54524. *
  54525. * function square(n) {
  54526. * return n * n;
  54527. * }
  54528. *
  54529. * var func = _.overArgs(function(x, y) {
  54530. * return [x, y];
  54531. * }, [square, doubled]);
  54532. *
  54533. * func(9, 3);
  54534. * // => [81, 6]
  54535. *
  54536. * func(10, 5);
  54537. * // => [100, 10]
  54538. */
  54539. var overArgs = castRest(function(func, transforms) {
  54540. transforms = (transforms.length == 1 && isArray(transforms[0]))
  54541. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  54542. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  54543. var funcsLength = transforms.length;
  54544. return baseRest(function(args) {
  54545. var index = -1,
  54546. length = nativeMin(args.length, funcsLength);
  54547. while (++index < length) {
  54548. args[index] = transforms[index].call(this, args[index]);
  54549. }
  54550. return apply(func, this, args);
  54551. });
  54552. });
  54553. /**
  54554. * Creates a function that invokes `func` with `partials` prepended to the
  54555. * arguments it receives. This method is like `_.bind` except it does **not**
  54556. * alter the `this` binding.
  54557. *
  54558. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  54559. * builds, may be used as a placeholder for partially applied arguments.
  54560. *
  54561. * **Note:** This method doesn't set the "length" property of partially
  54562. * applied functions.
  54563. *
  54564. * @static
  54565. * @memberOf _
  54566. * @since 0.2.0
  54567. * @category Function
  54568. * @param {Function} func The function to partially apply arguments to.
  54569. * @param {...*} [partials] The arguments to be partially applied.
  54570. * @returns {Function} Returns the new partially applied function.
  54571. * @example
  54572. *
  54573. * function greet(greeting, name) {
  54574. * return greeting + ' ' + name;
  54575. * }
  54576. *
  54577. * var sayHelloTo = _.partial(greet, 'hello');
  54578. * sayHelloTo('fred');
  54579. * // => 'hello fred'
  54580. *
  54581. * // Partially applied with placeholders.
  54582. * var greetFred = _.partial(greet, _, 'fred');
  54583. * greetFred('hi');
  54584. * // => 'hi fred'
  54585. */
  54586. var partial = baseRest(function(func, partials) {
  54587. var holders = replaceHolders(partials, getHolder(partial));
  54588. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  54589. });
  54590. /**
  54591. * This method is like `_.partial` except that partially applied arguments
  54592. * are appended to the arguments it receives.
  54593. *
  54594. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  54595. * builds, may be used as a placeholder for partially applied arguments.
  54596. *
  54597. * **Note:** This method doesn't set the "length" property of partially
  54598. * applied functions.
  54599. *
  54600. * @static
  54601. * @memberOf _
  54602. * @since 1.0.0
  54603. * @category Function
  54604. * @param {Function} func The function to partially apply arguments to.
  54605. * @param {...*} [partials] The arguments to be partially applied.
  54606. * @returns {Function} Returns the new partially applied function.
  54607. * @example
  54608. *
  54609. * function greet(greeting, name) {
  54610. * return greeting + ' ' + name;
  54611. * }
  54612. *
  54613. * var greetFred = _.partialRight(greet, 'fred');
  54614. * greetFred('hi');
  54615. * // => 'hi fred'
  54616. *
  54617. * // Partially applied with placeholders.
  54618. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  54619. * sayHelloTo('fred');
  54620. * // => 'hello fred'
  54621. */
  54622. var partialRight = baseRest(function(func, partials) {
  54623. var holders = replaceHolders(partials, getHolder(partialRight));
  54624. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  54625. });
  54626. /**
  54627. * Creates a function that invokes `func` with arguments arranged according
  54628. * to the specified `indexes` where the argument value at the first index is
  54629. * provided as the first argument, the argument value at the second index is
  54630. * provided as the second argument, and so on.
  54631. *
  54632. * @static
  54633. * @memberOf _
  54634. * @since 3.0.0
  54635. * @category Function
  54636. * @param {Function} func The function to rearrange arguments for.
  54637. * @param {...(number|number[])} indexes The arranged argument indexes.
  54638. * @returns {Function} Returns the new function.
  54639. * @example
  54640. *
  54641. * var rearged = _.rearg(function(a, b, c) {
  54642. * return [a, b, c];
  54643. * }, [2, 0, 1]);
  54644. *
  54645. * rearged('b', 'c', 'a')
  54646. * // => ['a', 'b', 'c']
  54647. */
  54648. var rearg = flatRest(function(func, indexes) {
  54649. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  54650. });
  54651. /**
  54652. * Creates a function that invokes `func` with the `this` binding of the
  54653. * created function and arguments from `start` and beyond provided as
  54654. * an array.
  54655. *
  54656. * **Note:** This method is based on the
  54657. * [rest parameter](https://mdn.io/rest_parameters).
  54658. *
  54659. * @static
  54660. * @memberOf _
  54661. * @since 4.0.0
  54662. * @category Function
  54663. * @param {Function} func The function to apply a rest parameter to.
  54664. * @param {number} [start=func.length-1] The start position of the rest parameter.
  54665. * @returns {Function} Returns the new function.
  54666. * @example
  54667. *
  54668. * var say = _.rest(function(what, names) {
  54669. * return what + ' ' + _.initial(names).join(', ') +
  54670. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  54671. * });
  54672. *
  54673. * say('hello', 'fred', 'barney', 'pebbles');
  54674. * // => 'hello fred, barney, & pebbles'
  54675. */
  54676. function rest(func, start) {
  54677. if (typeof func != 'function') {
  54678. throw new TypeError(FUNC_ERROR_TEXT);
  54679. }
  54680. start = start === undefined ? start : toInteger(start);
  54681. return baseRest(func, start);
  54682. }
  54683. /**
  54684. * Creates a function that invokes `func` with the `this` binding of the
  54685. * create function and an array of arguments much like
  54686. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  54687. *
  54688. * **Note:** This method is based on the
  54689. * [spread operator](https://mdn.io/spread_operator).
  54690. *
  54691. * @static
  54692. * @memberOf _
  54693. * @since 3.2.0
  54694. * @category Function
  54695. * @param {Function} func The function to spread arguments over.
  54696. * @param {number} [start=0] The start position of the spread.
  54697. * @returns {Function} Returns the new function.
  54698. * @example
  54699. *
  54700. * var say = _.spread(function(who, what) {
  54701. * return who + ' says ' + what;
  54702. * });
  54703. *
  54704. * say(['fred', 'hello']);
  54705. * // => 'fred says hello'
  54706. *
  54707. * var numbers = Promise.all([
  54708. * Promise.resolve(40),
  54709. * Promise.resolve(36)
  54710. * ]);
  54711. *
  54712. * numbers.then(_.spread(function(x, y) {
  54713. * return x + y;
  54714. * }));
  54715. * // => a Promise of 76
  54716. */
  54717. function spread(func, start) {
  54718. if (typeof func != 'function') {
  54719. throw new TypeError(FUNC_ERROR_TEXT);
  54720. }
  54721. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  54722. return baseRest(function(args) {
  54723. var array = args[start],
  54724. otherArgs = castSlice(args, 0, start);
  54725. if (array) {
  54726. arrayPush(otherArgs, array);
  54727. }
  54728. return apply(func, this, otherArgs);
  54729. });
  54730. }
  54731. /**
  54732. * Creates a throttled function that only invokes `func` at most once per
  54733. * every `wait` milliseconds. The throttled function comes with a `cancel`
  54734. * method to cancel delayed `func` invocations and a `flush` method to
  54735. * immediately invoke them. Provide `options` to indicate whether `func`
  54736. * should be invoked on the leading and/or trailing edge of the `wait`
  54737. * timeout. The `func` is invoked with the last arguments provided to the
  54738. * throttled function. Subsequent calls to the throttled function return the
  54739. * result of the last `func` invocation.
  54740. *
  54741. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  54742. * invoked on the trailing edge of the timeout only if the throttled function
  54743. * is invoked more than once during the `wait` timeout.
  54744. *
  54745. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  54746. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  54747. *
  54748. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  54749. * for details over the differences between `_.throttle` and `_.debounce`.
  54750. *
  54751. * @static
  54752. * @memberOf _
  54753. * @since 0.1.0
  54754. * @category Function
  54755. * @param {Function} func The function to throttle.
  54756. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  54757. * @param {Object} [options={}] The options object.
  54758. * @param {boolean} [options.leading=true]
  54759. * Specify invoking on the leading edge of the timeout.
  54760. * @param {boolean} [options.trailing=true]
  54761. * Specify invoking on the trailing edge of the timeout.
  54762. * @returns {Function} Returns the new throttled function.
  54763. * @example
  54764. *
  54765. * // Avoid excessively updating the position while scrolling.
  54766. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  54767. *
  54768. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  54769. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  54770. * jQuery(element).on('click', throttled);
  54771. *
  54772. * // Cancel the trailing throttled invocation.
  54773. * jQuery(window).on('popstate', throttled.cancel);
  54774. */
  54775. function throttle(func, wait, options) {
  54776. var leading = true,
  54777. trailing = true;
  54778. if (typeof func != 'function') {
  54779. throw new TypeError(FUNC_ERROR_TEXT);
  54780. }
  54781. if (isObject(options)) {
  54782. leading = 'leading' in options ? !!options.leading : leading;
  54783. trailing = 'trailing' in options ? !!options.trailing : trailing;
  54784. }
  54785. return debounce(func, wait, {
  54786. 'leading': leading,
  54787. 'maxWait': wait,
  54788. 'trailing': trailing
  54789. });
  54790. }
  54791. /**
  54792. * Creates a function that accepts up to one argument, ignoring any
  54793. * additional arguments.
  54794. *
  54795. * @static
  54796. * @memberOf _
  54797. * @since 4.0.0
  54798. * @category Function
  54799. * @param {Function} func The function to cap arguments for.
  54800. * @returns {Function} Returns the new capped function.
  54801. * @example
  54802. *
  54803. * _.map(['6', '8', '10'], _.unary(parseInt));
  54804. * // => [6, 8, 10]
  54805. */
  54806. function unary(func) {
  54807. return ary(func, 1);
  54808. }
  54809. /**
  54810. * Creates a function that provides `value` to `wrapper` as its first
  54811. * argument. Any additional arguments provided to the function are appended
  54812. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  54813. * binding of the created function.
  54814. *
  54815. * @static
  54816. * @memberOf _
  54817. * @since 0.1.0
  54818. * @category Function
  54819. * @param {*} value The value to wrap.
  54820. * @param {Function} [wrapper=identity] The wrapper function.
  54821. * @returns {Function} Returns the new function.
  54822. * @example
  54823. *
  54824. * var p = _.wrap(_.escape, function(func, text) {
  54825. * return '<p>' + func(text) + '</p>';
  54826. * });
  54827. *
  54828. * p('fred, barney, & pebbles');
  54829. * // => '<p>fred, barney, &amp; pebbles</p>'
  54830. */
  54831. function wrap(value, wrapper) {
  54832. return partial(castFunction(wrapper), value);
  54833. }
  54834. /*------------------------------------------------------------------------*/
  54835. /**
  54836. * Casts `value` as an array if it's not one.
  54837. *
  54838. * @static
  54839. * @memberOf _
  54840. * @since 4.4.0
  54841. * @category Lang
  54842. * @param {*} value The value to inspect.
  54843. * @returns {Array} Returns the cast array.
  54844. * @example
  54845. *
  54846. * _.castArray(1);
  54847. * // => [1]
  54848. *
  54849. * _.castArray({ 'a': 1 });
  54850. * // => [{ 'a': 1 }]
  54851. *
  54852. * _.castArray('abc');
  54853. * // => ['abc']
  54854. *
  54855. * _.castArray(null);
  54856. * // => [null]
  54857. *
  54858. * _.castArray(undefined);
  54859. * // => [undefined]
  54860. *
  54861. * _.castArray();
  54862. * // => []
  54863. *
  54864. * var array = [1, 2, 3];
  54865. * console.log(_.castArray(array) === array);
  54866. * // => true
  54867. */
  54868. function castArray() {
  54869. if (!arguments.length) {
  54870. return [];
  54871. }
  54872. var value = arguments[0];
  54873. return isArray(value) ? value : [value];
  54874. }
  54875. /**
  54876. * Creates a shallow clone of `value`.
  54877. *
  54878. * **Note:** This method is loosely based on the
  54879. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  54880. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  54881. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  54882. * arrays. The own enumerable properties of `arguments` objects are cloned
  54883. * as plain objects. An empty object is returned for uncloneable values such
  54884. * as error objects, functions, DOM nodes, and WeakMaps.
  54885. *
  54886. * @static
  54887. * @memberOf _
  54888. * @since 0.1.0
  54889. * @category Lang
  54890. * @param {*} value The value to clone.
  54891. * @returns {*} Returns the cloned value.
  54892. * @see _.cloneDeep
  54893. * @example
  54894. *
  54895. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  54896. *
  54897. * var shallow = _.clone(objects);
  54898. * console.log(shallow[0] === objects[0]);
  54899. * // => true
  54900. */
  54901. function clone(value) {
  54902. return baseClone(value, CLONE_SYMBOLS_FLAG);
  54903. }
  54904. /**
  54905. * This method is like `_.clone` except that it accepts `customizer` which
  54906. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  54907. * cloning is handled by the method instead. The `customizer` is invoked with
  54908. * up to four arguments; (value [, index|key, object, stack]).
  54909. *
  54910. * @static
  54911. * @memberOf _
  54912. * @since 4.0.0
  54913. * @category Lang
  54914. * @param {*} value The value to clone.
  54915. * @param {Function} [customizer] The function to customize cloning.
  54916. * @returns {*} Returns the cloned value.
  54917. * @see _.cloneDeepWith
  54918. * @example
  54919. *
  54920. * function customizer(value) {
  54921. * if (_.isElement(value)) {
  54922. * return value.cloneNode(false);
  54923. * }
  54924. * }
  54925. *
  54926. * var el = _.cloneWith(document.body, customizer);
  54927. *
  54928. * console.log(el === document.body);
  54929. * // => false
  54930. * console.log(el.nodeName);
  54931. * // => 'BODY'
  54932. * console.log(el.childNodes.length);
  54933. * // => 0
  54934. */
  54935. function cloneWith(value, customizer) {
  54936. customizer = typeof customizer == 'function' ? customizer : undefined;
  54937. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  54938. }
  54939. /**
  54940. * This method is like `_.clone` except that it recursively clones `value`.
  54941. *
  54942. * @static
  54943. * @memberOf _
  54944. * @since 1.0.0
  54945. * @category Lang
  54946. * @param {*} value The value to recursively clone.
  54947. * @returns {*} Returns the deep cloned value.
  54948. * @see _.clone
  54949. * @example
  54950. *
  54951. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  54952. *
  54953. * var deep = _.cloneDeep(objects);
  54954. * console.log(deep[0] === objects[0]);
  54955. * // => false
  54956. */
  54957. function cloneDeep(value) {
  54958. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  54959. }
  54960. /**
  54961. * This method is like `_.cloneWith` except that it recursively clones `value`.
  54962. *
  54963. * @static
  54964. * @memberOf _
  54965. * @since 4.0.0
  54966. * @category Lang
  54967. * @param {*} value The value to recursively clone.
  54968. * @param {Function} [customizer] The function to customize cloning.
  54969. * @returns {*} Returns the deep cloned value.
  54970. * @see _.cloneWith
  54971. * @example
  54972. *
  54973. * function customizer(value) {
  54974. * if (_.isElement(value)) {
  54975. * return value.cloneNode(true);
  54976. * }
  54977. * }
  54978. *
  54979. * var el = _.cloneDeepWith(document.body, customizer);
  54980. *
  54981. * console.log(el === document.body);
  54982. * // => false
  54983. * console.log(el.nodeName);
  54984. * // => 'BODY'
  54985. * console.log(el.childNodes.length);
  54986. * // => 20
  54987. */
  54988. function cloneDeepWith(value, customizer) {
  54989. customizer = typeof customizer == 'function' ? customizer : undefined;
  54990. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  54991. }
  54992. /**
  54993. * Checks if `object` conforms to `source` by invoking the predicate
  54994. * properties of `source` with the corresponding property values of `object`.
  54995. *
  54996. * **Note:** This method is equivalent to `_.conforms` when `source` is
  54997. * partially applied.
  54998. *
  54999. * @static
  55000. * @memberOf _
  55001. * @since 4.14.0
  55002. * @category Lang
  55003. * @param {Object} object The object to inspect.
  55004. * @param {Object} source The object of property predicates to conform to.
  55005. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  55006. * @example
  55007. *
  55008. * var object = { 'a': 1, 'b': 2 };
  55009. *
  55010. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  55011. * // => true
  55012. *
  55013. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  55014. * // => false
  55015. */
  55016. function conformsTo(object, source) {
  55017. return source == null || baseConformsTo(object, source, keys(source));
  55018. }
  55019. /**
  55020. * Performs a
  55021. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  55022. * comparison between two values to determine if they are equivalent.
  55023. *
  55024. * @static
  55025. * @memberOf _
  55026. * @since 4.0.0
  55027. * @category Lang
  55028. * @param {*} value The value to compare.
  55029. * @param {*} other The other value to compare.
  55030. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  55031. * @example
  55032. *
  55033. * var object = { 'a': 1 };
  55034. * var other = { 'a': 1 };
  55035. *
  55036. * _.eq(object, object);
  55037. * // => true
  55038. *
  55039. * _.eq(object, other);
  55040. * // => false
  55041. *
  55042. * _.eq('a', 'a');
  55043. * // => true
  55044. *
  55045. * _.eq('a', Object('a'));
  55046. * // => false
  55047. *
  55048. * _.eq(NaN, NaN);
  55049. * // => true
  55050. */
  55051. function eq(value, other) {
  55052. return value === other || (value !== value && other !== other);
  55053. }
  55054. /**
  55055. * Checks if `value` is greater than `other`.
  55056. *
  55057. * @static
  55058. * @memberOf _
  55059. * @since 3.9.0
  55060. * @category Lang
  55061. * @param {*} value The value to compare.
  55062. * @param {*} other The other value to compare.
  55063. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  55064. * else `false`.
  55065. * @see _.lt
  55066. * @example
  55067. *
  55068. * _.gt(3, 1);
  55069. * // => true
  55070. *
  55071. * _.gt(3, 3);
  55072. * // => false
  55073. *
  55074. * _.gt(1, 3);
  55075. * // => false
  55076. */
  55077. var gt = createRelationalOperation(baseGt);
  55078. /**
  55079. * Checks if `value` is greater than or equal to `other`.
  55080. *
  55081. * @static
  55082. * @memberOf _
  55083. * @since 3.9.0
  55084. * @category Lang
  55085. * @param {*} value The value to compare.
  55086. * @param {*} other The other value to compare.
  55087. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  55088. * `other`, else `false`.
  55089. * @see _.lte
  55090. * @example
  55091. *
  55092. * _.gte(3, 1);
  55093. * // => true
  55094. *
  55095. * _.gte(3, 3);
  55096. * // => true
  55097. *
  55098. * _.gte(1, 3);
  55099. * // => false
  55100. */
  55101. var gte = createRelationalOperation(function(value, other) {
  55102. return value >= other;
  55103. });
  55104. /**
  55105. * Checks if `value` is likely an `arguments` object.
  55106. *
  55107. * @static
  55108. * @memberOf _
  55109. * @since 0.1.0
  55110. * @category Lang
  55111. * @param {*} value The value to check.
  55112. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  55113. * else `false`.
  55114. * @example
  55115. *
  55116. * _.isArguments(function() { return arguments; }());
  55117. * // => true
  55118. *
  55119. * _.isArguments([1, 2, 3]);
  55120. * // => false
  55121. */
  55122. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  55123. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  55124. !propertyIsEnumerable.call(value, 'callee');
  55125. };
  55126. /**
  55127. * Checks if `value` is classified as an `Array` object.
  55128. *
  55129. * @static
  55130. * @memberOf _
  55131. * @since 0.1.0
  55132. * @category Lang
  55133. * @param {*} value The value to check.
  55134. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  55135. * @example
  55136. *
  55137. * _.isArray([1, 2, 3]);
  55138. * // => true
  55139. *
  55140. * _.isArray(document.body.children);
  55141. * // => false
  55142. *
  55143. * _.isArray('abc');
  55144. * // => false
  55145. *
  55146. * _.isArray(_.noop);
  55147. * // => false
  55148. */
  55149. var isArray = Array.isArray;
  55150. /**
  55151. * Checks if `value` is classified as an `ArrayBuffer` object.
  55152. *
  55153. * @static
  55154. * @memberOf _
  55155. * @since 4.3.0
  55156. * @category Lang
  55157. * @param {*} value The value to check.
  55158. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  55159. * @example
  55160. *
  55161. * _.isArrayBuffer(new ArrayBuffer(2));
  55162. * // => true
  55163. *
  55164. * _.isArrayBuffer(new Array(2));
  55165. * // => false
  55166. */
  55167. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  55168. /**
  55169. * Checks if `value` is array-like. A value is considered array-like if it's
  55170. * not a function and has a `value.length` that's an integer greater than or
  55171. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  55172. *
  55173. * @static
  55174. * @memberOf _
  55175. * @since 4.0.0
  55176. * @category Lang
  55177. * @param {*} value The value to check.
  55178. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  55179. * @example
  55180. *
  55181. * _.isArrayLike([1, 2, 3]);
  55182. * // => true
  55183. *
  55184. * _.isArrayLike(document.body.children);
  55185. * // => true
  55186. *
  55187. * _.isArrayLike('abc');
  55188. * // => true
  55189. *
  55190. * _.isArrayLike(_.noop);
  55191. * // => false
  55192. */
  55193. function isArrayLike(value) {
  55194. return value != null && isLength(value.length) && !isFunction(value);
  55195. }
  55196. /**
  55197. * This method is like `_.isArrayLike` except that it also checks if `value`
  55198. * is an object.
  55199. *
  55200. * @static
  55201. * @memberOf _
  55202. * @since 4.0.0
  55203. * @category Lang
  55204. * @param {*} value The value to check.
  55205. * @returns {boolean} Returns `true` if `value` is an array-like object,
  55206. * else `false`.
  55207. * @example
  55208. *
  55209. * _.isArrayLikeObject([1, 2, 3]);
  55210. * // => true
  55211. *
  55212. * _.isArrayLikeObject(document.body.children);
  55213. * // => true
  55214. *
  55215. * _.isArrayLikeObject('abc');
  55216. * // => false
  55217. *
  55218. * _.isArrayLikeObject(_.noop);
  55219. * // => false
  55220. */
  55221. function isArrayLikeObject(value) {
  55222. return isObjectLike(value) && isArrayLike(value);
  55223. }
  55224. /**
  55225. * Checks if `value` is classified as a boolean primitive or object.
  55226. *
  55227. * @static
  55228. * @memberOf _
  55229. * @since 0.1.0
  55230. * @category Lang
  55231. * @param {*} value The value to check.
  55232. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  55233. * @example
  55234. *
  55235. * _.isBoolean(false);
  55236. * // => true
  55237. *
  55238. * _.isBoolean(null);
  55239. * // => false
  55240. */
  55241. function isBoolean(value) {
  55242. return value === true || value === false ||
  55243. (isObjectLike(value) && baseGetTag(value) == boolTag);
  55244. }
  55245. /**
  55246. * Checks if `value` is a buffer.
  55247. *
  55248. * @static
  55249. * @memberOf _
  55250. * @since 4.3.0
  55251. * @category Lang
  55252. * @param {*} value The value to check.
  55253. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  55254. * @example
  55255. *
  55256. * _.isBuffer(new Buffer(2));
  55257. * // => true
  55258. *
  55259. * _.isBuffer(new Uint8Array(2));
  55260. * // => false
  55261. */
  55262. var isBuffer = nativeIsBuffer || stubFalse;
  55263. /**
  55264. * Checks if `value` is classified as a `Date` object.
  55265. *
  55266. * @static
  55267. * @memberOf _
  55268. * @since 0.1.0
  55269. * @category Lang
  55270. * @param {*} value The value to check.
  55271. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  55272. * @example
  55273. *
  55274. * _.isDate(new Date);
  55275. * // => true
  55276. *
  55277. * _.isDate('Mon April 23 2012');
  55278. * // => false
  55279. */
  55280. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  55281. /**
  55282. * Checks if `value` is likely a DOM element.
  55283. *
  55284. * @static
  55285. * @memberOf _
  55286. * @since 0.1.0
  55287. * @category Lang
  55288. * @param {*} value The value to check.
  55289. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  55290. * @example
  55291. *
  55292. * _.isElement(document.body);
  55293. * // => true
  55294. *
  55295. * _.isElement('<body>');
  55296. * // => false
  55297. */
  55298. function isElement(value) {
  55299. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  55300. }
  55301. /**
  55302. * Checks if `value` is an empty object, collection, map, or set.
  55303. *
  55304. * Objects are considered empty if they have no own enumerable string keyed
  55305. * properties.
  55306. *
  55307. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  55308. * jQuery-like collections are considered empty if they have a `length` of `0`.
  55309. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  55310. *
  55311. * @static
  55312. * @memberOf _
  55313. * @since 0.1.0
  55314. * @category Lang
  55315. * @param {*} value The value to check.
  55316. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  55317. * @example
  55318. *
  55319. * _.isEmpty(null);
  55320. * // => true
  55321. *
  55322. * _.isEmpty(true);
  55323. * // => true
  55324. *
  55325. * _.isEmpty(1);
  55326. * // => true
  55327. *
  55328. * _.isEmpty([1, 2, 3]);
  55329. * // => false
  55330. *
  55331. * _.isEmpty({ 'a': 1 });
  55332. * // => false
  55333. */
  55334. function isEmpty(value) {
  55335. if (value == null) {
  55336. return true;
  55337. }
  55338. if (isArrayLike(value) &&
  55339. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  55340. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  55341. return !value.length;
  55342. }
  55343. var tag = getTag(value);
  55344. if (tag == mapTag || tag == setTag) {
  55345. return !value.size;
  55346. }
  55347. if (isPrototype(value)) {
  55348. return !baseKeys(value).length;
  55349. }
  55350. for (var key in value) {
  55351. if (hasOwnProperty.call(value, key)) {
  55352. return false;
  55353. }
  55354. }
  55355. return true;
  55356. }
  55357. /**
  55358. * Performs a deep comparison between two values to determine if they are
  55359. * equivalent.
  55360. *
  55361. * **Note:** This method supports comparing arrays, array buffers, booleans,
  55362. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  55363. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  55364. * by their own, not inherited, enumerable properties. Functions and DOM
  55365. * nodes are compared by strict equality, i.e. `===`.
  55366. *
  55367. * @static
  55368. * @memberOf _
  55369. * @since 0.1.0
  55370. * @category Lang
  55371. * @param {*} value The value to compare.
  55372. * @param {*} other The other value to compare.
  55373. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  55374. * @example
  55375. *
  55376. * var object = { 'a': 1 };
  55377. * var other = { 'a': 1 };
  55378. *
  55379. * _.isEqual(object, other);
  55380. * // => true
  55381. *
  55382. * object === other;
  55383. * // => false
  55384. */
  55385. function isEqual(value, other) {
  55386. return baseIsEqual(value, other);
  55387. }
  55388. /**
  55389. * This method is like `_.isEqual` except that it accepts `customizer` which
  55390. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  55391. * are handled by the method instead. The `customizer` is invoked with up to
  55392. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  55393. *
  55394. * @static
  55395. * @memberOf _
  55396. * @since 4.0.0
  55397. * @category Lang
  55398. * @param {*} value The value to compare.
  55399. * @param {*} other The other value to compare.
  55400. * @param {Function} [customizer] The function to customize comparisons.
  55401. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  55402. * @example
  55403. *
  55404. * function isGreeting(value) {
  55405. * return /^h(?:i|ello)$/.test(value);
  55406. * }
  55407. *
  55408. * function customizer(objValue, othValue) {
  55409. * if (isGreeting(objValue) && isGreeting(othValue)) {
  55410. * return true;
  55411. * }
  55412. * }
  55413. *
  55414. * var array = ['hello', 'goodbye'];
  55415. * var other = ['hi', 'goodbye'];
  55416. *
  55417. * _.isEqualWith(array, other, customizer);
  55418. * // => true
  55419. */
  55420. function isEqualWith(value, other, customizer) {
  55421. customizer = typeof customizer == 'function' ? customizer : undefined;
  55422. var result = customizer ? customizer(value, other) : undefined;
  55423. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  55424. }
  55425. /**
  55426. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  55427. * `SyntaxError`, `TypeError`, or `URIError` object.
  55428. *
  55429. * @static
  55430. * @memberOf _
  55431. * @since 3.0.0
  55432. * @category Lang
  55433. * @param {*} value The value to check.
  55434. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  55435. * @example
  55436. *
  55437. * _.isError(new Error);
  55438. * // => true
  55439. *
  55440. * _.isError(Error);
  55441. * // => false
  55442. */
  55443. function isError(value) {
  55444. if (!isObjectLike(value)) {
  55445. return false;
  55446. }
  55447. var tag = baseGetTag(value);
  55448. return tag == errorTag || tag == domExcTag ||
  55449. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  55450. }
  55451. /**
  55452. * Checks if `value` is a finite primitive number.
  55453. *
  55454. * **Note:** This method is based on
  55455. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  55456. *
  55457. * @static
  55458. * @memberOf _
  55459. * @since 0.1.0
  55460. * @category Lang
  55461. * @param {*} value The value to check.
  55462. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  55463. * @example
  55464. *
  55465. * _.isFinite(3);
  55466. * // => true
  55467. *
  55468. * _.isFinite(Number.MIN_VALUE);
  55469. * // => true
  55470. *
  55471. * _.isFinite(Infinity);
  55472. * // => false
  55473. *
  55474. * _.isFinite('3');
  55475. * // => false
  55476. */
  55477. function isFinite(value) {
  55478. return typeof value == 'number' && nativeIsFinite(value);
  55479. }
  55480. /**
  55481. * Checks if `value` is classified as a `Function` object.
  55482. *
  55483. * @static
  55484. * @memberOf _
  55485. * @since 0.1.0
  55486. * @category Lang
  55487. * @param {*} value The value to check.
  55488. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  55489. * @example
  55490. *
  55491. * _.isFunction(_);
  55492. * // => true
  55493. *
  55494. * _.isFunction(/abc/);
  55495. * // => false
  55496. */
  55497. function isFunction(value) {
  55498. if (!isObject(value)) {
  55499. return false;
  55500. }
  55501. // The use of `Object#toString` avoids issues with the `typeof` operator
  55502. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  55503. var tag = baseGetTag(value);
  55504. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  55505. }
  55506. /**
  55507. * Checks if `value` is an integer.
  55508. *
  55509. * **Note:** This method is based on
  55510. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  55511. *
  55512. * @static
  55513. * @memberOf _
  55514. * @since 4.0.0
  55515. * @category Lang
  55516. * @param {*} value The value to check.
  55517. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  55518. * @example
  55519. *
  55520. * _.isInteger(3);
  55521. * // => true
  55522. *
  55523. * _.isInteger(Number.MIN_VALUE);
  55524. * // => false
  55525. *
  55526. * _.isInteger(Infinity);
  55527. * // => false
  55528. *
  55529. * _.isInteger('3');
  55530. * // => false
  55531. */
  55532. function isInteger(value) {
  55533. return typeof value == 'number' && value == toInteger(value);
  55534. }
  55535. /**
  55536. * Checks if `value` is a valid array-like length.
  55537. *
  55538. * **Note:** This method is loosely based on
  55539. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  55540. *
  55541. * @static
  55542. * @memberOf _
  55543. * @since 4.0.0
  55544. * @category Lang
  55545. * @param {*} value The value to check.
  55546. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  55547. * @example
  55548. *
  55549. * _.isLength(3);
  55550. * // => true
  55551. *
  55552. * _.isLength(Number.MIN_VALUE);
  55553. * // => false
  55554. *
  55555. * _.isLength(Infinity);
  55556. * // => false
  55557. *
  55558. * _.isLength('3');
  55559. * // => false
  55560. */
  55561. function isLength(value) {
  55562. return typeof value == 'number' &&
  55563. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  55564. }
  55565. /**
  55566. * Checks if `value` is the
  55567. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  55568. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  55569. *
  55570. * @static
  55571. * @memberOf _
  55572. * @since 0.1.0
  55573. * @category Lang
  55574. * @param {*} value The value to check.
  55575. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  55576. * @example
  55577. *
  55578. * _.isObject({});
  55579. * // => true
  55580. *
  55581. * _.isObject([1, 2, 3]);
  55582. * // => true
  55583. *
  55584. * _.isObject(_.noop);
  55585. * // => true
  55586. *
  55587. * _.isObject(null);
  55588. * // => false
  55589. */
  55590. function isObject(value) {
  55591. var type = typeof value;
  55592. return value != null && (type == 'object' || type == 'function');
  55593. }
  55594. /**
  55595. * Checks if `value` is object-like. A value is object-like if it's not `null`
  55596. * and has a `typeof` result of "object".
  55597. *
  55598. * @static
  55599. * @memberOf _
  55600. * @since 4.0.0
  55601. * @category Lang
  55602. * @param {*} value The value to check.
  55603. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  55604. * @example
  55605. *
  55606. * _.isObjectLike({});
  55607. * // => true
  55608. *
  55609. * _.isObjectLike([1, 2, 3]);
  55610. * // => true
  55611. *
  55612. * _.isObjectLike(_.noop);
  55613. * // => false
  55614. *
  55615. * _.isObjectLike(null);
  55616. * // => false
  55617. */
  55618. function isObjectLike(value) {
  55619. return value != null && typeof value == 'object';
  55620. }
  55621. /**
  55622. * Checks if `value` is classified as a `Map` object.
  55623. *
  55624. * @static
  55625. * @memberOf _
  55626. * @since 4.3.0
  55627. * @category Lang
  55628. * @param {*} value The value to check.
  55629. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  55630. * @example
  55631. *
  55632. * _.isMap(new Map);
  55633. * // => true
  55634. *
  55635. * _.isMap(new WeakMap);
  55636. * // => false
  55637. */
  55638. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  55639. /**
  55640. * Performs a partial deep comparison between `object` and `source` to
  55641. * determine if `object` contains equivalent property values.
  55642. *
  55643. * **Note:** This method is equivalent to `_.matches` when `source` is
  55644. * partially applied.
  55645. *
  55646. * Partial comparisons will match empty array and empty object `source`
  55647. * values against any array or object value, respectively. See `_.isEqual`
  55648. * for a list of supported value comparisons.
  55649. *
  55650. * @static
  55651. * @memberOf _
  55652. * @since 3.0.0
  55653. * @category Lang
  55654. * @param {Object} object The object to inspect.
  55655. * @param {Object} source The object of property values to match.
  55656. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  55657. * @example
  55658. *
  55659. * var object = { 'a': 1, 'b': 2 };
  55660. *
  55661. * _.isMatch(object, { 'b': 2 });
  55662. * // => true
  55663. *
  55664. * _.isMatch(object, { 'b': 1 });
  55665. * // => false
  55666. */
  55667. function isMatch(object, source) {
  55668. return object === source || baseIsMatch(object, source, getMatchData(source));
  55669. }
  55670. /**
  55671. * This method is like `_.isMatch` except that it accepts `customizer` which
  55672. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  55673. * are handled by the method instead. The `customizer` is invoked with five
  55674. * arguments: (objValue, srcValue, index|key, object, source).
  55675. *
  55676. * @static
  55677. * @memberOf _
  55678. * @since 4.0.0
  55679. * @category Lang
  55680. * @param {Object} object The object to inspect.
  55681. * @param {Object} source The object of property values to match.
  55682. * @param {Function} [customizer] The function to customize comparisons.
  55683. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  55684. * @example
  55685. *
  55686. * function isGreeting(value) {
  55687. * return /^h(?:i|ello)$/.test(value);
  55688. * }
  55689. *
  55690. * function customizer(objValue, srcValue) {
  55691. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  55692. * return true;
  55693. * }
  55694. * }
  55695. *
  55696. * var object = { 'greeting': 'hello' };
  55697. * var source = { 'greeting': 'hi' };
  55698. *
  55699. * _.isMatchWith(object, source, customizer);
  55700. * // => true
  55701. */
  55702. function isMatchWith(object, source, customizer) {
  55703. customizer = typeof customizer == 'function' ? customizer : undefined;
  55704. return baseIsMatch(object, source, getMatchData(source), customizer);
  55705. }
  55706. /**
  55707. * Checks if `value` is `NaN`.
  55708. *
  55709. * **Note:** This method is based on
  55710. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  55711. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  55712. * `undefined` and other non-number values.
  55713. *
  55714. * @static
  55715. * @memberOf _
  55716. * @since 0.1.0
  55717. * @category Lang
  55718. * @param {*} value The value to check.
  55719. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  55720. * @example
  55721. *
  55722. * _.isNaN(NaN);
  55723. * // => true
  55724. *
  55725. * _.isNaN(new Number(NaN));
  55726. * // => true
  55727. *
  55728. * isNaN(undefined);
  55729. * // => true
  55730. *
  55731. * _.isNaN(undefined);
  55732. * // => false
  55733. */
  55734. function isNaN(value) {
  55735. // An `NaN` primitive is the only value that is not equal to itself.
  55736. // Perform the `toStringTag` check first to avoid errors with some
  55737. // ActiveX objects in IE.
  55738. return isNumber(value) && value != +value;
  55739. }
  55740. /**
  55741. * Checks if `value` is a pristine native function.
  55742. *
  55743. * **Note:** This method can't reliably detect native functions in the presence
  55744. * of the core-js package because core-js circumvents this kind of detection.
  55745. * Despite multiple requests, the core-js maintainer has made it clear: any
  55746. * attempt to fix the detection will be obstructed. As a result, we're left
  55747. * with little choice but to throw an error. Unfortunately, this also affects
  55748. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  55749. * which rely on core-js.
  55750. *
  55751. * @static
  55752. * @memberOf _
  55753. * @since 3.0.0
  55754. * @category Lang
  55755. * @param {*} value The value to check.
  55756. * @returns {boolean} Returns `true` if `value` is a native function,
  55757. * else `false`.
  55758. * @example
  55759. *
  55760. * _.isNative(Array.prototype.push);
  55761. * // => true
  55762. *
  55763. * _.isNative(_);
  55764. * // => false
  55765. */
  55766. function isNative(value) {
  55767. if (isMaskable(value)) {
  55768. throw new Error(CORE_ERROR_TEXT);
  55769. }
  55770. return baseIsNative(value);
  55771. }
  55772. /**
  55773. * Checks if `value` is `null`.
  55774. *
  55775. * @static
  55776. * @memberOf _
  55777. * @since 0.1.0
  55778. * @category Lang
  55779. * @param {*} value The value to check.
  55780. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  55781. * @example
  55782. *
  55783. * _.isNull(null);
  55784. * // => true
  55785. *
  55786. * _.isNull(void 0);
  55787. * // => false
  55788. */
  55789. function isNull(value) {
  55790. return value === null;
  55791. }
  55792. /**
  55793. * Checks if `value` is `null` or `undefined`.
  55794. *
  55795. * @static
  55796. * @memberOf _
  55797. * @since 4.0.0
  55798. * @category Lang
  55799. * @param {*} value The value to check.
  55800. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  55801. * @example
  55802. *
  55803. * _.isNil(null);
  55804. * // => true
  55805. *
  55806. * _.isNil(void 0);
  55807. * // => true
  55808. *
  55809. * _.isNil(NaN);
  55810. * // => false
  55811. */
  55812. function isNil(value) {
  55813. return value == null;
  55814. }
  55815. /**
  55816. * Checks if `value` is classified as a `Number` primitive or object.
  55817. *
  55818. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  55819. * classified as numbers, use the `_.isFinite` method.
  55820. *
  55821. * @static
  55822. * @memberOf _
  55823. * @since 0.1.0
  55824. * @category Lang
  55825. * @param {*} value The value to check.
  55826. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  55827. * @example
  55828. *
  55829. * _.isNumber(3);
  55830. * // => true
  55831. *
  55832. * _.isNumber(Number.MIN_VALUE);
  55833. * // => true
  55834. *
  55835. * _.isNumber(Infinity);
  55836. * // => true
  55837. *
  55838. * _.isNumber('3');
  55839. * // => false
  55840. */
  55841. function isNumber(value) {
  55842. return typeof value == 'number' ||
  55843. (isObjectLike(value) && baseGetTag(value) == numberTag);
  55844. }
  55845. /**
  55846. * Checks if `value` is a plain object, that is, an object created by the
  55847. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  55848. *
  55849. * @static
  55850. * @memberOf _
  55851. * @since 0.8.0
  55852. * @category Lang
  55853. * @param {*} value The value to check.
  55854. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  55855. * @example
  55856. *
  55857. * function Foo() {
  55858. * this.a = 1;
  55859. * }
  55860. *
  55861. * _.isPlainObject(new Foo);
  55862. * // => false
  55863. *
  55864. * _.isPlainObject([1, 2, 3]);
  55865. * // => false
  55866. *
  55867. * _.isPlainObject({ 'x': 0, 'y': 0 });
  55868. * // => true
  55869. *
  55870. * _.isPlainObject(Object.create(null));
  55871. * // => true
  55872. */
  55873. function isPlainObject(value) {
  55874. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  55875. return false;
  55876. }
  55877. var proto = getPrototype(value);
  55878. if (proto === null) {
  55879. return true;
  55880. }
  55881. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  55882. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  55883. funcToString.call(Ctor) == objectCtorString;
  55884. }
  55885. /**
  55886. * Checks if `value` is classified as a `RegExp` object.
  55887. *
  55888. * @static
  55889. * @memberOf _
  55890. * @since 0.1.0
  55891. * @category Lang
  55892. * @param {*} value The value to check.
  55893. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  55894. * @example
  55895. *
  55896. * _.isRegExp(/abc/);
  55897. * // => true
  55898. *
  55899. * _.isRegExp('/abc/');
  55900. * // => false
  55901. */
  55902. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  55903. /**
  55904. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  55905. * double precision number which isn't the result of a rounded unsafe integer.
  55906. *
  55907. * **Note:** This method is based on
  55908. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  55909. *
  55910. * @static
  55911. * @memberOf _
  55912. * @since 4.0.0
  55913. * @category Lang
  55914. * @param {*} value The value to check.
  55915. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  55916. * @example
  55917. *
  55918. * _.isSafeInteger(3);
  55919. * // => true
  55920. *
  55921. * _.isSafeInteger(Number.MIN_VALUE);
  55922. * // => false
  55923. *
  55924. * _.isSafeInteger(Infinity);
  55925. * // => false
  55926. *
  55927. * _.isSafeInteger('3');
  55928. * // => false
  55929. */
  55930. function isSafeInteger(value) {
  55931. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  55932. }
  55933. /**
  55934. * Checks if `value` is classified as a `Set` object.
  55935. *
  55936. * @static
  55937. * @memberOf _
  55938. * @since 4.3.0
  55939. * @category Lang
  55940. * @param {*} value The value to check.
  55941. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  55942. * @example
  55943. *
  55944. * _.isSet(new Set);
  55945. * // => true
  55946. *
  55947. * _.isSet(new WeakSet);
  55948. * // => false
  55949. */
  55950. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  55951. /**
  55952. * Checks if `value` is classified as a `String` primitive or object.
  55953. *
  55954. * @static
  55955. * @since 0.1.0
  55956. * @memberOf _
  55957. * @category Lang
  55958. * @param {*} value The value to check.
  55959. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  55960. * @example
  55961. *
  55962. * _.isString('abc');
  55963. * // => true
  55964. *
  55965. * _.isString(1);
  55966. * // => false
  55967. */
  55968. function isString(value) {
  55969. return typeof value == 'string' ||
  55970. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  55971. }
  55972. /**
  55973. * Checks if `value` is classified as a `Symbol` primitive or object.
  55974. *
  55975. * @static
  55976. * @memberOf _
  55977. * @since 4.0.0
  55978. * @category Lang
  55979. * @param {*} value The value to check.
  55980. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  55981. * @example
  55982. *
  55983. * _.isSymbol(Symbol.iterator);
  55984. * // => true
  55985. *
  55986. * _.isSymbol('abc');
  55987. * // => false
  55988. */
  55989. function isSymbol(value) {
  55990. return typeof value == 'symbol' ||
  55991. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  55992. }
  55993. /**
  55994. * Checks if `value` is classified as a typed array.
  55995. *
  55996. * @static
  55997. * @memberOf _
  55998. * @since 3.0.0
  55999. * @category Lang
  56000. * @param {*} value The value to check.
  56001. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  56002. * @example
  56003. *
  56004. * _.isTypedArray(new Uint8Array);
  56005. * // => true
  56006. *
  56007. * _.isTypedArray([]);
  56008. * // => false
  56009. */
  56010. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  56011. /**
  56012. * Checks if `value` is `undefined`.
  56013. *
  56014. * @static
  56015. * @since 0.1.0
  56016. * @memberOf _
  56017. * @category Lang
  56018. * @param {*} value The value to check.
  56019. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  56020. * @example
  56021. *
  56022. * _.isUndefined(void 0);
  56023. * // => true
  56024. *
  56025. * _.isUndefined(null);
  56026. * // => false
  56027. */
  56028. function isUndefined(value) {
  56029. return value === undefined;
  56030. }
  56031. /**
  56032. * Checks if `value` is classified as a `WeakMap` object.
  56033. *
  56034. * @static
  56035. * @memberOf _
  56036. * @since 4.3.0
  56037. * @category Lang
  56038. * @param {*} value The value to check.
  56039. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  56040. * @example
  56041. *
  56042. * _.isWeakMap(new WeakMap);
  56043. * // => true
  56044. *
  56045. * _.isWeakMap(new Map);
  56046. * // => false
  56047. */
  56048. function isWeakMap(value) {
  56049. return isObjectLike(value) && getTag(value) == weakMapTag;
  56050. }
  56051. /**
  56052. * Checks if `value` is classified as a `WeakSet` object.
  56053. *
  56054. * @static
  56055. * @memberOf _
  56056. * @since 4.3.0
  56057. * @category Lang
  56058. * @param {*} value The value to check.
  56059. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  56060. * @example
  56061. *
  56062. * _.isWeakSet(new WeakSet);
  56063. * // => true
  56064. *
  56065. * _.isWeakSet(new Set);
  56066. * // => false
  56067. */
  56068. function isWeakSet(value) {
  56069. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  56070. }
  56071. /**
  56072. * Checks if `value` is less than `other`.
  56073. *
  56074. * @static
  56075. * @memberOf _
  56076. * @since 3.9.0
  56077. * @category Lang
  56078. * @param {*} value The value to compare.
  56079. * @param {*} other The other value to compare.
  56080. * @returns {boolean} Returns `true` if `value` is less than `other`,
  56081. * else `false`.
  56082. * @see _.gt
  56083. * @example
  56084. *
  56085. * _.lt(1, 3);
  56086. * // => true
  56087. *
  56088. * _.lt(3, 3);
  56089. * // => false
  56090. *
  56091. * _.lt(3, 1);
  56092. * // => false
  56093. */
  56094. var lt = createRelationalOperation(baseLt);
  56095. /**
  56096. * Checks if `value` is less than or equal to `other`.
  56097. *
  56098. * @static
  56099. * @memberOf _
  56100. * @since 3.9.0
  56101. * @category Lang
  56102. * @param {*} value The value to compare.
  56103. * @param {*} other The other value to compare.
  56104. * @returns {boolean} Returns `true` if `value` is less than or equal to
  56105. * `other`, else `false`.
  56106. * @see _.gte
  56107. * @example
  56108. *
  56109. * _.lte(1, 3);
  56110. * // => true
  56111. *
  56112. * _.lte(3, 3);
  56113. * // => true
  56114. *
  56115. * _.lte(3, 1);
  56116. * // => false
  56117. */
  56118. var lte = createRelationalOperation(function(value, other) {
  56119. return value <= other;
  56120. });
  56121. /**
  56122. * Converts `value` to an array.
  56123. *
  56124. * @static
  56125. * @since 0.1.0
  56126. * @memberOf _
  56127. * @category Lang
  56128. * @param {*} value The value to convert.
  56129. * @returns {Array} Returns the converted array.
  56130. * @example
  56131. *
  56132. * _.toArray({ 'a': 1, 'b': 2 });
  56133. * // => [1, 2]
  56134. *
  56135. * _.toArray('abc');
  56136. * // => ['a', 'b', 'c']
  56137. *
  56138. * _.toArray(1);
  56139. * // => []
  56140. *
  56141. * _.toArray(null);
  56142. * // => []
  56143. */
  56144. function toArray(value) {
  56145. if (!value) {
  56146. return [];
  56147. }
  56148. if (isArrayLike(value)) {
  56149. return isString(value) ? stringToArray(value) : copyArray(value);
  56150. }
  56151. if (symIterator && value[symIterator]) {
  56152. return iteratorToArray(value[symIterator]());
  56153. }
  56154. var tag = getTag(value),
  56155. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  56156. return func(value);
  56157. }
  56158. /**
  56159. * Converts `value` to a finite number.
  56160. *
  56161. * @static
  56162. * @memberOf _
  56163. * @since 4.12.0
  56164. * @category Lang
  56165. * @param {*} value The value to convert.
  56166. * @returns {number} Returns the converted number.
  56167. * @example
  56168. *
  56169. * _.toFinite(3.2);
  56170. * // => 3.2
  56171. *
  56172. * _.toFinite(Number.MIN_VALUE);
  56173. * // => 5e-324
  56174. *
  56175. * _.toFinite(Infinity);
  56176. * // => 1.7976931348623157e+308
  56177. *
  56178. * _.toFinite('3.2');
  56179. * // => 3.2
  56180. */
  56181. function toFinite(value) {
  56182. if (!value) {
  56183. return value === 0 ? value : 0;
  56184. }
  56185. value = toNumber(value);
  56186. if (value === INFINITY || value === -INFINITY) {
  56187. var sign = (value < 0 ? -1 : 1);
  56188. return sign * MAX_INTEGER;
  56189. }
  56190. return value === value ? value : 0;
  56191. }
  56192. /**
  56193. * Converts `value` to an integer.
  56194. *
  56195. * **Note:** This method is loosely based on
  56196. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  56197. *
  56198. * @static
  56199. * @memberOf _
  56200. * @since 4.0.0
  56201. * @category Lang
  56202. * @param {*} value The value to convert.
  56203. * @returns {number} Returns the converted integer.
  56204. * @example
  56205. *
  56206. * _.toInteger(3.2);
  56207. * // => 3
  56208. *
  56209. * _.toInteger(Number.MIN_VALUE);
  56210. * // => 0
  56211. *
  56212. * _.toInteger(Infinity);
  56213. * // => 1.7976931348623157e+308
  56214. *
  56215. * _.toInteger('3.2');
  56216. * // => 3
  56217. */
  56218. function toInteger(value) {
  56219. var result = toFinite(value),
  56220. remainder = result % 1;
  56221. return result === result ? (remainder ? result - remainder : result) : 0;
  56222. }
  56223. /**
  56224. * Converts `value` to an integer suitable for use as the length of an
  56225. * array-like object.
  56226. *
  56227. * **Note:** This method is based on
  56228. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  56229. *
  56230. * @static
  56231. * @memberOf _
  56232. * @since 4.0.0
  56233. * @category Lang
  56234. * @param {*} value The value to convert.
  56235. * @returns {number} Returns the converted integer.
  56236. * @example
  56237. *
  56238. * _.toLength(3.2);
  56239. * // => 3
  56240. *
  56241. * _.toLength(Number.MIN_VALUE);
  56242. * // => 0
  56243. *
  56244. * _.toLength(Infinity);
  56245. * // => 4294967295
  56246. *
  56247. * _.toLength('3.2');
  56248. * // => 3
  56249. */
  56250. function toLength(value) {
  56251. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  56252. }
  56253. /**
  56254. * Converts `value` to a number.
  56255. *
  56256. * @static
  56257. * @memberOf _
  56258. * @since 4.0.0
  56259. * @category Lang
  56260. * @param {*} value The value to process.
  56261. * @returns {number} Returns the number.
  56262. * @example
  56263. *
  56264. * _.toNumber(3.2);
  56265. * // => 3.2
  56266. *
  56267. * _.toNumber(Number.MIN_VALUE);
  56268. * // => 5e-324
  56269. *
  56270. * _.toNumber(Infinity);
  56271. * // => Infinity
  56272. *
  56273. * _.toNumber('3.2');
  56274. * // => 3.2
  56275. */
  56276. function toNumber(value) {
  56277. if (typeof value == 'number') {
  56278. return value;
  56279. }
  56280. if (isSymbol(value)) {
  56281. return NAN;
  56282. }
  56283. if (isObject(value)) {
  56284. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  56285. value = isObject(other) ? (other + '') : other;
  56286. }
  56287. if (typeof value != 'string') {
  56288. return value === 0 ? value : +value;
  56289. }
  56290. value = baseTrim(value);
  56291. var isBinary = reIsBinary.test(value);
  56292. return (isBinary || reIsOctal.test(value))
  56293. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  56294. : (reIsBadHex.test(value) ? NAN : +value);
  56295. }
  56296. /**
  56297. * Converts `value` to a plain object flattening inherited enumerable string
  56298. * keyed properties of `value` to own properties of the plain object.
  56299. *
  56300. * @static
  56301. * @memberOf _
  56302. * @since 3.0.0
  56303. * @category Lang
  56304. * @param {*} value The value to convert.
  56305. * @returns {Object} Returns the converted plain object.
  56306. * @example
  56307. *
  56308. * function Foo() {
  56309. * this.b = 2;
  56310. * }
  56311. *
  56312. * Foo.prototype.c = 3;
  56313. *
  56314. * _.assign({ 'a': 1 }, new Foo);
  56315. * // => { 'a': 1, 'b': 2 }
  56316. *
  56317. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  56318. * // => { 'a': 1, 'b': 2, 'c': 3 }
  56319. */
  56320. function toPlainObject(value) {
  56321. return copyObject(value, keysIn(value));
  56322. }
  56323. /**
  56324. * Converts `value` to a safe integer. A safe integer can be compared and
  56325. * represented correctly.
  56326. *
  56327. * @static
  56328. * @memberOf _
  56329. * @since 4.0.0
  56330. * @category Lang
  56331. * @param {*} value The value to convert.
  56332. * @returns {number} Returns the converted integer.
  56333. * @example
  56334. *
  56335. * _.toSafeInteger(3.2);
  56336. * // => 3
  56337. *
  56338. * _.toSafeInteger(Number.MIN_VALUE);
  56339. * // => 0
  56340. *
  56341. * _.toSafeInteger(Infinity);
  56342. * // => 9007199254740991
  56343. *
  56344. * _.toSafeInteger('3.2');
  56345. * // => 3
  56346. */
  56347. function toSafeInteger(value) {
  56348. return value
  56349. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  56350. : (value === 0 ? value : 0);
  56351. }
  56352. /**
  56353. * Converts `value` to a string. An empty string is returned for `null`
  56354. * and `undefined` values. The sign of `-0` is preserved.
  56355. *
  56356. * @static
  56357. * @memberOf _
  56358. * @since 4.0.0
  56359. * @category Lang
  56360. * @param {*} value The value to convert.
  56361. * @returns {string} Returns the converted string.
  56362. * @example
  56363. *
  56364. * _.toString(null);
  56365. * // => ''
  56366. *
  56367. * _.toString(-0);
  56368. * // => '-0'
  56369. *
  56370. * _.toString([1, 2, 3]);
  56371. * // => '1,2,3'
  56372. */
  56373. function toString(value) {
  56374. return value == null ? '' : baseToString(value);
  56375. }
  56376. /*------------------------------------------------------------------------*/
  56377. /**
  56378. * Assigns own enumerable string keyed properties of source objects to the
  56379. * destination object. Source objects are applied from left to right.
  56380. * Subsequent sources overwrite property assignments of previous sources.
  56381. *
  56382. * **Note:** This method mutates `object` and is loosely based on
  56383. * [`Object.assign`](https://mdn.io/Object/assign).
  56384. *
  56385. * @static
  56386. * @memberOf _
  56387. * @since 0.10.0
  56388. * @category Object
  56389. * @param {Object} object The destination object.
  56390. * @param {...Object} [sources] The source objects.
  56391. * @returns {Object} Returns `object`.
  56392. * @see _.assignIn
  56393. * @example
  56394. *
  56395. * function Foo() {
  56396. * this.a = 1;
  56397. * }
  56398. *
  56399. * function Bar() {
  56400. * this.c = 3;
  56401. * }
  56402. *
  56403. * Foo.prototype.b = 2;
  56404. * Bar.prototype.d = 4;
  56405. *
  56406. * _.assign({ 'a': 0 }, new Foo, new Bar);
  56407. * // => { 'a': 1, 'c': 3 }
  56408. */
  56409. var assign = createAssigner(function(object, source) {
  56410. if (isPrototype(source) || isArrayLike(source)) {
  56411. copyObject(source, keys(source), object);
  56412. return;
  56413. }
  56414. for (var key in source) {
  56415. if (hasOwnProperty.call(source, key)) {
  56416. assignValue(object, key, source[key]);
  56417. }
  56418. }
  56419. });
  56420. /**
  56421. * This method is like `_.assign` except that it iterates over own and
  56422. * inherited source properties.
  56423. *
  56424. * **Note:** This method mutates `object`.
  56425. *
  56426. * @static
  56427. * @memberOf _
  56428. * @since 4.0.0
  56429. * @alias extend
  56430. * @category Object
  56431. * @param {Object} object The destination object.
  56432. * @param {...Object} [sources] The source objects.
  56433. * @returns {Object} Returns `object`.
  56434. * @see _.assign
  56435. * @example
  56436. *
  56437. * function Foo() {
  56438. * this.a = 1;
  56439. * }
  56440. *
  56441. * function Bar() {
  56442. * this.c = 3;
  56443. * }
  56444. *
  56445. * Foo.prototype.b = 2;
  56446. * Bar.prototype.d = 4;
  56447. *
  56448. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  56449. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  56450. */
  56451. var assignIn = createAssigner(function(object, source) {
  56452. copyObject(source, keysIn(source), object);
  56453. });
  56454. /**
  56455. * This method is like `_.assignIn` except that it accepts `customizer`
  56456. * which is invoked to produce the assigned values. If `customizer` returns
  56457. * `undefined`, assignment is handled by the method instead. The `customizer`
  56458. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  56459. *
  56460. * **Note:** This method mutates `object`.
  56461. *
  56462. * @static
  56463. * @memberOf _
  56464. * @since 4.0.0
  56465. * @alias extendWith
  56466. * @category Object
  56467. * @param {Object} object The destination object.
  56468. * @param {...Object} sources The source objects.
  56469. * @param {Function} [customizer] The function to customize assigned values.
  56470. * @returns {Object} Returns `object`.
  56471. * @see _.assignWith
  56472. * @example
  56473. *
  56474. * function customizer(objValue, srcValue) {
  56475. * return _.isUndefined(objValue) ? srcValue : objValue;
  56476. * }
  56477. *
  56478. * var defaults = _.partialRight(_.assignInWith, customizer);
  56479. *
  56480. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  56481. * // => { 'a': 1, 'b': 2 }
  56482. */
  56483. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  56484. copyObject(source, keysIn(source), object, customizer);
  56485. });
  56486. /**
  56487. * This method is like `_.assign` except that it accepts `customizer`
  56488. * which is invoked to produce the assigned values. If `customizer` returns
  56489. * `undefined`, assignment is handled by the method instead. The `customizer`
  56490. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  56491. *
  56492. * **Note:** This method mutates `object`.
  56493. *
  56494. * @static
  56495. * @memberOf _
  56496. * @since 4.0.0
  56497. * @category Object
  56498. * @param {Object} object The destination object.
  56499. * @param {...Object} sources The source objects.
  56500. * @param {Function} [customizer] The function to customize assigned values.
  56501. * @returns {Object} Returns `object`.
  56502. * @see _.assignInWith
  56503. * @example
  56504. *
  56505. * function customizer(objValue, srcValue) {
  56506. * return _.isUndefined(objValue) ? srcValue : objValue;
  56507. * }
  56508. *
  56509. * var defaults = _.partialRight(_.assignWith, customizer);
  56510. *
  56511. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  56512. * // => { 'a': 1, 'b': 2 }
  56513. */
  56514. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  56515. copyObject(source, keys(source), object, customizer);
  56516. });
  56517. /**
  56518. * Creates an array of values corresponding to `paths` of `object`.
  56519. *
  56520. * @static
  56521. * @memberOf _
  56522. * @since 1.0.0
  56523. * @category Object
  56524. * @param {Object} object The object to iterate over.
  56525. * @param {...(string|string[])} [paths] The property paths to pick.
  56526. * @returns {Array} Returns the picked values.
  56527. * @example
  56528. *
  56529. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  56530. *
  56531. * _.at(object, ['a[0].b.c', 'a[1]']);
  56532. * // => [3, 4]
  56533. */
  56534. var at = flatRest(baseAt);
  56535. /**
  56536. * Creates an object that inherits from the `prototype` object. If a
  56537. * `properties` object is given, its own enumerable string keyed properties
  56538. * are assigned to the created object.
  56539. *
  56540. * @static
  56541. * @memberOf _
  56542. * @since 2.3.0
  56543. * @category Object
  56544. * @param {Object} prototype The object to inherit from.
  56545. * @param {Object} [properties] The properties to assign to the object.
  56546. * @returns {Object} Returns the new object.
  56547. * @example
  56548. *
  56549. * function Shape() {
  56550. * this.x = 0;
  56551. * this.y = 0;
  56552. * }
  56553. *
  56554. * function Circle() {
  56555. * Shape.call(this);
  56556. * }
  56557. *
  56558. * Circle.prototype = _.create(Shape.prototype, {
  56559. * 'constructor': Circle
  56560. * });
  56561. *
  56562. * var circle = new Circle;
  56563. * circle instanceof Circle;
  56564. * // => true
  56565. *
  56566. * circle instanceof Shape;
  56567. * // => true
  56568. */
  56569. function create(prototype, properties) {
  56570. var result = baseCreate(prototype);
  56571. return properties == null ? result : baseAssign(result, properties);
  56572. }
  56573. /**
  56574. * Assigns own and inherited enumerable string keyed properties of source
  56575. * objects to the destination object for all destination properties that
  56576. * resolve to `undefined`. Source objects are applied from left to right.
  56577. * Once a property is set, additional values of the same property are ignored.
  56578. *
  56579. * **Note:** This method mutates `object`.
  56580. *
  56581. * @static
  56582. * @since 0.1.0
  56583. * @memberOf _
  56584. * @category Object
  56585. * @param {Object} object The destination object.
  56586. * @param {...Object} [sources] The source objects.
  56587. * @returns {Object} Returns `object`.
  56588. * @see _.defaultsDeep
  56589. * @example
  56590. *
  56591. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  56592. * // => { 'a': 1, 'b': 2 }
  56593. */
  56594. var defaults = baseRest(function(object, sources) {
  56595. object = Object(object);
  56596. var index = -1;
  56597. var length = sources.length;
  56598. var guard = length > 2 ? sources[2] : undefined;
  56599. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  56600. length = 1;
  56601. }
  56602. while (++index < length) {
  56603. var source = sources[index];
  56604. var props = keysIn(source);
  56605. var propsIndex = -1;
  56606. var propsLength = props.length;
  56607. while (++propsIndex < propsLength) {
  56608. var key = props[propsIndex];
  56609. var value = object[key];
  56610. if (value === undefined ||
  56611. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  56612. object[key] = source[key];
  56613. }
  56614. }
  56615. }
  56616. return object;
  56617. });
  56618. /**
  56619. * This method is like `_.defaults` except that it recursively assigns
  56620. * default properties.
  56621. *
  56622. * **Note:** This method mutates `object`.
  56623. *
  56624. * @static
  56625. * @memberOf _
  56626. * @since 3.10.0
  56627. * @category Object
  56628. * @param {Object} object The destination object.
  56629. * @param {...Object} [sources] The source objects.
  56630. * @returns {Object} Returns `object`.
  56631. * @see _.defaults
  56632. * @example
  56633. *
  56634. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  56635. * // => { 'a': { 'b': 2, 'c': 3 } }
  56636. */
  56637. var defaultsDeep = baseRest(function(args) {
  56638. args.push(undefined, customDefaultsMerge);
  56639. return apply(mergeWith, undefined, args);
  56640. });
  56641. /**
  56642. * This method is like `_.find` except that it returns the key of the first
  56643. * element `predicate` returns truthy for instead of the element itself.
  56644. *
  56645. * @static
  56646. * @memberOf _
  56647. * @since 1.1.0
  56648. * @category Object
  56649. * @param {Object} object The object to inspect.
  56650. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  56651. * @returns {string|undefined} Returns the key of the matched element,
  56652. * else `undefined`.
  56653. * @example
  56654. *
  56655. * var users = {
  56656. * 'barney': { 'age': 36, 'active': true },
  56657. * 'fred': { 'age': 40, 'active': false },
  56658. * 'pebbles': { 'age': 1, 'active': true }
  56659. * };
  56660. *
  56661. * _.findKey(users, function(o) { return o.age < 40; });
  56662. * // => 'barney' (iteration order is not guaranteed)
  56663. *
  56664. * // The `_.matches` iteratee shorthand.
  56665. * _.findKey(users, { 'age': 1, 'active': true });
  56666. * // => 'pebbles'
  56667. *
  56668. * // The `_.matchesProperty` iteratee shorthand.
  56669. * _.findKey(users, ['active', false]);
  56670. * // => 'fred'
  56671. *
  56672. * // The `_.property` iteratee shorthand.
  56673. * _.findKey(users, 'active');
  56674. * // => 'barney'
  56675. */
  56676. function findKey(object, predicate) {
  56677. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  56678. }
  56679. /**
  56680. * This method is like `_.findKey` except that it iterates over elements of
  56681. * a collection in the opposite order.
  56682. *
  56683. * @static
  56684. * @memberOf _
  56685. * @since 2.0.0
  56686. * @category Object
  56687. * @param {Object} object The object to inspect.
  56688. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  56689. * @returns {string|undefined} Returns the key of the matched element,
  56690. * else `undefined`.
  56691. * @example
  56692. *
  56693. * var users = {
  56694. * 'barney': { 'age': 36, 'active': true },
  56695. * 'fred': { 'age': 40, 'active': false },
  56696. * 'pebbles': { 'age': 1, 'active': true }
  56697. * };
  56698. *
  56699. * _.findLastKey(users, function(o) { return o.age < 40; });
  56700. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  56701. *
  56702. * // The `_.matches` iteratee shorthand.
  56703. * _.findLastKey(users, { 'age': 36, 'active': true });
  56704. * // => 'barney'
  56705. *
  56706. * // The `_.matchesProperty` iteratee shorthand.
  56707. * _.findLastKey(users, ['active', false]);
  56708. * // => 'fred'
  56709. *
  56710. * // The `_.property` iteratee shorthand.
  56711. * _.findLastKey(users, 'active');
  56712. * // => 'pebbles'
  56713. */
  56714. function findLastKey(object, predicate) {
  56715. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  56716. }
  56717. /**
  56718. * Iterates over own and inherited enumerable string keyed properties of an
  56719. * object and invokes `iteratee` for each property. The iteratee is invoked
  56720. * with three arguments: (value, key, object). Iteratee functions may exit
  56721. * iteration early by explicitly returning `false`.
  56722. *
  56723. * @static
  56724. * @memberOf _
  56725. * @since 0.3.0
  56726. * @category Object
  56727. * @param {Object} object The object to iterate over.
  56728. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  56729. * @returns {Object} Returns `object`.
  56730. * @see _.forInRight
  56731. * @example
  56732. *
  56733. * function Foo() {
  56734. * this.a = 1;
  56735. * this.b = 2;
  56736. * }
  56737. *
  56738. * Foo.prototype.c = 3;
  56739. *
  56740. * _.forIn(new Foo, function(value, key) {
  56741. * console.log(key);
  56742. * });
  56743. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  56744. */
  56745. function forIn(object, iteratee) {
  56746. return object == null
  56747. ? object
  56748. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  56749. }
  56750. /**
  56751. * This method is like `_.forIn` except that it iterates over properties of
  56752. * `object` in the opposite order.
  56753. *
  56754. * @static
  56755. * @memberOf _
  56756. * @since 2.0.0
  56757. * @category Object
  56758. * @param {Object} object The object to iterate over.
  56759. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  56760. * @returns {Object} Returns `object`.
  56761. * @see _.forIn
  56762. * @example
  56763. *
  56764. * function Foo() {
  56765. * this.a = 1;
  56766. * this.b = 2;
  56767. * }
  56768. *
  56769. * Foo.prototype.c = 3;
  56770. *
  56771. * _.forInRight(new Foo, function(value, key) {
  56772. * console.log(key);
  56773. * });
  56774. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  56775. */
  56776. function forInRight(object, iteratee) {
  56777. return object == null
  56778. ? object
  56779. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  56780. }
  56781. /**
  56782. * Iterates over own enumerable string keyed properties of an object and
  56783. * invokes `iteratee` for each property. The iteratee is invoked with three
  56784. * arguments: (value, key, object). Iteratee functions may exit iteration
  56785. * early by explicitly returning `false`.
  56786. *
  56787. * @static
  56788. * @memberOf _
  56789. * @since 0.3.0
  56790. * @category Object
  56791. * @param {Object} object The object to iterate over.
  56792. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  56793. * @returns {Object} Returns `object`.
  56794. * @see _.forOwnRight
  56795. * @example
  56796. *
  56797. * function Foo() {
  56798. * this.a = 1;
  56799. * this.b = 2;
  56800. * }
  56801. *
  56802. * Foo.prototype.c = 3;
  56803. *
  56804. * _.forOwn(new Foo, function(value, key) {
  56805. * console.log(key);
  56806. * });
  56807. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  56808. */
  56809. function forOwn(object, iteratee) {
  56810. return object && baseForOwn(object, getIteratee(iteratee, 3));
  56811. }
  56812. /**
  56813. * This method is like `_.forOwn` except that it iterates over properties of
  56814. * `object` in the opposite order.
  56815. *
  56816. * @static
  56817. * @memberOf _
  56818. * @since 2.0.0
  56819. * @category Object
  56820. * @param {Object} object The object to iterate over.
  56821. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  56822. * @returns {Object} Returns `object`.
  56823. * @see _.forOwn
  56824. * @example
  56825. *
  56826. * function Foo() {
  56827. * this.a = 1;
  56828. * this.b = 2;
  56829. * }
  56830. *
  56831. * Foo.prototype.c = 3;
  56832. *
  56833. * _.forOwnRight(new Foo, function(value, key) {
  56834. * console.log(key);
  56835. * });
  56836. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  56837. */
  56838. function forOwnRight(object, iteratee) {
  56839. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  56840. }
  56841. /**
  56842. * Creates an array of function property names from own enumerable properties
  56843. * of `object`.
  56844. *
  56845. * @static
  56846. * @since 0.1.0
  56847. * @memberOf _
  56848. * @category Object
  56849. * @param {Object} object The object to inspect.
  56850. * @returns {Array} Returns the function names.
  56851. * @see _.functionsIn
  56852. * @example
  56853. *
  56854. * function Foo() {
  56855. * this.a = _.constant('a');
  56856. * this.b = _.constant('b');
  56857. * }
  56858. *
  56859. * Foo.prototype.c = _.constant('c');
  56860. *
  56861. * _.functions(new Foo);
  56862. * // => ['a', 'b']
  56863. */
  56864. function functions(object) {
  56865. return object == null ? [] : baseFunctions(object, keys(object));
  56866. }
  56867. /**
  56868. * Creates an array of function property names from own and inherited
  56869. * enumerable properties of `object`.
  56870. *
  56871. * @static
  56872. * @memberOf _
  56873. * @since 4.0.0
  56874. * @category Object
  56875. * @param {Object} object The object to inspect.
  56876. * @returns {Array} Returns the function names.
  56877. * @see _.functions
  56878. * @example
  56879. *
  56880. * function Foo() {
  56881. * this.a = _.constant('a');
  56882. * this.b = _.constant('b');
  56883. * }
  56884. *
  56885. * Foo.prototype.c = _.constant('c');
  56886. *
  56887. * _.functionsIn(new Foo);
  56888. * // => ['a', 'b', 'c']
  56889. */
  56890. function functionsIn(object) {
  56891. return object == null ? [] : baseFunctions(object, keysIn(object));
  56892. }
  56893. /**
  56894. * Gets the value at `path` of `object`. If the resolved value is
  56895. * `undefined`, the `defaultValue` is returned in its place.
  56896. *
  56897. * @static
  56898. * @memberOf _
  56899. * @since 3.7.0
  56900. * @category Object
  56901. * @param {Object} object The object to query.
  56902. * @param {Array|string} path The path of the property to get.
  56903. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  56904. * @returns {*} Returns the resolved value.
  56905. * @example
  56906. *
  56907. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  56908. *
  56909. * _.get(object, 'a[0].b.c');
  56910. * // => 3
  56911. *
  56912. * _.get(object, ['a', '0', 'b', 'c']);
  56913. * // => 3
  56914. *
  56915. * _.get(object, 'a.b.c', 'default');
  56916. * // => 'default'
  56917. */
  56918. function get(object, path, defaultValue) {
  56919. var result = object == null ? undefined : baseGet(object, path);
  56920. return result === undefined ? defaultValue : result;
  56921. }
  56922. /**
  56923. * Checks if `path` is a direct property of `object`.
  56924. *
  56925. * @static
  56926. * @since 0.1.0
  56927. * @memberOf _
  56928. * @category Object
  56929. * @param {Object} object The object to query.
  56930. * @param {Array|string} path The path to check.
  56931. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  56932. * @example
  56933. *
  56934. * var object = { 'a': { 'b': 2 } };
  56935. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  56936. *
  56937. * _.has(object, 'a');
  56938. * // => true
  56939. *
  56940. * _.has(object, 'a.b');
  56941. * // => true
  56942. *
  56943. * _.has(object, ['a', 'b']);
  56944. * // => true
  56945. *
  56946. * _.has(other, 'a');
  56947. * // => false
  56948. */
  56949. function has(object, path) {
  56950. return object != null && hasPath(object, path, baseHas);
  56951. }
  56952. /**
  56953. * Checks if `path` is a direct or inherited property of `object`.
  56954. *
  56955. * @static
  56956. * @memberOf _
  56957. * @since 4.0.0
  56958. * @category Object
  56959. * @param {Object} object The object to query.
  56960. * @param {Array|string} path The path to check.
  56961. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  56962. * @example
  56963. *
  56964. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  56965. *
  56966. * _.hasIn(object, 'a');
  56967. * // => true
  56968. *
  56969. * _.hasIn(object, 'a.b');
  56970. * // => true
  56971. *
  56972. * _.hasIn(object, ['a', 'b']);
  56973. * // => true
  56974. *
  56975. * _.hasIn(object, 'b');
  56976. * // => false
  56977. */
  56978. function hasIn(object, path) {
  56979. return object != null && hasPath(object, path, baseHasIn);
  56980. }
  56981. /**
  56982. * Creates an object composed of the inverted keys and values of `object`.
  56983. * If `object` contains duplicate values, subsequent values overwrite
  56984. * property assignments of previous values.
  56985. *
  56986. * @static
  56987. * @memberOf _
  56988. * @since 0.7.0
  56989. * @category Object
  56990. * @param {Object} object The object to invert.
  56991. * @returns {Object} Returns the new inverted object.
  56992. * @example
  56993. *
  56994. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  56995. *
  56996. * _.invert(object);
  56997. * // => { '1': 'c', '2': 'b' }
  56998. */
  56999. var invert = createInverter(function(result, value, key) {
  57000. if (value != null &&
  57001. typeof value.toString != 'function') {
  57002. value = nativeObjectToString.call(value);
  57003. }
  57004. result[value] = key;
  57005. }, constant(identity));
  57006. /**
  57007. * This method is like `_.invert` except that the inverted object is generated
  57008. * from the results of running each element of `object` thru `iteratee`. The
  57009. * corresponding inverted value of each inverted key is an array of keys
  57010. * responsible for generating the inverted value. The iteratee is invoked
  57011. * with one argument: (value).
  57012. *
  57013. * @static
  57014. * @memberOf _
  57015. * @since 4.1.0
  57016. * @category Object
  57017. * @param {Object} object The object to invert.
  57018. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  57019. * @returns {Object} Returns the new inverted object.
  57020. * @example
  57021. *
  57022. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  57023. *
  57024. * _.invertBy(object);
  57025. * // => { '1': ['a', 'c'], '2': ['b'] }
  57026. *
  57027. * _.invertBy(object, function(value) {
  57028. * return 'group' + value;
  57029. * });
  57030. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  57031. */
  57032. var invertBy = createInverter(function(result, value, key) {
  57033. if (value != null &&
  57034. typeof value.toString != 'function') {
  57035. value = nativeObjectToString.call(value);
  57036. }
  57037. if (hasOwnProperty.call(result, value)) {
  57038. result[value].push(key);
  57039. } else {
  57040. result[value] = [key];
  57041. }
  57042. }, getIteratee);
  57043. /**
  57044. * Invokes the method at `path` of `object`.
  57045. *
  57046. * @static
  57047. * @memberOf _
  57048. * @since 4.0.0
  57049. * @category Object
  57050. * @param {Object} object The object to query.
  57051. * @param {Array|string} path The path of the method to invoke.
  57052. * @param {...*} [args] The arguments to invoke the method with.
  57053. * @returns {*} Returns the result of the invoked method.
  57054. * @example
  57055. *
  57056. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  57057. *
  57058. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  57059. * // => [2, 3]
  57060. */
  57061. var invoke = baseRest(baseInvoke);
  57062. /**
  57063. * Creates an array of the own enumerable property names of `object`.
  57064. *
  57065. * **Note:** Non-object values are coerced to objects. See the
  57066. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  57067. * for more details.
  57068. *
  57069. * @static
  57070. * @since 0.1.0
  57071. * @memberOf _
  57072. * @category Object
  57073. * @param {Object} object The object to query.
  57074. * @returns {Array} Returns the array of property names.
  57075. * @example
  57076. *
  57077. * function Foo() {
  57078. * this.a = 1;
  57079. * this.b = 2;
  57080. * }
  57081. *
  57082. * Foo.prototype.c = 3;
  57083. *
  57084. * _.keys(new Foo);
  57085. * // => ['a', 'b'] (iteration order is not guaranteed)
  57086. *
  57087. * _.keys('hi');
  57088. * // => ['0', '1']
  57089. */
  57090. function keys(object) {
  57091. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  57092. }
  57093. /**
  57094. * Creates an array of the own and inherited enumerable property names of `object`.
  57095. *
  57096. * **Note:** Non-object values are coerced to objects.
  57097. *
  57098. * @static
  57099. * @memberOf _
  57100. * @since 3.0.0
  57101. * @category Object
  57102. * @param {Object} object The object to query.
  57103. * @returns {Array} Returns the array of property names.
  57104. * @example
  57105. *
  57106. * function Foo() {
  57107. * this.a = 1;
  57108. * this.b = 2;
  57109. * }
  57110. *
  57111. * Foo.prototype.c = 3;
  57112. *
  57113. * _.keysIn(new Foo);
  57114. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  57115. */
  57116. function keysIn(object) {
  57117. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  57118. }
  57119. /**
  57120. * The opposite of `_.mapValues`; this method creates an object with the
  57121. * same values as `object` and keys generated by running each own enumerable
  57122. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  57123. * with three arguments: (value, key, object).
  57124. *
  57125. * @static
  57126. * @memberOf _
  57127. * @since 3.8.0
  57128. * @category Object
  57129. * @param {Object} object The object to iterate over.
  57130. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  57131. * @returns {Object} Returns the new mapped object.
  57132. * @see _.mapValues
  57133. * @example
  57134. *
  57135. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  57136. * return key + value;
  57137. * });
  57138. * // => { 'a1': 1, 'b2': 2 }
  57139. */
  57140. function mapKeys(object, iteratee) {
  57141. var result = {};
  57142. iteratee = getIteratee(iteratee, 3);
  57143. baseForOwn(object, function(value, key, object) {
  57144. baseAssignValue(result, iteratee(value, key, object), value);
  57145. });
  57146. return result;
  57147. }
  57148. /**
  57149. * Creates an object with the same keys as `object` and values generated
  57150. * by running each own enumerable string keyed property of `object` thru
  57151. * `iteratee`. The iteratee is invoked with three arguments:
  57152. * (value, key, object).
  57153. *
  57154. * @static
  57155. * @memberOf _
  57156. * @since 2.4.0
  57157. * @category Object
  57158. * @param {Object} object The object to iterate over.
  57159. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  57160. * @returns {Object} Returns the new mapped object.
  57161. * @see _.mapKeys
  57162. * @example
  57163. *
  57164. * var users = {
  57165. * 'fred': { 'user': 'fred', 'age': 40 },
  57166. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  57167. * };
  57168. *
  57169. * _.mapValues(users, function(o) { return o.age; });
  57170. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  57171. *
  57172. * // The `_.property` iteratee shorthand.
  57173. * _.mapValues(users, 'age');
  57174. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  57175. */
  57176. function mapValues(object, iteratee) {
  57177. var result = {};
  57178. iteratee = getIteratee(iteratee, 3);
  57179. baseForOwn(object, function(value, key, object) {
  57180. baseAssignValue(result, key, iteratee(value, key, object));
  57181. });
  57182. return result;
  57183. }
  57184. /**
  57185. * This method is like `_.assign` except that it recursively merges own and
  57186. * inherited enumerable string keyed properties of source objects into the
  57187. * destination object. Source properties that resolve to `undefined` are
  57188. * skipped if a destination value exists. Array and plain object properties
  57189. * are merged recursively. Other objects and value types are overridden by
  57190. * assignment. Source objects are applied from left to right. Subsequent
  57191. * sources overwrite property assignments of previous sources.
  57192. *
  57193. * **Note:** This method mutates `object`.
  57194. *
  57195. * @static
  57196. * @memberOf _
  57197. * @since 0.5.0
  57198. * @category Object
  57199. * @param {Object} object The destination object.
  57200. * @param {...Object} [sources] The source objects.
  57201. * @returns {Object} Returns `object`.
  57202. * @example
  57203. *
  57204. * var object = {
  57205. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  57206. * };
  57207. *
  57208. * var other = {
  57209. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  57210. * };
  57211. *
  57212. * _.merge(object, other);
  57213. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  57214. */
  57215. var merge = createAssigner(function(object, source, srcIndex) {
  57216. baseMerge(object, source, srcIndex);
  57217. });
  57218. /**
  57219. * This method is like `_.merge` except that it accepts `customizer` which
  57220. * is invoked to produce the merged values of the destination and source
  57221. * properties. If `customizer` returns `undefined`, merging is handled by the
  57222. * method instead. The `customizer` is invoked with six arguments:
  57223. * (objValue, srcValue, key, object, source, stack).
  57224. *
  57225. * **Note:** This method mutates `object`.
  57226. *
  57227. * @static
  57228. * @memberOf _
  57229. * @since 4.0.0
  57230. * @category Object
  57231. * @param {Object} object The destination object.
  57232. * @param {...Object} sources The source objects.
  57233. * @param {Function} customizer The function to customize assigned values.
  57234. * @returns {Object} Returns `object`.
  57235. * @example
  57236. *
  57237. * function customizer(objValue, srcValue) {
  57238. * if (_.isArray(objValue)) {
  57239. * return objValue.concat(srcValue);
  57240. * }
  57241. * }
  57242. *
  57243. * var object = { 'a': [1], 'b': [2] };
  57244. * var other = { 'a': [3], 'b': [4] };
  57245. *
  57246. * _.mergeWith(object, other, customizer);
  57247. * // => { 'a': [1, 3], 'b': [2, 4] }
  57248. */
  57249. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  57250. baseMerge(object, source, srcIndex, customizer);
  57251. });
  57252. /**
  57253. * The opposite of `_.pick`; this method creates an object composed of the
  57254. * own and inherited enumerable property paths of `object` that are not omitted.
  57255. *
  57256. * **Note:** This method is considerably slower than `_.pick`.
  57257. *
  57258. * @static
  57259. * @since 0.1.0
  57260. * @memberOf _
  57261. * @category Object
  57262. * @param {Object} object The source object.
  57263. * @param {...(string|string[])} [paths] The property paths to omit.
  57264. * @returns {Object} Returns the new object.
  57265. * @example
  57266. *
  57267. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  57268. *
  57269. * _.omit(object, ['a', 'c']);
  57270. * // => { 'b': '2' }
  57271. */
  57272. var omit = flatRest(function(object, paths) {
  57273. var result = {};
  57274. if (object == null) {
  57275. return result;
  57276. }
  57277. var isDeep = false;
  57278. paths = arrayMap(paths, function(path) {
  57279. path = castPath(path, object);
  57280. isDeep || (isDeep = path.length > 1);
  57281. return path;
  57282. });
  57283. copyObject(object, getAllKeysIn(object), result);
  57284. if (isDeep) {
  57285. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  57286. }
  57287. var length = paths.length;
  57288. while (length--) {
  57289. baseUnset(result, paths[length]);
  57290. }
  57291. return result;
  57292. });
  57293. /**
  57294. * The opposite of `_.pickBy`; this method creates an object composed of
  57295. * the own and inherited enumerable string keyed properties of `object` that
  57296. * `predicate` doesn't return truthy for. The predicate is invoked with two
  57297. * arguments: (value, key).
  57298. *
  57299. * @static
  57300. * @memberOf _
  57301. * @since 4.0.0
  57302. * @category Object
  57303. * @param {Object} object The source object.
  57304. * @param {Function} [predicate=_.identity] The function invoked per property.
  57305. * @returns {Object} Returns the new object.
  57306. * @example
  57307. *
  57308. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  57309. *
  57310. * _.omitBy(object, _.isNumber);
  57311. * // => { 'b': '2' }
  57312. */
  57313. function omitBy(object, predicate) {
  57314. return pickBy(object, negate(getIteratee(predicate)));
  57315. }
  57316. /**
  57317. * Creates an object composed of the picked `object` properties.
  57318. *
  57319. * @static
  57320. * @since 0.1.0
  57321. * @memberOf _
  57322. * @category Object
  57323. * @param {Object} object The source object.
  57324. * @param {...(string|string[])} [paths] The property paths to pick.
  57325. * @returns {Object} Returns the new object.
  57326. * @example
  57327. *
  57328. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  57329. *
  57330. * _.pick(object, ['a', 'c']);
  57331. * // => { 'a': 1, 'c': 3 }
  57332. */
  57333. var pick = flatRest(function(object, paths) {
  57334. return object == null ? {} : basePick(object, paths);
  57335. });
  57336. /**
  57337. * Creates an object composed of the `object` properties `predicate` returns
  57338. * truthy for. The predicate is invoked with two arguments: (value, key).
  57339. *
  57340. * @static
  57341. * @memberOf _
  57342. * @since 4.0.0
  57343. * @category Object
  57344. * @param {Object} object The source object.
  57345. * @param {Function} [predicate=_.identity] The function invoked per property.
  57346. * @returns {Object} Returns the new object.
  57347. * @example
  57348. *
  57349. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  57350. *
  57351. * _.pickBy(object, _.isNumber);
  57352. * // => { 'a': 1, 'c': 3 }
  57353. */
  57354. function pickBy(object, predicate) {
  57355. if (object == null) {
  57356. return {};
  57357. }
  57358. var props = arrayMap(getAllKeysIn(object), function(prop) {
  57359. return [prop];
  57360. });
  57361. predicate = getIteratee(predicate);
  57362. return basePickBy(object, props, function(value, path) {
  57363. return predicate(value, path[0]);
  57364. });
  57365. }
  57366. /**
  57367. * This method is like `_.get` except that if the resolved value is a
  57368. * function it's invoked with the `this` binding of its parent object and
  57369. * its result is returned.
  57370. *
  57371. * @static
  57372. * @since 0.1.0
  57373. * @memberOf _
  57374. * @category Object
  57375. * @param {Object} object The object to query.
  57376. * @param {Array|string} path The path of the property to resolve.
  57377. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  57378. * @returns {*} Returns the resolved value.
  57379. * @example
  57380. *
  57381. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  57382. *
  57383. * _.result(object, 'a[0].b.c1');
  57384. * // => 3
  57385. *
  57386. * _.result(object, 'a[0].b.c2');
  57387. * // => 4
  57388. *
  57389. * _.result(object, 'a[0].b.c3', 'default');
  57390. * // => 'default'
  57391. *
  57392. * _.result(object, 'a[0].b.c3', _.constant('default'));
  57393. * // => 'default'
  57394. */
  57395. function result(object, path, defaultValue) {
  57396. path = castPath(path, object);
  57397. var index = -1,
  57398. length = path.length;
  57399. // Ensure the loop is entered when path is empty.
  57400. if (!length) {
  57401. length = 1;
  57402. object = undefined;
  57403. }
  57404. while (++index < length) {
  57405. var value = object == null ? undefined : object[toKey(path[index])];
  57406. if (value === undefined) {
  57407. index = length;
  57408. value = defaultValue;
  57409. }
  57410. object = isFunction(value) ? value.call(object) : value;
  57411. }
  57412. return object;
  57413. }
  57414. /**
  57415. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  57416. * it's created. Arrays are created for missing index properties while objects
  57417. * are created for all other missing properties. Use `_.setWith` to customize
  57418. * `path` creation.
  57419. *
  57420. * **Note:** This method mutates `object`.
  57421. *
  57422. * @static
  57423. * @memberOf _
  57424. * @since 3.7.0
  57425. * @category Object
  57426. * @param {Object} object The object to modify.
  57427. * @param {Array|string} path The path of the property to set.
  57428. * @param {*} value The value to set.
  57429. * @returns {Object} Returns `object`.
  57430. * @example
  57431. *
  57432. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  57433. *
  57434. * _.set(object, 'a[0].b.c', 4);
  57435. * console.log(object.a[0].b.c);
  57436. * // => 4
  57437. *
  57438. * _.set(object, ['x', '0', 'y', 'z'], 5);
  57439. * console.log(object.x[0].y.z);
  57440. * // => 5
  57441. */
  57442. function set(object, path, value) {
  57443. return object == null ? object : baseSet(object, path, value);
  57444. }
  57445. /**
  57446. * This method is like `_.set` except that it accepts `customizer` which is
  57447. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  57448. * path creation is handled by the method instead. The `customizer` is invoked
  57449. * with three arguments: (nsValue, key, nsObject).
  57450. *
  57451. * **Note:** This method mutates `object`.
  57452. *
  57453. * @static
  57454. * @memberOf _
  57455. * @since 4.0.0
  57456. * @category Object
  57457. * @param {Object} object The object to modify.
  57458. * @param {Array|string} path The path of the property to set.
  57459. * @param {*} value The value to set.
  57460. * @param {Function} [customizer] The function to customize assigned values.
  57461. * @returns {Object} Returns `object`.
  57462. * @example
  57463. *
  57464. * var object = {};
  57465. *
  57466. * _.setWith(object, '[0][1]', 'a', Object);
  57467. * // => { '0': { '1': 'a' } }
  57468. */
  57469. function setWith(object, path, value, customizer) {
  57470. customizer = typeof customizer == 'function' ? customizer : undefined;
  57471. return object == null ? object : baseSet(object, path, value, customizer);
  57472. }
  57473. /**
  57474. * Creates an array of own enumerable string keyed-value pairs for `object`
  57475. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  57476. * entries are returned.
  57477. *
  57478. * @static
  57479. * @memberOf _
  57480. * @since 4.0.0
  57481. * @alias entries
  57482. * @category Object
  57483. * @param {Object} object The object to query.
  57484. * @returns {Array} Returns the key-value pairs.
  57485. * @example
  57486. *
  57487. * function Foo() {
  57488. * this.a = 1;
  57489. * this.b = 2;
  57490. * }
  57491. *
  57492. * Foo.prototype.c = 3;
  57493. *
  57494. * _.toPairs(new Foo);
  57495. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  57496. */
  57497. var toPairs = createToPairs(keys);
  57498. /**
  57499. * Creates an array of own and inherited enumerable string keyed-value pairs
  57500. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  57501. * or set, its entries are returned.
  57502. *
  57503. * @static
  57504. * @memberOf _
  57505. * @since 4.0.0
  57506. * @alias entriesIn
  57507. * @category Object
  57508. * @param {Object} object The object to query.
  57509. * @returns {Array} Returns the key-value pairs.
  57510. * @example
  57511. *
  57512. * function Foo() {
  57513. * this.a = 1;
  57514. * this.b = 2;
  57515. * }
  57516. *
  57517. * Foo.prototype.c = 3;
  57518. *
  57519. * _.toPairsIn(new Foo);
  57520. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  57521. */
  57522. var toPairsIn = createToPairs(keysIn);
  57523. /**
  57524. * An alternative to `_.reduce`; this method transforms `object` to a new
  57525. * `accumulator` object which is the result of running each of its own
  57526. * enumerable string keyed properties thru `iteratee`, with each invocation
  57527. * potentially mutating the `accumulator` object. If `accumulator` is not
  57528. * provided, a new object with the same `[[Prototype]]` will be used. The
  57529. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  57530. * Iteratee functions may exit iteration early by explicitly returning `false`.
  57531. *
  57532. * @static
  57533. * @memberOf _
  57534. * @since 1.3.0
  57535. * @category Object
  57536. * @param {Object} object The object to iterate over.
  57537. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  57538. * @param {*} [accumulator] The custom accumulator value.
  57539. * @returns {*} Returns the accumulated value.
  57540. * @example
  57541. *
  57542. * _.transform([2, 3, 4], function(result, n) {
  57543. * result.push(n *= n);
  57544. * return n % 2 == 0;
  57545. * }, []);
  57546. * // => [4, 9]
  57547. *
  57548. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  57549. * (result[value] || (result[value] = [])).push(key);
  57550. * }, {});
  57551. * // => { '1': ['a', 'c'], '2': ['b'] }
  57552. */
  57553. function transform(object, iteratee, accumulator) {
  57554. var isArr = isArray(object),
  57555. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  57556. iteratee = getIteratee(iteratee, 4);
  57557. if (accumulator == null) {
  57558. var Ctor = object && object.constructor;
  57559. if (isArrLike) {
  57560. accumulator = isArr ? new Ctor : [];
  57561. }
  57562. else if (isObject(object)) {
  57563. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  57564. }
  57565. else {
  57566. accumulator = {};
  57567. }
  57568. }
  57569. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  57570. return iteratee(accumulator, value, index, object);
  57571. });
  57572. return accumulator;
  57573. }
  57574. /**
  57575. * Removes the property at `path` of `object`.
  57576. *
  57577. * **Note:** This method mutates `object`.
  57578. *
  57579. * @static
  57580. * @memberOf _
  57581. * @since 4.0.0
  57582. * @category Object
  57583. * @param {Object} object The object to modify.
  57584. * @param {Array|string} path The path of the property to unset.
  57585. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  57586. * @example
  57587. *
  57588. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  57589. * _.unset(object, 'a[0].b.c');
  57590. * // => true
  57591. *
  57592. * console.log(object);
  57593. * // => { 'a': [{ 'b': {} }] };
  57594. *
  57595. * _.unset(object, ['a', '0', 'b', 'c']);
  57596. * // => true
  57597. *
  57598. * console.log(object);
  57599. * // => { 'a': [{ 'b': {} }] };
  57600. */
  57601. function unset(object, path) {
  57602. return object == null ? true : baseUnset(object, path);
  57603. }
  57604. /**
  57605. * This method is like `_.set` except that accepts `updater` to produce the
  57606. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  57607. * is invoked with one argument: (value).
  57608. *
  57609. * **Note:** This method mutates `object`.
  57610. *
  57611. * @static
  57612. * @memberOf _
  57613. * @since 4.6.0
  57614. * @category Object
  57615. * @param {Object} object The object to modify.
  57616. * @param {Array|string} path The path of the property to set.
  57617. * @param {Function} updater The function to produce the updated value.
  57618. * @returns {Object} Returns `object`.
  57619. * @example
  57620. *
  57621. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  57622. *
  57623. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  57624. * console.log(object.a[0].b.c);
  57625. * // => 9
  57626. *
  57627. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  57628. * console.log(object.x[0].y.z);
  57629. * // => 0
  57630. */
  57631. function update(object, path, updater) {
  57632. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  57633. }
  57634. /**
  57635. * This method is like `_.update` except that it accepts `customizer` which is
  57636. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  57637. * path creation is handled by the method instead. The `customizer` is invoked
  57638. * with three arguments: (nsValue, key, nsObject).
  57639. *
  57640. * **Note:** This method mutates `object`.
  57641. *
  57642. * @static
  57643. * @memberOf _
  57644. * @since 4.6.0
  57645. * @category Object
  57646. * @param {Object} object The object to modify.
  57647. * @param {Array|string} path The path of the property to set.
  57648. * @param {Function} updater The function to produce the updated value.
  57649. * @param {Function} [customizer] The function to customize assigned values.
  57650. * @returns {Object} Returns `object`.
  57651. * @example
  57652. *
  57653. * var object = {};
  57654. *
  57655. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  57656. * // => { '0': { '1': 'a' } }
  57657. */
  57658. function updateWith(object, path, updater, customizer) {
  57659. customizer = typeof customizer == 'function' ? customizer : undefined;
  57660. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  57661. }
  57662. /**
  57663. * Creates an array of the own enumerable string keyed property values of `object`.
  57664. *
  57665. * **Note:** Non-object values are coerced to objects.
  57666. *
  57667. * @static
  57668. * @since 0.1.0
  57669. * @memberOf _
  57670. * @category Object
  57671. * @param {Object} object The object to query.
  57672. * @returns {Array} Returns the array of property values.
  57673. * @example
  57674. *
  57675. * function Foo() {
  57676. * this.a = 1;
  57677. * this.b = 2;
  57678. * }
  57679. *
  57680. * Foo.prototype.c = 3;
  57681. *
  57682. * _.values(new Foo);
  57683. * // => [1, 2] (iteration order is not guaranteed)
  57684. *
  57685. * _.values('hi');
  57686. * // => ['h', 'i']
  57687. */
  57688. function values(object) {
  57689. return object == null ? [] : baseValues(object, keys(object));
  57690. }
  57691. /**
  57692. * Creates an array of the own and inherited enumerable string keyed property
  57693. * values of `object`.
  57694. *
  57695. * **Note:** Non-object values are coerced to objects.
  57696. *
  57697. * @static
  57698. * @memberOf _
  57699. * @since 3.0.0
  57700. * @category Object
  57701. * @param {Object} object The object to query.
  57702. * @returns {Array} Returns the array of property values.
  57703. * @example
  57704. *
  57705. * function Foo() {
  57706. * this.a = 1;
  57707. * this.b = 2;
  57708. * }
  57709. *
  57710. * Foo.prototype.c = 3;
  57711. *
  57712. * _.valuesIn(new Foo);
  57713. * // => [1, 2, 3] (iteration order is not guaranteed)
  57714. */
  57715. function valuesIn(object) {
  57716. return object == null ? [] : baseValues(object, keysIn(object));
  57717. }
  57718. /*------------------------------------------------------------------------*/
  57719. /**
  57720. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  57721. *
  57722. * @static
  57723. * @memberOf _
  57724. * @since 4.0.0
  57725. * @category Number
  57726. * @param {number} number The number to clamp.
  57727. * @param {number} [lower] The lower bound.
  57728. * @param {number} upper The upper bound.
  57729. * @returns {number} Returns the clamped number.
  57730. * @example
  57731. *
  57732. * _.clamp(-10, -5, 5);
  57733. * // => -5
  57734. *
  57735. * _.clamp(10, -5, 5);
  57736. * // => 5
  57737. */
  57738. function clamp(number, lower, upper) {
  57739. if (upper === undefined) {
  57740. upper = lower;
  57741. lower = undefined;
  57742. }
  57743. if (upper !== undefined) {
  57744. upper = toNumber(upper);
  57745. upper = upper === upper ? upper : 0;
  57746. }
  57747. if (lower !== undefined) {
  57748. lower = toNumber(lower);
  57749. lower = lower === lower ? lower : 0;
  57750. }
  57751. return baseClamp(toNumber(number), lower, upper);
  57752. }
  57753. /**
  57754. * Checks if `n` is between `start` and up to, but not including, `end`. If
  57755. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  57756. * If `start` is greater than `end` the params are swapped to support
  57757. * negative ranges.
  57758. *
  57759. * @static
  57760. * @memberOf _
  57761. * @since 3.3.0
  57762. * @category Number
  57763. * @param {number} number The number to check.
  57764. * @param {number} [start=0] The start of the range.
  57765. * @param {number} end The end of the range.
  57766. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  57767. * @see _.range, _.rangeRight
  57768. * @example
  57769. *
  57770. * _.inRange(3, 2, 4);
  57771. * // => true
  57772. *
  57773. * _.inRange(4, 8);
  57774. * // => true
  57775. *
  57776. * _.inRange(4, 2);
  57777. * // => false
  57778. *
  57779. * _.inRange(2, 2);
  57780. * // => false
  57781. *
  57782. * _.inRange(1.2, 2);
  57783. * // => true
  57784. *
  57785. * _.inRange(5.2, 4);
  57786. * // => false
  57787. *
  57788. * _.inRange(-3, -2, -6);
  57789. * // => true
  57790. */
  57791. function inRange(number, start, end) {
  57792. start = toFinite(start);
  57793. if (end === undefined) {
  57794. end = start;
  57795. start = 0;
  57796. } else {
  57797. end = toFinite(end);
  57798. }
  57799. number = toNumber(number);
  57800. return baseInRange(number, start, end);
  57801. }
  57802. /**
  57803. * Produces a random number between the inclusive `lower` and `upper` bounds.
  57804. * If only one argument is provided a number between `0` and the given number
  57805. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  57806. * floats, a floating-point number is returned instead of an integer.
  57807. *
  57808. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  57809. * floating-point values which can produce unexpected results.
  57810. *
  57811. * @static
  57812. * @memberOf _
  57813. * @since 0.7.0
  57814. * @category Number
  57815. * @param {number} [lower=0] The lower bound.
  57816. * @param {number} [upper=1] The upper bound.
  57817. * @param {boolean} [floating] Specify returning a floating-point number.
  57818. * @returns {number} Returns the random number.
  57819. * @example
  57820. *
  57821. * _.random(0, 5);
  57822. * // => an integer between 0 and 5
  57823. *
  57824. * _.random(5);
  57825. * // => also an integer between 0 and 5
  57826. *
  57827. * _.random(5, true);
  57828. * // => a floating-point number between 0 and 5
  57829. *
  57830. * _.random(1.2, 5.2);
  57831. * // => a floating-point number between 1.2 and 5.2
  57832. */
  57833. function random(lower, upper, floating) {
  57834. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  57835. upper = floating = undefined;
  57836. }
  57837. if (floating === undefined) {
  57838. if (typeof upper == 'boolean') {
  57839. floating = upper;
  57840. upper = undefined;
  57841. }
  57842. else if (typeof lower == 'boolean') {
  57843. floating = lower;
  57844. lower = undefined;
  57845. }
  57846. }
  57847. if (lower === undefined && upper === undefined) {
  57848. lower = 0;
  57849. upper = 1;
  57850. }
  57851. else {
  57852. lower = toFinite(lower);
  57853. if (upper === undefined) {
  57854. upper = lower;
  57855. lower = 0;
  57856. } else {
  57857. upper = toFinite(upper);
  57858. }
  57859. }
  57860. if (lower > upper) {
  57861. var temp = lower;
  57862. lower = upper;
  57863. upper = temp;
  57864. }
  57865. if (floating || lower % 1 || upper % 1) {
  57866. var rand = nativeRandom();
  57867. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  57868. }
  57869. return baseRandom(lower, upper);
  57870. }
  57871. /*------------------------------------------------------------------------*/
  57872. /**
  57873. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  57874. *
  57875. * @static
  57876. * @memberOf _
  57877. * @since 3.0.0
  57878. * @category String
  57879. * @param {string} [string=''] The string to convert.
  57880. * @returns {string} Returns the camel cased string.
  57881. * @example
  57882. *
  57883. * _.camelCase('Foo Bar');
  57884. * // => 'fooBar'
  57885. *
  57886. * _.camelCase('--foo-bar--');
  57887. * // => 'fooBar'
  57888. *
  57889. * _.camelCase('__FOO_BAR__');
  57890. * // => 'fooBar'
  57891. */
  57892. var camelCase = createCompounder(function(result, word, index) {
  57893. word = word.toLowerCase();
  57894. return result + (index ? capitalize(word) : word);
  57895. });
  57896. /**
  57897. * Converts the first character of `string` to upper case and the remaining
  57898. * to lower case.
  57899. *
  57900. * @static
  57901. * @memberOf _
  57902. * @since 3.0.0
  57903. * @category String
  57904. * @param {string} [string=''] The string to capitalize.
  57905. * @returns {string} Returns the capitalized string.
  57906. * @example
  57907. *
  57908. * _.capitalize('FRED');
  57909. * // => 'Fred'
  57910. */
  57911. function capitalize(string) {
  57912. return upperFirst(toString(string).toLowerCase());
  57913. }
  57914. /**
  57915. * Deburrs `string` by converting
  57916. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  57917. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  57918. * letters to basic Latin letters and removing
  57919. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  57920. *
  57921. * @static
  57922. * @memberOf _
  57923. * @since 3.0.0
  57924. * @category String
  57925. * @param {string} [string=''] The string to deburr.
  57926. * @returns {string} Returns the deburred string.
  57927. * @example
  57928. *
  57929. * _.deburr('déjà vu');
  57930. * // => 'deja vu'
  57931. */
  57932. function deburr(string) {
  57933. string = toString(string);
  57934. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  57935. }
  57936. /**
  57937. * Checks if `string` ends with the given target string.
  57938. *
  57939. * @static
  57940. * @memberOf _
  57941. * @since 3.0.0
  57942. * @category String
  57943. * @param {string} [string=''] The string to inspect.
  57944. * @param {string} [target] The string to search for.
  57945. * @param {number} [position=string.length] The position to search up to.
  57946. * @returns {boolean} Returns `true` if `string` ends with `target`,
  57947. * else `false`.
  57948. * @example
  57949. *
  57950. * _.endsWith('abc', 'c');
  57951. * // => true
  57952. *
  57953. * _.endsWith('abc', 'b');
  57954. * // => false
  57955. *
  57956. * _.endsWith('abc', 'b', 2);
  57957. * // => true
  57958. */
  57959. function endsWith(string, target, position) {
  57960. string = toString(string);
  57961. target = baseToString(target);
  57962. var length = string.length;
  57963. position = position === undefined
  57964. ? length
  57965. : baseClamp(toInteger(position), 0, length);
  57966. var end = position;
  57967. position -= target.length;
  57968. return position >= 0 && string.slice(position, end) == target;
  57969. }
  57970. /**
  57971. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  57972. * corresponding HTML entities.
  57973. *
  57974. * **Note:** No other characters are escaped. To escape additional
  57975. * characters use a third-party library like [_he_](https://mths.be/he).
  57976. *
  57977. * Though the ">" character is escaped for symmetry, characters like
  57978. * ">" and "/" don't need escaping in HTML and have no special meaning
  57979. * unless they're part of a tag or unquoted attribute value. See
  57980. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  57981. * (under "semi-related fun fact") for more details.
  57982. *
  57983. * When working with HTML you should always
  57984. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  57985. * XSS vectors.
  57986. *
  57987. * @static
  57988. * @since 0.1.0
  57989. * @memberOf _
  57990. * @category String
  57991. * @param {string} [string=''] The string to escape.
  57992. * @returns {string} Returns the escaped string.
  57993. * @example
  57994. *
  57995. * _.escape('fred, barney, & pebbles');
  57996. * // => 'fred, barney, &amp; pebbles'
  57997. */
  57998. function escape(string) {
  57999. string = toString(string);
  58000. return (string && reHasUnescapedHtml.test(string))
  58001. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  58002. : string;
  58003. }
  58004. /**
  58005. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  58006. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  58007. *
  58008. * @static
  58009. * @memberOf _
  58010. * @since 3.0.0
  58011. * @category String
  58012. * @param {string} [string=''] The string to escape.
  58013. * @returns {string} Returns the escaped string.
  58014. * @example
  58015. *
  58016. * _.escapeRegExp('[lodash](https://lodash.com/)');
  58017. * // => '\[lodash\]\(https://lodash\.com/\)'
  58018. */
  58019. function escapeRegExp(string) {
  58020. string = toString(string);
  58021. return (string && reHasRegExpChar.test(string))
  58022. ? string.replace(reRegExpChar, '\\$&')
  58023. : string;
  58024. }
  58025. /**
  58026. * Converts `string` to
  58027. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  58028. *
  58029. * @static
  58030. * @memberOf _
  58031. * @since 3.0.0
  58032. * @category String
  58033. * @param {string} [string=''] The string to convert.
  58034. * @returns {string} Returns the kebab cased string.
  58035. * @example
  58036. *
  58037. * _.kebabCase('Foo Bar');
  58038. * // => 'foo-bar'
  58039. *
  58040. * _.kebabCase('fooBar');
  58041. * // => 'foo-bar'
  58042. *
  58043. * _.kebabCase('__FOO_BAR__');
  58044. * // => 'foo-bar'
  58045. */
  58046. var kebabCase = createCompounder(function(result, word, index) {
  58047. return result + (index ? '-' : '') + word.toLowerCase();
  58048. });
  58049. /**
  58050. * Converts `string`, as space separated words, to lower case.
  58051. *
  58052. * @static
  58053. * @memberOf _
  58054. * @since 4.0.0
  58055. * @category String
  58056. * @param {string} [string=''] The string to convert.
  58057. * @returns {string} Returns the lower cased string.
  58058. * @example
  58059. *
  58060. * _.lowerCase('--Foo-Bar--');
  58061. * // => 'foo bar'
  58062. *
  58063. * _.lowerCase('fooBar');
  58064. * // => 'foo bar'
  58065. *
  58066. * _.lowerCase('__FOO_BAR__');
  58067. * // => 'foo bar'
  58068. */
  58069. var lowerCase = createCompounder(function(result, word, index) {
  58070. return result + (index ? ' ' : '') + word.toLowerCase();
  58071. });
  58072. /**
  58073. * Converts the first character of `string` to lower case.
  58074. *
  58075. * @static
  58076. * @memberOf _
  58077. * @since 4.0.0
  58078. * @category String
  58079. * @param {string} [string=''] The string to convert.
  58080. * @returns {string} Returns the converted string.
  58081. * @example
  58082. *
  58083. * _.lowerFirst('Fred');
  58084. * // => 'fred'
  58085. *
  58086. * _.lowerFirst('FRED');
  58087. * // => 'fRED'
  58088. */
  58089. var lowerFirst = createCaseFirst('toLowerCase');
  58090. /**
  58091. * Pads `string` on the left and right sides if it's shorter than `length`.
  58092. * Padding characters are truncated if they can't be evenly divided by `length`.
  58093. *
  58094. * @static
  58095. * @memberOf _
  58096. * @since 3.0.0
  58097. * @category String
  58098. * @param {string} [string=''] The string to pad.
  58099. * @param {number} [length=0] The padding length.
  58100. * @param {string} [chars=' '] The string used as padding.
  58101. * @returns {string} Returns the padded string.
  58102. * @example
  58103. *
  58104. * _.pad('abc', 8);
  58105. * // => ' abc '
  58106. *
  58107. * _.pad('abc', 8, '_-');
  58108. * // => '_-abc_-_'
  58109. *
  58110. * _.pad('abc', 3);
  58111. * // => 'abc'
  58112. */
  58113. function pad(string, length, chars) {
  58114. string = toString(string);
  58115. length = toInteger(length);
  58116. var strLength = length ? stringSize(string) : 0;
  58117. if (!length || strLength >= length) {
  58118. return string;
  58119. }
  58120. var mid = (length - strLength) / 2;
  58121. return (
  58122. createPadding(nativeFloor(mid), chars) +
  58123. string +
  58124. createPadding(nativeCeil(mid), chars)
  58125. );
  58126. }
  58127. /**
  58128. * Pads `string` on the right side if it's shorter than `length`. Padding
  58129. * characters are truncated if they exceed `length`.
  58130. *
  58131. * @static
  58132. * @memberOf _
  58133. * @since 4.0.0
  58134. * @category String
  58135. * @param {string} [string=''] The string to pad.
  58136. * @param {number} [length=0] The padding length.
  58137. * @param {string} [chars=' '] The string used as padding.
  58138. * @returns {string} Returns the padded string.
  58139. * @example
  58140. *
  58141. * _.padEnd('abc', 6);
  58142. * // => 'abc '
  58143. *
  58144. * _.padEnd('abc', 6, '_-');
  58145. * // => 'abc_-_'
  58146. *
  58147. * _.padEnd('abc', 3);
  58148. * // => 'abc'
  58149. */
  58150. function padEnd(string, length, chars) {
  58151. string = toString(string);
  58152. length = toInteger(length);
  58153. var strLength = length ? stringSize(string) : 0;
  58154. return (length && strLength < length)
  58155. ? (string + createPadding(length - strLength, chars))
  58156. : string;
  58157. }
  58158. /**
  58159. * Pads `string` on the left side if it's shorter than `length`. Padding
  58160. * characters are truncated if they exceed `length`.
  58161. *
  58162. * @static
  58163. * @memberOf _
  58164. * @since 4.0.0
  58165. * @category String
  58166. * @param {string} [string=''] The string to pad.
  58167. * @param {number} [length=0] The padding length.
  58168. * @param {string} [chars=' '] The string used as padding.
  58169. * @returns {string} Returns the padded string.
  58170. * @example
  58171. *
  58172. * _.padStart('abc', 6);
  58173. * // => ' abc'
  58174. *
  58175. * _.padStart('abc', 6, '_-');
  58176. * // => '_-_abc'
  58177. *
  58178. * _.padStart('abc', 3);
  58179. * // => 'abc'
  58180. */
  58181. function padStart(string, length, chars) {
  58182. string = toString(string);
  58183. length = toInteger(length);
  58184. var strLength = length ? stringSize(string) : 0;
  58185. return (length && strLength < length)
  58186. ? (createPadding(length - strLength, chars) + string)
  58187. : string;
  58188. }
  58189. /**
  58190. * Converts `string` to an integer of the specified radix. If `radix` is
  58191. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  58192. * hexadecimal, in which case a `radix` of `16` is used.
  58193. *
  58194. * **Note:** This method aligns with the
  58195. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  58196. *
  58197. * @static
  58198. * @memberOf _
  58199. * @since 1.1.0
  58200. * @category String
  58201. * @param {string} string The string to convert.
  58202. * @param {number} [radix=10] The radix to interpret `value` by.
  58203. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58204. * @returns {number} Returns the converted integer.
  58205. * @example
  58206. *
  58207. * _.parseInt('08');
  58208. * // => 8
  58209. *
  58210. * _.map(['6', '08', '10'], _.parseInt);
  58211. * // => [6, 8, 10]
  58212. */
  58213. function parseInt(string, radix, guard) {
  58214. if (guard || radix == null) {
  58215. radix = 0;
  58216. } else if (radix) {
  58217. radix = +radix;
  58218. }
  58219. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  58220. }
  58221. /**
  58222. * Repeats the given string `n` times.
  58223. *
  58224. * @static
  58225. * @memberOf _
  58226. * @since 3.0.0
  58227. * @category String
  58228. * @param {string} [string=''] The string to repeat.
  58229. * @param {number} [n=1] The number of times to repeat the string.
  58230. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58231. * @returns {string} Returns the repeated string.
  58232. * @example
  58233. *
  58234. * _.repeat('*', 3);
  58235. * // => '***'
  58236. *
  58237. * _.repeat('abc', 2);
  58238. * // => 'abcabc'
  58239. *
  58240. * _.repeat('abc', 0);
  58241. * // => ''
  58242. */
  58243. function repeat(string, n, guard) {
  58244. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  58245. n = 1;
  58246. } else {
  58247. n = toInteger(n);
  58248. }
  58249. return baseRepeat(toString(string), n);
  58250. }
  58251. /**
  58252. * Replaces matches for `pattern` in `string` with `replacement`.
  58253. *
  58254. * **Note:** This method is based on
  58255. * [`String#replace`](https://mdn.io/String/replace).
  58256. *
  58257. * @static
  58258. * @memberOf _
  58259. * @since 4.0.0
  58260. * @category String
  58261. * @param {string} [string=''] The string to modify.
  58262. * @param {RegExp|string} pattern The pattern to replace.
  58263. * @param {Function|string} replacement The match replacement.
  58264. * @returns {string} Returns the modified string.
  58265. * @example
  58266. *
  58267. * _.replace('Hi Fred', 'Fred', 'Barney');
  58268. * // => 'Hi Barney'
  58269. */
  58270. function replace() {
  58271. var args = arguments,
  58272. string = toString(args[0]);
  58273. return args.length < 3 ? string : string.replace(args[1], args[2]);
  58274. }
  58275. /**
  58276. * Converts `string` to
  58277. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  58278. *
  58279. * @static
  58280. * @memberOf _
  58281. * @since 3.0.0
  58282. * @category String
  58283. * @param {string} [string=''] The string to convert.
  58284. * @returns {string} Returns the snake cased string.
  58285. * @example
  58286. *
  58287. * _.snakeCase('Foo Bar');
  58288. * // => 'foo_bar'
  58289. *
  58290. * _.snakeCase('fooBar');
  58291. * // => 'foo_bar'
  58292. *
  58293. * _.snakeCase('--FOO-BAR--');
  58294. * // => 'foo_bar'
  58295. */
  58296. var snakeCase = createCompounder(function(result, word, index) {
  58297. return result + (index ? '_' : '') + word.toLowerCase();
  58298. });
  58299. /**
  58300. * Splits `string` by `separator`.
  58301. *
  58302. * **Note:** This method is based on
  58303. * [`String#split`](https://mdn.io/String/split).
  58304. *
  58305. * @static
  58306. * @memberOf _
  58307. * @since 4.0.0
  58308. * @category String
  58309. * @param {string} [string=''] The string to split.
  58310. * @param {RegExp|string} separator The separator pattern to split by.
  58311. * @param {number} [limit] The length to truncate results to.
  58312. * @returns {Array} Returns the string segments.
  58313. * @example
  58314. *
  58315. * _.split('a-b-c', '-', 2);
  58316. * // => ['a', 'b']
  58317. */
  58318. function split(string, separator, limit) {
  58319. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  58320. separator = limit = undefined;
  58321. }
  58322. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  58323. if (!limit) {
  58324. return [];
  58325. }
  58326. string = toString(string);
  58327. if (string && (
  58328. typeof separator == 'string' ||
  58329. (separator != null && !isRegExp(separator))
  58330. )) {
  58331. separator = baseToString(separator);
  58332. if (!separator && hasUnicode(string)) {
  58333. return castSlice(stringToArray(string), 0, limit);
  58334. }
  58335. }
  58336. return string.split(separator, limit);
  58337. }
  58338. /**
  58339. * Converts `string` to
  58340. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  58341. *
  58342. * @static
  58343. * @memberOf _
  58344. * @since 3.1.0
  58345. * @category String
  58346. * @param {string} [string=''] The string to convert.
  58347. * @returns {string} Returns the start cased string.
  58348. * @example
  58349. *
  58350. * _.startCase('--foo-bar--');
  58351. * // => 'Foo Bar'
  58352. *
  58353. * _.startCase('fooBar');
  58354. * // => 'Foo Bar'
  58355. *
  58356. * _.startCase('__FOO_BAR__');
  58357. * // => 'FOO BAR'
  58358. */
  58359. var startCase = createCompounder(function(result, word, index) {
  58360. return result + (index ? ' ' : '') + upperFirst(word);
  58361. });
  58362. /**
  58363. * Checks if `string` starts with the given target string.
  58364. *
  58365. * @static
  58366. * @memberOf _
  58367. * @since 3.0.0
  58368. * @category String
  58369. * @param {string} [string=''] The string to inspect.
  58370. * @param {string} [target] The string to search for.
  58371. * @param {number} [position=0] The position to search from.
  58372. * @returns {boolean} Returns `true` if `string` starts with `target`,
  58373. * else `false`.
  58374. * @example
  58375. *
  58376. * _.startsWith('abc', 'a');
  58377. * // => true
  58378. *
  58379. * _.startsWith('abc', 'b');
  58380. * // => false
  58381. *
  58382. * _.startsWith('abc', 'b', 1);
  58383. * // => true
  58384. */
  58385. function startsWith(string, target, position) {
  58386. string = toString(string);
  58387. position = position == null
  58388. ? 0
  58389. : baseClamp(toInteger(position), 0, string.length);
  58390. target = baseToString(target);
  58391. return string.slice(position, position + target.length) == target;
  58392. }
  58393. /**
  58394. * Creates a compiled template function that can interpolate data properties
  58395. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  58396. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  58397. * properties may be accessed as free variables in the template. If a setting
  58398. * object is given, it takes precedence over `_.templateSettings` values.
  58399. *
  58400. * **Note:** In the development build `_.template` utilizes
  58401. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  58402. * for easier debugging.
  58403. *
  58404. * For more information on precompiling templates see
  58405. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  58406. *
  58407. * For more information on Chrome extension sandboxes see
  58408. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  58409. *
  58410. * @static
  58411. * @since 0.1.0
  58412. * @memberOf _
  58413. * @category String
  58414. * @param {string} [string=''] The template string.
  58415. * @param {Object} [options={}] The options object.
  58416. * @param {RegExp} [options.escape=_.templateSettings.escape]
  58417. * The HTML "escape" delimiter.
  58418. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  58419. * The "evaluate" delimiter.
  58420. * @param {Object} [options.imports=_.templateSettings.imports]
  58421. * An object to import into the template as free variables.
  58422. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  58423. * The "interpolate" delimiter.
  58424. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  58425. * The sourceURL of the compiled template.
  58426. * @param {string} [options.variable='obj']
  58427. * The data object variable name.
  58428. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58429. * @returns {Function} Returns the compiled template function.
  58430. * @example
  58431. *
  58432. * // Use the "interpolate" delimiter to create a compiled template.
  58433. * var compiled = _.template('hello <%= user %>!');
  58434. * compiled({ 'user': 'fred' });
  58435. * // => 'hello fred!'
  58436. *
  58437. * // Use the HTML "escape" delimiter to escape data property values.
  58438. * var compiled = _.template('<b><%- value %></b>');
  58439. * compiled({ 'value': '<script>' });
  58440. * // => '<b>&lt;script&gt;</b>'
  58441. *
  58442. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  58443. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  58444. * compiled({ 'users': ['fred', 'barney'] });
  58445. * // => '<li>fred</li><li>barney</li>'
  58446. *
  58447. * // Use the internal `print` function in "evaluate" delimiters.
  58448. * var compiled = _.template('<% print("hello " + user); %>!');
  58449. * compiled({ 'user': 'barney' });
  58450. * // => 'hello barney!'
  58451. *
  58452. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  58453. * // Disable support by replacing the "interpolate" delimiter.
  58454. * var compiled = _.template('hello ${ user }!');
  58455. * compiled({ 'user': 'pebbles' });
  58456. * // => 'hello pebbles!'
  58457. *
  58458. * // Use backslashes to treat delimiters as plain text.
  58459. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  58460. * compiled({ 'value': 'ignored' });
  58461. * // => '<%- value %>'
  58462. *
  58463. * // Use the `imports` option to import `jQuery` as `jq`.
  58464. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  58465. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  58466. * compiled({ 'users': ['fred', 'barney'] });
  58467. * // => '<li>fred</li><li>barney</li>'
  58468. *
  58469. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  58470. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  58471. * compiled(data);
  58472. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  58473. *
  58474. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  58475. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  58476. * compiled.source;
  58477. * // => function(data) {
  58478. * // var __t, __p = '';
  58479. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  58480. * // return __p;
  58481. * // }
  58482. *
  58483. * // Use custom template delimiters.
  58484. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  58485. * var compiled = _.template('hello {{ user }}!');
  58486. * compiled({ 'user': 'mustache' });
  58487. * // => 'hello mustache!'
  58488. *
  58489. * // Use the `source` property to inline compiled templates for meaningful
  58490. * // line numbers in error messages and stack traces.
  58491. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  58492. * var JST = {\
  58493. * "main": ' + _.template(mainText).source + '\
  58494. * };\
  58495. * ');
  58496. */
  58497. function template(string, options, guard) {
  58498. // Based on John Resig's `tmpl` implementation
  58499. // (http://ejohn.org/blog/javascript-micro-templating/)
  58500. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  58501. var settings = lodash.templateSettings;
  58502. if (guard && isIterateeCall(string, options, guard)) {
  58503. options = undefined;
  58504. }
  58505. string = toString(string);
  58506. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  58507. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  58508. importsKeys = keys(imports),
  58509. importsValues = baseValues(imports, importsKeys);
  58510. var isEscaping,
  58511. isEvaluating,
  58512. index = 0,
  58513. interpolate = options.interpolate || reNoMatch,
  58514. source = "__p += '";
  58515. // Compile the regexp to match each delimiter.
  58516. var reDelimiters = RegExp(
  58517. (options.escape || reNoMatch).source + '|' +
  58518. interpolate.source + '|' +
  58519. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  58520. (options.evaluate || reNoMatch).source + '|$'
  58521. , 'g');
  58522. // Use a sourceURL for easier debugging.
  58523. // The sourceURL gets injected into the source that's eval-ed, so be careful
  58524. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  58525. // and escape the comment, thus injecting code that gets evaled.
  58526. var sourceURL = '//# sourceURL=' +
  58527. (hasOwnProperty.call(options, 'sourceURL')
  58528. ? (options.sourceURL + '').replace(/\s/g, ' ')
  58529. : ('lodash.templateSources[' + (++templateCounter) + ']')
  58530. ) + '\n';
  58531. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  58532. interpolateValue || (interpolateValue = esTemplateValue);
  58533. // Escape characters that can't be included in string literals.
  58534. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  58535. // Replace delimiters with snippets.
  58536. if (escapeValue) {
  58537. isEscaping = true;
  58538. source += "' +\n__e(" + escapeValue + ") +\n'";
  58539. }
  58540. if (evaluateValue) {
  58541. isEvaluating = true;
  58542. source += "';\n" + evaluateValue + ";\n__p += '";
  58543. }
  58544. if (interpolateValue) {
  58545. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  58546. }
  58547. index = offset + match.length;
  58548. // The JS engine embedded in Adobe products needs `match` returned in
  58549. // order to produce the correct `offset` value.
  58550. return match;
  58551. });
  58552. source += "';\n";
  58553. // If `variable` is not specified wrap a with-statement around the generated
  58554. // code to add the data object to the top of the scope chain.
  58555. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  58556. if (!variable) {
  58557. source = 'with (obj) {\n' + source + '\n}\n';
  58558. }
  58559. // Throw an error if a forbidden character was found in `variable`, to prevent
  58560. // potential command injection attacks.
  58561. else if (reForbiddenIdentifierChars.test(variable)) {
  58562. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  58563. }
  58564. // Cleanup code by stripping empty strings.
  58565. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  58566. .replace(reEmptyStringMiddle, '$1')
  58567. .replace(reEmptyStringTrailing, '$1;');
  58568. // Frame code as the function body.
  58569. source = 'function(' + (variable || 'obj') + ') {\n' +
  58570. (variable
  58571. ? ''
  58572. : 'obj || (obj = {});\n'
  58573. ) +
  58574. "var __t, __p = ''" +
  58575. (isEscaping
  58576. ? ', __e = _.escape'
  58577. : ''
  58578. ) +
  58579. (isEvaluating
  58580. ? ', __j = Array.prototype.join;\n' +
  58581. "function print() { __p += __j.call(arguments, '') }\n"
  58582. : ';\n'
  58583. ) +
  58584. source +
  58585. 'return __p\n}';
  58586. var result = attempt(function() {
  58587. return Function(importsKeys, sourceURL + 'return ' + source)
  58588. .apply(undefined, importsValues);
  58589. });
  58590. // Provide the compiled function's source by its `toString` method or
  58591. // the `source` property as a convenience for inlining compiled templates.
  58592. result.source = source;
  58593. if (isError(result)) {
  58594. throw result;
  58595. }
  58596. return result;
  58597. }
  58598. /**
  58599. * Converts `string`, as a whole, to lower case just like
  58600. * [String#toLowerCase](https://mdn.io/toLowerCase).
  58601. *
  58602. * @static
  58603. * @memberOf _
  58604. * @since 4.0.0
  58605. * @category String
  58606. * @param {string} [string=''] The string to convert.
  58607. * @returns {string} Returns the lower cased string.
  58608. * @example
  58609. *
  58610. * _.toLower('--Foo-Bar--');
  58611. * // => '--foo-bar--'
  58612. *
  58613. * _.toLower('fooBar');
  58614. * // => 'foobar'
  58615. *
  58616. * _.toLower('__FOO_BAR__');
  58617. * // => '__foo_bar__'
  58618. */
  58619. function toLower(value) {
  58620. return toString(value).toLowerCase();
  58621. }
  58622. /**
  58623. * Converts `string`, as a whole, to upper case just like
  58624. * [String#toUpperCase](https://mdn.io/toUpperCase).
  58625. *
  58626. * @static
  58627. * @memberOf _
  58628. * @since 4.0.0
  58629. * @category String
  58630. * @param {string} [string=''] The string to convert.
  58631. * @returns {string} Returns the upper cased string.
  58632. * @example
  58633. *
  58634. * _.toUpper('--foo-bar--');
  58635. * // => '--FOO-BAR--'
  58636. *
  58637. * _.toUpper('fooBar');
  58638. * // => 'FOOBAR'
  58639. *
  58640. * _.toUpper('__foo_bar__');
  58641. * // => '__FOO_BAR__'
  58642. */
  58643. function toUpper(value) {
  58644. return toString(value).toUpperCase();
  58645. }
  58646. /**
  58647. * Removes leading and trailing whitespace or specified characters from `string`.
  58648. *
  58649. * @static
  58650. * @memberOf _
  58651. * @since 3.0.0
  58652. * @category String
  58653. * @param {string} [string=''] The string to trim.
  58654. * @param {string} [chars=whitespace] The characters to trim.
  58655. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58656. * @returns {string} Returns the trimmed string.
  58657. * @example
  58658. *
  58659. * _.trim(' abc ');
  58660. * // => 'abc'
  58661. *
  58662. * _.trim('-_-abc-_-', '_-');
  58663. * // => 'abc'
  58664. *
  58665. * _.map([' foo ', ' bar '], _.trim);
  58666. * // => ['foo', 'bar']
  58667. */
  58668. function trim(string, chars, guard) {
  58669. string = toString(string);
  58670. if (string && (guard || chars === undefined)) {
  58671. return baseTrim(string);
  58672. }
  58673. if (!string || !(chars = baseToString(chars))) {
  58674. return string;
  58675. }
  58676. var strSymbols = stringToArray(string),
  58677. chrSymbols = stringToArray(chars),
  58678. start = charsStartIndex(strSymbols, chrSymbols),
  58679. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  58680. return castSlice(strSymbols, start, end).join('');
  58681. }
  58682. /**
  58683. * Removes trailing whitespace or specified characters from `string`.
  58684. *
  58685. * @static
  58686. * @memberOf _
  58687. * @since 4.0.0
  58688. * @category String
  58689. * @param {string} [string=''] The string to trim.
  58690. * @param {string} [chars=whitespace] The characters to trim.
  58691. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58692. * @returns {string} Returns the trimmed string.
  58693. * @example
  58694. *
  58695. * _.trimEnd(' abc ');
  58696. * // => ' abc'
  58697. *
  58698. * _.trimEnd('-_-abc-_-', '_-');
  58699. * // => '-_-abc'
  58700. */
  58701. function trimEnd(string, chars, guard) {
  58702. string = toString(string);
  58703. if (string && (guard || chars === undefined)) {
  58704. return string.slice(0, trimmedEndIndex(string) + 1);
  58705. }
  58706. if (!string || !(chars = baseToString(chars))) {
  58707. return string;
  58708. }
  58709. var strSymbols = stringToArray(string),
  58710. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  58711. return castSlice(strSymbols, 0, end).join('');
  58712. }
  58713. /**
  58714. * Removes leading whitespace or specified characters from `string`.
  58715. *
  58716. * @static
  58717. * @memberOf _
  58718. * @since 4.0.0
  58719. * @category String
  58720. * @param {string} [string=''] The string to trim.
  58721. * @param {string} [chars=whitespace] The characters to trim.
  58722. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58723. * @returns {string} Returns the trimmed string.
  58724. * @example
  58725. *
  58726. * _.trimStart(' abc ');
  58727. * // => 'abc '
  58728. *
  58729. * _.trimStart('-_-abc-_-', '_-');
  58730. * // => 'abc-_-'
  58731. */
  58732. function trimStart(string, chars, guard) {
  58733. string = toString(string);
  58734. if (string && (guard || chars === undefined)) {
  58735. return string.replace(reTrimStart, '');
  58736. }
  58737. if (!string || !(chars = baseToString(chars))) {
  58738. return string;
  58739. }
  58740. var strSymbols = stringToArray(string),
  58741. start = charsStartIndex(strSymbols, stringToArray(chars));
  58742. return castSlice(strSymbols, start).join('');
  58743. }
  58744. /**
  58745. * Truncates `string` if it's longer than the given maximum string length.
  58746. * The last characters of the truncated string are replaced with the omission
  58747. * string which defaults to "...".
  58748. *
  58749. * @static
  58750. * @memberOf _
  58751. * @since 4.0.0
  58752. * @category String
  58753. * @param {string} [string=''] The string to truncate.
  58754. * @param {Object} [options={}] The options object.
  58755. * @param {number} [options.length=30] The maximum string length.
  58756. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  58757. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  58758. * @returns {string} Returns the truncated string.
  58759. * @example
  58760. *
  58761. * _.truncate('hi-diddly-ho there, neighborino');
  58762. * // => 'hi-diddly-ho there, neighbo...'
  58763. *
  58764. * _.truncate('hi-diddly-ho there, neighborino', {
  58765. * 'length': 24,
  58766. * 'separator': ' '
  58767. * });
  58768. * // => 'hi-diddly-ho there,...'
  58769. *
  58770. * _.truncate('hi-diddly-ho there, neighborino', {
  58771. * 'length': 24,
  58772. * 'separator': /,? +/
  58773. * });
  58774. * // => 'hi-diddly-ho there...'
  58775. *
  58776. * _.truncate('hi-diddly-ho there, neighborino', {
  58777. * 'omission': ' [...]'
  58778. * });
  58779. * // => 'hi-diddly-ho there, neig [...]'
  58780. */
  58781. function truncate(string, options) {
  58782. var length = DEFAULT_TRUNC_LENGTH,
  58783. omission = DEFAULT_TRUNC_OMISSION;
  58784. if (isObject(options)) {
  58785. var separator = 'separator' in options ? options.separator : separator;
  58786. length = 'length' in options ? toInteger(options.length) : length;
  58787. omission = 'omission' in options ? baseToString(options.omission) : omission;
  58788. }
  58789. string = toString(string);
  58790. var strLength = string.length;
  58791. if (hasUnicode(string)) {
  58792. var strSymbols = stringToArray(string);
  58793. strLength = strSymbols.length;
  58794. }
  58795. if (length >= strLength) {
  58796. return string;
  58797. }
  58798. var end = length - stringSize(omission);
  58799. if (end < 1) {
  58800. return omission;
  58801. }
  58802. var result = strSymbols
  58803. ? castSlice(strSymbols, 0, end).join('')
  58804. : string.slice(0, end);
  58805. if (separator === undefined) {
  58806. return result + omission;
  58807. }
  58808. if (strSymbols) {
  58809. end += (result.length - end);
  58810. }
  58811. if (isRegExp(separator)) {
  58812. if (string.slice(end).search(separator)) {
  58813. var match,
  58814. substring = result;
  58815. if (!separator.global) {
  58816. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  58817. }
  58818. separator.lastIndex = 0;
  58819. while ((match = separator.exec(substring))) {
  58820. var newEnd = match.index;
  58821. }
  58822. result = result.slice(0, newEnd === undefined ? end : newEnd);
  58823. }
  58824. } else if (string.indexOf(baseToString(separator), end) != end) {
  58825. var index = result.lastIndexOf(separator);
  58826. if (index > -1) {
  58827. result = result.slice(0, index);
  58828. }
  58829. }
  58830. return result + omission;
  58831. }
  58832. /**
  58833. * The inverse of `_.escape`; this method converts the HTML entities
  58834. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  58835. * their corresponding characters.
  58836. *
  58837. * **Note:** No other HTML entities are unescaped. To unescape additional
  58838. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  58839. *
  58840. * @static
  58841. * @memberOf _
  58842. * @since 0.6.0
  58843. * @category String
  58844. * @param {string} [string=''] The string to unescape.
  58845. * @returns {string} Returns the unescaped string.
  58846. * @example
  58847. *
  58848. * _.unescape('fred, barney, &amp; pebbles');
  58849. * // => 'fred, barney, & pebbles'
  58850. */
  58851. function unescape(string) {
  58852. string = toString(string);
  58853. return (string && reHasEscapedHtml.test(string))
  58854. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  58855. : string;
  58856. }
  58857. /**
  58858. * Converts `string`, as space separated words, to upper case.
  58859. *
  58860. * @static
  58861. * @memberOf _
  58862. * @since 4.0.0
  58863. * @category String
  58864. * @param {string} [string=''] The string to convert.
  58865. * @returns {string} Returns the upper cased string.
  58866. * @example
  58867. *
  58868. * _.upperCase('--foo-bar');
  58869. * // => 'FOO BAR'
  58870. *
  58871. * _.upperCase('fooBar');
  58872. * // => 'FOO BAR'
  58873. *
  58874. * _.upperCase('__foo_bar__');
  58875. * // => 'FOO BAR'
  58876. */
  58877. var upperCase = createCompounder(function(result, word, index) {
  58878. return result + (index ? ' ' : '') + word.toUpperCase();
  58879. });
  58880. /**
  58881. * Converts the first character of `string` to upper case.
  58882. *
  58883. * @static
  58884. * @memberOf _
  58885. * @since 4.0.0
  58886. * @category String
  58887. * @param {string} [string=''] The string to convert.
  58888. * @returns {string} Returns the converted string.
  58889. * @example
  58890. *
  58891. * _.upperFirst('fred');
  58892. * // => 'Fred'
  58893. *
  58894. * _.upperFirst('FRED');
  58895. * // => 'FRED'
  58896. */
  58897. var upperFirst = createCaseFirst('toUpperCase');
  58898. /**
  58899. * Splits `string` into an array of its words.
  58900. *
  58901. * @static
  58902. * @memberOf _
  58903. * @since 3.0.0
  58904. * @category String
  58905. * @param {string} [string=''] The string to inspect.
  58906. * @param {RegExp|string} [pattern] The pattern to match words.
  58907. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  58908. * @returns {Array} Returns the words of `string`.
  58909. * @example
  58910. *
  58911. * _.words('fred, barney, & pebbles');
  58912. * // => ['fred', 'barney', 'pebbles']
  58913. *
  58914. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  58915. * // => ['fred', 'barney', '&', 'pebbles']
  58916. */
  58917. function words(string, pattern, guard) {
  58918. string = toString(string);
  58919. pattern = guard ? undefined : pattern;
  58920. if (pattern === undefined) {
  58921. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  58922. }
  58923. return string.match(pattern) || [];
  58924. }
  58925. /*------------------------------------------------------------------------*/
  58926. /**
  58927. * Attempts to invoke `func`, returning either the result or the caught error
  58928. * object. Any additional arguments are provided to `func` when it's invoked.
  58929. *
  58930. * @static
  58931. * @memberOf _
  58932. * @since 3.0.0
  58933. * @category Util
  58934. * @param {Function} func The function to attempt.
  58935. * @param {...*} [args] The arguments to invoke `func` with.
  58936. * @returns {*} Returns the `func` result or error object.
  58937. * @example
  58938. *
  58939. * // Avoid throwing errors for invalid selectors.
  58940. * var elements = _.attempt(function(selector) {
  58941. * return document.querySelectorAll(selector);
  58942. * }, '>_>');
  58943. *
  58944. * if (_.isError(elements)) {
  58945. * elements = [];
  58946. * }
  58947. */
  58948. var attempt = baseRest(function(func, args) {
  58949. try {
  58950. return apply(func, undefined, args);
  58951. } catch (e) {
  58952. return isError(e) ? e : new Error(e);
  58953. }
  58954. });
  58955. /**
  58956. * Binds methods of an object to the object itself, overwriting the existing
  58957. * method.
  58958. *
  58959. * **Note:** This method doesn't set the "length" property of bound functions.
  58960. *
  58961. * @static
  58962. * @since 0.1.0
  58963. * @memberOf _
  58964. * @category Util
  58965. * @param {Object} object The object to bind and assign the bound methods to.
  58966. * @param {...(string|string[])} methodNames The object method names to bind.
  58967. * @returns {Object} Returns `object`.
  58968. * @example
  58969. *
  58970. * var view = {
  58971. * 'label': 'docs',
  58972. * 'click': function() {
  58973. * console.log('clicked ' + this.label);
  58974. * }
  58975. * };
  58976. *
  58977. * _.bindAll(view, ['click']);
  58978. * jQuery(element).on('click', view.click);
  58979. * // => Logs 'clicked docs' when clicked.
  58980. */
  58981. var bindAll = flatRest(function(object, methodNames) {
  58982. arrayEach(methodNames, function(key) {
  58983. key = toKey(key);
  58984. baseAssignValue(object, key, bind(object[key], object));
  58985. });
  58986. return object;
  58987. });
  58988. /**
  58989. * Creates a function that iterates over `pairs` and invokes the corresponding
  58990. * function of the first predicate to return truthy. The predicate-function
  58991. * pairs are invoked with the `this` binding and arguments of the created
  58992. * function.
  58993. *
  58994. * @static
  58995. * @memberOf _
  58996. * @since 4.0.0
  58997. * @category Util
  58998. * @param {Array} pairs The predicate-function pairs.
  58999. * @returns {Function} Returns the new composite function.
  59000. * @example
  59001. *
  59002. * var func = _.cond([
  59003. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  59004. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  59005. * [_.stubTrue, _.constant('no match')]
  59006. * ]);
  59007. *
  59008. * func({ 'a': 1, 'b': 2 });
  59009. * // => 'matches A'
  59010. *
  59011. * func({ 'a': 0, 'b': 1 });
  59012. * // => 'matches B'
  59013. *
  59014. * func({ 'a': '1', 'b': '2' });
  59015. * // => 'no match'
  59016. */
  59017. function cond(pairs) {
  59018. var length = pairs == null ? 0 : pairs.length,
  59019. toIteratee = getIteratee();
  59020. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  59021. if (typeof pair[1] != 'function') {
  59022. throw new TypeError(FUNC_ERROR_TEXT);
  59023. }
  59024. return [toIteratee(pair[0]), pair[1]];
  59025. });
  59026. return baseRest(function(args) {
  59027. var index = -1;
  59028. while (++index < length) {
  59029. var pair = pairs[index];
  59030. if (apply(pair[0], this, args)) {
  59031. return apply(pair[1], this, args);
  59032. }
  59033. }
  59034. });
  59035. }
  59036. /**
  59037. * Creates a function that invokes the predicate properties of `source` with
  59038. * the corresponding property values of a given object, returning `true` if
  59039. * all predicates return truthy, else `false`.
  59040. *
  59041. * **Note:** The created function is equivalent to `_.conformsTo` with
  59042. * `source` partially applied.
  59043. *
  59044. * @static
  59045. * @memberOf _
  59046. * @since 4.0.0
  59047. * @category Util
  59048. * @param {Object} source The object of property predicates to conform to.
  59049. * @returns {Function} Returns the new spec function.
  59050. * @example
  59051. *
  59052. * var objects = [
  59053. * { 'a': 2, 'b': 1 },
  59054. * { 'a': 1, 'b': 2 }
  59055. * ];
  59056. *
  59057. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  59058. * // => [{ 'a': 1, 'b': 2 }]
  59059. */
  59060. function conforms(source) {
  59061. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  59062. }
  59063. /**
  59064. * Creates a function that returns `value`.
  59065. *
  59066. * @static
  59067. * @memberOf _
  59068. * @since 2.4.0
  59069. * @category Util
  59070. * @param {*} value The value to return from the new function.
  59071. * @returns {Function} Returns the new constant function.
  59072. * @example
  59073. *
  59074. * var objects = _.times(2, _.constant({ 'a': 1 }));
  59075. *
  59076. * console.log(objects);
  59077. * // => [{ 'a': 1 }, { 'a': 1 }]
  59078. *
  59079. * console.log(objects[0] === objects[1]);
  59080. * // => true
  59081. */
  59082. function constant(value) {
  59083. return function() {
  59084. return value;
  59085. };
  59086. }
  59087. /**
  59088. * Checks `value` to determine whether a default value should be returned in
  59089. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  59090. * or `undefined`.
  59091. *
  59092. * @static
  59093. * @memberOf _
  59094. * @since 4.14.0
  59095. * @category Util
  59096. * @param {*} value The value to check.
  59097. * @param {*} defaultValue The default value.
  59098. * @returns {*} Returns the resolved value.
  59099. * @example
  59100. *
  59101. * _.defaultTo(1, 10);
  59102. * // => 1
  59103. *
  59104. * _.defaultTo(undefined, 10);
  59105. * // => 10
  59106. */
  59107. function defaultTo(value, defaultValue) {
  59108. return (value == null || value !== value) ? defaultValue : value;
  59109. }
  59110. /**
  59111. * Creates a function that returns the result of invoking the given functions
  59112. * with the `this` binding of the created function, where each successive
  59113. * invocation is supplied the return value of the previous.
  59114. *
  59115. * @static
  59116. * @memberOf _
  59117. * @since 3.0.0
  59118. * @category Util
  59119. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  59120. * @returns {Function} Returns the new composite function.
  59121. * @see _.flowRight
  59122. * @example
  59123. *
  59124. * function square(n) {
  59125. * return n * n;
  59126. * }
  59127. *
  59128. * var addSquare = _.flow([_.add, square]);
  59129. * addSquare(1, 2);
  59130. * // => 9
  59131. */
  59132. var flow = createFlow();
  59133. /**
  59134. * This method is like `_.flow` except that it creates a function that
  59135. * invokes the given functions from right to left.
  59136. *
  59137. * @static
  59138. * @since 3.0.0
  59139. * @memberOf _
  59140. * @category Util
  59141. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  59142. * @returns {Function} Returns the new composite function.
  59143. * @see _.flow
  59144. * @example
  59145. *
  59146. * function square(n) {
  59147. * return n * n;
  59148. * }
  59149. *
  59150. * var addSquare = _.flowRight([square, _.add]);
  59151. * addSquare(1, 2);
  59152. * // => 9
  59153. */
  59154. var flowRight = createFlow(true);
  59155. /**
  59156. * This method returns the first argument it receives.
  59157. *
  59158. * @static
  59159. * @since 0.1.0
  59160. * @memberOf _
  59161. * @category Util
  59162. * @param {*} value Any value.
  59163. * @returns {*} Returns `value`.
  59164. * @example
  59165. *
  59166. * var object = { 'a': 1 };
  59167. *
  59168. * console.log(_.identity(object) === object);
  59169. * // => true
  59170. */
  59171. function identity(value) {
  59172. return value;
  59173. }
  59174. /**
  59175. * Creates a function that invokes `func` with the arguments of the created
  59176. * function. If `func` is a property name, the created function returns the
  59177. * property value for a given element. If `func` is an array or object, the
  59178. * created function returns `true` for elements that contain the equivalent
  59179. * source properties, otherwise it returns `false`.
  59180. *
  59181. * @static
  59182. * @since 4.0.0
  59183. * @memberOf _
  59184. * @category Util
  59185. * @param {*} [func=_.identity] The value to convert to a callback.
  59186. * @returns {Function} Returns the callback.
  59187. * @example
  59188. *
  59189. * var users = [
  59190. * { 'user': 'barney', 'age': 36, 'active': true },
  59191. * { 'user': 'fred', 'age': 40, 'active': false }
  59192. * ];
  59193. *
  59194. * // The `_.matches` iteratee shorthand.
  59195. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  59196. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  59197. *
  59198. * // The `_.matchesProperty` iteratee shorthand.
  59199. * _.filter(users, _.iteratee(['user', 'fred']));
  59200. * // => [{ 'user': 'fred', 'age': 40 }]
  59201. *
  59202. * // The `_.property` iteratee shorthand.
  59203. * _.map(users, _.iteratee('user'));
  59204. * // => ['barney', 'fred']
  59205. *
  59206. * // Create custom iteratee shorthands.
  59207. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  59208. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  59209. * return func.test(string);
  59210. * };
  59211. * });
  59212. *
  59213. * _.filter(['abc', 'def'], /ef/);
  59214. * // => ['def']
  59215. */
  59216. function iteratee(func) {
  59217. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  59218. }
  59219. /**
  59220. * Creates a function that performs a partial deep comparison between a given
  59221. * object and `source`, returning `true` if the given object has equivalent
  59222. * property values, else `false`.
  59223. *
  59224. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  59225. * partially applied.
  59226. *
  59227. * Partial comparisons will match empty array and empty object `source`
  59228. * values against any array or object value, respectively. See `_.isEqual`
  59229. * for a list of supported value comparisons.
  59230. *
  59231. * **Note:** Multiple values can be checked by combining several matchers
  59232. * using `_.overSome`
  59233. *
  59234. * @static
  59235. * @memberOf _
  59236. * @since 3.0.0
  59237. * @category Util
  59238. * @param {Object} source The object of property values to match.
  59239. * @returns {Function} Returns the new spec function.
  59240. * @example
  59241. *
  59242. * var objects = [
  59243. * { 'a': 1, 'b': 2, 'c': 3 },
  59244. * { 'a': 4, 'b': 5, 'c': 6 }
  59245. * ];
  59246. *
  59247. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  59248. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  59249. *
  59250. * // Checking for several possible values
  59251. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  59252. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  59253. */
  59254. function matches(source) {
  59255. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  59256. }
  59257. /**
  59258. * Creates a function that performs a partial deep comparison between the
  59259. * value at `path` of a given object to `srcValue`, returning `true` if the
  59260. * object value is equivalent, else `false`.
  59261. *
  59262. * **Note:** Partial comparisons will match empty array and empty object
  59263. * `srcValue` values against any array or object value, respectively. See
  59264. * `_.isEqual` for a list of supported value comparisons.
  59265. *
  59266. * **Note:** Multiple values can be checked by combining several matchers
  59267. * using `_.overSome`
  59268. *
  59269. * @static
  59270. * @memberOf _
  59271. * @since 3.2.0
  59272. * @category Util
  59273. * @param {Array|string} path The path of the property to get.
  59274. * @param {*} srcValue The value to match.
  59275. * @returns {Function} Returns the new spec function.
  59276. * @example
  59277. *
  59278. * var objects = [
  59279. * { 'a': 1, 'b': 2, 'c': 3 },
  59280. * { 'a': 4, 'b': 5, 'c': 6 }
  59281. * ];
  59282. *
  59283. * _.find(objects, _.matchesProperty('a', 4));
  59284. * // => { 'a': 4, 'b': 5, 'c': 6 }
  59285. *
  59286. * // Checking for several possible values
  59287. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  59288. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  59289. */
  59290. function matchesProperty(path, srcValue) {
  59291. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  59292. }
  59293. /**
  59294. * Creates a function that invokes the method at `path` of a given object.
  59295. * Any additional arguments are provided to the invoked method.
  59296. *
  59297. * @static
  59298. * @memberOf _
  59299. * @since 3.7.0
  59300. * @category Util
  59301. * @param {Array|string} path The path of the method to invoke.
  59302. * @param {...*} [args] The arguments to invoke the method with.
  59303. * @returns {Function} Returns the new invoker function.
  59304. * @example
  59305. *
  59306. * var objects = [
  59307. * { 'a': { 'b': _.constant(2) } },
  59308. * { 'a': { 'b': _.constant(1) } }
  59309. * ];
  59310. *
  59311. * _.map(objects, _.method('a.b'));
  59312. * // => [2, 1]
  59313. *
  59314. * _.map(objects, _.method(['a', 'b']));
  59315. * // => [2, 1]
  59316. */
  59317. var method = baseRest(function(path, args) {
  59318. return function(object) {
  59319. return baseInvoke(object, path, args);
  59320. };
  59321. });
  59322. /**
  59323. * The opposite of `_.method`; this method creates a function that invokes
  59324. * the method at a given path of `object`. Any additional arguments are
  59325. * provided to the invoked method.
  59326. *
  59327. * @static
  59328. * @memberOf _
  59329. * @since 3.7.0
  59330. * @category Util
  59331. * @param {Object} object The object to query.
  59332. * @param {...*} [args] The arguments to invoke the method with.
  59333. * @returns {Function} Returns the new invoker function.
  59334. * @example
  59335. *
  59336. * var array = _.times(3, _.constant),
  59337. * object = { 'a': array, 'b': array, 'c': array };
  59338. *
  59339. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  59340. * // => [2, 0]
  59341. *
  59342. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  59343. * // => [2, 0]
  59344. */
  59345. var methodOf = baseRest(function(object, args) {
  59346. return function(path) {
  59347. return baseInvoke(object, path, args);
  59348. };
  59349. });
  59350. /**
  59351. * Adds all own enumerable string keyed function properties of a source
  59352. * object to the destination object. If `object` is a function, then methods
  59353. * are added to its prototype as well.
  59354. *
  59355. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  59356. * avoid conflicts caused by modifying the original.
  59357. *
  59358. * @static
  59359. * @since 0.1.0
  59360. * @memberOf _
  59361. * @category Util
  59362. * @param {Function|Object} [object=lodash] The destination object.
  59363. * @param {Object} source The object of functions to add.
  59364. * @param {Object} [options={}] The options object.
  59365. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  59366. * @returns {Function|Object} Returns `object`.
  59367. * @example
  59368. *
  59369. * function vowels(string) {
  59370. * return _.filter(string, function(v) {
  59371. * return /[aeiou]/i.test(v);
  59372. * });
  59373. * }
  59374. *
  59375. * _.mixin({ 'vowels': vowels });
  59376. * _.vowels('fred');
  59377. * // => ['e']
  59378. *
  59379. * _('fred').vowels().value();
  59380. * // => ['e']
  59381. *
  59382. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  59383. * _('fred').vowels();
  59384. * // => ['e']
  59385. */
  59386. function mixin(object, source, options) {
  59387. var props = keys(source),
  59388. methodNames = baseFunctions(source, props);
  59389. if (options == null &&
  59390. !(isObject(source) && (methodNames.length || !props.length))) {
  59391. options = source;
  59392. source = object;
  59393. object = this;
  59394. methodNames = baseFunctions(source, keys(source));
  59395. }
  59396. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  59397. isFunc = isFunction(object);
  59398. arrayEach(methodNames, function(methodName) {
  59399. var func = source[methodName];
  59400. object[methodName] = func;
  59401. if (isFunc) {
  59402. object.prototype[methodName] = function() {
  59403. var chainAll = this.__chain__;
  59404. if (chain || chainAll) {
  59405. var result = object(this.__wrapped__),
  59406. actions = result.__actions__ = copyArray(this.__actions__);
  59407. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  59408. result.__chain__ = chainAll;
  59409. return result;
  59410. }
  59411. return func.apply(object, arrayPush([this.value()], arguments));
  59412. };
  59413. }
  59414. });
  59415. return object;
  59416. }
  59417. /**
  59418. * Reverts the `_` variable to its previous value and returns a reference to
  59419. * the `lodash` function.
  59420. *
  59421. * @static
  59422. * @since 0.1.0
  59423. * @memberOf _
  59424. * @category Util
  59425. * @returns {Function} Returns the `lodash` function.
  59426. * @example
  59427. *
  59428. * var lodash = _.noConflict();
  59429. */
  59430. function noConflict() {
  59431. if (root._ === this) {
  59432. root._ = oldDash;
  59433. }
  59434. return this;
  59435. }
  59436. /**
  59437. * This method returns `undefined`.
  59438. *
  59439. * @static
  59440. * @memberOf _
  59441. * @since 2.3.0
  59442. * @category Util
  59443. * @example
  59444. *
  59445. * _.times(2, _.noop);
  59446. * // => [undefined, undefined]
  59447. */
  59448. function noop() {
  59449. // No operation performed.
  59450. }
  59451. /**
  59452. * Creates a function that gets the argument at index `n`. If `n` is negative,
  59453. * the nth argument from the end is returned.
  59454. *
  59455. * @static
  59456. * @memberOf _
  59457. * @since 4.0.0
  59458. * @category Util
  59459. * @param {number} [n=0] The index of the argument to return.
  59460. * @returns {Function} Returns the new pass-thru function.
  59461. * @example
  59462. *
  59463. * var func = _.nthArg(1);
  59464. * func('a', 'b', 'c', 'd');
  59465. * // => 'b'
  59466. *
  59467. * var func = _.nthArg(-2);
  59468. * func('a', 'b', 'c', 'd');
  59469. * // => 'c'
  59470. */
  59471. function nthArg(n) {
  59472. n = toInteger(n);
  59473. return baseRest(function(args) {
  59474. return baseNth(args, n);
  59475. });
  59476. }
  59477. /**
  59478. * Creates a function that invokes `iteratees` with the arguments it receives
  59479. * and returns their results.
  59480. *
  59481. * @static
  59482. * @memberOf _
  59483. * @since 4.0.0
  59484. * @category Util
  59485. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  59486. * The iteratees to invoke.
  59487. * @returns {Function} Returns the new function.
  59488. * @example
  59489. *
  59490. * var func = _.over([Math.max, Math.min]);
  59491. *
  59492. * func(1, 2, 3, 4);
  59493. * // => [4, 1]
  59494. */
  59495. var over = createOver(arrayMap);
  59496. /**
  59497. * Creates a function that checks if **all** of the `predicates` return
  59498. * truthy when invoked with the arguments it receives.
  59499. *
  59500. * Following shorthands are possible for providing predicates.
  59501. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  59502. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  59503. *
  59504. * @static
  59505. * @memberOf _
  59506. * @since 4.0.0
  59507. * @category Util
  59508. * @param {...(Function|Function[])} [predicates=[_.identity]]
  59509. * The predicates to check.
  59510. * @returns {Function} Returns the new function.
  59511. * @example
  59512. *
  59513. * var func = _.overEvery([Boolean, isFinite]);
  59514. *
  59515. * func('1');
  59516. * // => true
  59517. *
  59518. * func(null);
  59519. * // => false
  59520. *
  59521. * func(NaN);
  59522. * // => false
  59523. */
  59524. var overEvery = createOver(arrayEvery);
  59525. /**
  59526. * Creates a function that checks if **any** of the `predicates` return
  59527. * truthy when invoked with the arguments it receives.
  59528. *
  59529. * Following shorthands are possible for providing predicates.
  59530. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  59531. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  59532. *
  59533. * @static
  59534. * @memberOf _
  59535. * @since 4.0.0
  59536. * @category Util
  59537. * @param {...(Function|Function[])} [predicates=[_.identity]]
  59538. * The predicates to check.
  59539. * @returns {Function} Returns the new function.
  59540. * @example
  59541. *
  59542. * var func = _.overSome([Boolean, isFinite]);
  59543. *
  59544. * func('1');
  59545. * // => true
  59546. *
  59547. * func(null);
  59548. * // => true
  59549. *
  59550. * func(NaN);
  59551. * // => false
  59552. *
  59553. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  59554. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  59555. */
  59556. var overSome = createOver(arraySome);
  59557. /**
  59558. * Creates a function that returns the value at `path` of a given object.
  59559. *
  59560. * @static
  59561. * @memberOf _
  59562. * @since 2.4.0
  59563. * @category Util
  59564. * @param {Array|string} path The path of the property to get.
  59565. * @returns {Function} Returns the new accessor function.
  59566. * @example
  59567. *
  59568. * var objects = [
  59569. * { 'a': { 'b': 2 } },
  59570. * { 'a': { 'b': 1 } }
  59571. * ];
  59572. *
  59573. * _.map(objects, _.property('a.b'));
  59574. * // => [2, 1]
  59575. *
  59576. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  59577. * // => [1, 2]
  59578. */
  59579. function property(path) {
  59580. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  59581. }
  59582. /**
  59583. * The opposite of `_.property`; this method creates a function that returns
  59584. * the value at a given path of `object`.
  59585. *
  59586. * @static
  59587. * @memberOf _
  59588. * @since 3.0.0
  59589. * @category Util
  59590. * @param {Object} object The object to query.
  59591. * @returns {Function} Returns the new accessor function.
  59592. * @example
  59593. *
  59594. * var array = [0, 1, 2],
  59595. * object = { 'a': array, 'b': array, 'c': array };
  59596. *
  59597. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  59598. * // => [2, 0]
  59599. *
  59600. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  59601. * // => [2, 0]
  59602. */
  59603. function propertyOf(object) {
  59604. return function(path) {
  59605. return object == null ? undefined : baseGet(object, path);
  59606. };
  59607. }
  59608. /**
  59609. * Creates an array of numbers (positive and/or negative) progressing from
  59610. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  59611. * `start` is specified without an `end` or `step`. If `end` is not specified,
  59612. * it's set to `start` with `start` then set to `0`.
  59613. *
  59614. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  59615. * floating-point values which can produce unexpected results.
  59616. *
  59617. * @static
  59618. * @since 0.1.0
  59619. * @memberOf _
  59620. * @category Util
  59621. * @param {number} [start=0] The start of the range.
  59622. * @param {number} end The end of the range.
  59623. * @param {number} [step=1] The value to increment or decrement by.
  59624. * @returns {Array} Returns the range of numbers.
  59625. * @see _.inRange, _.rangeRight
  59626. * @example
  59627. *
  59628. * _.range(4);
  59629. * // => [0, 1, 2, 3]
  59630. *
  59631. * _.range(-4);
  59632. * // => [0, -1, -2, -3]
  59633. *
  59634. * _.range(1, 5);
  59635. * // => [1, 2, 3, 4]
  59636. *
  59637. * _.range(0, 20, 5);
  59638. * // => [0, 5, 10, 15]
  59639. *
  59640. * _.range(0, -4, -1);
  59641. * // => [0, -1, -2, -3]
  59642. *
  59643. * _.range(1, 4, 0);
  59644. * // => [1, 1, 1]
  59645. *
  59646. * _.range(0);
  59647. * // => []
  59648. */
  59649. var range = createRange();
  59650. /**
  59651. * This method is like `_.range` except that it populates values in
  59652. * descending order.
  59653. *
  59654. * @static
  59655. * @memberOf _
  59656. * @since 4.0.0
  59657. * @category Util
  59658. * @param {number} [start=0] The start of the range.
  59659. * @param {number} end The end of the range.
  59660. * @param {number} [step=1] The value to increment or decrement by.
  59661. * @returns {Array} Returns the range of numbers.
  59662. * @see _.inRange, _.range
  59663. * @example
  59664. *
  59665. * _.rangeRight(4);
  59666. * // => [3, 2, 1, 0]
  59667. *
  59668. * _.rangeRight(-4);
  59669. * // => [-3, -2, -1, 0]
  59670. *
  59671. * _.rangeRight(1, 5);
  59672. * // => [4, 3, 2, 1]
  59673. *
  59674. * _.rangeRight(0, 20, 5);
  59675. * // => [15, 10, 5, 0]
  59676. *
  59677. * _.rangeRight(0, -4, -1);
  59678. * // => [-3, -2, -1, 0]
  59679. *
  59680. * _.rangeRight(1, 4, 0);
  59681. * // => [1, 1, 1]
  59682. *
  59683. * _.rangeRight(0);
  59684. * // => []
  59685. */
  59686. var rangeRight = createRange(true);
  59687. /**
  59688. * This method returns a new empty array.
  59689. *
  59690. * @static
  59691. * @memberOf _
  59692. * @since 4.13.0
  59693. * @category Util
  59694. * @returns {Array} Returns the new empty array.
  59695. * @example
  59696. *
  59697. * var arrays = _.times(2, _.stubArray);
  59698. *
  59699. * console.log(arrays);
  59700. * // => [[], []]
  59701. *
  59702. * console.log(arrays[0] === arrays[1]);
  59703. * // => false
  59704. */
  59705. function stubArray() {
  59706. return [];
  59707. }
  59708. /**
  59709. * This method returns `false`.
  59710. *
  59711. * @static
  59712. * @memberOf _
  59713. * @since 4.13.0
  59714. * @category Util
  59715. * @returns {boolean} Returns `false`.
  59716. * @example
  59717. *
  59718. * _.times(2, _.stubFalse);
  59719. * // => [false, false]
  59720. */
  59721. function stubFalse() {
  59722. return false;
  59723. }
  59724. /**
  59725. * This method returns a new empty object.
  59726. *
  59727. * @static
  59728. * @memberOf _
  59729. * @since 4.13.0
  59730. * @category Util
  59731. * @returns {Object} Returns the new empty object.
  59732. * @example
  59733. *
  59734. * var objects = _.times(2, _.stubObject);
  59735. *
  59736. * console.log(objects);
  59737. * // => [{}, {}]
  59738. *
  59739. * console.log(objects[0] === objects[1]);
  59740. * // => false
  59741. */
  59742. function stubObject() {
  59743. return {};
  59744. }
  59745. /**
  59746. * This method returns an empty string.
  59747. *
  59748. * @static
  59749. * @memberOf _
  59750. * @since 4.13.0
  59751. * @category Util
  59752. * @returns {string} Returns the empty string.
  59753. * @example
  59754. *
  59755. * _.times(2, _.stubString);
  59756. * // => ['', '']
  59757. */
  59758. function stubString() {
  59759. return '';
  59760. }
  59761. /**
  59762. * This method returns `true`.
  59763. *
  59764. * @static
  59765. * @memberOf _
  59766. * @since 4.13.0
  59767. * @category Util
  59768. * @returns {boolean} Returns `true`.
  59769. * @example
  59770. *
  59771. * _.times(2, _.stubTrue);
  59772. * // => [true, true]
  59773. */
  59774. function stubTrue() {
  59775. return true;
  59776. }
  59777. /**
  59778. * Invokes the iteratee `n` times, returning an array of the results of
  59779. * each invocation. The iteratee is invoked with one argument; (index).
  59780. *
  59781. * @static
  59782. * @since 0.1.0
  59783. * @memberOf _
  59784. * @category Util
  59785. * @param {number} n The number of times to invoke `iteratee`.
  59786. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  59787. * @returns {Array} Returns the array of results.
  59788. * @example
  59789. *
  59790. * _.times(3, String);
  59791. * // => ['0', '1', '2']
  59792. *
  59793. * _.times(4, _.constant(0));
  59794. * // => [0, 0, 0, 0]
  59795. */
  59796. function times(n, iteratee) {
  59797. n = toInteger(n);
  59798. if (n < 1 || n > MAX_SAFE_INTEGER) {
  59799. return [];
  59800. }
  59801. var index = MAX_ARRAY_LENGTH,
  59802. length = nativeMin(n, MAX_ARRAY_LENGTH);
  59803. iteratee = getIteratee(iteratee);
  59804. n -= MAX_ARRAY_LENGTH;
  59805. var result = baseTimes(length, iteratee);
  59806. while (++index < n) {
  59807. iteratee(index);
  59808. }
  59809. return result;
  59810. }
  59811. /**
  59812. * Converts `value` to a property path array.
  59813. *
  59814. * @static
  59815. * @memberOf _
  59816. * @since 4.0.0
  59817. * @category Util
  59818. * @param {*} value The value to convert.
  59819. * @returns {Array} Returns the new property path array.
  59820. * @example
  59821. *
  59822. * _.toPath('a.b.c');
  59823. * // => ['a', 'b', 'c']
  59824. *
  59825. * _.toPath('a[0].b.c');
  59826. * // => ['a', '0', 'b', 'c']
  59827. */
  59828. function toPath(value) {
  59829. if (isArray(value)) {
  59830. return arrayMap(value, toKey);
  59831. }
  59832. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  59833. }
  59834. /**
  59835. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  59836. *
  59837. * @static
  59838. * @since 0.1.0
  59839. * @memberOf _
  59840. * @category Util
  59841. * @param {string} [prefix=''] The value to prefix the ID with.
  59842. * @returns {string} Returns the unique ID.
  59843. * @example
  59844. *
  59845. * _.uniqueId('contact_');
  59846. * // => 'contact_104'
  59847. *
  59848. * _.uniqueId();
  59849. * // => '105'
  59850. */
  59851. function uniqueId(prefix) {
  59852. var id = ++idCounter;
  59853. return toString(prefix) + id;
  59854. }
  59855. /*------------------------------------------------------------------------*/
  59856. /**
  59857. * Adds two numbers.
  59858. *
  59859. * @static
  59860. * @memberOf _
  59861. * @since 3.4.0
  59862. * @category Math
  59863. * @param {number} augend The first number in an addition.
  59864. * @param {number} addend The second number in an addition.
  59865. * @returns {number} Returns the total.
  59866. * @example
  59867. *
  59868. * _.add(6, 4);
  59869. * // => 10
  59870. */
  59871. var add = createMathOperation(function(augend, addend) {
  59872. return augend + addend;
  59873. }, 0);
  59874. /**
  59875. * Computes `number` rounded up to `precision`.
  59876. *
  59877. * @static
  59878. * @memberOf _
  59879. * @since 3.10.0
  59880. * @category Math
  59881. * @param {number} number The number to round up.
  59882. * @param {number} [precision=0] The precision to round up to.
  59883. * @returns {number} Returns the rounded up number.
  59884. * @example
  59885. *
  59886. * _.ceil(4.006);
  59887. * // => 5
  59888. *
  59889. * _.ceil(6.004, 2);
  59890. * // => 6.01
  59891. *
  59892. * _.ceil(6040, -2);
  59893. * // => 6100
  59894. */
  59895. var ceil = createRound('ceil');
  59896. /**
  59897. * Divide two numbers.
  59898. *
  59899. * @static
  59900. * @memberOf _
  59901. * @since 4.7.0
  59902. * @category Math
  59903. * @param {number} dividend The first number in a division.
  59904. * @param {number} divisor The second number in a division.
  59905. * @returns {number} Returns the quotient.
  59906. * @example
  59907. *
  59908. * _.divide(6, 4);
  59909. * // => 1.5
  59910. */
  59911. var divide = createMathOperation(function(dividend, divisor) {
  59912. return dividend / divisor;
  59913. }, 1);
  59914. /**
  59915. * Computes `number` rounded down to `precision`.
  59916. *
  59917. * @static
  59918. * @memberOf _
  59919. * @since 3.10.0
  59920. * @category Math
  59921. * @param {number} number The number to round down.
  59922. * @param {number} [precision=0] The precision to round down to.
  59923. * @returns {number} Returns the rounded down number.
  59924. * @example
  59925. *
  59926. * _.floor(4.006);
  59927. * // => 4
  59928. *
  59929. * _.floor(0.046, 2);
  59930. * // => 0.04
  59931. *
  59932. * _.floor(4060, -2);
  59933. * // => 4000
  59934. */
  59935. var floor = createRound('floor');
  59936. /**
  59937. * Computes the maximum value of `array`. If `array` is empty or falsey,
  59938. * `undefined` is returned.
  59939. *
  59940. * @static
  59941. * @since 0.1.0
  59942. * @memberOf _
  59943. * @category Math
  59944. * @param {Array} array The array to iterate over.
  59945. * @returns {*} Returns the maximum value.
  59946. * @example
  59947. *
  59948. * _.max([4, 2, 8, 6]);
  59949. * // => 8
  59950. *
  59951. * _.max([]);
  59952. * // => undefined
  59953. */
  59954. function max(array) {
  59955. return (array && array.length)
  59956. ? baseExtremum(array, identity, baseGt)
  59957. : undefined;
  59958. }
  59959. /**
  59960. * This method is like `_.max` except that it accepts `iteratee` which is
  59961. * invoked for each element in `array` to generate the criterion by which
  59962. * the value is ranked. The iteratee is invoked with one argument: (value).
  59963. *
  59964. * @static
  59965. * @memberOf _
  59966. * @since 4.0.0
  59967. * @category Math
  59968. * @param {Array} array The array to iterate over.
  59969. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  59970. * @returns {*} Returns the maximum value.
  59971. * @example
  59972. *
  59973. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  59974. *
  59975. * _.maxBy(objects, function(o) { return o.n; });
  59976. * // => { 'n': 2 }
  59977. *
  59978. * // The `_.property` iteratee shorthand.
  59979. * _.maxBy(objects, 'n');
  59980. * // => { 'n': 2 }
  59981. */
  59982. function maxBy(array, iteratee) {
  59983. return (array && array.length)
  59984. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  59985. : undefined;
  59986. }
  59987. /**
  59988. * Computes the mean of the values in `array`.
  59989. *
  59990. * @static
  59991. * @memberOf _
  59992. * @since 4.0.0
  59993. * @category Math
  59994. * @param {Array} array The array to iterate over.
  59995. * @returns {number} Returns the mean.
  59996. * @example
  59997. *
  59998. * _.mean([4, 2, 8, 6]);
  59999. * // => 5
  60000. */
  60001. function mean(array) {
  60002. return baseMean(array, identity);
  60003. }
  60004. /**
  60005. * This method is like `_.mean` except that it accepts `iteratee` which is
  60006. * invoked for each element in `array` to generate the value to be averaged.
  60007. * The iteratee is invoked with one argument: (value).
  60008. *
  60009. * @static
  60010. * @memberOf _
  60011. * @since 4.7.0
  60012. * @category Math
  60013. * @param {Array} array The array to iterate over.
  60014. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  60015. * @returns {number} Returns the mean.
  60016. * @example
  60017. *
  60018. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  60019. *
  60020. * _.meanBy(objects, function(o) { return o.n; });
  60021. * // => 5
  60022. *
  60023. * // The `_.property` iteratee shorthand.
  60024. * _.meanBy(objects, 'n');
  60025. * // => 5
  60026. */
  60027. function meanBy(array, iteratee) {
  60028. return baseMean(array, getIteratee(iteratee, 2));
  60029. }
  60030. /**
  60031. * Computes the minimum value of `array`. If `array` is empty or falsey,
  60032. * `undefined` is returned.
  60033. *
  60034. * @static
  60035. * @since 0.1.0
  60036. * @memberOf _
  60037. * @category Math
  60038. * @param {Array} array The array to iterate over.
  60039. * @returns {*} Returns the minimum value.
  60040. * @example
  60041. *
  60042. * _.min([4, 2, 8, 6]);
  60043. * // => 2
  60044. *
  60045. * _.min([]);
  60046. * // => undefined
  60047. */
  60048. function min(array) {
  60049. return (array && array.length)
  60050. ? baseExtremum(array, identity, baseLt)
  60051. : undefined;
  60052. }
  60053. /**
  60054. * This method is like `_.min` except that it accepts `iteratee` which is
  60055. * invoked for each element in `array` to generate the criterion by which
  60056. * the value is ranked. The iteratee is invoked with one argument: (value).
  60057. *
  60058. * @static
  60059. * @memberOf _
  60060. * @since 4.0.0
  60061. * @category Math
  60062. * @param {Array} array The array to iterate over.
  60063. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  60064. * @returns {*} Returns the minimum value.
  60065. * @example
  60066. *
  60067. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  60068. *
  60069. * _.minBy(objects, function(o) { return o.n; });
  60070. * // => { 'n': 1 }
  60071. *
  60072. * // The `_.property` iteratee shorthand.
  60073. * _.minBy(objects, 'n');
  60074. * // => { 'n': 1 }
  60075. */
  60076. function minBy(array, iteratee) {
  60077. return (array && array.length)
  60078. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  60079. : undefined;
  60080. }
  60081. /**
  60082. * Multiply two numbers.
  60083. *
  60084. * @static
  60085. * @memberOf _
  60086. * @since 4.7.0
  60087. * @category Math
  60088. * @param {number} multiplier The first number in a multiplication.
  60089. * @param {number} multiplicand The second number in a multiplication.
  60090. * @returns {number} Returns the product.
  60091. * @example
  60092. *
  60093. * _.multiply(6, 4);
  60094. * // => 24
  60095. */
  60096. var multiply = createMathOperation(function(multiplier, multiplicand) {
  60097. return multiplier * multiplicand;
  60098. }, 1);
  60099. /**
  60100. * Computes `number` rounded to `precision`.
  60101. *
  60102. * @static
  60103. * @memberOf _
  60104. * @since 3.10.0
  60105. * @category Math
  60106. * @param {number} number The number to round.
  60107. * @param {number} [precision=0] The precision to round to.
  60108. * @returns {number} Returns the rounded number.
  60109. * @example
  60110. *
  60111. * _.round(4.006);
  60112. * // => 4
  60113. *
  60114. * _.round(4.006, 2);
  60115. * // => 4.01
  60116. *
  60117. * _.round(4060, -2);
  60118. * // => 4100
  60119. */
  60120. var round = createRound('round');
  60121. /**
  60122. * Subtract two numbers.
  60123. *
  60124. * @static
  60125. * @memberOf _
  60126. * @since 4.0.0
  60127. * @category Math
  60128. * @param {number} minuend The first number in a subtraction.
  60129. * @param {number} subtrahend The second number in a subtraction.
  60130. * @returns {number} Returns the difference.
  60131. * @example
  60132. *
  60133. * _.subtract(6, 4);
  60134. * // => 2
  60135. */
  60136. var subtract = createMathOperation(function(minuend, subtrahend) {
  60137. return minuend - subtrahend;
  60138. }, 0);
  60139. /**
  60140. * Computes the sum of the values in `array`.
  60141. *
  60142. * @static
  60143. * @memberOf _
  60144. * @since 3.4.0
  60145. * @category Math
  60146. * @param {Array} array The array to iterate over.
  60147. * @returns {number} Returns the sum.
  60148. * @example
  60149. *
  60150. * _.sum([4, 2, 8, 6]);
  60151. * // => 20
  60152. */
  60153. function sum(array) {
  60154. return (array && array.length)
  60155. ? baseSum(array, identity)
  60156. : 0;
  60157. }
  60158. /**
  60159. * This method is like `_.sum` except that it accepts `iteratee` which is
  60160. * invoked for each element in `array` to generate the value to be summed.
  60161. * The iteratee is invoked with one argument: (value).
  60162. *
  60163. * @static
  60164. * @memberOf _
  60165. * @since 4.0.0
  60166. * @category Math
  60167. * @param {Array} array The array to iterate over.
  60168. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  60169. * @returns {number} Returns the sum.
  60170. * @example
  60171. *
  60172. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  60173. *
  60174. * _.sumBy(objects, function(o) { return o.n; });
  60175. * // => 20
  60176. *
  60177. * // The `_.property` iteratee shorthand.
  60178. * _.sumBy(objects, 'n');
  60179. * // => 20
  60180. */
  60181. function sumBy(array, iteratee) {
  60182. return (array && array.length)
  60183. ? baseSum(array, getIteratee(iteratee, 2))
  60184. : 0;
  60185. }
  60186. /*------------------------------------------------------------------------*/
  60187. // Add methods that return wrapped values in chain sequences.
  60188. lodash.after = after;
  60189. lodash.ary = ary;
  60190. lodash.assign = assign;
  60191. lodash.assignIn = assignIn;
  60192. lodash.assignInWith = assignInWith;
  60193. lodash.assignWith = assignWith;
  60194. lodash.at = at;
  60195. lodash.before = before;
  60196. lodash.bind = bind;
  60197. lodash.bindAll = bindAll;
  60198. lodash.bindKey = bindKey;
  60199. lodash.castArray = castArray;
  60200. lodash.chain = chain;
  60201. lodash.chunk = chunk;
  60202. lodash.compact = compact;
  60203. lodash.concat = concat;
  60204. lodash.cond = cond;
  60205. lodash.conforms = conforms;
  60206. lodash.constant = constant;
  60207. lodash.countBy = countBy;
  60208. lodash.create = create;
  60209. lodash.curry = curry;
  60210. lodash.curryRight = curryRight;
  60211. lodash.debounce = debounce;
  60212. lodash.defaults = defaults;
  60213. lodash.defaultsDeep = defaultsDeep;
  60214. lodash.defer = defer;
  60215. lodash.delay = delay;
  60216. lodash.difference = difference;
  60217. lodash.differenceBy = differenceBy;
  60218. lodash.differenceWith = differenceWith;
  60219. lodash.drop = drop;
  60220. lodash.dropRight = dropRight;
  60221. lodash.dropRightWhile = dropRightWhile;
  60222. lodash.dropWhile = dropWhile;
  60223. lodash.fill = fill;
  60224. lodash.filter = filter;
  60225. lodash.flatMap = flatMap;
  60226. lodash.flatMapDeep = flatMapDeep;
  60227. lodash.flatMapDepth = flatMapDepth;
  60228. lodash.flatten = flatten;
  60229. lodash.flattenDeep = flattenDeep;
  60230. lodash.flattenDepth = flattenDepth;
  60231. lodash.flip = flip;
  60232. lodash.flow = flow;
  60233. lodash.flowRight = flowRight;
  60234. lodash.fromPairs = fromPairs;
  60235. lodash.functions = functions;
  60236. lodash.functionsIn = functionsIn;
  60237. lodash.groupBy = groupBy;
  60238. lodash.initial = initial;
  60239. lodash.intersection = intersection;
  60240. lodash.intersectionBy = intersectionBy;
  60241. lodash.intersectionWith = intersectionWith;
  60242. lodash.invert = invert;
  60243. lodash.invertBy = invertBy;
  60244. lodash.invokeMap = invokeMap;
  60245. lodash.iteratee = iteratee;
  60246. lodash.keyBy = keyBy;
  60247. lodash.keys = keys;
  60248. lodash.keysIn = keysIn;
  60249. lodash.map = map;
  60250. lodash.mapKeys = mapKeys;
  60251. lodash.mapValues = mapValues;
  60252. lodash.matches = matches;
  60253. lodash.matchesProperty = matchesProperty;
  60254. lodash.memoize = memoize;
  60255. lodash.merge = merge;
  60256. lodash.mergeWith = mergeWith;
  60257. lodash.method = method;
  60258. lodash.methodOf = methodOf;
  60259. lodash.mixin = mixin;
  60260. lodash.negate = negate;
  60261. lodash.nthArg = nthArg;
  60262. lodash.omit = omit;
  60263. lodash.omitBy = omitBy;
  60264. lodash.once = once;
  60265. lodash.orderBy = orderBy;
  60266. lodash.over = over;
  60267. lodash.overArgs = overArgs;
  60268. lodash.overEvery = overEvery;
  60269. lodash.overSome = overSome;
  60270. lodash.partial = partial;
  60271. lodash.partialRight = partialRight;
  60272. lodash.partition = partition;
  60273. lodash.pick = pick;
  60274. lodash.pickBy = pickBy;
  60275. lodash.property = property;
  60276. lodash.propertyOf = propertyOf;
  60277. lodash.pull = pull;
  60278. lodash.pullAll = pullAll;
  60279. lodash.pullAllBy = pullAllBy;
  60280. lodash.pullAllWith = pullAllWith;
  60281. lodash.pullAt = pullAt;
  60282. lodash.range = range;
  60283. lodash.rangeRight = rangeRight;
  60284. lodash.rearg = rearg;
  60285. lodash.reject = reject;
  60286. lodash.remove = remove;
  60287. lodash.rest = rest;
  60288. lodash.reverse = reverse;
  60289. lodash.sampleSize = sampleSize;
  60290. lodash.set = set;
  60291. lodash.setWith = setWith;
  60292. lodash.shuffle = shuffle;
  60293. lodash.slice = slice;
  60294. lodash.sortBy = sortBy;
  60295. lodash.sortedUniq = sortedUniq;
  60296. lodash.sortedUniqBy = sortedUniqBy;
  60297. lodash.split = split;
  60298. lodash.spread = spread;
  60299. lodash.tail = tail;
  60300. lodash.take = take;
  60301. lodash.takeRight = takeRight;
  60302. lodash.takeRightWhile = takeRightWhile;
  60303. lodash.takeWhile = takeWhile;
  60304. lodash.tap = tap;
  60305. lodash.throttle = throttle;
  60306. lodash.thru = thru;
  60307. lodash.toArray = toArray;
  60308. lodash.toPairs = toPairs;
  60309. lodash.toPairsIn = toPairsIn;
  60310. lodash.toPath = toPath;
  60311. lodash.toPlainObject = toPlainObject;
  60312. lodash.transform = transform;
  60313. lodash.unary = unary;
  60314. lodash.union = union;
  60315. lodash.unionBy = unionBy;
  60316. lodash.unionWith = unionWith;
  60317. lodash.uniq = uniq;
  60318. lodash.uniqBy = uniqBy;
  60319. lodash.uniqWith = uniqWith;
  60320. lodash.unset = unset;
  60321. lodash.unzip = unzip;
  60322. lodash.unzipWith = unzipWith;
  60323. lodash.update = update;
  60324. lodash.updateWith = updateWith;
  60325. lodash.values = values;
  60326. lodash.valuesIn = valuesIn;
  60327. lodash.without = without;
  60328. lodash.words = words;
  60329. lodash.wrap = wrap;
  60330. lodash.xor = xor;
  60331. lodash.xorBy = xorBy;
  60332. lodash.xorWith = xorWith;
  60333. lodash.zip = zip;
  60334. lodash.zipObject = zipObject;
  60335. lodash.zipObjectDeep = zipObjectDeep;
  60336. lodash.zipWith = zipWith;
  60337. // Add aliases.
  60338. lodash.entries = toPairs;
  60339. lodash.entriesIn = toPairsIn;
  60340. lodash.extend = assignIn;
  60341. lodash.extendWith = assignInWith;
  60342. // Add methods to `lodash.prototype`.
  60343. mixin(lodash, lodash);
  60344. /*------------------------------------------------------------------------*/
  60345. // Add methods that return unwrapped values in chain sequences.
  60346. lodash.add = add;
  60347. lodash.attempt = attempt;
  60348. lodash.camelCase = camelCase;
  60349. lodash.capitalize = capitalize;
  60350. lodash.ceil = ceil;
  60351. lodash.clamp = clamp;
  60352. lodash.clone = clone;
  60353. lodash.cloneDeep = cloneDeep;
  60354. lodash.cloneDeepWith = cloneDeepWith;
  60355. lodash.cloneWith = cloneWith;
  60356. lodash.conformsTo = conformsTo;
  60357. lodash.deburr = deburr;
  60358. lodash.defaultTo = defaultTo;
  60359. lodash.divide = divide;
  60360. lodash.endsWith = endsWith;
  60361. lodash.eq = eq;
  60362. lodash.escape = escape;
  60363. lodash.escapeRegExp = escapeRegExp;
  60364. lodash.every = every;
  60365. lodash.find = find;
  60366. lodash.findIndex = findIndex;
  60367. lodash.findKey = findKey;
  60368. lodash.findLast = findLast;
  60369. lodash.findLastIndex = findLastIndex;
  60370. lodash.findLastKey = findLastKey;
  60371. lodash.floor = floor;
  60372. lodash.forEach = forEach;
  60373. lodash.forEachRight = forEachRight;
  60374. lodash.forIn = forIn;
  60375. lodash.forInRight = forInRight;
  60376. lodash.forOwn = forOwn;
  60377. lodash.forOwnRight = forOwnRight;
  60378. lodash.get = get;
  60379. lodash.gt = gt;
  60380. lodash.gte = gte;
  60381. lodash.has = has;
  60382. lodash.hasIn = hasIn;
  60383. lodash.head = head;
  60384. lodash.identity = identity;
  60385. lodash.includes = includes;
  60386. lodash.indexOf = indexOf;
  60387. lodash.inRange = inRange;
  60388. lodash.invoke = invoke;
  60389. lodash.isArguments = isArguments;
  60390. lodash.isArray = isArray;
  60391. lodash.isArrayBuffer = isArrayBuffer;
  60392. lodash.isArrayLike = isArrayLike;
  60393. lodash.isArrayLikeObject = isArrayLikeObject;
  60394. lodash.isBoolean = isBoolean;
  60395. lodash.isBuffer = isBuffer;
  60396. lodash.isDate = isDate;
  60397. lodash.isElement = isElement;
  60398. lodash.isEmpty = isEmpty;
  60399. lodash.isEqual = isEqual;
  60400. lodash.isEqualWith = isEqualWith;
  60401. lodash.isError = isError;
  60402. lodash.isFinite = isFinite;
  60403. lodash.isFunction = isFunction;
  60404. lodash.isInteger = isInteger;
  60405. lodash.isLength = isLength;
  60406. lodash.isMap = isMap;
  60407. lodash.isMatch = isMatch;
  60408. lodash.isMatchWith = isMatchWith;
  60409. lodash.isNaN = isNaN;
  60410. lodash.isNative = isNative;
  60411. lodash.isNil = isNil;
  60412. lodash.isNull = isNull;
  60413. lodash.isNumber = isNumber;
  60414. lodash.isObject = isObject;
  60415. lodash.isObjectLike = isObjectLike;
  60416. lodash.isPlainObject = isPlainObject;
  60417. lodash.isRegExp = isRegExp;
  60418. lodash.isSafeInteger = isSafeInteger;
  60419. lodash.isSet = isSet;
  60420. lodash.isString = isString;
  60421. lodash.isSymbol = isSymbol;
  60422. lodash.isTypedArray = isTypedArray;
  60423. lodash.isUndefined = isUndefined;
  60424. lodash.isWeakMap = isWeakMap;
  60425. lodash.isWeakSet = isWeakSet;
  60426. lodash.join = join;
  60427. lodash.kebabCase = kebabCase;
  60428. lodash.last = last;
  60429. lodash.lastIndexOf = lastIndexOf;
  60430. lodash.lowerCase = lowerCase;
  60431. lodash.lowerFirst = lowerFirst;
  60432. lodash.lt = lt;
  60433. lodash.lte = lte;
  60434. lodash.max = max;
  60435. lodash.maxBy = maxBy;
  60436. lodash.mean = mean;
  60437. lodash.meanBy = meanBy;
  60438. lodash.min = min;
  60439. lodash.minBy = minBy;
  60440. lodash.stubArray = stubArray;
  60441. lodash.stubFalse = stubFalse;
  60442. lodash.stubObject = stubObject;
  60443. lodash.stubString = stubString;
  60444. lodash.stubTrue = stubTrue;
  60445. lodash.multiply = multiply;
  60446. lodash.nth = nth;
  60447. lodash.noConflict = noConflict;
  60448. lodash.noop = noop;
  60449. lodash.now = now;
  60450. lodash.pad = pad;
  60451. lodash.padEnd = padEnd;
  60452. lodash.padStart = padStart;
  60453. lodash.parseInt = parseInt;
  60454. lodash.random = random;
  60455. lodash.reduce = reduce;
  60456. lodash.reduceRight = reduceRight;
  60457. lodash.repeat = repeat;
  60458. lodash.replace = replace;
  60459. lodash.result = result;
  60460. lodash.round = round;
  60461. lodash.runInContext = runInContext;
  60462. lodash.sample = sample;
  60463. lodash.size = size;
  60464. lodash.snakeCase = snakeCase;
  60465. lodash.some = some;
  60466. lodash.sortedIndex = sortedIndex;
  60467. lodash.sortedIndexBy = sortedIndexBy;
  60468. lodash.sortedIndexOf = sortedIndexOf;
  60469. lodash.sortedLastIndex = sortedLastIndex;
  60470. lodash.sortedLastIndexBy = sortedLastIndexBy;
  60471. lodash.sortedLastIndexOf = sortedLastIndexOf;
  60472. lodash.startCase = startCase;
  60473. lodash.startsWith = startsWith;
  60474. lodash.subtract = subtract;
  60475. lodash.sum = sum;
  60476. lodash.sumBy = sumBy;
  60477. lodash.template = template;
  60478. lodash.times = times;
  60479. lodash.toFinite = toFinite;
  60480. lodash.toInteger = toInteger;
  60481. lodash.toLength = toLength;
  60482. lodash.toLower = toLower;
  60483. lodash.toNumber = toNumber;
  60484. lodash.toSafeInteger = toSafeInteger;
  60485. lodash.toString = toString;
  60486. lodash.toUpper = toUpper;
  60487. lodash.trim = trim;
  60488. lodash.trimEnd = trimEnd;
  60489. lodash.trimStart = trimStart;
  60490. lodash.truncate = truncate;
  60491. lodash.unescape = unescape;
  60492. lodash.uniqueId = uniqueId;
  60493. lodash.upperCase = upperCase;
  60494. lodash.upperFirst = upperFirst;
  60495. // Add aliases.
  60496. lodash.each = forEach;
  60497. lodash.eachRight = forEachRight;
  60498. lodash.first = head;
  60499. mixin(lodash, (function() {
  60500. var source = {};
  60501. baseForOwn(lodash, function(func, methodName) {
  60502. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  60503. source[methodName] = func;
  60504. }
  60505. });
  60506. return source;
  60507. }()), { 'chain': false });
  60508. /*------------------------------------------------------------------------*/
  60509. /**
  60510. * The semantic version number.
  60511. *
  60512. * @static
  60513. * @memberOf _
  60514. * @type {string}
  60515. */
  60516. lodash.VERSION = VERSION;
  60517. // Assign default placeholders.
  60518. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  60519. lodash[methodName].placeholder = lodash;
  60520. });
  60521. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  60522. arrayEach(['drop', 'take'], function(methodName, index) {
  60523. LazyWrapper.prototype[methodName] = function(n) {
  60524. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  60525. var result = (this.__filtered__ && !index)
  60526. ? new LazyWrapper(this)
  60527. : this.clone();
  60528. if (result.__filtered__) {
  60529. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  60530. } else {
  60531. result.__views__.push({
  60532. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  60533. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  60534. });
  60535. }
  60536. return result;
  60537. };
  60538. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  60539. return this.reverse()[methodName](n).reverse();
  60540. };
  60541. });
  60542. // Add `LazyWrapper` methods that accept an `iteratee` value.
  60543. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  60544. var type = index + 1,
  60545. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  60546. LazyWrapper.prototype[methodName] = function(iteratee) {
  60547. var result = this.clone();
  60548. result.__iteratees__.push({
  60549. 'iteratee': getIteratee(iteratee, 3),
  60550. 'type': type
  60551. });
  60552. result.__filtered__ = result.__filtered__ || isFilter;
  60553. return result;
  60554. };
  60555. });
  60556. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  60557. arrayEach(['head', 'last'], function(methodName, index) {
  60558. var takeName = 'take' + (index ? 'Right' : '');
  60559. LazyWrapper.prototype[methodName] = function() {
  60560. return this[takeName](1).value()[0];
  60561. };
  60562. });
  60563. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  60564. arrayEach(['initial', 'tail'], function(methodName, index) {
  60565. var dropName = 'drop' + (index ? '' : 'Right');
  60566. LazyWrapper.prototype[methodName] = function() {
  60567. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  60568. };
  60569. });
  60570. LazyWrapper.prototype.compact = function() {
  60571. return this.filter(identity);
  60572. };
  60573. LazyWrapper.prototype.find = function(predicate) {
  60574. return this.filter(predicate).head();
  60575. };
  60576. LazyWrapper.prototype.findLast = function(predicate) {
  60577. return this.reverse().find(predicate);
  60578. };
  60579. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  60580. if (typeof path == 'function') {
  60581. return new LazyWrapper(this);
  60582. }
  60583. return this.map(function(value) {
  60584. return baseInvoke(value, path, args);
  60585. });
  60586. });
  60587. LazyWrapper.prototype.reject = function(predicate) {
  60588. return this.filter(negate(getIteratee(predicate)));
  60589. };
  60590. LazyWrapper.prototype.slice = function(start, end) {
  60591. start = toInteger(start);
  60592. var result = this;
  60593. if (result.__filtered__ && (start > 0 || end < 0)) {
  60594. return new LazyWrapper(result);
  60595. }
  60596. if (start < 0) {
  60597. result = result.takeRight(-start);
  60598. } else if (start) {
  60599. result = result.drop(start);
  60600. }
  60601. if (end !== undefined) {
  60602. end = toInteger(end);
  60603. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  60604. }
  60605. return result;
  60606. };
  60607. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  60608. return this.reverse().takeWhile(predicate).reverse();
  60609. };
  60610. LazyWrapper.prototype.toArray = function() {
  60611. return this.take(MAX_ARRAY_LENGTH);
  60612. };
  60613. // Add `LazyWrapper` methods to `lodash.prototype`.
  60614. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  60615. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  60616. isTaker = /^(?:head|last)$/.test(methodName),
  60617. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  60618. retUnwrapped = isTaker || /^find/.test(methodName);
  60619. if (!lodashFunc) {
  60620. return;
  60621. }
  60622. lodash.prototype[methodName] = function() {
  60623. var value = this.__wrapped__,
  60624. args = isTaker ? [1] : arguments,
  60625. isLazy = value instanceof LazyWrapper,
  60626. iteratee = args[0],
  60627. useLazy = isLazy || isArray(value);
  60628. var interceptor = function(value) {
  60629. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  60630. return (isTaker && chainAll) ? result[0] : result;
  60631. };
  60632. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  60633. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  60634. isLazy = useLazy = false;
  60635. }
  60636. var chainAll = this.__chain__,
  60637. isHybrid = !!this.__actions__.length,
  60638. isUnwrapped = retUnwrapped && !chainAll,
  60639. onlyLazy = isLazy && !isHybrid;
  60640. if (!retUnwrapped && useLazy) {
  60641. value = onlyLazy ? value : new LazyWrapper(this);
  60642. var result = func.apply(value, args);
  60643. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  60644. return new LodashWrapper(result, chainAll);
  60645. }
  60646. if (isUnwrapped && onlyLazy) {
  60647. return func.apply(this, args);
  60648. }
  60649. result = this.thru(interceptor);
  60650. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  60651. };
  60652. });
  60653. // Add `Array` methods to `lodash.prototype`.
  60654. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  60655. var func = arrayProto[methodName],
  60656. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  60657. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  60658. lodash.prototype[methodName] = function() {
  60659. var args = arguments;
  60660. if (retUnwrapped && !this.__chain__) {
  60661. var value = this.value();
  60662. return func.apply(isArray(value) ? value : [], args);
  60663. }
  60664. return this[chainName](function(value) {
  60665. return func.apply(isArray(value) ? value : [], args);
  60666. });
  60667. };
  60668. });
  60669. // Map minified method names to their real names.
  60670. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  60671. var lodashFunc = lodash[methodName];
  60672. if (lodashFunc) {
  60673. var key = lodashFunc.name + '';
  60674. if (!hasOwnProperty.call(realNames, key)) {
  60675. realNames[key] = [];
  60676. }
  60677. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  60678. }
  60679. });
  60680. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  60681. 'name': 'wrapper',
  60682. 'func': undefined
  60683. }];
  60684. // Add methods to `LazyWrapper`.
  60685. LazyWrapper.prototype.clone = lazyClone;
  60686. LazyWrapper.prototype.reverse = lazyReverse;
  60687. LazyWrapper.prototype.value = lazyValue;
  60688. // Add chain sequence methods to the `lodash` wrapper.
  60689. lodash.prototype.at = wrapperAt;
  60690. lodash.prototype.chain = wrapperChain;
  60691. lodash.prototype.commit = wrapperCommit;
  60692. lodash.prototype.next = wrapperNext;
  60693. lodash.prototype.plant = wrapperPlant;
  60694. lodash.prototype.reverse = wrapperReverse;
  60695. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  60696. // Add lazy aliases.
  60697. lodash.prototype.first = lodash.prototype.head;
  60698. if (symIterator) {
  60699. lodash.prototype[symIterator] = wrapperToIterator;
  60700. }
  60701. return lodash;
  60702. });
  60703. /*--------------------------------------------------------------------------*/
  60704. // Export lodash.
  60705. var _ = runInContext();
  60706. // Some AMD build optimizers, like r.js, check for condition patterns like:
  60707. if (true) {
  60708. // Expose Lodash on the global object to prevent errors when Lodash is
  60709. // loaded by a script tag in the presence of an AMD loader.
  60710. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  60711. // Use `_.noConflict` to remove Lodash from the global object.
  60712. root._ = _;
  60713. // Define as an anonymous module so, through path mapping, it can be
  60714. // referenced as the "underscore" module.
  60715. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  60716. return _;
  60717. }).call(exports, __webpack_require__, exports, module),
  60718. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  60719. }
  60720. // Check for `exports` after `define` in case a build optimizer adds it.
  60721. else {}
  60722. }.call(this));
  60723. /***/ }),
  60724. /***/ "./node_modules/lower-case/dist.es2015/index.js":
  60725. /*!******************************************************!*\
  60726. !*** ./node_modules/lower-case/dist.es2015/index.js ***!
  60727. \******************************************************/
  60728. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  60729. "use strict";
  60730. __webpack_require__.r(__webpack_exports__);
  60731. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  60732. /* harmony export */ localeLowerCase: () => (/* binding */ localeLowerCase),
  60733. /* harmony export */ lowerCase: () => (/* binding */ lowerCase)
  60734. /* harmony export */ });
  60735. /**
  60736. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  60737. */
  60738. var SUPPORTED_LOCALE = {
  60739. tr: {
  60740. regexp: /\u0130|\u0049|\u0049\u0307/g,
  60741. map: {
  60742. İ: "\u0069",
  60743. I: "\u0131",
  60744. İ: "\u0069",
  60745. },
  60746. },
  60747. az: {
  60748. regexp: /\u0130/g,
  60749. map: {
  60750. İ: "\u0069",
  60751. I: "\u0131",
  60752. İ: "\u0069",
  60753. },
  60754. },
  60755. lt: {
  60756. regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
  60757. map: {
  60758. I: "\u0069\u0307",
  60759. J: "\u006A\u0307",
  60760. Į: "\u012F\u0307",
  60761. Ì: "\u0069\u0307\u0300",
  60762. Í: "\u0069\u0307\u0301",
  60763. Ĩ: "\u0069\u0307\u0303",
  60764. },
  60765. },
  60766. };
  60767. /**
  60768. * Localized lower case.
  60769. */
  60770. function localeLowerCase(str, locale) {
  60771. var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
  60772. if (lang)
  60773. return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
  60774. return lowerCase(str);
  60775. }
  60776. /**
  60777. * Lower case as a function.
  60778. */
  60779. function lowerCase(str) {
  60780. return str.toLowerCase();
  60781. }
  60782. //# sourceMappingURL=index.js.map
  60783. /***/ }),
  60784. /***/ "./node_modules/md5.js/index.js":
  60785. /*!**************************************!*\
  60786. !*** ./node_modules/md5.js/index.js ***!
  60787. \**************************************/
  60788. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  60789. "use strict";
  60790. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  60791. var HashBase = __webpack_require__(/*! hash-base */ "./node_modules/hash-base/index.js")
  60792. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  60793. var ARRAY16 = new Array(16)
  60794. function MD5 () {
  60795. HashBase.call(this, 64)
  60796. // state
  60797. this._a = 0x67452301
  60798. this._b = 0xefcdab89
  60799. this._c = 0x98badcfe
  60800. this._d = 0x10325476
  60801. }
  60802. inherits(MD5, HashBase)
  60803. MD5.prototype._update = function () {
  60804. var M = ARRAY16
  60805. for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
  60806. var a = this._a
  60807. var b = this._b
  60808. var c = this._c
  60809. var d = this._d
  60810. a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
  60811. d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
  60812. c = fnF(c, d, a, b, M[2], 0x242070db, 17)
  60813. b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
  60814. a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
  60815. d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
  60816. c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
  60817. b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
  60818. a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
  60819. d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
  60820. c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
  60821. b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
  60822. a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
  60823. d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
  60824. c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
  60825. b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
  60826. a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
  60827. d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
  60828. c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
  60829. b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
  60830. a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
  60831. d = fnG(d, a, b, c, M[10], 0x02441453, 9)
  60832. c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
  60833. b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
  60834. a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
  60835. d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
  60836. c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
  60837. b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
  60838. a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
  60839. d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
  60840. c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
  60841. b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
  60842. a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
  60843. d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
  60844. c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
  60845. b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
  60846. a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
  60847. d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
  60848. c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
  60849. b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
  60850. a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
  60851. d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
  60852. c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
  60853. b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
  60854. a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
  60855. d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
  60856. c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
  60857. b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
  60858. a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
  60859. d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
  60860. c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
  60861. b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
  60862. a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
  60863. d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
  60864. c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
  60865. b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
  60866. a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
  60867. d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
  60868. c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
  60869. b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
  60870. a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
  60871. d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
  60872. c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
  60873. b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
  60874. this._a = (this._a + a) | 0
  60875. this._b = (this._b + b) | 0
  60876. this._c = (this._c + c) | 0
  60877. this._d = (this._d + d) | 0
  60878. }
  60879. MD5.prototype._digest = function () {
  60880. // create padding and handle blocks
  60881. this._block[this._blockOffset++] = 0x80
  60882. if (this._blockOffset > 56) {
  60883. this._block.fill(0, this._blockOffset, 64)
  60884. this._update()
  60885. this._blockOffset = 0
  60886. }
  60887. this._block.fill(0, this._blockOffset, 56)
  60888. this._block.writeUInt32LE(this._length[0], 56)
  60889. this._block.writeUInt32LE(this._length[1], 60)
  60890. this._update()
  60891. // produce result
  60892. var buffer = Buffer.allocUnsafe(16)
  60893. buffer.writeInt32LE(this._a, 0)
  60894. buffer.writeInt32LE(this._b, 4)
  60895. buffer.writeInt32LE(this._c, 8)
  60896. buffer.writeInt32LE(this._d, 12)
  60897. return buffer
  60898. }
  60899. function rotl (x, n) {
  60900. return (x << n) | (x >>> (32 - n))
  60901. }
  60902. function fnF (a, b, c, d, m, k, s) {
  60903. return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
  60904. }
  60905. function fnG (a, b, c, d, m, k, s) {
  60906. return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
  60907. }
  60908. function fnH (a, b, c, d, m, k, s) {
  60909. return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
  60910. }
  60911. function fnI (a, b, c, d, m, k, s) {
  60912. return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
  60913. }
  60914. module.exports = MD5
  60915. /***/ }),
  60916. /***/ "./node_modules/miller-rabin/lib/mr.js":
  60917. /*!*********************************************!*\
  60918. !*** ./node_modules/miller-rabin/lib/mr.js ***!
  60919. \*********************************************/
  60920. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  60921. var bn = __webpack_require__(/*! bn.js */ "./node_modules/miller-rabin/node_modules/bn.js/lib/bn.js");
  60922. var brorand = __webpack_require__(/*! brorand */ "./node_modules/brorand/index.js");
  60923. function MillerRabin(rand) {
  60924. this.rand = rand || new brorand.Rand();
  60925. }
  60926. module.exports = MillerRabin;
  60927. MillerRabin.create = function create(rand) {
  60928. return new MillerRabin(rand);
  60929. };
  60930. MillerRabin.prototype._randbelow = function _randbelow(n) {
  60931. var len = n.bitLength();
  60932. var min_bytes = Math.ceil(len / 8);
  60933. // Generage random bytes until a number less than n is found.
  60934. // This ensures that 0..n-1 have an equal probability of being selected.
  60935. do
  60936. var a = new bn(this.rand.generate(min_bytes));
  60937. while (a.cmp(n) >= 0);
  60938. return a;
  60939. };
  60940. MillerRabin.prototype._randrange = function _randrange(start, stop) {
  60941. // Generate a random number greater than or equal to start and less than stop.
  60942. var size = stop.sub(start);
  60943. return start.add(this._randbelow(size));
  60944. };
  60945. MillerRabin.prototype.test = function test(n, k, cb) {
  60946. var len = n.bitLength();
  60947. var red = bn.mont(n);
  60948. var rone = new bn(1).toRed(red);
  60949. if (!k)
  60950. k = Math.max(1, (len / 48) | 0);
  60951. // Find d and s, (n - 1) = (2 ^ s) * d;
  60952. var n1 = n.subn(1);
  60953. for (var s = 0; !n1.testn(s); s++) {}
  60954. var d = n.shrn(s);
  60955. var rn1 = n1.toRed(red);
  60956. var prime = true;
  60957. for (; k > 0; k--) {
  60958. var a = this._randrange(new bn(2), n1);
  60959. if (cb)
  60960. cb(a);
  60961. var x = a.toRed(red).redPow(d);
  60962. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
  60963. continue;
  60964. for (var i = 1; i < s; i++) {
  60965. x = x.redSqr();
  60966. if (x.cmp(rone) === 0)
  60967. return false;
  60968. if (x.cmp(rn1) === 0)
  60969. break;
  60970. }
  60971. if (i === s)
  60972. return false;
  60973. }
  60974. return prime;
  60975. };
  60976. MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
  60977. var len = n.bitLength();
  60978. var red = bn.mont(n);
  60979. var rone = new bn(1).toRed(red);
  60980. if (!k)
  60981. k = Math.max(1, (len / 48) | 0);
  60982. // Find d and s, (n - 1) = (2 ^ s) * d;
  60983. var n1 = n.subn(1);
  60984. for (var s = 0; !n1.testn(s); s++) {}
  60985. var d = n.shrn(s);
  60986. var rn1 = n1.toRed(red);
  60987. for (; k > 0; k--) {
  60988. var a = this._randrange(new bn(2), n1);
  60989. var g = n.gcd(a);
  60990. if (g.cmpn(1) !== 0)
  60991. return g;
  60992. var x = a.toRed(red).redPow(d);
  60993. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
  60994. continue;
  60995. for (var i = 1; i < s; i++) {
  60996. x = x.redSqr();
  60997. if (x.cmp(rone) === 0)
  60998. return x.fromRed().subn(1).gcd(n);
  60999. if (x.cmp(rn1) === 0)
  61000. break;
  61001. }
  61002. if (i === s) {
  61003. x = x.redSqr();
  61004. return x.fromRed().subn(1).gcd(n);
  61005. }
  61006. }
  61007. return false;
  61008. };
  61009. /***/ }),
  61010. /***/ "./node_modules/miller-rabin/node_modules/bn.js/lib/bn.js":
  61011. /*!****************************************************************!*\
  61012. !*** ./node_modules/miller-rabin/node_modules/bn.js/lib/bn.js ***!
  61013. \****************************************************************/
  61014. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  61015. /* module decorator */ module = __webpack_require__.nmd(module);
  61016. (function (module, exports) {
  61017. 'use strict';
  61018. // Utils
  61019. function assert (val, msg) {
  61020. if (!val) throw new Error(msg || 'Assertion failed');
  61021. }
  61022. // Could use `inherits` module, but don't want to move from single file
  61023. // architecture yet.
  61024. function inherits (ctor, superCtor) {
  61025. ctor.super_ = superCtor;
  61026. var TempCtor = function () {};
  61027. TempCtor.prototype = superCtor.prototype;
  61028. ctor.prototype = new TempCtor();
  61029. ctor.prototype.constructor = ctor;
  61030. }
  61031. // BN
  61032. function BN (number, base, endian) {
  61033. if (BN.isBN(number)) {
  61034. return number;
  61035. }
  61036. this.negative = 0;
  61037. this.words = null;
  61038. this.length = 0;
  61039. // Reduction context
  61040. this.red = null;
  61041. if (number !== null) {
  61042. if (base === 'le' || base === 'be') {
  61043. endian = base;
  61044. base = 10;
  61045. }
  61046. this._init(number || 0, base || 10, endian || 'be');
  61047. }
  61048. }
  61049. if (typeof module === 'object') {
  61050. module.exports = BN;
  61051. } else {
  61052. exports.BN = BN;
  61053. }
  61054. BN.BN = BN;
  61055. BN.wordSize = 26;
  61056. var Buffer;
  61057. try {
  61058. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  61059. Buffer = window.Buffer;
  61060. } else {
  61061. Buffer = (__webpack_require__(/*! buffer */ "?5588").Buffer);
  61062. }
  61063. } catch (e) {
  61064. }
  61065. BN.isBN = function isBN (num) {
  61066. if (num instanceof BN) {
  61067. return true;
  61068. }
  61069. return num !== null && typeof num === 'object' &&
  61070. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  61071. };
  61072. BN.max = function max (left, right) {
  61073. if (left.cmp(right) > 0) return left;
  61074. return right;
  61075. };
  61076. BN.min = function min (left, right) {
  61077. if (left.cmp(right) < 0) return left;
  61078. return right;
  61079. };
  61080. BN.prototype._init = function init (number, base, endian) {
  61081. if (typeof number === 'number') {
  61082. return this._initNumber(number, base, endian);
  61083. }
  61084. if (typeof number === 'object') {
  61085. return this._initArray(number, base, endian);
  61086. }
  61087. if (base === 'hex') {
  61088. base = 16;
  61089. }
  61090. assert(base === (base | 0) && base >= 2 && base <= 36);
  61091. number = number.toString().replace(/\s+/g, '');
  61092. var start = 0;
  61093. if (number[0] === '-') {
  61094. start++;
  61095. this.negative = 1;
  61096. }
  61097. if (start < number.length) {
  61098. if (base === 16) {
  61099. this._parseHex(number, start, endian);
  61100. } else {
  61101. this._parseBase(number, base, start);
  61102. if (endian === 'le') {
  61103. this._initArray(this.toArray(), base, endian);
  61104. }
  61105. }
  61106. }
  61107. };
  61108. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  61109. if (number < 0) {
  61110. this.negative = 1;
  61111. number = -number;
  61112. }
  61113. if (number < 0x4000000) {
  61114. this.words = [ number & 0x3ffffff ];
  61115. this.length = 1;
  61116. } else if (number < 0x10000000000000) {
  61117. this.words = [
  61118. number & 0x3ffffff,
  61119. (number / 0x4000000) & 0x3ffffff
  61120. ];
  61121. this.length = 2;
  61122. } else {
  61123. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  61124. this.words = [
  61125. number & 0x3ffffff,
  61126. (number / 0x4000000) & 0x3ffffff,
  61127. 1
  61128. ];
  61129. this.length = 3;
  61130. }
  61131. if (endian !== 'le') return;
  61132. // Reverse the bytes
  61133. this._initArray(this.toArray(), base, endian);
  61134. };
  61135. BN.prototype._initArray = function _initArray (number, base, endian) {
  61136. // Perhaps a Uint8Array
  61137. assert(typeof number.length === 'number');
  61138. if (number.length <= 0) {
  61139. this.words = [ 0 ];
  61140. this.length = 1;
  61141. return this;
  61142. }
  61143. this.length = Math.ceil(number.length / 3);
  61144. this.words = new Array(this.length);
  61145. for (var i = 0; i < this.length; i++) {
  61146. this.words[i] = 0;
  61147. }
  61148. var j, w;
  61149. var off = 0;
  61150. if (endian === 'be') {
  61151. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  61152. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  61153. this.words[j] |= (w << off) & 0x3ffffff;
  61154. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  61155. off += 24;
  61156. if (off >= 26) {
  61157. off -= 26;
  61158. j++;
  61159. }
  61160. }
  61161. } else if (endian === 'le') {
  61162. for (i = 0, j = 0; i < number.length; i += 3) {
  61163. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  61164. this.words[j] |= (w << off) & 0x3ffffff;
  61165. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  61166. off += 24;
  61167. if (off >= 26) {
  61168. off -= 26;
  61169. j++;
  61170. }
  61171. }
  61172. }
  61173. return this.strip();
  61174. };
  61175. function parseHex4Bits (string, index) {
  61176. var c = string.charCodeAt(index);
  61177. // 'A' - 'F'
  61178. if (c >= 65 && c <= 70) {
  61179. return c - 55;
  61180. // 'a' - 'f'
  61181. } else if (c >= 97 && c <= 102) {
  61182. return c - 87;
  61183. // '0' - '9'
  61184. } else {
  61185. return (c - 48) & 0xf;
  61186. }
  61187. }
  61188. function parseHexByte (string, lowerBound, index) {
  61189. var r = parseHex4Bits(string, index);
  61190. if (index - 1 >= lowerBound) {
  61191. r |= parseHex4Bits(string, index - 1) << 4;
  61192. }
  61193. return r;
  61194. }
  61195. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  61196. // Create possibly bigger array to ensure that it fits the number
  61197. this.length = Math.ceil((number.length - start) / 6);
  61198. this.words = new Array(this.length);
  61199. for (var i = 0; i < this.length; i++) {
  61200. this.words[i] = 0;
  61201. }
  61202. // 24-bits chunks
  61203. var off = 0;
  61204. var j = 0;
  61205. var w;
  61206. if (endian === 'be') {
  61207. for (i = number.length - 1; i >= start; i -= 2) {
  61208. w = parseHexByte(number, start, i) << off;
  61209. this.words[j] |= w & 0x3ffffff;
  61210. if (off >= 18) {
  61211. off -= 18;
  61212. j += 1;
  61213. this.words[j] |= w >>> 26;
  61214. } else {
  61215. off += 8;
  61216. }
  61217. }
  61218. } else {
  61219. var parseLength = number.length - start;
  61220. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  61221. w = parseHexByte(number, start, i) << off;
  61222. this.words[j] |= w & 0x3ffffff;
  61223. if (off >= 18) {
  61224. off -= 18;
  61225. j += 1;
  61226. this.words[j] |= w >>> 26;
  61227. } else {
  61228. off += 8;
  61229. }
  61230. }
  61231. }
  61232. this.strip();
  61233. };
  61234. function parseBase (str, start, end, mul) {
  61235. var r = 0;
  61236. var len = Math.min(str.length, end);
  61237. for (var i = start; i < len; i++) {
  61238. var c = str.charCodeAt(i) - 48;
  61239. r *= mul;
  61240. // 'a'
  61241. if (c >= 49) {
  61242. r += c - 49 + 0xa;
  61243. // 'A'
  61244. } else if (c >= 17) {
  61245. r += c - 17 + 0xa;
  61246. // '0' - '9'
  61247. } else {
  61248. r += c;
  61249. }
  61250. }
  61251. return r;
  61252. }
  61253. BN.prototype._parseBase = function _parseBase (number, base, start) {
  61254. // Initialize as zero
  61255. this.words = [ 0 ];
  61256. this.length = 1;
  61257. // Find length of limb in base
  61258. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  61259. limbLen++;
  61260. }
  61261. limbLen--;
  61262. limbPow = (limbPow / base) | 0;
  61263. var total = number.length - start;
  61264. var mod = total % limbLen;
  61265. var end = Math.min(total, total - mod) + start;
  61266. var word = 0;
  61267. for (var i = start; i < end; i += limbLen) {
  61268. word = parseBase(number, i, i + limbLen, base);
  61269. this.imuln(limbPow);
  61270. if (this.words[0] + word < 0x4000000) {
  61271. this.words[0] += word;
  61272. } else {
  61273. this._iaddn(word);
  61274. }
  61275. }
  61276. if (mod !== 0) {
  61277. var pow = 1;
  61278. word = parseBase(number, i, number.length, base);
  61279. for (i = 0; i < mod; i++) {
  61280. pow *= base;
  61281. }
  61282. this.imuln(pow);
  61283. if (this.words[0] + word < 0x4000000) {
  61284. this.words[0] += word;
  61285. } else {
  61286. this._iaddn(word);
  61287. }
  61288. }
  61289. this.strip();
  61290. };
  61291. BN.prototype.copy = function copy (dest) {
  61292. dest.words = new Array(this.length);
  61293. for (var i = 0; i < this.length; i++) {
  61294. dest.words[i] = this.words[i];
  61295. }
  61296. dest.length = this.length;
  61297. dest.negative = this.negative;
  61298. dest.red = this.red;
  61299. };
  61300. BN.prototype.clone = function clone () {
  61301. var r = new BN(null);
  61302. this.copy(r);
  61303. return r;
  61304. };
  61305. BN.prototype._expand = function _expand (size) {
  61306. while (this.length < size) {
  61307. this.words[this.length++] = 0;
  61308. }
  61309. return this;
  61310. };
  61311. // Remove leading `0` from `this`
  61312. BN.prototype.strip = function strip () {
  61313. while (this.length > 1 && this.words[this.length - 1] === 0) {
  61314. this.length--;
  61315. }
  61316. return this._normSign();
  61317. };
  61318. BN.prototype._normSign = function _normSign () {
  61319. // -0 = 0
  61320. if (this.length === 1 && this.words[0] === 0) {
  61321. this.negative = 0;
  61322. }
  61323. return this;
  61324. };
  61325. BN.prototype.inspect = function inspect () {
  61326. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  61327. };
  61328. /*
  61329. var zeros = [];
  61330. var groupSizes = [];
  61331. var groupBases = [];
  61332. var s = '';
  61333. var i = -1;
  61334. while (++i < BN.wordSize) {
  61335. zeros[i] = s;
  61336. s += '0';
  61337. }
  61338. groupSizes[0] = 0;
  61339. groupSizes[1] = 0;
  61340. groupBases[0] = 0;
  61341. groupBases[1] = 0;
  61342. var base = 2 - 1;
  61343. while (++base < 36 + 1) {
  61344. var groupSize = 0;
  61345. var groupBase = 1;
  61346. while (groupBase < (1 << BN.wordSize) / base) {
  61347. groupBase *= base;
  61348. groupSize += 1;
  61349. }
  61350. groupSizes[base] = groupSize;
  61351. groupBases[base] = groupBase;
  61352. }
  61353. */
  61354. var zeros = [
  61355. '',
  61356. '0',
  61357. '00',
  61358. '000',
  61359. '0000',
  61360. '00000',
  61361. '000000',
  61362. '0000000',
  61363. '00000000',
  61364. '000000000',
  61365. '0000000000',
  61366. '00000000000',
  61367. '000000000000',
  61368. '0000000000000',
  61369. '00000000000000',
  61370. '000000000000000',
  61371. '0000000000000000',
  61372. '00000000000000000',
  61373. '000000000000000000',
  61374. '0000000000000000000',
  61375. '00000000000000000000',
  61376. '000000000000000000000',
  61377. '0000000000000000000000',
  61378. '00000000000000000000000',
  61379. '000000000000000000000000',
  61380. '0000000000000000000000000'
  61381. ];
  61382. var groupSizes = [
  61383. 0, 0,
  61384. 25, 16, 12, 11, 10, 9, 8,
  61385. 8, 7, 7, 7, 7, 6, 6,
  61386. 6, 6, 6, 6, 6, 5, 5,
  61387. 5, 5, 5, 5, 5, 5, 5,
  61388. 5, 5, 5, 5, 5, 5, 5
  61389. ];
  61390. var groupBases = [
  61391. 0, 0,
  61392. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  61393. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  61394. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  61395. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  61396. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  61397. ];
  61398. BN.prototype.toString = function toString (base, padding) {
  61399. base = base || 10;
  61400. padding = padding | 0 || 1;
  61401. var out;
  61402. if (base === 16 || base === 'hex') {
  61403. out = '';
  61404. var off = 0;
  61405. var carry = 0;
  61406. for (var i = 0; i < this.length; i++) {
  61407. var w = this.words[i];
  61408. var word = (((w << off) | carry) & 0xffffff).toString(16);
  61409. carry = (w >>> (24 - off)) & 0xffffff;
  61410. if (carry !== 0 || i !== this.length - 1) {
  61411. out = zeros[6 - word.length] + word + out;
  61412. } else {
  61413. out = word + out;
  61414. }
  61415. off += 2;
  61416. if (off >= 26) {
  61417. off -= 26;
  61418. i--;
  61419. }
  61420. }
  61421. if (carry !== 0) {
  61422. out = carry.toString(16) + out;
  61423. }
  61424. while (out.length % padding !== 0) {
  61425. out = '0' + out;
  61426. }
  61427. if (this.negative !== 0) {
  61428. out = '-' + out;
  61429. }
  61430. return out;
  61431. }
  61432. if (base === (base | 0) && base >= 2 && base <= 36) {
  61433. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  61434. var groupSize = groupSizes[base];
  61435. // var groupBase = Math.pow(base, groupSize);
  61436. var groupBase = groupBases[base];
  61437. out = '';
  61438. var c = this.clone();
  61439. c.negative = 0;
  61440. while (!c.isZero()) {
  61441. var r = c.modn(groupBase).toString(base);
  61442. c = c.idivn(groupBase);
  61443. if (!c.isZero()) {
  61444. out = zeros[groupSize - r.length] + r + out;
  61445. } else {
  61446. out = r + out;
  61447. }
  61448. }
  61449. if (this.isZero()) {
  61450. out = '0' + out;
  61451. }
  61452. while (out.length % padding !== 0) {
  61453. out = '0' + out;
  61454. }
  61455. if (this.negative !== 0) {
  61456. out = '-' + out;
  61457. }
  61458. return out;
  61459. }
  61460. assert(false, 'Base should be between 2 and 36');
  61461. };
  61462. BN.prototype.toNumber = function toNumber () {
  61463. var ret = this.words[0];
  61464. if (this.length === 2) {
  61465. ret += this.words[1] * 0x4000000;
  61466. } else if (this.length === 3 && this.words[2] === 0x01) {
  61467. // NOTE: at this stage it is known that the top bit is set
  61468. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  61469. } else if (this.length > 2) {
  61470. assert(false, 'Number can only safely store up to 53 bits');
  61471. }
  61472. return (this.negative !== 0) ? -ret : ret;
  61473. };
  61474. BN.prototype.toJSON = function toJSON () {
  61475. return this.toString(16);
  61476. };
  61477. BN.prototype.toBuffer = function toBuffer (endian, length) {
  61478. assert(typeof Buffer !== 'undefined');
  61479. return this.toArrayLike(Buffer, endian, length);
  61480. };
  61481. BN.prototype.toArray = function toArray (endian, length) {
  61482. return this.toArrayLike(Array, endian, length);
  61483. };
  61484. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  61485. var byteLength = this.byteLength();
  61486. var reqLength = length || Math.max(1, byteLength);
  61487. assert(byteLength <= reqLength, 'byte array longer than desired length');
  61488. assert(reqLength > 0, 'Requested array length <= 0');
  61489. this.strip();
  61490. var littleEndian = endian === 'le';
  61491. var res = new ArrayType(reqLength);
  61492. var b, i;
  61493. var q = this.clone();
  61494. if (!littleEndian) {
  61495. // Assume big-endian
  61496. for (i = 0; i < reqLength - byteLength; i++) {
  61497. res[i] = 0;
  61498. }
  61499. for (i = 0; !q.isZero(); i++) {
  61500. b = q.andln(0xff);
  61501. q.iushrn(8);
  61502. res[reqLength - i - 1] = b;
  61503. }
  61504. } else {
  61505. for (i = 0; !q.isZero(); i++) {
  61506. b = q.andln(0xff);
  61507. q.iushrn(8);
  61508. res[i] = b;
  61509. }
  61510. for (; i < reqLength; i++) {
  61511. res[i] = 0;
  61512. }
  61513. }
  61514. return res;
  61515. };
  61516. if (Math.clz32) {
  61517. BN.prototype._countBits = function _countBits (w) {
  61518. return 32 - Math.clz32(w);
  61519. };
  61520. } else {
  61521. BN.prototype._countBits = function _countBits (w) {
  61522. var t = w;
  61523. var r = 0;
  61524. if (t >= 0x1000) {
  61525. r += 13;
  61526. t >>>= 13;
  61527. }
  61528. if (t >= 0x40) {
  61529. r += 7;
  61530. t >>>= 7;
  61531. }
  61532. if (t >= 0x8) {
  61533. r += 4;
  61534. t >>>= 4;
  61535. }
  61536. if (t >= 0x02) {
  61537. r += 2;
  61538. t >>>= 2;
  61539. }
  61540. return r + t;
  61541. };
  61542. }
  61543. BN.prototype._zeroBits = function _zeroBits (w) {
  61544. // Short-cut
  61545. if (w === 0) return 26;
  61546. var t = w;
  61547. var r = 0;
  61548. if ((t & 0x1fff) === 0) {
  61549. r += 13;
  61550. t >>>= 13;
  61551. }
  61552. if ((t & 0x7f) === 0) {
  61553. r += 7;
  61554. t >>>= 7;
  61555. }
  61556. if ((t & 0xf) === 0) {
  61557. r += 4;
  61558. t >>>= 4;
  61559. }
  61560. if ((t & 0x3) === 0) {
  61561. r += 2;
  61562. t >>>= 2;
  61563. }
  61564. if ((t & 0x1) === 0) {
  61565. r++;
  61566. }
  61567. return r;
  61568. };
  61569. // Return number of used bits in a BN
  61570. BN.prototype.bitLength = function bitLength () {
  61571. var w = this.words[this.length - 1];
  61572. var hi = this._countBits(w);
  61573. return (this.length - 1) * 26 + hi;
  61574. };
  61575. function toBitArray (num) {
  61576. var w = new Array(num.bitLength());
  61577. for (var bit = 0; bit < w.length; bit++) {
  61578. var off = (bit / 26) | 0;
  61579. var wbit = bit % 26;
  61580. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  61581. }
  61582. return w;
  61583. }
  61584. // Number of trailing zero bits
  61585. BN.prototype.zeroBits = function zeroBits () {
  61586. if (this.isZero()) return 0;
  61587. var r = 0;
  61588. for (var i = 0; i < this.length; i++) {
  61589. var b = this._zeroBits(this.words[i]);
  61590. r += b;
  61591. if (b !== 26) break;
  61592. }
  61593. return r;
  61594. };
  61595. BN.prototype.byteLength = function byteLength () {
  61596. return Math.ceil(this.bitLength() / 8);
  61597. };
  61598. BN.prototype.toTwos = function toTwos (width) {
  61599. if (this.negative !== 0) {
  61600. return this.abs().inotn(width).iaddn(1);
  61601. }
  61602. return this.clone();
  61603. };
  61604. BN.prototype.fromTwos = function fromTwos (width) {
  61605. if (this.testn(width - 1)) {
  61606. return this.notn(width).iaddn(1).ineg();
  61607. }
  61608. return this.clone();
  61609. };
  61610. BN.prototype.isNeg = function isNeg () {
  61611. return this.negative !== 0;
  61612. };
  61613. // Return negative clone of `this`
  61614. BN.prototype.neg = function neg () {
  61615. return this.clone().ineg();
  61616. };
  61617. BN.prototype.ineg = function ineg () {
  61618. if (!this.isZero()) {
  61619. this.negative ^= 1;
  61620. }
  61621. return this;
  61622. };
  61623. // Or `num` with `this` in-place
  61624. BN.prototype.iuor = function iuor (num) {
  61625. while (this.length < num.length) {
  61626. this.words[this.length++] = 0;
  61627. }
  61628. for (var i = 0; i < num.length; i++) {
  61629. this.words[i] = this.words[i] | num.words[i];
  61630. }
  61631. return this.strip();
  61632. };
  61633. BN.prototype.ior = function ior (num) {
  61634. assert((this.negative | num.negative) === 0);
  61635. return this.iuor(num);
  61636. };
  61637. // Or `num` with `this`
  61638. BN.prototype.or = function or (num) {
  61639. if (this.length > num.length) return this.clone().ior(num);
  61640. return num.clone().ior(this);
  61641. };
  61642. BN.prototype.uor = function uor (num) {
  61643. if (this.length > num.length) return this.clone().iuor(num);
  61644. return num.clone().iuor(this);
  61645. };
  61646. // And `num` with `this` in-place
  61647. BN.prototype.iuand = function iuand (num) {
  61648. // b = min-length(num, this)
  61649. var b;
  61650. if (this.length > num.length) {
  61651. b = num;
  61652. } else {
  61653. b = this;
  61654. }
  61655. for (var i = 0; i < b.length; i++) {
  61656. this.words[i] = this.words[i] & num.words[i];
  61657. }
  61658. this.length = b.length;
  61659. return this.strip();
  61660. };
  61661. BN.prototype.iand = function iand (num) {
  61662. assert((this.negative | num.negative) === 0);
  61663. return this.iuand(num);
  61664. };
  61665. // And `num` with `this`
  61666. BN.prototype.and = function and (num) {
  61667. if (this.length > num.length) return this.clone().iand(num);
  61668. return num.clone().iand(this);
  61669. };
  61670. BN.prototype.uand = function uand (num) {
  61671. if (this.length > num.length) return this.clone().iuand(num);
  61672. return num.clone().iuand(this);
  61673. };
  61674. // Xor `num` with `this` in-place
  61675. BN.prototype.iuxor = function iuxor (num) {
  61676. // a.length > b.length
  61677. var a;
  61678. var b;
  61679. if (this.length > num.length) {
  61680. a = this;
  61681. b = num;
  61682. } else {
  61683. a = num;
  61684. b = this;
  61685. }
  61686. for (var i = 0; i < b.length; i++) {
  61687. this.words[i] = a.words[i] ^ b.words[i];
  61688. }
  61689. if (this !== a) {
  61690. for (; i < a.length; i++) {
  61691. this.words[i] = a.words[i];
  61692. }
  61693. }
  61694. this.length = a.length;
  61695. return this.strip();
  61696. };
  61697. BN.prototype.ixor = function ixor (num) {
  61698. assert((this.negative | num.negative) === 0);
  61699. return this.iuxor(num);
  61700. };
  61701. // Xor `num` with `this`
  61702. BN.prototype.xor = function xor (num) {
  61703. if (this.length > num.length) return this.clone().ixor(num);
  61704. return num.clone().ixor(this);
  61705. };
  61706. BN.prototype.uxor = function uxor (num) {
  61707. if (this.length > num.length) return this.clone().iuxor(num);
  61708. return num.clone().iuxor(this);
  61709. };
  61710. // Not ``this`` with ``width`` bitwidth
  61711. BN.prototype.inotn = function inotn (width) {
  61712. assert(typeof width === 'number' && width >= 0);
  61713. var bytesNeeded = Math.ceil(width / 26) | 0;
  61714. var bitsLeft = width % 26;
  61715. // Extend the buffer with leading zeroes
  61716. this._expand(bytesNeeded);
  61717. if (bitsLeft > 0) {
  61718. bytesNeeded--;
  61719. }
  61720. // Handle complete words
  61721. for (var i = 0; i < bytesNeeded; i++) {
  61722. this.words[i] = ~this.words[i] & 0x3ffffff;
  61723. }
  61724. // Handle the residue
  61725. if (bitsLeft > 0) {
  61726. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  61727. }
  61728. // And remove leading zeroes
  61729. return this.strip();
  61730. };
  61731. BN.prototype.notn = function notn (width) {
  61732. return this.clone().inotn(width);
  61733. };
  61734. // Set `bit` of `this`
  61735. BN.prototype.setn = function setn (bit, val) {
  61736. assert(typeof bit === 'number' && bit >= 0);
  61737. var off = (bit / 26) | 0;
  61738. var wbit = bit % 26;
  61739. this._expand(off + 1);
  61740. if (val) {
  61741. this.words[off] = this.words[off] | (1 << wbit);
  61742. } else {
  61743. this.words[off] = this.words[off] & ~(1 << wbit);
  61744. }
  61745. return this.strip();
  61746. };
  61747. // Add `num` to `this` in-place
  61748. BN.prototype.iadd = function iadd (num) {
  61749. var r;
  61750. // negative + positive
  61751. if (this.negative !== 0 && num.negative === 0) {
  61752. this.negative = 0;
  61753. r = this.isub(num);
  61754. this.negative ^= 1;
  61755. return this._normSign();
  61756. // positive + negative
  61757. } else if (this.negative === 0 && num.negative !== 0) {
  61758. num.negative = 0;
  61759. r = this.isub(num);
  61760. num.negative = 1;
  61761. return r._normSign();
  61762. }
  61763. // a.length > b.length
  61764. var a, b;
  61765. if (this.length > num.length) {
  61766. a = this;
  61767. b = num;
  61768. } else {
  61769. a = num;
  61770. b = this;
  61771. }
  61772. var carry = 0;
  61773. for (var i = 0; i < b.length; i++) {
  61774. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  61775. this.words[i] = r & 0x3ffffff;
  61776. carry = r >>> 26;
  61777. }
  61778. for (; carry !== 0 && i < a.length; i++) {
  61779. r = (a.words[i] | 0) + carry;
  61780. this.words[i] = r & 0x3ffffff;
  61781. carry = r >>> 26;
  61782. }
  61783. this.length = a.length;
  61784. if (carry !== 0) {
  61785. this.words[this.length] = carry;
  61786. this.length++;
  61787. // Copy the rest of the words
  61788. } else if (a !== this) {
  61789. for (; i < a.length; i++) {
  61790. this.words[i] = a.words[i];
  61791. }
  61792. }
  61793. return this;
  61794. };
  61795. // Add `num` to `this`
  61796. BN.prototype.add = function add (num) {
  61797. var res;
  61798. if (num.negative !== 0 && this.negative === 0) {
  61799. num.negative = 0;
  61800. res = this.sub(num);
  61801. num.negative ^= 1;
  61802. return res;
  61803. } else if (num.negative === 0 && this.negative !== 0) {
  61804. this.negative = 0;
  61805. res = num.sub(this);
  61806. this.negative = 1;
  61807. return res;
  61808. }
  61809. if (this.length > num.length) return this.clone().iadd(num);
  61810. return num.clone().iadd(this);
  61811. };
  61812. // Subtract `num` from `this` in-place
  61813. BN.prototype.isub = function isub (num) {
  61814. // this - (-num) = this + num
  61815. if (num.negative !== 0) {
  61816. num.negative = 0;
  61817. var r = this.iadd(num);
  61818. num.negative = 1;
  61819. return r._normSign();
  61820. // -this - num = -(this + num)
  61821. } else if (this.negative !== 0) {
  61822. this.negative = 0;
  61823. this.iadd(num);
  61824. this.negative = 1;
  61825. return this._normSign();
  61826. }
  61827. // At this point both numbers are positive
  61828. var cmp = this.cmp(num);
  61829. // Optimization - zeroify
  61830. if (cmp === 0) {
  61831. this.negative = 0;
  61832. this.length = 1;
  61833. this.words[0] = 0;
  61834. return this;
  61835. }
  61836. // a > b
  61837. var a, b;
  61838. if (cmp > 0) {
  61839. a = this;
  61840. b = num;
  61841. } else {
  61842. a = num;
  61843. b = this;
  61844. }
  61845. var carry = 0;
  61846. for (var i = 0; i < b.length; i++) {
  61847. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  61848. carry = r >> 26;
  61849. this.words[i] = r & 0x3ffffff;
  61850. }
  61851. for (; carry !== 0 && i < a.length; i++) {
  61852. r = (a.words[i] | 0) + carry;
  61853. carry = r >> 26;
  61854. this.words[i] = r & 0x3ffffff;
  61855. }
  61856. // Copy rest of the words
  61857. if (carry === 0 && i < a.length && a !== this) {
  61858. for (; i < a.length; i++) {
  61859. this.words[i] = a.words[i];
  61860. }
  61861. }
  61862. this.length = Math.max(this.length, i);
  61863. if (a !== this) {
  61864. this.negative = 1;
  61865. }
  61866. return this.strip();
  61867. };
  61868. // Subtract `num` from `this`
  61869. BN.prototype.sub = function sub (num) {
  61870. return this.clone().isub(num);
  61871. };
  61872. function smallMulTo (self, num, out) {
  61873. out.negative = num.negative ^ self.negative;
  61874. var len = (self.length + num.length) | 0;
  61875. out.length = len;
  61876. len = (len - 1) | 0;
  61877. // Peel one iteration (compiler can't do it, because of code complexity)
  61878. var a = self.words[0] | 0;
  61879. var b = num.words[0] | 0;
  61880. var r = a * b;
  61881. var lo = r & 0x3ffffff;
  61882. var carry = (r / 0x4000000) | 0;
  61883. out.words[0] = lo;
  61884. for (var k = 1; k < len; k++) {
  61885. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  61886. // note that ncarry could be >= 0x3ffffff
  61887. var ncarry = carry >>> 26;
  61888. var rword = carry & 0x3ffffff;
  61889. var maxJ = Math.min(k, num.length - 1);
  61890. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  61891. var i = (k - j) | 0;
  61892. a = self.words[i] | 0;
  61893. b = num.words[j] | 0;
  61894. r = a * b + rword;
  61895. ncarry += (r / 0x4000000) | 0;
  61896. rword = r & 0x3ffffff;
  61897. }
  61898. out.words[k] = rword | 0;
  61899. carry = ncarry | 0;
  61900. }
  61901. if (carry !== 0) {
  61902. out.words[k] = carry | 0;
  61903. } else {
  61904. out.length--;
  61905. }
  61906. return out.strip();
  61907. }
  61908. // TODO(indutny): it may be reasonable to omit it for users who don't need
  61909. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  61910. // multiplication (like elliptic secp256k1).
  61911. var comb10MulTo = function comb10MulTo (self, num, out) {
  61912. var a = self.words;
  61913. var b = num.words;
  61914. var o = out.words;
  61915. var c = 0;
  61916. var lo;
  61917. var mid;
  61918. var hi;
  61919. var a0 = a[0] | 0;
  61920. var al0 = a0 & 0x1fff;
  61921. var ah0 = a0 >>> 13;
  61922. var a1 = a[1] | 0;
  61923. var al1 = a1 & 0x1fff;
  61924. var ah1 = a1 >>> 13;
  61925. var a2 = a[2] | 0;
  61926. var al2 = a2 & 0x1fff;
  61927. var ah2 = a2 >>> 13;
  61928. var a3 = a[3] | 0;
  61929. var al3 = a3 & 0x1fff;
  61930. var ah3 = a3 >>> 13;
  61931. var a4 = a[4] | 0;
  61932. var al4 = a4 & 0x1fff;
  61933. var ah4 = a4 >>> 13;
  61934. var a5 = a[5] | 0;
  61935. var al5 = a5 & 0x1fff;
  61936. var ah5 = a5 >>> 13;
  61937. var a6 = a[6] | 0;
  61938. var al6 = a6 & 0x1fff;
  61939. var ah6 = a6 >>> 13;
  61940. var a7 = a[7] | 0;
  61941. var al7 = a7 & 0x1fff;
  61942. var ah7 = a7 >>> 13;
  61943. var a8 = a[8] | 0;
  61944. var al8 = a8 & 0x1fff;
  61945. var ah8 = a8 >>> 13;
  61946. var a9 = a[9] | 0;
  61947. var al9 = a9 & 0x1fff;
  61948. var ah9 = a9 >>> 13;
  61949. var b0 = b[0] | 0;
  61950. var bl0 = b0 & 0x1fff;
  61951. var bh0 = b0 >>> 13;
  61952. var b1 = b[1] | 0;
  61953. var bl1 = b1 & 0x1fff;
  61954. var bh1 = b1 >>> 13;
  61955. var b2 = b[2] | 0;
  61956. var bl2 = b2 & 0x1fff;
  61957. var bh2 = b2 >>> 13;
  61958. var b3 = b[3] | 0;
  61959. var bl3 = b3 & 0x1fff;
  61960. var bh3 = b3 >>> 13;
  61961. var b4 = b[4] | 0;
  61962. var bl4 = b4 & 0x1fff;
  61963. var bh4 = b4 >>> 13;
  61964. var b5 = b[5] | 0;
  61965. var bl5 = b5 & 0x1fff;
  61966. var bh5 = b5 >>> 13;
  61967. var b6 = b[6] | 0;
  61968. var bl6 = b6 & 0x1fff;
  61969. var bh6 = b6 >>> 13;
  61970. var b7 = b[7] | 0;
  61971. var bl7 = b7 & 0x1fff;
  61972. var bh7 = b7 >>> 13;
  61973. var b8 = b[8] | 0;
  61974. var bl8 = b8 & 0x1fff;
  61975. var bh8 = b8 >>> 13;
  61976. var b9 = b[9] | 0;
  61977. var bl9 = b9 & 0x1fff;
  61978. var bh9 = b9 >>> 13;
  61979. out.negative = self.negative ^ num.negative;
  61980. out.length = 19;
  61981. /* k = 0 */
  61982. lo = Math.imul(al0, bl0);
  61983. mid = Math.imul(al0, bh0);
  61984. mid = (mid + Math.imul(ah0, bl0)) | 0;
  61985. hi = Math.imul(ah0, bh0);
  61986. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  61987. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  61988. w0 &= 0x3ffffff;
  61989. /* k = 1 */
  61990. lo = Math.imul(al1, bl0);
  61991. mid = Math.imul(al1, bh0);
  61992. mid = (mid + Math.imul(ah1, bl0)) | 0;
  61993. hi = Math.imul(ah1, bh0);
  61994. lo = (lo + Math.imul(al0, bl1)) | 0;
  61995. mid = (mid + Math.imul(al0, bh1)) | 0;
  61996. mid = (mid + Math.imul(ah0, bl1)) | 0;
  61997. hi = (hi + Math.imul(ah0, bh1)) | 0;
  61998. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  61999. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  62000. w1 &= 0x3ffffff;
  62001. /* k = 2 */
  62002. lo = Math.imul(al2, bl0);
  62003. mid = Math.imul(al2, bh0);
  62004. mid = (mid + Math.imul(ah2, bl0)) | 0;
  62005. hi = Math.imul(ah2, bh0);
  62006. lo = (lo + Math.imul(al1, bl1)) | 0;
  62007. mid = (mid + Math.imul(al1, bh1)) | 0;
  62008. mid = (mid + Math.imul(ah1, bl1)) | 0;
  62009. hi = (hi + Math.imul(ah1, bh1)) | 0;
  62010. lo = (lo + Math.imul(al0, bl2)) | 0;
  62011. mid = (mid + Math.imul(al0, bh2)) | 0;
  62012. mid = (mid + Math.imul(ah0, bl2)) | 0;
  62013. hi = (hi + Math.imul(ah0, bh2)) | 0;
  62014. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62015. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  62016. w2 &= 0x3ffffff;
  62017. /* k = 3 */
  62018. lo = Math.imul(al3, bl0);
  62019. mid = Math.imul(al3, bh0);
  62020. mid = (mid + Math.imul(ah3, bl0)) | 0;
  62021. hi = Math.imul(ah3, bh0);
  62022. lo = (lo + Math.imul(al2, bl1)) | 0;
  62023. mid = (mid + Math.imul(al2, bh1)) | 0;
  62024. mid = (mid + Math.imul(ah2, bl1)) | 0;
  62025. hi = (hi + Math.imul(ah2, bh1)) | 0;
  62026. lo = (lo + Math.imul(al1, bl2)) | 0;
  62027. mid = (mid + Math.imul(al1, bh2)) | 0;
  62028. mid = (mid + Math.imul(ah1, bl2)) | 0;
  62029. hi = (hi + Math.imul(ah1, bh2)) | 0;
  62030. lo = (lo + Math.imul(al0, bl3)) | 0;
  62031. mid = (mid + Math.imul(al0, bh3)) | 0;
  62032. mid = (mid + Math.imul(ah0, bl3)) | 0;
  62033. hi = (hi + Math.imul(ah0, bh3)) | 0;
  62034. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62035. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  62036. w3 &= 0x3ffffff;
  62037. /* k = 4 */
  62038. lo = Math.imul(al4, bl0);
  62039. mid = Math.imul(al4, bh0);
  62040. mid = (mid + Math.imul(ah4, bl0)) | 0;
  62041. hi = Math.imul(ah4, bh0);
  62042. lo = (lo + Math.imul(al3, bl1)) | 0;
  62043. mid = (mid + Math.imul(al3, bh1)) | 0;
  62044. mid = (mid + Math.imul(ah3, bl1)) | 0;
  62045. hi = (hi + Math.imul(ah3, bh1)) | 0;
  62046. lo = (lo + Math.imul(al2, bl2)) | 0;
  62047. mid = (mid + Math.imul(al2, bh2)) | 0;
  62048. mid = (mid + Math.imul(ah2, bl2)) | 0;
  62049. hi = (hi + Math.imul(ah2, bh2)) | 0;
  62050. lo = (lo + Math.imul(al1, bl3)) | 0;
  62051. mid = (mid + Math.imul(al1, bh3)) | 0;
  62052. mid = (mid + Math.imul(ah1, bl3)) | 0;
  62053. hi = (hi + Math.imul(ah1, bh3)) | 0;
  62054. lo = (lo + Math.imul(al0, bl4)) | 0;
  62055. mid = (mid + Math.imul(al0, bh4)) | 0;
  62056. mid = (mid + Math.imul(ah0, bl4)) | 0;
  62057. hi = (hi + Math.imul(ah0, bh4)) | 0;
  62058. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62059. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  62060. w4 &= 0x3ffffff;
  62061. /* k = 5 */
  62062. lo = Math.imul(al5, bl0);
  62063. mid = Math.imul(al5, bh0);
  62064. mid = (mid + Math.imul(ah5, bl0)) | 0;
  62065. hi = Math.imul(ah5, bh0);
  62066. lo = (lo + Math.imul(al4, bl1)) | 0;
  62067. mid = (mid + Math.imul(al4, bh1)) | 0;
  62068. mid = (mid + Math.imul(ah4, bl1)) | 0;
  62069. hi = (hi + Math.imul(ah4, bh1)) | 0;
  62070. lo = (lo + Math.imul(al3, bl2)) | 0;
  62071. mid = (mid + Math.imul(al3, bh2)) | 0;
  62072. mid = (mid + Math.imul(ah3, bl2)) | 0;
  62073. hi = (hi + Math.imul(ah3, bh2)) | 0;
  62074. lo = (lo + Math.imul(al2, bl3)) | 0;
  62075. mid = (mid + Math.imul(al2, bh3)) | 0;
  62076. mid = (mid + Math.imul(ah2, bl3)) | 0;
  62077. hi = (hi + Math.imul(ah2, bh3)) | 0;
  62078. lo = (lo + Math.imul(al1, bl4)) | 0;
  62079. mid = (mid + Math.imul(al1, bh4)) | 0;
  62080. mid = (mid + Math.imul(ah1, bl4)) | 0;
  62081. hi = (hi + Math.imul(ah1, bh4)) | 0;
  62082. lo = (lo + Math.imul(al0, bl5)) | 0;
  62083. mid = (mid + Math.imul(al0, bh5)) | 0;
  62084. mid = (mid + Math.imul(ah0, bl5)) | 0;
  62085. hi = (hi + Math.imul(ah0, bh5)) | 0;
  62086. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62087. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  62088. w5 &= 0x3ffffff;
  62089. /* k = 6 */
  62090. lo = Math.imul(al6, bl0);
  62091. mid = Math.imul(al6, bh0);
  62092. mid = (mid + Math.imul(ah6, bl0)) | 0;
  62093. hi = Math.imul(ah6, bh0);
  62094. lo = (lo + Math.imul(al5, bl1)) | 0;
  62095. mid = (mid + Math.imul(al5, bh1)) | 0;
  62096. mid = (mid + Math.imul(ah5, bl1)) | 0;
  62097. hi = (hi + Math.imul(ah5, bh1)) | 0;
  62098. lo = (lo + Math.imul(al4, bl2)) | 0;
  62099. mid = (mid + Math.imul(al4, bh2)) | 0;
  62100. mid = (mid + Math.imul(ah4, bl2)) | 0;
  62101. hi = (hi + Math.imul(ah4, bh2)) | 0;
  62102. lo = (lo + Math.imul(al3, bl3)) | 0;
  62103. mid = (mid + Math.imul(al3, bh3)) | 0;
  62104. mid = (mid + Math.imul(ah3, bl3)) | 0;
  62105. hi = (hi + Math.imul(ah3, bh3)) | 0;
  62106. lo = (lo + Math.imul(al2, bl4)) | 0;
  62107. mid = (mid + Math.imul(al2, bh4)) | 0;
  62108. mid = (mid + Math.imul(ah2, bl4)) | 0;
  62109. hi = (hi + Math.imul(ah2, bh4)) | 0;
  62110. lo = (lo + Math.imul(al1, bl5)) | 0;
  62111. mid = (mid + Math.imul(al1, bh5)) | 0;
  62112. mid = (mid + Math.imul(ah1, bl5)) | 0;
  62113. hi = (hi + Math.imul(ah1, bh5)) | 0;
  62114. lo = (lo + Math.imul(al0, bl6)) | 0;
  62115. mid = (mid + Math.imul(al0, bh6)) | 0;
  62116. mid = (mid + Math.imul(ah0, bl6)) | 0;
  62117. hi = (hi + Math.imul(ah0, bh6)) | 0;
  62118. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62119. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  62120. w6 &= 0x3ffffff;
  62121. /* k = 7 */
  62122. lo = Math.imul(al7, bl0);
  62123. mid = Math.imul(al7, bh0);
  62124. mid = (mid + Math.imul(ah7, bl0)) | 0;
  62125. hi = Math.imul(ah7, bh0);
  62126. lo = (lo + Math.imul(al6, bl1)) | 0;
  62127. mid = (mid + Math.imul(al6, bh1)) | 0;
  62128. mid = (mid + Math.imul(ah6, bl1)) | 0;
  62129. hi = (hi + Math.imul(ah6, bh1)) | 0;
  62130. lo = (lo + Math.imul(al5, bl2)) | 0;
  62131. mid = (mid + Math.imul(al5, bh2)) | 0;
  62132. mid = (mid + Math.imul(ah5, bl2)) | 0;
  62133. hi = (hi + Math.imul(ah5, bh2)) | 0;
  62134. lo = (lo + Math.imul(al4, bl3)) | 0;
  62135. mid = (mid + Math.imul(al4, bh3)) | 0;
  62136. mid = (mid + Math.imul(ah4, bl3)) | 0;
  62137. hi = (hi + Math.imul(ah4, bh3)) | 0;
  62138. lo = (lo + Math.imul(al3, bl4)) | 0;
  62139. mid = (mid + Math.imul(al3, bh4)) | 0;
  62140. mid = (mid + Math.imul(ah3, bl4)) | 0;
  62141. hi = (hi + Math.imul(ah3, bh4)) | 0;
  62142. lo = (lo + Math.imul(al2, bl5)) | 0;
  62143. mid = (mid + Math.imul(al2, bh5)) | 0;
  62144. mid = (mid + Math.imul(ah2, bl5)) | 0;
  62145. hi = (hi + Math.imul(ah2, bh5)) | 0;
  62146. lo = (lo + Math.imul(al1, bl6)) | 0;
  62147. mid = (mid + Math.imul(al1, bh6)) | 0;
  62148. mid = (mid + Math.imul(ah1, bl6)) | 0;
  62149. hi = (hi + Math.imul(ah1, bh6)) | 0;
  62150. lo = (lo + Math.imul(al0, bl7)) | 0;
  62151. mid = (mid + Math.imul(al0, bh7)) | 0;
  62152. mid = (mid + Math.imul(ah0, bl7)) | 0;
  62153. hi = (hi + Math.imul(ah0, bh7)) | 0;
  62154. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62155. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  62156. w7 &= 0x3ffffff;
  62157. /* k = 8 */
  62158. lo = Math.imul(al8, bl0);
  62159. mid = Math.imul(al8, bh0);
  62160. mid = (mid + Math.imul(ah8, bl0)) | 0;
  62161. hi = Math.imul(ah8, bh0);
  62162. lo = (lo + Math.imul(al7, bl1)) | 0;
  62163. mid = (mid + Math.imul(al7, bh1)) | 0;
  62164. mid = (mid + Math.imul(ah7, bl1)) | 0;
  62165. hi = (hi + Math.imul(ah7, bh1)) | 0;
  62166. lo = (lo + Math.imul(al6, bl2)) | 0;
  62167. mid = (mid + Math.imul(al6, bh2)) | 0;
  62168. mid = (mid + Math.imul(ah6, bl2)) | 0;
  62169. hi = (hi + Math.imul(ah6, bh2)) | 0;
  62170. lo = (lo + Math.imul(al5, bl3)) | 0;
  62171. mid = (mid + Math.imul(al5, bh3)) | 0;
  62172. mid = (mid + Math.imul(ah5, bl3)) | 0;
  62173. hi = (hi + Math.imul(ah5, bh3)) | 0;
  62174. lo = (lo + Math.imul(al4, bl4)) | 0;
  62175. mid = (mid + Math.imul(al4, bh4)) | 0;
  62176. mid = (mid + Math.imul(ah4, bl4)) | 0;
  62177. hi = (hi + Math.imul(ah4, bh4)) | 0;
  62178. lo = (lo + Math.imul(al3, bl5)) | 0;
  62179. mid = (mid + Math.imul(al3, bh5)) | 0;
  62180. mid = (mid + Math.imul(ah3, bl5)) | 0;
  62181. hi = (hi + Math.imul(ah3, bh5)) | 0;
  62182. lo = (lo + Math.imul(al2, bl6)) | 0;
  62183. mid = (mid + Math.imul(al2, bh6)) | 0;
  62184. mid = (mid + Math.imul(ah2, bl6)) | 0;
  62185. hi = (hi + Math.imul(ah2, bh6)) | 0;
  62186. lo = (lo + Math.imul(al1, bl7)) | 0;
  62187. mid = (mid + Math.imul(al1, bh7)) | 0;
  62188. mid = (mid + Math.imul(ah1, bl7)) | 0;
  62189. hi = (hi + Math.imul(ah1, bh7)) | 0;
  62190. lo = (lo + Math.imul(al0, bl8)) | 0;
  62191. mid = (mid + Math.imul(al0, bh8)) | 0;
  62192. mid = (mid + Math.imul(ah0, bl8)) | 0;
  62193. hi = (hi + Math.imul(ah0, bh8)) | 0;
  62194. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62195. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  62196. w8 &= 0x3ffffff;
  62197. /* k = 9 */
  62198. lo = Math.imul(al9, bl0);
  62199. mid = Math.imul(al9, bh0);
  62200. mid = (mid + Math.imul(ah9, bl0)) | 0;
  62201. hi = Math.imul(ah9, bh0);
  62202. lo = (lo + Math.imul(al8, bl1)) | 0;
  62203. mid = (mid + Math.imul(al8, bh1)) | 0;
  62204. mid = (mid + Math.imul(ah8, bl1)) | 0;
  62205. hi = (hi + Math.imul(ah8, bh1)) | 0;
  62206. lo = (lo + Math.imul(al7, bl2)) | 0;
  62207. mid = (mid + Math.imul(al7, bh2)) | 0;
  62208. mid = (mid + Math.imul(ah7, bl2)) | 0;
  62209. hi = (hi + Math.imul(ah7, bh2)) | 0;
  62210. lo = (lo + Math.imul(al6, bl3)) | 0;
  62211. mid = (mid + Math.imul(al6, bh3)) | 0;
  62212. mid = (mid + Math.imul(ah6, bl3)) | 0;
  62213. hi = (hi + Math.imul(ah6, bh3)) | 0;
  62214. lo = (lo + Math.imul(al5, bl4)) | 0;
  62215. mid = (mid + Math.imul(al5, bh4)) | 0;
  62216. mid = (mid + Math.imul(ah5, bl4)) | 0;
  62217. hi = (hi + Math.imul(ah5, bh4)) | 0;
  62218. lo = (lo + Math.imul(al4, bl5)) | 0;
  62219. mid = (mid + Math.imul(al4, bh5)) | 0;
  62220. mid = (mid + Math.imul(ah4, bl5)) | 0;
  62221. hi = (hi + Math.imul(ah4, bh5)) | 0;
  62222. lo = (lo + Math.imul(al3, bl6)) | 0;
  62223. mid = (mid + Math.imul(al3, bh6)) | 0;
  62224. mid = (mid + Math.imul(ah3, bl6)) | 0;
  62225. hi = (hi + Math.imul(ah3, bh6)) | 0;
  62226. lo = (lo + Math.imul(al2, bl7)) | 0;
  62227. mid = (mid + Math.imul(al2, bh7)) | 0;
  62228. mid = (mid + Math.imul(ah2, bl7)) | 0;
  62229. hi = (hi + Math.imul(ah2, bh7)) | 0;
  62230. lo = (lo + Math.imul(al1, bl8)) | 0;
  62231. mid = (mid + Math.imul(al1, bh8)) | 0;
  62232. mid = (mid + Math.imul(ah1, bl8)) | 0;
  62233. hi = (hi + Math.imul(ah1, bh8)) | 0;
  62234. lo = (lo + Math.imul(al0, bl9)) | 0;
  62235. mid = (mid + Math.imul(al0, bh9)) | 0;
  62236. mid = (mid + Math.imul(ah0, bl9)) | 0;
  62237. hi = (hi + Math.imul(ah0, bh9)) | 0;
  62238. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62239. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  62240. w9 &= 0x3ffffff;
  62241. /* k = 10 */
  62242. lo = Math.imul(al9, bl1);
  62243. mid = Math.imul(al9, bh1);
  62244. mid = (mid + Math.imul(ah9, bl1)) | 0;
  62245. hi = Math.imul(ah9, bh1);
  62246. lo = (lo + Math.imul(al8, bl2)) | 0;
  62247. mid = (mid + Math.imul(al8, bh2)) | 0;
  62248. mid = (mid + Math.imul(ah8, bl2)) | 0;
  62249. hi = (hi + Math.imul(ah8, bh2)) | 0;
  62250. lo = (lo + Math.imul(al7, bl3)) | 0;
  62251. mid = (mid + Math.imul(al7, bh3)) | 0;
  62252. mid = (mid + Math.imul(ah7, bl3)) | 0;
  62253. hi = (hi + Math.imul(ah7, bh3)) | 0;
  62254. lo = (lo + Math.imul(al6, bl4)) | 0;
  62255. mid = (mid + Math.imul(al6, bh4)) | 0;
  62256. mid = (mid + Math.imul(ah6, bl4)) | 0;
  62257. hi = (hi + Math.imul(ah6, bh4)) | 0;
  62258. lo = (lo + Math.imul(al5, bl5)) | 0;
  62259. mid = (mid + Math.imul(al5, bh5)) | 0;
  62260. mid = (mid + Math.imul(ah5, bl5)) | 0;
  62261. hi = (hi + Math.imul(ah5, bh5)) | 0;
  62262. lo = (lo + Math.imul(al4, bl6)) | 0;
  62263. mid = (mid + Math.imul(al4, bh6)) | 0;
  62264. mid = (mid + Math.imul(ah4, bl6)) | 0;
  62265. hi = (hi + Math.imul(ah4, bh6)) | 0;
  62266. lo = (lo + Math.imul(al3, bl7)) | 0;
  62267. mid = (mid + Math.imul(al3, bh7)) | 0;
  62268. mid = (mid + Math.imul(ah3, bl7)) | 0;
  62269. hi = (hi + Math.imul(ah3, bh7)) | 0;
  62270. lo = (lo + Math.imul(al2, bl8)) | 0;
  62271. mid = (mid + Math.imul(al2, bh8)) | 0;
  62272. mid = (mid + Math.imul(ah2, bl8)) | 0;
  62273. hi = (hi + Math.imul(ah2, bh8)) | 0;
  62274. lo = (lo + Math.imul(al1, bl9)) | 0;
  62275. mid = (mid + Math.imul(al1, bh9)) | 0;
  62276. mid = (mid + Math.imul(ah1, bl9)) | 0;
  62277. hi = (hi + Math.imul(ah1, bh9)) | 0;
  62278. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62279. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  62280. w10 &= 0x3ffffff;
  62281. /* k = 11 */
  62282. lo = Math.imul(al9, bl2);
  62283. mid = Math.imul(al9, bh2);
  62284. mid = (mid + Math.imul(ah9, bl2)) | 0;
  62285. hi = Math.imul(ah9, bh2);
  62286. lo = (lo + Math.imul(al8, bl3)) | 0;
  62287. mid = (mid + Math.imul(al8, bh3)) | 0;
  62288. mid = (mid + Math.imul(ah8, bl3)) | 0;
  62289. hi = (hi + Math.imul(ah8, bh3)) | 0;
  62290. lo = (lo + Math.imul(al7, bl4)) | 0;
  62291. mid = (mid + Math.imul(al7, bh4)) | 0;
  62292. mid = (mid + Math.imul(ah7, bl4)) | 0;
  62293. hi = (hi + Math.imul(ah7, bh4)) | 0;
  62294. lo = (lo + Math.imul(al6, bl5)) | 0;
  62295. mid = (mid + Math.imul(al6, bh5)) | 0;
  62296. mid = (mid + Math.imul(ah6, bl5)) | 0;
  62297. hi = (hi + Math.imul(ah6, bh5)) | 0;
  62298. lo = (lo + Math.imul(al5, bl6)) | 0;
  62299. mid = (mid + Math.imul(al5, bh6)) | 0;
  62300. mid = (mid + Math.imul(ah5, bl6)) | 0;
  62301. hi = (hi + Math.imul(ah5, bh6)) | 0;
  62302. lo = (lo + Math.imul(al4, bl7)) | 0;
  62303. mid = (mid + Math.imul(al4, bh7)) | 0;
  62304. mid = (mid + Math.imul(ah4, bl7)) | 0;
  62305. hi = (hi + Math.imul(ah4, bh7)) | 0;
  62306. lo = (lo + Math.imul(al3, bl8)) | 0;
  62307. mid = (mid + Math.imul(al3, bh8)) | 0;
  62308. mid = (mid + Math.imul(ah3, bl8)) | 0;
  62309. hi = (hi + Math.imul(ah3, bh8)) | 0;
  62310. lo = (lo + Math.imul(al2, bl9)) | 0;
  62311. mid = (mid + Math.imul(al2, bh9)) | 0;
  62312. mid = (mid + Math.imul(ah2, bl9)) | 0;
  62313. hi = (hi + Math.imul(ah2, bh9)) | 0;
  62314. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62315. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  62316. w11 &= 0x3ffffff;
  62317. /* k = 12 */
  62318. lo = Math.imul(al9, bl3);
  62319. mid = Math.imul(al9, bh3);
  62320. mid = (mid + Math.imul(ah9, bl3)) | 0;
  62321. hi = Math.imul(ah9, bh3);
  62322. lo = (lo + Math.imul(al8, bl4)) | 0;
  62323. mid = (mid + Math.imul(al8, bh4)) | 0;
  62324. mid = (mid + Math.imul(ah8, bl4)) | 0;
  62325. hi = (hi + Math.imul(ah8, bh4)) | 0;
  62326. lo = (lo + Math.imul(al7, bl5)) | 0;
  62327. mid = (mid + Math.imul(al7, bh5)) | 0;
  62328. mid = (mid + Math.imul(ah7, bl5)) | 0;
  62329. hi = (hi + Math.imul(ah7, bh5)) | 0;
  62330. lo = (lo + Math.imul(al6, bl6)) | 0;
  62331. mid = (mid + Math.imul(al6, bh6)) | 0;
  62332. mid = (mid + Math.imul(ah6, bl6)) | 0;
  62333. hi = (hi + Math.imul(ah6, bh6)) | 0;
  62334. lo = (lo + Math.imul(al5, bl7)) | 0;
  62335. mid = (mid + Math.imul(al5, bh7)) | 0;
  62336. mid = (mid + Math.imul(ah5, bl7)) | 0;
  62337. hi = (hi + Math.imul(ah5, bh7)) | 0;
  62338. lo = (lo + Math.imul(al4, bl8)) | 0;
  62339. mid = (mid + Math.imul(al4, bh8)) | 0;
  62340. mid = (mid + Math.imul(ah4, bl8)) | 0;
  62341. hi = (hi + Math.imul(ah4, bh8)) | 0;
  62342. lo = (lo + Math.imul(al3, bl9)) | 0;
  62343. mid = (mid + Math.imul(al3, bh9)) | 0;
  62344. mid = (mid + Math.imul(ah3, bl9)) | 0;
  62345. hi = (hi + Math.imul(ah3, bh9)) | 0;
  62346. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62347. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  62348. w12 &= 0x3ffffff;
  62349. /* k = 13 */
  62350. lo = Math.imul(al9, bl4);
  62351. mid = Math.imul(al9, bh4);
  62352. mid = (mid + Math.imul(ah9, bl4)) | 0;
  62353. hi = Math.imul(ah9, bh4);
  62354. lo = (lo + Math.imul(al8, bl5)) | 0;
  62355. mid = (mid + Math.imul(al8, bh5)) | 0;
  62356. mid = (mid + Math.imul(ah8, bl5)) | 0;
  62357. hi = (hi + Math.imul(ah8, bh5)) | 0;
  62358. lo = (lo + Math.imul(al7, bl6)) | 0;
  62359. mid = (mid + Math.imul(al7, bh6)) | 0;
  62360. mid = (mid + Math.imul(ah7, bl6)) | 0;
  62361. hi = (hi + Math.imul(ah7, bh6)) | 0;
  62362. lo = (lo + Math.imul(al6, bl7)) | 0;
  62363. mid = (mid + Math.imul(al6, bh7)) | 0;
  62364. mid = (mid + Math.imul(ah6, bl7)) | 0;
  62365. hi = (hi + Math.imul(ah6, bh7)) | 0;
  62366. lo = (lo + Math.imul(al5, bl8)) | 0;
  62367. mid = (mid + Math.imul(al5, bh8)) | 0;
  62368. mid = (mid + Math.imul(ah5, bl8)) | 0;
  62369. hi = (hi + Math.imul(ah5, bh8)) | 0;
  62370. lo = (lo + Math.imul(al4, bl9)) | 0;
  62371. mid = (mid + Math.imul(al4, bh9)) | 0;
  62372. mid = (mid + Math.imul(ah4, bl9)) | 0;
  62373. hi = (hi + Math.imul(ah4, bh9)) | 0;
  62374. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62375. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  62376. w13 &= 0x3ffffff;
  62377. /* k = 14 */
  62378. lo = Math.imul(al9, bl5);
  62379. mid = Math.imul(al9, bh5);
  62380. mid = (mid + Math.imul(ah9, bl5)) | 0;
  62381. hi = Math.imul(ah9, bh5);
  62382. lo = (lo + Math.imul(al8, bl6)) | 0;
  62383. mid = (mid + Math.imul(al8, bh6)) | 0;
  62384. mid = (mid + Math.imul(ah8, bl6)) | 0;
  62385. hi = (hi + Math.imul(ah8, bh6)) | 0;
  62386. lo = (lo + Math.imul(al7, bl7)) | 0;
  62387. mid = (mid + Math.imul(al7, bh7)) | 0;
  62388. mid = (mid + Math.imul(ah7, bl7)) | 0;
  62389. hi = (hi + Math.imul(ah7, bh7)) | 0;
  62390. lo = (lo + Math.imul(al6, bl8)) | 0;
  62391. mid = (mid + Math.imul(al6, bh8)) | 0;
  62392. mid = (mid + Math.imul(ah6, bl8)) | 0;
  62393. hi = (hi + Math.imul(ah6, bh8)) | 0;
  62394. lo = (lo + Math.imul(al5, bl9)) | 0;
  62395. mid = (mid + Math.imul(al5, bh9)) | 0;
  62396. mid = (mid + Math.imul(ah5, bl9)) | 0;
  62397. hi = (hi + Math.imul(ah5, bh9)) | 0;
  62398. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62399. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  62400. w14 &= 0x3ffffff;
  62401. /* k = 15 */
  62402. lo = Math.imul(al9, bl6);
  62403. mid = Math.imul(al9, bh6);
  62404. mid = (mid + Math.imul(ah9, bl6)) | 0;
  62405. hi = Math.imul(ah9, bh6);
  62406. lo = (lo + Math.imul(al8, bl7)) | 0;
  62407. mid = (mid + Math.imul(al8, bh7)) | 0;
  62408. mid = (mid + Math.imul(ah8, bl7)) | 0;
  62409. hi = (hi + Math.imul(ah8, bh7)) | 0;
  62410. lo = (lo + Math.imul(al7, bl8)) | 0;
  62411. mid = (mid + Math.imul(al7, bh8)) | 0;
  62412. mid = (mid + Math.imul(ah7, bl8)) | 0;
  62413. hi = (hi + Math.imul(ah7, bh8)) | 0;
  62414. lo = (lo + Math.imul(al6, bl9)) | 0;
  62415. mid = (mid + Math.imul(al6, bh9)) | 0;
  62416. mid = (mid + Math.imul(ah6, bl9)) | 0;
  62417. hi = (hi + Math.imul(ah6, bh9)) | 0;
  62418. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62419. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  62420. w15 &= 0x3ffffff;
  62421. /* k = 16 */
  62422. lo = Math.imul(al9, bl7);
  62423. mid = Math.imul(al9, bh7);
  62424. mid = (mid + Math.imul(ah9, bl7)) | 0;
  62425. hi = Math.imul(ah9, bh7);
  62426. lo = (lo + Math.imul(al8, bl8)) | 0;
  62427. mid = (mid + Math.imul(al8, bh8)) | 0;
  62428. mid = (mid + Math.imul(ah8, bl8)) | 0;
  62429. hi = (hi + Math.imul(ah8, bh8)) | 0;
  62430. lo = (lo + Math.imul(al7, bl9)) | 0;
  62431. mid = (mid + Math.imul(al7, bh9)) | 0;
  62432. mid = (mid + Math.imul(ah7, bl9)) | 0;
  62433. hi = (hi + Math.imul(ah7, bh9)) | 0;
  62434. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62435. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  62436. w16 &= 0x3ffffff;
  62437. /* k = 17 */
  62438. lo = Math.imul(al9, bl8);
  62439. mid = Math.imul(al9, bh8);
  62440. mid = (mid + Math.imul(ah9, bl8)) | 0;
  62441. hi = Math.imul(ah9, bh8);
  62442. lo = (lo + Math.imul(al8, bl9)) | 0;
  62443. mid = (mid + Math.imul(al8, bh9)) | 0;
  62444. mid = (mid + Math.imul(ah8, bl9)) | 0;
  62445. hi = (hi + Math.imul(ah8, bh9)) | 0;
  62446. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62447. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  62448. w17 &= 0x3ffffff;
  62449. /* k = 18 */
  62450. lo = Math.imul(al9, bl9);
  62451. mid = Math.imul(al9, bh9);
  62452. mid = (mid + Math.imul(ah9, bl9)) | 0;
  62453. hi = Math.imul(ah9, bh9);
  62454. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  62455. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  62456. w18 &= 0x3ffffff;
  62457. o[0] = w0;
  62458. o[1] = w1;
  62459. o[2] = w2;
  62460. o[3] = w3;
  62461. o[4] = w4;
  62462. o[5] = w5;
  62463. o[6] = w6;
  62464. o[7] = w7;
  62465. o[8] = w8;
  62466. o[9] = w9;
  62467. o[10] = w10;
  62468. o[11] = w11;
  62469. o[12] = w12;
  62470. o[13] = w13;
  62471. o[14] = w14;
  62472. o[15] = w15;
  62473. o[16] = w16;
  62474. o[17] = w17;
  62475. o[18] = w18;
  62476. if (c !== 0) {
  62477. o[19] = c;
  62478. out.length++;
  62479. }
  62480. return out;
  62481. };
  62482. // Polyfill comb
  62483. if (!Math.imul) {
  62484. comb10MulTo = smallMulTo;
  62485. }
  62486. function bigMulTo (self, num, out) {
  62487. out.negative = num.negative ^ self.negative;
  62488. out.length = self.length + num.length;
  62489. var carry = 0;
  62490. var hncarry = 0;
  62491. for (var k = 0; k < out.length - 1; k++) {
  62492. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  62493. // note that ncarry could be >= 0x3ffffff
  62494. var ncarry = hncarry;
  62495. hncarry = 0;
  62496. var rword = carry & 0x3ffffff;
  62497. var maxJ = Math.min(k, num.length - 1);
  62498. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  62499. var i = k - j;
  62500. var a = self.words[i] | 0;
  62501. var b = num.words[j] | 0;
  62502. var r = a * b;
  62503. var lo = r & 0x3ffffff;
  62504. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  62505. lo = (lo + rword) | 0;
  62506. rword = lo & 0x3ffffff;
  62507. ncarry = (ncarry + (lo >>> 26)) | 0;
  62508. hncarry += ncarry >>> 26;
  62509. ncarry &= 0x3ffffff;
  62510. }
  62511. out.words[k] = rword;
  62512. carry = ncarry;
  62513. ncarry = hncarry;
  62514. }
  62515. if (carry !== 0) {
  62516. out.words[k] = carry;
  62517. } else {
  62518. out.length--;
  62519. }
  62520. return out.strip();
  62521. }
  62522. function jumboMulTo (self, num, out) {
  62523. var fftm = new FFTM();
  62524. return fftm.mulp(self, num, out);
  62525. }
  62526. BN.prototype.mulTo = function mulTo (num, out) {
  62527. var res;
  62528. var len = this.length + num.length;
  62529. if (this.length === 10 && num.length === 10) {
  62530. res = comb10MulTo(this, num, out);
  62531. } else if (len < 63) {
  62532. res = smallMulTo(this, num, out);
  62533. } else if (len < 1024) {
  62534. res = bigMulTo(this, num, out);
  62535. } else {
  62536. res = jumboMulTo(this, num, out);
  62537. }
  62538. return res;
  62539. };
  62540. // Cooley-Tukey algorithm for FFT
  62541. // slightly revisited to rely on looping instead of recursion
  62542. function FFTM (x, y) {
  62543. this.x = x;
  62544. this.y = y;
  62545. }
  62546. FFTM.prototype.makeRBT = function makeRBT (N) {
  62547. var t = new Array(N);
  62548. var l = BN.prototype._countBits(N) - 1;
  62549. for (var i = 0; i < N; i++) {
  62550. t[i] = this.revBin(i, l, N);
  62551. }
  62552. return t;
  62553. };
  62554. // Returns binary-reversed representation of `x`
  62555. FFTM.prototype.revBin = function revBin (x, l, N) {
  62556. if (x === 0 || x === N - 1) return x;
  62557. var rb = 0;
  62558. for (var i = 0; i < l; i++) {
  62559. rb |= (x & 1) << (l - i - 1);
  62560. x >>= 1;
  62561. }
  62562. return rb;
  62563. };
  62564. // Performs "tweedling" phase, therefore 'emulating'
  62565. // behaviour of the recursive algorithm
  62566. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  62567. for (var i = 0; i < N; i++) {
  62568. rtws[i] = rws[rbt[i]];
  62569. itws[i] = iws[rbt[i]];
  62570. }
  62571. };
  62572. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  62573. this.permute(rbt, rws, iws, rtws, itws, N);
  62574. for (var s = 1; s < N; s <<= 1) {
  62575. var l = s << 1;
  62576. var rtwdf = Math.cos(2 * Math.PI / l);
  62577. var itwdf = Math.sin(2 * Math.PI / l);
  62578. for (var p = 0; p < N; p += l) {
  62579. var rtwdf_ = rtwdf;
  62580. var itwdf_ = itwdf;
  62581. for (var j = 0; j < s; j++) {
  62582. var re = rtws[p + j];
  62583. var ie = itws[p + j];
  62584. var ro = rtws[p + j + s];
  62585. var io = itws[p + j + s];
  62586. var rx = rtwdf_ * ro - itwdf_ * io;
  62587. io = rtwdf_ * io + itwdf_ * ro;
  62588. ro = rx;
  62589. rtws[p + j] = re + ro;
  62590. itws[p + j] = ie + io;
  62591. rtws[p + j + s] = re - ro;
  62592. itws[p + j + s] = ie - io;
  62593. /* jshint maxdepth : false */
  62594. if (j !== l) {
  62595. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  62596. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  62597. rtwdf_ = rx;
  62598. }
  62599. }
  62600. }
  62601. }
  62602. };
  62603. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  62604. var N = Math.max(m, n) | 1;
  62605. var odd = N & 1;
  62606. var i = 0;
  62607. for (N = N / 2 | 0; N; N = N >>> 1) {
  62608. i++;
  62609. }
  62610. return 1 << i + 1 + odd;
  62611. };
  62612. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  62613. if (N <= 1) return;
  62614. for (var i = 0; i < N / 2; i++) {
  62615. var t = rws[i];
  62616. rws[i] = rws[N - i - 1];
  62617. rws[N - i - 1] = t;
  62618. t = iws[i];
  62619. iws[i] = -iws[N - i - 1];
  62620. iws[N - i - 1] = -t;
  62621. }
  62622. };
  62623. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  62624. var carry = 0;
  62625. for (var i = 0; i < N / 2; i++) {
  62626. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  62627. Math.round(ws[2 * i] / N) +
  62628. carry;
  62629. ws[i] = w & 0x3ffffff;
  62630. if (w < 0x4000000) {
  62631. carry = 0;
  62632. } else {
  62633. carry = w / 0x4000000 | 0;
  62634. }
  62635. }
  62636. return ws;
  62637. };
  62638. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  62639. var carry = 0;
  62640. for (var i = 0; i < len; i++) {
  62641. carry = carry + (ws[i] | 0);
  62642. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  62643. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  62644. }
  62645. // Pad with zeroes
  62646. for (i = 2 * len; i < N; ++i) {
  62647. rws[i] = 0;
  62648. }
  62649. assert(carry === 0);
  62650. assert((carry & ~0x1fff) === 0);
  62651. };
  62652. FFTM.prototype.stub = function stub (N) {
  62653. var ph = new Array(N);
  62654. for (var i = 0; i < N; i++) {
  62655. ph[i] = 0;
  62656. }
  62657. return ph;
  62658. };
  62659. FFTM.prototype.mulp = function mulp (x, y, out) {
  62660. var N = 2 * this.guessLen13b(x.length, y.length);
  62661. var rbt = this.makeRBT(N);
  62662. var _ = this.stub(N);
  62663. var rws = new Array(N);
  62664. var rwst = new Array(N);
  62665. var iwst = new Array(N);
  62666. var nrws = new Array(N);
  62667. var nrwst = new Array(N);
  62668. var niwst = new Array(N);
  62669. var rmws = out.words;
  62670. rmws.length = N;
  62671. this.convert13b(x.words, x.length, rws, N);
  62672. this.convert13b(y.words, y.length, nrws, N);
  62673. this.transform(rws, _, rwst, iwst, N, rbt);
  62674. this.transform(nrws, _, nrwst, niwst, N, rbt);
  62675. for (var i = 0; i < N; i++) {
  62676. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  62677. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  62678. rwst[i] = rx;
  62679. }
  62680. this.conjugate(rwst, iwst, N);
  62681. this.transform(rwst, iwst, rmws, _, N, rbt);
  62682. this.conjugate(rmws, _, N);
  62683. this.normalize13b(rmws, N);
  62684. out.negative = x.negative ^ y.negative;
  62685. out.length = x.length + y.length;
  62686. return out.strip();
  62687. };
  62688. // Multiply `this` by `num`
  62689. BN.prototype.mul = function mul (num) {
  62690. var out = new BN(null);
  62691. out.words = new Array(this.length + num.length);
  62692. return this.mulTo(num, out);
  62693. };
  62694. // Multiply employing FFT
  62695. BN.prototype.mulf = function mulf (num) {
  62696. var out = new BN(null);
  62697. out.words = new Array(this.length + num.length);
  62698. return jumboMulTo(this, num, out);
  62699. };
  62700. // In-place Multiplication
  62701. BN.prototype.imul = function imul (num) {
  62702. return this.clone().mulTo(num, this);
  62703. };
  62704. BN.prototype.imuln = function imuln (num) {
  62705. assert(typeof num === 'number');
  62706. assert(num < 0x4000000);
  62707. // Carry
  62708. var carry = 0;
  62709. for (var i = 0; i < this.length; i++) {
  62710. var w = (this.words[i] | 0) * num;
  62711. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  62712. carry >>= 26;
  62713. carry += (w / 0x4000000) | 0;
  62714. // NOTE: lo is 27bit maximum
  62715. carry += lo >>> 26;
  62716. this.words[i] = lo & 0x3ffffff;
  62717. }
  62718. if (carry !== 0) {
  62719. this.words[i] = carry;
  62720. this.length++;
  62721. }
  62722. return this;
  62723. };
  62724. BN.prototype.muln = function muln (num) {
  62725. return this.clone().imuln(num);
  62726. };
  62727. // `this` * `this`
  62728. BN.prototype.sqr = function sqr () {
  62729. return this.mul(this);
  62730. };
  62731. // `this` * `this` in-place
  62732. BN.prototype.isqr = function isqr () {
  62733. return this.imul(this.clone());
  62734. };
  62735. // Math.pow(`this`, `num`)
  62736. BN.prototype.pow = function pow (num) {
  62737. var w = toBitArray(num);
  62738. if (w.length === 0) return new BN(1);
  62739. // Skip leading zeroes
  62740. var res = this;
  62741. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  62742. if (w[i] !== 0) break;
  62743. }
  62744. if (++i < w.length) {
  62745. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  62746. if (w[i] === 0) continue;
  62747. res = res.mul(q);
  62748. }
  62749. }
  62750. return res;
  62751. };
  62752. // Shift-left in-place
  62753. BN.prototype.iushln = function iushln (bits) {
  62754. assert(typeof bits === 'number' && bits >= 0);
  62755. var r = bits % 26;
  62756. var s = (bits - r) / 26;
  62757. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  62758. var i;
  62759. if (r !== 0) {
  62760. var carry = 0;
  62761. for (i = 0; i < this.length; i++) {
  62762. var newCarry = this.words[i] & carryMask;
  62763. var c = ((this.words[i] | 0) - newCarry) << r;
  62764. this.words[i] = c | carry;
  62765. carry = newCarry >>> (26 - r);
  62766. }
  62767. if (carry) {
  62768. this.words[i] = carry;
  62769. this.length++;
  62770. }
  62771. }
  62772. if (s !== 0) {
  62773. for (i = this.length - 1; i >= 0; i--) {
  62774. this.words[i + s] = this.words[i];
  62775. }
  62776. for (i = 0; i < s; i++) {
  62777. this.words[i] = 0;
  62778. }
  62779. this.length += s;
  62780. }
  62781. return this.strip();
  62782. };
  62783. BN.prototype.ishln = function ishln (bits) {
  62784. // TODO(indutny): implement me
  62785. assert(this.negative === 0);
  62786. return this.iushln(bits);
  62787. };
  62788. // Shift-right in-place
  62789. // NOTE: `hint` is a lowest bit before trailing zeroes
  62790. // NOTE: if `extended` is present - it will be filled with destroyed bits
  62791. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  62792. assert(typeof bits === 'number' && bits >= 0);
  62793. var h;
  62794. if (hint) {
  62795. h = (hint - (hint % 26)) / 26;
  62796. } else {
  62797. h = 0;
  62798. }
  62799. var r = bits % 26;
  62800. var s = Math.min((bits - r) / 26, this.length);
  62801. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  62802. var maskedWords = extended;
  62803. h -= s;
  62804. h = Math.max(0, h);
  62805. // Extended mode, copy masked part
  62806. if (maskedWords) {
  62807. for (var i = 0; i < s; i++) {
  62808. maskedWords.words[i] = this.words[i];
  62809. }
  62810. maskedWords.length = s;
  62811. }
  62812. if (s === 0) {
  62813. // No-op, we should not move anything at all
  62814. } else if (this.length > s) {
  62815. this.length -= s;
  62816. for (i = 0; i < this.length; i++) {
  62817. this.words[i] = this.words[i + s];
  62818. }
  62819. } else {
  62820. this.words[0] = 0;
  62821. this.length = 1;
  62822. }
  62823. var carry = 0;
  62824. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  62825. var word = this.words[i] | 0;
  62826. this.words[i] = (carry << (26 - r)) | (word >>> r);
  62827. carry = word & mask;
  62828. }
  62829. // Push carried bits as a mask
  62830. if (maskedWords && carry !== 0) {
  62831. maskedWords.words[maskedWords.length++] = carry;
  62832. }
  62833. if (this.length === 0) {
  62834. this.words[0] = 0;
  62835. this.length = 1;
  62836. }
  62837. return this.strip();
  62838. };
  62839. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  62840. // TODO(indutny): implement me
  62841. assert(this.negative === 0);
  62842. return this.iushrn(bits, hint, extended);
  62843. };
  62844. // Shift-left
  62845. BN.prototype.shln = function shln (bits) {
  62846. return this.clone().ishln(bits);
  62847. };
  62848. BN.prototype.ushln = function ushln (bits) {
  62849. return this.clone().iushln(bits);
  62850. };
  62851. // Shift-right
  62852. BN.prototype.shrn = function shrn (bits) {
  62853. return this.clone().ishrn(bits);
  62854. };
  62855. BN.prototype.ushrn = function ushrn (bits) {
  62856. return this.clone().iushrn(bits);
  62857. };
  62858. // Test if n bit is set
  62859. BN.prototype.testn = function testn (bit) {
  62860. assert(typeof bit === 'number' && bit >= 0);
  62861. var r = bit % 26;
  62862. var s = (bit - r) / 26;
  62863. var q = 1 << r;
  62864. // Fast case: bit is much higher than all existing words
  62865. if (this.length <= s) return false;
  62866. // Check bit and return
  62867. var w = this.words[s];
  62868. return !!(w & q);
  62869. };
  62870. // Return only lowers bits of number (in-place)
  62871. BN.prototype.imaskn = function imaskn (bits) {
  62872. assert(typeof bits === 'number' && bits >= 0);
  62873. var r = bits % 26;
  62874. var s = (bits - r) / 26;
  62875. assert(this.negative === 0, 'imaskn works only with positive numbers');
  62876. if (this.length <= s) {
  62877. return this;
  62878. }
  62879. if (r !== 0) {
  62880. s++;
  62881. }
  62882. this.length = Math.min(s, this.length);
  62883. if (r !== 0) {
  62884. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  62885. this.words[this.length - 1] &= mask;
  62886. }
  62887. return this.strip();
  62888. };
  62889. // Return only lowers bits of number
  62890. BN.prototype.maskn = function maskn (bits) {
  62891. return this.clone().imaskn(bits);
  62892. };
  62893. // Add plain number `num` to `this`
  62894. BN.prototype.iaddn = function iaddn (num) {
  62895. assert(typeof num === 'number');
  62896. assert(num < 0x4000000);
  62897. if (num < 0) return this.isubn(-num);
  62898. // Possible sign change
  62899. if (this.negative !== 0) {
  62900. if (this.length === 1 && (this.words[0] | 0) < num) {
  62901. this.words[0] = num - (this.words[0] | 0);
  62902. this.negative = 0;
  62903. return this;
  62904. }
  62905. this.negative = 0;
  62906. this.isubn(num);
  62907. this.negative = 1;
  62908. return this;
  62909. }
  62910. // Add without checks
  62911. return this._iaddn(num);
  62912. };
  62913. BN.prototype._iaddn = function _iaddn (num) {
  62914. this.words[0] += num;
  62915. // Carry
  62916. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  62917. this.words[i] -= 0x4000000;
  62918. if (i === this.length - 1) {
  62919. this.words[i + 1] = 1;
  62920. } else {
  62921. this.words[i + 1]++;
  62922. }
  62923. }
  62924. this.length = Math.max(this.length, i + 1);
  62925. return this;
  62926. };
  62927. // Subtract plain number `num` from `this`
  62928. BN.prototype.isubn = function isubn (num) {
  62929. assert(typeof num === 'number');
  62930. assert(num < 0x4000000);
  62931. if (num < 0) return this.iaddn(-num);
  62932. if (this.negative !== 0) {
  62933. this.negative = 0;
  62934. this.iaddn(num);
  62935. this.negative = 1;
  62936. return this;
  62937. }
  62938. this.words[0] -= num;
  62939. if (this.length === 1 && this.words[0] < 0) {
  62940. this.words[0] = -this.words[0];
  62941. this.negative = 1;
  62942. } else {
  62943. // Carry
  62944. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  62945. this.words[i] += 0x4000000;
  62946. this.words[i + 1] -= 1;
  62947. }
  62948. }
  62949. return this.strip();
  62950. };
  62951. BN.prototype.addn = function addn (num) {
  62952. return this.clone().iaddn(num);
  62953. };
  62954. BN.prototype.subn = function subn (num) {
  62955. return this.clone().isubn(num);
  62956. };
  62957. BN.prototype.iabs = function iabs () {
  62958. this.negative = 0;
  62959. return this;
  62960. };
  62961. BN.prototype.abs = function abs () {
  62962. return this.clone().iabs();
  62963. };
  62964. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  62965. var len = num.length + shift;
  62966. var i;
  62967. this._expand(len);
  62968. var w;
  62969. var carry = 0;
  62970. for (i = 0; i < num.length; i++) {
  62971. w = (this.words[i + shift] | 0) + carry;
  62972. var right = (num.words[i] | 0) * mul;
  62973. w -= right & 0x3ffffff;
  62974. carry = (w >> 26) - ((right / 0x4000000) | 0);
  62975. this.words[i + shift] = w & 0x3ffffff;
  62976. }
  62977. for (; i < this.length - shift; i++) {
  62978. w = (this.words[i + shift] | 0) + carry;
  62979. carry = w >> 26;
  62980. this.words[i + shift] = w & 0x3ffffff;
  62981. }
  62982. if (carry === 0) return this.strip();
  62983. // Subtraction overflow
  62984. assert(carry === -1);
  62985. carry = 0;
  62986. for (i = 0; i < this.length; i++) {
  62987. w = -(this.words[i] | 0) + carry;
  62988. carry = w >> 26;
  62989. this.words[i] = w & 0x3ffffff;
  62990. }
  62991. this.negative = 1;
  62992. return this.strip();
  62993. };
  62994. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  62995. var shift = this.length - num.length;
  62996. var a = this.clone();
  62997. var b = num;
  62998. // Normalize
  62999. var bhi = b.words[b.length - 1] | 0;
  63000. var bhiBits = this._countBits(bhi);
  63001. shift = 26 - bhiBits;
  63002. if (shift !== 0) {
  63003. b = b.ushln(shift);
  63004. a.iushln(shift);
  63005. bhi = b.words[b.length - 1] | 0;
  63006. }
  63007. // Initialize quotient
  63008. var m = a.length - b.length;
  63009. var q;
  63010. if (mode !== 'mod') {
  63011. q = new BN(null);
  63012. q.length = m + 1;
  63013. q.words = new Array(q.length);
  63014. for (var i = 0; i < q.length; i++) {
  63015. q.words[i] = 0;
  63016. }
  63017. }
  63018. var diff = a.clone()._ishlnsubmul(b, 1, m);
  63019. if (diff.negative === 0) {
  63020. a = diff;
  63021. if (q) {
  63022. q.words[m] = 1;
  63023. }
  63024. }
  63025. for (var j = m - 1; j >= 0; j--) {
  63026. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  63027. (a.words[b.length + j - 1] | 0);
  63028. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  63029. // (0x7ffffff)
  63030. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  63031. a._ishlnsubmul(b, qj, j);
  63032. while (a.negative !== 0) {
  63033. qj--;
  63034. a.negative = 0;
  63035. a._ishlnsubmul(b, 1, j);
  63036. if (!a.isZero()) {
  63037. a.negative ^= 1;
  63038. }
  63039. }
  63040. if (q) {
  63041. q.words[j] = qj;
  63042. }
  63043. }
  63044. if (q) {
  63045. q.strip();
  63046. }
  63047. a.strip();
  63048. // Denormalize
  63049. if (mode !== 'div' && shift !== 0) {
  63050. a.iushrn(shift);
  63051. }
  63052. return {
  63053. div: q || null,
  63054. mod: a
  63055. };
  63056. };
  63057. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  63058. // to `div` to request div only, or be absent to
  63059. // request both div & mod
  63060. // 2) `positive` is true if unsigned mod is requested
  63061. BN.prototype.divmod = function divmod (num, mode, positive) {
  63062. assert(!num.isZero());
  63063. if (this.isZero()) {
  63064. return {
  63065. div: new BN(0),
  63066. mod: new BN(0)
  63067. };
  63068. }
  63069. var div, mod, res;
  63070. if (this.negative !== 0 && num.negative === 0) {
  63071. res = this.neg().divmod(num, mode);
  63072. if (mode !== 'mod') {
  63073. div = res.div.neg();
  63074. }
  63075. if (mode !== 'div') {
  63076. mod = res.mod.neg();
  63077. if (positive && mod.negative !== 0) {
  63078. mod.iadd(num);
  63079. }
  63080. }
  63081. return {
  63082. div: div,
  63083. mod: mod
  63084. };
  63085. }
  63086. if (this.negative === 0 && num.negative !== 0) {
  63087. res = this.divmod(num.neg(), mode);
  63088. if (mode !== 'mod') {
  63089. div = res.div.neg();
  63090. }
  63091. return {
  63092. div: div,
  63093. mod: res.mod
  63094. };
  63095. }
  63096. if ((this.negative & num.negative) !== 0) {
  63097. res = this.neg().divmod(num.neg(), mode);
  63098. if (mode !== 'div') {
  63099. mod = res.mod.neg();
  63100. if (positive && mod.negative !== 0) {
  63101. mod.isub(num);
  63102. }
  63103. }
  63104. return {
  63105. div: res.div,
  63106. mod: mod
  63107. };
  63108. }
  63109. // Both numbers are positive at this point
  63110. // Strip both numbers to approximate shift value
  63111. if (num.length > this.length || this.cmp(num) < 0) {
  63112. return {
  63113. div: new BN(0),
  63114. mod: this
  63115. };
  63116. }
  63117. // Very short reduction
  63118. if (num.length === 1) {
  63119. if (mode === 'div') {
  63120. return {
  63121. div: this.divn(num.words[0]),
  63122. mod: null
  63123. };
  63124. }
  63125. if (mode === 'mod') {
  63126. return {
  63127. div: null,
  63128. mod: new BN(this.modn(num.words[0]))
  63129. };
  63130. }
  63131. return {
  63132. div: this.divn(num.words[0]),
  63133. mod: new BN(this.modn(num.words[0]))
  63134. };
  63135. }
  63136. return this._wordDiv(num, mode);
  63137. };
  63138. // Find `this` / `num`
  63139. BN.prototype.div = function div (num) {
  63140. return this.divmod(num, 'div', false).div;
  63141. };
  63142. // Find `this` % `num`
  63143. BN.prototype.mod = function mod (num) {
  63144. return this.divmod(num, 'mod', false).mod;
  63145. };
  63146. BN.prototype.umod = function umod (num) {
  63147. return this.divmod(num, 'mod', true).mod;
  63148. };
  63149. // Find Round(`this` / `num`)
  63150. BN.prototype.divRound = function divRound (num) {
  63151. var dm = this.divmod(num);
  63152. // Fast case - exact division
  63153. if (dm.mod.isZero()) return dm.div;
  63154. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  63155. var half = num.ushrn(1);
  63156. var r2 = num.andln(1);
  63157. var cmp = mod.cmp(half);
  63158. // Round down
  63159. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  63160. // Round up
  63161. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  63162. };
  63163. BN.prototype.modn = function modn (num) {
  63164. assert(num <= 0x3ffffff);
  63165. var p = (1 << 26) % num;
  63166. var acc = 0;
  63167. for (var i = this.length - 1; i >= 0; i--) {
  63168. acc = (p * acc + (this.words[i] | 0)) % num;
  63169. }
  63170. return acc;
  63171. };
  63172. // In-place division by number
  63173. BN.prototype.idivn = function idivn (num) {
  63174. assert(num <= 0x3ffffff);
  63175. var carry = 0;
  63176. for (var i = this.length - 1; i >= 0; i--) {
  63177. var w = (this.words[i] | 0) + carry * 0x4000000;
  63178. this.words[i] = (w / num) | 0;
  63179. carry = w % num;
  63180. }
  63181. return this.strip();
  63182. };
  63183. BN.prototype.divn = function divn (num) {
  63184. return this.clone().idivn(num);
  63185. };
  63186. BN.prototype.egcd = function egcd (p) {
  63187. assert(p.negative === 0);
  63188. assert(!p.isZero());
  63189. var x = this;
  63190. var y = p.clone();
  63191. if (x.negative !== 0) {
  63192. x = x.umod(p);
  63193. } else {
  63194. x = x.clone();
  63195. }
  63196. // A * x + B * y = x
  63197. var A = new BN(1);
  63198. var B = new BN(0);
  63199. // C * x + D * y = y
  63200. var C = new BN(0);
  63201. var D = new BN(1);
  63202. var g = 0;
  63203. while (x.isEven() && y.isEven()) {
  63204. x.iushrn(1);
  63205. y.iushrn(1);
  63206. ++g;
  63207. }
  63208. var yp = y.clone();
  63209. var xp = x.clone();
  63210. while (!x.isZero()) {
  63211. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  63212. if (i > 0) {
  63213. x.iushrn(i);
  63214. while (i-- > 0) {
  63215. if (A.isOdd() || B.isOdd()) {
  63216. A.iadd(yp);
  63217. B.isub(xp);
  63218. }
  63219. A.iushrn(1);
  63220. B.iushrn(1);
  63221. }
  63222. }
  63223. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  63224. if (j > 0) {
  63225. y.iushrn(j);
  63226. while (j-- > 0) {
  63227. if (C.isOdd() || D.isOdd()) {
  63228. C.iadd(yp);
  63229. D.isub(xp);
  63230. }
  63231. C.iushrn(1);
  63232. D.iushrn(1);
  63233. }
  63234. }
  63235. if (x.cmp(y) >= 0) {
  63236. x.isub(y);
  63237. A.isub(C);
  63238. B.isub(D);
  63239. } else {
  63240. y.isub(x);
  63241. C.isub(A);
  63242. D.isub(B);
  63243. }
  63244. }
  63245. return {
  63246. a: C,
  63247. b: D,
  63248. gcd: y.iushln(g)
  63249. };
  63250. };
  63251. // This is reduced incarnation of the binary EEA
  63252. // above, designated to invert members of the
  63253. // _prime_ fields F(p) at a maximal speed
  63254. BN.prototype._invmp = function _invmp (p) {
  63255. assert(p.negative === 0);
  63256. assert(!p.isZero());
  63257. var a = this;
  63258. var b = p.clone();
  63259. if (a.negative !== 0) {
  63260. a = a.umod(p);
  63261. } else {
  63262. a = a.clone();
  63263. }
  63264. var x1 = new BN(1);
  63265. var x2 = new BN(0);
  63266. var delta = b.clone();
  63267. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  63268. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  63269. if (i > 0) {
  63270. a.iushrn(i);
  63271. while (i-- > 0) {
  63272. if (x1.isOdd()) {
  63273. x1.iadd(delta);
  63274. }
  63275. x1.iushrn(1);
  63276. }
  63277. }
  63278. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  63279. if (j > 0) {
  63280. b.iushrn(j);
  63281. while (j-- > 0) {
  63282. if (x2.isOdd()) {
  63283. x2.iadd(delta);
  63284. }
  63285. x2.iushrn(1);
  63286. }
  63287. }
  63288. if (a.cmp(b) >= 0) {
  63289. a.isub(b);
  63290. x1.isub(x2);
  63291. } else {
  63292. b.isub(a);
  63293. x2.isub(x1);
  63294. }
  63295. }
  63296. var res;
  63297. if (a.cmpn(1) === 0) {
  63298. res = x1;
  63299. } else {
  63300. res = x2;
  63301. }
  63302. if (res.cmpn(0) < 0) {
  63303. res.iadd(p);
  63304. }
  63305. return res;
  63306. };
  63307. BN.prototype.gcd = function gcd (num) {
  63308. if (this.isZero()) return num.abs();
  63309. if (num.isZero()) return this.abs();
  63310. var a = this.clone();
  63311. var b = num.clone();
  63312. a.negative = 0;
  63313. b.negative = 0;
  63314. // Remove common factor of two
  63315. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  63316. a.iushrn(1);
  63317. b.iushrn(1);
  63318. }
  63319. do {
  63320. while (a.isEven()) {
  63321. a.iushrn(1);
  63322. }
  63323. while (b.isEven()) {
  63324. b.iushrn(1);
  63325. }
  63326. var r = a.cmp(b);
  63327. if (r < 0) {
  63328. // Swap `a` and `b` to make `a` always bigger than `b`
  63329. var t = a;
  63330. a = b;
  63331. b = t;
  63332. } else if (r === 0 || b.cmpn(1) === 0) {
  63333. break;
  63334. }
  63335. a.isub(b);
  63336. } while (true);
  63337. return b.iushln(shift);
  63338. };
  63339. // Invert number in the field F(num)
  63340. BN.prototype.invm = function invm (num) {
  63341. return this.egcd(num).a.umod(num);
  63342. };
  63343. BN.prototype.isEven = function isEven () {
  63344. return (this.words[0] & 1) === 0;
  63345. };
  63346. BN.prototype.isOdd = function isOdd () {
  63347. return (this.words[0] & 1) === 1;
  63348. };
  63349. // And first word and num
  63350. BN.prototype.andln = function andln (num) {
  63351. return this.words[0] & num;
  63352. };
  63353. // Increment at the bit position in-line
  63354. BN.prototype.bincn = function bincn (bit) {
  63355. assert(typeof bit === 'number');
  63356. var r = bit % 26;
  63357. var s = (bit - r) / 26;
  63358. var q = 1 << r;
  63359. // Fast case: bit is much higher than all existing words
  63360. if (this.length <= s) {
  63361. this._expand(s + 1);
  63362. this.words[s] |= q;
  63363. return this;
  63364. }
  63365. // Add bit and propagate, if needed
  63366. var carry = q;
  63367. for (var i = s; carry !== 0 && i < this.length; i++) {
  63368. var w = this.words[i] | 0;
  63369. w += carry;
  63370. carry = w >>> 26;
  63371. w &= 0x3ffffff;
  63372. this.words[i] = w;
  63373. }
  63374. if (carry !== 0) {
  63375. this.words[i] = carry;
  63376. this.length++;
  63377. }
  63378. return this;
  63379. };
  63380. BN.prototype.isZero = function isZero () {
  63381. return this.length === 1 && this.words[0] === 0;
  63382. };
  63383. BN.prototype.cmpn = function cmpn (num) {
  63384. var negative = num < 0;
  63385. if (this.negative !== 0 && !negative) return -1;
  63386. if (this.negative === 0 && negative) return 1;
  63387. this.strip();
  63388. var res;
  63389. if (this.length > 1) {
  63390. res = 1;
  63391. } else {
  63392. if (negative) {
  63393. num = -num;
  63394. }
  63395. assert(num <= 0x3ffffff, 'Number is too big');
  63396. var w = this.words[0] | 0;
  63397. res = w === num ? 0 : w < num ? -1 : 1;
  63398. }
  63399. if (this.negative !== 0) return -res | 0;
  63400. return res;
  63401. };
  63402. // Compare two numbers and return:
  63403. // 1 - if `this` > `num`
  63404. // 0 - if `this` == `num`
  63405. // -1 - if `this` < `num`
  63406. BN.prototype.cmp = function cmp (num) {
  63407. if (this.negative !== 0 && num.negative === 0) return -1;
  63408. if (this.negative === 0 && num.negative !== 0) return 1;
  63409. var res = this.ucmp(num);
  63410. if (this.negative !== 0) return -res | 0;
  63411. return res;
  63412. };
  63413. // Unsigned comparison
  63414. BN.prototype.ucmp = function ucmp (num) {
  63415. // At this point both numbers have the same sign
  63416. if (this.length > num.length) return 1;
  63417. if (this.length < num.length) return -1;
  63418. var res = 0;
  63419. for (var i = this.length - 1; i >= 0; i--) {
  63420. var a = this.words[i] | 0;
  63421. var b = num.words[i] | 0;
  63422. if (a === b) continue;
  63423. if (a < b) {
  63424. res = -1;
  63425. } else if (a > b) {
  63426. res = 1;
  63427. }
  63428. break;
  63429. }
  63430. return res;
  63431. };
  63432. BN.prototype.gtn = function gtn (num) {
  63433. return this.cmpn(num) === 1;
  63434. };
  63435. BN.prototype.gt = function gt (num) {
  63436. return this.cmp(num) === 1;
  63437. };
  63438. BN.prototype.gten = function gten (num) {
  63439. return this.cmpn(num) >= 0;
  63440. };
  63441. BN.prototype.gte = function gte (num) {
  63442. return this.cmp(num) >= 0;
  63443. };
  63444. BN.prototype.ltn = function ltn (num) {
  63445. return this.cmpn(num) === -1;
  63446. };
  63447. BN.prototype.lt = function lt (num) {
  63448. return this.cmp(num) === -1;
  63449. };
  63450. BN.prototype.lten = function lten (num) {
  63451. return this.cmpn(num) <= 0;
  63452. };
  63453. BN.prototype.lte = function lte (num) {
  63454. return this.cmp(num) <= 0;
  63455. };
  63456. BN.prototype.eqn = function eqn (num) {
  63457. return this.cmpn(num) === 0;
  63458. };
  63459. BN.prototype.eq = function eq (num) {
  63460. return this.cmp(num) === 0;
  63461. };
  63462. //
  63463. // A reduce context, could be using montgomery or something better, depending
  63464. // on the `m` itself.
  63465. //
  63466. BN.red = function red (num) {
  63467. return new Red(num);
  63468. };
  63469. BN.prototype.toRed = function toRed (ctx) {
  63470. assert(!this.red, 'Already a number in reduction context');
  63471. assert(this.negative === 0, 'red works only with positives');
  63472. return ctx.convertTo(this)._forceRed(ctx);
  63473. };
  63474. BN.prototype.fromRed = function fromRed () {
  63475. assert(this.red, 'fromRed works only with numbers in reduction context');
  63476. return this.red.convertFrom(this);
  63477. };
  63478. BN.prototype._forceRed = function _forceRed (ctx) {
  63479. this.red = ctx;
  63480. return this;
  63481. };
  63482. BN.prototype.forceRed = function forceRed (ctx) {
  63483. assert(!this.red, 'Already a number in reduction context');
  63484. return this._forceRed(ctx);
  63485. };
  63486. BN.prototype.redAdd = function redAdd (num) {
  63487. assert(this.red, 'redAdd works only with red numbers');
  63488. return this.red.add(this, num);
  63489. };
  63490. BN.prototype.redIAdd = function redIAdd (num) {
  63491. assert(this.red, 'redIAdd works only with red numbers');
  63492. return this.red.iadd(this, num);
  63493. };
  63494. BN.prototype.redSub = function redSub (num) {
  63495. assert(this.red, 'redSub works only with red numbers');
  63496. return this.red.sub(this, num);
  63497. };
  63498. BN.prototype.redISub = function redISub (num) {
  63499. assert(this.red, 'redISub works only with red numbers');
  63500. return this.red.isub(this, num);
  63501. };
  63502. BN.prototype.redShl = function redShl (num) {
  63503. assert(this.red, 'redShl works only with red numbers');
  63504. return this.red.shl(this, num);
  63505. };
  63506. BN.prototype.redMul = function redMul (num) {
  63507. assert(this.red, 'redMul works only with red numbers');
  63508. this.red._verify2(this, num);
  63509. return this.red.mul(this, num);
  63510. };
  63511. BN.prototype.redIMul = function redIMul (num) {
  63512. assert(this.red, 'redMul works only with red numbers');
  63513. this.red._verify2(this, num);
  63514. return this.red.imul(this, num);
  63515. };
  63516. BN.prototype.redSqr = function redSqr () {
  63517. assert(this.red, 'redSqr works only with red numbers');
  63518. this.red._verify1(this);
  63519. return this.red.sqr(this);
  63520. };
  63521. BN.prototype.redISqr = function redISqr () {
  63522. assert(this.red, 'redISqr works only with red numbers');
  63523. this.red._verify1(this);
  63524. return this.red.isqr(this);
  63525. };
  63526. // Square root over p
  63527. BN.prototype.redSqrt = function redSqrt () {
  63528. assert(this.red, 'redSqrt works only with red numbers');
  63529. this.red._verify1(this);
  63530. return this.red.sqrt(this);
  63531. };
  63532. BN.prototype.redInvm = function redInvm () {
  63533. assert(this.red, 'redInvm works only with red numbers');
  63534. this.red._verify1(this);
  63535. return this.red.invm(this);
  63536. };
  63537. // Return negative clone of `this` % `red modulo`
  63538. BN.prototype.redNeg = function redNeg () {
  63539. assert(this.red, 'redNeg works only with red numbers');
  63540. this.red._verify1(this);
  63541. return this.red.neg(this);
  63542. };
  63543. BN.prototype.redPow = function redPow (num) {
  63544. assert(this.red && !num.red, 'redPow(normalNum)');
  63545. this.red._verify1(this);
  63546. return this.red.pow(this, num);
  63547. };
  63548. // Prime numbers with efficient reduction
  63549. var primes = {
  63550. k256: null,
  63551. p224: null,
  63552. p192: null,
  63553. p25519: null
  63554. };
  63555. // Pseudo-Mersenne prime
  63556. function MPrime (name, p) {
  63557. // P = 2 ^ N - K
  63558. this.name = name;
  63559. this.p = new BN(p, 16);
  63560. this.n = this.p.bitLength();
  63561. this.k = new BN(1).iushln(this.n).isub(this.p);
  63562. this.tmp = this._tmp();
  63563. }
  63564. MPrime.prototype._tmp = function _tmp () {
  63565. var tmp = new BN(null);
  63566. tmp.words = new Array(Math.ceil(this.n / 13));
  63567. return tmp;
  63568. };
  63569. MPrime.prototype.ireduce = function ireduce (num) {
  63570. // Assumes that `num` is less than `P^2`
  63571. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  63572. var r = num;
  63573. var rlen;
  63574. do {
  63575. this.split(r, this.tmp);
  63576. r = this.imulK(r);
  63577. r = r.iadd(this.tmp);
  63578. rlen = r.bitLength();
  63579. } while (rlen > this.n);
  63580. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  63581. if (cmp === 0) {
  63582. r.words[0] = 0;
  63583. r.length = 1;
  63584. } else if (cmp > 0) {
  63585. r.isub(this.p);
  63586. } else {
  63587. if (r.strip !== undefined) {
  63588. // r is BN v4 instance
  63589. r.strip();
  63590. } else {
  63591. // r is BN v5 instance
  63592. r._strip();
  63593. }
  63594. }
  63595. return r;
  63596. };
  63597. MPrime.prototype.split = function split (input, out) {
  63598. input.iushrn(this.n, 0, out);
  63599. };
  63600. MPrime.prototype.imulK = function imulK (num) {
  63601. return num.imul(this.k);
  63602. };
  63603. function K256 () {
  63604. MPrime.call(
  63605. this,
  63606. 'k256',
  63607. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  63608. }
  63609. inherits(K256, MPrime);
  63610. K256.prototype.split = function split (input, output) {
  63611. // 256 = 9 * 26 + 22
  63612. var mask = 0x3fffff;
  63613. var outLen = Math.min(input.length, 9);
  63614. for (var i = 0; i < outLen; i++) {
  63615. output.words[i] = input.words[i];
  63616. }
  63617. output.length = outLen;
  63618. if (input.length <= 9) {
  63619. input.words[0] = 0;
  63620. input.length = 1;
  63621. return;
  63622. }
  63623. // Shift by 9 limbs
  63624. var prev = input.words[9];
  63625. output.words[output.length++] = prev & mask;
  63626. for (i = 10; i < input.length; i++) {
  63627. var next = input.words[i] | 0;
  63628. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  63629. prev = next;
  63630. }
  63631. prev >>>= 22;
  63632. input.words[i - 10] = prev;
  63633. if (prev === 0 && input.length > 10) {
  63634. input.length -= 10;
  63635. } else {
  63636. input.length -= 9;
  63637. }
  63638. };
  63639. K256.prototype.imulK = function imulK (num) {
  63640. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  63641. num.words[num.length] = 0;
  63642. num.words[num.length + 1] = 0;
  63643. num.length += 2;
  63644. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  63645. var lo = 0;
  63646. for (var i = 0; i < num.length; i++) {
  63647. var w = num.words[i] | 0;
  63648. lo += w * 0x3d1;
  63649. num.words[i] = lo & 0x3ffffff;
  63650. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  63651. }
  63652. // Fast length reduction
  63653. if (num.words[num.length - 1] === 0) {
  63654. num.length--;
  63655. if (num.words[num.length - 1] === 0) {
  63656. num.length--;
  63657. }
  63658. }
  63659. return num;
  63660. };
  63661. function P224 () {
  63662. MPrime.call(
  63663. this,
  63664. 'p224',
  63665. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  63666. }
  63667. inherits(P224, MPrime);
  63668. function P192 () {
  63669. MPrime.call(
  63670. this,
  63671. 'p192',
  63672. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  63673. }
  63674. inherits(P192, MPrime);
  63675. function P25519 () {
  63676. // 2 ^ 255 - 19
  63677. MPrime.call(
  63678. this,
  63679. '25519',
  63680. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  63681. }
  63682. inherits(P25519, MPrime);
  63683. P25519.prototype.imulK = function imulK (num) {
  63684. // K = 0x13
  63685. var carry = 0;
  63686. for (var i = 0; i < num.length; i++) {
  63687. var hi = (num.words[i] | 0) * 0x13 + carry;
  63688. var lo = hi & 0x3ffffff;
  63689. hi >>>= 26;
  63690. num.words[i] = lo;
  63691. carry = hi;
  63692. }
  63693. if (carry !== 0) {
  63694. num.words[num.length++] = carry;
  63695. }
  63696. return num;
  63697. };
  63698. // Exported mostly for testing purposes, use plain name instead
  63699. BN._prime = function prime (name) {
  63700. // Cached version of prime
  63701. if (primes[name]) return primes[name];
  63702. var prime;
  63703. if (name === 'k256') {
  63704. prime = new K256();
  63705. } else if (name === 'p224') {
  63706. prime = new P224();
  63707. } else if (name === 'p192') {
  63708. prime = new P192();
  63709. } else if (name === 'p25519') {
  63710. prime = new P25519();
  63711. } else {
  63712. throw new Error('Unknown prime ' + name);
  63713. }
  63714. primes[name] = prime;
  63715. return prime;
  63716. };
  63717. //
  63718. // Base reduction engine
  63719. //
  63720. function Red (m) {
  63721. if (typeof m === 'string') {
  63722. var prime = BN._prime(m);
  63723. this.m = prime.p;
  63724. this.prime = prime;
  63725. } else {
  63726. assert(m.gtn(1), 'modulus must be greater than 1');
  63727. this.m = m;
  63728. this.prime = null;
  63729. }
  63730. }
  63731. Red.prototype._verify1 = function _verify1 (a) {
  63732. assert(a.negative === 0, 'red works only with positives');
  63733. assert(a.red, 'red works only with red numbers');
  63734. };
  63735. Red.prototype._verify2 = function _verify2 (a, b) {
  63736. assert((a.negative | b.negative) === 0, 'red works only with positives');
  63737. assert(a.red && a.red === b.red,
  63738. 'red works only with red numbers');
  63739. };
  63740. Red.prototype.imod = function imod (a) {
  63741. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  63742. return a.umod(this.m)._forceRed(this);
  63743. };
  63744. Red.prototype.neg = function neg (a) {
  63745. if (a.isZero()) {
  63746. return a.clone();
  63747. }
  63748. return this.m.sub(a)._forceRed(this);
  63749. };
  63750. Red.prototype.add = function add (a, b) {
  63751. this._verify2(a, b);
  63752. var res = a.add(b);
  63753. if (res.cmp(this.m) >= 0) {
  63754. res.isub(this.m);
  63755. }
  63756. return res._forceRed(this);
  63757. };
  63758. Red.prototype.iadd = function iadd (a, b) {
  63759. this._verify2(a, b);
  63760. var res = a.iadd(b);
  63761. if (res.cmp(this.m) >= 0) {
  63762. res.isub(this.m);
  63763. }
  63764. return res;
  63765. };
  63766. Red.prototype.sub = function sub (a, b) {
  63767. this._verify2(a, b);
  63768. var res = a.sub(b);
  63769. if (res.cmpn(0) < 0) {
  63770. res.iadd(this.m);
  63771. }
  63772. return res._forceRed(this);
  63773. };
  63774. Red.prototype.isub = function isub (a, b) {
  63775. this._verify2(a, b);
  63776. var res = a.isub(b);
  63777. if (res.cmpn(0) < 0) {
  63778. res.iadd(this.m);
  63779. }
  63780. return res;
  63781. };
  63782. Red.prototype.shl = function shl (a, num) {
  63783. this._verify1(a);
  63784. return this.imod(a.ushln(num));
  63785. };
  63786. Red.prototype.imul = function imul (a, b) {
  63787. this._verify2(a, b);
  63788. return this.imod(a.imul(b));
  63789. };
  63790. Red.prototype.mul = function mul (a, b) {
  63791. this._verify2(a, b);
  63792. return this.imod(a.mul(b));
  63793. };
  63794. Red.prototype.isqr = function isqr (a) {
  63795. return this.imul(a, a.clone());
  63796. };
  63797. Red.prototype.sqr = function sqr (a) {
  63798. return this.mul(a, a);
  63799. };
  63800. Red.prototype.sqrt = function sqrt (a) {
  63801. if (a.isZero()) return a.clone();
  63802. var mod3 = this.m.andln(3);
  63803. assert(mod3 % 2 === 1);
  63804. // Fast case
  63805. if (mod3 === 3) {
  63806. var pow = this.m.add(new BN(1)).iushrn(2);
  63807. return this.pow(a, pow);
  63808. }
  63809. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  63810. //
  63811. // Find Q and S, that Q * 2 ^ S = (P - 1)
  63812. var q = this.m.subn(1);
  63813. var s = 0;
  63814. while (!q.isZero() && q.andln(1) === 0) {
  63815. s++;
  63816. q.iushrn(1);
  63817. }
  63818. assert(!q.isZero());
  63819. var one = new BN(1).toRed(this);
  63820. var nOne = one.redNeg();
  63821. // Find quadratic non-residue
  63822. // NOTE: Max is such because of generalized Riemann hypothesis.
  63823. var lpow = this.m.subn(1).iushrn(1);
  63824. var z = this.m.bitLength();
  63825. z = new BN(2 * z * z).toRed(this);
  63826. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  63827. z.redIAdd(nOne);
  63828. }
  63829. var c = this.pow(z, q);
  63830. var r = this.pow(a, q.addn(1).iushrn(1));
  63831. var t = this.pow(a, q);
  63832. var m = s;
  63833. while (t.cmp(one) !== 0) {
  63834. var tmp = t;
  63835. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  63836. tmp = tmp.redSqr();
  63837. }
  63838. assert(i < m);
  63839. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  63840. r = r.redMul(b);
  63841. c = b.redSqr();
  63842. t = t.redMul(c);
  63843. m = i;
  63844. }
  63845. return r;
  63846. };
  63847. Red.prototype.invm = function invm (a) {
  63848. var inv = a._invmp(this.m);
  63849. if (inv.negative !== 0) {
  63850. inv.negative = 0;
  63851. return this.imod(inv).redNeg();
  63852. } else {
  63853. return this.imod(inv);
  63854. }
  63855. };
  63856. Red.prototype.pow = function pow (a, num) {
  63857. if (num.isZero()) return new BN(1).toRed(this);
  63858. if (num.cmpn(1) === 0) return a.clone();
  63859. var windowSize = 4;
  63860. var wnd = new Array(1 << windowSize);
  63861. wnd[0] = new BN(1).toRed(this);
  63862. wnd[1] = a;
  63863. for (var i = 2; i < wnd.length; i++) {
  63864. wnd[i] = this.mul(wnd[i - 1], a);
  63865. }
  63866. var res = wnd[0];
  63867. var current = 0;
  63868. var currentLen = 0;
  63869. var start = num.bitLength() % 26;
  63870. if (start === 0) {
  63871. start = 26;
  63872. }
  63873. for (i = num.length - 1; i >= 0; i--) {
  63874. var word = num.words[i];
  63875. for (var j = start - 1; j >= 0; j--) {
  63876. var bit = (word >> j) & 1;
  63877. if (res !== wnd[0]) {
  63878. res = this.sqr(res);
  63879. }
  63880. if (bit === 0 && current === 0) {
  63881. currentLen = 0;
  63882. continue;
  63883. }
  63884. current <<= 1;
  63885. current |= bit;
  63886. currentLen++;
  63887. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  63888. res = this.mul(res, wnd[current]);
  63889. currentLen = 0;
  63890. current = 0;
  63891. }
  63892. start = 26;
  63893. }
  63894. return res;
  63895. };
  63896. Red.prototype.convertTo = function convertTo (num) {
  63897. var r = num.umod(this.m);
  63898. return r === num ? r.clone() : r;
  63899. };
  63900. Red.prototype.convertFrom = function convertFrom (num) {
  63901. var res = num.clone();
  63902. res.red = null;
  63903. return res;
  63904. };
  63905. //
  63906. // Montgomery method engine
  63907. //
  63908. BN.mont = function mont (num) {
  63909. return new Mont(num);
  63910. };
  63911. function Mont (m) {
  63912. Red.call(this, m);
  63913. this.shift = this.m.bitLength();
  63914. if (this.shift % 26 !== 0) {
  63915. this.shift += 26 - (this.shift % 26);
  63916. }
  63917. this.r = new BN(1).iushln(this.shift);
  63918. this.r2 = this.imod(this.r.sqr());
  63919. this.rinv = this.r._invmp(this.m);
  63920. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  63921. this.minv = this.minv.umod(this.r);
  63922. this.minv = this.r.sub(this.minv);
  63923. }
  63924. inherits(Mont, Red);
  63925. Mont.prototype.convertTo = function convertTo (num) {
  63926. return this.imod(num.ushln(this.shift));
  63927. };
  63928. Mont.prototype.convertFrom = function convertFrom (num) {
  63929. var r = this.imod(num.mul(this.rinv));
  63930. r.red = null;
  63931. return r;
  63932. };
  63933. Mont.prototype.imul = function imul (a, b) {
  63934. if (a.isZero() || b.isZero()) {
  63935. a.words[0] = 0;
  63936. a.length = 1;
  63937. return a;
  63938. }
  63939. var t = a.imul(b);
  63940. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  63941. var u = t.isub(c).iushrn(this.shift);
  63942. var res = u;
  63943. if (u.cmp(this.m) >= 0) {
  63944. res = u.isub(this.m);
  63945. } else if (u.cmpn(0) < 0) {
  63946. res = u.iadd(this.m);
  63947. }
  63948. return res._forceRed(this);
  63949. };
  63950. Mont.prototype.mul = function mul (a, b) {
  63951. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  63952. var t = a.mul(b);
  63953. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  63954. var u = t.isub(c).iushrn(this.shift);
  63955. var res = u;
  63956. if (u.cmp(this.m) >= 0) {
  63957. res = u.isub(this.m);
  63958. } else if (u.cmpn(0) < 0) {
  63959. res = u.iadd(this.m);
  63960. }
  63961. return res._forceRed(this);
  63962. };
  63963. Mont.prototype.invm = function invm (a) {
  63964. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  63965. var res = this.imod(a._invmp(this.m).mul(this.r2));
  63966. return res._forceRed(this);
  63967. };
  63968. })( false || module, this);
  63969. /***/ }),
  63970. /***/ "./resources/css/app.css":
  63971. /*!*******************************!*\
  63972. !*** ./resources/css/app.css ***!
  63973. \*******************************/
  63974. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  63975. "use strict";
  63976. __webpack_require__.r(__webpack_exports__);
  63977. // extracted by mini-css-extract-plugin
  63978. /***/ }),
  63979. /***/ "./node_modules/minimalistic-assert/index.js":
  63980. /*!***************************************************!*\
  63981. !*** ./node_modules/minimalistic-assert/index.js ***!
  63982. \***************************************************/
  63983. /***/ ((module) => {
  63984. module.exports = assert;
  63985. function assert(val, msg) {
  63986. if (!val)
  63987. throw new Error(msg || 'Assertion failed');
  63988. }
  63989. assert.equal = function assertEqual(l, r, msg) {
  63990. if (l != r)
  63991. throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
  63992. };
  63993. /***/ }),
  63994. /***/ "./node_modules/minimalistic-crypto-utils/lib/utils.js":
  63995. /*!*************************************************************!*\
  63996. !*** ./node_modules/minimalistic-crypto-utils/lib/utils.js ***!
  63997. \*************************************************************/
  63998. /***/ ((__unused_webpack_module, exports) => {
  63999. "use strict";
  64000. var utils = exports;
  64001. function toArray(msg, enc) {
  64002. if (Array.isArray(msg))
  64003. return msg.slice();
  64004. if (!msg)
  64005. return [];
  64006. var res = [];
  64007. if (typeof msg !== 'string') {
  64008. for (var i = 0; i < msg.length; i++)
  64009. res[i] = msg[i] | 0;
  64010. return res;
  64011. }
  64012. if (enc === 'hex') {
  64013. msg = msg.replace(/[^a-z0-9]+/ig, '');
  64014. if (msg.length % 2 !== 0)
  64015. msg = '0' + msg;
  64016. for (var i = 0; i < msg.length; i += 2)
  64017. res.push(parseInt(msg[i] + msg[i + 1], 16));
  64018. } else {
  64019. for (var i = 0; i < msg.length; i++) {
  64020. var c = msg.charCodeAt(i);
  64021. var hi = c >> 8;
  64022. var lo = c & 0xff;
  64023. if (hi)
  64024. res.push(hi, lo);
  64025. else
  64026. res.push(lo);
  64027. }
  64028. }
  64029. return res;
  64030. }
  64031. utils.toArray = toArray;
  64032. function zero2(word) {
  64033. if (word.length === 1)
  64034. return '0' + word;
  64035. else
  64036. return word;
  64037. }
  64038. utils.zero2 = zero2;
  64039. function toHex(msg) {
  64040. var res = '';
  64041. for (var i = 0; i < msg.length; i++)
  64042. res += zero2(msg[i].toString(16));
  64043. return res;
  64044. }
  64045. utils.toHex = toHex;
  64046. utils.encode = function encode(arr, enc) {
  64047. if (enc === 'hex')
  64048. return toHex(arr);
  64049. else
  64050. return arr;
  64051. };
  64052. /***/ }),
  64053. /***/ "./node_modules/no-case/dist.es2015/index.js":
  64054. /*!***************************************************!*\
  64055. !*** ./node_modules/no-case/dist.es2015/index.js ***!
  64056. \***************************************************/
  64057. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  64058. "use strict";
  64059. __webpack_require__.r(__webpack_exports__);
  64060. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  64061. /* harmony export */ noCase: () => (/* binding */ noCase)
  64062. /* harmony export */ });
  64063. /* harmony import */ var lower_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lower-case */ "./node_modules/lower-case/dist.es2015/index.js");
  64064. // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
  64065. var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  64066. // Remove all non-word characters.
  64067. var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  64068. /**
  64069. * Normalize the string into something other libraries can manipulate easier.
  64070. */
  64071. function noCase(input, options) {
  64072. if (options === void 0) { options = {}; }
  64073. var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lower_case__WEBPACK_IMPORTED_MODULE_0__.lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
  64074. var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
  64075. var start = 0;
  64076. var end = result.length;
  64077. // Trim the delimiter from around the output string.
  64078. while (result.charAt(start) === "\0")
  64079. start++;
  64080. while (result.charAt(end - 1) === "\0")
  64081. end--;
  64082. // Transform each token independently.
  64083. return result.slice(start, end).split("\0").map(transform).join(delimiter);
  64084. }
  64085. /**
  64086. * Replace `re` in the input string with the replacement value.
  64087. */
  64088. function replace(input, re, value) {
  64089. if (re instanceof RegExp)
  64090. return input.replace(re, value);
  64091. return re.reduce(function (input, re) { return input.replace(re, value); }, input);
  64092. }
  64093. //# sourceMappingURL=index.js.map
  64094. /***/ }),
  64095. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/buffer/index.js":
  64096. /*!********************************************************************************!*\
  64097. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/buffer/index.js ***!
  64098. \********************************************************************************/
  64099. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  64100. "use strict";
  64101. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  64102. /*!
  64103. * The buffer module from node.js, for the browser.
  64104. *
  64105. * @author Feross Aboukhadijeh <https://feross.org>
  64106. * @license MIT
  64107. */
  64108. /* eslint-disable no-proto */
  64109. const base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  64110. const ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  64111. const customInspectSymbol =
  64112. (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
  64113. ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
  64114. : null
  64115. exports.Buffer = Buffer
  64116. exports.SlowBuffer = SlowBuffer
  64117. exports.INSPECT_MAX_BYTES = 50
  64118. const K_MAX_LENGTH = 0x7fffffff
  64119. exports.kMaxLength = K_MAX_LENGTH
  64120. /**
  64121. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  64122. * === true Use Uint8Array implementation (fastest)
  64123. * === false Print warning and recommend using `buffer` v4.x which has an Object
  64124. * implementation (most compatible, even IE6)
  64125. *
  64126. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  64127. * Opera 11.6+, iOS 4.2+.
  64128. *
  64129. * We report that the browser does not support typed arrays if the are not subclassable
  64130. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  64131. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  64132. * for __proto__ and has a buggy typed array implementation.
  64133. */
  64134. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  64135. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  64136. typeof console.error === 'function') {
  64137. console.error(
  64138. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  64139. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  64140. )
  64141. }
  64142. function typedArraySupport () {
  64143. // Can typed array instances can be augmented?
  64144. try {
  64145. const arr = new Uint8Array(1)
  64146. const proto = { foo: function () { return 42 } }
  64147. Object.setPrototypeOf(proto, Uint8Array.prototype)
  64148. Object.setPrototypeOf(arr, proto)
  64149. return arr.foo() === 42
  64150. } catch (e) {
  64151. return false
  64152. }
  64153. }
  64154. Object.defineProperty(Buffer.prototype, 'parent', {
  64155. enumerable: true,
  64156. get: function () {
  64157. if (!Buffer.isBuffer(this)) return undefined
  64158. return this.buffer
  64159. }
  64160. })
  64161. Object.defineProperty(Buffer.prototype, 'offset', {
  64162. enumerable: true,
  64163. get: function () {
  64164. if (!Buffer.isBuffer(this)) return undefined
  64165. return this.byteOffset
  64166. }
  64167. })
  64168. function createBuffer (length) {
  64169. if (length > K_MAX_LENGTH) {
  64170. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  64171. }
  64172. // Return an augmented `Uint8Array` instance
  64173. const buf = new Uint8Array(length)
  64174. Object.setPrototypeOf(buf, Buffer.prototype)
  64175. return buf
  64176. }
  64177. /**
  64178. * The Buffer constructor returns instances of `Uint8Array` that have their
  64179. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  64180. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  64181. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  64182. * returns a single octet.
  64183. *
  64184. * The `Uint8Array` prototype remains unmodified.
  64185. */
  64186. function Buffer (arg, encodingOrOffset, length) {
  64187. // Common case.
  64188. if (typeof arg === 'number') {
  64189. if (typeof encodingOrOffset === 'string') {
  64190. throw new TypeError(
  64191. 'The "string" argument must be of type string. Received type number'
  64192. )
  64193. }
  64194. return allocUnsafe(arg)
  64195. }
  64196. return from(arg, encodingOrOffset, length)
  64197. }
  64198. Buffer.poolSize = 8192 // not used by this implementation
  64199. function from (value, encodingOrOffset, length) {
  64200. if (typeof value === 'string') {
  64201. return fromString(value, encodingOrOffset)
  64202. }
  64203. if (ArrayBuffer.isView(value)) {
  64204. return fromArrayView(value)
  64205. }
  64206. if (value == null) {
  64207. throw new TypeError(
  64208. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  64209. 'or Array-like Object. Received type ' + (typeof value)
  64210. )
  64211. }
  64212. if (isInstance(value, ArrayBuffer) ||
  64213. (value && isInstance(value.buffer, ArrayBuffer))) {
  64214. return fromArrayBuffer(value, encodingOrOffset, length)
  64215. }
  64216. if (typeof SharedArrayBuffer !== 'undefined' &&
  64217. (isInstance(value, SharedArrayBuffer) ||
  64218. (value && isInstance(value.buffer, SharedArrayBuffer)))) {
  64219. return fromArrayBuffer(value, encodingOrOffset, length)
  64220. }
  64221. if (typeof value === 'number') {
  64222. throw new TypeError(
  64223. 'The "value" argument must not be of type number. Received type number'
  64224. )
  64225. }
  64226. const valueOf = value.valueOf && value.valueOf()
  64227. if (valueOf != null && valueOf !== value) {
  64228. return Buffer.from(valueOf, encodingOrOffset, length)
  64229. }
  64230. const b = fromObject(value)
  64231. if (b) return b
  64232. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  64233. typeof value[Symbol.toPrimitive] === 'function') {
  64234. return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
  64235. }
  64236. throw new TypeError(
  64237. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  64238. 'or Array-like Object. Received type ' + (typeof value)
  64239. )
  64240. }
  64241. /**
  64242. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  64243. * if value is a number.
  64244. * Buffer.from(str[, encoding])
  64245. * Buffer.from(array)
  64246. * Buffer.from(buffer)
  64247. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  64248. **/
  64249. Buffer.from = function (value, encodingOrOffset, length) {
  64250. return from(value, encodingOrOffset, length)
  64251. }
  64252. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  64253. // https://github.com/feross/buffer/pull/148
  64254. Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
  64255. Object.setPrototypeOf(Buffer, Uint8Array)
  64256. function assertSize (size) {
  64257. if (typeof size !== 'number') {
  64258. throw new TypeError('"size" argument must be of type number')
  64259. } else if (size < 0) {
  64260. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  64261. }
  64262. }
  64263. function alloc (size, fill, encoding) {
  64264. assertSize(size)
  64265. if (size <= 0) {
  64266. return createBuffer(size)
  64267. }
  64268. if (fill !== undefined) {
  64269. // Only pay attention to encoding if it's a string. This
  64270. // prevents accidentally sending in a number that would
  64271. // be interpreted as a start offset.
  64272. return typeof encoding === 'string'
  64273. ? createBuffer(size).fill(fill, encoding)
  64274. : createBuffer(size).fill(fill)
  64275. }
  64276. return createBuffer(size)
  64277. }
  64278. /**
  64279. * Creates a new filled Buffer instance.
  64280. * alloc(size[, fill[, encoding]])
  64281. **/
  64282. Buffer.alloc = function (size, fill, encoding) {
  64283. return alloc(size, fill, encoding)
  64284. }
  64285. function allocUnsafe (size) {
  64286. assertSize(size)
  64287. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  64288. }
  64289. /**
  64290. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  64291. * */
  64292. Buffer.allocUnsafe = function (size) {
  64293. return allocUnsafe(size)
  64294. }
  64295. /**
  64296. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  64297. */
  64298. Buffer.allocUnsafeSlow = function (size) {
  64299. return allocUnsafe(size)
  64300. }
  64301. function fromString (string, encoding) {
  64302. if (typeof encoding !== 'string' || encoding === '') {
  64303. encoding = 'utf8'
  64304. }
  64305. if (!Buffer.isEncoding(encoding)) {
  64306. throw new TypeError('Unknown encoding: ' + encoding)
  64307. }
  64308. const length = byteLength(string, encoding) | 0
  64309. let buf = createBuffer(length)
  64310. const actual = buf.write(string, encoding)
  64311. if (actual !== length) {
  64312. // Writing a hex string, for example, that contains invalid characters will
  64313. // cause everything after the first invalid character to be ignored. (e.g.
  64314. // 'abxxcd' will be treated as 'ab')
  64315. buf = buf.slice(0, actual)
  64316. }
  64317. return buf
  64318. }
  64319. function fromArrayLike (array) {
  64320. const length = array.length < 0 ? 0 : checked(array.length) | 0
  64321. const buf = createBuffer(length)
  64322. for (let i = 0; i < length; i += 1) {
  64323. buf[i] = array[i] & 255
  64324. }
  64325. return buf
  64326. }
  64327. function fromArrayView (arrayView) {
  64328. if (isInstance(arrayView, Uint8Array)) {
  64329. const copy = new Uint8Array(arrayView)
  64330. return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
  64331. }
  64332. return fromArrayLike(arrayView)
  64333. }
  64334. function fromArrayBuffer (array, byteOffset, length) {
  64335. if (byteOffset < 0 || array.byteLength < byteOffset) {
  64336. throw new RangeError('"offset" is outside of buffer bounds')
  64337. }
  64338. if (array.byteLength < byteOffset + (length || 0)) {
  64339. throw new RangeError('"length" is outside of buffer bounds')
  64340. }
  64341. let buf
  64342. if (byteOffset === undefined && length === undefined) {
  64343. buf = new Uint8Array(array)
  64344. } else if (length === undefined) {
  64345. buf = new Uint8Array(array, byteOffset)
  64346. } else {
  64347. buf = new Uint8Array(array, byteOffset, length)
  64348. }
  64349. // Return an augmented `Uint8Array` instance
  64350. Object.setPrototypeOf(buf, Buffer.prototype)
  64351. return buf
  64352. }
  64353. function fromObject (obj) {
  64354. if (Buffer.isBuffer(obj)) {
  64355. const len = checked(obj.length) | 0
  64356. const buf = createBuffer(len)
  64357. if (buf.length === 0) {
  64358. return buf
  64359. }
  64360. obj.copy(buf, 0, 0, len)
  64361. return buf
  64362. }
  64363. if (obj.length !== undefined) {
  64364. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  64365. return createBuffer(0)
  64366. }
  64367. return fromArrayLike(obj)
  64368. }
  64369. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  64370. return fromArrayLike(obj.data)
  64371. }
  64372. }
  64373. function checked (length) {
  64374. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  64375. // length is NaN (which is otherwise coerced to zero.)
  64376. if (length >= K_MAX_LENGTH) {
  64377. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  64378. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  64379. }
  64380. return length | 0
  64381. }
  64382. function SlowBuffer (length) {
  64383. if (+length != length) { // eslint-disable-line eqeqeq
  64384. length = 0
  64385. }
  64386. return Buffer.alloc(+length)
  64387. }
  64388. Buffer.isBuffer = function isBuffer (b) {
  64389. return b != null && b._isBuffer === true &&
  64390. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  64391. }
  64392. Buffer.compare = function compare (a, b) {
  64393. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  64394. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  64395. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  64396. throw new TypeError(
  64397. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  64398. )
  64399. }
  64400. if (a === b) return 0
  64401. let x = a.length
  64402. let y = b.length
  64403. for (let i = 0, len = Math.min(x, y); i < len; ++i) {
  64404. if (a[i] !== b[i]) {
  64405. x = a[i]
  64406. y = b[i]
  64407. break
  64408. }
  64409. }
  64410. if (x < y) return -1
  64411. if (y < x) return 1
  64412. return 0
  64413. }
  64414. Buffer.isEncoding = function isEncoding (encoding) {
  64415. switch (String(encoding).toLowerCase()) {
  64416. case 'hex':
  64417. case 'utf8':
  64418. case 'utf-8':
  64419. case 'ascii':
  64420. case 'latin1':
  64421. case 'binary':
  64422. case 'base64':
  64423. case 'ucs2':
  64424. case 'ucs-2':
  64425. case 'utf16le':
  64426. case 'utf-16le':
  64427. return true
  64428. default:
  64429. return false
  64430. }
  64431. }
  64432. Buffer.concat = function concat (list, length) {
  64433. if (!Array.isArray(list)) {
  64434. throw new TypeError('"list" argument must be an Array of Buffers')
  64435. }
  64436. if (list.length === 0) {
  64437. return Buffer.alloc(0)
  64438. }
  64439. let i
  64440. if (length === undefined) {
  64441. length = 0
  64442. for (i = 0; i < list.length; ++i) {
  64443. length += list[i].length
  64444. }
  64445. }
  64446. const buffer = Buffer.allocUnsafe(length)
  64447. let pos = 0
  64448. for (i = 0; i < list.length; ++i) {
  64449. let buf = list[i]
  64450. if (isInstance(buf, Uint8Array)) {
  64451. if (pos + buf.length > buffer.length) {
  64452. if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
  64453. buf.copy(buffer, pos)
  64454. } else {
  64455. Uint8Array.prototype.set.call(
  64456. buffer,
  64457. buf,
  64458. pos
  64459. )
  64460. }
  64461. } else if (!Buffer.isBuffer(buf)) {
  64462. throw new TypeError('"list" argument must be an Array of Buffers')
  64463. } else {
  64464. buf.copy(buffer, pos)
  64465. }
  64466. pos += buf.length
  64467. }
  64468. return buffer
  64469. }
  64470. function byteLength (string, encoding) {
  64471. if (Buffer.isBuffer(string)) {
  64472. return string.length
  64473. }
  64474. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  64475. return string.byteLength
  64476. }
  64477. if (typeof string !== 'string') {
  64478. throw new TypeError(
  64479. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  64480. 'Received type ' + typeof string
  64481. )
  64482. }
  64483. const len = string.length
  64484. const mustMatch = (arguments.length > 2 && arguments[2] === true)
  64485. if (!mustMatch && len === 0) return 0
  64486. // Use a for loop to avoid recursion
  64487. let loweredCase = false
  64488. for (;;) {
  64489. switch (encoding) {
  64490. case 'ascii':
  64491. case 'latin1':
  64492. case 'binary':
  64493. return len
  64494. case 'utf8':
  64495. case 'utf-8':
  64496. return utf8ToBytes(string).length
  64497. case 'ucs2':
  64498. case 'ucs-2':
  64499. case 'utf16le':
  64500. case 'utf-16le':
  64501. return len * 2
  64502. case 'hex':
  64503. return len >>> 1
  64504. case 'base64':
  64505. return base64ToBytes(string).length
  64506. default:
  64507. if (loweredCase) {
  64508. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  64509. }
  64510. encoding = ('' + encoding).toLowerCase()
  64511. loweredCase = true
  64512. }
  64513. }
  64514. }
  64515. Buffer.byteLength = byteLength
  64516. function slowToString (encoding, start, end) {
  64517. let loweredCase = false
  64518. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  64519. // property of a typed array.
  64520. // This behaves neither like String nor Uint8Array in that we set start/end
  64521. // to their upper/lower bounds if the value passed is out of range.
  64522. // undefined is handled specially as per ECMA-262 6th Edition,
  64523. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  64524. if (start === undefined || start < 0) {
  64525. start = 0
  64526. }
  64527. // Return early if start > this.length. Done here to prevent potential uint32
  64528. // coercion fail below.
  64529. if (start > this.length) {
  64530. return ''
  64531. }
  64532. if (end === undefined || end > this.length) {
  64533. end = this.length
  64534. }
  64535. if (end <= 0) {
  64536. return ''
  64537. }
  64538. // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
  64539. end >>>= 0
  64540. start >>>= 0
  64541. if (end <= start) {
  64542. return ''
  64543. }
  64544. if (!encoding) encoding = 'utf8'
  64545. while (true) {
  64546. switch (encoding) {
  64547. case 'hex':
  64548. return hexSlice(this, start, end)
  64549. case 'utf8':
  64550. case 'utf-8':
  64551. return utf8Slice(this, start, end)
  64552. case 'ascii':
  64553. return asciiSlice(this, start, end)
  64554. case 'latin1':
  64555. case 'binary':
  64556. return latin1Slice(this, start, end)
  64557. case 'base64':
  64558. return base64Slice(this, start, end)
  64559. case 'ucs2':
  64560. case 'ucs-2':
  64561. case 'utf16le':
  64562. case 'utf-16le':
  64563. return utf16leSlice(this, start, end)
  64564. default:
  64565. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  64566. encoding = (encoding + '').toLowerCase()
  64567. loweredCase = true
  64568. }
  64569. }
  64570. }
  64571. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  64572. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  64573. // reliably in a browserify context because there could be multiple different
  64574. // copies of the 'buffer' package in use. This method works even for Buffer
  64575. // instances that were created from another copy of the `buffer` package.
  64576. // See: https://github.com/feross/buffer/issues/154
  64577. Buffer.prototype._isBuffer = true
  64578. function swap (b, n, m) {
  64579. const i = b[n]
  64580. b[n] = b[m]
  64581. b[m] = i
  64582. }
  64583. Buffer.prototype.swap16 = function swap16 () {
  64584. const len = this.length
  64585. if (len % 2 !== 0) {
  64586. throw new RangeError('Buffer size must be a multiple of 16-bits')
  64587. }
  64588. for (let i = 0; i < len; i += 2) {
  64589. swap(this, i, i + 1)
  64590. }
  64591. return this
  64592. }
  64593. Buffer.prototype.swap32 = function swap32 () {
  64594. const len = this.length
  64595. if (len % 4 !== 0) {
  64596. throw new RangeError('Buffer size must be a multiple of 32-bits')
  64597. }
  64598. for (let i = 0; i < len; i += 4) {
  64599. swap(this, i, i + 3)
  64600. swap(this, i + 1, i + 2)
  64601. }
  64602. return this
  64603. }
  64604. Buffer.prototype.swap64 = function swap64 () {
  64605. const len = this.length
  64606. if (len % 8 !== 0) {
  64607. throw new RangeError('Buffer size must be a multiple of 64-bits')
  64608. }
  64609. for (let i = 0; i < len; i += 8) {
  64610. swap(this, i, i + 7)
  64611. swap(this, i + 1, i + 6)
  64612. swap(this, i + 2, i + 5)
  64613. swap(this, i + 3, i + 4)
  64614. }
  64615. return this
  64616. }
  64617. Buffer.prototype.toString = function toString () {
  64618. const length = this.length
  64619. if (length === 0) return ''
  64620. if (arguments.length === 0) return utf8Slice(this, 0, length)
  64621. return slowToString.apply(this, arguments)
  64622. }
  64623. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  64624. Buffer.prototype.equals = function equals (b) {
  64625. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  64626. if (this === b) return true
  64627. return Buffer.compare(this, b) === 0
  64628. }
  64629. Buffer.prototype.inspect = function inspect () {
  64630. let str = ''
  64631. const max = exports.INSPECT_MAX_BYTES
  64632. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  64633. if (this.length > max) str += ' ... '
  64634. return '<Buffer ' + str + '>'
  64635. }
  64636. if (customInspectSymbol) {
  64637. Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
  64638. }
  64639. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  64640. if (isInstance(target, Uint8Array)) {
  64641. target = Buffer.from(target, target.offset, target.byteLength)
  64642. }
  64643. if (!Buffer.isBuffer(target)) {
  64644. throw new TypeError(
  64645. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  64646. 'Received type ' + (typeof target)
  64647. )
  64648. }
  64649. if (start === undefined) {
  64650. start = 0
  64651. }
  64652. if (end === undefined) {
  64653. end = target ? target.length : 0
  64654. }
  64655. if (thisStart === undefined) {
  64656. thisStart = 0
  64657. }
  64658. if (thisEnd === undefined) {
  64659. thisEnd = this.length
  64660. }
  64661. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  64662. throw new RangeError('out of range index')
  64663. }
  64664. if (thisStart >= thisEnd && start >= end) {
  64665. return 0
  64666. }
  64667. if (thisStart >= thisEnd) {
  64668. return -1
  64669. }
  64670. if (start >= end) {
  64671. return 1
  64672. }
  64673. start >>>= 0
  64674. end >>>= 0
  64675. thisStart >>>= 0
  64676. thisEnd >>>= 0
  64677. if (this === target) return 0
  64678. let x = thisEnd - thisStart
  64679. let y = end - start
  64680. const len = Math.min(x, y)
  64681. const thisCopy = this.slice(thisStart, thisEnd)
  64682. const targetCopy = target.slice(start, end)
  64683. for (let i = 0; i < len; ++i) {
  64684. if (thisCopy[i] !== targetCopy[i]) {
  64685. x = thisCopy[i]
  64686. y = targetCopy[i]
  64687. break
  64688. }
  64689. }
  64690. if (x < y) return -1
  64691. if (y < x) return 1
  64692. return 0
  64693. }
  64694. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  64695. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  64696. //
  64697. // Arguments:
  64698. // - buffer - a Buffer to search
  64699. // - val - a string, Buffer, or number
  64700. // - byteOffset - an index into `buffer`; will be clamped to an int32
  64701. // - encoding - an optional encoding, relevant is val is a string
  64702. // - dir - true for indexOf, false for lastIndexOf
  64703. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  64704. // Empty buffer means no match
  64705. if (buffer.length === 0) return -1
  64706. // Normalize byteOffset
  64707. if (typeof byteOffset === 'string') {
  64708. encoding = byteOffset
  64709. byteOffset = 0
  64710. } else if (byteOffset > 0x7fffffff) {
  64711. byteOffset = 0x7fffffff
  64712. } else if (byteOffset < -0x80000000) {
  64713. byteOffset = -0x80000000
  64714. }
  64715. byteOffset = +byteOffset // Coerce to Number.
  64716. if (numberIsNaN(byteOffset)) {
  64717. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  64718. byteOffset = dir ? 0 : (buffer.length - 1)
  64719. }
  64720. // Normalize byteOffset: negative offsets start from the end of the buffer
  64721. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  64722. if (byteOffset >= buffer.length) {
  64723. if (dir) return -1
  64724. else byteOffset = buffer.length - 1
  64725. } else if (byteOffset < 0) {
  64726. if (dir) byteOffset = 0
  64727. else return -1
  64728. }
  64729. // Normalize val
  64730. if (typeof val === 'string') {
  64731. val = Buffer.from(val, encoding)
  64732. }
  64733. // Finally, search either indexOf (if dir is true) or lastIndexOf
  64734. if (Buffer.isBuffer(val)) {
  64735. // Special case: looking for empty string/buffer always fails
  64736. if (val.length === 0) {
  64737. return -1
  64738. }
  64739. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  64740. } else if (typeof val === 'number') {
  64741. val = val & 0xFF // Search for a byte value [0-255]
  64742. if (typeof Uint8Array.prototype.indexOf === 'function') {
  64743. if (dir) {
  64744. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  64745. } else {
  64746. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  64747. }
  64748. }
  64749. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
  64750. }
  64751. throw new TypeError('val must be string, number or Buffer')
  64752. }
  64753. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  64754. let indexSize = 1
  64755. let arrLength = arr.length
  64756. let valLength = val.length
  64757. if (encoding !== undefined) {
  64758. encoding = String(encoding).toLowerCase()
  64759. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  64760. encoding === 'utf16le' || encoding === 'utf-16le') {
  64761. if (arr.length < 2 || val.length < 2) {
  64762. return -1
  64763. }
  64764. indexSize = 2
  64765. arrLength /= 2
  64766. valLength /= 2
  64767. byteOffset /= 2
  64768. }
  64769. }
  64770. function read (buf, i) {
  64771. if (indexSize === 1) {
  64772. return buf[i]
  64773. } else {
  64774. return buf.readUInt16BE(i * indexSize)
  64775. }
  64776. }
  64777. let i
  64778. if (dir) {
  64779. let foundIndex = -1
  64780. for (i = byteOffset; i < arrLength; i++) {
  64781. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  64782. if (foundIndex === -1) foundIndex = i
  64783. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  64784. } else {
  64785. if (foundIndex !== -1) i -= i - foundIndex
  64786. foundIndex = -1
  64787. }
  64788. }
  64789. } else {
  64790. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  64791. for (i = byteOffset; i >= 0; i--) {
  64792. let found = true
  64793. for (let j = 0; j < valLength; j++) {
  64794. if (read(arr, i + j) !== read(val, j)) {
  64795. found = false
  64796. break
  64797. }
  64798. }
  64799. if (found) return i
  64800. }
  64801. }
  64802. return -1
  64803. }
  64804. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  64805. return this.indexOf(val, byteOffset, encoding) !== -1
  64806. }
  64807. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  64808. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  64809. }
  64810. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  64811. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  64812. }
  64813. function hexWrite (buf, string, offset, length) {
  64814. offset = Number(offset) || 0
  64815. const remaining = buf.length - offset
  64816. if (!length) {
  64817. length = remaining
  64818. } else {
  64819. length = Number(length)
  64820. if (length > remaining) {
  64821. length = remaining
  64822. }
  64823. }
  64824. const strLen = string.length
  64825. if (length > strLen / 2) {
  64826. length = strLen / 2
  64827. }
  64828. let i
  64829. for (i = 0; i < length; ++i) {
  64830. const parsed = parseInt(string.substr(i * 2, 2), 16)
  64831. if (numberIsNaN(parsed)) return i
  64832. buf[offset + i] = parsed
  64833. }
  64834. return i
  64835. }
  64836. function utf8Write (buf, string, offset, length) {
  64837. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  64838. }
  64839. function asciiWrite (buf, string, offset, length) {
  64840. return blitBuffer(asciiToBytes(string), buf, offset, length)
  64841. }
  64842. function base64Write (buf, string, offset, length) {
  64843. return blitBuffer(base64ToBytes(string), buf, offset, length)
  64844. }
  64845. function ucs2Write (buf, string, offset, length) {
  64846. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  64847. }
  64848. Buffer.prototype.write = function write (string, offset, length, encoding) {
  64849. // Buffer#write(string)
  64850. if (offset === undefined) {
  64851. encoding = 'utf8'
  64852. length = this.length
  64853. offset = 0
  64854. // Buffer#write(string, encoding)
  64855. } else if (length === undefined && typeof offset === 'string') {
  64856. encoding = offset
  64857. length = this.length
  64858. offset = 0
  64859. // Buffer#write(string, offset[, length][, encoding])
  64860. } else if (isFinite(offset)) {
  64861. offset = offset >>> 0
  64862. if (isFinite(length)) {
  64863. length = length >>> 0
  64864. if (encoding === undefined) encoding = 'utf8'
  64865. } else {
  64866. encoding = length
  64867. length = undefined
  64868. }
  64869. } else {
  64870. throw new Error(
  64871. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  64872. )
  64873. }
  64874. const remaining = this.length - offset
  64875. if (length === undefined || length > remaining) length = remaining
  64876. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  64877. throw new RangeError('Attempt to write outside buffer bounds')
  64878. }
  64879. if (!encoding) encoding = 'utf8'
  64880. let loweredCase = false
  64881. for (;;) {
  64882. switch (encoding) {
  64883. case 'hex':
  64884. return hexWrite(this, string, offset, length)
  64885. case 'utf8':
  64886. case 'utf-8':
  64887. return utf8Write(this, string, offset, length)
  64888. case 'ascii':
  64889. case 'latin1':
  64890. case 'binary':
  64891. return asciiWrite(this, string, offset, length)
  64892. case 'base64':
  64893. // Warning: maxLength not taken into account in base64Write
  64894. return base64Write(this, string, offset, length)
  64895. case 'ucs2':
  64896. case 'ucs-2':
  64897. case 'utf16le':
  64898. case 'utf-16le':
  64899. return ucs2Write(this, string, offset, length)
  64900. default:
  64901. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  64902. encoding = ('' + encoding).toLowerCase()
  64903. loweredCase = true
  64904. }
  64905. }
  64906. }
  64907. Buffer.prototype.toJSON = function toJSON () {
  64908. return {
  64909. type: 'Buffer',
  64910. data: Array.prototype.slice.call(this._arr || this, 0)
  64911. }
  64912. }
  64913. function base64Slice (buf, start, end) {
  64914. if (start === 0 && end === buf.length) {
  64915. return base64.fromByteArray(buf)
  64916. } else {
  64917. return base64.fromByteArray(buf.slice(start, end))
  64918. }
  64919. }
  64920. function utf8Slice (buf, start, end) {
  64921. end = Math.min(buf.length, end)
  64922. const res = []
  64923. let i = start
  64924. while (i < end) {
  64925. const firstByte = buf[i]
  64926. let codePoint = null
  64927. let bytesPerSequence = (firstByte > 0xEF)
  64928. ? 4
  64929. : (firstByte > 0xDF)
  64930. ? 3
  64931. : (firstByte > 0xBF)
  64932. ? 2
  64933. : 1
  64934. if (i + bytesPerSequence <= end) {
  64935. let secondByte, thirdByte, fourthByte, tempCodePoint
  64936. switch (bytesPerSequence) {
  64937. case 1:
  64938. if (firstByte < 0x80) {
  64939. codePoint = firstByte
  64940. }
  64941. break
  64942. case 2:
  64943. secondByte = buf[i + 1]
  64944. if ((secondByte & 0xC0) === 0x80) {
  64945. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  64946. if (tempCodePoint > 0x7F) {
  64947. codePoint = tempCodePoint
  64948. }
  64949. }
  64950. break
  64951. case 3:
  64952. secondByte = buf[i + 1]
  64953. thirdByte = buf[i + 2]
  64954. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  64955. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  64956. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  64957. codePoint = tempCodePoint
  64958. }
  64959. }
  64960. break
  64961. case 4:
  64962. secondByte = buf[i + 1]
  64963. thirdByte = buf[i + 2]
  64964. fourthByte = buf[i + 3]
  64965. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  64966. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  64967. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  64968. codePoint = tempCodePoint
  64969. }
  64970. }
  64971. }
  64972. }
  64973. if (codePoint === null) {
  64974. // we did not generate a valid codePoint so insert a
  64975. // replacement char (U+FFFD) and advance only 1 byte
  64976. codePoint = 0xFFFD
  64977. bytesPerSequence = 1
  64978. } else if (codePoint > 0xFFFF) {
  64979. // encode to utf16 (surrogate pair dance)
  64980. codePoint -= 0x10000
  64981. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  64982. codePoint = 0xDC00 | codePoint & 0x3FF
  64983. }
  64984. res.push(codePoint)
  64985. i += bytesPerSequence
  64986. }
  64987. return decodeCodePointsArray(res)
  64988. }
  64989. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  64990. // the lowest limit is Chrome, with 0x10000 args.
  64991. // We go 1 magnitude less, for safety
  64992. const MAX_ARGUMENTS_LENGTH = 0x1000
  64993. function decodeCodePointsArray (codePoints) {
  64994. const len = codePoints.length
  64995. if (len <= MAX_ARGUMENTS_LENGTH) {
  64996. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  64997. }
  64998. // Decode in chunks to avoid "call stack size exceeded".
  64999. let res = ''
  65000. let i = 0
  65001. while (i < len) {
  65002. res += String.fromCharCode.apply(
  65003. String,
  65004. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  65005. )
  65006. }
  65007. return res
  65008. }
  65009. function asciiSlice (buf, start, end) {
  65010. let ret = ''
  65011. end = Math.min(buf.length, end)
  65012. for (let i = start; i < end; ++i) {
  65013. ret += String.fromCharCode(buf[i] & 0x7F)
  65014. }
  65015. return ret
  65016. }
  65017. function latin1Slice (buf, start, end) {
  65018. let ret = ''
  65019. end = Math.min(buf.length, end)
  65020. for (let i = start; i < end; ++i) {
  65021. ret += String.fromCharCode(buf[i])
  65022. }
  65023. return ret
  65024. }
  65025. function hexSlice (buf, start, end) {
  65026. const len = buf.length
  65027. if (!start || start < 0) start = 0
  65028. if (!end || end < 0 || end > len) end = len
  65029. let out = ''
  65030. for (let i = start; i < end; ++i) {
  65031. out += hexSliceLookupTable[buf[i]]
  65032. }
  65033. return out
  65034. }
  65035. function utf16leSlice (buf, start, end) {
  65036. const bytes = buf.slice(start, end)
  65037. let res = ''
  65038. // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
  65039. for (let i = 0; i < bytes.length - 1; i += 2) {
  65040. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  65041. }
  65042. return res
  65043. }
  65044. Buffer.prototype.slice = function slice (start, end) {
  65045. const len = this.length
  65046. start = ~~start
  65047. end = end === undefined ? len : ~~end
  65048. if (start < 0) {
  65049. start += len
  65050. if (start < 0) start = 0
  65051. } else if (start > len) {
  65052. start = len
  65053. }
  65054. if (end < 0) {
  65055. end += len
  65056. if (end < 0) end = 0
  65057. } else if (end > len) {
  65058. end = len
  65059. }
  65060. if (end < start) end = start
  65061. const newBuf = this.subarray(start, end)
  65062. // Return an augmented `Uint8Array` instance
  65063. Object.setPrototypeOf(newBuf, Buffer.prototype)
  65064. return newBuf
  65065. }
  65066. /*
  65067. * Need to make sure that buffer isn't trying to write out of bounds.
  65068. */
  65069. function checkOffset (offset, ext, length) {
  65070. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  65071. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  65072. }
  65073. Buffer.prototype.readUintLE =
  65074. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  65075. offset = offset >>> 0
  65076. byteLength = byteLength >>> 0
  65077. if (!noAssert) checkOffset(offset, byteLength, this.length)
  65078. let val = this[offset]
  65079. let mul = 1
  65080. let i = 0
  65081. while (++i < byteLength && (mul *= 0x100)) {
  65082. val += this[offset + i] * mul
  65083. }
  65084. return val
  65085. }
  65086. Buffer.prototype.readUintBE =
  65087. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  65088. offset = offset >>> 0
  65089. byteLength = byteLength >>> 0
  65090. if (!noAssert) {
  65091. checkOffset(offset, byteLength, this.length)
  65092. }
  65093. let val = this[offset + --byteLength]
  65094. let mul = 1
  65095. while (byteLength > 0 && (mul *= 0x100)) {
  65096. val += this[offset + --byteLength] * mul
  65097. }
  65098. return val
  65099. }
  65100. Buffer.prototype.readUint8 =
  65101. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  65102. offset = offset >>> 0
  65103. if (!noAssert) checkOffset(offset, 1, this.length)
  65104. return this[offset]
  65105. }
  65106. Buffer.prototype.readUint16LE =
  65107. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  65108. offset = offset >>> 0
  65109. if (!noAssert) checkOffset(offset, 2, this.length)
  65110. return this[offset] | (this[offset + 1] << 8)
  65111. }
  65112. Buffer.prototype.readUint16BE =
  65113. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  65114. offset = offset >>> 0
  65115. if (!noAssert) checkOffset(offset, 2, this.length)
  65116. return (this[offset] << 8) | this[offset + 1]
  65117. }
  65118. Buffer.prototype.readUint32LE =
  65119. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  65120. offset = offset >>> 0
  65121. if (!noAssert) checkOffset(offset, 4, this.length)
  65122. return ((this[offset]) |
  65123. (this[offset + 1] << 8) |
  65124. (this[offset + 2] << 16)) +
  65125. (this[offset + 3] * 0x1000000)
  65126. }
  65127. Buffer.prototype.readUint32BE =
  65128. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  65129. offset = offset >>> 0
  65130. if (!noAssert) checkOffset(offset, 4, this.length)
  65131. return (this[offset] * 0x1000000) +
  65132. ((this[offset + 1] << 16) |
  65133. (this[offset + 2] << 8) |
  65134. this[offset + 3])
  65135. }
  65136. Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
  65137. offset = offset >>> 0
  65138. validateNumber(offset, 'offset')
  65139. const first = this[offset]
  65140. const last = this[offset + 7]
  65141. if (first === undefined || last === undefined) {
  65142. boundsError(offset, this.length - 8)
  65143. }
  65144. const lo = first +
  65145. this[++offset] * 2 ** 8 +
  65146. this[++offset] * 2 ** 16 +
  65147. this[++offset] * 2 ** 24
  65148. const hi = this[++offset] +
  65149. this[++offset] * 2 ** 8 +
  65150. this[++offset] * 2 ** 16 +
  65151. last * 2 ** 24
  65152. return BigInt(lo) + (BigInt(hi) << BigInt(32))
  65153. })
  65154. Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
  65155. offset = offset >>> 0
  65156. validateNumber(offset, 'offset')
  65157. const first = this[offset]
  65158. const last = this[offset + 7]
  65159. if (first === undefined || last === undefined) {
  65160. boundsError(offset, this.length - 8)
  65161. }
  65162. const hi = first * 2 ** 24 +
  65163. this[++offset] * 2 ** 16 +
  65164. this[++offset] * 2 ** 8 +
  65165. this[++offset]
  65166. const lo = this[++offset] * 2 ** 24 +
  65167. this[++offset] * 2 ** 16 +
  65168. this[++offset] * 2 ** 8 +
  65169. last
  65170. return (BigInt(hi) << BigInt(32)) + BigInt(lo)
  65171. })
  65172. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  65173. offset = offset >>> 0
  65174. byteLength = byteLength >>> 0
  65175. if (!noAssert) checkOffset(offset, byteLength, this.length)
  65176. let val = this[offset]
  65177. let mul = 1
  65178. let i = 0
  65179. while (++i < byteLength && (mul *= 0x100)) {
  65180. val += this[offset + i] * mul
  65181. }
  65182. mul *= 0x80
  65183. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  65184. return val
  65185. }
  65186. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  65187. offset = offset >>> 0
  65188. byteLength = byteLength >>> 0
  65189. if (!noAssert) checkOffset(offset, byteLength, this.length)
  65190. let i = byteLength
  65191. let mul = 1
  65192. let val = this[offset + --i]
  65193. while (i > 0 && (mul *= 0x100)) {
  65194. val += this[offset + --i] * mul
  65195. }
  65196. mul *= 0x80
  65197. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  65198. return val
  65199. }
  65200. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  65201. offset = offset >>> 0
  65202. if (!noAssert) checkOffset(offset, 1, this.length)
  65203. if (!(this[offset] & 0x80)) return (this[offset])
  65204. return ((0xff - this[offset] + 1) * -1)
  65205. }
  65206. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  65207. offset = offset >>> 0
  65208. if (!noAssert) checkOffset(offset, 2, this.length)
  65209. const val = this[offset] | (this[offset + 1] << 8)
  65210. return (val & 0x8000) ? val | 0xFFFF0000 : val
  65211. }
  65212. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  65213. offset = offset >>> 0
  65214. if (!noAssert) checkOffset(offset, 2, this.length)
  65215. const val = this[offset + 1] | (this[offset] << 8)
  65216. return (val & 0x8000) ? val | 0xFFFF0000 : val
  65217. }
  65218. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  65219. offset = offset >>> 0
  65220. if (!noAssert) checkOffset(offset, 4, this.length)
  65221. return (this[offset]) |
  65222. (this[offset + 1] << 8) |
  65223. (this[offset + 2] << 16) |
  65224. (this[offset + 3] << 24)
  65225. }
  65226. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  65227. offset = offset >>> 0
  65228. if (!noAssert) checkOffset(offset, 4, this.length)
  65229. return (this[offset] << 24) |
  65230. (this[offset + 1] << 16) |
  65231. (this[offset + 2] << 8) |
  65232. (this[offset + 3])
  65233. }
  65234. Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
  65235. offset = offset >>> 0
  65236. validateNumber(offset, 'offset')
  65237. const first = this[offset]
  65238. const last = this[offset + 7]
  65239. if (first === undefined || last === undefined) {
  65240. boundsError(offset, this.length - 8)
  65241. }
  65242. const val = this[offset + 4] +
  65243. this[offset + 5] * 2 ** 8 +
  65244. this[offset + 6] * 2 ** 16 +
  65245. (last << 24) // Overflow
  65246. return (BigInt(val) << BigInt(32)) +
  65247. BigInt(first +
  65248. this[++offset] * 2 ** 8 +
  65249. this[++offset] * 2 ** 16 +
  65250. this[++offset] * 2 ** 24)
  65251. })
  65252. Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
  65253. offset = offset >>> 0
  65254. validateNumber(offset, 'offset')
  65255. const first = this[offset]
  65256. const last = this[offset + 7]
  65257. if (first === undefined || last === undefined) {
  65258. boundsError(offset, this.length - 8)
  65259. }
  65260. const val = (first << 24) + // Overflow
  65261. this[++offset] * 2 ** 16 +
  65262. this[++offset] * 2 ** 8 +
  65263. this[++offset]
  65264. return (BigInt(val) << BigInt(32)) +
  65265. BigInt(this[++offset] * 2 ** 24 +
  65266. this[++offset] * 2 ** 16 +
  65267. this[++offset] * 2 ** 8 +
  65268. last)
  65269. })
  65270. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  65271. offset = offset >>> 0
  65272. if (!noAssert) checkOffset(offset, 4, this.length)
  65273. return ieee754.read(this, offset, true, 23, 4)
  65274. }
  65275. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  65276. offset = offset >>> 0
  65277. if (!noAssert) checkOffset(offset, 4, this.length)
  65278. return ieee754.read(this, offset, false, 23, 4)
  65279. }
  65280. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  65281. offset = offset >>> 0
  65282. if (!noAssert) checkOffset(offset, 8, this.length)
  65283. return ieee754.read(this, offset, true, 52, 8)
  65284. }
  65285. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  65286. offset = offset >>> 0
  65287. if (!noAssert) checkOffset(offset, 8, this.length)
  65288. return ieee754.read(this, offset, false, 52, 8)
  65289. }
  65290. function checkInt (buf, value, offset, ext, max, min) {
  65291. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  65292. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  65293. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  65294. }
  65295. Buffer.prototype.writeUintLE =
  65296. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  65297. value = +value
  65298. offset = offset >>> 0
  65299. byteLength = byteLength >>> 0
  65300. if (!noAssert) {
  65301. const maxBytes = Math.pow(2, 8 * byteLength) - 1
  65302. checkInt(this, value, offset, byteLength, maxBytes, 0)
  65303. }
  65304. let mul = 1
  65305. let i = 0
  65306. this[offset] = value & 0xFF
  65307. while (++i < byteLength && (mul *= 0x100)) {
  65308. this[offset + i] = (value / mul) & 0xFF
  65309. }
  65310. return offset + byteLength
  65311. }
  65312. Buffer.prototype.writeUintBE =
  65313. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  65314. value = +value
  65315. offset = offset >>> 0
  65316. byteLength = byteLength >>> 0
  65317. if (!noAssert) {
  65318. const maxBytes = Math.pow(2, 8 * byteLength) - 1
  65319. checkInt(this, value, offset, byteLength, maxBytes, 0)
  65320. }
  65321. let i = byteLength - 1
  65322. let mul = 1
  65323. this[offset + i] = value & 0xFF
  65324. while (--i >= 0 && (mul *= 0x100)) {
  65325. this[offset + i] = (value / mul) & 0xFF
  65326. }
  65327. return offset + byteLength
  65328. }
  65329. Buffer.prototype.writeUint8 =
  65330. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  65331. value = +value
  65332. offset = offset >>> 0
  65333. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  65334. this[offset] = (value & 0xff)
  65335. return offset + 1
  65336. }
  65337. Buffer.prototype.writeUint16LE =
  65338. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  65339. value = +value
  65340. offset = offset >>> 0
  65341. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  65342. this[offset] = (value & 0xff)
  65343. this[offset + 1] = (value >>> 8)
  65344. return offset + 2
  65345. }
  65346. Buffer.prototype.writeUint16BE =
  65347. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  65348. value = +value
  65349. offset = offset >>> 0
  65350. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  65351. this[offset] = (value >>> 8)
  65352. this[offset + 1] = (value & 0xff)
  65353. return offset + 2
  65354. }
  65355. Buffer.prototype.writeUint32LE =
  65356. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  65357. value = +value
  65358. offset = offset >>> 0
  65359. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  65360. this[offset + 3] = (value >>> 24)
  65361. this[offset + 2] = (value >>> 16)
  65362. this[offset + 1] = (value >>> 8)
  65363. this[offset] = (value & 0xff)
  65364. return offset + 4
  65365. }
  65366. Buffer.prototype.writeUint32BE =
  65367. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  65368. value = +value
  65369. offset = offset >>> 0
  65370. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  65371. this[offset] = (value >>> 24)
  65372. this[offset + 1] = (value >>> 16)
  65373. this[offset + 2] = (value >>> 8)
  65374. this[offset + 3] = (value & 0xff)
  65375. return offset + 4
  65376. }
  65377. function wrtBigUInt64LE (buf, value, offset, min, max) {
  65378. checkIntBI(value, min, max, buf, offset, 7)
  65379. let lo = Number(value & BigInt(0xffffffff))
  65380. buf[offset++] = lo
  65381. lo = lo >> 8
  65382. buf[offset++] = lo
  65383. lo = lo >> 8
  65384. buf[offset++] = lo
  65385. lo = lo >> 8
  65386. buf[offset++] = lo
  65387. let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
  65388. buf[offset++] = hi
  65389. hi = hi >> 8
  65390. buf[offset++] = hi
  65391. hi = hi >> 8
  65392. buf[offset++] = hi
  65393. hi = hi >> 8
  65394. buf[offset++] = hi
  65395. return offset
  65396. }
  65397. function wrtBigUInt64BE (buf, value, offset, min, max) {
  65398. checkIntBI(value, min, max, buf, offset, 7)
  65399. let lo = Number(value & BigInt(0xffffffff))
  65400. buf[offset + 7] = lo
  65401. lo = lo >> 8
  65402. buf[offset + 6] = lo
  65403. lo = lo >> 8
  65404. buf[offset + 5] = lo
  65405. lo = lo >> 8
  65406. buf[offset + 4] = lo
  65407. let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
  65408. buf[offset + 3] = hi
  65409. hi = hi >> 8
  65410. buf[offset + 2] = hi
  65411. hi = hi >> 8
  65412. buf[offset + 1] = hi
  65413. hi = hi >> 8
  65414. buf[offset] = hi
  65415. return offset + 8
  65416. }
  65417. Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
  65418. return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
  65419. })
  65420. Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
  65421. return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
  65422. })
  65423. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  65424. value = +value
  65425. offset = offset >>> 0
  65426. if (!noAssert) {
  65427. const limit = Math.pow(2, (8 * byteLength) - 1)
  65428. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  65429. }
  65430. let i = 0
  65431. let mul = 1
  65432. let sub = 0
  65433. this[offset] = value & 0xFF
  65434. while (++i < byteLength && (mul *= 0x100)) {
  65435. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  65436. sub = 1
  65437. }
  65438. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  65439. }
  65440. return offset + byteLength
  65441. }
  65442. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  65443. value = +value
  65444. offset = offset >>> 0
  65445. if (!noAssert) {
  65446. const limit = Math.pow(2, (8 * byteLength) - 1)
  65447. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  65448. }
  65449. let i = byteLength - 1
  65450. let mul = 1
  65451. let sub = 0
  65452. this[offset + i] = value & 0xFF
  65453. while (--i >= 0 && (mul *= 0x100)) {
  65454. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  65455. sub = 1
  65456. }
  65457. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  65458. }
  65459. return offset + byteLength
  65460. }
  65461. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  65462. value = +value
  65463. offset = offset >>> 0
  65464. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  65465. if (value < 0) value = 0xff + value + 1
  65466. this[offset] = (value & 0xff)
  65467. return offset + 1
  65468. }
  65469. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  65470. value = +value
  65471. offset = offset >>> 0
  65472. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  65473. this[offset] = (value & 0xff)
  65474. this[offset + 1] = (value >>> 8)
  65475. return offset + 2
  65476. }
  65477. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  65478. value = +value
  65479. offset = offset >>> 0
  65480. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  65481. this[offset] = (value >>> 8)
  65482. this[offset + 1] = (value & 0xff)
  65483. return offset + 2
  65484. }
  65485. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  65486. value = +value
  65487. offset = offset >>> 0
  65488. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  65489. this[offset] = (value & 0xff)
  65490. this[offset + 1] = (value >>> 8)
  65491. this[offset + 2] = (value >>> 16)
  65492. this[offset + 3] = (value >>> 24)
  65493. return offset + 4
  65494. }
  65495. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  65496. value = +value
  65497. offset = offset >>> 0
  65498. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  65499. if (value < 0) value = 0xffffffff + value + 1
  65500. this[offset] = (value >>> 24)
  65501. this[offset + 1] = (value >>> 16)
  65502. this[offset + 2] = (value >>> 8)
  65503. this[offset + 3] = (value & 0xff)
  65504. return offset + 4
  65505. }
  65506. Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
  65507. return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
  65508. })
  65509. Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
  65510. return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
  65511. })
  65512. function checkIEEE754 (buf, value, offset, ext, max, min) {
  65513. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  65514. if (offset < 0) throw new RangeError('Index out of range')
  65515. }
  65516. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  65517. value = +value
  65518. offset = offset >>> 0
  65519. if (!noAssert) {
  65520. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  65521. }
  65522. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  65523. return offset + 4
  65524. }
  65525. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  65526. return writeFloat(this, value, offset, true, noAssert)
  65527. }
  65528. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  65529. return writeFloat(this, value, offset, false, noAssert)
  65530. }
  65531. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  65532. value = +value
  65533. offset = offset >>> 0
  65534. if (!noAssert) {
  65535. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  65536. }
  65537. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  65538. return offset + 8
  65539. }
  65540. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  65541. return writeDouble(this, value, offset, true, noAssert)
  65542. }
  65543. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  65544. return writeDouble(this, value, offset, false, noAssert)
  65545. }
  65546. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  65547. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  65548. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  65549. if (!start) start = 0
  65550. if (!end && end !== 0) end = this.length
  65551. if (targetStart >= target.length) targetStart = target.length
  65552. if (!targetStart) targetStart = 0
  65553. if (end > 0 && end < start) end = start
  65554. // Copy 0 bytes; we're done
  65555. if (end === start) return 0
  65556. if (target.length === 0 || this.length === 0) return 0
  65557. // Fatal error conditions
  65558. if (targetStart < 0) {
  65559. throw new RangeError('targetStart out of bounds')
  65560. }
  65561. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  65562. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  65563. // Are we oob?
  65564. if (end > this.length) end = this.length
  65565. if (target.length - targetStart < end - start) {
  65566. end = target.length - targetStart + start
  65567. }
  65568. const len = end - start
  65569. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  65570. // Use built-in when available, missing from IE11
  65571. this.copyWithin(targetStart, start, end)
  65572. } else {
  65573. Uint8Array.prototype.set.call(
  65574. target,
  65575. this.subarray(start, end),
  65576. targetStart
  65577. )
  65578. }
  65579. return len
  65580. }
  65581. // Usage:
  65582. // buffer.fill(number[, offset[, end]])
  65583. // buffer.fill(buffer[, offset[, end]])
  65584. // buffer.fill(string[, offset[, end]][, encoding])
  65585. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  65586. // Handle string cases:
  65587. if (typeof val === 'string') {
  65588. if (typeof start === 'string') {
  65589. encoding = start
  65590. start = 0
  65591. end = this.length
  65592. } else if (typeof end === 'string') {
  65593. encoding = end
  65594. end = this.length
  65595. }
  65596. if (encoding !== undefined && typeof encoding !== 'string') {
  65597. throw new TypeError('encoding must be a string')
  65598. }
  65599. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  65600. throw new TypeError('Unknown encoding: ' + encoding)
  65601. }
  65602. if (val.length === 1) {
  65603. const code = val.charCodeAt(0)
  65604. if ((encoding === 'utf8' && code < 128) ||
  65605. encoding === 'latin1') {
  65606. // Fast path: If `val` fits into a single byte, use that numeric value.
  65607. val = code
  65608. }
  65609. }
  65610. } else if (typeof val === 'number') {
  65611. val = val & 255
  65612. } else if (typeof val === 'boolean') {
  65613. val = Number(val)
  65614. }
  65615. // Invalid ranges are not set to a default, so can range check early.
  65616. if (start < 0 || this.length < start || this.length < end) {
  65617. throw new RangeError('Out of range index')
  65618. }
  65619. if (end <= start) {
  65620. return this
  65621. }
  65622. start = start >>> 0
  65623. end = end === undefined ? this.length : end >>> 0
  65624. if (!val) val = 0
  65625. let i
  65626. if (typeof val === 'number') {
  65627. for (i = start; i < end; ++i) {
  65628. this[i] = val
  65629. }
  65630. } else {
  65631. const bytes = Buffer.isBuffer(val)
  65632. ? val
  65633. : Buffer.from(val, encoding)
  65634. const len = bytes.length
  65635. if (len === 0) {
  65636. throw new TypeError('The value "' + val +
  65637. '" is invalid for argument "value"')
  65638. }
  65639. for (i = 0; i < end - start; ++i) {
  65640. this[i + start] = bytes[i % len]
  65641. }
  65642. }
  65643. return this
  65644. }
  65645. // CUSTOM ERRORS
  65646. // =============
  65647. // Simplified versions from Node, changed for Buffer-only usage
  65648. const errors = {}
  65649. function E (sym, getMessage, Base) {
  65650. errors[sym] = class NodeError extends Base {
  65651. constructor () {
  65652. super()
  65653. Object.defineProperty(this, 'message', {
  65654. value: getMessage.apply(this, arguments),
  65655. writable: true,
  65656. configurable: true
  65657. })
  65658. // Add the error code to the name to include it in the stack trace.
  65659. this.name = `${this.name} [${sym}]`
  65660. // Access the stack to generate the error message including the error code
  65661. // from the name.
  65662. this.stack // eslint-disable-line no-unused-expressions
  65663. // Reset the name to the actual name.
  65664. delete this.name
  65665. }
  65666. get code () {
  65667. return sym
  65668. }
  65669. set code (value) {
  65670. Object.defineProperty(this, 'code', {
  65671. configurable: true,
  65672. enumerable: true,
  65673. value,
  65674. writable: true
  65675. })
  65676. }
  65677. toString () {
  65678. return `${this.name} [${sym}]: ${this.message}`
  65679. }
  65680. }
  65681. }
  65682. E('ERR_BUFFER_OUT_OF_BOUNDS',
  65683. function (name) {
  65684. if (name) {
  65685. return `${name} is outside of buffer bounds`
  65686. }
  65687. return 'Attempt to access memory outside buffer bounds'
  65688. }, RangeError)
  65689. E('ERR_INVALID_ARG_TYPE',
  65690. function (name, actual) {
  65691. return `The "${name}" argument must be of type number. Received type ${typeof actual}`
  65692. }, TypeError)
  65693. E('ERR_OUT_OF_RANGE',
  65694. function (str, range, input) {
  65695. let msg = `The value of "${str}" is out of range.`
  65696. let received = input
  65697. if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
  65698. received = addNumericalSeparator(String(input))
  65699. } else if (typeof input === 'bigint') {
  65700. received = String(input)
  65701. if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
  65702. received = addNumericalSeparator(received)
  65703. }
  65704. received += 'n'
  65705. }
  65706. msg += ` It must be ${range}. Received ${received}`
  65707. return msg
  65708. }, RangeError)
  65709. function addNumericalSeparator (val) {
  65710. let res = ''
  65711. let i = val.length
  65712. const start = val[0] === '-' ? 1 : 0
  65713. for (; i >= start + 4; i -= 3) {
  65714. res = `_${val.slice(i - 3, i)}${res}`
  65715. }
  65716. return `${val.slice(0, i)}${res}`
  65717. }
  65718. // CHECK FUNCTIONS
  65719. // ===============
  65720. function checkBounds (buf, offset, byteLength) {
  65721. validateNumber(offset, 'offset')
  65722. if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
  65723. boundsError(offset, buf.length - (byteLength + 1))
  65724. }
  65725. }
  65726. function checkIntBI (value, min, max, buf, offset, byteLength) {
  65727. if (value > max || value < min) {
  65728. const n = typeof min === 'bigint' ? 'n' : ''
  65729. let range
  65730. if (byteLength > 3) {
  65731. if (min === 0 || min === BigInt(0)) {
  65732. range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`
  65733. } else {
  65734. range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
  65735. `${(byteLength + 1) * 8 - 1}${n}`
  65736. }
  65737. } else {
  65738. range = `>= ${min}${n} and <= ${max}${n}`
  65739. }
  65740. throw new errors.ERR_OUT_OF_RANGE('value', range, value)
  65741. }
  65742. checkBounds(buf, offset, byteLength)
  65743. }
  65744. function validateNumber (value, name) {
  65745. if (typeof value !== 'number') {
  65746. throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
  65747. }
  65748. }
  65749. function boundsError (value, length, type) {
  65750. if (Math.floor(value) !== value) {
  65751. validateNumber(value, type)
  65752. throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
  65753. }
  65754. if (length < 0) {
  65755. throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
  65756. }
  65757. throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
  65758. `>= ${type ? 1 : 0} and <= ${length}`,
  65759. value)
  65760. }
  65761. // HELPER FUNCTIONS
  65762. // ================
  65763. const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  65764. function base64clean (str) {
  65765. // Node takes equal signs as end of the Base64 encoding
  65766. str = str.split('=')[0]
  65767. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  65768. str = str.trim().replace(INVALID_BASE64_RE, '')
  65769. // Node converts strings with length < 2 to ''
  65770. if (str.length < 2) return ''
  65771. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  65772. while (str.length % 4 !== 0) {
  65773. str = str + '='
  65774. }
  65775. return str
  65776. }
  65777. function utf8ToBytes (string, units) {
  65778. units = units || Infinity
  65779. let codePoint
  65780. const length = string.length
  65781. let leadSurrogate = null
  65782. const bytes = []
  65783. for (let i = 0; i < length; ++i) {
  65784. codePoint = string.charCodeAt(i)
  65785. // is surrogate component
  65786. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  65787. // last char was a lead
  65788. if (!leadSurrogate) {
  65789. // no lead yet
  65790. if (codePoint > 0xDBFF) {
  65791. // unexpected trail
  65792. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  65793. continue
  65794. } else if (i + 1 === length) {
  65795. // unpaired lead
  65796. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  65797. continue
  65798. }
  65799. // valid lead
  65800. leadSurrogate = codePoint
  65801. continue
  65802. }
  65803. // 2 leads in a row
  65804. if (codePoint < 0xDC00) {
  65805. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  65806. leadSurrogate = codePoint
  65807. continue
  65808. }
  65809. // valid surrogate pair
  65810. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  65811. } else if (leadSurrogate) {
  65812. // valid bmp char, but last char was a lead
  65813. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  65814. }
  65815. leadSurrogate = null
  65816. // encode utf8
  65817. if (codePoint < 0x80) {
  65818. if ((units -= 1) < 0) break
  65819. bytes.push(codePoint)
  65820. } else if (codePoint < 0x800) {
  65821. if ((units -= 2) < 0) break
  65822. bytes.push(
  65823. codePoint >> 0x6 | 0xC0,
  65824. codePoint & 0x3F | 0x80
  65825. )
  65826. } else if (codePoint < 0x10000) {
  65827. if ((units -= 3) < 0) break
  65828. bytes.push(
  65829. codePoint >> 0xC | 0xE0,
  65830. codePoint >> 0x6 & 0x3F | 0x80,
  65831. codePoint & 0x3F | 0x80
  65832. )
  65833. } else if (codePoint < 0x110000) {
  65834. if ((units -= 4) < 0) break
  65835. bytes.push(
  65836. codePoint >> 0x12 | 0xF0,
  65837. codePoint >> 0xC & 0x3F | 0x80,
  65838. codePoint >> 0x6 & 0x3F | 0x80,
  65839. codePoint & 0x3F | 0x80
  65840. )
  65841. } else {
  65842. throw new Error('Invalid code point')
  65843. }
  65844. }
  65845. return bytes
  65846. }
  65847. function asciiToBytes (str) {
  65848. const byteArray = []
  65849. for (let i = 0; i < str.length; ++i) {
  65850. // Node's code seems to be doing this and not & 0x7F..
  65851. byteArray.push(str.charCodeAt(i) & 0xFF)
  65852. }
  65853. return byteArray
  65854. }
  65855. function utf16leToBytes (str, units) {
  65856. let c, hi, lo
  65857. const byteArray = []
  65858. for (let i = 0; i < str.length; ++i) {
  65859. if ((units -= 2) < 0) break
  65860. c = str.charCodeAt(i)
  65861. hi = c >> 8
  65862. lo = c % 256
  65863. byteArray.push(lo)
  65864. byteArray.push(hi)
  65865. }
  65866. return byteArray
  65867. }
  65868. function base64ToBytes (str) {
  65869. return base64.toByteArray(base64clean(str))
  65870. }
  65871. function blitBuffer (src, dst, offset, length) {
  65872. let i
  65873. for (i = 0; i < length; ++i) {
  65874. if ((i + offset >= dst.length) || (i >= src.length)) break
  65875. dst[i + offset] = src[i]
  65876. }
  65877. return i
  65878. }
  65879. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  65880. // the `instanceof` check but they should be treated as of that type.
  65881. // See: https://github.com/feross/buffer/issues/166
  65882. function isInstance (obj, type) {
  65883. return obj instanceof type ||
  65884. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  65885. obj.constructor.name === type.name)
  65886. }
  65887. function numberIsNaN (obj) {
  65888. // For IE11 support
  65889. return obj !== obj // eslint-disable-line no-self-compare
  65890. }
  65891. // Create lookup table for `toString('hex')`
  65892. // See: https://github.com/feross/buffer/issues/219
  65893. const hexSliceLookupTable = (function () {
  65894. const alphabet = '0123456789abcdef'
  65895. const table = new Array(256)
  65896. for (let i = 0; i < 16; ++i) {
  65897. const i16 = i * 16
  65898. for (let j = 0; j < 16; ++j) {
  65899. table[i16 + j] = alphabet[i] + alphabet[j]
  65900. }
  65901. }
  65902. return table
  65903. })()
  65904. // Return not function with Error if BigInt not supported
  65905. function defineBigIntMethod (fn) {
  65906. return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
  65907. }
  65908. function BufferBigIntNotDefined () {
  65909. throw new Error('BigInt not supported')
  65910. }
  65911. /***/ }),
  65912. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js":
  65913. /*!**************************************************************************************************!*\
  65914. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js ***!
  65915. \**************************************************************************************************/
  65916. /***/ ((module) => {
  65917. "use strict";
  65918. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  65919. var codes = {};
  65920. function createErrorType(code, message, Base) {
  65921. if (!Base) {
  65922. Base = Error;
  65923. }
  65924. function getMessage(arg1, arg2, arg3) {
  65925. if (typeof message === 'string') {
  65926. return message;
  65927. } else {
  65928. return message(arg1, arg2, arg3);
  65929. }
  65930. }
  65931. var NodeError =
  65932. /*#__PURE__*/
  65933. function (_Base) {
  65934. _inheritsLoose(NodeError, _Base);
  65935. function NodeError(arg1, arg2, arg3) {
  65936. return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
  65937. }
  65938. return NodeError;
  65939. }(Base);
  65940. NodeError.prototype.name = Base.name;
  65941. NodeError.prototype.code = code;
  65942. codes[code] = NodeError;
  65943. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  65944. function oneOf(expected, thing) {
  65945. if (Array.isArray(expected)) {
  65946. var len = expected.length;
  65947. expected = expected.map(function (i) {
  65948. return String(i);
  65949. });
  65950. if (len > 2) {
  65951. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  65952. } else if (len === 2) {
  65953. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  65954. } else {
  65955. return "of ".concat(thing, " ").concat(expected[0]);
  65956. }
  65957. } else {
  65958. return "of ".concat(thing, " ").concat(String(expected));
  65959. }
  65960. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  65961. function startsWith(str, search, pos) {
  65962. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  65963. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  65964. function endsWith(str, search, this_len) {
  65965. if (this_len === undefined || this_len > str.length) {
  65966. this_len = str.length;
  65967. }
  65968. return str.substring(this_len - search.length, this_len) === search;
  65969. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  65970. function includes(str, search, start) {
  65971. if (typeof start !== 'number') {
  65972. start = 0;
  65973. }
  65974. if (start + search.length > str.length) {
  65975. return false;
  65976. } else {
  65977. return str.indexOf(search, start) !== -1;
  65978. }
  65979. }
  65980. createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
  65981. return 'The value "' + value + '" is invalid for option "' + name + '"';
  65982. }, TypeError);
  65983. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  65984. // determiner: 'must be' or 'must not be'
  65985. var determiner;
  65986. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  65987. determiner = 'must not be';
  65988. expected = expected.replace(/^not /, '');
  65989. } else {
  65990. determiner = 'must be';
  65991. }
  65992. var msg;
  65993. if (endsWith(name, ' argument')) {
  65994. // For cases like 'first argument'
  65995. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  65996. } else {
  65997. var type = includes(name, '.') ? 'property' : 'argument';
  65998. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  65999. }
  66000. msg += ". Received type ".concat(typeof actual);
  66001. return msg;
  66002. }, TypeError);
  66003. createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
  66004. createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
  66005. return 'The ' + name + ' method is not implemented';
  66006. });
  66007. createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
  66008. createErrorType('ERR_STREAM_DESTROYED', function (name) {
  66009. return 'Cannot call ' + name + ' after a stream was destroyed';
  66010. });
  66011. createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
  66012. createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
  66013. createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
  66014. createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
  66015. createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
  66016. return 'Unknown encoding: ' + arg;
  66017. }, TypeError);
  66018. createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
  66019. module.exports.codes = codes;
  66020. /***/ }),
  66021. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js":
  66022. /*!******************************************************************************************************!*\
  66023. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js ***!
  66024. \******************************************************************************************************/
  66025. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  66026. "use strict";
  66027. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  66028. // Copyright Joyent, Inc. and other Node contributors.
  66029. //
  66030. // Permission is hereby granted, free of charge, to any person obtaining a
  66031. // copy of this software and associated documentation files (the
  66032. // "Software"), to deal in the Software without restriction, including
  66033. // without limitation the rights to use, copy, modify, merge, publish,
  66034. // distribute, sublicense, and/or sell copies of the Software, and to permit
  66035. // persons to whom the Software is furnished to do so, subject to the
  66036. // following conditions:
  66037. //
  66038. // The above copyright notice and this permission notice shall be included
  66039. // in all copies or substantial portions of the Software.
  66040. //
  66041. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  66042. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  66043. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  66044. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  66045. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  66046. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  66047. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  66048. // a duplex stream is just a stream that is both readable and writable.
  66049. // Since JS doesn't have multiple prototypal inheritance, this class
  66050. // prototypally inherits from Readable, and then parasitically from
  66051. // Writable.
  66052. /*<replacement>*/
  66053. var objectKeys = Object.keys || function (obj) {
  66054. var keys = [];
  66055. for (var key in obj) keys.push(key);
  66056. return keys;
  66057. };
  66058. /*</replacement>*/
  66059. module.exports = Duplex;
  66060. var Readable = __webpack_require__(/*! ./_stream_readable */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_readable.js");
  66061. var Writable = __webpack_require__(/*! ./_stream_writable */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_writable.js");
  66062. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Duplex, Readable);
  66063. {
  66064. // Allow the keys array to be GC'ed.
  66065. var keys = objectKeys(Writable.prototype);
  66066. for (var v = 0; v < keys.length; v++) {
  66067. var method = keys[v];
  66068. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  66069. }
  66070. }
  66071. function Duplex(options) {
  66072. if (!(this instanceof Duplex)) return new Duplex(options);
  66073. Readable.call(this, options);
  66074. Writable.call(this, options);
  66075. this.allowHalfOpen = true;
  66076. if (options) {
  66077. if (options.readable === false) this.readable = false;
  66078. if (options.writable === false) this.writable = false;
  66079. if (options.allowHalfOpen === false) {
  66080. this.allowHalfOpen = false;
  66081. this.once('end', onend);
  66082. }
  66083. }
  66084. }
  66085. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  66086. // making it explicit this property is not enumerable
  66087. // because otherwise some prototype manipulation in
  66088. // userland will fail
  66089. enumerable: false,
  66090. get: function get() {
  66091. return this._writableState.highWaterMark;
  66092. }
  66093. });
  66094. Object.defineProperty(Duplex.prototype, 'writableBuffer', {
  66095. // making it explicit this property is not enumerable
  66096. // because otherwise some prototype manipulation in
  66097. // userland will fail
  66098. enumerable: false,
  66099. get: function get() {
  66100. return this._writableState && this._writableState.getBuffer();
  66101. }
  66102. });
  66103. Object.defineProperty(Duplex.prototype, 'writableLength', {
  66104. // making it explicit this property is not enumerable
  66105. // because otherwise some prototype manipulation in
  66106. // userland will fail
  66107. enumerable: false,
  66108. get: function get() {
  66109. return this._writableState.length;
  66110. }
  66111. });
  66112. // the no-half-open enforcer
  66113. function onend() {
  66114. // If the writable side ended, then we're ok.
  66115. if (this._writableState.ended) return;
  66116. // no more data can be written.
  66117. // But allow more writes to happen in this tick.
  66118. process.nextTick(onEndNT, this);
  66119. }
  66120. function onEndNT(self) {
  66121. self.end();
  66122. }
  66123. Object.defineProperty(Duplex.prototype, 'destroyed', {
  66124. // making it explicit this property is not enumerable
  66125. // because otherwise some prototype manipulation in
  66126. // userland will fail
  66127. enumerable: false,
  66128. get: function get() {
  66129. if (this._readableState === undefined || this._writableState === undefined) {
  66130. return false;
  66131. }
  66132. return this._readableState.destroyed && this._writableState.destroyed;
  66133. },
  66134. set: function set(value) {
  66135. // we ignore the value if the stream
  66136. // has not been initialized yet
  66137. if (this._readableState === undefined || this._writableState === undefined) {
  66138. return;
  66139. }
  66140. // backward compatibility, the user is explicitly
  66141. // managing destroyed
  66142. this._readableState.destroyed = value;
  66143. this._writableState.destroyed = value;
  66144. }
  66145. });
  66146. /***/ }),
  66147. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_passthrough.js":
  66148. /*!***********************************************************************************************************!*\
  66149. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_passthrough.js ***!
  66150. \***********************************************************************************************************/
  66151. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  66152. "use strict";
  66153. // Copyright Joyent, Inc. and other Node contributors.
  66154. //
  66155. // Permission is hereby granted, free of charge, to any person obtaining a
  66156. // copy of this software and associated documentation files (the
  66157. // "Software"), to deal in the Software without restriction, including
  66158. // without limitation the rights to use, copy, modify, merge, publish,
  66159. // distribute, sublicense, and/or sell copies of the Software, and to permit
  66160. // persons to whom the Software is furnished to do so, subject to the
  66161. // following conditions:
  66162. //
  66163. // The above copyright notice and this permission notice shall be included
  66164. // in all copies or substantial portions of the Software.
  66165. //
  66166. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  66167. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  66168. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  66169. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  66170. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  66171. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  66172. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  66173. // a passthrough stream.
  66174. // basically just the most minimal sort of Transform stream.
  66175. // Every written chunk gets output as-is.
  66176. module.exports = PassThrough;
  66177. var Transform = __webpack_require__(/*! ./_stream_transform */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_transform.js");
  66178. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(PassThrough, Transform);
  66179. function PassThrough(options) {
  66180. if (!(this instanceof PassThrough)) return new PassThrough(options);
  66181. Transform.call(this, options);
  66182. }
  66183. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  66184. cb(null, chunk);
  66185. };
  66186. /***/ }),
  66187. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_readable.js":
  66188. /*!********************************************************************************************************!*\
  66189. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_readable.js ***!
  66190. \********************************************************************************************************/
  66191. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  66192. "use strict";
  66193. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  66194. // Copyright Joyent, Inc. and other Node contributors.
  66195. //
  66196. // Permission is hereby granted, free of charge, to any person obtaining a
  66197. // copy of this software and associated documentation files (the
  66198. // "Software"), to deal in the Software without restriction, including
  66199. // without limitation the rights to use, copy, modify, merge, publish,
  66200. // distribute, sublicense, and/or sell copies of the Software, and to permit
  66201. // persons to whom the Software is furnished to do so, subject to the
  66202. // following conditions:
  66203. //
  66204. // The above copyright notice and this permission notice shall be included
  66205. // in all copies or substantial portions of the Software.
  66206. //
  66207. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  66208. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  66209. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  66210. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  66211. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  66212. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  66213. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  66214. module.exports = Readable;
  66215. /*<replacement>*/
  66216. var Duplex;
  66217. /*</replacement>*/
  66218. Readable.ReadableState = ReadableState;
  66219. /*<replacement>*/
  66220. var EE = (__webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter);
  66221. var EElistenerCount = function EElistenerCount(emitter, type) {
  66222. return emitter.listeners(type).length;
  66223. };
  66224. /*</replacement>*/
  66225. /*<replacement>*/
  66226. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  66227. /*</replacement>*/
  66228. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/node-polyfill-webpack-plugin/node_modules/buffer/index.js").Buffer);
  66229. var OurUint8Array = (typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
  66230. function _uint8ArrayToBuffer(chunk) {
  66231. return Buffer.from(chunk);
  66232. }
  66233. function _isUint8Array(obj) {
  66234. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  66235. }
  66236. /*<replacement>*/
  66237. var debugUtil = __webpack_require__(/*! util */ "?9a2a");
  66238. var debug;
  66239. if (debugUtil && debugUtil.debuglog) {
  66240. debug = debugUtil.debuglog('stream');
  66241. } else {
  66242. debug = function debug() {};
  66243. }
  66244. /*</replacement>*/
  66245. var BufferList = __webpack_require__(/*! ./internal/streams/buffer_list */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/buffer_list.js");
  66246. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/destroy.js");
  66247. var _require = __webpack_require__(/*! ./internal/streams/state */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/state.js"),
  66248. getHighWaterMark = _require.getHighWaterMark;
  66249. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js").codes),
  66250. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  66251. ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
  66252. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  66253. ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
  66254. // Lazy loaded to improve the startup performance.
  66255. var StringDecoder;
  66256. var createReadableStreamAsyncIterator;
  66257. var from;
  66258. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Readable, Stream);
  66259. var errorOrDestroy = destroyImpl.errorOrDestroy;
  66260. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  66261. function prependListener(emitter, event, fn) {
  66262. // Sadly this is not cacheable as some libraries bundle their own
  66263. // event emitter implementation with them.
  66264. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  66265. // This is a hack to make sure that our error handler is attached before any
  66266. // userland ones. NEVER DO THIS. This is here only because this code needs
  66267. // to continue to work with older versions of Node.js that do not include
  66268. // the prependListener() method. The goal is to eventually remove this hack.
  66269. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  66270. }
  66271. function ReadableState(options, stream, isDuplex) {
  66272. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js");
  66273. options = options || {};
  66274. // Duplex streams are both readable and writable, but share
  66275. // the same options object.
  66276. // However, some cases require setting options to different
  66277. // values for the readable and the writable sides of the duplex stream.
  66278. // These options can be provided separately as readableXXX and writableXXX.
  66279. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
  66280. // object stream flag. Used to make read(n) ignore n and to
  66281. // make all the buffer merging and length checks go away
  66282. this.objectMode = !!options.objectMode;
  66283. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  66284. // the point at which it stops calling _read() to fill the buffer
  66285. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  66286. this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex);
  66287. // A linked list is used to store data chunks instead of an array because the
  66288. // linked list can remove elements from the beginning faster than
  66289. // array.shift()
  66290. this.buffer = new BufferList();
  66291. this.length = 0;
  66292. this.pipes = null;
  66293. this.pipesCount = 0;
  66294. this.flowing = null;
  66295. this.ended = false;
  66296. this.endEmitted = false;
  66297. this.reading = false;
  66298. // a flag to be able to tell if the event 'readable'/'data' is emitted
  66299. // immediately, or on a later tick. We set this to true at first, because
  66300. // any actions that shouldn't happen until "later" should generally also
  66301. // not happen before the first read call.
  66302. this.sync = true;
  66303. // whenever we return null, then we set a flag to say
  66304. // that we're awaiting a 'readable' event emission.
  66305. this.needReadable = false;
  66306. this.emittedReadable = false;
  66307. this.readableListening = false;
  66308. this.resumeScheduled = false;
  66309. this.paused = true;
  66310. // Should close be emitted on destroy. Defaults to true.
  66311. this.emitClose = options.emitClose !== false;
  66312. // Should .destroy() be called after 'end' (and potentially 'finish')
  66313. this.autoDestroy = !!options.autoDestroy;
  66314. // has it been destroyed
  66315. this.destroyed = false;
  66316. // Crypto is kind of old and crusty. Historically, its default string
  66317. // encoding is 'binary' so we have to make this configurable.
  66318. // Everything else in the universe uses 'utf8', though.
  66319. this.defaultEncoding = options.defaultEncoding || 'utf8';
  66320. // the number of writers that are awaiting a drain event in .pipe()s
  66321. this.awaitDrain = 0;
  66322. // if true, a maybeReadMore has been scheduled
  66323. this.readingMore = false;
  66324. this.decoder = null;
  66325. this.encoding = null;
  66326. if (options.encoding) {
  66327. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  66328. this.decoder = new StringDecoder(options.encoding);
  66329. this.encoding = options.encoding;
  66330. }
  66331. }
  66332. function Readable(options) {
  66333. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js");
  66334. if (!(this instanceof Readable)) return new Readable(options);
  66335. // Checking for a Stream.Duplex instance is faster here instead of inside
  66336. // the ReadableState constructor, at least with V8 6.5
  66337. var isDuplex = this instanceof Duplex;
  66338. this._readableState = new ReadableState(options, this, isDuplex);
  66339. // legacy
  66340. this.readable = true;
  66341. if (options) {
  66342. if (typeof options.read === 'function') this._read = options.read;
  66343. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  66344. }
  66345. Stream.call(this);
  66346. }
  66347. Object.defineProperty(Readable.prototype, 'destroyed', {
  66348. // making it explicit this property is not enumerable
  66349. // because otherwise some prototype manipulation in
  66350. // userland will fail
  66351. enumerable: false,
  66352. get: function get() {
  66353. if (this._readableState === undefined) {
  66354. return false;
  66355. }
  66356. return this._readableState.destroyed;
  66357. },
  66358. set: function set(value) {
  66359. // we ignore the value if the stream
  66360. // has not been initialized yet
  66361. if (!this._readableState) {
  66362. return;
  66363. }
  66364. // backward compatibility, the user is explicitly
  66365. // managing destroyed
  66366. this._readableState.destroyed = value;
  66367. }
  66368. });
  66369. Readable.prototype.destroy = destroyImpl.destroy;
  66370. Readable.prototype._undestroy = destroyImpl.undestroy;
  66371. Readable.prototype._destroy = function (err, cb) {
  66372. cb(err);
  66373. };
  66374. // Manually shove something into the read() buffer.
  66375. // This returns true if the highWaterMark has not been hit yet,
  66376. // similar to how Writable.write() returns true if you should
  66377. // write() some more.
  66378. Readable.prototype.push = function (chunk, encoding) {
  66379. var state = this._readableState;
  66380. var skipChunkCheck;
  66381. if (!state.objectMode) {
  66382. if (typeof chunk === 'string') {
  66383. encoding = encoding || state.defaultEncoding;
  66384. if (encoding !== state.encoding) {
  66385. chunk = Buffer.from(chunk, encoding);
  66386. encoding = '';
  66387. }
  66388. skipChunkCheck = true;
  66389. }
  66390. } else {
  66391. skipChunkCheck = true;
  66392. }
  66393. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  66394. };
  66395. // Unshift should *always* be something directly out of read()
  66396. Readable.prototype.unshift = function (chunk) {
  66397. return readableAddChunk(this, chunk, null, true, false);
  66398. };
  66399. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  66400. debug('readableAddChunk', chunk);
  66401. var state = stream._readableState;
  66402. if (chunk === null) {
  66403. state.reading = false;
  66404. onEofChunk(stream, state);
  66405. } else {
  66406. var er;
  66407. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  66408. if (er) {
  66409. errorOrDestroy(stream, er);
  66410. } else if (state.objectMode || chunk && chunk.length > 0) {
  66411. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  66412. chunk = _uint8ArrayToBuffer(chunk);
  66413. }
  66414. if (addToFront) {
  66415. if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
  66416. } else if (state.ended) {
  66417. errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
  66418. } else if (state.destroyed) {
  66419. return false;
  66420. } else {
  66421. state.reading = false;
  66422. if (state.decoder && !encoding) {
  66423. chunk = state.decoder.write(chunk);
  66424. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  66425. } else {
  66426. addChunk(stream, state, chunk, false);
  66427. }
  66428. }
  66429. } else if (!addToFront) {
  66430. state.reading = false;
  66431. maybeReadMore(stream, state);
  66432. }
  66433. }
  66434. // We can push more data if we are below the highWaterMark.
  66435. // Also, if we have no data yet, we can stand some more bytes.
  66436. // This is to work around cases where hwm=0, such as the repl.
  66437. return !state.ended && (state.length < state.highWaterMark || state.length === 0);
  66438. }
  66439. function addChunk(stream, state, chunk, addToFront) {
  66440. if (state.flowing && state.length === 0 && !state.sync) {
  66441. state.awaitDrain = 0;
  66442. stream.emit('data', chunk);
  66443. } else {
  66444. // update the buffer info.
  66445. state.length += state.objectMode ? 1 : chunk.length;
  66446. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  66447. if (state.needReadable) emitReadable(stream);
  66448. }
  66449. maybeReadMore(stream, state);
  66450. }
  66451. function chunkInvalid(state, chunk) {
  66452. var er;
  66453. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  66454. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
  66455. }
  66456. return er;
  66457. }
  66458. Readable.prototype.isPaused = function () {
  66459. return this._readableState.flowing === false;
  66460. };
  66461. // backwards compatibility.
  66462. Readable.prototype.setEncoding = function (enc) {
  66463. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "./node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  66464. var decoder = new StringDecoder(enc);
  66465. this._readableState.decoder = decoder;
  66466. // If setEncoding(null), decoder.encoding equals utf8
  66467. this._readableState.encoding = this._readableState.decoder.encoding;
  66468. // Iterate over current buffer to convert already stored Buffers:
  66469. var p = this._readableState.buffer.head;
  66470. var content = '';
  66471. while (p !== null) {
  66472. content += decoder.write(p.data);
  66473. p = p.next;
  66474. }
  66475. this._readableState.buffer.clear();
  66476. if (content !== '') this._readableState.buffer.push(content);
  66477. this._readableState.length = content.length;
  66478. return this;
  66479. };
  66480. // Don't raise the hwm > 1GB
  66481. var MAX_HWM = 0x40000000;
  66482. function computeNewHighWaterMark(n) {
  66483. if (n >= MAX_HWM) {
  66484. // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
  66485. n = MAX_HWM;
  66486. } else {
  66487. // Get the next highest power of 2 to prevent increasing hwm excessively in
  66488. // tiny amounts
  66489. n--;
  66490. n |= n >>> 1;
  66491. n |= n >>> 2;
  66492. n |= n >>> 4;
  66493. n |= n >>> 8;
  66494. n |= n >>> 16;
  66495. n++;
  66496. }
  66497. return n;
  66498. }
  66499. // This function is designed to be inlinable, so please take care when making
  66500. // changes to the function body.
  66501. function howMuchToRead(n, state) {
  66502. if (n <= 0 || state.length === 0 && state.ended) return 0;
  66503. if (state.objectMode) return 1;
  66504. if (n !== n) {
  66505. // Only flow one buffer at a time
  66506. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  66507. }
  66508. // If we're asking for more than the current hwm, then raise the hwm.
  66509. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  66510. if (n <= state.length) return n;
  66511. // Don't have enough
  66512. if (!state.ended) {
  66513. state.needReadable = true;
  66514. return 0;
  66515. }
  66516. return state.length;
  66517. }
  66518. // you can override either this method, or the async _read(n) below.
  66519. Readable.prototype.read = function (n) {
  66520. debug('read', n);
  66521. n = parseInt(n, 10);
  66522. var state = this._readableState;
  66523. var nOrig = n;
  66524. if (n !== 0) state.emittedReadable = false;
  66525. // if we're doing read(0) to trigger a readable event, but we
  66526. // already have a bunch of data in the buffer, then just trigger
  66527. // the 'readable' event and move on.
  66528. if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
  66529. debug('read: emitReadable', state.length, state.ended);
  66530. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  66531. return null;
  66532. }
  66533. n = howMuchToRead(n, state);
  66534. // if we've ended, and we're now clear, then finish it up.
  66535. if (n === 0 && state.ended) {
  66536. if (state.length === 0) endReadable(this);
  66537. return null;
  66538. }
  66539. // All the actual chunk generation logic needs to be
  66540. // *below* the call to _read. The reason is that in certain
  66541. // synthetic stream cases, such as passthrough streams, _read
  66542. // may be a completely synchronous operation which may change
  66543. // the state of the read buffer, providing enough data when
  66544. // before there was *not* enough.
  66545. //
  66546. // So, the steps are:
  66547. // 1. Figure out what the state of things will be after we do
  66548. // a read from the buffer.
  66549. //
  66550. // 2. If that resulting state will trigger a _read, then call _read.
  66551. // Note that this may be asynchronous, or synchronous. Yes, it is
  66552. // deeply ugly to write APIs this way, but that still doesn't mean
  66553. // that the Readable class should behave improperly, as streams are
  66554. // designed to be sync/async agnostic.
  66555. // Take note if the _read call is sync or async (ie, if the read call
  66556. // has returned yet), so that we know whether or not it's safe to emit
  66557. // 'readable' etc.
  66558. //
  66559. // 3. Actually pull the requested chunks out of the buffer and return.
  66560. // if we need a readable event, then we need to do some reading.
  66561. var doRead = state.needReadable;
  66562. debug('need readable', doRead);
  66563. // if we currently have less than the highWaterMark, then also read some
  66564. if (state.length === 0 || state.length - n < state.highWaterMark) {
  66565. doRead = true;
  66566. debug('length less than watermark', doRead);
  66567. }
  66568. // however, if we've ended, then there's no point, and if we're already
  66569. // reading, then it's unnecessary.
  66570. if (state.ended || state.reading) {
  66571. doRead = false;
  66572. debug('reading or ended', doRead);
  66573. } else if (doRead) {
  66574. debug('do read');
  66575. state.reading = true;
  66576. state.sync = true;
  66577. // if the length is currently zero, then we *need* a readable event.
  66578. if (state.length === 0) state.needReadable = true;
  66579. // call internal read method
  66580. this._read(state.highWaterMark);
  66581. state.sync = false;
  66582. // If _read pushed data synchronously, then `reading` will be false,
  66583. // and we need to re-evaluate how much data we can return to the user.
  66584. if (!state.reading) n = howMuchToRead(nOrig, state);
  66585. }
  66586. var ret;
  66587. if (n > 0) ret = fromList(n, state);else ret = null;
  66588. if (ret === null) {
  66589. state.needReadable = state.length <= state.highWaterMark;
  66590. n = 0;
  66591. } else {
  66592. state.length -= n;
  66593. state.awaitDrain = 0;
  66594. }
  66595. if (state.length === 0) {
  66596. // If we have nothing in the buffer, then we want to know
  66597. // as soon as we *do* get something into the buffer.
  66598. if (!state.ended) state.needReadable = true;
  66599. // If we tried to read() past the EOF, then emit end on the next tick.
  66600. if (nOrig !== n && state.ended) endReadable(this);
  66601. }
  66602. if (ret !== null) this.emit('data', ret);
  66603. return ret;
  66604. };
  66605. function onEofChunk(stream, state) {
  66606. debug('onEofChunk');
  66607. if (state.ended) return;
  66608. if (state.decoder) {
  66609. var chunk = state.decoder.end();
  66610. if (chunk && chunk.length) {
  66611. state.buffer.push(chunk);
  66612. state.length += state.objectMode ? 1 : chunk.length;
  66613. }
  66614. }
  66615. state.ended = true;
  66616. if (state.sync) {
  66617. // if we are sync, wait until next tick to emit the data.
  66618. // Otherwise we risk emitting data in the flow()
  66619. // the readable code triggers during a read() call
  66620. emitReadable(stream);
  66621. } else {
  66622. // emit 'readable' now to make sure it gets picked up.
  66623. state.needReadable = false;
  66624. if (!state.emittedReadable) {
  66625. state.emittedReadable = true;
  66626. emitReadable_(stream);
  66627. }
  66628. }
  66629. }
  66630. // Don't emit readable right away in sync mode, because this can trigger
  66631. // another read() call => stack overflow. This way, it might trigger
  66632. // a nextTick recursion warning, but that's not so bad.
  66633. function emitReadable(stream) {
  66634. var state = stream._readableState;
  66635. debug('emitReadable', state.needReadable, state.emittedReadable);
  66636. state.needReadable = false;
  66637. if (!state.emittedReadable) {
  66638. debug('emitReadable', state.flowing);
  66639. state.emittedReadable = true;
  66640. process.nextTick(emitReadable_, stream);
  66641. }
  66642. }
  66643. function emitReadable_(stream) {
  66644. var state = stream._readableState;
  66645. debug('emitReadable_', state.destroyed, state.length, state.ended);
  66646. if (!state.destroyed && (state.length || state.ended)) {
  66647. stream.emit('readable');
  66648. state.emittedReadable = false;
  66649. }
  66650. // The stream needs another readable event if
  66651. // 1. It is not flowing, as the flow mechanism will take
  66652. // care of it.
  66653. // 2. It is not ended.
  66654. // 3. It is below the highWaterMark, so we can schedule
  66655. // another readable later.
  66656. state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
  66657. flow(stream);
  66658. }
  66659. // at this point, the user has presumably seen the 'readable' event,
  66660. // and called read() to consume some data. that may have triggered
  66661. // in turn another _read(n) call, in which case reading = true if
  66662. // it's in progress.
  66663. // However, if we're not ended, or reading, and the length < hwm,
  66664. // then go ahead and try to read some more preemptively.
  66665. function maybeReadMore(stream, state) {
  66666. if (!state.readingMore) {
  66667. state.readingMore = true;
  66668. process.nextTick(maybeReadMore_, stream, state);
  66669. }
  66670. }
  66671. function maybeReadMore_(stream, state) {
  66672. // Attempt to read more data if we should.
  66673. //
  66674. // The conditions for reading more data are (one of):
  66675. // - Not enough data buffered (state.length < state.highWaterMark). The loop
  66676. // is responsible for filling the buffer with enough data if such data
  66677. // is available. If highWaterMark is 0 and we are not in the flowing mode
  66678. // we should _not_ attempt to buffer any extra data. We'll get more data
  66679. // when the stream consumer calls read() instead.
  66680. // - No data in the buffer, and the stream is in flowing mode. In this mode
  66681. // the loop below is responsible for ensuring read() is called. Failing to
  66682. // call read here would abort the flow and there's no other mechanism for
  66683. // continuing the flow if the stream consumer has just subscribed to the
  66684. // 'data' event.
  66685. //
  66686. // In addition to the above conditions to keep reading data, the following
  66687. // conditions prevent the data from being read:
  66688. // - The stream has ended (state.ended).
  66689. // - There is already a pending 'read' operation (state.reading). This is a
  66690. // case where the the stream has called the implementation defined _read()
  66691. // method, but they are processing the call asynchronously and have _not_
  66692. // called push() with new data. In this case we skip performing more
  66693. // read()s. The execution ends in this method again after the _read() ends
  66694. // up calling push() with more data.
  66695. while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
  66696. var len = state.length;
  66697. debug('maybeReadMore read 0');
  66698. stream.read(0);
  66699. if (len === state.length)
  66700. // didn't get any data, stop spinning.
  66701. break;
  66702. }
  66703. state.readingMore = false;
  66704. }
  66705. // abstract method. to be overridden in specific implementation classes.
  66706. // call cb(er, data) where data is <= n in length.
  66707. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  66708. // arbitrary, and perhaps not very meaningful.
  66709. Readable.prototype._read = function (n) {
  66710. errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
  66711. };
  66712. Readable.prototype.pipe = function (dest, pipeOpts) {
  66713. var src = this;
  66714. var state = this._readableState;
  66715. switch (state.pipesCount) {
  66716. case 0:
  66717. state.pipes = dest;
  66718. break;
  66719. case 1:
  66720. state.pipes = [state.pipes, dest];
  66721. break;
  66722. default:
  66723. state.pipes.push(dest);
  66724. break;
  66725. }
  66726. state.pipesCount += 1;
  66727. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  66728. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  66729. var endFn = doEnd ? onend : unpipe;
  66730. if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
  66731. dest.on('unpipe', onunpipe);
  66732. function onunpipe(readable, unpipeInfo) {
  66733. debug('onunpipe');
  66734. if (readable === src) {
  66735. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  66736. unpipeInfo.hasUnpiped = true;
  66737. cleanup();
  66738. }
  66739. }
  66740. }
  66741. function onend() {
  66742. debug('onend');
  66743. dest.end();
  66744. }
  66745. // when the dest drains, it reduces the awaitDrain counter
  66746. // on the source. This would be more elegant with a .once()
  66747. // handler in flow(), but adding and removing repeatedly is
  66748. // too slow.
  66749. var ondrain = pipeOnDrain(src);
  66750. dest.on('drain', ondrain);
  66751. var cleanedUp = false;
  66752. function cleanup() {
  66753. debug('cleanup');
  66754. // cleanup event handlers once the pipe is broken
  66755. dest.removeListener('close', onclose);
  66756. dest.removeListener('finish', onfinish);
  66757. dest.removeListener('drain', ondrain);
  66758. dest.removeListener('error', onerror);
  66759. dest.removeListener('unpipe', onunpipe);
  66760. src.removeListener('end', onend);
  66761. src.removeListener('end', unpipe);
  66762. src.removeListener('data', ondata);
  66763. cleanedUp = true;
  66764. // if the reader is waiting for a drain event from this
  66765. // specific writer, then it would cause it to never start
  66766. // flowing again.
  66767. // So, if this is awaiting a drain, then we just call it now.
  66768. // If we don't know, then assume that we are waiting for one.
  66769. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  66770. }
  66771. src.on('data', ondata);
  66772. function ondata(chunk) {
  66773. debug('ondata');
  66774. var ret = dest.write(chunk);
  66775. debug('dest.write', ret);
  66776. if (ret === false) {
  66777. // If the user unpiped during `dest.write()`, it is possible
  66778. // to get stuck in a permanently paused state if that write
  66779. // also returned false.
  66780. // => Check whether `dest` is still a piping destination.
  66781. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  66782. debug('false write response, pause', state.awaitDrain);
  66783. state.awaitDrain++;
  66784. }
  66785. src.pause();
  66786. }
  66787. }
  66788. // if the dest has an error, then stop piping into it.
  66789. // however, don't suppress the throwing behavior for this.
  66790. function onerror(er) {
  66791. debug('onerror', er);
  66792. unpipe();
  66793. dest.removeListener('error', onerror);
  66794. if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
  66795. }
  66796. // Make sure our error handler is attached before userland ones.
  66797. prependListener(dest, 'error', onerror);
  66798. // Both close and finish should trigger unpipe, but only once.
  66799. function onclose() {
  66800. dest.removeListener('finish', onfinish);
  66801. unpipe();
  66802. }
  66803. dest.once('close', onclose);
  66804. function onfinish() {
  66805. debug('onfinish');
  66806. dest.removeListener('close', onclose);
  66807. unpipe();
  66808. }
  66809. dest.once('finish', onfinish);
  66810. function unpipe() {
  66811. debug('unpipe');
  66812. src.unpipe(dest);
  66813. }
  66814. // tell the dest that it's being piped to
  66815. dest.emit('pipe', src);
  66816. // start the flow if it hasn't been started already.
  66817. if (!state.flowing) {
  66818. debug('pipe resume');
  66819. src.resume();
  66820. }
  66821. return dest;
  66822. };
  66823. function pipeOnDrain(src) {
  66824. return function pipeOnDrainFunctionResult() {
  66825. var state = src._readableState;
  66826. debug('pipeOnDrain', state.awaitDrain);
  66827. if (state.awaitDrain) state.awaitDrain--;
  66828. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  66829. state.flowing = true;
  66830. flow(src);
  66831. }
  66832. };
  66833. }
  66834. Readable.prototype.unpipe = function (dest) {
  66835. var state = this._readableState;
  66836. var unpipeInfo = {
  66837. hasUnpiped: false
  66838. };
  66839. // if we're not piping anywhere, then do nothing.
  66840. if (state.pipesCount === 0) return this;
  66841. // just one destination. most common case.
  66842. if (state.pipesCount === 1) {
  66843. // passed in one, but it's not the right one.
  66844. if (dest && dest !== state.pipes) return this;
  66845. if (!dest) dest = state.pipes;
  66846. // got a match.
  66847. state.pipes = null;
  66848. state.pipesCount = 0;
  66849. state.flowing = false;
  66850. if (dest) dest.emit('unpipe', this, unpipeInfo);
  66851. return this;
  66852. }
  66853. // slow case. multiple pipe destinations.
  66854. if (!dest) {
  66855. // remove all.
  66856. var dests = state.pipes;
  66857. var len = state.pipesCount;
  66858. state.pipes = null;
  66859. state.pipesCount = 0;
  66860. state.flowing = false;
  66861. for (var i = 0; i < len; i++) dests[i].emit('unpipe', this, {
  66862. hasUnpiped: false
  66863. });
  66864. return this;
  66865. }
  66866. // try to find the right one.
  66867. var index = indexOf(state.pipes, dest);
  66868. if (index === -1) return this;
  66869. state.pipes.splice(index, 1);
  66870. state.pipesCount -= 1;
  66871. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  66872. dest.emit('unpipe', this, unpipeInfo);
  66873. return this;
  66874. };
  66875. // set up data events if they are asked for
  66876. // Ensure readable listeners eventually get something
  66877. Readable.prototype.on = function (ev, fn) {
  66878. var res = Stream.prototype.on.call(this, ev, fn);
  66879. var state = this._readableState;
  66880. if (ev === 'data') {
  66881. // update readableListening so that resume() may be a no-op
  66882. // a few lines down. This is needed to support once('readable').
  66883. state.readableListening = this.listenerCount('readable') > 0;
  66884. // Try start flowing on next tick if stream isn't explicitly paused
  66885. if (state.flowing !== false) this.resume();
  66886. } else if (ev === 'readable') {
  66887. if (!state.endEmitted && !state.readableListening) {
  66888. state.readableListening = state.needReadable = true;
  66889. state.flowing = false;
  66890. state.emittedReadable = false;
  66891. debug('on readable', state.length, state.reading);
  66892. if (state.length) {
  66893. emitReadable(this);
  66894. } else if (!state.reading) {
  66895. process.nextTick(nReadingNextTick, this);
  66896. }
  66897. }
  66898. }
  66899. return res;
  66900. };
  66901. Readable.prototype.addListener = Readable.prototype.on;
  66902. Readable.prototype.removeListener = function (ev, fn) {
  66903. var res = Stream.prototype.removeListener.call(this, ev, fn);
  66904. if (ev === 'readable') {
  66905. // We need to check if there is someone still listening to
  66906. // readable and reset the state. However this needs to happen
  66907. // after readable has been emitted but before I/O (nextTick) to
  66908. // support once('readable', fn) cycles. This means that calling
  66909. // resume within the same tick will have no
  66910. // effect.
  66911. process.nextTick(updateReadableListening, this);
  66912. }
  66913. return res;
  66914. };
  66915. Readable.prototype.removeAllListeners = function (ev) {
  66916. var res = Stream.prototype.removeAllListeners.apply(this, arguments);
  66917. if (ev === 'readable' || ev === undefined) {
  66918. // We need to check if there is someone still listening to
  66919. // readable and reset the state. However this needs to happen
  66920. // after readable has been emitted but before I/O (nextTick) to
  66921. // support once('readable', fn) cycles. This means that calling
  66922. // resume within the same tick will have no
  66923. // effect.
  66924. process.nextTick(updateReadableListening, this);
  66925. }
  66926. return res;
  66927. };
  66928. function updateReadableListening(self) {
  66929. var state = self._readableState;
  66930. state.readableListening = self.listenerCount('readable') > 0;
  66931. if (state.resumeScheduled && !state.paused) {
  66932. // flowing needs to be set to true now, otherwise
  66933. // the upcoming resume will not flow.
  66934. state.flowing = true;
  66935. // crude way to check if we should resume
  66936. } else if (self.listenerCount('data') > 0) {
  66937. self.resume();
  66938. }
  66939. }
  66940. function nReadingNextTick(self) {
  66941. debug('readable nexttick read 0');
  66942. self.read(0);
  66943. }
  66944. // pause() and resume() are remnants of the legacy readable stream API
  66945. // If the user uses them, then switch into old mode.
  66946. Readable.prototype.resume = function () {
  66947. var state = this._readableState;
  66948. if (!state.flowing) {
  66949. debug('resume');
  66950. // we flow only if there is no one listening
  66951. // for readable, but we still have to call
  66952. // resume()
  66953. state.flowing = !state.readableListening;
  66954. resume(this, state);
  66955. }
  66956. state.paused = false;
  66957. return this;
  66958. };
  66959. function resume(stream, state) {
  66960. if (!state.resumeScheduled) {
  66961. state.resumeScheduled = true;
  66962. process.nextTick(resume_, stream, state);
  66963. }
  66964. }
  66965. function resume_(stream, state) {
  66966. debug('resume', state.reading);
  66967. if (!state.reading) {
  66968. stream.read(0);
  66969. }
  66970. state.resumeScheduled = false;
  66971. stream.emit('resume');
  66972. flow(stream);
  66973. if (state.flowing && !state.reading) stream.read(0);
  66974. }
  66975. Readable.prototype.pause = function () {
  66976. debug('call pause flowing=%j', this._readableState.flowing);
  66977. if (this._readableState.flowing !== false) {
  66978. debug('pause');
  66979. this._readableState.flowing = false;
  66980. this.emit('pause');
  66981. }
  66982. this._readableState.paused = true;
  66983. return this;
  66984. };
  66985. function flow(stream) {
  66986. var state = stream._readableState;
  66987. debug('flow', state.flowing);
  66988. while (state.flowing && stream.read() !== null);
  66989. }
  66990. // wrap an old-style stream as the async data source.
  66991. // This is *not* part of the readable stream interface.
  66992. // It is an ugly unfortunate mess of history.
  66993. Readable.prototype.wrap = function (stream) {
  66994. var _this = this;
  66995. var state = this._readableState;
  66996. var paused = false;
  66997. stream.on('end', function () {
  66998. debug('wrapped end');
  66999. if (state.decoder && !state.ended) {
  67000. var chunk = state.decoder.end();
  67001. if (chunk && chunk.length) _this.push(chunk);
  67002. }
  67003. _this.push(null);
  67004. });
  67005. stream.on('data', function (chunk) {
  67006. debug('wrapped data');
  67007. if (state.decoder) chunk = state.decoder.write(chunk);
  67008. // don't skip over falsy values in objectMode
  67009. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  67010. var ret = _this.push(chunk);
  67011. if (!ret) {
  67012. paused = true;
  67013. stream.pause();
  67014. }
  67015. });
  67016. // proxy all the other methods.
  67017. // important when wrapping filters and duplexes.
  67018. for (var i in stream) {
  67019. if (this[i] === undefined && typeof stream[i] === 'function') {
  67020. this[i] = function methodWrap(method) {
  67021. return function methodWrapReturnFunction() {
  67022. return stream[method].apply(stream, arguments);
  67023. };
  67024. }(i);
  67025. }
  67026. }
  67027. // proxy certain important events.
  67028. for (var n = 0; n < kProxyEvents.length; n++) {
  67029. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  67030. }
  67031. // when we try to consume some more bytes, simply unpause the
  67032. // underlying stream.
  67033. this._read = function (n) {
  67034. debug('wrapped _read', n);
  67035. if (paused) {
  67036. paused = false;
  67037. stream.resume();
  67038. }
  67039. };
  67040. return this;
  67041. };
  67042. if (typeof Symbol === 'function') {
  67043. Readable.prototype[Symbol.asyncIterator] = function () {
  67044. if (createReadableStreamAsyncIterator === undefined) {
  67045. createReadableStreamAsyncIterator = __webpack_require__(/*! ./internal/streams/async_iterator */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/async_iterator.js");
  67046. }
  67047. return createReadableStreamAsyncIterator(this);
  67048. };
  67049. }
  67050. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  67051. // making it explicit this property is not enumerable
  67052. // because otherwise some prototype manipulation in
  67053. // userland will fail
  67054. enumerable: false,
  67055. get: function get() {
  67056. return this._readableState.highWaterMark;
  67057. }
  67058. });
  67059. Object.defineProperty(Readable.prototype, 'readableBuffer', {
  67060. // making it explicit this property is not enumerable
  67061. // because otherwise some prototype manipulation in
  67062. // userland will fail
  67063. enumerable: false,
  67064. get: function get() {
  67065. return this._readableState && this._readableState.buffer;
  67066. }
  67067. });
  67068. Object.defineProperty(Readable.prototype, 'readableFlowing', {
  67069. // making it explicit this property is not enumerable
  67070. // because otherwise some prototype manipulation in
  67071. // userland will fail
  67072. enumerable: false,
  67073. get: function get() {
  67074. return this._readableState.flowing;
  67075. },
  67076. set: function set(state) {
  67077. if (this._readableState) {
  67078. this._readableState.flowing = state;
  67079. }
  67080. }
  67081. });
  67082. // exposed for testing purposes only.
  67083. Readable._fromList = fromList;
  67084. Object.defineProperty(Readable.prototype, 'readableLength', {
  67085. // making it explicit this property is not enumerable
  67086. // because otherwise some prototype manipulation in
  67087. // userland will fail
  67088. enumerable: false,
  67089. get: function get() {
  67090. return this._readableState.length;
  67091. }
  67092. });
  67093. // Pluck off n bytes from an array of buffers.
  67094. // Length is the combined lengths of all the buffers in the list.
  67095. // This function is designed to be inlinable, so please take care when making
  67096. // changes to the function body.
  67097. function fromList(n, state) {
  67098. // nothing buffered
  67099. if (state.length === 0) return null;
  67100. var ret;
  67101. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  67102. // read it all, truncate the list
  67103. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
  67104. state.buffer.clear();
  67105. } else {
  67106. // read part of list
  67107. ret = state.buffer.consume(n, state.decoder);
  67108. }
  67109. return ret;
  67110. }
  67111. function endReadable(stream) {
  67112. var state = stream._readableState;
  67113. debug('endReadable', state.endEmitted);
  67114. if (!state.endEmitted) {
  67115. state.ended = true;
  67116. process.nextTick(endReadableNT, state, stream);
  67117. }
  67118. }
  67119. function endReadableNT(state, stream) {
  67120. debug('endReadableNT', state.endEmitted, state.length);
  67121. // Check that we didn't get one last unshift.
  67122. if (!state.endEmitted && state.length === 0) {
  67123. state.endEmitted = true;
  67124. stream.readable = false;
  67125. stream.emit('end');
  67126. if (state.autoDestroy) {
  67127. // In case of duplex streams we need a way to detect
  67128. // if the writable side is ready for autoDestroy as well
  67129. var wState = stream._writableState;
  67130. if (!wState || wState.autoDestroy && wState.finished) {
  67131. stream.destroy();
  67132. }
  67133. }
  67134. }
  67135. }
  67136. if (typeof Symbol === 'function') {
  67137. Readable.from = function (iterable, opts) {
  67138. if (from === undefined) {
  67139. from = __webpack_require__(/*! ./internal/streams/from */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/from-browser.js");
  67140. }
  67141. return from(Readable, iterable, opts);
  67142. };
  67143. }
  67144. function indexOf(xs, x) {
  67145. for (var i = 0, l = xs.length; i < l; i++) {
  67146. if (xs[i] === x) return i;
  67147. }
  67148. return -1;
  67149. }
  67150. /***/ }),
  67151. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_transform.js":
  67152. /*!*********************************************************************************************************!*\
  67153. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_transform.js ***!
  67154. \*********************************************************************************************************/
  67155. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  67156. "use strict";
  67157. // Copyright Joyent, Inc. and other Node contributors.
  67158. //
  67159. // Permission is hereby granted, free of charge, to any person obtaining a
  67160. // copy of this software and associated documentation files (the
  67161. // "Software"), to deal in the Software without restriction, including
  67162. // without limitation the rights to use, copy, modify, merge, publish,
  67163. // distribute, sublicense, and/or sell copies of the Software, and to permit
  67164. // persons to whom the Software is furnished to do so, subject to the
  67165. // following conditions:
  67166. //
  67167. // The above copyright notice and this permission notice shall be included
  67168. // in all copies or substantial portions of the Software.
  67169. //
  67170. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  67171. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  67172. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  67173. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  67174. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  67175. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  67176. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  67177. // a transform stream is a readable/writable stream where you do
  67178. // something with the data. Sometimes it's called a "filter",
  67179. // but that's not a great name for it, since that implies a thing where
  67180. // some bits pass through, and others are simply ignored. (That would
  67181. // be a valid example of a transform, of course.)
  67182. //
  67183. // While the output is causally related to the input, it's not a
  67184. // necessarily symmetric or synchronous transformation. For example,
  67185. // a zlib stream might take multiple plain-text writes(), and then
  67186. // emit a single compressed chunk some time in the future.
  67187. //
  67188. // Here's how this works:
  67189. //
  67190. // The Transform stream has all the aspects of the readable and writable
  67191. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  67192. // internally, and returns false if there's a lot of pending writes
  67193. // buffered up. When you call read(), that calls _read(n) until
  67194. // there's enough pending readable data buffered up.
  67195. //
  67196. // In a transform stream, the written data is placed in a buffer. When
  67197. // _read(n) is called, it transforms the queued up data, calling the
  67198. // buffered _write cb's as it consumes chunks. If consuming a single
  67199. // written chunk would result in multiple output chunks, then the first
  67200. // outputted bit calls the readcb, and subsequent chunks just go into
  67201. // the read buffer, and will cause it to emit 'readable' if necessary.
  67202. //
  67203. // This way, back-pressure is actually determined by the reading side,
  67204. // since _read has to be called to start processing a new chunk. However,
  67205. // a pathological inflate type of transform can cause excessive buffering
  67206. // here. For example, imagine a stream where every byte of input is
  67207. // interpreted as an integer from 0-255, and then results in that many
  67208. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  67209. // 1kb of data being output. In this case, you could write a very small
  67210. // amount of input, and end up with a very large amount of output. In
  67211. // such a pathological inflating mechanism, there'd be no way to tell
  67212. // the system to stop doing the transform. A single 4MB write could
  67213. // cause the system to run out of memory.
  67214. //
  67215. // However, even in such a pathological case, only a single written chunk
  67216. // would be consumed, and then the rest would wait (un-transformed) until
  67217. // the results of the previous transformed chunk were consumed.
  67218. module.exports = Transform;
  67219. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js").codes),
  67220. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  67221. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  67222. ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
  67223. ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
  67224. var Duplex = __webpack_require__(/*! ./_stream_duplex */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js");
  67225. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Transform, Duplex);
  67226. function afterTransform(er, data) {
  67227. var ts = this._transformState;
  67228. ts.transforming = false;
  67229. var cb = ts.writecb;
  67230. if (cb === null) {
  67231. return this.emit('error', new ERR_MULTIPLE_CALLBACK());
  67232. }
  67233. ts.writechunk = null;
  67234. ts.writecb = null;
  67235. if (data != null)
  67236. // single equals check for both `null` and `undefined`
  67237. this.push(data);
  67238. cb(er);
  67239. var rs = this._readableState;
  67240. rs.reading = false;
  67241. if (rs.needReadable || rs.length < rs.highWaterMark) {
  67242. this._read(rs.highWaterMark);
  67243. }
  67244. }
  67245. function Transform(options) {
  67246. if (!(this instanceof Transform)) return new Transform(options);
  67247. Duplex.call(this, options);
  67248. this._transformState = {
  67249. afterTransform: afterTransform.bind(this),
  67250. needTransform: false,
  67251. transforming: false,
  67252. writecb: null,
  67253. writechunk: null,
  67254. writeencoding: null
  67255. };
  67256. // start out asking for a readable event once data is transformed.
  67257. this._readableState.needReadable = true;
  67258. // we have implemented the _read method, and done the other things
  67259. // that Readable wants before the first _read call, so unset the
  67260. // sync guard flag.
  67261. this._readableState.sync = false;
  67262. if (options) {
  67263. if (typeof options.transform === 'function') this._transform = options.transform;
  67264. if (typeof options.flush === 'function') this._flush = options.flush;
  67265. }
  67266. // When the writable side finishes, then flush out anything remaining.
  67267. this.on('prefinish', prefinish);
  67268. }
  67269. function prefinish() {
  67270. var _this = this;
  67271. if (typeof this._flush === 'function' && !this._readableState.destroyed) {
  67272. this._flush(function (er, data) {
  67273. done(_this, er, data);
  67274. });
  67275. } else {
  67276. done(this, null, null);
  67277. }
  67278. }
  67279. Transform.prototype.push = function (chunk, encoding) {
  67280. this._transformState.needTransform = false;
  67281. return Duplex.prototype.push.call(this, chunk, encoding);
  67282. };
  67283. // This is the part where you do stuff!
  67284. // override this function in implementation classes.
  67285. // 'chunk' is an input chunk.
  67286. //
  67287. // Call `push(newChunk)` to pass along transformed output
  67288. // to the readable side. You may call 'push' zero or more times.
  67289. //
  67290. // Call `cb(err)` when you are done with this chunk. If you pass
  67291. // an error, then that'll put the hurt on the whole operation. If you
  67292. // never call cb(), then you'll never get another chunk.
  67293. Transform.prototype._transform = function (chunk, encoding, cb) {
  67294. cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
  67295. };
  67296. Transform.prototype._write = function (chunk, encoding, cb) {
  67297. var ts = this._transformState;
  67298. ts.writecb = cb;
  67299. ts.writechunk = chunk;
  67300. ts.writeencoding = encoding;
  67301. if (!ts.transforming) {
  67302. var rs = this._readableState;
  67303. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  67304. }
  67305. };
  67306. // Doesn't matter what the args are here.
  67307. // _transform does all the work.
  67308. // That we got here means that the readable side wants more data.
  67309. Transform.prototype._read = function (n) {
  67310. var ts = this._transformState;
  67311. if (ts.writechunk !== null && !ts.transforming) {
  67312. ts.transforming = true;
  67313. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  67314. } else {
  67315. // mark that we need a transform, so that any data that comes in
  67316. // will get processed, now that we've asked for it.
  67317. ts.needTransform = true;
  67318. }
  67319. };
  67320. Transform.prototype._destroy = function (err, cb) {
  67321. Duplex.prototype._destroy.call(this, err, function (err2) {
  67322. cb(err2);
  67323. });
  67324. };
  67325. function done(stream, er, data) {
  67326. if (er) return stream.emit('error', er);
  67327. if (data != null)
  67328. // single equals check for both `null` and `undefined`
  67329. stream.push(data);
  67330. // TODO(BridgeAR): Write a test for these two error cases
  67331. // if there's nothing in the write buffer, then that means
  67332. // that nothing more will ever be provided
  67333. if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
  67334. if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
  67335. return stream.push(null);
  67336. }
  67337. /***/ }),
  67338. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_writable.js":
  67339. /*!********************************************************************************************************!*\
  67340. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_writable.js ***!
  67341. \********************************************************************************************************/
  67342. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  67343. "use strict";
  67344. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  67345. // Copyright Joyent, Inc. and other Node contributors.
  67346. //
  67347. // Permission is hereby granted, free of charge, to any person obtaining a
  67348. // copy of this software and associated documentation files (the
  67349. // "Software"), to deal in the Software without restriction, including
  67350. // without limitation the rights to use, copy, modify, merge, publish,
  67351. // distribute, sublicense, and/or sell copies of the Software, and to permit
  67352. // persons to whom the Software is furnished to do so, subject to the
  67353. // following conditions:
  67354. //
  67355. // The above copyright notice and this permission notice shall be included
  67356. // in all copies or substantial portions of the Software.
  67357. //
  67358. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  67359. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  67360. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  67361. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  67362. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  67363. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  67364. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  67365. // A bit simpler than readable streams.
  67366. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  67367. // the drain event emission and buffering.
  67368. module.exports = Writable;
  67369. /* <replacement> */
  67370. function WriteReq(chunk, encoding, cb) {
  67371. this.chunk = chunk;
  67372. this.encoding = encoding;
  67373. this.callback = cb;
  67374. this.next = null;
  67375. }
  67376. // It seems a linked list but it is not
  67377. // there will be only 2 of these for each stream
  67378. function CorkedRequest(state) {
  67379. var _this = this;
  67380. this.next = null;
  67381. this.entry = null;
  67382. this.finish = function () {
  67383. onCorkedFinish(_this, state);
  67384. };
  67385. }
  67386. /* </replacement> */
  67387. /*<replacement>*/
  67388. var Duplex;
  67389. /*</replacement>*/
  67390. Writable.WritableState = WritableState;
  67391. /*<replacement>*/
  67392. var internalUtil = {
  67393. deprecate: __webpack_require__(/*! util-deprecate */ "./node_modules/util-deprecate/browser.js")
  67394. };
  67395. /*</replacement>*/
  67396. /*<replacement>*/
  67397. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  67398. /*</replacement>*/
  67399. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/node-polyfill-webpack-plugin/node_modules/buffer/index.js").Buffer);
  67400. var OurUint8Array = (typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
  67401. function _uint8ArrayToBuffer(chunk) {
  67402. return Buffer.from(chunk);
  67403. }
  67404. function _isUint8Array(obj) {
  67405. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  67406. }
  67407. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/destroy.js");
  67408. var _require = __webpack_require__(/*! ./internal/streams/state */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/state.js"),
  67409. getHighWaterMark = _require.getHighWaterMark;
  67410. var _require$codes = (__webpack_require__(/*! ../errors */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js").codes),
  67411. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  67412. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  67413. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  67414. ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
  67415. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
  67416. ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
  67417. ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
  67418. ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
  67419. var errorOrDestroy = destroyImpl.errorOrDestroy;
  67420. __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")(Writable, Stream);
  67421. function nop() {}
  67422. function WritableState(options, stream, isDuplex) {
  67423. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js");
  67424. options = options || {};
  67425. // Duplex streams are both readable and writable, but share
  67426. // the same options object.
  67427. // However, some cases require setting options to different
  67428. // values for the readable and the writable sides of the duplex stream,
  67429. // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
  67430. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
  67431. // object stream flag to indicate whether or not this stream
  67432. // contains buffers or objects.
  67433. this.objectMode = !!options.objectMode;
  67434. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  67435. // the point at which write() starts returning false
  67436. // Note: 0 is a valid value, means that we always return false if
  67437. // the entire buffer is not flushed immediately on write()
  67438. this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex);
  67439. // if _final has been called
  67440. this.finalCalled = false;
  67441. // drain event flag.
  67442. this.needDrain = false;
  67443. // at the start of calling end()
  67444. this.ending = false;
  67445. // when end() has been called, and returned
  67446. this.ended = false;
  67447. // when 'finish' is emitted
  67448. this.finished = false;
  67449. // has it been destroyed
  67450. this.destroyed = false;
  67451. // should we decode strings into buffers before passing to _write?
  67452. // this is here so that some node-core streams can optimize string
  67453. // handling at a lower level.
  67454. var noDecode = options.decodeStrings === false;
  67455. this.decodeStrings = !noDecode;
  67456. // Crypto is kind of old and crusty. Historically, its default string
  67457. // encoding is 'binary' so we have to make this configurable.
  67458. // Everything else in the universe uses 'utf8', though.
  67459. this.defaultEncoding = options.defaultEncoding || 'utf8';
  67460. // not an actual buffer we keep track of, but a measurement
  67461. // of how much we're waiting to get pushed to some underlying
  67462. // socket or file.
  67463. this.length = 0;
  67464. // a flag to see when we're in the middle of a write.
  67465. this.writing = false;
  67466. // when true all writes will be buffered until .uncork() call
  67467. this.corked = 0;
  67468. // a flag to be able to tell if the onwrite cb is called immediately,
  67469. // or on a later tick. We set this to true at first, because any
  67470. // actions that shouldn't happen until "later" should generally also
  67471. // not happen before the first write call.
  67472. this.sync = true;
  67473. // a flag to know if we're processing previously buffered items, which
  67474. // may call the _write() callback in the same tick, so that we don't
  67475. // end up in an overlapped onwrite situation.
  67476. this.bufferProcessing = false;
  67477. // the callback that's passed to _write(chunk,cb)
  67478. this.onwrite = function (er) {
  67479. onwrite(stream, er);
  67480. };
  67481. // the callback that the user supplies to write(chunk,encoding,cb)
  67482. this.writecb = null;
  67483. // the amount that is being written when _write is called.
  67484. this.writelen = 0;
  67485. this.bufferedRequest = null;
  67486. this.lastBufferedRequest = null;
  67487. // number of pending user-supplied write callbacks
  67488. // this must be 0 before 'finish' can be emitted
  67489. this.pendingcb = 0;
  67490. // emit prefinish if the only thing we're waiting for is _write cbs
  67491. // This is relevant for synchronous Transform streams
  67492. this.prefinished = false;
  67493. // True if the error was already emitted and should not be thrown again
  67494. this.errorEmitted = false;
  67495. // Should close be emitted on destroy. Defaults to true.
  67496. this.emitClose = options.emitClose !== false;
  67497. // Should .destroy() be called after 'finish' (and potentially 'end')
  67498. this.autoDestroy = !!options.autoDestroy;
  67499. // count buffered requests
  67500. this.bufferedRequestCount = 0;
  67501. // allocate the first CorkedRequest, there is always
  67502. // one allocated and free to use, and we maintain at most two
  67503. this.corkedRequestsFree = new CorkedRequest(this);
  67504. }
  67505. WritableState.prototype.getBuffer = function getBuffer() {
  67506. var current = this.bufferedRequest;
  67507. var out = [];
  67508. while (current) {
  67509. out.push(current);
  67510. current = current.next;
  67511. }
  67512. return out;
  67513. };
  67514. (function () {
  67515. try {
  67516. Object.defineProperty(WritableState.prototype, 'buffer', {
  67517. get: internalUtil.deprecate(function writableStateBufferGetter() {
  67518. return this.getBuffer();
  67519. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  67520. });
  67521. } catch (_) {}
  67522. })();
  67523. // Test _writableState for inheritance to account for Duplex streams,
  67524. // whose prototype chain only points to Readable.
  67525. var realHasInstance;
  67526. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  67527. realHasInstance = Function.prototype[Symbol.hasInstance];
  67528. Object.defineProperty(Writable, Symbol.hasInstance, {
  67529. value: function value(object) {
  67530. if (realHasInstance.call(this, object)) return true;
  67531. if (this !== Writable) return false;
  67532. return object && object._writableState instanceof WritableState;
  67533. }
  67534. });
  67535. } else {
  67536. realHasInstance = function realHasInstance(object) {
  67537. return object instanceof this;
  67538. };
  67539. }
  67540. function Writable(options) {
  67541. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js");
  67542. // Writable ctor is applied to Duplexes, too.
  67543. // `realHasInstance` is necessary because using plain `instanceof`
  67544. // would return false, as no `_writableState` property is attached.
  67545. // Trying to use the custom `instanceof` for Writable here will also break the
  67546. // Node.js LazyTransform implementation, which has a non-trivial getter for
  67547. // `_writableState` that would lead to infinite recursion.
  67548. // Checking for a Stream.Duplex instance is faster here instead of inside
  67549. // the WritableState constructor, at least with V8 6.5
  67550. var isDuplex = this instanceof Duplex;
  67551. if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  67552. this._writableState = new WritableState(options, this, isDuplex);
  67553. // legacy.
  67554. this.writable = true;
  67555. if (options) {
  67556. if (typeof options.write === 'function') this._write = options.write;
  67557. if (typeof options.writev === 'function') this._writev = options.writev;
  67558. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  67559. if (typeof options.final === 'function') this._final = options.final;
  67560. }
  67561. Stream.call(this);
  67562. }
  67563. // Otherwise people can pipe Writable streams, which is just wrong.
  67564. Writable.prototype.pipe = function () {
  67565. errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
  67566. };
  67567. function writeAfterEnd(stream, cb) {
  67568. var er = new ERR_STREAM_WRITE_AFTER_END();
  67569. // TODO: defer error events consistently everywhere, not just the cb
  67570. errorOrDestroy(stream, er);
  67571. process.nextTick(cb, er);
  67572. }
  67573. // Checks that a user-supplied chunk is valid, especially for the particular
  67574. // mode the stream is in. Currently this means that `null` is never accepted
  67575. // and undefined/non-string values are only allowed in object mode.
  67576. function validChunk(stream, state, chunk, cb) {
  67577. var er;
  67578. if (chunk === null) {
  67579. er = new ERR_STREAM_NULL_VALUES();
  67580. } else if (typeof chunk !== 'string' && !state.objectMode) {
  67581. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  67582. }
  67583. if (er) {
  67584. errorOrDestroy(stream, er);
  67585. process.nextTick(cb, er);
  67586. return false;
  67587. }
  67588. return true;
  67589. }
  67590. Writable.prototype.write = function (chunk, encoding, cb) {
  67591. var state = this._writableState;
  67592. var ret = false;
  67593. var isBuf = !state.objectMode && _isUint8Array(chunk);
  67594. if (isBuf && !Buffer.isBuffer(chunk)) {
  67595. chunk = _uint8ArrayToBuffer(chunk);
  67596. }
  67597. if (typeof encoding === 'function') {
  67598. cb = encoding;
  67599. encoding = null;
  67600. }
  67601. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  67602. if (typeof cb !== 'function') cb = nop;
  67603. if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  67604. state.pendingcb++;
  67605. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  67606. }
  67607. return ret;
  67608. };
  67609. Writable.prototype.cork = function () {
  67610. this._writableState.corked++;
  67611. };
  67612. Writable.prototype.uncork = function () {
  67613. var state = this._writableState;
  67614. if (state.corked) {
  67615. state.corked--;
  67616. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  67617. }
  67618. };
  67619. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  67620. // node::ParseEncoding() requires lower case.
  67621. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  67622. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  67623. this._writableState.defaultEncoding = encoding;
  67624. return this;
  67625. };
  67626. Object.defineProperty(Writable.prototype, 'writableBuffer', {
  67627. // making it explicit this property is not enumerable
  67628. // because otherwise some prototype manipulation in
  67629. // userland will fail
  67630. enumerable: false,
  67631. get: function get() {
  67632. return this._writableState && this._writableState.getBuffer();
  67633. }
  67634. });
  67635. function decodeChunk(state, chunk, encoding) {
  67636. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  67637. chunk = Buffer.from(chunk, encoding);
  67638. }
  67639. return chunk;
  67640. }
  67641. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  67642. // making it explicit this property is not enumerable
  67643. // because otherwise some prototype manipulation in
  67644. // userland will fail
  67645. enumerable: false,
  67646. get: function get() {
  67647. return this._writableState.highWaterMark;
  67648. }
  67649. });
  67650. // if we're already writing something, then just put this
  67651. // in the queue, and wait our turn. Otherwise, call _write
  67652. // If we return false, then we need a drain event, so set that flag.
  67653. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  67654. if (!isBuf) {
  67655. var newChunk = decodeChunk(state, chunk, encoding);
  67656. if (chunk !== newChunk) {
  67657. isBuf = true;
  67658. encoding = 'buffer';
  67659. chunk = newChunk;
  67660. }
  67661. }
  67662. var len = state.objectMode ? 1 : chunk.length;
  67663. state.length += len;
  67664. var ret = state.length < state.highWaterMark;
  67665. // we must ensure that previous needDrain will not be reset to false.
  67666. if (!ret) state.needDrain = true;
  67667. if (state.writing || state.corked) {
  67668. var last = state.lastBufferedRequest;
  67669. state.lastBufferedRequest = {
  67670. chunk: chunk,
  67671. encoding: encoding,
  67672. isBuf: isBuf,
  67673. callback: cb,
  67674. next: null
  67675. };
  67676. if (last) {
  67677. last.next = state.lastBufferedRequest;
  67678. } else {
  67679. state.bufferedRequest = state.lastBufferedRequest;
  67680. }
  67681. state.bufferedRequestCount += 1;
  67682. } else {
  67683. doWrite(stream, state, false, len, chunk, encoding, cb);
  67684. }
  67685. return ret;
  67686. }
  67687. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  67688. state.writelen = len;
  67689. state.writecb = cb;
  67690. state.writing = true;
  67691. state.sync = true;
  67692. if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  67693. state.sync = false;
  67694. }
  67695. function onwriteError(stream, state, sync, er, cb) {
  67696. --state.pendingcb;
  67697. if (sync) {
  67698. // defer the callback if we are being called synchronously
  67699. // to avoid piling up things on the stack
  67700. process.nextTick(cb, er);
  67701. // this can emit finish, and it will always happen
  67702. // after error
  67703. process.nextTick(finishMaybe, stream, state);
  67704. stream._writableState.errorEmitted = true;
  67705. errorOrDestroy(stream, er);
  67706. } else {
  67707. // the caller expect this to happen before if
  67708. // it is async
  67709. cb(er);
  67710. stream._writableState.errorEmitted = true;
  67711. errorOrDestroy(stream, er);
  67712. // this can emit finish, but finish must
  67713. // always follow error
  67714. finishMaybe(stream, state);
  67715. }
  67716. }
  67717. function onwriteStateUpdate(state) {
  67718. state.writing = false;
  67719. state.writecb = null;
  67720. state.length -= state.writelen;
  67721. state.writelen = 0;
  67722. }
  67723. function onwrite(stream, er) {
  67724. var state = stream._writableState;
  67725. var sync = state.sync;
  67726. var cb = state.writecb;
  67727. if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  67728. onwriteStateUpdate(state);
  67729. if (er) onwriteError(stream, state, sync, er, cb);else {
  67730. // Check if we're actually ready to finish, but don't emit yet
  67731. var finished = needFinish(state) || stream.destroyed;
  67732. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  67733. clearBuffer(stream, state);
  67734. }
  67735. if (sync) {
  67736. process.nextTick(afterWrite, stream, state, finished, cb);
  67737. } else {
  67738. afterWrite(stream, state, finished, cb);
  67739. }
  67740. }
  67741. }
  67742. function afterWrite(stream, state, finished, cb) {
  67743. if (!finished) onwriteDrain(stream, state);
  67744. state.pendingcb--;
  67745. cb();
  67746. finishMaybe(stream, state);
  67747. }
  67748. // Must force callback to be called on nextTick, so that we don't
  67749. // emit 'drain' before the write() consumer gets the 'false' return
  67750. // value, and has a chance to attach a 'drain' listener.
  67751. function onwriteDrain(stream, state) {
  67752. if (state.length === 0 && state.needDrain) {
  67753. state.needDrain = false;
  67754. stream.emit('drain');
  67755. }
  67756. }
  67757. // if there's something in the buffer waiting, then process it
  67758. function clearBuffer(stream, state) {
  67759. state.bufferProcessing = true;
  67760. var entry = state.bufferedRequest;
  67761. if (stream._writev && entry && entry.next) {
  67762. // Fast case, write everything using _writev()
  67763. var l = state.bufferedRequestCount;
  67764. var buffer = new Array(l);
  67765. var holder = state.corkedRequestsFree;
  67766. holder.entry = entry;
  67767. var count = 0;
  67768. var allBuffers = true;
  67769. while (entry) {
  67770. buffer[count] = entry;
  67771. if (!entry.isBuf) allBuffers = false;
  67772. entry = entry.next;
  67773. count += 1;
  67774. }
  67775. buffer.allBuffers = allBuffers;
  67776. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  67777. // doWrite is almost always async, defer these to save a bit of time
  67778. // as the hot path ends with doWrite
  67779. state.pendingcb++;
  67780. state.lastBufferedRequest = null;
  67781. if (holder.next) {
  67782. state.corkedRequestsFree = holder.next;
  67783. holder.next = null;
  67784. } else {
  67785. state.corkedRequestsFree = new CorkedRequest(state);
  67786. }
  67787. state.bufferedRequestCount = 0;
  67788. } else {
  67789. // Slow case, write chunks one-by-one
  67790. while (entry) {
  67791. var chunk = entry.chunk;
  67792. var encoding = entry.encoding;
  67793. var cb = entry.callback;
  67794. var len = state.objectMode ? 1 : chunk.length;
  67795. doWrite(stream, state, false, len, chunk, encoding, cb);
  67796. entry = entry.next;
  67797. state.bufferedRequestCount--;
  67798. // if we didn't call the onwrite immediately, then
  67799. // it means that we need to wait until it does.
  67800. // also, that means that the chunk and cb are currently
  67801. // being processed, so move the buffer counter past them.
  67802. if (state.writing) {
  67803. break;
  67804. }
  67805. }
  67806. if (entry === null) state.lastBufferedRequest = null;
  67807. }
  67808. state.bufferedRequest = entry;
  67809. state.bufferProcessing = false;
  67810. }
  67811. Writable.prototype._write = function (chunk, encoding, cb) {
  67812. cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
  67813. };
  67814. Writable.prototype._writev = null;
  67815. Writable.prototype.end = function (chunk, encoding, cb) {
  67816. var state = this._writableState;
  67817. if (typeof chunk === 'function') {
  67818. cb = chunk;
  67819. chunk = null;
  67820. encoding = null;
  67821. } else if (typeof encoding === 'function') {
  67822. cb = encoding;
  67823. encoding = null;
  67824. }
  67825. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  67826. // .end() fully uncorks
  67827. if (state.corked) {
  67828. state.corked = 1;
  67829. this.uncork();
  67830. }
  67831. // ignore unnecessary end() calls.
  67832. if (!state.ending) endWritable(this, state, cb);
  67833. return this;
  67834. };
  67835. Object.defineProperty(Writable.prototype, 'writableLength', {
  67836. // making it explicit this property is not enumerable
  67837. // because otherwise some prototype manipulation in
  67838. // userland will fail
  67839. enumerable: false,
  67840. get: function get() {
  67841. return this._writableState.length;
  67842. }
  67843. });
  67844. function needFinish(state) {
  67845. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  67846. }
  67847. function callFinal(stream, state) {
  67848. stream._final(function (err) {
  67849. state.pendingcb--;
  67850. if (err) {
  67851. errorOrDestroy(stream, err);
  67852. }
  67853. state.prefinished = true;
  67854. stream.emit('prefinish');
  67855. finishMaybe(stream, state);
  67856. });
  67857. }
  67858. function prefinish(stream, state) {
  67859. if (!state.prefinished && !state.finalCalled) {
  67860. if (typeof stream._final === 'function' && !state.destroyed) {
  67861. state.pendingcb++;
  67862. state.finalCalled = true;
  67863. process.nextTick(callFinal, stream, state);
  67864. } else {
  67865. state.prefinished = true;
  67866. stream.emit('prefinish');
  67867. }
  67868. }
  67869. }
  67870. function finishMaybe(stream, state) {
  67871. var need = needFinish(state);
  67872. if (need) {
  67873. prefinish(stream, state);
  67874. if (state.pendingcb === 0) {
  67875. state.finished = true;
  67876. stream.emit('finish');
  67877. if (state.autoDestroy) {
  67878. // In case of duplex streams we need a way to detect
  67879. // if the readable side is ready for autoDestroy as well
  67880. var rState = stream._readableState;
  67881. if (!rState || rState.autoDestroy && rState.endEmitted) {
  67882. stream.destroy();
  67883. }
  67884. }
  67885. }
  67886. }
  67887. return need;
  67888. }
  67889. function endWritable(stream, state, cb) {
  67890. state.ending = true;
  67891. finishMaybe(stream, state);
  67892. if (cb) {
  67893. if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
  67894. }
  67895. state.ended = true;
  67896. stream.writable = false;
  67897. }
  67898. function onCorkedFinish(corkReq, state, err) {
  67899. var entry = corkReq.entry;
  67900. corkReq.entry = null;
  67901. while (entry) {
  67902. var cb = entry.callback;
  67903. state.pendingcb--;
  67904. cb(err);
  67905. entry = entry.next;
  67906. }
  67907. // reuse the free corkReq.
  67908. state.corkedRequestsFree.next = corkReq;
  67909. }
  67910. Object.defineProperty(Writable.prototype, 'destroyed', {
  67911. // making it explicit this property is not enumerable
  67912. // because otherwise some prototype manipulation in
  67913. // userland will fail
  67914. enumerable: false,
  67915. get: function get() {
  67916. if (this._writableState === undefined) {
  67917. return false;
  67918. }
  67919. return this._writableState.destroyed;
  67920. },
  67921. set: function set(value) {
  67922. // we ignore the value if the stream
  67923. // has not been initialized yet
  67924. if (!this._writableState) {
  67925. return;
  67926. }
  67927. // backward compatibility, the user is explicitly
  67928. // managing destroyed
  67929. this._writableState.destroyed = value;
  67930. }
  67931. });
  67932. Writable.prototype.destroy = destroyImpl.destroy;
  67933. Writable.prototype._undestroy = destroyImpl.undestroy;
  67934. Writable.prototype._destroy = function (err, cb) {
  67935. cb(err);
  67936. };
  67937. /***/ }),
  67938. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/async_iterator.js":
  67939. /*!***********************************************************************************************************************!*\
  67940. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/async_iterator.js ***!
  67941. \***********************************************************************************************************************/
  67942. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  67943. "use strict";
  67944. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  67945. var _Object$setPrototypeO;
  67946. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  67947. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
  67948. function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  67949. var finished = __webpack_require__(/*! ./end-of-stream */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  67950. var kLastResolve = Symbol('lastResolve');
  67951. var kLastReject = Symbol('lastReject');
  67952. var kError = Symbol('error');
  67953. var kEnded = Symbol('ended');
  67954. var kLastPromise = Symbol('lastPromise');
  67955. var kHandlePromise = Symbol('handlePromise');
  67956. var kStream = Symbol('stream');
  67957. function createIterResult(value, done) {
  67958. return {
  67959. value: value,
  67960. done: done
  67961. };
  67962. }
  67963. function readAndResolve(iter) {
  67964. var resolve = iter[kLastResolve];
  67965. if (resolve !== null) {
  67966. var data = iter[kStream].read();
  67967. // we defer if data is null
  67968. // we can be expecting either 'end' or
  67969. // 'error'
  67970. if (data !== null) {
  67971. iter[kLastPromise] = null;
  67972. iter[kLastResolve] = null;
  67973. iter[kLastReject] = null;
  67974. resolve(createIterResult(data, false));
  67975. }
  67976. }
  67977. }
  67978. function onReadable(iter) {
  67979. // we wait for the next tick, because it might
  67980. // emit an error with process.nextTick
  67981. process.nextTick(readAndResolve, iter);
  67982. }
  67983. function wrapForNext(lastPromise, iter) {
  67984. return function (resolve, reject) {
  67985. lastPromise.then(function () {
  67986. if (iter[kEnded]) {
  67987. resolve(createIterResult(undefined, true));
  67988. return;
  67989. }
  67990. iter[kHandlePromise](resolve, reject);
  67991. }, reject);
  67992. };
  67993. }
  67994. var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
  67995. var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
  67996. get stream() {
  67997. return this[kStream];
  67998. },
  67999. next: function next() {
  68000. var _this = this;
  68001. // if we have detected an error in the meanwhile
  68002. // reject straight away
  68003. var error = this[kError];
  68004. if (error !== null) {
  68005. return Promise.reject(error);
  68006. }
  68007. if (this[kEnded]) {
  68008. return Promise.resolve(createIterResult(undefined, true));
  68009. }
  68010. if (this[kStream].destroyed) {
  68011. // We need to defer via nextTick because if .destroy(err) is
  68012. // called, the error will be emitted via nextTick, and
  68013. // we cannot guarantee that there is no error lingering around
  68014. // waiting to be emitted.
  68015. return new Promise(function (resolve, reject) {
  68016. process.nextTick(function () {
  68017. if (_this[kError]) {
  68018. reject(_this[kError]);
  68019. } else {
  68020. resolve(createIterResult(undefined, true));
  68021. }
  68022. });
  68023. });
  68024. }
  68025. // if we have multiple next() calls
  68026. // we will wait for the previous Promise to finish
  68027. // this logic is optimized to support for await loops,
  68028. // where next() is only called once at a time
  68029. var lastPromise = this[kLastPromise];
  68030. var promise;
  68031. if (lastPromise) {
  68032. promise = new Promise(wrapForNext(lastPromise, this));
  68033. } else {
  68034. // fast path needed to support multiple this.push()
  68035. // without triggering the next() queue
  68036. var data = this[kStream].read();
  68037. if (data !== null) {
  68038. return Promise.resolve(createIterResult(data, false));
  68039. }
  68040. promise = new Promise(this[kHandlePromise]);
  68041. }
  68042. this[kLastPromise] = promise;
  68043. return promise;
  68044. }
  68045. }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
  68046. return this;
  68047. }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
  68048. var _this2 = this;
  68049. // destroy(err, cb) is a private API
  68050. // we can guarantee we have that here, because we control the
  68051. // Readable class this is attached to
  68052. return new Promise(function (resolve, reject) {
  68053. _this2[kStream].destroy(null, function (err) {
  68054. if (err) {
  68055. reject(err);
  68056. return;
  68057. }
  68058. resolve(createIterResult(undefined, true));
  68059. });
  68060. });
  68061. }), _Object$setPrototypeO), AsyncIteratorPrototype);
  68062. var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
  68063. var _Object$create;
  68064. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
  68065. value: stream,
  68066. writable: true
  68067. }), _defineProperty(_Object$create, kLastResolve, {
  68068. value: null,
  68069. writable: true
  68070. }), _defineProperty(_Object$create, kLastReject, {
  68071. value: null,
  68072. writable: true
  68073. }), _defineProperty(_Object$create, kError, {
  68074. value: null,
  68075. writable: true
  68076. }), _defineProperty(_Object$create, kEnded, {
  68077. value: stream._readableState.endEmitted,
  68078. writable: true
  68079. }), _defineProperty(_Object$create, kHandlePromise, {
  68080. value: function value(resolve, reject) {
  68081. var data = iterator[kStream].read();
  68082. if (data) {
  68083. iterator[kLastPromise] = null;
  68084. iterator[kLastResolve] = null;
  68085. iterator[kLastReject] = null;
  68086. resolve(createIterResult(data, false));
  68087. } else {
  68088. iterator[kLastResolve] = resolve;
  68089. iterator[kLastReject] = reject;
  68090. }
  68091. },
  68092. writable: true
  68093. }), _Object$create));
  68094. iterator[kLastPromise] = null;
  68095. finished(stream, function (err) {
  68096. if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
  68097. var reject = iterator[kLastReject];
  68098. // reject if we are waiting for data in the Promise
  68099. // returned by next() and store the error
  68100. if (reject !== null) {
  68101. iterator[kLastPromise] = null;
  68102. iterator[kLastResolve] = null;
  68103. iterator[kLastReject] = null;
  68104. reject(err);
  68105. }
  68106. iterator[kError] = err;
  68107. return;
  68108. }
  68109. var resolve = iterator[kLastResolve];
  68110. if (resolve !== null) {
  68111. iterator[kLastPromise] = null;
  68112. iterator[kLastResolve] = null;
  68113. iterator[kLastReject] = null;
  68114. resolve(createIterResult(undefined, true));
  68115. }
  68116. iterator[kEnded] = true;
  68117. });
  68118. stream.on('readable', onReadable.bind(null, iterator));
  68119. return iterator;
  68120. };
  68121. module.exports = createReadableStreamAsyncIterator;
  68122. /***/ }),
  68123. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/buffer_list.js":
  68124. /*!********************************************************************************************************************!*\
  68125. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/buffer_list.js ***!
  68126. \********************************************************************************************************************/
  68127. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68128. "use strict";
  68129. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  68130. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  68131. function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  68132. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  68133. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
  68134. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
  68135. function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
  68136. function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
  68137. var _require = __webpack_require__(/*! buffer */ "./node_modules/node-polyfill-webpack-plugin/node_modules/buffer/index.js"),
  68138. Buffer = _require.Buffer;
  68139. var _require2 = __webpack_require__(/*! util */ "?adc3"),
  68140. inspect = _require2.inspect;
  68141. var custom = inspect && inspect.custom || 'inspect';
  68142. function copyBuffer(src, target, offset) {
  68143. Buffer.prototype.copy.call(src, target, offset);
  68144. }
  68145. module.exports = /*#__PURE__*/function () {
  68146. function BufferList() {
  68147. _classCallCheck(this, BufferList);
  68148. this.head = null;
  68149. this.tail = null;
  68150. this.length = 0;
  68151. }
  68152. _createClass(BufferList, [{
  68153. key: "push",
  68154. value: function push(v) {
  68155. var entry = {
  68156. data: v,
  68157. next: null
  68158. };
  68159. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  68160. this.tail = entry;
  68161. ++this.length;
  68162. }
  68163. }, {
  68164. key: "unshift",
  68165. value: function unshift(v) {
  68166. var entry = {
  68167. data: v,
  68168. next: this.head
  68169. };
  68170. if (this.length === 0) this.tail = entry;
  68171. this.head = entry;
  68172. ++this.length;
  68173. }
  68174. }, {
  68175. key: "shift",
  68176. value: function shift() {
  68177. if (this.length === 0) return;
  68178. var ret = this.head.data;
  68179. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  68180. --this.length;
  68181. return ret;
  68182. }
  68183. }, {
  68184. key: "clear",
  68185. value: function clear() {
  68186. this.head = this.tail = null;
  68187. this.length = 0;
  68188. }
  68189. }, {
  68190. key: "join",
  68191. value: function join(s) {
  68192. if (this.length === 0) return '';
  68193. var p = this.head;
  68194. var ret = '' + p.data;
  68195. while (p = p.next) ret += s + p.data;
  68196. return ret;
  68197. }
  68198. }, {
  68199. key: "concat",
  68200. value: function concat(n) {
  68201. if (this.length === 0) return Buffer.alloc(0);
  68202. var ret = Buffer.allocUnsafe(n >>> 0);
  68203. var p = this.head;
  68204. var i = 0;
  68205. while (p) {
  68206. copyBuffer(p.data, ret, i);
  68207. i += p.data.length;
  68208. p = p.next;
  68209. }
  68210. return ret;
  68211. }
  68212. // Consumes a specified amount of bytes or characters from the buffered data.
  68213. }, {
  68214. key: "consume",
  68215. value: function consume(n, hasStrings) {
  68216. var ret;
  68217. if (n < this.head.data.length) {
  68218. // `slice` is the same for buffers and strings.
  68219. ret = this.head.data.slice(0, n);
  68220. this.head.data = this.head.data.slice(n);
  68221. } else if (n === this.head.data.length) {
  68222. // First chunk is a perfect match.
  68223. ret = this.shift();
  68224. } else {
  68225. // Result spans more than one buffer.
  68226. ret = hasStrings ? this._getString(n) : this._getBuffer(n);
  68227. }
  68228. return ret;
  68229. }
  68230. }, {
  68231. key: "first",
  68232. value: function first() {
  68233. return this.head.data;
  68234. }
  68235. // Consumes a specified amount of characters from the buffered data.
  68236. }, {
  68237. key: "_getString",
  68238. value: function _getString(n) {
  68239. var p = this.head;
  68240. var c = 1;
  68241. var ret = p.data;
  68242. n -= ret.length;
  68243. while (p = p.next) {
  68244. var str = p.data;
  68245. var nb = n > str.length ? str.length : n;
  68246. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  68247. n -= nb;
  68248. if (n === 0) {
  68249. if (nb === str.length) {
  68250. ++c;
  68251. if (p.next) this.head = p.next;else this.head = this.tail = null;
  68252. } else {
  68253. this.head = p;
  68254. p.data = str.slice(nb);
  68255. }
  68256. break;
  68257. }
  68258. ++c;
  68259. }
  68260. this.length -= c;
  68261. return ret;
  68262. }
  68263. // Consumes a specified amount of bytes from the buffered data.
  68264. }, {
  68265. key: "_getBuffer",
  68266. value: function _getBuffer(n) {
  68267. var ret = Buffer.allocUnsafe(n);
  68268. var p = this.head;
  68269. var c = 1;
  68270. p.data.copy(ret);
  68271. n -= p.data.length;
  68272. while (p = p.next) {
  68273. var buf = p.data;
  68274. var nb = n > buf.length ? buf.length : n;
  68275. buf.copy(ret, ret.length - n, 0, nb);
  68276. n -= nb;
  68277. if (n === 0) {
  68278. if (nb === buf.length) {
  68279. ++c;
  68280. if (p.next) this.head = p.next;else this.head = this.tail = null;
  68281. } else {
  68282. this.head = p;
  68283. p.data = buf.slice(nb);
  68284. }
  68285. break;
  68286. }
  68287. ++c;
  68288. }
  68289. this.length -= c;
  68290. return ret;
  68291. }
  68292. // Make sure the linked list only shows the minimal necessary information.
  68293. }, {
  68294. key: custom,
  68295. value: function value(_, options) {
  68296. return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
  68297. // Only inspect one level.
  68298. depth: 0,
  68299. // It should not recurse.
  68300. customInspect: false
  68301. }));
  68302. }
  68303. }]);
  68304. return BufferList;
  68305. }();
  68306. /***/ }),
  68307. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/destroy.js":
  68308. /*!****************************************************************************************************************!*\
  68309. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/destroy.js ***!
  68310. \****************************************************************************************************************/
  68311. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68312. "use strict";
  68313. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  68314. // undocumented cb() API, needed for core, not for public API
  68315. function destroy(err, cb) {
  68316. var _this = this;
  68317. var readableDestroyed = this._readableState && this._readableState.destroyed;
  68318. var writableDestroyed = this._writableState && this._writableState.destroyed;
  68319. if (readableDestroyed || writableDestroyed) {
  68320. if (cb) {
  68321. cb(err);
  68322. } else if (err) {
  68323. if (!this._writableState) {
  68324. process.nextTick(emitErrorNT, this, err);
  68325. } else if (!this._writableState.errorEmitted) {
  68326. this._writableState.errorEmitted = true;
  68327. process.nextTick(emitErrorNT, this, err);
  68328. }
  68329. }
  68330. return this;
  68331. }
  68332. // we set destroyed to true before firing error callbacks in order
  68333. // to make it re-entrance safe in case destroy() is called within callbacks
  68334. if (this._readableState) {
  68335. this._readableState.destroyed = true;
  68336. }
  68337. // if this is a duplex stream mark the writable part as destroyed as well
  68338. if (this._writableState) {
  68339. this._writableState.destroyed = true;
  68340. }
  68341. this._destroy(err || null, function (err) {
  68342. if (!cb && err) {
  68343. if (!_this._writableState) {
  68344. process.nextTick(emitErrorAndCloseNT, _this, err);
  68345. } else if (!_this._writableState.errorEmitted) {
  68346. _this._writableState.errorEmitted = true;
  68347. process.nextTick(emitErrorAndCloseNT, _this, err);
  68348. } else {
  68349. process.nextTick(emitCloseNT, _this);
  68350. }
  68351. } else if (cb) {
  68352. process.nextTick(emitCloseNT, _this);
  68353. cb(err);
  68354. } else {
  68355. process.nextTick(emitCloseNT, _this);
  68356. }
  68357. });
  68358. return this;
  68359. }
  68360. function emitErrorAndCloseNT(self, err) {
  68361. emitErrorNT(self, err);
  68362. emitCloseNT(self);
  68363. }
  68364. function emitCloseNT(self) {
  68365. if (self._writableState && !self._writableState.emitClose) return;
  68366. if (self._readableState && !self._readableState.emitClose) return;
  68367. self.emit('close');
  68368. }
  68369. function undestroy() {
  68370. if (this._readableState) {
  68371. this._readableState.destroyed = false;
  68372. this._readableState.reading = false;
  68373. this._readableState.ended = false;
  68374. this._readableState.endEmitted = false;
  68375. }
  68376. if (this._writableState) {
  68377. this._writableState.destroyed = false;
  68378. this._writableState.ended = false;
  68379. this._writableState.ending = false;
  68380. this._writableState.finalCalled = false;
  68381. this._writableState.prefinished = false;
  68382. this._writableState.finished = false;
  68383. this._writableState.errorEmitted = false;
  68384. }
  68385. }
  68386. function emitErrorNT(self, err) {
  68387. self.emit('error', err);
  68388. }
  68389. function errorOrDestroy(stream, err) {
  68390. // We have tests that rely on errors being emitted
  68391. // in the same tick, so changing this is semver major.
  68392. // For now when you opt-in to autoDestroy we allow
  68393. // the error to be emitted nextTick. In a future
  68394. // semver major update we should change the default to this.
  68395. var rState = stream._readableState;
  68396. var wState = stream._writableState;
  68397. if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
  68398. }
  68399. module.exports = {
  68400. destroy: destroy,
  68401. undestroy: undestroy,
  68402. errorOrDestroy: errorOrDestroy
  68403. };
  68404. /***/ }),
  68405. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/end-of-stream.js":
  68406. /*!**********************************************************************************************************************!*\
  68407. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/end-of-stream.js ***!
  68408. \**********************************************************************************************************************/
  68409. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68410. "use strict";
  68411. // Ported from https://github.com/mafintosh/end-of-stream with
  68412. // permission from the author, Mathias Buus (@mafintosh).
  68413. var ERR_STREAM_PREMATURE_CLOSE = (__webpack_require__(/*! ../../../errors */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js").codes.ERR_STREAM_PREMATURE_CLOSE);
  68414. function once(callback) {
  68415. var called = false;
  68416. return function () {
  68417. if (called) return;
  68418. called = true;
  68419. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  68420. args[_key] = arguments[_key];
  68421. }
  68422. callback.apply(this, args);
  68423. };
  68424. }
  68425. function noop() {}
  68426. function isRequest(stream) {
  68427. return stream.setHeader && typeof stream.abort === 'function';
  68428. }
  68429. function eos(stream, opts, callback) {
  68430. if (typeof opts === 'function') return eos(stream, null, opts);
  68431. if (!opts) opts = {};
  68432. callback = once(callback || noop);
  68433. var readable = opts.readable || opts.readable !== false && stream.readable;
  68434. var writable = opts.writable || opts.writable !== false && stream.writable;
  68435. var onlegacyfinish = function onlegacyfinish() {
  68436. if (!stream.writable) onfinish();
  68437. };
  68438. var writableEnded = stream._writableState && stream._writableState.finished;
  68439. var onfinish = function onfinish() {
  68440. writable = false;
  68441. writableEnded = true;
  68442. if (!readable) callback.call(stream);
  68443. };
  68444. var readableEnded = stream._readableState && stream._readableState.endEmitted;
  68445. var onend = function onend() {
  68446. readable = false;
  68447. readableEnded = true;
  68448. if (!writable) callback.call(stream);
  68449. };
  68450. var onerror = function onerror(err) {
  68451. callback.call(stream, err);
  68452. };
  68453. var onclose = function onclose() {
  68454. var err;
  68455. if (readable && !readableEnded) {
  68456. if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  68457. return callback.call(stream, err);
  68458. }
  68459. if (writable && !writableEnded) {
  68460. if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  68461. return callback.call(stream, err);
  68462. }
  68463. };
  68464. var onrequest = function onrequest() {
  68465. stream.req.on('finish', onfinish);
  68466. };
  68467. if (isRequest(stream)) {
  68468. stream.on('complete', onfinish);
  68469. stream.on('abort', onclose);
  68470. if (stream.req) onrequest();else stream.on('request', onrequest);
  68471. } else if (writable && !stream._writableState) {
  68472. // legacy streams
  68473. stream.on('end', onlegacyfinish);
  68474. stream.on('close', onlegacyfinish);
  68475. }
  68476. stream.on('end', onend);
  68477. stream.on('finish', onfinish);
  68478. if (opts.error !== false) stream.on('error', onerror);
  68479. stream.on('close', onclose);
  68480. return function () {
  68481. stream.removeListener('complete', onfinish);
  68482. stream.removeListener('abort', onclose);
  68483. stream.removeListener('request', onrequest);
  68484. if (stream.req) stream.req.removeListener('finish', onfinish);
  68485. stream.removeListener('end', onlegacyfinish);
  68486. stream.removeListener('close', onlegacyfinish);
  68487. stream.removeListener('finish', onfinish);
  68488. stream.removeListener('end', onend);
  68489. stream.removeListener('error', onerror);
  68490. stream.removeListener('close', onclose);
  68491. };
  68492. }
  68493. module.exports = eos;
  68494. /***/ }),
  68495. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/from-browser.js":
  68496. /*!*********************************************************************************************************************!*\
  68497. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/from-browser.js ***!
  68498. \*********************************************************************************************************************/
  68499. /***/ ((module) => {
  68500. module.exports = function () {
  68501. throw new Error('Readable.from is not available in the browser')
  68502. };
  68503. /***/ }),
  68504. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/pipeline.js":
  68505. /*!*****************************************************************************************************************!*\
  68506. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/pipeline.js ***!
  68507. \*****************************************************************************************************************/
  68508. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68509. "use strict";
  68510. // Ported from https://github.com/mafintosh/pump with
  68511. // permission from the author, Mathias Buus (@mafintosh).
  68512. var eos;
  68513. function once(callback) {
  68514. var called = false;
  68515. return function () {
  68516. if (called) return;
  68517. called = true;
  68518. callback.apply(void 0, arguments);
  68519. };
  68520. }
  68521. var _require$codes = (__webpack_require__(/*! ../../../errors */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js").codes),
  68522. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
  68523. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
  68524. function noop(err) {
  68525. // Rethrow the error if it exists to avoid swallowing it
  68526. if (err) throw err;
  68527. }
  68528. function isRequest(stream) {
  68529. return stream.setHeader && typeof stream.abort === 'function';
  68530. }
  68531. function destroyer(stream, reading, writing, callback) {
  68532. callback = once(callback);
  68533. var closed = false;
  68534. stream.on('close', function () {
  68535. closed = true;
  68536. });
  68537. if (eos === undefined) eos = __webpack_require__(/*! ./end-of-stream */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  68538. eos(stream, {
  68539. readable: reading,
  68540. writable: writing
  68541. }, function (err) {
  68542. if (err) return callback(err);
  68543. closed = true;
  68544. callback();
  68545. });
  68546. var destroyed = false;
  68547. return function (err) {
  68548. if (closed) return;
  68549. if (destroyed) return;
  68550. destroyed = true;
  68551. // request.destroy just do .end - .abort is what we want
  68552. if (isRequest(stream)) return stream.abort();
  68553. if (typeof stream.destroy === 'function') return stream.destroy();
  68554. callback(err || new ERR_STREAM_DESTROYED('pipe'));
  68555. };
  68556. }
  68557. function call(fn) {
  68558. fn();
  68559. }
  68560. function pipe(from, to) {
  68561. return from.pipe(to);
  68562. }
  68563. function popCallback(streams) {
  68564. if (!streams.length) return noop;
  68565. if (typeof streams[streams.length - 1] !== 'function') return noop;
  68566. return streams.pop();
  68567. }
  68568. function pipeline() {
  68569. for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
  68570. streams[_key] = arguments[_key];
  68571. }
  68572. var callback = popCallback(streams);
  68573. if (Array.isArray(streams[0])) streams = streams[0];
  68574. if (streams.length < 2) {
  68575. throw new ERR_MISSING_ARGS('streams');
  68576. }
  68577. var error;
  68578. var destroys = streams.map(function (stream, i) {
  68579. var reading = i < streams.length - 1;
  68580. var writing = i > 0;
  68581. return destroyer(stream, reading, writing, function (err) {
  68582. if (!error) error = err;
  68583. if (err) destroys.forEach(call);
  68584. if (reading) return;
  68585. destroys.forEach(call);
  68586. callback(error);
  68587. });
  68588. });
  68589. return streams.reduce(pipe);
  68590. }
  68591. module.exports = pipeline;
  68592. /***/ }),
  68593. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/state.js":
  68594. /*!**************************************************************************************************************!*\
  68595. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/state.js ***!
  68596. \**************************************************************************************************************/
  68597. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68598. "use strict";
  68599. var ERR_INVALID_OPT_VALUE = (__webpack_require__(/*! ../../../errors */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/errors-browser.js").codes.ERR_INVALID_OPT_VALUE);
  68600. function highWaterMarkFrom(options, isDuplex, duplexKey) {
  68601. return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
  68602. }
  68603. function getHighWaterMark(state, options, duplexKey, isDuplex) {
  68604. var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
  68605. if (hwm != null) {
  68606. if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
  68607. var name = isDuplex ? duplexKey : 'highWaterMark';
  68608. throw new ERR_INVALID_OPT_VALUE(name, hwm);
  68609. }
  68610. return Math.floor(hwm);
  68611. }
  68612. // Default value
  68613. return state.objectMode ? 16 : 16 * 1024;
  68614. }
  68615. module.exports = {
  68616. getHighWaterMark: getHighWaterMark
  68617. };
  68618. /***/ }),
  68619. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/stream-browser.js":
  68620. /*!***********************************************************************************************************************!*\
  68621. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/stream-browser.js ***!
  68622. \***********************************************************************************************************************/
  68623. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68624. module.exports = __webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter;
  68625. /***/ }),
  68626. /***/ "./node_modules/node-polyfill-webpack-plugin/node_modules/stream-browserify/index.js":
  68627. /*!*******************************************************************************************!*\
  68628. !*** ./node_modules/node-polyfill-webpack-plugin/node_modules/stream-browserify/index.js ***!
  68629. \*******************************************************************************************/
  68630. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68631. // Copyright Joyent, Inc. and other Node contributors.
  68632. //
  68633. // Permission is hereby granted, free of charge, to any person obtaining a
  68634. // copy of this software and associated documentation files (the
  68635. // "Software"), to deal in the Software without restriction, including
  68636. // without limitation the rights to use, copy, modify, merge, publish,
  68637. // distribute, sublicense, and/or sell copies of the Software, and to permit
  68638. // persons to whom the Software is furnished to do so, subject to the
  68639. // following conditions:
  68640. //
  68641. // The above copyright notice and this permission notice shall be included
  68642. // in all copies or substantial portions of the Software.
  68643. //
  68644. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  68645. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  68646. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  68647. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  68648. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  68649. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  68650. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  68651. module.exports = Stream;
  68652. var EE = (__webpack_require__(/*! events */ "./node_modules/events/events.js").EventEmitter);
  68653. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
  68654. inherits(Stream, EE);
  68655. Stream.Readable = __webpack_require__(/*! readable-stream/lib/_stream_readable.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_readable.js");
  68656. Stream.Writable = __webpack_require__(/*! readable-stream/lib/_stream_writable.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_writable.js");
  68657. Stream.Duplex = __webpack_require__(/*! readable-stream/lib/_stream_duplex.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_duplex.js");
  68658. Stream.Transform = __webpack_require__(/*! readable-stream/lib/_stream_transform.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_transform.js");
  68659. Stream.PassThrough = __webpack_require__(/*! readable-stream/lib/_stream_passthrough.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/_stream_passthrough.js");
  68660. Stream.finished = __webpack_require__(/*! readable-stream/lib/internal/streams/end-of-stream.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/end-of-stream.js")
  68661. Stream.pipeline = __webpack_require__(/*! readable-stream/lib/internal/streams/pipeline.js */ "./node_modules/node-polyfill-webpack-plugin/node_modules/readable-stream/lib/internal/streams/pipeline.js")
  68662. // Backwards-compat with node 0.4.x
  68663. Stream.Stream = Stream;
  68664. // old-style streams. Note that the pipe method (the only relevant
  68665. // part of this class) is overridden in the Readable class.
  68666. function Stream() {
  68667. EE.call(this);
  68668. }
  68669. Stream.prototype.pipe = function(dest, options) {
  68670. var source = this;
  68671. function ondata(chunk) {
  68672. if (dest.writable) {
  68673. if (false === dest.write(chunk) && source.pause) {
  68674. source.pause();
  68675. }
  68676. }
  68677. }
  68678. source.on('data', ondata);
  68679. function ondrain() {
  68680. if (source.readable && source.resume) {
  68681. source.resume();
  68682. }
  68683. }
  68684. dest.on('drain', ondrain);
  68685. // If the 'end' option is not supplied, dest.end() will be called when
  68686. // source gets the 'end' or 'close' events. Only dest.end() once.
  68687. if (!dest._isStdio && (!options || options.end !== false)) {
  68688. source.on('end', onend);
  68689. source.on('close', onclose);
  68690. }
  68691. var didOnEnd = false;
  68692. function onend() {
  68693. if (didOnEnd) return;
  68694. didOnEnd = true;
  68695. dest.end();
  68696. }
  68697. function onclose() {
  68698. if (didOnEnd) return;
  68699. didOnEnd = true;
  68700. if (typeof dest.destroy === 'function') dest.destroy();
  68701. }
  68702. // don't leave dangling pipes when there are errors.
  68703. function onerror(er) {
  68704. cleanup();
  68705. if (EE.listenerCount(this, 'error') === 0) {
  68706. throw er; // Unhandled stream error in pipe.
  68707. }
  68708. }
  68709. source.on('error', onerror);
  68710. dest.on('error', onerror);
  68711. // remove all the event listeners that were added.
  68712. function cleanup() {
  68713. source.removeListener('data', ondata);
  68714. dest.removeListener('drain', ondrain);
  68715. source.removeListener('end', onend);
  68716. source.removeListener('close', onclose);
  68717. source.removeListener('error', onerror);
  68718. dest.removeListener('error', onerror);
  68719. source.removeListener('end', cleanup);
  68720. source.removeListener('close', cleanup);
  68721. dest.removeListener('close', cleanup);
  68722. }
  68723. source.on('end', cleanup);
  68724. source.on('close', cleanup);
  68725. dest.on('close', cleanup);
  68726. dest.emit('pipe', source);
  68727. // Allow for unix-like usage: A.pipe(B).pipe(C)
  68728. return dest;
  68729. };
  68730. /***/ }),
  68731. /***/ "./node_modules/object-assign/index.js":
  68732. /*!*********************************************!*\
  68733. !*** ./node_modules/object-assign/index.js ***!
  68734. \*********************************************/
  68735. /***/ ((module) => {
  68736. "use strict";
  68737. /*
  68738. object-assign
  68739. (c) Sindre Sorhus
  68740. @license MIT
  68741. */
  68742. /* eslint-disable no-unused-vars */
  68743. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  68744. var hasOwnProperty = Object.prototype.hasOwnProperty;
  68745. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  68746. function toObject(val) {
  68747. if (val === null || val === undefined) {
  68748. throw new TypeError('Object.assign cannot be called with null or undefined');
  68749. }
  68750. return Object(val);
  68751. }
  68752. function shouldUseNative() {
  68753. try {
  68754. if (!Object.assign) {
  68755. return false;
  68756. }
  68757. // Detect buggy property enumeration order in older V8 versions.
  68758. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  68759. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  68760. test1[5] = 'de';
  68761. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  68762. return false;
  68763. }
  68764. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  68765. var test2 = {};
  68766. for (var i = 0; i < 10; i++) {
  68767. test2['_' + String.fromCharCode(i)] = i;
  68768. }
  68769. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  68770. return test2[n];
  68771. });
  68772. if (order2.join('') !== '0123456789') {
  68773. return false;
  68774. }
  68775. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  68776. var test3 = {};
  68777. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  68778. test3[letter] = letter;
  68779. });
  68780. if (Object.keys(Object.assign({}, test3)).join('') !==
  68781. 'abcdefghijklmnopqrst') {
  68782. return false;
  68783. }
  68784. return true;
  68785. } catch (err) {
  68786. // We don't expect any of the above to throw, but better to be safe.
  68787. return false;
  68788. }
  68789. }
  68790. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  68791. var from;
  68792. var to = toObject(target);
  68793. var symbols;
  68794. for (var s = 1; s < arguments.length; s++) {
  68795. from = Object(arguments[s]);
  68796. for (var key in from) {
  68797. if (hasOwnProperty.call(from, key)) {
  68798. to[key] = from[key];
  68799. }
  68800. }
  68801. if (getOwnPropertySymbols) {
  68802. symbols = getOwnPropertySymbols(from);
  68803. for (var i = 0; i < symbols.length; i++) {
  68804. if (propIsEnumerable.call(from, symbols[i])) {
  68805. to[symbols[i]] = from[symbols[i]];
  68806. }
  68807. }
  68808. }
  68809. }
  68810. return to;
  68811. };
  68812. /***/ }),
  68813. /***/ "./node_modules/param-case/dist.es2015/index.js":
  68814. /*!******************************************************!*\
  68815. !*** ./node_modules/param-case/dist.es2015/index.js ***!
  68816. \******************************************************/
  68817. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  68818. "use strict";
  68819. __webpack_require__.r(__webpack_exports__);
  68820. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  68821. /* harmony export */ paramCase: () => (/* binding */ paramCase)
  68822. /* harmony export */ });
  68823. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  68824. /* harmony import */ var dot_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! dot-case */ "./node_modules/dot-case/dist.es2015/index.js");
  68825. function paramCase(input, options) {
  68826. if (options === void 0) { options = {}; }
  68827. return (0,dot_case__WEBPACK_IMPORTED_MODULE_0__.dotCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ delimiter: "-" }, options));
  68828. }
  68829. //# sourceMappingURL=index.js.map
  68830. /***/ }),
  68831. /***/ "./node_modules/parse-asn1/asn1.js":
  68832. /*!*****************************************!*\
  68833. !*** ./node_modules/parse-asn1/asn1.js ***!
  68834. \*****************************************/
  68835. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  68836. "use strict";
  68837. // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
  68838. // Fedor, you are amazing.
  68839. var asn1 = __webpack_require__(/*! asn1.js */ "./node_modules/asn1.js/lib/asn1.js")
  68840. exports.certificate = __webpack_require__(/*! ./certificate */ "./node_modules/parse-asn1/certificate.js")
  68841. var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
  68842. this.seq().obj(
  68843. this.key('version').int(),
  68844. this.key('modulus').int(),
  68845. this.key('publicExponent').int(),
  68846. this.key('privateExponent').int(),
  68847. this.key('prime1').int(),
  68848. this.key('prime2').int(),
  68849. this.key('exponent1').int(),
  68850. this.key('exponent2').int(),
  68851. this.key('coefficient').int()
  68852. )
  68853. })
  68854. exports.RSAPrivateKey = RSAPrivateKey
  68855. var RSAPublicKey = asn1.define('RSAPublicKey', function () {
  68856. this.seq().obj(
  68857. this.key('modulus').int(),
  68858. this.key('publicExponent').int()
  68859. )
  68860. })
  68861. exports.RSAPublicKey = RSAPublicKey
  68862. var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
  68863. this.seq().obj(
  68864. this.key('algorithm').use(AlgorithmIdentifier),
  68865. this.key('subjectPublicKey').bitstr()
  68866. )
  68867. })
  68868. exports.PublicKey = PublicKey
  68869. var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
  68870. this.seq().obj(
  68871. this.key('algorithm').objid(),
  68872. this.key('none').null_().optional(),
  68873. this.key('curve').objid().optional(),
  68874. this.key('params').seq().obj(
  68875. this.key('p').int(),
  68876. this.key('q').int(),
  68877. this.key('g').int()
  68878. ).optional()
  68879. )
  68880. })
  68881. var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
  68882. this.seq().obj(
  68883. this.key('version').int(),
  68884. this.key('algorithm').use(AlgorithmIdentifier),
  68885. this.key('subjectPrivateKey').octstr()
  68886. )
  68887. })
  68888. exports.PrivateKey = PrivateKeyInfo
  68889. var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
  68890. this.seq().obj(
  68891. this.key('algorithm').seq().obj(
  68892. this.key('id').objid(),
  68893. this.key('decrypt').seq().obj(
  68894. this.key('kde').seq().obj(
  68895. this.key('id').objid(),
  68896. this.key('kdeparams').seq().obj(
  68897. this.key('salt').octstr(),
  68898. this.key('iters').int()
  68899. )
  68900. ),
  68901. this.key('cipher').seq().obj(
  68902. this.key('algo').objid(),
  68903. this.key('iv').octstr()
  68904. )
  68905. )
  68906. ),
  68907. this.key('subjectPrivateKey').octstr()
  68908. )
  68909. })
  68910. exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
  68911. var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
  68912. this.seq().obj(
  68913. this.key('version').int(),
  68914. this.key('p').int(),
  68915. this.key('q').int(),
  68916. this.key('g').int(),
  68917. this.key('pub_key').int(),
  68918. this.key('priv_key').int()
  68919. )
  68920. })
  68921. exports.DSAPrivateKey = DSAPrivateKey
  68922. exports.DSAparam = asn1.define('DSAparam', function () {
  68923. this.int()
  68924. })
  68925. var ECPrivateKey = asn1.define('ECPrivateKey', function () {
  68926. this.seq().obj(
  68927. this.key('version').int(),
  68928. this.key('privateKey').octstr(),
  68929. this.key('parameters').optional().explicit(0).use(ECParameters),
  68930. this.key('publicKey').optional().explicit(1).bitstr()
  68931. )
  68932. })
  68933. exports.ECPrivateKey = ECPrivateKey
  68934. var ECParameters = asn1.define('ECParameters', function () {
  68935. this.choice({
  68936. namedCurve: this.objid()
  68937. })
  68938. })
  68939. exports.signature = asn1.define('signature', function () {
  68940. this.seq().obj(
  68941. this.key('r').int(),
  68942. this.key('s').int()
  68943. )
  68944. })
  68945. /***/ }),
  68946. /***/ "./node_modules/parse-asn1/certificate.js":
  68947. /*!************************************************!*\
  68948. !*** ./node_modules/parse-asn1/certificate.js ***!
  68949. \************************************************/
  68950. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68951. "use strict";
  68952. // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
  68953. // thanks to @Rantanen
  68954. var asn = __webpack_require__(/*! asn1.js */ "./node_modules/asn1.js/lib/asn1.js")
  68955. var Time = asn.define('Time', function () {
  68956. this.choice({
  68957. utcTime: this.utctime(),
  68958. generalTime: this.gentime()
  68959. })
  68960. })
  68961. var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
  68962. this.seq().obj(
  68963. this.key('type').objid(),
  68964. this.key('value').any()
  68965. )
  68966. })
  68967. var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
  68968. this.seq().obj(
  68969. this.key('algorithm').objid(),
  68970. this.key('parameters').optional(),
  68971. this.key('curve').objid().optional()
  68972. )
  68973. })
  68974. var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
  68975. this.seq().obj(
  68976. this.key('algorithm').use(AlgorithmIdentifier),
  68977. this.key('subjectPublicKey').bitstr()
  68978. )
  68979. })
  68980. var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
  68981. this.setof(AttributeTypeValue)
  68982. })
  68983. var RDNSequence = asn.define('RDNSequence', function () {
  68984. this.seqof(RelativeDistinguishedName)
  68985. })
  68986. var Name = asn.define('Name', function () {
  68987. this.choice({
  68988. rdnSequence: this.use(RDNSequence)
  68989. })
  68990. })
  68991. var Validity = asn.define('Validity', function () {
  68992. this.seq().obj(
  68993. this.key('notBefore').use(Time),
  68994. this.key('notAfter').use(Time)
  68995. )
  68996. })
  68997. var Extension = asn.define('Extension', function () {
  68998. this.seq().obj(
  68999. this.key('extnID').objid(),
  69000. this.key('critical').bool().def(false),
  69001. this.key('extnValue').octstr()
  69002. )
  69003. })
  69004. var TBSCertificate = asn.define('TBSCertificate', function () {
  69005. this.seq().obj(
  69006. this.key('version').explicit(0).int().optional(),
  69007. this.key('serialNumber').int(),
  69008. this.key('signature').use(AlgorithmIdentifier),
  69009. this.key('issuer').use(Name),
  69010. this.key('validity').use(Validity),
  69011. this.key('subject').use(Name),
  69012. this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
  69013. this.key('issuerUniqueID').implicit(1).bitstr().optional(),
  69014. this.key('subjectUniqueID').implicit(2).bitstr().optional(),
  69015. this.key('extensions').explicit(3).seqof(Extension).optional()
  69016. )
  69017. })
  69018. var X509Certificate = asn.define('X509Certificate', function () {
  69019. this.seq().obj(
  69020. this.key('tbsCertificate').use(TBSCertificate),
  69021. this.key('signatureAlgorithm').use(AlgorithmIdentifier),
  69022. this.key('signatureValue').bitstr()
  69023. )
  69024. })
  69025. module.exports = X509Certificate
  69026. /***/ }),
  69027. /***/ "./node_modules/parse-asn1/fixProc.js":
  69028. /*!********************************************!*\
  69029. !*** ./node_modules/parse-asn1/fixProc.js ***!
  69030. \********************************************/
  69031. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69032. // adapted from https://github.com/apatil/pemstrip
  69033. var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m
  69034. var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m
  69035. var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m
  69036. var evp = __webpack_require__(/*! evp_bytestokey */ "./node_modules/evp_bytestokey/index.js")
  69037. var ciphers = __webpack_require__(/*! browserify-aes */ "./node_modules/browserify-aes/browser.js")
  69038. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  69039. module.exports = function (okey, password) {
  69040. var key = okey.toString()
  69041. var match = key.match(findProc)
  69042. var decrypted
  69043. if (!match) {
  69044. var match2 = key.match(fullRegex)
  69045. decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64')
  69046. } else {
  69047. var suite = 'aes' + match[1]
  69048. var iv = Buffer.from(match[2], 'hex')
  69049. var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64')
  69050. var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
  69051. var out = []
  69052. var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
  69053. out.push(cipher.update(cipherText))
  69054. out.push(cipher.final())
  69055. decrypted = Buffer.concat(out)
  69056. }
  69057. var tag = key.match(startRegex)[1]
  69058. return {
  69059. tag: tag,
  69060. data: decrypted
  69061. }
  69062. }
  69063. /***/ }),
  69064. /***/ "./node_modules/parse-asn1/index.js":
  69065. /*!******************************************!*\
  69066. !*** ./node_modules/parse-asn1/index.js ***!
  69067. \******************************************/
  69068. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69069. var asn1 = __webpack_require__(/*! ./asn1 */ "./node_modules/parse-asn1/asn1.js")
  69070. var aesid = __webpack_require__(/*! ./aesid.json */ "./node_modules/parse-asn1/aesid.json")
  69071. var fixProc = __webpack_require__(/*! ./fixProc */ "./node_modules/parse-asn1/fixProc.js")
  69072. var ciphers = __webpack_require__(/*! browserify-aes */ "./node_modules/browserify-aes/browser.js")
  69073. var compat = __webpack_require__(/*! pbkdf2 */ "./node_modules/pbkdf2/browser.js")
  69074. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  69075. module.exports = parseKeys
  69076. function parseKeys (buffer) {
  69077. var password
  69078. if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
  69079. password = buffer.passphrase
  69080. buffer = buffer.key
  69081. }
  69082. if (typeof buffer === 'string') {
  69083. buffer = Buffer.from(buffer)
  69084. }
  69085. var stripped = fixProc(buffer, password)
  69086. var type = stripped.tag
  69087. var data = stripped.data
  69088. var subtype, ndata
  69089. switch (type) {
  69090. case 'CERTIFICATE':
  69091. ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
  69092. // falls through
  69093. case 'PUBLIC KEY':
  69094. if (!ndata) {
  69095. ndata = asn1.PublicKey.decode(data, 'der')
  69096. }
  69097. subtype = ndata.algorithm.algorithm.join('.')
  69098. switch (subtype) {
  69099. case '1.2.840.113549.1.1.1':
  69100. return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
  69101. case '1.2.840.10045.2.1':
  69102. ndata.subjectPrivateKey = ndata.subjectPublicKey
  69103. return {
  69104. type: 'ec',
  69105. data: ndata
  69106. }
  69107. case '1.2.840.10040.4.1':
  69108. ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
  69109. return {
  69110. type: 'dsa',
  69111. data: ndata.algorithm.params
  69112. }
  69113. default: throw new Error('unknown key id ' + subtype)
  69114. }
  69115. // throw new Error('unknown key type ' + type)
  69116. case 'ENCRYPTED PRIVATE KEY':
  69117. data = asn1.EncryptedPrivateKey.decode(data, 'der')
  69118. data = decrypt(data, password)
  69119. // falls through
  69120. case 'PRIVATE KEY':
  69121. ndata = asn1.PrivateKey.decode(data, 'der')
  69122. subtype = ndata.algorithm.algorithm.join('.')
  69123. switch (subtype) {
  69124. case '1.2.840.113549.1.1.1':
  69125. return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
  69126. case '1.2.840.10045.2.1':
  69127. return {
  69128. curve: ndata.algorithm.curve,
  69129. privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
  69130. }
  69131. case '1.2.840.10040.4.1':
  69132. ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
  69133. return {
  69134. type: 'dsa',
  69135. params: ndata.algorithm.params
  69136. }
  69137. default: throw new Error('unknown key id ' + subtype)
  69138. }
  69139. // throw new Error('unknown key type ' + type)
  69140. case 'RSA PUBLIC KEY':
  69141. return asn1.RSAPublicKey.decode(data, 'der')
  69142. case 'RSA PRIVATE KEY':
  69143. return asn1.RSAPrivateKey.decode(data, 'der')
  69144. case 'DSA PRIVATE KEY':
  69145. return {
  69146. type: 'dsa',
  69147. params: asn1.DSAPrivateKey.decode(data, 'der')
  69148. }
  69149. case 'EC PRIVATE KEY':
  69150. data = asn1.ECPrivateKey.decode(data, 'der')
  69151. return {
  69152. curve: data.parameters.value,
  69153. privateKey: data.privateKey
  69154. }
  69155. default: throw new Error('unknown key type ' + type)
  69156. }
  69157. }
  69158. parseKeys.signature = asn1.signature
  69159. function decrypt (data, password) {
  69160. var salt = data.algorithm.decrypt.kde.kdeparams.salt
  69161. var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
  69162. var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
  69163. var iv = data.algorithm.decrypt.cipher.iv
  69164. var cipherText = data.subjectPrivateKey
  69165. var keylen = parseInt(algo.split('-')[1], 10) / 8
  69166. var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1')
  69167. var cipher = ciphers.createDecipheriv(algo, key, iv)
  69168. var out = []
  69169. out.push(cipher.update(cipherText))
  69170. out.push(cipher.final())
  69171. return Buffer.concat(out)
  69172. }
  69173. /***/ }),
  69174. /***/ "./node_modules/pascal-case/dist.es2015/index.js":
  69175. /*!*******************************************************!*\
  69176. !*** ./node_modules/pascal-case/dist.es2015/index.js ***!
  69177. \*******************************************************/
  69178. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  69179. "use strict";
  69180. __webpack_require__.r(__webpack_exports__);
  69181. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  69182. /* harmony export */ pascalCase: () => (/* binding */ pascalCase),
  69183. /* harmony export */ pascalCaseTransform: () => (/* binding */ pascalCaseTransform),
  69184. /* harmony export */ pascalCaseTransformMerge: () => (/* binding */ pascalCaseTransformMerge)
  69185. /* harmony export */ });
  69186. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  69187. /* harmony import */ var no_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! no-case */ "./node_modules/no-case/dist.es2015/index.js");
  69188. function pascalCaseTransform(input, index) {
  69189. var firstChar = input.charAt(0);
  69190. var lowerChars = input.substr(1).toLowerCase();
  69191. if (index > 0 && firstChar >= "0" && firstChar <= "9") {
  69192. return "_" + firstChar + lowerChars;
  69193. }
  69194. return "" + firstChar.toUpperCase() + lowerChars;
  69195. }
  69196. function pascalCaseTransformMerge(input) {
  69197. return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
  69198. }
  69199. function pascalCase(input, options) {
  69200. if (options === void 0) { options = {}; }
  69201. return (0,no_case__WEBPACK_IMPORTED_MODULE_0__.noCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ delimiter: "", transform: pascalCaseTransform }, options));
  69202. }
  69203. //# sourceMappingURL=index.js.map
  69204. /***/ }),
  69205. /***/ "./node_modules/pbkdf2/browser.js":
  69206. /*!****************************************!*\
  69207. !*** ./node_modules/pbkdf2/browser.js ***!
  69208. \****************************************/
  69209. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  69210. exports.pbkdf2 = __webpack_require__(/*! ./lib/async */ "./node_modules/pbkdf2/lib/async.js")
  69211. exports.pbkdf2Sync = __webpack_require__(/*! ./lib/sync */ "./node_modules/pbkdf2/lib/sync-browser.js")
  69212. /***/ }),
  69213. /***/ "./node_modules/pbkdf2/lib/async.js":
  69214. /*!******************************************!*\
  69215. !*** ./node_modules/pbkdf2/lib/async.js ***!
  69216. \******************************************/
  69217. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69218. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  69219. var checkParameters = __webpack_require__(/*! ./precondition */ "./node_modules/pbkdf2/lib/precondition.js")
  69220. var defaultEncoding = __webpack_require__(/*! ./default-encoding */ "./node_modules/pbkdf2/lib/default-encoding.js")
  69221. var sync = __webpack_require__(/*! ./sync */ "./node_modules/pbkdf2/lib/sync-browser.js")
  69222. var toBuffer = __webpack_require__(/*! ./to-buffer */ "./node_modules/pbkdf2/lib/to-buffer.js")
  69223. var ZERO_BUF
  69224. var subtle = __webpack_require__.g.crypto && __webpack_require__.g.crypto.subtle
  69225. var toBrowser = {
  69226. sha: 'SHA-1',
  69227. 'sha-1': 'SHA-1',
  69228. sha1: 'SHA-1',
  69229. sha256: 'SHA-256',
  69230. 'sha-256': 'SHA-256',
  69231. sha384: 'SHA-384',
  69232. 'sha-384': 'SHA-384',
  69233. 'sha-512': 'SHA-512',
  69234. sha512: 'SHA-512'
  69235. }
  69236. var checks = []
  69237. function checkNative (algo) {
  69238. if (__webpack_require__.g.process && !__webpack_require__.g.process.browser) {
  69239. return Promise.resolve(false)
  69240. }
  69241. if (!subtle || !subtle.importKey || !subtle.deriveBits) {
  69242. return Promise.resolve(false)
  69243. }
  69244. if (checks[algo] !== undefined) {
  69245. return checks[algo]
  69246. }
  69247. ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
  69248. var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
  69249. .then(function () {
  69250. return true
  69251. }).catch(function () {
  69252. return false
  69253. })
  69254. checks[algo] = prom
  69255. return prom
  69256. }
  69257. var nextTick
  69258. function getNextTick () {
  69259. if (nextTick) {
  69260. return nextTick
  69261. }
  69262. if (__webpack_require__.g.process && __webpack_require__.g.process.nextTick) {
  69263. nextTick = __webpack_require__.g.process.nextTick
  69264. } else if (__webpack_require__.g.queueMicrotask) {
  69265. nextTick = __webpack_require__.g.queueMicrotask
  69266. } else if (__webpack_require__.g.setImmediate) {
  69267. nextTick = __webpack_require__.g.setImmediate
  69268. } else {
  69269. nextTick = __webpack_require__.g.setTimeout
  69270. }
  69271. return nextTick
  69272. }
  69273. function browserPbkdf2 (password, salt, iterations, length, algo) {
  69274. return subtle.importKey(
  69275. 'raw', password, { name: 'PBKDF2' }, false, ['deriveBits']
  69276. ).then(function (key) {
  69277. return subtle.deriveBits({
  69278. name: 'PBKDF2',
  69279. salt: salt,
  69280. iterations: iterations,
  69281. hash: {
  69282. name: algo
  69283. }
  69284. }, key, length << 3)
  69285. }).then(function (res) {
  69286. return Buffer.from(res)
  69287. })
  69288. }
  69289. function resolvePromise (promise, callback) {
  69290. promise.then(function (out) {
  69291. getNextTick()(function () {
  69292. callback(null, out)
  69293. })
  69294. }, function (e) {
  69295. getNextTick()(function () {
  69296. callback(e)
  69297. })
  69298. })
  69299. }
  69300. module.exports = function (password, salt, iterations, keylen, digest, callback) {
  69301. if (typeof digest === 'function') {
  69302. callback = digest
  69303. digest = undefined
  69304. }
  69305. digest = digest || 'sha1'
  69306. var algo = toBrowser[digest.toLowerCase()]
  69307. if (!algo || typeof __webpack_require__.g.Promise !== 'function') {
  69308. getNextTick()(function () {
  69309. var out
  69310. try {
  69311. out = sync(password, salt, iterations, keylen, digest)
  69312. } catch (e) {
  69313. return callback(e)
  69314. }
  69315. callback(null, out)
  69316. })
  69317. return
  69318. }
  69319. checkParameters(iterations, keylen)
  69320. password = toBuffer(password, defaultEncoding, 'Password')
  69321. salt = toBuffer(salt, defaultEncoding, 'Salt')
  69322. if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
  69323. resolvePromise(checkNative(algo).then(function (resp) {
  69324. if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)
  69325. return sync(password, salt, iterations, keylen, digest)
  69326. }), callback)
  69327. }
  69328. /***/ }),
  69329. /***/ "./node_modules/pbkdf2/lib/default-encoding.js":
  69330. /*!*****************************************************!*\
  69331. !*** ./node_modules/pbkdf2/lib/default-encoding.js ***!
  69332. \*****************************************************/
  69333. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69334. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  69335. var defaultEncoding
  69336. /* istanbul ignore next */
  69337. if (__webpack_require__.g.process && __webpack_require__.g.process.browser) {
  69338. defaultEncoding = 'utf-8'
  69339. } else if (__webpack_require__.g.process && __webpack_require__.g.process.version) {
  69340. var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
  69341. defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
  69342. } else {
  69343. defaultEncoding = 'utf-8'
  69344. }
  69345. module.exports = defaultEncoding
  69346. /***/ }),
  69347. /***/ "./node_modules/pbkdf2/lib/precondition.js":
  69348. /*!*************************************************!*\
  69349. !*** ./node_modules/pbkdf2/lib/precondition.js ***!
  69350. \*************************************************/
  69351. /***/ ((module) => {
  69352. var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
  69353. module.exports = function (iterations, keylen) {
  69354. if (typeof iterations !== 'number') {
  69355. throw new TypeError('Iterations not a number')
  69356. }
  69357. if (iterations < 0) {
  69358. throw new TypeError('Bad iterations')
  69359. }
  69360. if (typeof keylen !== 'number') {
  69361. throw new TypeError('Key length not a number')
  69362. }
  69363. if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
  69364. throw new TypeError('Bad key length')
  69365. }
  69366. }
  69367. /***/ }),
  69368. /***/ "./node_modules/pbkdf2/lib/sync-browser.js":
  69369. /*!*************************************************!*\
  69370. !*** ./node_modules/pbkdf2/lib/sync-browser.js ***!
  69371. \*************************************************/
  69372. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69373. var md5 = __webpack_require__(/*! create-hash/md5 */ "./node_modules/create-hash/md5.js")
  69374. var RIPEMD160 = __webpack_require__(/*! ripemd160 */ "./node_modules/ripemd160/index.js")
  69375. var sha = __webpack_require__(/*! sha.js */ "./node_modules/sha.js/index.js")
  69376. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  69377. var checkParameters = __webpack_require__(/*! ./precondition */ "./node_modules/pbkdf2/lib/precondition.js")
  69378. var defaultEncoding = __webpack_require__(/*! ./default-encoding */ "./node_modules/pbkdf2/lib/default-encoding.js")
  69379. var toBuffer = __webpack_require__(/*! ./to-buffer */ "./node_modules/pbkdf2/lib/to-buffer.js")
  69380. var ZEROS = Buffer.alloc(128)
  69381. var sizes = {
  69382. md5: 16,
  69383. sha1: 20,
  69384. sha224: 28,
  69385. sha256: 32,
  69386. sha384: 48,
  69387. sha512: 64,
  69388. rmd160: 20,
  69389. ripemd160: 20
  69390. }
  69391. function Hmac (alg, key, saltLen) {
  69392. var hash = getDigest(alg)
  69393. var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
  69394. if (key.length > blocksize) {
  69395. key = hash(key)
  69396. } else if (key.length < blocksize) {
  69397. key = Buffer.concat([key, ZEROS], blocksize)
  69398. }
  69399. var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
  69400. var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
  69401. for (var i = 0; i < blocksize; i++) {
  69402. ipad[i] = key[i] ^ 0x36
  69403. opad[i] = key[i] ^ 0x5C
  69404. }
  69405. var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
  69406. ipad.copy(ipad1, 0, 0, blocksize)
  69407. this.ipad1 = ipad1
  69408. this.ipad2 = ipad
  69409. this.opad = opad
  69410. this.alg = alg
  69411. this.blocksize = blocksize
  69412. this.hash = hash
  69413. this.size = sizes[alg]
  69414. }
  69415. Hmac.prototype.run = function (data, ipad) {
  69416. data.copy(ipad, this.blocksize)
  69417. var h = this.hash(ipad)
  69418. h.copy(this.opad, this.blocksize)
  69419. return this.hash(this.opad)
  69420. }
  69421. function getDigest (alg) {
  69422. function shaFunc (data) {
  69423. return sha(alg).update(data).digest()
  69424. }
  69425. function rmd160Func (data) {
  69426. return new RIPEMD160().update(data).digest()
  69427. }
  69428. if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func
  69429. if (alg === 'md5') return md5
  69430. return shaFunc
  69431. }
  69432. function pbkdf2 (password, salt, iterations, keylen, digest) {
  69433. checkParameters(iterations, keylen)
  69434. password = toBuffer(password, defaultEncoding, 'Password')
  69435. salt = toBuffer(salt, defaultEncoding, 'Salt')
  69436. digest = digest || 'sha1'
  69437. var hmac = new Hmac(digest, password, salt.length)
  69438. var DK = Buffer.allocUnsafe(keylen)
  69439. var block1 = Buffer.allocUnsafe(salt.length + 4)
  69440. salt.copy(block1, 0, 0, salt.length)
  69441. var destPos = 0
  69442. var hLen = sizes[digest]
  69443. var l = Math.ceil(keylen / hLen)
  69444. for (var i = 1; i <= l; i++) {
  69445. block1.writeUInt32BE(i, salt.length)
  69446. var T = hmac.run(block1, hmac.ipad1)
  69447. var U = T
  69448. for (var j = 1; j < iterations; j++) {
  69449. U = hmac.run(U, hmac.ipad2)
  69450. for (var k = 0; k < hLen; k++) T[k] ^= U[k]
  69451. }
  69452. T.copy(DK, destPos)
  69453. destPos += hLen
  69454. }
  69455. return DK
  69456. }
  69457. module.exports = pbkdf2
  69458. /***/ }),
  69459. /***/ "./node_modules/pbkdf2/lib/to-buffer.js":
  69460. /*!**********************************************!*\
  69461. !*** ./node_modules/pbkdf2/lib/to-buffer.js ***!
  69462. \**********************************************/
  69463. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69464. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  69465. module.exports = function (thing, encoding, name) {
  69466. if (Buffer.isBuffer(thing)) {
  69467. return thing
  69468. } else if (typeof thing === 'string') {
  69469. return Buffer.from(thing, encoding)
  69470. } else if (ArrayBuffer.isView(thing)) {
  69471. return Buffer.from(thing.buffer)
  69472. } else {
  69473. throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView')
  69474. }
  69475. }
  69476. /***/ }),
  69477. /***/ "./node_modules/process/browser.js":
  69478. /*!*****************************************!*\
  69479. !*** ./node_modules/process/browser.js ***!
  69480. \*****************************************/
  69481. /***/ ((module) => {
  69482. // shim for using process in browser
  69483. var process = module.exports = {};
  69484. // cached from whatever global is present so that test runners that stub it
  69485. // don't break things. But we need to wrap it in a try catch in case it is
  69486. // wrapped in strict mode code which doesn't define any globals. It's inside a
  69487. // function because try/catches deoptimize in certain engines.
  69488. var cachedSetTimeout;
  69489. var cachedClearTimeout;
  69490. function defaultSetTimout() {
  69491. throw new Error('setTimeout has not been defined');
  69492. }
  69493. function defaultClearTimeout () {
  69494. throw new Error('clearTimeout has not been defined');
  69495. }
  69496. (function () {
  69497. try {
  69498. if (typeof setTimeout === 'function') {
  69499. cachedSetTimeout = setTimeout;
  69500. } else {
  69501. cachedSetTimeout = defaultSetTimout;
  69502. }
  69503. } catch (e) {
  69504. cachedSetTimeout = defaultSetTimout;
  69505. }
  69506. try {
  69507. if (typeof clearTimeout === 'function') {
  69508. cachedClearTimeout = clearTimeout;
  69509. } else {
  69510. cachedClearTimeout = defaultClearTimeout;
  69511. }
  69512. } catch (e) {
  69513. cachedClearTimeout = defaultClearTimeout;
  69514. }
  69515. } ())
  69516. function runTimeout(fun) {
  69517. if (cachedSetTimeout === setTimeout) {
  69518. //normal enviroments in sane situations
  69519. return setTimeout(fun, 0);
  69520. }
  69521. // if setTimeout wasn't available but was latter defined
  69522. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  69523. cachedSetTimeout = setTimeout;
  69524. return setTimeout(fun, 0);
  69525. }
  69526. try {
  69527. // when when somebody has screwed with setTimeout but no I.E. maddness
  69528. return cachedSetTimeout(fun, 0);
  69529. } catch(e){
  69530. try {
  69531. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  69532. return cachedSetTimeout.call(null, fun, 0);
  69533. } catch(e){
  69534. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  69535. return cachedSetTimeout.call(this, fun, 0);
  69536. }
  69537. }
  69538. }
  69539. function runClearTimeout(marker) {
  69540. if (cachedClearTimeout === clearTimeout) {
  69541. //normal enviroments in sane situations
  69542. return clearTimeout(marker);
  69543. }
  69544. // if clearTimeout wasn't available but was latter defined
  69545. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  69546. cachedClearTimeout = clearTimeout;
  69547. return clearTimeout(marker);
  69548. }
  69549. try {
  69550. // when when somebody has screwed with setTimeout but no I.E. maddness
  69551. return cachedClearTimeout(marker);
  69552. } catch (e){
  69553. try {
  69554. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  69555. return cachedClearTimeout.call(null, marker);
  69556. } catch (e){
  69557. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  69558. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  69559. return cachedClearTimeout.call(this, marker);
  69560. }
  69561. }
  69562. }
  69563. var queue = [];
  69564. var draining = false;
  69565. var currentQueue;
  69566. var queueIndex = -1;
  69567. function cleanUpNextTick() {
  69568. if (!draining || !currentQueue) {
  69569. return;
  69570. }
  69571. draining = false;
  69572. if (currentQueue.length) {
  69573. queue = currentQueue.concat(queue);
  69574. } else {
  69575. queueIndex = -1;
  69576. }
  69577. if (queue.length) {
  69578. drainQueue();
  69579. }
  69580. }
  69581. function drainQueue() {
  69582. if (draining) {
  69583. return;
  69584. }
  69585. var timeout = runTimeout(cleanUpNextTick);
  69586. draining = true;
  69587. var len = queue.length;
  69588. while(len) {
  69589. currentQueue = queue;
  69590. queue = [];
  69591. while (++queueIndex < len) {
  69592. if (currentQueue) {
  69593. currentQueue[queueIndex].run();
  69594. }
  69595. }
  69596. queueIndex = -1;
  69597. len = queue.length;
  69598. }
  69599. currentQueue = null;
  69600. draining = false;
  69601. runClearTimeout(timeout);
  69602. }
  69603. process.nextTick = function (fun) {
  69604. var args = new Array(arguments.length - 1);
  69605. if (arguments.length > 1) {
  69606. for (var i = 1; i < arguments.length; i++) {
  69607. args[i - 1] = arguments[i];
  69608. }
  69609. }
  69610. queue.push(new Item(fun, args));
  69611. if (queue.length === 1 && !draining) {
  69612. runTimeout(drainQueue);
  69613. }
  69614. };
  69615. // v8 likes predictible objects
  69616. function Item(fun, array) {
  69617. this.fun = fun;
  69618. this.array = array;
  69619. }
  69620. Item.prototype.run = function () {
  69621. this.fun.apply(null, this.array);
  69622. };
  69623. process.title = 'browser';
  69624. process.browser = true;
  69625. process.env = {};
  69626. process.argv = [];
  69627. process.version = ''; // empty string to avoid regexp issues
  69628. process.versions = {};
  69629. function noop() {}
  69630. process.on = noop;
  69631. process.addListener = noop;
  69632. process.once = noop;
  69633. process.off = noop;
  69634. process.removeListener = noop;
  69635. process.removeAllListeners = noop;
  69636. process.emit = noop;
  69637. process.prependListener = noop;
  69638. process.prependOnceListener = noop;
  69639. process.listeners = function (name) { return [] }
  69640. process.binding = function (name) {
  69641. throw new Error('process.binding is not supported');
  69642. };
  69643. process.cwd = function () { return '/' };
  69644. process.chdir = function (dir) {
  69645. throw new Error('process.chdir is not supported');
  69646. };
  69647. process.umask = function() { return 0; };
  69648. /***/ }),
  69649. /***/ "./node_modules/public-encrypt/browser.js":
  69650. /*!************************************************!*\
  69651. !*** ./node_modules/public-encrypt/browser.js ***!
  69652. \************************************************/
  69653. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  69654. exports.publicEncrypt = __webpack_require__(/*! ./publicEncrypt */ "./node_modules/public-encrypt/publicEncrypt.js")
  69655. exports.privateDecrypt = __webpack_require__(/*! ./privateDecrypt */ "./node_modules/public-encrypt/privateDecrypt.js")
  69656. exports.privateEncrypt = function privateEncrypt (key, buf) {
  69657. return exports.publicEncrypt(key, buf, true)
  69658. }
  69659. exports.publicDecrypt = function publicDecrypt (key, buf) {
  69660. return exports.privateDecrypt(key, buf, true)
  69661. }
  69662. /***/ }),
  69663. /***/ "./node_modules/public-encrypt/mgf.js":
  69664. /*!********************************************!*\
  69665. !*** ./node_modules/public-encrypt/mgf.js ***!
  69666. \********************************************/
  69667. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  69668. var createHash = __webpack_require__(/*! create-hash */ "./node_modules/create-hash/browser.js")
  69669. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  69670. module.exports = function (seed, len) {
  69671. var t = Buffer.alloc(0)
  69672. var i = 0
  69673. var c
  69674. while (t.length < len) {
  69675. c = i2ops(i++)
  69676. t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])
  69677. }
  69678. return t.slice(0, len)
  69679. }
  69680. function i2ops (c) {
  69681. var out = Buffer.allocUnsafe(4)
  69682. out.writeUInt32BE(c, 0)
  69683. return out
  69684. }
  69685. /***/ }),
  69686. /***/ "./node_modules/public-encrypt/node_modules/bn.js/lib/bn.js":
  69687. /*!******************************************************************!*\
  69688. !*** ./node_modules/public-encrypt/node_modules/bn.js/lib/bn.js ***!
  69689. \******************************************************************/
  69690. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  69691. /* module decorator */ module = __webpack_require__.nmd(module);
  69692. (function (module, exports) {
  69693. 'use strict';
  69694. // Utils
  69695. function assert (val, msg) {
  69696. if (!val) throw new Error(msg || 'Assertion failed');
  69697. }
  69698. // Could use `inherits` module, but don't want to move from single file
  69699. // architecture yet.
  69700. function inherits (ctor, superCtor) {
  69701. ctor.super_ = superCtor;
  69702. var TempCtor = function () {};
  69703. TempCtor.prototype = superCtor.prototype;
  69704. ctor.prototype = new TempCtor();
  69705. ctor.prototype.constructor = ctor;
  69706. }
  69707. // BN
  69708. function BN (number, base, endian) {
  69709. if (BN.isBN(number)) {
  69710. return number;
  69711. }
  69712. this.negative = 0;
  69713. this.words = null;
  69714. this.length = 0;
  69715. // Reduction context
  69716. this.red = null;
  69717. if (number !== null) {
  69718. if (base === 'le' || base === 'be') {
  69719. endian = base;
  69720. base = 10;
  69721. }
  69722. this._init(number || 0, base || 10, endian || 'be');
  69723. }
  69724. }
  69725. if (typeof module === 'object') {
  69726. module.exports = BN;
  69727. } else {
  69728. exports.BN = BN;
  69729. }
  69730. BN.BN = BN;
  69731. BN.wordSize = 26;
  69732. var Buffer;
  69733. try {
  69734. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  69735. Buffer = window.Buffer;
  69736. } else {
  69737. Buffer = (__webpack_require__(/*! buffer */ "?a44a").Buffer);
  69738. }
  69739. } catch (e) {
  69740. }
  69741. BN.isBN = function isBN (num) {
  69742. if (num instanceof BN) {
  69743. return true;
  69744. }
  69745. return num !== null && typeof num === 'object' &&
  69746. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  69747. };
  69748. BN.max = function max (left, right) {
  69749. if (left.cmp(right) > 0) return left;
  69750. return right;
  69751. };
  69752. BN.min = function min (left, right) {
  69753. if (left.cmp(right) < 0) return left;
  69754. return right;
  69755. };
  69756. BN.prototype._init = function init (number, base, endian) {
  69757. if (typeof number === 'number') {
  69758. return this._initNumber(number, base, endian);
  69759. }
  69760. if (typeof number === 'object') {
  69761. return this._initArray(number, base, endian);
  69762. }
  69763. if (base === 'hex') {
  69764. base = 16;
  69765. }
  69766. assert(base === (base | 0) && base >= 2 && base <= 36);
  69767. number = number.toString().replace(/\s+/g, '');
  69768. var start = 0;
  69769. if (number[0] === '-') {
  69770. start++;
  69771. this.negative = 1;
  69772. }
  69773. if (start < number.length) {
  69774. if (base === 16) {
  69775. this._parseHex(number, start, endian);
  69776. } else {
  69777. this._parseBase(number, base, start);
  69778. if (endian === 'le') {
  69779. this._initArray(this.toArray(), base, endian);
  69780. }
  69781. }
  69782. }
  69783. };
  69784. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  69785. if (number < 0) {
  69786. this.negative = 1;
  69787. number = -number;
  69788. }
  69789. if (number < 0x4000000) {
  69790. this.words = [ number & 0x3ffffff ];
  69791. this.length = 1;
  69792. } else if (number < 0x10000000000000) {
  69793. this.words = [
  69794. number & 0x3ffffff,
  69795. (number / 0x4000000) & 0x3ffffff
  69796. ];
  69797. this.length = 2;
  69798. } else {
  69799. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  69800. this.words = [
  69801. number & 0x3ffffff,
  69802. (number / 0x4000000) & 0x3ffffff,
  69803. 1
  69804. ];
  69805. this.length = 3;
  69806. }
  69807. if (endian !== 'le') return;
  69808. // Reverse the bytes
  69809. this._initArray(this.toArray(), base, endian);
  69810. };
  69811. BN.prototype._initArray = function _initArray (number, base, endian) {
  69812. // Perhaps a Uint8Array
  69813. assert(typeof number.length === 'number');
  69814. if (number.length <= 0) {
  69815. this.words = [ 0 ];
  69816. this.length = 1;
  69817. return this;
  69818. }
  69819. this.length = Math.ceil(number.length / 3);
  69820. this.words = new Array(this.length);
  69821. for (var i = 0; i < this.length; i++) {
  69822. this.words[i] = 0;
  69823. }
  69824. var j, w;
  69825. var off = 0;
  69826. if (endian === 'be') {
  69827. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  69828. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  69829. this.words[j] |= (w << off) & 0x3ffffff;
  69830. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  69831. off += 24;
  69832. if (off >= 26) {
  69833. off -= 26;
  69834. j++;
  69835. }
  69836. }
  69837. } else if (endian === 'le') {
  69838. for (i = 0, j = 0; i < number.length; i += 3) {
  69839. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  69840. this.words[j] |= (w << off) & 0x3ffffff;
  69841. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  69842. off += 24;
  69843. if (off >= 26) {
  69844. off -= 26;
  69845. j++;
  69846. }
  69847. }
  69848. }
  69849. return this.strip();
  69850. };
  69851. function parseHex4Bits (string, index) {
  69852. var c = string.charCodeAt(index);
  69853. // 'A' - 'F'
  69854. if (c >= 65 && c <= 70) {
  69855. return c - 55;
  69856. // 'a' - 'f'
  69857. } else if (c >= 97 && c <= 102) {
  69858. return c - 87;
  69859. // '0' - '9'
  69860. } else {
  69861. return (c - 48) & 0xf;
  69862. }
  69863. }
  69864. function parseHexByte (string, lowerBound, index) {
  69865. var r = parseHex4Bits(string, index);
  69866. if (index - 1 >= lowerBound) {
  69867. r |= parseHex4Bits(string, index - 1) << 4;
  69868. }
  69869. return r;
  69870. }
  69871. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  69872. // Create possibly bigger array to ensure that it fits the number
  69873. this.length = Math.ceil((number.length - start) / 6);
  69874. this.words = new Array(this.length);
  69875. for (var i = 0; i < this.length; i++) {
  69876. this.words[i] = 0;
  69877. }
  69878. // 24-bits chunks
  69879. var off = 0;
  69880. var j = 0;
  69881. var w;
  69882. if (endian === 'be') {
  69883. for (i = number.length - 1; i >= start; i -= 2) {
  69884. w = parseHexByte(number, start, i) << off;
  69885. this.words[j] |= w & 0x3ffffff;
  69886. if (off >= 18) {
  69887. off -= 18;
  69888. j += 1;
  69889. this.words[j] |= w >>> 26;
  69890. } else {
  69891. off += 8;
  69892. }
  69893. }
  69894. } else {
  69895. var parseLength = number.length - start;
  69896. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  69897. w = parseHexByte(number, start, i) << off;
  69898. this.words[j] |= w & 0x3ffffff;
  69899. if (off >= 18) {
  69900. off -= 18;
  69901. j += 1;
  69902. this.words[j] |= w >>> 26;
  69903. } else {
  69904. off += 8;
  69905. }
  69906. }
  69907. }
  69908. this.strip();
  69909. };
  69910. function parseBase (str, start, end, mul) {
  69911. var r = 0;
  69912. var len = Math.min(str.length, end);
  69913. for (var i = start; i < len; i++) {
  69914. var c = str.charCodeAt(i) - 48;
  69915. r *= mul;
  69916. // 'a'
  69917. if (c >= 49) {
  69918. r += c - 49 + 0xa;
  69919. // 'A'
  69920. } else if (c >= 17) {
  69921. r += c - 17 + 0xa;
  69922. // '0' - '9'
  69923. } else {
  69924. r += c;
  69925. }
  69926. }
  69927. return r;
  69928. }
  69929. BN.prototype._parseBase = function _parseBase (number, base, start) {
  69930. // Initialize as zero
  69931. this.words = [ 0 ];
  69932. this.length = 1;
  69933. // Find length of limb in base
  69934. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  69935. limbLen++;
  69936. }
  69937. limbLen--;
  69938. limbPow = (limbPow / base) | 0;
  69939. var total = number.length - start;
  69940. var mod = total % limbLen;
  69941. var end = Math.min(total, total - mod) + start;
  69942. var word = 0;
  69943. for (var i = start; i < end; i += limbLen) {
  69944. word = parseBase(number, i, i + limbLen, base);
  69945. this.imuln(limbPow);
  69946. if (this.words[0] + word < 0x4000000) {
  69947. this.words[0] += word;
  69948. } else {
  69949. this._iaddn(word);
  69950. }
  69951. }
  69952. if (mod !== 0) {
  69953. var pow = 1;
  69954. word = parseBase(number, i, number.length, base);
  69955. for (i = 0; i < mod; i++) {
  69956. pow *= base;
  69957. }
  69958. this.imuln(pow);
  69959. if (this.words[0] + word < 0x4000000) {
  69960. this.words[0] += word;
  69961. } else {
  69962. this._iaddn(word);
  69963. }
  69964. }
  69965. this.strip();
  69966. };
  69967. BN.prototype.copy = function copy (dest) {
  69968. dest.words = new Array(this.length);
  69969. for (var i = 0; i < this.length; i++) {
  69970. dest.words[i] = this.words[i];
  69971. }
  69972. dest.length = this.length;
  69973. dest.negative = this.negative;
  69974. dest.red = this.red;
  69975. };
  69976. BN.prototype.clone = function clone () {
  69977. var r = new BN(null);
  69978. this.copy(r);
  69979. return r;
  69980. };
  69981. BN.prototype._expand = function _expand (size) {
  69982. while (this.length < size) {
  69983. this.words[this.length++] = 0;
  69984. }
  69985. return this;
  69986. };
  69987. // Remove leading `0` from `this`
  69988. BN.prototype.strip = function strip () {
  69989. while (this.length > 1 && this.words[this.length - 1] === 0) {
  69990. this.length--;
  69991. }
  69992. return this._normSign();
  69993. };
  69994. BN.prototype._normSign = function _normSign () {
  69995. // -0 = 0
  69996. if (this.length === 1 && this.words[0] === 0) {
  69997. this.negative = 0;
  69998. }
  69999. return this;
  70000. };
  70001. BN.prototype.inspect = function inspect () {
  70002. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  70003. };
  70004. /*
  70005. var zeros = [];
  70006. var groupSizes = [];
  70007. var groupBases = [];
  70008. var s = '';
  70009. var i = -1;
  70010. while (++i < BN.wordSize) {
  70011. zeros[i] = s;
  70012. s += '0';
  70013. }
  70014. groupSizes[0] = 0;
  70015. groupSizes[1] = 0;
  70016. groupBases[0] = 0;
  70017. groupBases[1] = 0;
  70018. var base = 2 - 1;
  70019. while (++base < 36 + 1) {
  70020. var groupSize = 0;
  70021. var groupBase = 1;
  70022. while (groupBase < (1 << BN.wordSize) / base) {
  70023. groupBase *= base;
  70024. groupSize += 1;
  70025. }
  70026. groupSizes[base] = groupSize;
  70027. groupBases[base] = groupBase;
  70028. }
  70029. */
  70030. var zeros = [
  70031. '',
  70032. '0',
  70033. '00',
  70034. '000',
  70035. '0000',
  70036. '00000',
  70037. '000000',
  70038. '0000000',
  70039. '00000000',
  70040. '000000000',
  70041. '0000000000',
  70042. '00000000000',
  70043. '000000000000',
  70044. '0000000000000',
  70045. '00000000000000',
  70046. '000000000000000',
  70047. '0000000000000000',
  70048. '00000000000000000',
  70049. '000000000000000000',
  70050. '0000000000000000000',
  70051. '00000000000000000000',
  70052. '000000000000000000000',
  70053. '0000000000000000000000',
  70054. '00000000000000000000000',
  70055. '000000000000000000000000',
  70056. '0000000000000000000000000'
  70057. ];
  70058. var groupSizes = [
  70059. 0, 0,
  70060. 25, 16, 12, 11, 10, 9, 8,
  70061. 8, 7, 7, 7, 7, 6, 6,
  70062. 6, 6, 6, 6, 6, 5, 5,
  70063. 5, 5, 5, 5, 5, 5, 5,
  70064. 5, 5, 5, 5, 5, 5, 5
  70065. ];
  70066. var groupBases = [
  70067. 0, 0,
  70068. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  70069. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  70070. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  70071. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  70072. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  70073. ];
  70074. BN.prototype.toString = function toString (base, padding) {
  70075. base = base || 10;
  70076. padding = padding | 0 || 1;
  70077. var out;
  70078. if (base === 16 || base === 'hex') {
  70079. out = '';
  70080. var off = 0;
  70081. var carry = 0;
  70082. for (var i = 0; i < this.length; i++) {
  70083. var w = this.words[i];
  70084. var word = (((w << off) | carry) & 0xffffff).toString(16);
  70085. carry = (w >>> (24 - off)) & 0xffffff;
  70086. if (carry !== 0 || i !== this.length - 1) {
  70087. out = zeros[6 - word.length] + word + out;
  70088. } else {
  70089. out = word + out;
  70090. }
  70091. off += 2;
  70092. if (off >= 26) {
  70093. off -= 26;
  70094. i--;
  70095. }
  70096. }
  70097. if (carry !== 0) {
  70098. out = carry.toString(16) + out;
  70099. }
  70100. while (out.length % padding !== 0) {
  70101. out = '0' + out;
  70102. }
  70103. if (this.negative !== 0) {
  70104. out = '-' + out;
  70105. }
  70106. return out;
  70107. }
  70108. if (base === (base | 0) && base >= 2 && base <= 36) {
  70109. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  70110. var groupSize = groupSizes[base];
  70111. // var groupBase = Math.pow(base, groupSize);
  70112. var groupBase = groupBases[base];
  70113. out = '';
  70114. var c = this.clone();
  70115. c.negative = 0;
  70116. while (!c.isZero()) {
  70117. var r = c.modn(groupBase).toString(base);
  70118. c = c.idivn(groupBase);
  70119. if (!c.isZero()) {
  70120. out = zeros[groupSize - r.length] + r + out;
  70121. } else {
  70122. out = r + out;
  70123. }
  70124. }
  70125. if (this.isZero()) {
  70126. out = '0' + out;
  70127. }
  70128. while (out.length % padding !== 0) {
  70129. out = '0' + out;
  70130. }
  70131. if (this.negative !== 0) {
  70132. out = '-' + out;
  70133. }
  70134. return out;
  70135. }
  70136. assert(false, 'Base should be between 2 and 36');
  70137. };
  70138. BN.prototype.toNumber = function toNumber () {
  70139. var ret = this.words[0];
  70140. if (this.length === 2) {
  70141. ret += this.words[1] * 0x4000000;
  70142. } else if (this.length === 3 && this.words[2] === 0x01) {
  70143. // NOTE: at this stage it is known that the top bit is set
  70144. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  70145. } else if (this.length > 2) {
  70146. assert(false, 'Number can only safely store up to 53 bits');
  70147. }
  70148. return (this.negative !== 0) ? -ret : ret;
  70149. };
  70150. BN.prototype.toJSON = function toJSON () {
  70151. return this.toString(16);
  70152. };
  70153. BN.prototype.toBuffer = function toBuffer (endian, length) {
  70154. assert(typeof Buffer !== 'undefined');
  70155. return this.toArrayLike(Buffer, endian, length);
  70156. };
  70157. BN.prototype.toArray = function toArray (endian, length) {
  70158. return this.toArrayLike(Array, endian, length);
  70159. };
  70160. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  70161. var byteLength = this.byteLength();
  70162. var reqLength = length || Math.max(1, byteLength);
  70163. assert(byteLength <= reqLength, 'byte array longer than desired length');
  70164. assert(reqLength > 0, 'Requested array length <= 0');
  70165. this.strip();
  70166. var littleEndian = endian === 'le';
  70167. var res = new ArrayType(reqLength);
  70168. var b, i;
  70169. var q = this.clone();
  70170. if (!littleEndian) {
  70171. // Assume big-endian
  70172. for (i = 0; i < reqLength - byteLength; i++) {
  70173. res[i] = 0;
  70174. }
  70175. for (i = 0; !q.isZero(); i++) {
  70176. b = q.andln(0xff);
  70177. q.iushrn(8);
  70178. res[reqLength - i - 1] = b;
  70179. }
  70180. } else {
  70181. for (i = 0; !q.isZero(); i++) {
  70182. b = q.andln(0xff);
  70183. q.iushrn(8);
  70184. res[i] = b;
  70185. }
  70186. for (; i < reqLength; i++) {
  70187. res[i] = 0;
  70188. }
  70189. }
  70190. return res;
  70191. };
  70192. if (Math.clz32) {
  70193. BN.prototype._countBits = function _countBits (w) {
  70194. return 32 - Math.clz32(w);
  70195. };
  70196. } else {
  70197. BN.prototype._countBits = function _countBits (w) {
  70198. var t = w;
  70199. var r = 0;
  70200. if (t >= 0x1000) {
  70201. r += 13;
  70202. t >>>= 13;
  70203. }
  70204. if (t >= 0x40) {
  70205. r += 7;
  70206. t >>>= 7;
  70207. }
  70208. if (t >= 0x8) {
  70209. r += 4;
  70210. t >>>= 4;
  70211. }
  70212. if (t >= 0x02) {
  70213. r += 2;
  70214. t >>>= 2;
  70215. }
  70216. return r + t;
  70217. };
  70218. }
  70219. BN.prototype._zeroBits = function _zeroBits (w) {
  70220. // Short-cut
  70221. if (w === 0) return 26;
  70222. var t = w;
  70223. var r = 0;
  70224. if ((t & 0x1fff) === 0) {
  70225. r += 13;
  70226. t >>>= 13;
  70227. }
  70228. if ((t & 0x7f) === 0) {
  70229. r += 7;
  70230. t >>>= 7;
  70231. }
  70232. if ((t & 0xf) === 0) {
  70233. r += 4;
  70234. t >>>= 4;
  70235. }
  70236. if ((t & 0x3) === 0) {
  70237. r += 2;
  70238. t >>>= 2;
  70239. }
  70240. if ((t & 0x1) === 0) {
  70241. r++;
  70242. }
  70243. return r;
  70244. };
  70245. // Return number of used bits in a BN
  70246. BN.prototype.bitLength = function bitLength () {
  70247. var w = this.words[this.length - 1];
  70248. var hi = this._countBits(w);
  70249. return (this.length - 1) * 26 + hi;
  70250. };
  70251. function toBitArray (num) {
  70252. var w = new Array(num.bitLength());
  70253. for (var bit = 0; bit < w.length; bit++) {
  70254. var off = (bit / 26) | 0;
  70255. var wbit = bit % 26;
  70256. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  70257. }
  70258. return w;
  70259. }
  70260. // Number of trailing zero bits
  70261. BN.prototype.zeroBits = function zeroBits () {
  70262. if (this.isZero()) return 0;
  70263. var r = 0;
  70264. for (var i = 0; i < this.length; i++) {
  70265. var b = this._zeroBits(this.words[i]);
  70266. r += b;
  70267. if (b !== 26) break;
  70268. }
  70269. return r;
  70270. };
  70271. BN.prototype.byteLength = function byteLength () {
  70272. return Math.ceil(this.bitLength() / 8);
  70273. };
  70274. BN.prototype.toTwos = function toTwos (width) {
  70275. if (this.negative !== 0) {
  70276. return this.abs().inotn(width).iaddn(1);
  70277. }
  70278. return this.clone();
  70279. };
  70280. BN.prototype.fromTwos = function fromTwos (width) {
  70281. if (this.testn(width - 1)) {
  70282. return this.notn(width).iaddn(1).ineg();
  70283. }
  70284. return this.clone();
  70285. };
  70286. BN.prototype.isNeg = function isNeg () {
  70287. return this.negative !== 0;
  70288. };
  70289. // Return negative clone of `this`
  70290. BN.prototype.neg = function neg () {
  70291. return this.clone().ineg();
  70292. };
  70293. BN.prototype.ineg = function ineg () {
  70294. if (!this.isZero()) {
  70295. this.negative ^= 1;
  70296. }
  70297. return this;
  70298. };
  70299. // Or `num` with `this` in-place
  70300. BN.prototype.iuor = function iuor (num) {
  70301. while (this.length < num.length) {
  70302. this.words[this.length++] = 0;
  70303. }
  70304. for (var i = 0; i < num.length; i++) {
  70305. this.words[i] = this.words[i] | num.words[i];
  70306. }
  70307. return this.strip();
  70308. };
  70309. BN.prototype.ior = function ior (num) {
  70310. assert((this.negative | num.negative) === 0);
  70311. return this.iuor(num);
  70312. };
  70313. // Or `num` with `this`
  70314. BN.prototype.or = function or (num) {
  70315. if (this.length > num.length) return this.clone().ior(num);
  70316. return num.clone().ior(this);
  70317. };
  70318. BN.prototype.uor = function uor (num) {
  70319. if (this.length > num.length) return this.clone().iuor(num);
  70320. return num.clone().iuor(this);
  70321. };
  70322. // And `num` with `this` in-place
  70323. BN.prototype.iuand = function iuand (num) {
  70324. // b = min-length(num, this)
  70325. var b;
  70326. if (this.length > num.length) {
  70327. b = num;
  70328. } else {
  70329. b = this;
  70330. }
  70331. for (var i = 0; i < b.length; i++) {
  70332. this.words[i] = this.words[i] & num.words[i];
  70333. }
  70334. this.length = b.length;
  70335. return this.strip();
  70336. };
  70337. BN.prototype.iand = function iand (num) {
  70338. assert((this.negative | num.negative) === 0);
  70339. return this.iuand(num);
  70340. };
  70341. // And `num` with `this`
  70342. BN.prototype.and = function and (num) {
  70343. if (this.length > num.length) return this.clone().iand(num);
  70344. return num.clone().iand(this);
  70345. };
  70346. BN.prototype.uand = function uand (num) {
  70347. if (this.length > num.length) return this.clone().iuand(num);
  70348. return num.clone().iuand(this);
  70349. };
  70350. // Xor `num` with `this` in-place
  70351. BN.prototype.iuxor = function iuxor (num) {
  70352. // a.length > b.length
  70353. var a;
  70354. var b;
  70355. if (this.length > num.length) {
  70356. a = this;
  70357. b = num;
  70358. } else {
  70359. a = num;
  70360. b = this;
  70361. }
  70362. for (var i = 0; i < b.length; i++) {
  70363. this.words[i] = a.words[i] ^ b.words[i];
  70364. }
  70365. if (this !== a) {
  70366. for (; i < a.length; i++) {
  70367. this.words[i] = a.words[i];
  70368. }
  70369. }
  70370. this.length = a.length;
  70371. return this.strip();
  70372. };
  70373. BN.prototype.ixor = function ixor (num) {
  70374. assert((this.negative | num.negative) === 0);
  70375. return this.iuxor(num);
  70376. };
  70377. // Xor `num` with `this`
  70378. BN.prototype.xor = function xor (num) {
  70379. if (this.length > num.length) return this.clone().ixor(num);
  70380. return num.clone().ixor(this);
  70381. };
  70382. BN.prototype.uxor = function uxor (num) {
  70383. if (this.length > num.length) return this.clone().iuxor(num);
  70384. return num.clone().iuxor(this);
  70385. };
  70386. // Not ``this`` with ``width`` bitwidth
  70387. BN.prototype.inotn = function inotn (width) {
  70388. assert(typeof width === 'number' && width >= 0);
  70389. var bytesNeeded = Math.ceil(width / 26) | 0;
  70390. var bitsLeft = width % 26;
  70391. // Extend the buffer with leading zeroes
  70392. this._expand(bytesNeeded);
  70393. if (bitsLeft > 0) {
  70394. bytesNeeded--;
  70395. }
  70396. // Handle complete words
  70397. for (var i = 0; i < bytesNeeded; i++) {
  70398. this.words[i] = ~this.words[i] & 0x3ffffff;
  70399. }
  70400. // Handle the residue
  70401. if (bitsLeft > 0) {
  70402. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  70403. }
  70404. // And remove leading zeroes
  70405. return this.strip();
  70406. };
  70407. BN.prototype.notn = function notn (width) {
  70408. return this.clone().inotn(width);
  70409. };
  70410. // Set `bit` of `this`
  70411. BN.prototype.setn = function setn (bit, val) {
  70412. assert(typeof bit === 'number' && bit >= 0);
  70413. var off = (bit / 26) | 0;
  70414. var wbit = bit % 26;
  70415. this._expand(off + 1);
  70416. if (val) {
  70417. this.words[off] = this.words[off] | (1 << wbit);
  70418. } else {
  70419. this.words[off] = this.words[off] & ~(1 << wbit);
  70420. }
  70421. return this.strip();
  70422. };
  70423. // Add `num` to `this` in-place
  70424. BN.prototype.iadd = function iadd (num) {
  70425. var r;
  70426. // negative + positive
  70427. if (this.negative !== 0 && num.negative === 0) {
  70428. this.negative = 0;
  70429. r = this.isub(num);
  70430. this.negative ^= 1;
  70431. return this._normSign();
  70432. // positive + negative
  70433. } else if (this.negative === 0 && num.negative !== 0) {
  70434. num.negative = 0;
  70435. r = this.isub(num);
  70436. num.negative = 1;
  70437. return r._normSign();
  70438. }
  70439. // a.length > b.length
  70440. var a, b;
  70441. if (this.length > num.length) {
  70442. a = this;
  70443. b = num;
  70444. } else {
  70445. a = num;
  70446. b = this;
  70447. }
  70448. var carry = 0;
  70449. for (var i = 0; i < b.length; i++) {
  70450. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  70451. this.words[i] = r & 0x3ffffff;
  70452. carry = r >>> 26;
  70453. }
  70454. for (; carry !== 0 && i < a.length; i++) {
  70455. r = (a.words[i] | 0) + carry;
  70456. this.words[i] = r & 0x3ffffff;
  70457. carry = r >>> 26;
  70458. }
  70459. this.length = a.length;
  70460. if (carry !== 0) {
  70461. this.words[this.length] = carry;
  70462. this.length++;
  70463. // Copy the rest of the words
  70464. } else if (a !== this) {
  70465. for (; i < a.length; i++) {
  70466. this.words[i] = a.words[i];
  70467. }
  70468. }
  70469. return this;
  70470. };
  70471. // Add `num` to `this`
  70472. BN.prototype.add = function add (num) {
  70473. var res;
  70474. if (num.negative !== 0 && this.negative === 0) {
  70475. num.negative = 0;
  70476. res = this.sub(num);
  70477. num.negative ^= 1;
  70478. return res;
  70479. } else if (num.negative === 0 && this.negative !== 0) {
  70480. this.negative = 0;
  70481. res = num.sub(this);
  70482. this.negative = 1;
  70483. return res;
  70484. }
  70485. if (this.length > num.length) return this.clone().iadd(num);
  70486. return num.clone().iadd(this);
  70487. };
  70488. // Subtract `num` from `this` in-place
  70489. BN.prototype.isub = function isub (num) {
  70490. // this - (-num) = this + num
  70491. if (num.negative !== 0) {
  70492. num.negative = 0;
  70493. var r = this.iadd(num);
  70494. num.negative = 1;
  70495. return r._normSign();
  70496. // -this - num = -(this + num)
  70497. } else if (this.negative !== 0) {
  70498. this.negative = 0;
  70499. this.iadd(num);
  70500. this.negative = 1;
  70501. return this._normSign();
  70502. }
  70503. // At this point both numbers are positive
  70504. var cmp = this.cmp(num);
  70505. // Optimization - zeroify
  70506. if (cmp === 0) {
  70507. this.negative = 0;
  70508. this.length = 1;
  70509. this.words[0] = 0;
  70510. return this;
  70511. }
  70512. // a > b
  70513. var a, b;
  70514. if (cmp > 0) {
  70515. a = this;
  70516. b = num;
  70517. } else {
  70518. a = num;
  70519. b = this;
  70520. }
  70521. var carry = 0;
  70522. for (var i = 0; i < b.length; i++) {
  70523. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  70524. carry = r >> 26;
  70525. this.words[i] = r & 0x3ffffff;
  70526. }
  70527. for (; carry !== 0 && i < a.length; i++) {
  70528. r = (a.words[i] | 0) + carry;
  70529. carry = r >> 26;
  70530. this.words[i] = r & 0x3ffffff;
  70531. }
  70532. // Copy rest of the words
  70533. if (carry === 0 && i < a.length && a !== this) {
  70534. for (; i < a.length; i++) {
  70535. this.words[i] = a.words[i];
  70536. }
  70537. }
  70538. this.length = Math.max(this.length, i);
  70539. if (a !== this) {
  70540. this.negative = 1;
  70541. }
  70542. return this.strip();
  70543. };
  70544. // Subtract `num` from `this`
  70545. BN.prototype.sub = function sub (num) {
  70546. return this.clone().isub(num);
  70547. };
  70548. function smallMulTo (self, num, out) {
  70549. out.negative = num.negative ^ self.negative;
  70550. var len = (self.length + num.length) | 0;
  70551. out.length = len;
  70552. len = (len - 1) | 0;
  70553. // Peel one iteration (compiler can't do it, because of code complexity)
  70554. var a = self.words[0] | 0;
  70555. var b = num.words[0] | 0;
  70556. var r = a * b;
  70557. var lo = r & 0x3ffffff;
  70558. var carry = (r / 0x4000000) | 0;
  70559. out.words[0] = lo;
  70560. for (var k = 1; k < len; k++) {
  70561. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  70562. // note that ncarry could be >= 0x3ffffff
  70563. var ncarry = carry >>> 26;
  70564. var rword = carry & 0x3ffffff;
  70565. var maxJ = Math.min(k, num.length - 1);
  70566. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  70567. var i = (k - j) | 0;
  70568. a = self.words[i] | 0;
  70569. b = num.words[j] | 0;
  70570. r = a * b + rword;
  70571. ncarry += (r / 0x4000000) | 0;
  70572. rword = r & 0x3ffffff;
  70573. }
  70574. out.words[k] = rword | 0;
  70575. carry = ncarry | 0;
  70576. }
  70577. if (carry !== 0) {
  70578. out.words[k] = carry | 0;
  70579. } else {
  70580. out.length--;
  70581. }
  70582. return out.strip();
  70583. }
  70584. // TODO(indutny): it may be reasonable to omit it for users who don't need
  70585. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  70586. // multiplication (like elliptic secp256k1).
  70587. var comb10MulTo = function comb10MulTo (self, num, out) {
  70588. var a = self.words;
  70589. var b = num.words;
  70590. var o = out.words;
  70591. var c = 0;
  70592. var lo;
  70593. var mid;
  70594. var hi;
  70595. var a0 = a[0] | 0;
  70596. var al0 = a0 & 0x1fff;
  70597. var ah0 = a0 >>> 13;
  70598. var a1 = a[1] | 0;
  70599. var al1 = a1 & 0x1fff;
  70600. var ah1 = a1 >>> 13;
  70601. var a2 = a[2] | 0;
  70602. var al2 = a2 & 0x1fff;
  70603. var ah2 = a2 >>> 13;
  70604. var a3 = a[3] | 0;
  70605. var al3 = a3 & 0x1fff;
  70606. var ah3 = a3 >>> 13;
  70607. var a4 = a[4] | 0;
  70608. var al4 = a4 & 0x1fff;
  70609. var ah4 = a4 >>> 13;
  70610. var a5 = a[5] | 0;
  70611. var al5 = a5 & 0x1fff;
  70612. var ah5 = a5 >>> 13;
  70613. var a6 = a[6] | 0;
  70614. var al6 = a6 & 0x1fff;
  70615. var ah6 = a6 >>> 13;
  70616. var a7 = a[7] | 0;
  70617. var al7 = a7 & 0x1fff;
  70618. var ah7 = a7 >>> 13;
  70619. var a8 = a[8] | 0;
  70620. var al8 = a8 & 0x1fff;
  70621. var ah8 = a8 >>> 13;
  70622. var a9 = a[9] | 0;
  70623. var al9 = a9 & 0x1fff;
  70624. var ah9 = a9 >>> 13;
  70625. var b0 = b[0] | 0;
  70626. var bl0 = b0 & 0x1fff;
  70627. var bh0 = b0 >>> 13;
  70628. var b1 = b[1] | 0;
  70629. var bl1 = b1 & 0x1fff;
  70630. var bh1 = b1 >>> 13;
  70631. var b2 = b[2] | 0;
  70632. var bl2 = b2 & 0x1fff;
  70633. var bh2 = b2 >>> 13;
  70634. var b3 = b[3] | 0;
  70635. var bl3 = b3 & 0x1fff;
  70636. var bh3 = b3 >>> 13;
  70637. var b4 = b[4] | 0;
  70638. var bl4 = b4 & 0x1fff;
  70639. var bh4 = b4 >>> 13;
  70640. var b5 = b[5] | 0;
  70641. var bl5 = b5 & 0x1fff;
  70642. var bh5 = b5 >>> 13;
  70643. var b6 = b[6] | 0;
  70644. var bl6 = b6 & 0x1fff;
  70645. var bh6 = b6 >>> 13;
  70646. var b7 = b[7] | 0;
  70647. var bl7 = b7 & 0x1fff;
  70648. var bh7 = b7 >>> 13;
  70649. var b8 = b[8] | 0;
  70650. var bl8 = b8 & 0x1fff;
  70651. var bh8 = b8 >>> 13;
  70652. var b9 = b[9] | 0;
  70653. var bl9 = b9 & 0x1fff;
  70654. var bh9 = b9 >>> 13;
  70655. out.negative = self.negative ^ num.negative;
  70656. out.length = 19;
  70657. /* k = 0 */
  70658. lo = Math.imul(al0, bl0);
  70659. mid = Math.imul(al0, bh0);
  70660. mid = (mid + Math.imul(ah0, bl0)) | 0;
  70661. hi = Math.imul(ah0, bh0);
  70662. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70663. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  70664. w0 &= 0x3ffffff;
  70665. /* k = 1 */
  70666. lo = Math.imul(al1, bl0);
  70667. mid = Math.imul(al1, bh0);
  70668. mid = (mid + Math.imul(ah1, bl0)) | 0;
  70669. hi = Math.imul(ah1, bh0);
  70670. lo = (lo + Math.imul(al0, bl1)) | 0;
  70671. mid = (mid + Math.imul(al0, bh1)) | 0;
  70672. mid = (mid + Math.imul(ah0, bl1)) | 0;
  70673. hi = (hi + Math.imul(ah0, bh1)) | 0;
  70674. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70675. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  70676. w1 &= 0x3ffffff;
  70677. /* k = 2 */
  70678. lo = Math.imul(al2, bl0);
  70679. mid = Math.imul(al2, bh0);
  70680. mid = (mid + Math.imul(ah2, bl0)) | 0;
  70681. hi = Math.imul(ah2, bh0);
  70682. lo = (lo + Math.imul(al1, bl1)) | 0;
  70683. mid = (mid + Math.imul(al1, bh1)) | 0;
  70684. mid = (mid + Math.imul(ah1, bl1)) | 0;
  70685. hi = (hi + Math.imul(ah1, bh1)) | 0;
  70686. lo = (lo + Math.imul(al0, bl2)) | 0;
  70687. mid = (mid + Math.imul(al0, bh2)) | 0;
  70688. mid = (mid + Math.imul(ah0, bl2)) | 0;
  70689. hi = (hi + Math.imul(ah0, bh2)) | 0;
  70690. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70691. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  70692. w2 &= 0x3ffffff;
  70693. /* k = 3 */
  70694. lo = Math.imul(al3, bl0);
  70695. mid = Math.imul(al3, bh0);
  70696. mid = (mid + Math.imul(ah3, bl0)) | 0;
  70697. hi = Math.imul(ah3, bh0);
  70698. lo = (lo + Math.imul(al2, bl1)) | 0;
  70699. mid = (mid + Math.imul(al2, bh1)) | 0;
  70700. mid = (mid + Math.imul(ah2, bl1)) | 0;
  70701. hi = (hi + Math.imul(ah2, bh1)) | 0;
  70702. lo = (lo + Math.imul(al1, bl2)) | 0;
  70703. mid = (mid + Math.imul(al1, bh2)) | 0;
  70704. mid = (mid + Math.imul(ah1, bl2)) | 0;
  70705. hi = (hi + Math.imul(ah1, bh2)) | 0;
  70706. lo = (lo + Math.imul(al0, bl3)) | 0;
  70707. mid = (mid + Math.imul(al0, bh3)) | 0;
  70708. mid = (mid + Math.imul(ah0, bl3)) | 0;
  70709. hi = (hi + Math.imul(ah0, bh3)) | 0;
  70710. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70711. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  70712. w3 &= 0x3ffffff;
  70713. /* k = 4 */
  70714. lo = Math.imul(al4, bl0);
  70715. mid = Math.imul(al4, bh0);
  70716. mid = (mid + Math.imul(ah4, bl0)) | 0;
  70717. hi = Math.imul(ah4, bh0);
  70718. lo = (lo + Math.imul(al3, bl1)) | 0;
  70719. mid = (mid + Math.imul(al3, bh1)) | 0;
  70720. mid = (mid + Math.imul(ah3, bl1)) | 0;
  70721. hi = (hi + Math.imul(ah3, bh1)) | 0;
  70722. lo = (lo + Math.imul(al2, bl2)) | 0;
  70723. mid = (mid + Math.imul(al2, bh2)) | 0;
  70724. mid = (mid + Math.imul(ah2, bl2)) | 0;
  70725. hi = (hi + Math.imul(ah2, bh2)) | 0;
  70726. lo = (lo + Math.imul(al1, bl3)) | 0;
  70727. mid = (mid + Math.imul(al1, bh3)) | 0;
  70728. mid = (mid + Math.imul(ah1, bl3)) | 0;
  70729. hi = (hi + Math.imul(ah1, bh3)) | 0;
  70730. lo = (lo + Math.imul(al0, bl4)) | 0;
  70731. mid = (mid + Math.imul(al0, bh4)) | 0;
  70732. mid = (mid + Math.imul(ah0, bl4)) | 0;
  70733. hi = (hi + Math.imul(ah0, bh4)) | 0;
  70734. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70735. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  70736. w4 &= 0x3ffffff;
  70737. /* k = 5 */
  70738. lo = Math.imul(al5, bl0);
  70739. mid = Math.imul(al5, bh0);
  70740. mid = (mid + Math.imul(ah5, bl0)) | 0;
  70741. hi = Math.imul(ah5, bh0);
  70742. lo = (lo + Math.imul(al4, bl1)) | 0;
  70743. mid = (mid + Math.imul(al4, bh1)) | 0;
  70744. mid = (mid + Math.imul(ah4, bl1)) | 0;
  70745. hi = (hi + Math.imul(ah4, bh1)) | 0;
  70746. lo = (lo + Math.imul(al3, bl2)) | 0;
  70747. mid = (mid + Math.imul(al3, bh2)) | 0;
  70748. mid = (mid + Math.imul(ah3, bl2)) | 0;
  70749. hi = (hi + Math.imul(ah3, bh2)) | 0;
  70750. lo = (lo + Math.imul(al2, bl3)) | 0;
  70751. mid = (mid + Math.imul(al2, bh3)) | 0;
  70752. mid = (mid + Math.imul(ah2, bl3)) | 0;
  70753. hi = (hi + Math.imul(ah2, bh3)) | 0;
  70754. lo = (lo + Math.imul(al1, bl4)) | 0;
  70755. mid = (mid + Math.imul(al1, bh4)) | 0;
  70756. mid = (mid + Math.imul(ah1, bl4)) | 0;
  70757. hi = (hi + Math.imul(ah1, bh4)) | 0;
  70758. lo = (lo + Math.imul(al0, bl5)) | 0;
  70759. mid = (mid + Math.imul(al0, bh5)) | 0;
  70760. mid = (mid + Math.imul(ah0, bl5)) | 0;
  70761. hi = (hi + Math.imul(ah0, bh5)) | 0;
  70762. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70763. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  70764. w5 &= 0x3ffffff;
  70765. /* k = 6 */
  70766. lo = Math.imul(al6, bl0);
  70767. mid = Math.imul(al6, bh0);
  70768. mid = (mid + Math.imul(ah6, bl0)) | 0;
  70769. hi = Math.imul(ah6, bh0);
  70770. lo = (lo + Math.imul(al5, bl1)) | 0;
  70771. mid = (mid + Math.imul(al5, bh1)) | 0;
  70772. mid = (mid + Math.imul(ah5, bl1)) | 0;
  70773. hi = (hi + Math.imul(ah5, bh1)) | 0;
  70774. lo = (lo + Math.imul(al4, bl2)) | 0;
  70775. mid = (mid + Math.imul(al4, bh2)) | 0;
  70776. mid = (mid + Math.imul(ah4, bl2)) | 0;
  70777. hi = (hi + Math.imul(ah4, bh2)) | 0;
  70778. lo = (lo + Math.imul(al3, bl3)) | 0;
  70779. mid = (mid + Math.imul(al3, bh3)) | 0;
  70780. mid = (mid + Math.imul(ah3, bl3)) | 0;
  70781. hi = (hi + Math.imul(ah3, bh3)) | 0;
  70782. lo = (lo + Math.imul(al2, bl4)) | 0;
  70783. mid = (mid + Math.imul(al2, bh4)) | 0;
  70784. mid = (mid + Math.imul(ah2, bl4)) | 0;
  70785. hi = (hi + Math.imul(ah2, bh4)) | 0;
  70786. lo = (lo + Math.imul(al1, bl5)) | 0;
  70787. mid = (mid + Math.imul(al1, bh5)) | 0;
  70788. mid = (mid + Math.imul(ah1, bl5)) | 0;
  70789. hi = (hi + Math.imul(ah1, bh5)) | 0;
  70790. lo = (lo + Math.imul(al0, bl6)) | 0;
  70791. mid = (mid + Math.imul(al0, bh6)) | 0;
  70792. mid = (mid + Math.imul(ah0, bl6)) | 0;
  70793. hi = (hi + Math.imul(ah0, bh6)) | 0;
  70794. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70795. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  70796. w6 &= 0x3ffffff;
  70797. /* k = 7 */
  70798. lo = Math.imul(al7, bl0);
  70799. mid = Math.imul(al7, bh0);
  70800. mid = (mid + Math.imul(ah7, bl0)) | 0;
  70801. hi = Math.imul(ah7, bh0);
  70802. lo = (lo + Math.imul(al6, bl1)) | 0;
  70803. mid = (mid + Math.imul(al6, bh1)) | 0;
  70804. mid = (mid + Math.imul(ah6, bl1)) | 0;
  70805. hi = (hi + Math.imul(ah6, bh1)) | 0;
  70806. lo = (lo + Math.imul(al5, bl2)) | 0;
  70807. mid = (mid + Math.imul(al5, bh2)) | 0;
  70808. mid = (mid + Math.imul(ah5, bl2)) | 0;
  70809. hi = (hi + Math.imul(ah5, bh2)) | 0;
  70810. lo = (lo + Math.imul(al4, bl3)) | 0;
  70811. mid = (mid + Math.imul(al4, bh3)) | 0;
  70812. mid = (mid + Math.imul(ah4, bl3)) | 0;
  70813. hi = (hi + Math.imul(ah4, bh3)) | 0;
  70814. lo = (lo + Math.imul(al3, bl4)) | 0;
  70815. mid = (mid + Math.imul(al3, bh4)) | 0;
  70816. mid = (mid + Math.imul(ah3, bl4)) | 0;
  70817. hi = (hi + Math.imul(ah3, bh4)) | 0;
  70818. lo = (lo + Math.imul(al2, bl5)) | 0;
  70819. mid = (mid + Math.imul(al2, bh5)) | 0;
  70820. mid = (mid + Math.imul(ah2, bl5)) | 0;
  70821. hi = (hi + Math.imul(ah2, bh5)) | 0;
  70822. lo = (lo + Math.imul(al1, bl6)) | 0;
  70823. mid = (mid + Math.imul(al1, bh6)) | 0;
  70824. mid = (mid + Math.imul(ah1, bl6)) | 0;
  70825. hi = (hi + Math.imul(ah1, bh6)) | 0;
  70826. lo = (lo + Math.imul(al0, bl7)) | 0;
  70827. mid = (mid + Math.imul(al0, bh7)) | 0;
  70828. mid = (mid + Math.imul(ah0, bl7)) | 0;
  70829. hi = (hi + Math.imul(ah0, bh7)) | 0;
  70830. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70831. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  70832. w7 &= 0x3ffffff;
  70833. /* k = 8 */
  70834. lo = Math.imul(al8, bl0);
  70835. mid = Math.imul(al8, bh0);
  70836. mid = (mid + Math.imul(ah8, bl0)) | 0;
  70837. hi = Math.imul(ah8, bh0);
  70838. lo = (lo + Math.imul(al7, bl1)) | 0;
  70839. mid = (mid + Math.imul(al7, bh1)) | 0;
  70840. mid = (mid + Math.imul(ah7, bl1)) | 0;
  70841. hi = (hi + Math.imul(ah7, bh1)) | 0;
  70842. lo = (lo + Math.imul(al6, bl2)) | 0;
  70843. mid = (mid + Math.imul(al6, bh2)) | 0;
  70844. mid = (mid + Math.imul(ah6, bl2)) | 0;
  70845. hi = (hi + Math.imul(ah6, bh2)) | 0;
  70846. lo = (lo + Math.imul(al5, bl3)) | 0;
  70847. mid = (mid + Math.imul(al5, bh3)) | 0;
  70848. mid = (mid + Math.imul(ah5, bl3)) | 0;
  70849. hi = (hi + Math.imul(ah5, bh3)) | 0;
  70850. lo = (lo + Math.imul(al4, bl4)) | 0;
  70851. mid = (mid + Math.imul(al4, bh4)) | 0;
  70852. mid = (mid + Math.imul(ah4, bl4)) | 0;
  70853. hi = (hi + Math.imul(ah4, bh4)) | 0;
  70854. lo = (lo + Math.imul(al3, bl5)) | 0;
  70855. mid = (mid + Math.imul(al3, bh5)) | 0;
  70856. mid = (mid + Math.imul(ah3, bl5)) | 0;
  70857. hi = (hi + Math.imul(ah3, bh5)) | 0;
  70858. lo = (lo + Math.imul(al2, bl6)) | 0;
  70859. mid = (mid + Math.imul(al2, bh6)) | 0;
  70860. mid = (mid + Math.imul(ah2, bl6)) | 0;
  70861. hi = (hi + Math.imul(ah2, bh6)) | 0;
  70862. lo = (lo + Math.imul(al1, bl7)) | 0;
  70863. mid = (mid + Math.imul(al1, bh7)) | 0;
  70864. mid = (mid + Math.imul(ah1, bl7)) | 0;
  70865. hi = (hi + Math.imul(ah1, bh7)) | 0;
  70866. lo = (lo + Math.imul(al0, bl8)) | 0;
  70867. mid = (mid + Math.imul(al0, bh8)) | 0;
  70868. mid = (mid + Math.imul(ah0, bl8)) | 0;
  70869. hi = (hi + Math.imul(ah0, bh8)) | 0;
  70870. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70871. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  70872. w8 &= 0x3ffffff;
  70873. /* k = 9 */
  70874. lo = Math.imul(al9, bl0);
  70875. mid = Math.imul(al9, bh0);
  70876. mid = (mid + Math.imul(ah9, bl0)) | 0;
  70877. hi = Math.imul(ah9, bh0);
  70878. lo = (lo + Math.imul(al8, bl1)) | 0;
  70879. mid = (mid + Math.imul(al8, bh1)) | 0;
  70880. mid = (mid + Math.imul(ah8, bl1)) | 0;
  70881. hi = (hi + Math.imul(ah8, bh1)) | 0;
  70882. lo = (lo + Math.imul(al7, bl2)) | 0;
  70883. mid = (mid + Math.imul(al7, bh2)) | 0;
  70884. mid = (mid + Math.imul(ah7, bl2)) | 0;
  70885. hi = (hi + Math.imul(ah7, bh2)) | 0;
  70886. lo = (lo + Math.imul(al6, bl3)) | 0;
  70887. mid = (mid + Math.imul(al6, bh3)) | 0;
  70888. mid = (mid + Math.imul(ah6, bl3)) | 0;
  70889. hi = (hi + Math.imul(ah6, bh3)) | 0;
  70890. lo = (lo + Math.imul(al5, bl4)) | 0;
  70891. mid = (mid + Math.imul(al5, bh4)) | 0;
  70892. mid = (mid + Math.imul(ah5, bl4)) | 0;
  70893. hi = (hi + Math.imul(ah5, bh4)) | 0;
  70894. lo = (lo + Math.imul(al4, bl5)) | 0;
  70895. mid = (mid + Math.imul(al4, bh5)) | 0;
  70896. mid = (mid + Math.imul(ah4, bl5)) | 0;
  70897. hi = (hi + Math.imul(ah4, bh5)) | 0;
  70898. lo = (lo + Math.imul(al3, bl6)) | 0;
  70899. mid = (mid + Math.imul(al3, bh6)) | 0;
  70900. mid = (mid + Math.imul(ah3, bl6)) | 0;
  70901. hi = (hi + Math.imul(ah3, bh6)) | 0;
  70902. lo = (lo + Math.imul(al2, bl7)) | 0;
  70903. mid = (mid + Math.imul(al2, bh7)) | 0;
  70904. mid = (mid + Math.imul(ah2, bl7)) | 0;
  70905. hi = (hi + Math.imul(ah2, bh7)) | 0;
  70906. lo = (lo + Math.imul(al1, bl8)) | 0;
  70907. mid = (mid + Math.imul(al1, bh8)) | 0;
  70908. mid = (mid + Math.imul(ah1, bl8)) | 0;
  70909. hi = (hi + Math.imul(ah1, bh8)) | 0;
  70910. lo = (lo + Math.imul(al0, bl9)) | 0;
  70911. mid = (mid + Math.imul(al0, bh9)) | 0;
  70912. mid = (mid + Math.imul(ah0, bl9)) | 0;
  70913. hi = (hi + Math.imul(ah0, bh9)) | 0;
  70914. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70915. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  70916. w9 &= 0x3ffffff;
  70917. /* k = 10 */
  70918. lo = Math.imul(al9, bl1);
  70919. mid = Math.imul(al9, bh1);
  70920. mid = (mid + Math.imul(ah9, bl1)) | 0;
  70921. hi = Math.imul(ah9, bh1);
  70922. lo = (lo + Math.imul(al8, bl2)) | 0;
  70923. mid = (mid + Math.imul(al8, bh2)) | 0;
  70924. mid = (mid + Math.imul(ah8, bl2)) | 0;
  70925. hi = (hi + Math.imul(ah8, bh2)) | 0;
  70926. lo = (lo + Math.imul(al7, bl3)) | 0;
  70927. mid = (mid + Math.imul(al7, bh3)) | 0;
  70928. mid = (mid + Math.imul(ah7, bl3)) | 0;
  70929. hi = (hi + Math.imul(ah7, bh3)) | 0;
  70930. lo = (lo + Math.imul(al6, bl4)) | 0;
  70931. mid = (mid + Math.imul(al6, bh4)) | 0;
  70932. mid = (mid + Math.imul(ah6, bl4)) | 0;
  70933. hi = (hi + Math.imul(ah6, bh4)) | 0;
  70934. lo = (lo + Math.imul(al5, bl5)) | 0;
  70935. mid = (mid + Math.imul(al5, bh5)) | 0;
  70936. mid = (mid + Math.imul(ah5, bl5)) | 0;
  70937. hi = (hi + Math.imul(ah5, bh5)) | 0;
  70938. lo = (lo + Math.imul(al4, bl6)) | 0;
  70939. mid = (mid + Math.imul(al4, bh6)) | 0;
  70940. mid = (mid + Math.imul(ah4, bl6)) | 0;
  70941. hi = (hi + Math.imul(ah4, bh6)) | 0;
  70942. lo = (lo + Math.imul(al3, bl7)) | 0;
  70943. mid = (mid + Math.imul(al3, bh7)) | 0;
  70944. mid = (mid + Math.imul(ah3, bl7)) | 0;
  70945. hi = (hi + Math.imul(ah3, bh7)) | 0;
  70946. lo = (lo + Math.imul(al2, bl8)) | 0;
  70947. mid = (mid + Math.imul(al2, bh8)) | 0;
  70948. mid = (mid + Math.imul(ah2, bl8)) | 0;
  70949. hi = (hi + Math.imul(ah2, bh8)) | 0;
  70950. lo = (lo + Math.imul(al1, bl9)) | 0;
  70951. mid = (mid + Math.imul(al1, bh9)) | 0;
  70952. mid = (mid + Math.imul(ah1, bl9)) | 0;
  70953. hi = (hi + Math.imul(ah1, bh9)) | 0;
  70954. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70955. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  70956. w10 &= 0x3ffffff;
  70957. /* k = 11 */
  70958. lo = Math.imul(al9, bl2);
  70959. mid = Math.imul(al9, bh2);
  70960. mid = (mid + Math.imul(ah9, bl2)) | 0;
  70961. hi = Math.imul(ah9, bh2);
  70962. lo = (lo + Math.imul(al8, bl3)) | 0;
  70963. mid = (mid + Math.imul(al8, bh3)) | 0;
  70964. mid = (mid + Math.imul(ah8, bl3)) | 0;
  70965. hi = (hi + Math.imul(ah8, bh3)) | 0;
  70966. lo = (lo + Math.imul(al7, bl4)) | 0;
  70967. mid = (mid + Math.imul(al7, bh4)) | 0;
  70968. mid = (mid + Math.imul(ah7, bl4)) | 0;
  70969. hi = (hi + Math.imul(ah7, bh4)) | 0;
  70970. lo = (lo + Math.imul(al6, bl5)) | 0;
  70971. mid = (mid + Math.imul(al6, bh5)) | 0;
  70972. mid = (mid + Math.imul(ah6, bl5)) | 0;
  70973. hi = (hi + Math.imul(ah6, bh5)) | 0;
  70974. lo = (lo + Math.imul(al5, bl6)) | 0;
  70975. mid = (mid + Math.imul(al5, bh6)) | 0;
  70976. mid = (mid + Math.imul(ah5, bl6)) | 0;
  70977. hi = (hi + Math.imul(ah5, bh6)) | 0;
  70978. lo = (lo + Math.imul(al4, bl7)) | 0;
  70979. mid = (mid + Math.imul(al4, bh7)) | 0;
  70980. mid = (mid + Math.imul(ah4, bl7)) | 0;
  70981. hi = (hi + Math.imul(ah4, bh7)) | 0;
  70982. lo = (lo + Math.imul(al3, bl8)) | 0;
  70983. mid = (mid + Math.imul(al3, bh8)) | 0;
  70984. mid = (mid + Math.imul(ah3, bl8)) | 0;
  70985. hi = (hi + Math.imul(ah3, bh8)) | 0;
  70986. lo = (lo + Math.imul(al2, bl9)) | 0;
  70987. mid = (mid + Math.imul(al2, bh9)) | 0;
  70988. mid = (mid + Math.imul(ah2, bl9)) | 0;
  70989. hi = (hi + Math.imul(ah2, bh9)) | 0;
  70990. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  70991. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  70992. w11 &= 0x3ffffff;
  70993. /* k = 12 */
  70994. lo = Math.imul(al9, bl3);
  70995. mid = Math.imul(al9, bh3);
  70996. mid = (mid + Math.imul(ah9, bl3)) | 0;
  70997. hi = Math.imul(ah9, bh3);
  70998. lo = (lo + Math.imul(al8, bl4)) | 0;
  70999. mid = (mid + Math.imul(al8, bh4)) | 0;
  71000. mid = (mid + Math.imul(ah8, bl4)) | 0;
  71001. hi = (hi + Math.imul(ah8, bh4)) | 0;
  71002. lo = (lo + Math.imul(al7, bl5)) | 0;
  71003. mid = (mid + Math.imul(al7, bh5)) | 0;
  71004. mid = (mid + Math.imul(ah7, bl5)) | 0;
  71005. hi = (hi + Math.imul(ah7, bh5)) | 0;
  71006. lo = (lo + Math.imul(al6, bl6)) | 0;
  71007. mid = (mid + Math.imul(al6, bh6)) | 0;
  71008. mid = (mid + Math.imul(ah6, bl6)) | 0;
  71009. hi = (hi + Math.imul(ah6, bh6)) | 0;
  71010. lo = (lo + Math.imul(al5, bl7)) | 0;
  71011. mid = (mid + Math.imul(al5, bh7)) | 0;
  71012. mid = (mid + Math.imul(ah5, bl7)) | 0;
  71013. hi = (hi + Math.imul(ah5, bh7)) | 0;
  71014. lo = (lo + Math.imul(al4, bl8)) | 0;
  71015. mid = (mid + Math.imul(al4, bh8)) | 0;
  71016. mid = (mid + Math.imul(ah4, bl8)) | 0;
  71017. hi = (hi + Math.imul(ah4, bh8)) | 0;
  71018. lo = (lo + Math.imul(al3, bl9)) | 0;
  71019. mid = (mid + Math.imul(al3, bh9)) | 0;
  71020. mid = (mid + Math.imul(ah3, bl9)) | 0;
  71021. hi = (hi + Math.imul(ah3, bh9)) | 0;
  71022. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71023. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  71024. w12 &= 0x3ffffff;
  71025. /* k = 13 */
  71026. lo = Math.imul(al9, bl4);
  71027. mid = Math.imul(al9, bh4);
  71028. mid = (mid + Math.imul(ah9, bl4)) | 0;
  71029. hi = Math.imul(ah9, bh4);
  71030. lo = (lo + Math.imul(al8, bl5)) | 0;
  71031. mid = (mid + Math.imul(al8, bh5)) | 0;
  71032. mid = (mid + Math.imul(ah8, bl5)) | 0;
  71033. hi = (hi + Math.imul(ah8, bh5)) | 0;
  71034. lo = (lo + Math.imul(al7, bl6)) | 0;
  71035. mid = (mid + Math.imul(al7, bh6)) | 0;
  71036. mid = (mid + Math.imul(ah7, bl6)) | 0;
  71037. hi = (hi + Math.imul(ah7, bh6)) | 0;
  71038. lo = (lo + Math.imul(al6, bl7)) | 0;
  71039. mid = (mid + Math.imul(al6, bh7)) | 0;
  71040. mid = (mid + Math.imul(ah6, bl7)) | 0;
  71041. hi = (hi + Math.imul(ah6, bh7)) | 0;
  71042. lo = (lo + Math.imul(al5, bl8)) | 0;
  71043. mid = (mid + Math.imul(al5, bh8)) | 0;
  71044. mid = (mid + Math.imul(ah5, bl8)) | 0;
  71045. hi = (hi + Math.imul(ah5, bh8)) | 0;
  71046. lo = (lo + Math.imul(al4, bl9)) | 0;
  71047. mid = (mid + Math.imul(al4, bh9)) | 0;
  71048. mid = (mid + Math.imul(ah4, bl9)) | 0;
  71049. hi = (hi + Math.imul(ah4, bh9)) | 0;
  71050. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71051. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  71052. w13 &= 0x3ffffff;
  71053. /* k = 14 */
  71054. lo = Math.imul(al9, bl5);
  71055. mid = Math.imul(al9, bh5);
  71056. mid = (mid + Math.imul(ah9, bl5)) | 0;
  71057. hi = Math.imul(ah9, bh5);
  71058. lo = (lo + Math.imul(al8, bl6)) | 0;
  71059. mid = (mid + Math.imul(al8, bh6)) | 0;
  71060. mid = (mid + Math.imul(ah8, bl6)) | 0;
  71061. hi = (hi + Math.imul(ah8, bh6)) | 0;
  71062. lo = (lo + Math.imul(al7, bl7)) | 0;
  71063. mid = (mid + Math.imul(al7, bh7)) | 0;
  71064. mid = (mid + Math.imul(ah7, bl7)) | 0;
  71065. hi = (hi + Math.imul(ah7, bh7)) | 0;
  71066. lo = (lo + Math.imul(al6, bl8)) | 0;
  71067. mid = (mid + Math.imul(al6, bh8)) | 0;
  71068. mid = (mid + Math.imul(ah6, bl8)) | 0;
  71069. hi = (hi + Math.imul(ah6, bh8)) | 0;
  71070. lo = (lo + Math.imul(al5, bl9)) | 0;
  71071. mid = (mid + Math.imul(al5, bh9)) | 0;
  71072. mid = (mid + Math.imul(ah5, bl9)) | 0;
  71073. hi = (hi + Math.imul(ah5, bh9)) | 0;
  71074. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71075. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  71076. w14 &= 0x3ffffff;
  71077. /* k = 15 */
  71078. lo = Math.imul(al9, bl6);
  71079. mid = Math.imul(al9, bh6);
  71080. mid = (mid + Math.imul(ah9, bl6)) | 0;
  71081. hi = Math.imul(ah9, bh6);
  71082. lo = (lo + Math.imul(al8, bl7)) | 0;
  71083. mid = (mid + Math.imul(al8, bh7)) | 0;
  71084. mid = (mid + Math.imul(ah8, bl7)) | 0;
  71085. hi = (hi + Math.imul(ah8, bh7)) | 0;
  71086. lo = (lo + Math.imul(al7, bl8)) | 0;
  71087. mid = (mid + Math.imul(al7, bh8)) | 0;
  71088. mid = (mid + Math.imul(ah7, bl8)) | 0;
  71089. hi = (hi + Math.imul(ah7, bh8)) | 0;
  71090. lo = (lo + Math.imul(al6, bl9)) | 0;
  71091. mid = (mid + Math.imul(al6, bh9)) | 0;
  71092. mid = (mid + Math.imul(ah6, bl9)) | 0;
  71093. hi = (hi + Math.imul(ah6, bh9)) | 0;
  71094. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71095. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  71096. w15 &= 0x3ffffff;
  71097. /* k = 16 */
  71098. lo = Math.imul(al9, bl7);
  71099. mid = Math.imul(al9, bh7);
  71100. mid = (mid + Math.imul(ah9, bl7)) | 0;
  71101. hi = Math.imul(ah9, bh7);
  71102. lo = (lo + Math.imul(al8, bl8)) | 0;
  71103. mid = (mid + Math.imul(al8, bh8)) | 0;
  71104. mid = (mid + Math.imul(ah8, bl8)) | 0;
  71105. hi = (hi + Math.imul(ah8, bh8)) | 0;
  71106. lo = (lo + Math.imul(al7, bl9)) | 0;
  71107. mid = (mid + Math.imul(al7, bh9)) | 0;
  71108. mid = (mid + Math.imul(ah7, bl9)) | 0;
  71109. hi = (hi + Math.imul(ah7, bh9)) | 0;
  71110. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71111. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  71112. w16 &= 0x3ffffff;
  71113. /* k = 17 */
  71114. lo = Math.imul(al9, bl8);
  71115. mid = Math.imul(al9, bh8);
  71116. mid = (mid + Math.imul(ah9, bl8)) | 0;
  71117. hi = Math.imul(ah9, bh8);
  71118. lo = (lo + Math.imul(al8, bl9)) | 0;
  71119. mid = (mid + Math.imul(al8, bh9)) | 0;
  71120. mid = (mid + Math.imul(ah8, bl9)) | 0;
  71121. hi = (hi + Math.imul(ah8, bh9)) | 0;
  71122. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71123. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  71124. w17 &= 0x3ffffff;
  71125. /* k = 18 */
  71126. lo = Math.imul(al9, bl9);
  71127. mid = Math.imul(al9, bh9);
  71128. mid = (mid + Math.imul(ah9, bl9)) | 0;
  71129. hi = Math.imul(ah9, bh9);
  71130. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  71131. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  71132. w18 &= 0x3ffffff;
  71133. o[0] = w0;
  71134. o[1] = w1;
  71135. o[2] = w2;
  71136. o[3] = w3;
  71137. o[4] = w4;
  71138. o[5] = w5;
  71139. o[6] = w6;
  71140. o[7] = w7;
  71141. o[8] = w8;
  71142. o[9] = w9;
  71143. o[10] = w10;
  71144. o[11] = w11;
  71145. o[12] = w12;
  71146. o[13] = w13;
  71147. o[14] = w14;
  71148. o[15] = w15;
  71149. o[16] = w16;
  71150. o[17] = w17;
  71151. o[18] = w18;
  71152. if (c !== 0) {
  71153. o[19] = c;
  71154. out.length++;
  71155. }
  71156. return out;
  71157. };
  71158. // Polyfill comb
  71159. if (!Math.imul) {
  71160. comb10MulTo = smallMulTo;
  71161. }
  71162. function bigMulTo (self, num, out) {
  71163. out.negative = num.negative ^ self.negative;
  71164. out.length = self.length + num.length;
  71165. var carry = 0;
  71166. var hncarry = 0;
  71167. for (var k = 0; k < out.length - 1; k++) {
  71168. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  71169. // note that ncarry could be >= 0x3ffffff
  71170. var ncarry = hncarry;
  71171. hncarry = 0;
  71172. var rword = carry & 0x3ffffff;
  71173. var maxJ = Math.min(k, num.length - 1);
  71174. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  71175. var i = k - j;
  71176. var a = self.words[i] | 0;
  71177. var b = num.words[j] | 0;
  71178. var r = a * b;
  71179. var lo = r & 0x3ffffff;
  71180. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  71181. lo = (lo + rword) | 0;
  71182. rword = lo & 0x3ffffff;
  71183. ncarry = (ncarry + (lo >>> 26)) | 0;
  71184. hncarry += ncarry >>> 26;
  71185. ncarry &= 0x3ffffff;
  71186. }
  71187. out.words[k] = rword;
  71188. carry = ncarry;
  71189. ncarry = hncarry;
  71190. }
  71191. if (carry !== 0) {
  71192. out.words[k] = carry;
  71193. } else {
  71194. out.length--;
  71195. }
  71196. return out.strip();
  71197. }
  71198. function jumboMulTo (self, num, out) {
  71199. var fftm = new FFTM();
  71200. return fftm.mulp(self, num, out);
  71201. }
  71202. BN.prototype.mulTo = function mulTo (num, out) {
  71203. var res;
  71204. var len = this.length + num.length;
  71205. if (this.length === 10 && num.length === 10) {
  71206. res = comb10MulTo(this, num, out);
  71207. } else if (len < 63) {
  71208. res = smallMulTo(this, num, out);
  71209. } else if (len < 1024) {
  71210. res = bigMulTo(this, num, out);
  71211. } else {
  71212. res = jumboMulTo(this, num, out);
  71213. }
  71214. return res;
  71215. };
  71216. // Cooley-Tukey algorithm for FFT
  71217. // slightly revisited to rely on looping instead of recursion
  71218. function FFTM (x, y) {
  71219. this.x = x;
  71220. this.y = y;
  71221. }
  71222. FFTM.prototype.makeRBT = function makeRBT (N) {
  71223. var t = new Array(N);
  71224. var l = BN.prototype._countBits(N) - 1;
  71225. for (var i = 0; i < N; i++) {
  71226. t[i] = this.revBin(i, l, N);
  71227. }
  71228. return t;
  71229. };
  71230. // Returns binary-reversed representation of `x`
  71231. FFTM.prototype.revBin = function revBin (x, l, N) {
  71232. if (x === 0 || x === N - 1) return x;
  71233. var rb = 0;
  71234. for (var i = 0; i < l; i++) {
  71235. rb |= (x & 1) << (l - i - 1);
  71236. x >>= 1;
  71237. }
  71238. return rb;
  71239. };
  71240. // Performs "tweedling" phase, therefore 'emulating'
  71241. // behaviour of the recursive algorithm
  71242. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  71243. for (var i = 0; i < N; i++) {
  71244. rtws[i] = rws[rbt[i]];
  71245. itws[i] = iws[rbt[i]];
  71246. }
  71247. };
  71248. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  71249. this.permute(rbt, rws, iws, rtws, itws, N);
  71250. for (var s = 1; s < N; s <<= 1) {
  71251. var l = s << 1;
  71252. var rtwdf = Math.cos(2 * Math.PI / l);
  71253. var itwdf = Math.sin(2 * Math.PI / l);
  71254. for (var p = 0; p < N; p += l) {
  71255. var rtwdf_ = rtwdf;
  71256. var itwdf_ = itwdf;
  71257. for (var j = 0; j < s; j++) {
  71258. var re = rtws[p + j];
  71259. var ie = itws[p + j];
  71260. var ro = rtws[p + j + s];
  71261. var io = itws[p + j + s];
  71262. var rx = rtwdf_ * ro - itwdf_ * io;
  71263. io = rtwdf_ * io + itwdf_ * ro;
  71264. ro = rx;
  71265. rtws[p + j] = re + ro;
  71266. itws[p + j] = ie + io;
  71267. rtws[p + j + s] = re - ro;
  71268. itws[p + j + s] = ie - io;
  71269. /* jshint maxdepth : false */
  71270. if (j !== l) {
  71271. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  71272. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  71273. rtwdf_ = rx;
  71274. }
  71275. }
  71276. }
  71277. }
  71278. };
  71279. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  71280. var N = Math.max(m, n) | 1;
  71281. var odd = N & 1;
  71282. var i = 0;
  71283. for (N = N / 2 | 0; N; N = N >>> 1) {
  71284. i++;
  71285. }
  71286. return 1 << i + 1 + odd;
  71287. };
  71288. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  71289. if (N <= 1) return;
  71290. for (var i = 0; i < N / 2; i++) {
  71291. var t = rws[i];
  71292. rws[i] = rws[N - i - 1];
  71293. rws[N - i - 1] = t;
  71294. t = iws[i];
  71295. iws[i] = -iws[N - i - 1];
  71296. iws[N - i - 1] = -t;
  71297. }
  71298. };
  71299. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  71300. var carry = 0;
  71301. for (var i = 0; i < N / 2; i++) {
  71302. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  71303. Math.round(ws[2 * i] / N) +
  71304. carry;
  71305. ws[i] = w & 0x3ffffff;
  71306. if (w < 0x4000000) {
  71307. carry = 0;
  71308. } else {
  71309. carry = w / 0x4000000 | 0;
  71310. }
  71311. }
  71312. return ws;
  71313. };
  71314. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  71315. var carry = 0;
  71316. for (var i = 0; i < len; i++) {
  71317. carry = carry + (ws[i] | 0);
  71318. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  71319. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  71320. }
  71321. // Pad with zeroes
  71322. for (i = 2 * len; i < N; ++i) {
  71323. rws[i] = 0;
  71324. }
  71325. assert(carry === 0);
  71326. assert((carry & ~0x1fff) === 0);
  71327. };
  71328. FFTM.prototype.stub = function stub (N) {
  71329. var ph = new Array(N);
  71330. for (var i = 0; i < N; i++) {
  71331. ph[i] = 0;
  71332. }
  71333. return ph;
  71334. };
  71335. FFTM.prototype.mulp = function mulp (x, y, out) {
  71336. var N = 2 * this.guessLen13b(x.length, y.length);
  71337. var rbt = this.makeRBT(N);
  71338. var _ = this.stub(N);
  71339. var rws = new Array(N);
  71340. var rwst = new Array(N);
  71341. var iwst = new Array(N);
  71342. var nrws = new Array(N);
  71343. var nrwst = new Array(N);
  71344. var niwst = new Array(N);
  71345. var rmws = out.words;
  71346. rmws.length = N;
  71347. this.convert13b(x.words, x.length, rws, N);
  71348. this.convert13b(y.words, y.length, nrws, N);
  71349. this.transform(rws, _, rwst, iwst, N, rbt);
  71350. this.transform(nrws, _, nrwst, niwst, N, rbt);
  71351. for (var i = 0; i < N; i++) {
  71352. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  71353. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  71354. rwst[i] = rx;
  71355. }
  71356. this.conjugate(rwst, iwst, N);
  71357. this.transform(rwst, iwst, rmws, _, N, rbt);
  71358. this.conjugate(rmws, _, N);
  71359. this.normalize13b(rmws, N);
  71360. out.negative = x.negative ^ y.negative;
  71361. out.length = x.length + y.length;
  71362. return out.strip();
  71363. };
  71364. // Multiply `this` by `num`
  71365. BN.prototype.mul = function mul (num) {
  71366. var out = new BN(null);
  71367. out.words = new Array(this.length + num.length);
  71368. return this.mulTo(num, out);
  71369. };
  71370. // Multiply employing FFT
  71371. BN.prototype.mulf = function mulf (num) {
  71372. var out = new BN(null);
  71373. out.words = new Array(this.length + num.length);
  71374. return jumboMulTo(this, num, out);
  71375. };
  71376. // In-place Multiplication
  71377. BN.prototype.imul = function imul (num) {
  71378. return this.clone().mulTo(num, this);
  71379. };
  71380. BN.prototype.imuln = function imuln (num) {
  71381. assert(typeof num === 'number');
  71382. assert(num < 0x4000000);
  71383. // Carry
  71384. var carry = 0;
  71385. for (var i = 0; i < this.length; i++) {
  71386. var w = (this.words[i] | 0) * num;
  71387. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  71388. carry >>= 26;
  71389. carry += (w / 0x4000000) | 0;
  71390. // NOTE: lo is 27bit maximum
  71391. carry += lo >>> 26;
  71392. this.words[i] = lo & 0x3ffffff;
  71393. }
  71394. if (carry !== 0) {
  71395. this.words[i] = carry;
  71396. this.length++;
  71397. }
  71398. return this;
  71399. };
  71400. BN.prototype.muln = function muln (num) {
  71401. return this.clone().imuln(num);
  71402. };
  71403. // `this` * `this`
  71404. BN.prototype.sqr = function sqr () {
  71405. return this.mul(this);
  71406. };
  71407. // `this` * `this` in-place
  71408. BN.prototype.isqr = function isqr () {
  71409. return this.imul(this.clone());
  71410. };
  71411. // Math.pow(`this`, `num`)
  71412. BN.prototype.pow = function pow (num) {
  71413. var w = toBitArray(num);
  71414. if (w.length === 0) return new BN(1);
  71415. // Skip leading zeroes
  71416. var res = this;
  71417. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  71418. if (w[i] !== 0) break;
  71419. }
  71420. if (++i < w.length) {
  71421. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  71422. if (w[i] === 0) continue;
  71423. res = res.mul(q);
  71424. }
  71425. }
  71426. return res;
  71427. };
  71428. // Shift-left in-place
  71429. BN.prototype.iushln = function iushln (bits) {
  71430. assert(typeof bits === 'number' && bits >= 0);
  71431. var r = bits % 26;
  71432. var s = (bits - r) / 26;
  71433. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  71434. var i;
  71435. if (r !== 0) {
  71436. var carry = 0;
  71437. for (i = 0; i < this.length; i++) {
  71438. var newCarry = this.words[i] & carryMask;
  71439. var c = ((this.words[i] | 0) - newCarry) << r;
  71440. this.words[i] = c | carry;
  71441. carry = newCarry >>> (26 - r);
  71442. }
  71443. if (carry) {
  71444. this.words[i] = carry;
  71445. this.length++;
  71446. }
  71447. }
  71448. if (s !== 0) {
  71449. for (i = this.length - 1; i >= 0; i--) {
  71450. this.words[i + s] = this.words[i];
  71451. }
  71452. for (i = 0; i < s; i++) {
  71453. this.words[i] = 0;
  71454. }
  71455. this.length += s;
  71456. }
  71457. return this.strip();
  71458. };
  71459. BN.prototype.ishln = function ishln (bits) {
  71460. // TODO(indutny): implement me
  71461. assert(this.negative === 0);
  71462. return this.iushln(bits);
  71463. };
  71464. // Shift-right in-place
  71465. // NOTE: `hint` is a lowest bit before trailing zeroes
  71466. // NOTE: if `extended` is present - it will be filled with destroyed bits
  71467. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  71468. assert(typeof bits === 'number' && bits >= 0);
  71469. var h;
  71470. if (hint) {
  71471. h = (hint - (hint % 26)) / 26;
  71472. } else {
  71473. h = 0;
  71474. }
  71475. var r = bits % 26;
  71476. var s = Math.min((bits - r) / 26, this.length);
  71477. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  71478. var maskedWords = extended;
  71479. h -= s;
  71480. h = Math.max(0, h);
  71481. // Extended mode, copy masked part
  71482. if (maskedWords) {
  71483. for (var i = 0; i < s; i++) {
  71484. maskedWords.words[i] = this.words[i];
  71485. }
  71486. maskedWords.length = s;
  71487. }
  71488. if (s === 0) {
  71489. // No-op, we should not move anything at all
  71490. } else if (this.length > s) {
  71491. this.length -= s;
  71492. for (i = 0; i < this.length; i++) {
  71493. this.words[i] = this.words[i + s];
  71494. }
  71495. } else {
  71496. this.words[0] = 0;
  71497. this.length = 1;
  71498. }
  71499. var carry = 0;
  71500. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  71501. var word = this.words[i] | 0;
  71502. this.words[i] = (carry << (26 - r)) | (word >>> r);
  71503. carry = word & mask;
  71504. }
  71505. // Push carried bits as a mask
  71506. if (maskedWords && carry !== 0) {
  71507. maskedWords.words[maskedWords.length++] = carry;
  71508. }
  71509. if (this.length === 0) {
  71510. this.words[0] = 0;
  71511. this.length = 1;
  71512. }
  71513. return this.strip();
  71514. };
  71515. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  71516. // TODO(indutny): implement me
  71517. assert(this.negative === 0);
  71518. return this.iushrn(bits, hint, extended);
  71519. };
  71520. // Shift-left
  71521. BN.prototype.shln = function shln (bits) {
  71522. return this.clone().ishln(bits);
  71523. };
  71524. BN.prototype.ushln = function ushln (bits) {
  71525. return this.clone().iushln(bits);
  71526. };
  71527. // Shift-right
  71528. BN.prototype.shrn = function shrn (bits) {
  71529. return this.clone().ishrn(bits);
  71530. };
  71531. BN.prototype.ushrn = function ushrn (bits) {
  71532. return this.clone().iushrn(bits);
  71533. };
  71534. // Test if n bit is set
  71535. BN.prototype.testn = function testn (bit) {
  71536. assert(typeof bit === 'number' && bit >= 0);
  71537. var r = bit % 26;
  71538. var s = (bit - r) / 26;
  71539. var q = 1 << r;
  71540. // Fast case: bit is much higher than all existing words
  71541. if (this.length <= s) return false;
  71542. // Check bit and return
  71543. var w = this.words[s];
  71544. return !!(w & q);
  71545. };
  71546. // Return only lowers bits of number (in-place)
  71547. BN.prototype.imaskn = function imaskn (bits) {
  71548. assert(typeof bits === 'number' && bits >= 0);
  71549. var r = bits % 26;
  71550. var s = (bits - r) / 26;
  71551. assert(this.negative === 0, 'imaskn works only with positive numbers');
  71552. if (this.length <= s) {
  71553. return this;
  71554. }
  71555. if (r !== 0) {
  71556. s++;
  71557. }
  71558. this.length = Math.min(s, this.length);
  71559. if (r !== 0) {
  71560. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  71561. this.words[this.length - 1] &= mask;
  71562. }
  71563. return this.strip();
  71564. };
  71565. // Return only lowers bits of number
  71566. BN.prototype.maskn = function maskn (bits) {
  71567. return this.clone().imaskn(bits);
  71568. };
  71569. // Add plain number `num` to `this`
  71570. BN.prototype.iaddn = function iaddn (num) {
  71571. assert(typeof num === 'number');
  71572. assert(num < 0x4000000);
  71573. if (num < 0) return this.isubn(-num);
  71574. // Possible sign change
  71575. if (this.negative !== 0) {
  71576. if (this.length === 1 && (this.words[0] | 0) < num) {
  71577. this.words[0] = num - (this.words[0] | 0);
  71578. this.negative = 0;
  71579. return this;
  71580. }
  71581. this.negative = 0;
  71582. this.isubn(num);
  71583. this.negative = 1;
  71584. return this;
  71585. }
  71586. // Add without checks
  71587. return this._iaddn(num);
  71588. };
  71589. BN.prototype._iaddn = function _iaddn (num) {
  71590. this.words[0] += num;
  71591. // Carry
  71592. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  71593. this.words[i] -= 0x4000000;
  71594. if (i === this.length - 1) {
  71595. this.words[i + 1] = 1;
  71596. } else {
  71597. this.words[i + 1]++;
  71598. }
  71599. }
  71600. this.length = Math.max(this.length, i + 1);
  71601. return this;
  71602. };
  71603. // Subtract plain number `num` from `this`
  71604. BN.prototype.isubn = function isubn (num) {
  71605. assert(typeof num === 'number');
  71606. assert(num < 0x4000000);
  71607. if (num < 0) return this.iaddn(-num);
  71608. if (this.negative !== 0) {
  71609. this.negative = 0;
  71610. this.iaddn(num);
  71611. this.negative = 1;
  71612. return this;
  71613. }
  71614. this.words[0] -= num;
  71615. if (this.length === 1 && this.words[0] < 0) {
  71616. this.words[0] = -this.words[0];
  71617. this.negative = 1;
  71618. } else {
  71619. // Carry
  71620. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  71621. this.words[i] += 0x4000000;
  71622. this.words[i + 1] -= 1;
  71623. }
  71624. }
  71625. return this.strip();
  71626. };
  71627. BN.prototype.addn = function addn (num) {
  71628. return this.clone().iaddn(num);
  71629. };
  71630. BN.prototype.subn = function subn (num) {
  71631. return this.clone().isubn(num);
  71632. };
  71633. BN.prototype.iabs = function iabs () {
  71634. this.negative = 0;
  71635. return this;
  71636. };
  71637. BN.prototype.abs = function abs () {
  71638. return this.clone().iabs();
  71639. };
  71640. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  71641. var len = num.length + shift;
  71642. var i;
  71643. this._expand(len);
  71644. var w;
  71645. var carry = 0;
  71646. for (i = 0; i < num.length; i++) {
  71647. w = (this.words[i + shift] | 0) + carry;
  71648. var right = (num.words[i] | 0) * mul;
  71649. w -= right & 0x3ffffff;
  71650. carry = (w >> 26) - ((right / 0x4000000) | 0);
  71651. this.words[i + shift] = w & 0x3ffffff;
  71652. }
  71653. for (; i < this.length - shift; i++) {
  71654. w = (this.words[i + shift] | 0) + carry;
  71655. carry = w >> 26;
  71656. this.words[i + shift] = w & 0x3ffffff;
  71657. }
  71658. if (carry === 0) return this.strip();
  71659. // Subtraction overflow
  71660. assert(carry === -1);
  71661. carry = 0;
  71662. for (i = 0; i < this.length; i++) {
  71663. w = -(this.words[i] | 0) + carry;
  71664. carry = w >> 26;
  71665. this.words[i] = w & 0x3ffffff;
  71666. }
  71667. this.negative = 1;
  71668. return this.strip();
  71669. };
  71670. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  71671. var shift = this.length - num.length;
  71672. var a = this.clone();
  71673. var b = num;
  71674. // Normalize
  71675. var bhi = b.words[b.length - 1] | 0;
  71676. var bhiBits = this._countBits(bhi);
  71677. shift = 26 - bhiBits;
  71678. if (shift !== 0) {
  71679. b = b.ushln(shift);
  71680. a.iushln(shift);
  71681. bhi = b.words[b.length - 1] | 0;
  71682. }
  71683. // Initialize quotient
  71684. var m = a.length - b.length;
  71685. var q;
  71686. if (mode !== 'mod') {
  71687. q = new BN(null);
  71688. q.length = m + 1;
  71689. q.words = new Array(q.length);
  71690. for (var i = 0; i < q.length; i++) {
  71691. q.words[i] = 0;
  71692. }
  71693. }
  71694. var diff = a.clone()._ishlnsubmul(b, 1, m);
  71695. if (diff.negative === 0) {
  71696. a = diff;
  71697. if (q) {
  71698. q.words[m] = 1;
  71699. }
  71700. }
  71701. for (var j = m - 1; j >= 0; j--) {
  71702. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  71703. (a.words[b.length + j - 1] | 0);
  71704. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  71705. // (0x7ffffff)
  71706. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  71707. a._ishlnsubmul(b, qj, j);
  71708. while (a.negative !== 0) {
  71709. qj--;
  71710. a.negative = 0;
  71711. a._ishlnsubmul(b, 1, j);
  71712. if (!a.isZero()) {
  71713. a.negative ^= 1;
  71714. }
  71715. }
  71716. if (q) {
  71717. q.words[j] = qj;
  71718. }
  71719. }
  71720. if (q) {
  71721. q.strip();
  71722. }
  71723. a.strip();
  71724. // Denormalize
  71725. if (mode !== 'div' && shift !== 0) {
  71726. a.iushrn(shift);
  71727. }
  71728. return {
  71729. div: q || null,
  71730. mod: a
  71731. };
  71732. };
  71733. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  71734. // to `div` to request div only, or be absent to
  71735. // request both div & mod
  71736. // 2) `positive` is true if unsigned mod is requested
  71737. BN.prototype.divmod = function divmod (num, mode, positive) {
  71738. assert(!num.isZero());
  71739. if (this.isZero()) {
  71740. return {
  71741. div: new BN(0),
  71742. mod: new BN(0)
  71743. };
  71744. }
  71745. var div, mod, res;
  71746. if (this.negative !== 0 && num.negative === 0) {
  71747. res = this.neg().divmod(num, mode);
  71748. if (mode !== 'mod') {
  71749. div = res.div.neg();
  71750. }
  71751. if (mode !== 'div') {
  71752. mod = res.mod.neg();
  71753. if (positive && mod.negative !== 0) {
  71754. mod.iadd(num);
  71755. }
  71756. }
  71757. return {
  71758. div: div,
  71759. mod: mod
  71760. };
  71761. }
  71762. if (this.negative === 0 && num.negative !== 0) {
  71763. res = this.divmod(num.neg(), mode);
  71764. if (mode !== 'mod') {
  71765. div = res.div.neg();
  71766. }
  71767. return {
  71768. div: div,
  71769. mod: res.mod
  71770. };
  71771. }
  71772. if ((this.negative & num.negative) !== 0) {
  71773. res = this.neg().divmod(num.neg(), mode);
  71774. if (mode !== 'div') {
  71775. mod = res.mod.neg();
  71776. if (positive && mod.negative !== 0) {
  71777. mod.isub(num);
  71778. }
  71779. }
  71780. return {
  71781. div: res.div,
  71782. mod: mod
  71783. };
  71784. }
  71785. // Both numbers are positive at this point
  71786. // Strip both numbers to approximate shift value
  71787. if (num.length > this.length || this.cmp(num) < 0) {
  71788. return {
  71789. div: new BN(0),
  71790. mod: this
  71791. };
  71792. }
  71793. // Very short reduction
  71794. if (num.length === 1) {
  71795. if (mode === 'div') {
  71796. return {
  71797. div: this.divn(num.words[0]),
  71798. mod: null
  71799. };
  71800. }
  71801. if (mode === 'mod') {
  71802. return {
  71803. div: null,
  71804. mod: new BN(this.modn(num.words[0]))
  71805. };
  71806. }
  71807. return {
  71808. div: this.divn(num.words[0]),
  71809. mod: new BN(this.modn(num.words[0]))
  71810. };
  71811. }
  71812. return this._wordDiv(num, mode);
  71813. };
  71814. // Find `this` / `num`
  71815. BN.prototype.div = function div (num) {
  71816. return this.divmod(num, 'div', false).div;
  71817. };
  71818. // Find `this` % `num`
  71819. BN.prototype.mod = function mod (num) {
  71820. return this.divmod(num, 'mod', false).mod;
  71821. };
  71822. BN.prototype.umod = function umod (num) {
  71823. return this.divmod(num, 'mod', true).mod;
  71824. };
  71825. // Find Round(`this` / `num`)
  71826. BN.prototype.divRound = function divRound (num) {
  71827. var dm = this.divmod(num);
  71828. // Fast case - exact division
  71829. if (dm.mod.isZero()) return dm.div;
  71830. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  71831. var half = num.ushrn(1);
  71832. var r2 = num.andln(1);
  71833. var cmp = mod.cmp(half);
  71834. // Round down
  71835. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  71836. // Round up
  71837. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  71838. };
  71839. BN.prototype.modn = function modn (num) {
  71840. assert(num <= 0x3ffffff);
  71841. var p = (1 << 26) % num;
  71842. var acc = 0;
  71843. for (var i = this.length - 1; i >= 0; i--) {
  71844. acc = (p * acc + (this.words[i] | 0)) % num;
  71845. }
  71846. return acc;
  71847. };
  71848. // In-place division by number
  71849. BN.prototype.idivn = function idivn (num) {
  71850. assert(num <= 0x3ffffff);
  71851. var carry = 0;
  71852. for (var i = this.length - 1; i >= 0; i--) {
  71853. var w = (this.words[i] | 0) + carry * 0x4000000;
  71854. this.words[i] = (w / num) | 0;
  71855. carry = w % num;
  71856. }
  71857. return this.strip();
  71858. };
  71859. BN.prototype.divn = function divn (num) {
  71860. return this.clone().idivn(num);
  71861. };
  71862. BN.prototype.egcd = function egcd (p) {
  71863. assert(p.negative === 0);
  71864. assert(!p.isZero());
  71865. var x = this;
  71866. var y = p.clone();
  71867. if (x.negative !== 0) {
  71868. x = x.umod(p);
  71869. } else {
  71870. x = x.clone();
  71871. }
  71872. // A * x + B * y = x
  71873. var A = new BN(1);
  71874. var B = new BN(0);
  71875. // C * x + D * y = y
  71876. var C = new BN(0);
  71877. var D = new BN(1);
  71878. var g = 0;
  71879. while (x.isEven() && y.isEven()) {
  71880. x.iushrn(1);
  71881. y.iushrn(1);
  71882. ++g;
  71883. }
  71884. var yp = y.clone();
  71885. var xp = x.clone();
  71886. while (!x.isZero()) {
  71887. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  71888. if (i > 0) {
  71889. x.iushrn(i);
  71890. while (i-- > 0) {
  71891. if (A.isOdd() || B.isOdd()) {
  71892. A.iadd(yp);
  71893. B.isub(xp);
  71894. }
  71895. A.iushrn(1);
  71896. B.iushrn(1);
  71897. }
  71898. }
  71899. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  71900. if (j > 0) {
  71901. y.iushrn(j);
  71902. while (j-- > 0) {
  71903. if (C.isOdd() || D.isOdd()) {
  71904. C.iadd(yp);
  71905. D.isub(xp);
  71906. }
  71907. C.iushrn(1);
  71908. D.iushrn(1);
  71909. }
  71910. }
  71911. if (x.cmp(y) >= 0) {
  71912. x.isub(y);
  71913. A.isub(C);
  71914. B.isub(D);
  71915. } else {
  71916. y.isub(x);
  71917. C.isub(A);
  71918. D.isub(B);
  71919. }
  71920. }
  71921. return {
  71922. a: C,
  71923. b: D,
  71924. gcd: y.iushln(g)
  71925. };
  71926. };
  71927. // This is reduced incarnation of the binary EEA
  71928. // above, designated to invert members of the
  71929. // _prime_ fields F(p) at a maximal speed
  71930. BN.prototype._invmp = function _invmp (p) {
  71931. assert(p.negative === 0);
  71932. assert(!p.isZero());
  71933. var a = this;
  71934. var b = p.clone();
  71935. if (a.negative !== 0) {
  71936. a = a.umod(p);
  71937. } else {
  71938. a = a.clone();
  71939. }
  71940. var x1 = new BN(1);
  71941. var x2 = new BN(0);
  71942. var delta = b.clone();
  71943. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  71944. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  71945. if (i > 0) {
  71946. a.iushrn(i);
  71947. while (i-- > 0) {
  71948. if (x1.isOdd()) {
  71949. x1.iadd(delta);
  71950. }
  71951. x1.iushrn(1);
  71952. }
  71953. }
  71954. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  71955. if (j > 0) {
  71956. b.iushrn(j);
  71957. while (j-- > 0) {
  71958. if (x2.isOdd()) {
  71959. x2.iadd(delta);
  71960. }
  71961. x2.iushrn(1);
  71962. }
  71963. }
  71964. if (a.cmp(b) >= 0) {
  71965. a.isub(b);
  71966. x1.isub(x2);
  71967. } else {
  71968. b.isub(a);
  71969. x2.isub(x1);
  71970. }
  71971. }
  71972. var res;
  71973. if (a.cmpn(1) === 0) {
  71974. res = x1;
  71975. } else {
  71976. res = x2;
  71977. }
  71978. if (res.cmpn(0) < 0) {
  71979. res.iadd(p);
  71980. }
  71981. return res;
  71982. };
  71983. BN.prototype.gcd = function gcd (num) {
  71984. if (this.isZero()) return num.abs();
  71985. if (num.isZero()) return this.abs();
  71986. var a = this.clone();
  71987. var b = num.clone();
  71988. a.negative = 0;
  71989. b.negative = 0;
  71990. // Remove common factor of two
  71991. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  71992. a.iushrn(1);
  71993. b.iushrn(1);
  71994. }
  71995. do {
  71996. while (a.isEven()) {
  71997. a.iushrn(1);
  71998. }
  71999. while (b.isEven()) {
  72000. b.iushrn(1);
  72001. }
  72002. var r = a.cmp(b);
  72003. if (r < 0) {
  72004. // Swap `a` and `b` to make `a` always bigger than `b`
  72005. var t = a;
  72006. a = b;
  72007. b = t;
  72008. } else if (r === 0 || b.cmpn(1) === 0) {
  72009. break;
  72010. }
  72011. a.isub(b);
  72012. } while (true);
  72013. return b.iushln(shift);
  72014. };
  72015. // Invert number in the field F(num)
  72016. BN.prototype.invm = function invm (num) {
  72017. return this.egcd(num).a.umod(num);
  72018. };
  72019. BN.prototype.isEven = function isEven () {
  72020. return (this.words[0] & 1) === 0;
  72021. };
  72022. BN.prototype.isOdd = function isOdd () {
  72023. return (this.words[0] & 1) === 1;
  72024. };
  72025. // And first word and num
  72026. BN.prototype.andln = function andln (num) {
  72027. return this.words[0] & num;
  72028. };
  72029. // Increment at the bit position in-line
  72030. BN.prototype.bincn = function bincn (bit) {
  72031. assert(typeof bit === 'number');
  72032. var r = bit % 26;
  72033. var s = (bit - r) / 26;
  72034. var q = 1 << r;
  72035. // Fast case: bit is much higher than all existing words
  72036. if (this.length <= s) {
  72037. this._expand(s + 1);
  72038. this.words[s] |= q;
  72039. return this;
  72040. }
  72041. // Add bit and propagate, if needed
  72042. var carry = q;
  72043. for (var i = s; carry !== 0 && i < this.length; i++) {
  72044. var w = this.words[i] | 0;
  72045. w += carry;
  72046. carry = w >>> 26;
  72047. w &= 0x3ffffff;
  72048. this.words[i] = w;
  72049. }
  72050. if (carry !== 0) {
  72051. this.words[i] = carry;
  72052. this.length++;
  72053. }
  72054. return this;
  72055. };
  72056. BN.prototype.isZero = function isZero () {
  72057. return this.length === 1 && this.words[0] === 0;
  72058. };
  72059. BN.prototype.cmpn = function cmpn (num) {
  72060. var negative = num < 0;
  72061. if (this.negative !== 0 && !negative) return -1;
  72062. if (this.negative === 0 && negative) return 1;
  72063. this.strip();
  72064. var res;
  72065. if (this.length > 1) {
  72066. res = 1;
  72067. } else {
  72068. if (negative) {
  72069. num = -num;
  72070. }
  72071. assert(num <= 0x3ffffff, 'Number is too big');
  72072. var w = this.words[0] | 0;
  72073. res = w === num ? 0 : w < num ? -1 : 1;
  72074. }
  72075. if (this.negative !== 0) return -res | 0;
  72076. return res;
  72077. };
  72078. // Compare two numbers and return:
  72079. // 1 - if `this` > `num`
  72080. // 0 - if `this` == `num`
  72081. // -1 - if `this` < `num`
  72082. BN.prototype.cmp = function cmp (num) {
  72083. if (this.negative !== 0 && num.negative === 0) return -1;
  72084. if (this.negative === 0 && num.negative !== 0) return 1;
  72085. var res = this.ucmp(num);
  72086. if (this.negative !== 0) return -res | 0;
  72087. return res;
  72088. };
  72089. // Unsigned comparison
  72090. BN.prototype.ucmp = function ucmp (num) {
  72091. // At this point both numbers have the same sign
  72092. if (this.length > num.length) return 1;
  72093. if (this.length < num.length) return -1;
  72094. var res = 0;
  72095. for (var i = this.length - 1; i >= 0; i--) {
  72096. var a = this.words[i] | 0;
  72097. var b = num.words[i] | 0;
  72098. if (a === b) continue;
  72099. if (a < b) {
  72100. res = -1;
  72101. } else if (a > b) {
  72102. res = 1;
  72103. }
  72104. break;
  72105. }
  72106. return res;
  72107. };
  72108. BN.prototype.gtn = function gtn (num) {
  72109. return this.cmpn(num) === 1;
  72110. };
  72111. BN.prototype.gt = function gt (num) {
  72112. return this.cmp(num) === 1;
  72113. };
  72114. BN.prototype.gten = function gten (num) {
  72115. return this.cmpn(num) >= 0;
  72116. };
  72117. BN.prototype.gte = function gte (num) {
  72118. return this.cmp(num) >= 0;
  72119. };
  72120. BN.prototype.ltn = function ltn (num) {
  72121. return this.cmpn(num) === -1;
  72122. };
  72123. BN.prototype.lt = function lt (num) {
  72124. return this.cmp(num) === -1;
  72125. };
  72126. BN.prototype.lten = function lten (num) {
  72127. return this.cmpn(num) <= 0;
  72128. };
  72129. BN.prototype.lte = function lte (num) {
  72130. return this.cmp(num) <= 0;
  72131. };
  72132. BN.prototype.eqn = function eqn (num) {
  72133. return this.cmpn(num) === 0;
  72134. };
  72135. BN.prototype.eq = function eq (num) {
  72136. return this.cmp(num) === 0;
  72137. };
  72138. //
  72139. // A reduce context, could be using montgomery or something better, depending
  72140. // on the `m` itself.
  72141. //
  72142. BN.red = function red (num) {
  72143. return new Red(num);
  72144. };
  72145. BN.prototype.toRed = function toRed (ctx) {
  72146. assert(!this.red, 'Already a number in reduction context');
  72147. assert(this.negative === 0, 'red works only with positives');
  72148. return ctx.convertTo(this)._forceRed(ctx);
  72149. };
  72150. BN.prototype.fromRed = function fromRed () {
  72151. assert(this.red, 'fromRed works only with numbers in reduction context');
  72152. return this.red.convertFrom(this);
  72153. };
  72154. BN.prototype._forceRed = function _forceRed (ctx) {
  72155. this.red = ctx;
  72156. return this;
  72157. };
  72158. BN.prototype.forceRed = function forceRed (ctx) {
  72159. assert(!this.red, 'Already a number in reduction context');
  72160. return this._forceRed(ctx);
  72161. };
  72162. BN.prototype.redAdd = function redAdd (num) {
  72163. assert(this.red, 'redAdd works only with red numbers');
  72164. return this.red.add(this, num);
  72165. };
  72166. BN.prototype.redIAdd = function redIAdd (num) {
  72167. assert(this.red, 'redIAdd works only with red numbers');
  72168. return this.red.iadd(this, num);
  72169. };
  72170. BN.prototype.redSub = function redSub (num) {
  72171. assert(this.red, 'redSub works only with red numbers');
  72172. return this.red.sub(this, num);
  72173. };
  72174. BN.prototype.redISub = function redISub (num) {
  72175. assert(this.red, 'redISub works only with red numbers');
  72176. return this.red.isub(this, num);
  72177. };
  72178. BN.prototype.redShl = function redShl (num) {
  72179. assert(this.red, 'redShl works only with red numbers');
  72180. return this.red.shl(this, num);
  72181. };
  72182. BN.prototype.redMul = function redMul (num) {
  72183. assert(this.red, 'redMul works only with red numbers');
  72184. this.red._verify2(this, num);
  72185. return this.red.mul(this, num);
  72186. };
  72187. BN.prototype.redIMul = function redIMul (num) {
  72188. assert(this.red, 'redMul works only with red numbers');
  72189. this.red._verify2(this, num);
  72190. return this.red.imul(this, num);
  72191. };
  72192. BN.prototype.redSqr = function redSqr () {
  72193. assert(this.red, 'redSqr works only with red numbers');
  72194. this.red._verify1(this);
  72195. return this.red.sqr(this);
  72196. };
  72197. BN.prototype.redISqr = function redISqr () {
  72198. assert(this.red, 'redISqr works only with red numbers');
  72199. this.red._verify1(this);
  72200. return this.red.isqr(this);
  72201. };
  72202. // Square root over p
  72203. BN.prototype.redSqrt = function redSqrt () {
  72204. assert(this.red, 'redSqrt works only with red numbers');
  72205. this.red._verify1(this);
  72206. return this.red.sqrt(this);
  72207. };
  72208. BN.prototype.redInvm = function redInvm () {
  72209. assert(this.red, 'redInvm works only with red numbers');
  72210. this.red._verify1(this);
  72211. return this.red.invm(this);
  72212. };
  72213. // Return negative clone of `this` % `red modulo`
  72214. BN.prototype.redNeg = function redNeg () {
  72215. assert(this.red, 'redNeg works only with red numbers');
  72216. this.red._verify1(this);
  72217. return this.red.neg(this);
  72218. };
  72219. BN.prototype.redPow = function redPow (num) {
  72220. assert(this.red && !num.red, 'redPow(normalNum)');
  72221. this.red._verify1(this);
  72222. return this.red.pow(this, num);
  72223. };
  72224. // Prime numbers with efficient reduction
  72225. var primes = {
  72226. k256: null,
  72227. p224: null,
  72228. p192: null,
  72229. p25519: null
  72230. };
  72231. // Pseudo-Mersenne prime
  72232. function MPrime (name, p) {
  72233. // P = 2 ^ N - K
  72234. this.name = name;
  72235. this.p = new BN(p, 16);
  72236. this.n = this.p.bitLength();
  72237. this.k = new BN(1).iushln(this.n).isub(this.p);
  72238. this.tmp = this._tmp();
  72239. }
  72240. MPrime.prototype._tmp = function _tmp () {
  72241. var tmp = new BN(null);
  72242. tmp.words = new Array(Math.ceil(this.n / 13));
  72243. return tmp;
  72244. };
  72245. MPrime.prototype.ireduce = function ireduce (num) {
  72246. // Assumes that `num` is less than `P^2`
  72247. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  72248. var r = num;
  72249. var rlen;
  72250. do {
  72251. this.split(r, this.tmp);
  72252. r = this.imulK(r);
  72253. r = r.iadd(this.tmp);
  72254. rlen = r.bitLength();
  72255. } while (rlen > this.n);
  72256. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  72257. if (cmp === 0) {
  72258. r.words[0] = 0;
  72259. r.length = 1;
  72260. } else if (cmp > 0) {
  72261. r.isub(this.p);
  72262. } else {
  72263. if (r.strip !== undefined) {
  72264. // r is BN v4 instance
  72265. r.strip();
  72266. } else {
  72267. // r is BN v5 instance
  72268. r._strip();
  72269. }
  72270. }
  72271. return r;
  72272. };
  72273. MPrime.prototype.split = function split (input, out) {
  72274. input.iushrn(this.n, 0, out);
  72275. };
  72276. MPrime.prototype.imulK = function imulK (num) {
  72277. return num.imul(this.k);
  72278. };
  72279. function K256 () {
  72280. MPrime.call(
  72281. this,
  72282. 'k256',
  72283. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  72284. }
  72285. inherits(K256, MPrime);
  72286. K256.prototype.split = function split (input, output) {
  72287. // 256 = 9 * 26 + 22
  72288. var mask = 0x3fffff;
  72289. var outLen = Math.min(input.length, 9);
  72290. for (var i = 0; i < outLen; i++) {
  72291. output.words[i] = input.words[i];
  72292. }
  72293. output.length = outLen;
  72294. if (input.length <= 9) {
  72295. input.words[0] = 0;
  72296. input.length = 1;
  72297. return;
  72298. }
  72299. // Shift by 9 limbs
  72300. var prev = input.words[9];
  72301. output.words[output.length++] = prev & mask;
  72302. for (i = 10; i < input.length; i++) {
  72303. var next = input.words[i] | 0;
  72304. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  72305. prev = next;
  72306. }
  72307. prev >>>= 22;
  72308. input.words[i - 10] = prev;
  72309. if (prev === 0 && input.length > 10) {
  72310. input.length -= 10;
  72311. } else {
  72312. input.length -= 9;
  72313. }
  72314. };
  72315. K256.prototype.imulK = function imulK (num) {
  72316. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  72317. num.words[num.length] = 0;
  72318. num.words[num.length + 1] = 0;
  72319. num.length += 2;
  72320. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  72321. var lo = 0;
  72322. for (var i = 0; i < num.length; i++) {
  72323. var w = num.words[i] | 0;
  72324. lo += w * 0x3d1;
  72325. num.words[i] = lo & 0x3ffffff;
  72326. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  72327. }
  72328. // Fast length reduction
  72329. if (num.words[num.length - 1] === 0) {
  72330. num.length--;
  72331. if (num.words[num.length - 1] === 0) {
  72332. num.length--;
  72333. }
  72334. }
  72335. return num;
  72336. };
  72337. function P224 () {
  72338. MPrime.call(
  72339. this,
  72340. 'p224',
  72341. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  72342. }
  72343. inherits(P224, MPrime);
  72344. function P192 () {
  72345. MPrime.call(
  72346. this,
  72347. 'p192',
  72348. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  72349. }
  72350. inherits(P192, MPrime);
  72351. function P25519 () {
  72352. // 2 ^ 255 - 19
  72353. MPrime.call(
  72354. this,
  72355. '25519',
  72356. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  72357. }
  72358. inherits(P25519, MPrime);
  72359. P25519.prototype.imulK = function imulK (num) {
  72360. // K = 0x13
  72361. var carry = 0;
  72362. for (var i = 0; i < num.length; i++) {
  72363. var hi = (num.words[i] | 0) * 0x13 + carry;
  72364. var lo = hi & 0x3ffffff;
  72365. hi >>>= 26;
  72366. num.words[i] = lo;
  72367. carry = hi;
  72368. }
  72369. if (carry !== 0) {
  72370. num.words[num.length++] = carry;
  72371. }
  72372. return num;
  72373. };
  72374. // Exported mostly for testing purposes, use plain name instead
  72375. BN._prime = function prime (name) {
  72376. // Cached version of prime
  72377. if (primes[name]) return primes[name];
  72378. var prime;
  72379. if (name === 'k256') {
  72380. prime = new K256();
  72381. } else if (name === 'p224') {
  72382. prime = new P224();
  72383. } else if (name === 'p192') {
  72384. prime = new P192();
  72385. } else if (name === 'p25519') {
  72386. prime = new P25519();
  72387. } else {
  72388. throw new Error('Unknown prime ' + name);
  72389. }
  72390. primes[name] = prime;
  72391. return prime;
  72392. };
  72393. //
  72394. // Base reduction engine
  72395. //
  72396. function Red (m) {
  72397. if (typeof m === 'string') {
  72398. var prime = BN._prime(m);
  72399. this.m = prime.p;
  72400. this.prime = prime;
  72401. } else {
  72402. assert(m.gtn(1), 'modulus must be greater than 1');
  72403. this.m = m;
  72404. this.prime = null;
  72405. }
  72406. }
  72407. Red.prototype._verify1 = function _verify1 (a) {
  72408. assert(a.negative === 0, 'red works only with positives');
  72409. assert(a.red, 'red works only with red numbers');
  72410. };
  72411. Red.prototype._verify2 = function _verify2 (a, b) {
  72412. assert((a.negative | b.negative) === 0, 'red works only with positives');
  72413. assert(a.red && a.red === b.red,
  72414. 'red works only with red numbers');
  72415. };
  72416. Red.prototype.imod = function imod (a) {
  72417. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  72418. return a.umod(this.m)._forceRed(this);
  72419. };
  72420. Red.prototype.neg = function neg (a) {
  72421. if (a.isZero()) {
  72422. return a.clone();
  72423. }
  72424. return this.m.sub(a)._forceRed(this);
  72425. };
  72426. Red.prototype.add = function add (a, b) {
  72427. this._verify2(a, b);
  72428. var res = a.add(b);
  72429. if (res.cmp(this.m) >= 0) {
  72430. res.isub(this.m);
  72431. }
  72432. return res._forceRed(this);
  72433. };
  72434. Red.prototype.iadd = function iadd (a, b) {
  72435. this._verify2(a, b);
  72436. var res = a.iadd(b);
  72437. if (res.cmp(this.m) >= 0) {
  72438. res.isub(this.m);
  72439. }
  72440. return res;
  72441. };
  72442. Red.prototype.sub = function sub (a, b) {
  72443. this._verify2(a, b);
  72444. var res = a.sub(b);
  72445. if (res.cmpn(0) < 0) {
  72446. res.iadd(this.m);
  72447. }
  72448. return res._forceRed(this);
  72449. };
  72450. Red.prototype.isub = function isub (a, b) {
  72451. this._verify2(a, b);
  72452. var res = a.isub(b);
  72453. if (res.cmpn(0) < 0) {
  72454. res.iadd(this.m);
  72455. }
  72456. return res;
  72457. };
  72458. Red.prototype.shl = function shl (a, num) {
  72459. this._verify1(a);
  72460. return this.imod(a.ushln(num));
  72461. };
  72462. Red.prototype.imul = function imul (a, b) {
  72463. this._verify2(a, b);
  72464. return this.imod(a.imul(b));
  72465. };
  72466. Red.prototype.mul = function mul (a, b) {
  72467. this._verify2(a, b);
  72468. return this.imod(a.mul(b));
  72469. };
  72470. Red.prototype.isqr = function isqr (a) {
  72471. return this.imul(a, a.clone());
  72472. };
  72473. Red.prototype.sqr = function sqr (a) {
  72474. return this.mul(a, a);
  72475. };
  72476. Red.prototype.sqrt = function sqrt (a) {
  72477. if (a.isZero()) return a.clone();
  72478. var mod3 = this.m.andln(3);
  72479. assert(mod3 % 2 === 1);
  72480. // Fast case
  72481. if (mod3 === 3) {
  72482. var pow = this.m.add(new BN(1)).iushrn(2);
  72483. return this.pow(a, pow);
  72484. }
  72485. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  72486. //
  72487. // Find Q and S, that Q * 2 ^ S = (P - 1)
  72488. var q = this.m.subn(1);
  72489. var s = 0;
  72490. while (!q.isZero() && q.andln(1) === 0) {
  72491. s++;
  72492. q.iushrn(1);
  72493. }
  72494. assert(!q.isZero());
  72495. var one = new BN(1).toRed(this);
  72496. var nOne = one.redNeg();
  72497. // Find quadratic non-residue
  72498. // NOTE: Max is such because of generalized Riemann hypothesis.
  72499. var lpow = this.m.subn(1).iushrn(1);
  72500. var z = this.m.bitLength();
  72501. z = new BN(2 * z * z).toRed(this);
  72502. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  72503. z.redIAdd(nOne);
  72504. }
  72505. var c = this.pow(z, q);
  72506. var r = this.pow(a, q.addn(1).iushrn(1));
  72507. var t = this.pow(a, q);
  72508. var m = s;
  72509. while (t.cmp(one) !== 0) {
  72510. var tmp = t;
  72511. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  72512. tmp = tmp.redSqr();
  72513. }
  72514. assert(i < m);
  72515. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  72516. r = r.redMul(b);
  72517. c = b.redSqr();
  72518. t = t.redMul(c);
  72519. m = i;
  72520. }
  72521. return r;
  72522. };
  72523. Red.prototype.invm = function invm (a) {
  72524. var inv = a._invmp(this.m);
  72525. if (inv.negative !== 0) {
  72526. inv.negative = 0;
  72527. return this.imod(inv).redNeg();
  72528. } else {
  72529. return this.imod(inv);
  72530. }
  72531. };
  72532. Red.prototype.pow = function pow (a, num) {
  72533. if (num.isZero()) return new BN(1).toRed(this);
  72534. if (num.cmpn(1) === 0) return a.clone();
  72535. var windowSize = 4;
  72536. var wnd = new Array(1 << windowSize);
  72537. wnd[0] = new BN(1).toRed(this);
  72538. wnd[1] = a;
  72539. for (var i = 2; i < wnd.length; i++) {
  72540. wnd[i] = this.mul(wnd[i - 1], a);
  72541. }
  72542. var res = wnd[0];
  72543. var current = 0;
  72544. var currentLen = 0;
  72545. var start = num.bitLength() % 26;
  72546. if (start === 0) {
  72547. start = 26;
  72548. }
  72549. for (i = num.length - 1; i >= 0; i--) {
  72550. var word = num.words[i];
  72551. for (var j = start - 1; j >= 0; j--) {
  72552. var bit = (word >> j) & 1;
  72553. if (res !== wnd[0]) {
  72554. res = this.sqr(res);
  72555. }
  72556. if (bit === 0 && current === 0) {
  72557. currentLen = 0;
  72558. continue;
  72559. }
  72560. current <<= 1;
  72561. current |= bit;
  72562. currentLen++;
  72563. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  72564. res = this.mul(res, wnd[current]);
  72565. currentLen = 0;
  72566. current = 0;
  72567. }
  72568. start = 26;
  72569. }
  72570. return res;
  72571. };
  72572. Red.prototype.convertTo = function convertTo (num) {
  72573. var r = num.umod(this.m);
  72574. return r === num ? r.clone() : r;
  72575. };
  72576. Red.prototype.convertFrom = function convertFrom (num) {
  72577. var res = num.clone();
  72578. res.red = null;
  72579. return res;
  72580. };
  72581. //
  72582. // Montgomery method engine
  72583. //
  72584. BN.mont = function mont (num) {
  72585. return new Mont(num);
  72586. };
  72587. function Mont (m) {
  72588. Red.call(this, m);
  72589. this.shift = this.m.bitLength();
  72590. if (this.shift % 26 !== 0) {
  72591. this.shift += 26 - (this.shift % 26);
  72592. }
  72593. this.r = new BN(1).iushln(this.shift);
  72594. this.r2 = this.imod(this.r.sqr());
  72595. this.rinv = this.r._invmp(this.m);
  72596. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  72597. this.minv = this.minv.umod(this.r);
  72598. this.minv = this.r.sub(this.minv);
  72599. }
  72600. inherits(Mont, Red);
  72601. Mont.prototype.convertTo = function convertTo (num) {
  72602. return this.imod(num.ushln(this.shift));
  72603. };
  72604. Mont.prototype.convertFrom = function convertFrom (num) {
  72605. var r = this.imod(num.mul(this.rinv));
  72606. r.red = null;
  72607. return r;
  72608. };
  72609. Mont.prototype.imul = function imul (a, b) {
  72610. if (a.isZero() || b.isZero()) {
  72611. a.words[0] = 0;
  72612. a.length = 1;
  72613. return a;
  72614. }
  72615. var t = a.imul(b);
  72616. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  72617. var u = t.isub(c).iushrn(this.shift);
  72618. var res = u;
  72619. if (u.cmp(this.m) >= 0) {
  72620. res = u.isub(this.m);
  72621. } else if (u.cmpn(0) < 0) {
  72622. res = u.iadd(this.m);
  72623. }
  72624. return res._forceRed(this);
  72625. };
  72626. Mont.prototype.mul = function mul (a, b) {
  72627. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  72628. var t = a.mul(b);
  72629. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  72630. var u = t.isub(c).iushrn(this.shift);
  72631. var res = u;
  72632. if (u.cmp(this.m) >= 0) {
  72633. res = u.isub(this.m);
  72634. } else if (u.cmpn(0) < 0) {
  72635. res = u.iadd(this.m);
  72636. }
  72637. return res._forceRed(this);
  72638. };
  72639. Mont.prototype.invm = function invm (a) {
  72640. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  72641. var res = this.imod(a._invmp(this.m).mul(this.r2));
  72642. return res._forceRed(this);
  72643. };
  72644. })( false || module, this);
  72645. /***/ }),
  72646. /***/ "./node_modules/public-encrypt/privateDecrypt.js":
  72647. /*!*******************************************************!*\
  72648. !*** ./node_modules/public-encrypt/privateDecrypt.js ***!
  72649. \*******************************************************/
  72650. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  72651. var parseKeys = __webpack_require__(/*! parse-asn1 */ "./node_modules/parse-asn1/index.js")
  72652. var mgf = __webpack_require__(/*! ./mgf */ "./node_modules/public-encrypt/mgf.js")
  72653. var xor = __webpack_require__(/*! ./xor */ "./node_modules/public-encrypt/xor.js")
  72654. var BN = __webpack_require__(/*! bn.js */ "./node_modules/public-encrypt/node_modules/bn.js/lib/bn.js")
  72655. var crt = __webpack_require__(/*! browserify-rsa */ "./node_modules/browserify-rsa/index.js")
  72656. var createHash = __webpack_require__(/*! create-hash */ "./node_modules/create-hash/browser.js")
  72657. var withPublic = __webpack_require__(/*! ./withPublic */ "./node_modules/public-encrypt/withPublic.js")
  72658. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  72659. module.exports = function privateDecrypt (privateKey, enc, reverse) {
  72660. var padding
  72661. if (privateKey.padding) {
  72662. padding = privateKey.padding
  72663. } else if (reverse) {
  72664. padding = 1
  72665. } else {
  72666. padding = 4
  72667. }
  72668. var key = parseKeys(privateKey)
  72669. var k = key.modulus.byteLength()
  72670. if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
  72671. throw new Error('decryption error')
  72672. }
  72673. var msg
  72674. if (reverse) {
  72675. msg = withPublic(new BN(enc), key)
  72676. } else {
  72677. msg = crt(enc, key)
  72678. }
  72679. var zBuffer = Buffer.alloc(k - msg.length)
  72680. msg = Buffer.concat([zBuffer, msg], k)
  72681. if (padding === 4) {
  72682. return oaep(key, msg)
  72683. } else if (padding === 1) {
  72684. return pkcs1(key, msg, reverse)
  72685. } else if (padding === 3) {
  72686. return msg
  72687. } else {
  72688. throw new Error('unknown padding')
  72689. }
  72690. }
  72691. function oaep (key, msg) {
  72692. var k = key.modulus.byteLength()
  72693. var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
  72694. var hLen = iHash.length
  72695. if (msg[0] !== 0) {
  72696. throw new Error('decryption error')
  72697. }
  72698. var maskedSeed = msg.slice(1, hLen + 1)
  72699. var maskedDb = msg.slice(hLen + 1)
  72700. var seed = xor(maskedSeed, mgf(maskedDb, hLen))
  72701. var db = xor(maskedDb, mgf(seed, k - hLen - 1))
  72702. if (compare(iHash, db.slice(0, hLen))) {
  72703. throw new Error('decryption error')
  72704. }
  72705. var i = hLen
  72706. while (db[i] === 0) {
  72707. i++
  72708. }
  72709. if (db[i++] !== 1) {
  72710. throw new Error('decryption error')
  72711. }
  72712. return db.slice(i)
  72713. }
  72714. function pkcs1 (key, msg, reverse) {
  72715. var p1 = msg.slice(0, 2)
  72716. var i = 2
  72717. var status = 0
  72718. while (msg[i++] !== 0) {
  72719. if (i >= msg.length) {
  72720. status++
  72721. break
  72722. }
  72723. }
  72724. var ps = msg.slice(2, i - 1)
  72725. if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) {
  72726. status++
  72727. }
  72728. if (ps.length < 8) {
  72729. status++
  72730. }
  72731. if (status) {
  72732. throw new Error('decryption error')
  72733. }
  72734. return msg.slice(i)
  72735. }
  72736. function compare (a, b) {
  72737. a = Buffer.from(a)
  72738. b = Buffer.from(b)
  72739. var dif = 0
  72740. var len = a.length
  72741. if (a.length !== b.length) {
  72742. dif++
  72743. len = Math.min(a.length, b.length)
  72744. }
  72745. var i = -1
  72746. while (++i < len) {
  72747. dif += (a[i] ^ b[i])
  72748. }
  72749. return dif
  72750. }
  72751. /***/ }),
  72752. /***/ "./node_modules/public-encrypt/publicEncrypt.js":
  72753. /*!******************************************************!*\
  72754. !*** ./node_modules/public-encrypt/publicEncrypt.js ***!
  72755. \******************************************************/
  72756. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  72757. var parseKeys = __webpack_require__(/*! parse-asn1 */ "./node_modules/parse-asn1/index.js")
  72758. var randomBytes = __webpack_require__(/*! randombytes */ "./node_modules/randombytes/browser.js")
  72759. var createHash = __webpack_require__(/*! create-hash */ "./node_modules/create-hash/browser.js")
  72760. var mgf = __webpack_require__(/*! ./mgf */ "./node_modules/public-encrypt/mgf.js")
  72761. var xor = __webpack_require__(/*! ./xor */ "./node_modules/public-encrypt/xor.js")
  72762. var BN = __webpack_require__(/*! bn.js */ "./node_modules/public-encrypt/node_modules/bn.js/lib/bn.js")
  72763. var withPublic = __webpack_require__(/*! ./withPublic */ "./node_modules/public-encrypt/withPublic.js")
  72764. var crt = __webpack_require__(/*! browserify-rsa */ "./node_modules/browserify-rsa/index.js")
  72765. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  72766. module.exports = function publicEncrypt (publicKey, msg, reverse) {
  72767. var padding
  72768. if (publicKey.padding) {
  72769. padding = publicKey.padding
  72770. } else if (reverse) {
  72771. padding = 1
  72772. } else {
  72773. padding = 4
  72774. }
  72775. var key = parseKeys(publicKey)
  72776. var paddedMsg
  72777. if (padding === 4) {
  72778. paddedMsg = oaep(key, msg)
  72779. } else if (padding === 1) {
  72780. paddedMsg = pkcs1(key, msg, reverse)
  72781. } else if (padding === 3) {
  72782. paddedMsg = new BN(msg)
  72783. if (paddedMsg.cmp(key.modulus) >= 0) {
  72784. throw new Error('data too long for modulus')
  72785. }
  72786. } else {
  72787. throw new Error('unknown padding')
  72788. }
  72789. if (reverse) {
  72790. return crt(paddedMsg, key)
  72791. } else {
  72792. return withPublic(paddedMsg, key)
  72793. }
  72794. }
  72795. function oaep (key, msg) {
  72796. var k = key.modulus.byteLength()
  72797. var mLen = msg.length
  72798. var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
  72799. var hLen = iHash.length
  72800. var hLen2 = 2 * hLen
  72801. if (mLen > k - hLen2 - 2) {
  72802. throw new Error('message too long')
  72803. }
  72804. var ps = Buffer.alloc(k - mLen - hLen2 - 2)
  72805. var dblen = k - hLen - 1
  72806. var seed = randomBytes(hLen)
  72807. var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen))
  72808. var maskedSeed = xor(seed, mgf(maskedDb, hLen))
  72809. return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k))
  72810. }
  72811. function pkcs1 (key, msg, reverse) {
  72812. var mLen = msg.length
  72813. var k = key.modulus.byteLength()
  72814. if (mLen > k - 11) {
  72815. throw new Error('message too long')
  72816. }
  72817. var ps
  72818. if (reverse) {
  72819. ps = Buffer.alloc(k - mLen - 3, 0xff)
  72820. } else {
  72821. ps = nonZero(k - mLen - 3)
  72822. }
  72823. return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k))
  72824. }
  72825. function nonZero (len) {
  72826. var out = Buffer.allocUnsafe(len)
  72827. var i = 0
  72828. var cache = randomBytes(len * 2)
  72829. var cur = 0
  72830. var num
  72831. while (i < len) {
  72832. if (cur === cache.length) {
  72833. cache = randomBytes(len * 2)
  72834. cur = 0
  72835. }
  72836. num = cache[cur++]
  72837. if (num) {
  72838. out[i++] = num
  72839. }
  72840. }
  72841. return out
  72842. }
  72843. /***/ }),
  72844. /***/ "./node_modules/public-encrypt/withPublic.js":
  72845. /*!***************************************************!*\
  72846. !*** ./node_modules/public-encrypt/withPublic.js ***!
  72847. \***************************************************/
  72848. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  72849. var BN = __webpack_require__(/*! bn.js */ "./node_modules/public-encrypt/node_modules/bn.js/lib/bn.js")
  72850. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  72851. function withPublic (paddedMsg, key) {
  72852. return Buffer.from(paddedMsg
  72853. .toRed(BN.mont(key.modulus))
  72854. .redPow(new BN(key.publicExponent))
  72855. .fromRed()
  72856. .toArray())
  72857. }
  72858. module.exports = withPublic
  72859. /***/ }),
  72860. /***/ "./node_modules/public-encrypt/xor.js":
  72861. /*!********************************************!*\
  72862. !*** ./node_modules/public-encrypt/xor.js ***!
  72863. \********************************************/
  72864. /***/ ((module) => {
  72865. module.exports = function xor (a, b) {
  72866. var len = a.length
  72867. var i = -1
  72868. while (++i < len) {
  72869. a[i] ^= b[i]
  72870. }
  72871. return a
  72872. }
  72873. /***/ }),
  72874. /***/ "./node_modules/randombytes/browser.js":
  72875. /*!*********************************************!*\
  72876. !*** ./node_modules/randombytes/browser.js ***!
  72877. \*********************************************/
  72878. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  72879. "use strict";
  72880. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  72881. // limit of Crypto.getRandomValues()
  72882. // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
  72883. var MAX_BYTES = 65536
  72884. // Node supports requesting up to this number of bytes
  72885. // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
  72886. var MAX_UINT32 = 4294967295
  72887. function oldBrowser () {
  72888. throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
  72889. }
  72890. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  72891. var crypto = __webpack_require__.g.crypto || __webpack_require__.g.msCrypto
  72892. if (crypto && crypto.getRandomValues) {
  72893. module.exports = randomBytes
  72894. } else {
  72895. module.exports = oldBrowser
  72896. }
  72897. function randomBytes (size, cb) {
  72898. // phantomjs needs to throw
  72899. if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
  72900. var bytes = Buffer.allocUnsafe(size)
  72901. if (size > 0) { // getRandomValues fails on IE if size == 0
  72902. if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
  72903. // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
  72904. for (var generated = 0; generated < size; generated += MAX_BYTES) {
  72905. // buffer.slice automatically checks if the end is past the end of
  72906. // the buffer so we don't have to here
  72907. crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
  72908. }
  72909. } else {
  72910. crypto.getRandomValues(bytes)
  72911. }
  72912. }
  72913. if (typeof cb === 'function') {
  72914. return process.nextTick(function () {
  72915. cb(null, bytes)
  72916. })
  72917. }
  72918. return bytes
  72919. }
  72920. /***/ }),
  72921. /***/ "./node_modules/randomfill/browser.js":
  72922. /*!********************************************!*\
  72923. !*** ./node_modules/randomfill/browser.js ***!
  72924. \********************************************/
  72925. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  72926. "use strict";
  72927. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  72928. function oldBrowser () {
  72929. throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
  72930. }
  72931. var safeBuffer = __webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js")
  72932. var randombytes = __webpack_require__(/*! randombytes */ "./node_modules/randombytes/browser.js")
  72933. var Buffer = safeBuffer.Buffer
  72934. var kBufferMaxLength = safeBuffer.kMaxLength
  72935. var crypto = __webpack_require__.g.crypto || __webpack_require__.g.msCrypto
  72936. var kMaxUint32 = Math.pow(2, 32) - 1
  72937. function assertOffset (offset, length) {
  72938. if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
  72939. throw new TypeError('offset must be a number')
  72940. }
  72941. if (offset > kMaxUint32 || offset < 0) {
  72942. throw new TypeError('offset must be a uint32')
  72943. }
  72944. if (offset > kBufferMaxLength || offset > length) {
  72945. throw new RangeError('offset out of range')
  72946. }
  72947. }
  72948. function assertSize (size, offset, length) {
  72949. if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
  72950. throw new TypeError('size must be a number')
  72951. }
  72952. if (size > kMaxUint32 || size < 0) {
  72953. throw new TypeError('size must be a uint32')
  72954. }
  72955. if (size + offset > length || size > kBufferMaxLength) {
  72956. throw new RangeError('buffer too small')
  72957. }
  72958. }
  72959. if ((crypto && crypto.getRandomValues) || !process.browser) {
  72960. exports.randomFill = randomFill
  72961. exports.randomFillSync = randomFillSync
  72962. } else {
  72963. exports.randomFill = oldBrowser
  72964. exports.randomFillSync = oldBrowser
  72965. }
  72966. function randomFill (buf, offset, size, cb) {
  72967. if (!Buffer.isBuffer(buf) && !(buf instanceof __webpack_require__.g.Uint8Array)) {
  72968. throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
  72969. }
  72970. if (typeof offset === 'function') {
  72971. cb = offset
  72972. offset = 0
  72973. size = buf.length
  72974. } else if (typeof size === 'function') {
  72975. cb = size
  72976. size = buf.length - offset
  72977. } else if (typeof cb !== 'function') {
  72978. throw new TypeError('"cb" argument must be a function')
  72979. }
  72980. assertOffset(offset, buf.length)
  72981. assertSize(size, offset, buf.length)
  72982. return actualFill(buf, offset, size, cb)
  72983. }
  72984. function actualFill (buf, offset, size, cb) {
  72985. if (process.browser) {
  72986. var ourBuf = buf.buffer
  72987. var uint = new Uint8Array(ourBuf, offset, size)
  72988. crypto.getRandomValues(uint)
  72989. if (cb) {
  72990. process.nextTick(function () {
  72991. cb(null, buf)
  72992. })
  72993. return
  72994. }
  72995. return buf
  72996. }
  72997. if (cb) {
  72998. randombytes(size, function (err, bytes) {
  72999. if (err) {
  73000. return cb(err)
  73001. }
  73002. bytes.copy(buf, offset)
  73003. cb(null, buf)
  73004. })
  73005. return
  73006. }
  73007. var bytes = randombytes(size)
  73008. bytes.copy(buf, offset)
  73009. return buf
  73010. }
  73011. function randomFillSync (buf, offset, size) {
  73012. if (typeof offset === 'undefined') {
  73013. offset = 0
  73014. }
  73015. if (!Buffer.isBuffer(buf) && !(buf instanceof __webpack_require__.g.Uint8Array)) {
  73016. throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
  73017. }
  73018. assertOffset(offset, buf.length)
  73019. if (size === undefined) size = buf.length - offset
  73020. assertSize(size, offset, buf.length)
  73021. return actualFill(buf, offset, size)
  73022. }
  73023. /***/ }),
  73024. /***/ "./node_modules/ripemd160/index.js":
  73025. /*!*****************************************!*\
  73026. !*** ./node_modules/ripemd160/index.js ***!
  73027. \*****************************************/
  73028. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73029. "use strict";
  73030. var Buffer = (__webpack_require__(/*! buffer */ "./node_modules/buffer/index.js").Buffer)
  73031. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73032. var HashBase = __webpack_require__(/*! hash-base */ "./node_modules/hash-base/index.js")
  73033. var ARRAY16 = new Array(16)
  73034. var zl = [
  73035. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  73036. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  73037. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  73038. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  73039. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  73040. ]
  73041. var zr = [
  73042. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  73043. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  73044. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  73045. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  73046. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  73047. ]
  73048. var sl = [
  73049. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  73050. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  73051. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  73052. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  73053. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  73054. ]
  73055. var sr = [
  73056. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  73057. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  73058. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  73059. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  73060. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  73061. ]
  73062. var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
  73063. var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
  73064. function RIPEMD160 () {
  73065. HashBase.call(this, 64)
  73066. // state
  73067. this._a = 0x67452301
  73068. this._b = 0xefcdab89
  73069. this._c = 0x98badcfe
  73070. this._d = 0x10325476
  73071. this._e = 0xc3d2e1f0
  73072. }
  73073. inherits(RIPEMD160, HashBase)
  73074. RIPEMD160.prototype._update = function () {
  73075. var words = ARRAY16
  73076. for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
  73077. var al = this._a | 0
  73078. var bl = this._b | 0
  73079. var cl = this._c | 0
  73080. var dl = this._d | 0
  73081. var el = this._e | 0
  73082. var ar = this._a | 0
  73083. var br = this._b | 0
  73084. var cr = this._c | 0
  73085. var dr = this._d | 0
  73086. var er = this._e | 0
  73087. // computation
  73088. for (var i = 0; i < 80; i += 1) {
  73089. var tl
  73090. var tr
  73091. if (i < 16) {
  73092. tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
  73093. tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
  73094. } else if (i < 32) {
  73095. tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
  73096. tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
  73097. } else if (i < 48) {
  73098. tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
  73099. tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
  73100. } else if (i < 64) {
  73101. tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
  73102. tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
  73103. } else { // if (i<80) {
  73104. tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
  73105. tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
  73106. }
  73107. al = el
  73108. el = dl
  73109. dl = rotl(cl, 10)
  73110. cl = bl
  73111. bl = tl
  73112. ar = er
  73113. er = dr
  73114. dr = rotl(cr, 10)
  73115. cr = br
  73116. br = tr
  73117. }
  73118. // update state
  73119. var t = (this._b + cl + dr) | 0
  73120. this._b = (this._c + dl + er) | 0
  73121. this._c = (this._d + el + ar) | 0
  73122. this._d = (this._e + al + br) | 0
  73123. this._e = (this._a + bl + cr) | 0
  73124. this._a = t
  73125. }
  73126. RIPEMD160.prototype._digest = function () {
  73127. // create padding and handle blocks
  73128. this._block[this._blockOffset++] = 0x80
  73129. if (this._blockOffset > 56) {
  73130. this._block.fill(0, this._blockOffset, 64)
  73131. this._update()
  73132. this._blockOffset = 0
  73133. }
  73134. this._block.fill(0, this._blockOffset, 56)
  73135. this._block.writeUInt32LE(this._length[0], 56)
  73136. this._block.writeUInt32LE(this._length[1], 60)
  73137. this._update()
  73138. // produce result
  73139. var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
  73140. buffer.writeInt32LE(this._a, 0)
  73141. buffer.writeInt32LE(this._b, 4)
  73142. buffer.writeInt32LE(this._c, 8)
  73143. buffer.writeInt32LE(this._d, 12)
  73144. buffer.writeInt32LE(this._e, 16)
  73145. return buffer
  73146. }
  73147. function rotl (x, n) {
  73148. return (x << n) | (x >>> (32 - n))
  73149. }
  73150. function fn1 (a, b, c, d, e, m, k, s) {
  73151. return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
  73152. }
  73153. function fn2 (a, b, c, d, e, m, k, s) {
  73154. return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
  73155. }
  73156. function fn3 (a, b, c, d, e, m, k, s) {
  73157. return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
  73158. }
  73159. function fn4 (a, b, c, d, e, m, k, s) {
  73160. return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
  73161. }
  73162. function fn5 (a, b, c, d, e, m, k, s) {
  73163. return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
  73164. }
  73165. module.exports = RIPEMD160
  73166. /***/ }),
  73167. /***/ "./node_modules/safe-buffer/index.js":
  73168. /*!*******************************************!*\
  73169. !*** ./node_modules/safe-buffer/index.js ***!
  73170. \*******************************************/
  73171. /***/ ((module, exports, __webpack_require__) => {
  73172. /* eslint-disable node/no-deprecated-api */
  73173. var buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")
  73174. var Buffer = buffer.Buffer
  73175. // alternative to using Object.keys for old browsers
  73176. function copyProps (src, dst) {
  73177. for (var key in src) {
  73178. dst[key] = src[key]
  73179. }
  73180. }
  73181. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  73182. module.exports = buffer
  73183. } else {
  73184. // Copy properties from require('buffer')
  73185. copyProps(buffer, exports)
  73186. exports.Buffer = SafeBuffer
  73187. }
  73188. function SafeBuffer (arg, encodingOrOffset, length) {
  73189. return Buffer(arg, encodingOrOffset, length)
  73190. }
  73191. // Copy static methods from Buffer
  73192. copyProps(Buffer, SafeBuffer)
  73193. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  73194. if (typeof arg === 'number') {
  73195. throw new TypeError('Argument must not be a number')
  73196. }
  73197. return Buffer(arg, encodingOrOffset, length)
  73198. }
  73199. SafeBuffer.alloc = function (size, fill, encoding) {
  73200. if (typeof size !== 'number') {
  73201. throw new TypeError('Argument must be a number')
  73202. }
  73203. var buf = Buffer(size)
  73204. if (fill !== undefined) {
  73205. if (typeof encoding === 'string') {
  73206. buf.fill(fill, encoding)
  73207. } else {
  73208. buf.fill(fill)
  73209. }
  73210. } else {
  73211. buf.fill(0)
  73212. }
  73213. return buf
  73214. }
  73215. SafeBuffer.allocUnsafe = function (size) {
  73216. if (typeof size !== 'number') {
  73217. throw new TypeError('Argument must be a number')
  73218. }
  73219. return Buffer(size)
  73220. }
  73221. SafeBuffer.allocUnsafeSlow = function (size) {
  73222. if (typeof size !== 'number') {
  73223. throw new TypeError('Argument must be a number')
  73224. }
  73225. return buffer.SlowBuffer(size)
  73226. }
  73227. /***/ }),
  73228. /***/ "./node_modules/safer-buffer/safer.js":
  73229. /*!********************************************!*\
  73230. !*** ./node_modules/safer-buffer/safer.js ***!
  73231. \********************************************/
  73232. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73233. "use strict";
  73234. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  73235. /* eslint-disable node/no-deprecated-api */
  73236. var buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")
  73237. var Buffer = buffer.Buffer
  73238. var safer = {}
  73239. var key
  73240. for (key in buffer) {
  73241. if (!buffer.hasOwnProperty(key)) continue
  73242. if (key === 'SlowBuffer' || key === 'Buffer') continue
  73243. safer[key] = buffer[key]
  73244. }
  73245. var Safer = safer.Buffer = {}
  73246. for (key in Buffer) {
  73247. if (!Buffer.hasOwnProperty(key)) continue
  73248. if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue
  73249. Safer[key] = Buffer[key]
  73250. }
  73251. safer.Buffer.prototype = Buffer.prototype
  73252. if (!Safer.from || Safer.from === Uint8Array.from) {
  73253. Safer.from = function (value, encodingOrOffset, length) {
  73254. if (typeof value === 'number') {
  73255. throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value)
  73256. }
  73257. if (value && typeof value.length === 'undefined') {
  73258. throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)
  73259. }
  73260. return Buffer(value, encodingOrOffset, length)
  73261. }
  73262. }
  73263. if (!Safer.alloc) {
  73264. Safer.alloc = function (size, fill, encoding) {
  73265. if (typeof size !== 'number') {
  73266. throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)
  73267. }
  73268. if (size < 0 || size >= 2 * (1 << 30)) {
  73269. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  73270. }
  73271. var buf = Buffer(size)
  73272. if (!fill || fill.length === 0) {
  73273. buf.fill(0)
  73274. } else if (typeof encoding === 'string') {
  73275. buf.fill(fill, encoding)
  73276. } else {
  73277. buf.fill(fill)
  73278. }
  73279. return buf
  73280. }
  73281. }
  73282. if (!safer.kStringMaxLength) {
  73283. try {
  73284. safer.kStringMaxLength = process.binding('buffer').kStringMaxLength
  73285. } catch (e) {
  73286. // we can't determine kStringMaxLength in environments where process.binding
  73287. // is unsupported, so let's not set it
  73288. }
  73289. }
  73290. if (!safer.constants) {
  73291. safer.constants = {
  73292. MAX_LENGTH: safer.kMaxLength
  73293. }
  73294. if (safer.kStringMaxLength) {
  73295. safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength
  73296. }
  73297. }
  73298. module.exports = safer
  73299. /***/ }),
  73300. /***/ "./node_modules/sha.js/hash.js":
  73301. /*!*************************************!*\
  73302. !*** ./node_modules/sha.js/hash.js ***!
  73303. \*************************************/
  73304. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73305. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73306. // prototype class for hash functions
  73307. function Hash (blockSize, finalSize) {
  73308. this._block = Buffer.alloc(blockSize)
  73309. this._finalSize = finalSize
  73310. this._blockSize = blockSize
  73311. this._len = 0
  73312. }
  73313. Hash.prototype.update = function (data, enc) {
  73314. if (typeof data === 'string') {
  73315. enc = enc || 'utf8'
  73316. data = Buffer.from(data, enc)
  73317. }
  73318. var block = this._block
  73319. var blockSize = this._blockSize
  73320. var length = data.length
  73321. var accum = this._len
  73322. for (var offset = 0; offset < length;) {
  73323. var assigned = accum % blockSize
  73324. var remainder = Math.min(length - offset, blockSize - assigned)
  73325. for (var i = 0; i < remainder; i++) {
  73326. block[assigned + i] = data[offset + i]
  73327. }
  73328. accum += remainder
  73329. offset += remainder
  73330. if ((accum % blockSize) === 0) {
  73331. this._update(block)
  73332. }
  73333. }
  73334. this._len += length
  73335. return this
  73336. }
  73337. Hash.prototype.digest = function (enc) {
  73338. var rem = this._len % this._blockSize
  73339. this._block[rem] = 0x80
  73340. // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
  73341. // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
  73342. this._block.fill(0, rem + 1)
  73343. if (rem >= this._finalSize) {
  73344. this._update(this._block)
  73345. this._block.fill(0)
  73346. }
  73347. var bits = this._len * 8
  73348. // uint32
  73349. if (bits <= 0xffffffff) {
  73350. this._block.writeUInt32BE(bits, this._blockSize - 4)
  73351. // uint64
  73352. } else {
  73353. var lowBits = (bits & 0xffffffff) >>> 0
  73354. var highBits = (bits - lowBits) / 0x100000000
  73355. this._block.writeUInt32BE(highBits, this._blockSize - 8)
  73356. this._block.writeUInt32BE(lowBits, this._blockSize - 4)
  73357. }
  73358. this._update(this._block)
  73359. var hash = this._hash()
  73360. return enc ? hash.toString(enc) : hash
  73361. }
  73362. Hash.prototype._update = function () {
  73363. throw new Error('_update must be implemented by subclass')
  73364. }
  73365. module.exports = Hash
  73366. /***/ }),
  73367. /***/ "./node_modules/sha.js/index.js":
  73368. /*!**************************************!*\
  73369. !*** ./node_modules/sha.js/index.js ***!
  73370. \**************************************/
  73371. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73372. var exports = module.exports = function SHA (algorithm) {
  73373. algorithm = algorithm.toLowerCase()
  73374. var Algorithm = exports[algorithm]
  73375. if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
  73376. return new Algorithm()
  73377. }
  73378. exports.sha = __webpack_require__(/*! ./sha */ "./node_modules/sha.js/sha.js")
  73379. exports.sha1 = __webpack_require__(/*! ./sha1 */ "./node_modules/sha.js/sha1.js")
  73380. exports.sha224 = __webpack_require__(/*! ./sha224 */ "./node_modules/sha.js/sha224.js")
  73381. exports.sha256 = __webpack_require__(/*! ./sha256 */ "./node_modules/sha.js/sha256.js")
  73382. exports.sha384 = __webpack_require__(/*! ./sha384 */ "./node_modules/sha.js/sha384.js")
  73383. exports.sha512 = __webpack_require__(/*! ./sha512 */ "./node_modules/sha.js/sha512.js")
  73384. /***/ }),
  73385. /***/ "./node_modules/sha.js/sha.js":
  73386. /*!************************************!*\
  73387. !*** ./node_modules/sha.js/sha.js ***!
  73388. \************************************/
  73389. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73390. /*
  73391. * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
  73392. * in FIPS PUB 180-1
  73393. * This source code is derived from sha1.js of the same repository.
  73394. * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
  73395. * operation was added.
  73396. */
  73397. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73398. var Hash = __webpack_require__(/*! ./hash */ "./node_modules/sha.js/hash.js")
  73399. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73400. var K = [
  73401. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  73402. ]
  73403. var W = new Array(80)
  73404. function Sha () {
  73405. this.init()
  73406. this._w = W
  73407. Hash.call(this, 64, 56)
  73408. }
  73409. inherits(Sha, Hash)
  73410. Sha.prototype.init = function () {
  73411. this._a = 0x67452301
  73412. this._b = 0xefcdab89
  73413. this._c = 0x98badcfe
  73414. this._d = 0x10325476
  73415. this._e = 0xc3d2e1f0
  73416. return this
  73417. }
  73418. function rotl5 (num) {
  73419. return (num << 5) | (num >>> 27)
  73420. }
  73421. function rotl30 (num) {
  73422. return (num << 30) | (num >>> 2)
  73423. }
  73424. function ft (s, b, c, d) {
  73425. if (s === 0) return (b & c) | ((~b) & d)
  73426. if (s === 2) return (b & c) | (b & d) | (c & d)
  73427. return b ^ c ^ d
  73428. }
  73429. Sha.prototype._update = function (M) {
  73430. var W = this._w
  73431. var a = this._a | 0
  73432. var b = this._b | 0
  73433. var c = this._c | 0
  73434. var d = this._d | 0
  73435. var e = this._e | 0
  73436. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  73437. for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
  73438. for (var j = 0; j < 80; ++j) {
  73439. var s = ~~(j / 20)
  73440. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  73441. e = d
  73442. d = c
  73443. c = rotl30(b)
  73444. b = a
  73445. a = t
  73446. }
  73447. this._a = (a + this._a) | 0
  73448. this._b = (b + this._b) | 0
  73449. this._c = (c + this._c) | 0
  73450. this._d = (d + this._d) | 0
  73451. this._e = (e + this._e) | 0
  73452. }
  73453. Sha.prototype._hash = function () {
  73454. var H = Buffer.allocUnsafe(20)
  73455. H.writeInt32BE(this._a | 0, 0)
  73456. H.writeInt32BE(this._b | 0, 4)
  73457. H.writeInt32BE(this._c | 0, 8)
  73458. H.writeInt32BE(this._d | 0, 12)
  73459. H.writeInt32BE(this._e | 0, 16)
  73460. return H
  73461. }
  73462. module.exports = Sha
  73463. /***/ }),
  73464. /***/ "./node_modules/sha.js/sha1.js":
  73465. /*!*************************************!*\
  73466. !*** ./node_modules/sha.js/sha1.js ***!
  73467. \*************************************/
  73468. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73469. /*
  73470. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  73471. * in FIPS PUB 180-1
  73472. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  73473. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  73474. * Distributed under the BSD License
  73475. * See http://pajhome.org.uk/crypt/md5 for details.
  73476. */
  73477. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73478. var Hash = __webpack_require__(/*! ./hash */ "./node_modules/sha.js/hash.js")
  73479. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73480. var K = [
  73481. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  73482. ]
  73483. var W = new Array(80)
  73484. function Sha1 () {
  73485. this.init()
  73486. this._w = W
  73487. Hash.call(this, 64, 56)
  73488. }
  73489. inherits(Sha1, Hash)
  73490. Sha1.prototype.init = function () {
  73491. this._a = 0x67452301
  73492. this._b = 0xefcdab89
  73493. this._c = 0x98badcfe
  73494. this._d = 0x10325476
  73495. this._e = 0xc3d2e1f0
  73496. return this
  73497. }
  73498. function rotl1 (num) {
  73499. return (num << 1) | (num >>> 31)
  73500. }
  73501. function rotl5 (num) {
  73502. return (num << 5) | (num >>> 27)
  73503. }
  73504. function rotl30 (num) {
  73505. return (num << 30) | (num >>> 2)
  73506. }
  73507. function ft (s, b, c, d) {
  73508. if (s === 0) return (b & c) | ((~b) & d)
  73509. if (s === 2) return (b & c) | (b & d) | (c & d)
  73510. return b ^ c ^ d
  73511. }
  73512. Sha1.prototype._update = function (M) {
  73513. var W = this._w
  73514. var a = this._a | 0
  73515. var b = this._b | 0
  73516. var c = this._c | 0
  73517. var d = this._d | 0
  73518. var e = this._e | 0
  73519. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  73520. for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
  73521. for (var j = 0; j < 80; ++j) {
  73522. var s = ~~(j / 20)
  73523. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  73524. e = d
  73525. d = c
  73526. c = rotl30(b)
  73527. b = a
  73528. a = t
  73529. }
  73530. this._a = (a + this._a) | 0
  73531. this._b = (b + this._b) | 0
  73532. this._c = (c + this._c) | 0
  73533. this._d = (d + this._d) | 0
  73534. this._e = (e + this._e) | 0
  73535. }
  73536. Sha1.prototype._hash = function () {
  73537. var H = Buffer.allocUnsafe(20)
  73538. H.writeInt32BE(this._a | 0, 0)
  73539. H.writeInt32BE(this._b | 0, 4)
  73540. H.writeInt32BE(this._c | 0, 8)
  73541. H.writeInt32BE(this._d | 0, 12)
  73542. H.writeInt32BE(this._e | 0, 16)
  73543. return H
  73544. }
  73545. module.exports = Sha1
  73546. /***/ }),
  73547. /***/ "./node_modules/sha.js/sha224.js":
  73548. /*!***************************************!*\
  73549. !*** ./node_modules/sha.js/sha224.js ***!
  73550. \***************************************/
  73551. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73552. /**
  73553. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  73554. * in FIPS 180-2
  73555. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  73556. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  73557. *
  73558. */
  73559. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73560. var Sha256 = __webpack_require__(/*! ./sha256 */ "./node_modules/sha.js/sha256.js")
  73561. var Hash = __webpack_require__(/*! ./hash */ "./node_modules/sha.js/hash.js")
  73562. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73563. var W = new Array(64)
  73564. function Sha224 () {
  73565. this.init()
  73566. this._w = W // new Array(64)
  73567. Hash.call(this, 64, 56)
  73568. }
  73569. inherits(Sha224, Sha256)
  73570. Sha224.prototype.init = function () {
  73571. this._a = 0xc1059ed8
  73572. this._b = 0x367cd507
  73573. this._c = 0x3070dd17
  73574. this._d = 0xf70e5939
  73575. this._e = 0xffc00b31
  73576. this._f = 0x68581511
  73577. this._g = 0x64f98fa7
  73578. this._h = 0xbefa4fa4
  73579. return this
  73580. }
  73581. Sha224.prototype._hash = function () {
  73582. var H = Buffer.allocUnsafe(28)
  73583. H.writeInt32BE(this._a, 0)
  73584. H.writeInt32BE(this._b, 4)
  73585. H.writeInt32BE(this._c, 8)
  73586. H.writeInt32BE(this._d, 12)
  73587. H.writeInt32BE(this._e, 16)
  73588. H.writeInt32BE(this._f, 20)
  73589. H.writeInt32BE(this._g, 24)
  73590. return H
  73591. }
  73592. module.exports = Sha224
  73593. /***/ }),
  73594. /***/ "./node_modules/sha.js/sha256.js":
  73595. /*!***************************************!*\
  73596. !*** ./node_modules/sha.js/sha256.js ***!
  73597. \***************************************/
  73598. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73599. /**
  73600. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  73601. * in FIPS 180-2
  73602. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  73603. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  73604. *
  73605. */
  73606. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73607. var Hash = __webpack_require__(/*! ./hash */ "./node_modules/sha.js/hash.js")
  73608. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73609. var K = [
  73610. 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
  73611. 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
  73612. 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
  73613. 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
  73614. 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
  73615. 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
  73616. 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
  73617. 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
  73618. 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
  73619. 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
  73620. 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
  73621. 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
  73622. 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
  73623. 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
  73624. 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
  73625. 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
  73626. ]
  73627. var W = new Array(64)
  73628. function Sha256 () {
  73629. this.init()
  73630. this._w = W // new Array(64)
  73631. Hash.call(this, 64, 56)
  73632. }
  73633. inherits(Sha256, Hash)
  73634. Sha256.prototype.init = function () {
  73635. this._a = 0x6a09e667
  73636. this._b = 0xbb67ae85
  73637. this._c = 0x3c6ef372
  73638. this._d = 0xa54ff53a
  73639. this._e = 0x510e527f
  73640. this._f = 0x9b05688c
  73641. this._g = 0x1f83d9ab
  73642. this._h = 0x5be0cd19
  73643. return this
  73644. }
  73645. function ch (x, y, z) {
  73646. return z ^ (x & (y ^ z))
  73647. }
  73648. function maj (x, y, z) {
  73649. return (x & y) | (z & (x | y))
  73650. }
  73651. function sigma0 (x) {
  73652. return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
  73653. }
  73654. function sigma1 (x) {
  73655. return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
  73656. }
  73657. function gamma0 (x) {
  73658. return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
  73659. }
  73660. function gamma1 (x) {
  73661. return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
  73662. }
  73663. Sha256.prototype._update = function (M) {
  73664. var W = this._w
  73665. var a = this._a | 0
  73666. var b = this._b | 0
  73667. var c = this._c | 0
  73668. var d = this._d | 0
  73669. var e = this._e | 0
  73670. var f = this._f | 0
  73671. var g = this._g | 0
  73672. var h = this._h | 0
  73673. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  73674. for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
  73675. for (var j = 0; j < 64; ++j) {
  73676. var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
  73677. var T2 = (sigma0(a) + maj(a, b, c)) | 0
  73678. h = g
  73679. g = f
  73680. f = e
  73681. e = (d + T1) | 0
  73682. d = c
  73683. c = b
  73684. b = a
  73685. a = (T1 + T2) | 0
  73686. }
  73687. this._a = (a + this._a) | 0
  73688. this._b = (b + this._b) | 0
  73689. this._c = (c + this._c) | 0
  73690. this._d = (d + this._d) | 0
  73691. this._e = (e + this._e) | 0
  73692. this._f = (f + this._f) | 0
  73693. this._g = (g + this._g) | 0
  73694. this._h = (h + this._h) | 0
  73695. }
  73696. Sha256.prototype._hash = function () {
  73697. var H = Buffer.allocUnsafe(32)
  73698. H.writeInt32BE(this._a, 0)
  73699. H.writeInt32BE(this._b, 4)
  73700. H.writeInt32BE(this._c, 8)
  73701. H.writeInt32BE(this._d, 12)
  73702. H.writeInt32BE(this._e, 16)
  73703. H.writeInt32BE(this._f, 20)
  73704. H.writeInt32BE(this._g, 24)
  73705. H.writeInt32BE(this._h, 28)
  73706. return H
  73707. }
  73708. module.exports = Sha256
  73709. /***/ }),
  73710. /***/ "./node_modules/sha.js/sha384.js":
  73711. /*!***************************************!*\
  73712. !*** ./node_modules/sha.js/sha384.js ***!
  73713. \***************************************/
  73714. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73715. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73716. var SHA512 = __webpack_require__(/*! ./sha512 */ "./node_modules/sha.js/sha512.js")
  73717. var Hash = __webpack_require__(/*! ./hash */ "./node_modules/sha.js/hash.js")
  73718. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73719. var W = new Array(160)
  73720. function Sha384 () {
  73721. this.init()
  73722. this._w = W
  73723. Hash.call(this, 128, 112)
  73724. }
  73725. inherits(Sha384, SHA512)
  73726. Sha384.prototype.init = function () {
  73727. this._ah = 0xcbbb9d5d
  73728. this._bh = 0x629a292a
  73729. this._ch = 0x9159015a
  73730. this._dh = 0x152fecd8
  73731. this._eh = 0x67332667
  73732. this._fh = 0x8eb44a87
  73733. this._gh = 0xdb0c2e0d
  73734. this._hh = 0x47b5481d
  73735. this._al = 0xc1059ed8
  73736. this._bl = 0x367cd507
  73737. this._cl = 0x3070dd17
  73738. this._dl = 0xf70e5939
  73739. this._el = 0xffc00b31
  73740. this._fl = 0x68581511
  73741. this._gl = 0x64f98fa7
  73742. this._hl = 0xbefa4fa4
  73743. return this
  73744. }
  73745. Sha384.prototype._hash = function () {
  73746. var H = Buffer.allocUnsafe(48)
  73747. function writeInt64BE (h, l, offset) {
  73748. H.writeInt32BE(h, offset)
  73749. H.writeInt32BE(l, offset + 4)
  73750. }
  73751. writeInt64BE(this._ah, this._al, 0)
  73752. writeInt64BE(this._bh, this._bl, 8)
  73753. writeInt64BE(this._ch, this._cl, 16)
  73754. writeInt64BE(this._dh, this._dl, 24)
  73755. writeInt64BE(this._eh, this._el, 32)
  73756. writeInt64BE(this._fh, this._fl, 40)
  73757. return H
  73758. }
  73759. module.exports = Sha384
  73760. /***/ }),
  73761. /***/ "./node_modules/sha.js/sha512.js":
  73762. /*!***************************************!*\
  73763. !*** ./node_modules/sha.js/sha512.js ***!
  73764. \***************************************/
  73765. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  73766. var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js")
  73767. var Hash = __webpack_require__(/*! ./hash */ "./node_modules/sha.js/hash.js")
  73768. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/safe-buffer/index.js").Buffer)
  73769. var K = [
  73770. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  73771. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  73772. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  73773. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  73774. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  73775. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  73776. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  73777. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  73778. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  73779. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  73780. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  73781. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  73782. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  73783. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  73784. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  73785. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  73786. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  73787. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  73788. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  73789. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  73790. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  73791. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  73792. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  73793. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  73794. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  73795. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  73796. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  73797. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  73798. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  73799. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  73800. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  73801. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  73802. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  73803. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  73804. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  73805. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  73806. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  73807. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  73808. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  73809. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  73810. ]
  73811. var W = new Array(160)
  73812. function Sha512 () {
  73813. this.init()
  73814. this._w = W
  73815. Hash.call(this, 128, 112)
  73816. }
  73817. inherits(Sha512, Hash)
  73818. Sha512.prototype.init = function () {
  73819. this._ah = 0x6a09e667
  73820. this._bh = 0xbb67ae85
  73821. this._ch = 0x3c6ef372
  73822. this._dh = 0xa54ff53a
  73823. this._eh = 0x510e527f
  73824. this._fh = 0x9b05688c
  73825. this._gh = 0x1f83d9ab
  73826. this._hh = 0x5be0cd19
  73827. this._al = 0xf3bcc908
  73828. this._bl = 0x84caa73b
  73829. this._cl = 0xfe94f82b
  73830. this._dl = 0x5f1d36f1
  73831. this._el = 0xade682d1
  73832. this._fl = 0x2b3e6c1f
  73833. this._gl = 0xfb41bd6b
  73834. this._hl = 0x137e2179
  73835. return this
  73836. }
  73837. function Ch (x, y, z) {
  73838. return z ^ (x & (y ^ z))
  73839. }
  73840. function maj (x, y, z) {
  73841. return (x & y) | (z & (x | y))
  73842. }
  73843. function sigma0 (x, xl) {
  73844. return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
  73845. }
  73846. function sigma1 (x, xl) {
  73847. return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
  73848. }
  73849. function Gamma0 (x, xl) {
  73850. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
  73851. }
  73852. function Gamma0l (x, xl) {
  73853. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
  73854. }
  73855. function Gamma1 (x, xl) {
  73856. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
  73857. }
  73858. function Gamma1l (x, xl) {
  73859. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
  73860. }
  73861. function getCarry (a, b) {
  73862. return (a >>> 0) < (b >>> 0) ? 1 : 0
  73863. }
  73864. Sha512.prototype._update = function (M) {
  73865. var W = this._w
  73866. var ah = this._ah | 0
  73867. var bh = this._bh | 0
  73868. var ch = this._ch | 0
  73869. var dh = this._dh | 0
  73870. var eh = this._eh | 0
  73871. var fh = this._fh | 0
  73872. var gh = this._gh | 0
  73873. var hh = this._hh | 0
  73874. var al = this._al | 0
  73875. var bl = this._bl | 0
  73876. var cl = this._cl | 0
  73877. var dl = this._dl | 0
  73878. var el = this._el | 0
  73879. var fl = this._fl | 0
  73880. var gl = this._gl | 0
  73881. var hl = this._hl | 0
  73882. for (var i = 0; i < 32; i += 2) {
  73883. W[i] = M.readInt32BE(i * 4)
  73884. W[i + 1] = M.readInt32BE(i * 4 + 4)
  73885. }
  73886. for (; i < 160; i += 2) {
  73887. var xh = W[i - 15 * 2]
  73888. var xl = W[i - 15 * 2 + 1]
  73889. var gamma0 = Gamma0(xh, xl)
  73890. var gamma0l = Gamma0l(xl, xh)
  73891. xh = W[i - 2 * 2]
  73892. xl = W[i - 2 * 2 + 1]
  73893. var gamma1 = Gamma1(xh, xl)
  73894. var gamma1l = Gamma1l(xl, xh)
  73895. // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  73896. var Wi7h = W[i - 7 * 2]
  73897. var Wi7l = W[i - 7 * 2 + 1]
  73898. var Wi16h = W[i - 16 * 2]
  73899. var Wi16l = W[i - 16 * 2 + 1]
  73900. var Wil = (gamma0l + Wi7l) | 0
  73901. var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
  73902. Wil = (Wil + gamma1l) | 0
  73903. Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
  73904. Wil = (Wil + Wi16l) | 0
  73905. Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
  73906. W[i] = Wih
  73907. W[i + 1] = Wil
  73908. }
  73909. for (var j = 0; j < 160; j += 2) {
  73910. Wih = W[j]
  73911. Wil = W[j + 1]
  73912. var majh = maj(ah, bh, ch)
  73913. var majl = maj(al, bl, cl)
  73914. var sigma0h = sigma0(ah, al)
  73915. var sigma0l = sigma0(al, ah)
  73916. var sigma1h = sigma1(eh, el)
  73917. var sigma1l = sigma1(el, eh)
  73918. // t1 = h + sigma1 + ch + K[j] + W[j]
  73919. var Kih = K[j]
  73920. var Kil = K[j + 1]
  73921. var chh = Ch(eh, fh, gh)
  73922. var chl = Ch(el, fl, gl)
  73923. var t1l = (hl + sigma1l) | 0
  73924. var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
  73925. t1l = (t1l + chl) | 0
  73926. t1h = (t1h + chh + getCarry(t1l, chl)) | 0
  73927. t1l = (t1l + Kil) | 0
  73928. t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
  73929. t1l = (t1l + Wil) | 0
  73930. t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
  73931. // t2 = sigma0 + maj
  73932. var t2l = (sigma0l + majl) | 0
  73933. var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
  73934. hh = gh
  73935. hl = gl
  73936. gh = fh
  73937. gl = fl
  73938. fh = eh
  73939. fl = el
  73940. el = (dl + t1l) | 0
  73941. eh = (dh + t1h + getCarry(el, dl)) | 0
  73942. dh = ch
  73943. dl = cl
  73944. ch = bh
  73945. cl = bl
  73946. bh = ah
  73947. bl = al
  73948. al = (t1l + t2l) | 0
  73949. ah = (t1h + t2h + getCarry(al, t1l)) | 0
  73950. }
  73951. this._al = (this._al + al) | 0
  73952. this._bl = (this._bl + bl) | 0
  73953. this._cl = (this._cl + cl) | 0
  73954. this._dl = (this._dl + dl) | 0
  73955. this._el = (this._el + el) | 0
  73956. this._fl = (this._fl + fl) | 0
  73957. this._gl = (this._gl + gl) | 0
  73958. this._hl = (this._hl + hl) | 0
  73959. this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
  73960. this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
  73961. this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
  73962. this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
  73963. this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
  73964. this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
  73965. this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
  73966. this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
  73967. }
  73968. Sha512.prototype._hash = function () {
  73969. var H = Buffer.allocUnsafe(64)
  73970. function writeInt64BE (h, l, offset) {
  73971. H.writeInt32BE(h, offset)
  73972. H.writeInt32BE(l, offset + 4)
  73973. }
  73974. writeInt64BE(this._ah, this._al, 0)
  73975. writeInt64BE(this._bh, this._bl, 8)
  73976. writeInt64BE(this._ch, this._cl, 16)
  73977. writeInt64BE(this._dh, this._dl, 24)
  73978. writeInt64BE(this._eh, this._el, 32)
  73979. writeInt64BE(this._fh, this._fl, 40)
  73980. writeInt64BE(this._gh, this._gl, 48)
  73981. writeInt64BE(this._hh, this._hl, 56)
  73982. return H
  73983. }
  73984. module.exports = Sha512
  73985. /***/ }),
  73986. /***/ "./node_modules/snake-case/dist.es2015/index.js":
  73987. /*!******************************************************!*\
  73988. !*** ./node_modules/snake-case/dist.es2015/index.js ***!
  73989. \******************************************************/
  73990. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  73991. "use strict";
  73992. __webpack_require__.r(__webpack_exports__);
  73993. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  73994. /* harmony export */ snakeCase: () => (/* binding */ snakeCase)
  73995. /* harmony export */ });
  73996. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
  73997. /* harmony import */ var dot_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! dot-case */ "./node_modules/dot-case/dist.es2015/index.js");
  73998. function snakeCase(input, options) {
  73999. if (options === void 0) { options = {}; }
  74000. return (0,dot_case__WEBPACK_IMPORTED_MODULE_0__.dotCase)(input, (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__assign)({ delimiter: "_" }, options));
  74001. }
  74002. //# sourceMappingURL=index.js.map
  74003. /***/ }),
  74004. /***/ "./node_modules/string_decoder/lib/string_decoder.js":
  74005. /*!***********************************************************!*\
  74006. !*** ./node_modules/string_decoder/lib/string_decoder.js ***!
  74007. \***********************************************************/
  74008. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  74009. "use strict";
  74010. // Copyright Joyent, Inc. and other Node contributors.
  74011. //
  74012. // Permission is hereby granted, free of charge, to any person obtaining a
  74013. // copy of this software and associated documentation files (the
  74014. // "Software"), to deal in the Software without restriction, including
  74015. // without limitation the rights to use, copy, modify, merge, publish,
  74016. // distribute, sublicense, and/or sell copies of the Software, and to permit
  74017. // persons to whom the Software is furnished to do so, subject to the
  74018. // following conditions:
  74019. //
  74020. // The above copyright notice and this permission notice shall be included
  74021. // in all copies or substantial portions of the Software.
  74022. //
  74023. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  74024. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  74025. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  74026. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  74027. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  74028. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  74029. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  74030. /*<replacement>*/
  74031. var Buffer = (__webpack_require__(/*! safe-buffer */ "./node_modules/string_decoder/node_modules/safe-buffer/index.js").Buffer);
  74032. /*</replacement>*/
  74033. var isEncoding = Buffer.isEncoding || function (encoding) {
  74034. encoding = '' + encoding;
  74035. switch (encoding && encoding.toLowerCase()) {
  74036. case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
  74037. return true;
  74038. default:
  74039. return false;
  74040. }
  74041. };
  74042. function _normalizeEncoding(enc) {
  74043. if (!enc) return 'utf8';
  74044. var retried;
  74045. while (true) {
  74046. switch (enc) {
  74047. case 'utf8':
  74048. case 'utf-8':
  74049. return 'utf8';
  74050. case 'ucs2':
  74051. case 'ucs-2':
  74052. case 'utf16le':
  74053. case 'utf-16le':
  74054. return 'utf16le';
  74055. case 'latin1':
  74056. case 'binary':
  74057. return 'latin1';
  74058. case 'base64':
  74059. case 'ascii':
  74060. case 'hex':
  74061. return enc;
  74062. default:
  74063. if (retried) return; // undefined
  74064. enc = ('' + enc).toLowerCase();
  74065. retried = true;
  74066. }
  74067. }
  74068. };
  74069. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  74070. // modules monkey-patch it to support additional encodings
  74071. function normalizeEncoding(enc) {
  74072. var nenc = _normalizeEncoding(enc);
  74073. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  74074. return nenc || enc;
  74075. }
  74076. // StringDecoder provides an interface for efficiently splitting a series of
  74077. // buffers into a series of JS strings without breaking apart multi-byte
  74078. // characters.
  74079. exports.StringDecoder = StringDecoder;
  74080. function StringDecoder(encoding) {
  74081. this.encoding = normalizeEncoding(encoding);
  74082. var nb;
  74083. switch (this.encoding) {
  74084. case 'utf16le':
  74085. this.text = utf16Text;
  74086. this.end = utf16End;
  74087. nb = 4;
  74088. break;
  74089. case 'utf8':
  74090. this.fillLast = utf8FillLast;
  74091. nb = 4;
  74092. break;
  74093. case 'base64':
  74094. this.text = base64Text;
  74095. this.end = base64End;
  74096. nb = 3;
  74097. break;
  74098. default:
  74099. this.write = simpleWrite;
  74100. this.end = simpleEnd;
  74101. return;
  74102. }
  74103. this.lastNeed = 0;
  74104. this.lastTotal = 0;
  74105. this.lastChar = Buffer.allocUnsafe(nb);
  74106. }
  74107. StringDecoder.prototype.write = function (buf) {
  74108. if (buf.length === 0) return '';
  74109. var r;
  74110. var i;
  74111. if (this.lastNeed) {
  74112. r = this.fillLast(buf);
  74113. if (r === undefined) return '';
  74114. i = this.lastNeed;
  74115. this.lastNeed = 0;
  74116. } else {
  74117. i = 0;
  74118. }
  74119. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  74120. return r || '';
  74121. };
  74122. StringDecoder.prototype.end = utf8End;
  74123. // Returns only complete characters in a Buffer
  74124. StringDecoder.prototype.text = utf8Text;
  74125. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  74126. StringDecoder.prototype.fillLast = function (buf) {
  74127. if (this.lastNeed <= buf.length) {
  74128. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  74129. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  74130. }
  74131. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  74132. this.lastNeed -= buf.length;
  74133. };
  74134. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  74135. // continuation byte. If an invalid byte is detected, -2 is returned.
  74136. function utf8CheckByte(byte) {
  74137. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  74138. return byte >> 6 === 0x02 ? -1 : -2;
  74139. }
  74140. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  74141. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  74142. // needed to complete the UTF-8 character (if applicable) are returned.
  74143. function utf8CheckIncomplete(self, buf, i) {
  74144. var j = buf.length - 1;
  74145. if (j < i) return 0;
  74146. var nb = utf8CheckByte(buf[j]);
  74147. if (nb >= 0) {
  74148. if (nb > 0) self.lastNeed = nb - 1;
  74149. return nb;
  74150. }
  74151. if (--j < i || nb === -2) return 0;
  74152. nb = utf8CheckByte(buf[j]);
  74153. if (nb >= 0) {
  74154. if (nb > 0) self.lastNeed = nb - 2;
  74155. return nb;
  74156. }
  74157. if (--j < i || nb === -2) return 0;
  74158. nb = utf8CheckByte(buf[j]);
  74159. if (nb >= 0) {
  74160. if (nb > 0) {
  74161. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  74162. }
  74163. return nb;
  74164. }
  74165. return 0;
  74166. }
  74167. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  74168. // needed or are available. If we see a non-continuation byte where we expect
  74169. // one, we "replace" the validated continuation bytes we've seen so far with
  74170. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  74171. // behavior. The continuation byte check is included three times in the case
  74172. // where all of the continuation bytes for a character exist in the same buffer.
  74173. // It is also done this way as a slight performance increase instead of using a
  74174. // loop.
  74175. function utf8CheckExtraBytes(self, buf, p) {
  74176. if ((buf[0] & 0xC0) !== 0x80) {
  74177. self.lastNeed = 0;
  74178. return '\ufffd';
  74179. }
  74180. if (self.lastNeed > 1 && buf.length > 1) {
  74181. if ((buf[1] & 0xC0) !== 0x80) {
  74182. self.lastNeed = 1;
  74183. return '\ufffd';
  74184. }
  74185. if (self.lastNeed > 2 && buf.length > 2) {
  74186. if ((buf[2] & 0xC0) !== 0x80) {
  74187. self.lastNeed = 2;
  74188. return '\ufffd';
  74189. }
  74190. }
  74191. }
  74192. }
  74193. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  74194. function utf8FillLast(buf) {
  74195. var p = this.lastTotal - this.lastNeed;
  74196. var r = utf8CheckExtraBytes(this, buf, p);
  74197. if (r !== undefined) return r;
  74198. if (this.lastNeed <= buf.length) {
  74199. buf.copy(this.lastChar, p, 0, this.lastNeed);
  74200. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  74201. }
  74202. buf.copy(this.lastChar, p, 0, buf.length);
  74203. this.lastNeed -= buf.length;
  74204. }
  74205. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  74206. // partial character, the character's bytes are buffered until the required
  74207. // number of bytes are available.
  74208. function utf8Text(buf, i) {
  74209. var total = utf8CheckIncomplete(this, buf, i);
  74210. if (!this.lastNeed) return buf.toString('utf8', i);
  74211. this.lastTotal = total;
  74212. var end = buf.length - (total - this.lastNeed);
  74213. buf.copy(this.lastChar, 0, end);
  74214. return buf.toString('utf8', i, end);
  74215. }
  74216. // For UTF-8, a replacement character is added when ending on a partial
  74217. // character.
  74218. function utf8End(buf) {
  74219. var r = buf && buf.length ? this.write(buf) : '';
  74220. if (this.lastNeed) return r + '\ufffd';
  74221. return r;
  74222. }
  74223. // UTF-16LE typically needs two bytes per character, but even if we have an even
  74224. // number of bytes available, we need to check if we end on a leading/high
  74225. // surrogate. In that case, we need to wait for the next two bytes in order to
  74226. // decode the last character properly.
  74227. function utf16Text(buf, i) {
  74228. if ((buf.length - i) % 2 === 0) {
  74229. var r = buf.toString('utf16le', i);
  74230. if (r) {
  74231. var c = r.charCodeAt(r.length - 1);
  74232. if (c >= 0xD800 && c <= 0xDBFF) {
  74233. this.lastNeed = 2;
  74234. this.lastTotal = 4;
  74235. this.lastChar[0] = buf[buf.length - 2];
  74236. this.lastChar[1] = buf[buf.length - 1];
  74237. return r.slice(0, -1);
  74238. }
  74239. }
  74240. return r;
  74241. }
  74242. this.lastNeed = 1;
  74243. this.lastTotal = 2;
  74244. this.lastChar[0] = buf[buf.length - 1];
  74245. return buf.toString('utf16le', i, buf.length - 1);
  74246. }
  74247. // For UTF-16LE we do not explicitly append special replacement characters if we
  74248. // end on a partial character, we simply let v8 handle that.
  74249. function utf16End(buf) {
  74250. var r = buf && buf.length ? this.write(buf) : '';
  74251. if (this.lastNeed) {
  74252. var end = this.lastTotal - this.lastNeed;
  74253. return r + this.lastChar.toString('utf16le', 0, end);
  74254. }
  74255. return r;
  74256. }
  74257. function base64Text(buf, i) {
  74258. var n = (buf.length - i) % 3;
  74259. if (n === 0) return buf.toString('base64', i);
  74260. this.lastNeed = 3 - n;
  74261. this.lastTotal = 3;
  74262. if (n === 1) {
  74263. this.lastChar[0] = buf[buf.length - 1];
  74264. } else {
  74265. this.lastChar[0] = buf[buf.length - 2];
  74266. this.lastChar[1] = buf[buf.length - 1];
  74267. }
  74268. return buf.toString('base64', i, buf.length - n);
  74269. }
  74270. function base64End(buf) {
  74271. var r = buf && buf.length ? this.write(buf) : '';
  74272. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  74273. return r;
  74274. }
  74275. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  74276. function simpleWrite(buf) {
  74277. return buf.toString(this.encoding);
  74278. }
  74279. function simpleEnd(buf) {
  74280. return buf && buf.length ? this.write(buf) : '';
  74281. }
  74282. /***/ }),
  74283. /***/ "./node_modules/string_decoder/node_modules/safe-buffer/index.js":
  74284. /*!***********************************************************************!*\
  74285. !*** ./node_modules/string_decoder/node_modules/safe-buffer/index.js ***!
  74286. \***********************************************************************/
  74287. /***/ ((module, exports, __webpack_require__) => {
  74288. /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  74289. /* eslint-disable node/no-deprecated-api */
  74290. var buffer = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js")
  74291. var Buffer = buffer.Buffer
  74292. // alternative to using Object.keys for old browsers
  74293. function copyProps (src, dst) {
  74294. for (var key in src) {
  74295. dst[key] = src[key]
  74296. }
  74297. }
  74298. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  74299. module.exports = buffer
  74300. } else {
  74301. // Copy properties from require('buffer')
  74302. copyProps(buffer, exports)
  74303. exports.Buffer = SafeBuffer
  74304. }
  74305. function SafeBuffer (arg, encodingOrOffset, length) {
  74306. return Buffer(arg, encodingOrOffset, length)
  74307. }
  74308. SafeBuffer.prototype = Object.create(Buffer.prototype)
  74309. // Copy static methods from Buffer
  74310. copyProps(Buffer, SafeBuffer)
  74311. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  74312. if (typeof arg === 'number') {
  74313. throw new TypeError('Argument must not be a number')
  74314. }
  74315. return Buffer(arg, encodingOrOffset, length)
  74316. }
  74317. SafeBuffer.alloc = function (size, fill, encoding) {
  74318. if (typeof size !== 'number') {
  74319. throw new TypeError('Argument must be a number')
  74320. }
  74321. var buf = Buffer(size)
  74322. if (fill !== undefined) {
  74323. if (typeof encoding === 'string') {
  74324. buf.fill(fill, encoding)
  74325. } else {
  74326. buf.fill(fill)
  74327. }
  74328. } else {
  74329. buf.fill(0)
  74330. }
  74331. return buf
  74332. }
  74333. SafeBuffer.allocUnsafe = function (size) {
  74334. if (typeof size !== 'number') {
  74335. throw new TypeError('Argument must be a number')
  74336. }
  74337. return Buffer(size)
  74338. }
  74339. SafeBuffer.allocUnsafeSlow = function (size) {
  74340. if (typeof size !== 'number') {
  74341. throw new TypeError('Argument must be a number')
  74342. }
  74343. return buffer.SlowBuffer(size)
  74344. }
  74345. /***/ }),
  74346. /***/ "./node_modules/izitoast/dist/css/iziToast.min.css":
  74347. /*!*********************************************************!*\
  74348. !*** ./node_modules/izitoast/dist/css/iziToast.min.css ***!
  74349. \*********************************************************/
  74350. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  74351. "use strict";
  74352. __webpack_require__.r(__webpack_exports__);
  74353. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  74354. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  74355. /* harmony export */ });
  74356. /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
  74357. /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
  74358. /* harmony import */ var _css_loader_dist_cjs_js_ruleSet_1_rules_6_oneOf_1_use_1_postcss_loader_dist_cjs_js_ruleSet_1_rules_6_oneOf_1_use_2_iziToast_min_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !!../../../css-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[1]!../../../postcss-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[2]!./iziToast.min.css */ "./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[6].oneOf[1].use[2]!./node_modules/izitoast/dist/css/iziToast.min.css");
  74359. var options = {};
  74360. options.insert = "head";
  74361. options.singleton = false;
  74362. var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_ruleSet_1_rules_6_oneOf_1_use_1_postcss_loader_dist_cjs_js_ruleSet_1_rules_6_oneOf_1_use_2_iziToast_min_css__WEBPACK_IMPORTED_MODULE_1__["default"], options);
  74363. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_ruleSet_1_rules_6_oneOf_1_use_1_postcss_loader_dist_cjs_js_ruleSet_1_rules_6_oneOf_1_use_2_iziToast_min_css__WEBPACK_IMPORTED_MODULE_1__["default"].locals || {});
  74364. /***/ }),
  74365. /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
  74366. /*!****************************************************************************!*\
  74367. !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
  74368. \****************************************************************************/
  74369. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  74370. "use strict";
  74371. var isOldIE = function isOldIE() {
  74372. var memo;
  74373. return function memorize() {
  74374. if (typeof memo === 'undefined') {
  74375. // Test for IE <= 9 as proposed by Browserhacks
  74376. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  74377. // Tests for existence of standard globals is to allow style-loader
  74378. // to operate correctly into non-standard environments
  74379. // @see https://github.com/webpack-contrib/style-loader/issues/177
  74380. memo = Boolean(window && document && document.all && !window.atob);
  74381. }
  74382. return memo;
  74383. };
  74384. }();
  74385. var getTarget = function getTarget() {
  74386. var memo = {};
  74387. return function memorize(target) {
  74388. if (typeof memo[target] === 'undefined') {
  74389. var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
  74390. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  74391. try {
  74392. // This will throw an exception if access to iframe is blocked
  74393. // due to cross-origin restrictions
  74394. styleTarget = styleTarget.contentDocument.head;
  74395. } catch (e) {
  74396. // istanbul ignore next
  74397. styleTarget = null;
  74398. }
  74399. }
  74400. memo[target] = styleTarget;
  74401. }
  74402. return memo[target];
  74403. };
  74404. }();
  74405. var stylesInDom = [];
  74406. function getIndexByIdentifier(identifier) {
  74407. var result = -1;
  74408. for (var i = 0; i < stylesInDom.length; i++) {
  74409. if (stylesInDom[i].identifier === identifier) {
  74410. result = i;
  74411. break;
  74412. }
  74413. }
  74414. return result;
  74415. }
  74416. function modulesToDom(list, options) {
  74417. var idCountMap = {};
  74418. var identifiers = [];
  74419. for (var i = 0; i < list.length; i++) {
  74420. var item = list[i];
  74421. var id = options.base ? item[0] + options.base : item[0];
  74422. var count = idCountMap[id] || 0;
  74423. var identifier = "".concat(id, " ").concat(count);
  74424. idCountMap[id] = count + 1;
  74425. var index = getIndexByIdentifier(identifier);
  74426. var obj = {
  74427. css: item[1],
  74428. media: item[2],
  74429. sourceMap: item[3]
  74430. };
  74431. if (index !== -1) {
  74432. stylesInDom[index].references++;
  74433. stylesInDom[index].updater(obj);
  74434. } else {
  74435. stylesInDom.push({
  74436. identifier: identifier,
  74437. updater: addStyle(obj, options),
  74438. references: 1
  74439. });
  74440. }
  74441. identifiers.push(identifier);
  74442. }
  74443. return identifiers;
  74444. }
  74445. function insertStyleElement(options) {
  74446. var style = document.createElement('style');
  74447. var attributes = options.attributes || {};
  74448. if (typeof attributes.nonce === 'undefined') {
  74449. var nonce = true ? __webpack_require__.nc : 0;
  74450. if (nonce) {
  74451. attributes.nonce = nonce;
  74452. }
  74453. }
  74454. Object.keys(attributes).forEach(function (key) {
  74455. style.setAttribute(key, attributes[key]);
  74456. });
  74457. if (typeof options.insert === 'function') {
  74458. options.insert(style);
  74459. } else {
  74460. var target = getTarget(options.insert || 'head');
  74461. if (!target) {
  74462. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  74463. }
  74464. target.appendChild(style);
  74465. }
  74466. return style;
  74467. }
  74468. function removeStyleElement(style) {
  74469. // istanbul ignore if
  74470. if (style.parentNode === null) {
  74471. return false;
  74472. }
  74473. style.parentNode.removeChild(style);
  74474. }
  74475. /* istanbul ignore next */
  74476. var replaceText = function replaceText() {
  74477. var textStore = [];
  74478. return function replace(index, replacement) {
  74479. textStore[index] = replacement;
  74480. return textStore.filter(Boolean).join('\n');
  74481. };
  74482. }();
  74483. function applyToSingletonTag(style, index, remove, obj) {
  74484. var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
  74485. /* istanbul ignore if */
  74486. if (style.styleSheet) {
  74487. style.styleSheet.cssText = replaceText(index, css);
  74488. } else {
  74489. var cssNode = document.createTextNode(css);
  74490. var childNodes = style.childNodes;
  74491. if (childNodes[index]) {
  74492. style.removeChild(childNodes[index]);
  74493. }
  74494. if (childNodes.length) {
  74495. style.insertBefore(cssNode, childNodes[index]);
  74496. } else {
  74497. style.appendChild(cssNode);
  74498. }
  74499. }
  74500. }
  74501. function applyToTag(style, options, obj) {
  74502. var css = obj.css;
  74503. var media = obj.media;
  74504. var sourceMap = obj.sourceMap;
  74505. if (media) {
  74506. style.setAttribute('media', media);
  74507. } else {
  74508. style.removeAttribute('media');
  74509. }
  74510. if (sourceMap && typeof btoa !== 'undefined') {
  74511. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  74512. } // For old IE
  74513. /* istanbul ignore if */
  74514. if (style.styleSheet) {
  74515. style.styleSheet.cssText = css;
  74516. } else {
  74517. while (style.firstChild) {
  74518. style.removeChild(style.firstChild);
  74519. }
  74520. style.appendChild(document.createTextNode(css));
  74521. }
  74522. }
  74523. var singleton = null;
  74524. var singletonCounter = 0;
  74525. function addStyle(obj, options) {
  74526. var style;
  74527. var update;
  74528. var remove;
  74529. if (options.singleton) {
  74530. var styleIndex = singletonCounter++;
  74531. style = singleton || (singleton = insertStyleElement(options));
  74532. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  74533. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  74534. } else {
  74535. style = insertStyleElement(options);
  74536. update = applyToTag.bind(null, style, options);
  74537. remove = function remove() {
  74538. removeStyleElement(style);
  74539. };
  74540. }
  74541. update(obj);
  74542. return function updateStyle(newObj) {
  74543. if (newObj) {
  74544. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
  74545. return;
  74546. }
  74547. update(obj = newObj);
  74548. } else {
  74549. remove();
  74550. }
  74551. };
  74552. }
  74553. module.exports = function (list, options) {
  74554. options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  74555. // tags it will allow on a page
  74556. if (!options.singleton && typeof options.singleton !== 'boolean') {
  74557. options.singleton = isOldIE();
  74558. }
  74559. list = list || [];
  74560. var lastIdentifiers = modulesToDom(list, options);
  74561. return function update(newList) {
  74562. newList = newList || [];
  74563. if (Object.prototype.toString.call(newList) !== '[object Array]') {
  74564. return;
  74565. }
  74566. for (var i = 0; i < lastIdentifiers.length; i++) {
  74567. var identifier = lastIdentifiers[i];
  74568. var index = getIndexByIdentifier(identifier);
  74569. stylesInDom[index].references--;
  74570. }
  74571. var newLastIdentifiers = modulesToDom(newList, options);
  74572. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  74573. var _identifier = lastIdentifiers[_i];
  74574. var _index = getIndexByIdentifier(_identifier);
  74575. if (stylesInDom[_index].references === 0) {
  74576. stylesInDom[_index].updater();
  74577. stylesInDom.splice(_index, 1);
  74578. }
  74579. }
  74580. lastIdentifiers = newLastIdentifiers;
  74581. };
  74582. };
  74583. /***/ }),
  74584. /***/ "./node_modules/tslib/tslib.es6.js":
  74585. /*!*****************************************!*\
  74586. !*** ./node_modules/tslib/tslib.es6.js ***!
  74587. \*****************************************/
  74588. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  74589. "use strict";
  74590. __webpack_require__.r(__webpack_exports__);
  74591. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  74592. /* harmony export */ __assign: () => (/* binding */ __assign),
  74593. /* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator),
  74594. /* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator),
  74595. /* harmony export */ __asyncValues: () => (/* binding */ __asyncValues),
  74596. /* harmony export */ __await: () => (/* binding */ __await),
  74597. /* harmony export */ __awaiter: () => (/* binding */ __awaiter),
  74598. /* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet),
  74599. /* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet),
  74600. /* harmony export */ __createBinding: () => (/* binding */ __createBinding),
  74601. /* harmony export */ __decorate: () => (/* binding */ __decorate),
  74602. /* harmony export */ __exportStar: () => (/* binding */ __exportStar),
  74603. /* harmony export */ __extends: () => (/* binding */ __extends),
  74604. /* harmony export */ __generator: () => (/* binding */ __generator),
  74605. /* harmony export */ __importDefault: () => (/* binding */ __importDefault),
  74606. /* harmony export */ __importStar: () => (/* binding */ __importStar),
  74607. /* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject),
  74608. /* harmony export */ __metadata: () => (/* binding */ __metadata),
  74609. /* harmony export */ __param: () => (/* binding */ __param),
  74610. /* harmony export */ __read: () => (/* binding */ __read),
  74611. /* harmony export */ __rest: () => (/* binding */ __rest),
  74612. /* harmony export */ __spread: () => (/* binding */ __spread),
  74613. /* harmony export */ __spreadArray: () => (/* binding */ __spreadArray),
  74614. /* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays),
  74615. /* harmony export */ __values: () => (/* binding */ __values)
  74616. /* harmony export */ });
  74617. /*! *****************************************************************************
  74618. Copyright (c) Microsoft Corporation.
  74619. Permission to use, copy, modify, and/or distribute this software for any
  74620. purpose with or without fee is hereby granted.
  74621. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  74622. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  74623. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  74624. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  74625. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  74626. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  74627. PERFORMANCE OF THIS SOFTWARE.
  74628. ***************************************************************************** */
  74629. /* global Reflect, Promise */
  74630. var extendStatics = function(d, b) {
  74631. extendStatics = Object.setPrototypeOf ||
  74632. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  74633. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  74634. return extendStatics(d, b);
  74635. };
  74636. function __extends(d, b) {
  74637. if (typeof b !== "function" && b !== null)
  74638. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  74639. extendStatics(d, b);
  74640. function __() { this.constructor = d; }
  74641. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  74642. }
  74643. var __assign = function() {
  74644. __assign = Object.assign || function __assign(t) {
  74645. for (var s, i = 1, n = arguments.length; i < n; i++) {
  74646. s = arguments[i];
  74647. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  74648. }
  74649. return t;
  74650. }
  74651. return __assign.apply(this, arguments);
  74652. }
  74653. function __rest(s, e) {
  74654. var t = {};
  74655. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  74656. t[p] = s[p];
  74657. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  74658. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  74659. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  74660. t[p[i]] = s[p[i]];
  74661. }
  74662. return t;
  74663. }
  74664. function __decorate(decorators, target, key, desc) {
  74665. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  74666. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  74667. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  74668. return c > 3 && r && Object.defineProperty(target, key, r), r;
  74669. }
  74670. function __param(paramIndex, decorator) {
  74671. return function (target, key) { decorator(target, key, paramIndex); }
  74672. }
  74673. function __metadata(metadataKey, metadataValue) {
  74674. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  74675. }
  74676. function __awaiter(thisArg, _arguments, P, generator) {
  74677. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  74678. return new (P || (P = Promise))(function (resolve, reject) {
  74679. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  74680. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  74681. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  74682. step((generator = generator.apply(thisArg, _arguments || [])).next());
  74683. });
  74684. }
  74685. function __generator(thisArg, body) {
  74686. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  74687. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  74688. function verb(n) { return function (v) { return step([n, v]); }; }
  74689. function step(op) {
  74690. if (f) throw new TypeError("Generator is already executing.");
  74691. while (_) try {
  74692. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  74693. if (y = 0, t) op = [op[0] & 2, t.value];
  74694. switch (op[0]) {
  74695. case 0: case 1: t = op; break;
  74696. case 4: _.label++; return { value: op[1], done: false };
  74697. case 5: _.label++; y = op[1]; op = [0]; continue;
  74698. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  74699. default:
  74700. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  74701. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  74702. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  74703. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  74704. if (t[2]) _.ops.pop();
  74705. _.trys.pop(); continue;
  74706. }
  74707. op = body.call(thisArg, _);
  74708. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  74709. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  74710. }
  74711. }
  74712. var __createBinding = Object.create ? (function(o, m, k, k2) {
  74713. if (k2 === undefined) k2 = k;
  74714. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  74715. }) : (function(o, m, k, k2) {
  74716. if (k2 === undefined) k2 = k;
  74717. o[k2] = m[k];
  74718. });
  74719. function __exportStar(m, o) {
  74720. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  74721. }
  74722. function __values(o) {
  74723. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  74724. if (m) return m.call(o);
  74725. if (o && typeof o.length === "number") return {
  74726. next: function () {
  74727. if (o && i >= o.length) o = void 0;
  74728. return { value: o && o[i++], done: !o };
  74729. }
  74730. };
  74731. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  74732. }
  74733. function __read(o, n) {
  74734. var m = typeof Symbol === "function" && o[Symbol.iterator];
  74735. if (!m) return o;
  74736. var i = m.call(o), r, ar = [], e;
  74737. try {
  74738. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  74739. }
  74740. catch (error) { e = { error: error }; }
  74741. finally {
  74742. try {
  74743. if (r && !r.done && (m = i["return"])) m.call(i);
  74744. }
  74745. finally { if (e) throw e.error; }
  74746. }
  74747. return ar;
  74748. }
  74749. /** @deprecated */
  74750. function __spread() {
  74751. for (var ar = [], i = 0; i < arguments.length; i++)
  74752. ar = ar.concat(__read(arguments[i]));
  74753. return ar;
  74754. }
  74755. /** @deprecated */
  74756. function __spreadArrays() {
  74757. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  74758. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  74759. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  74760. r[k] = a[j];
  74761. return r;
  74762. }
  74763. function __spreadArray(to, from, pack) {
  74764. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  74765. if (ar || !(i in from)) {
  74766. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  74767. ar[i] = from[i];
  74768. }
  74769. }
  74770. return to.concat(ar || Array.prototype.slice.call(from));
  74771. }
  74772. function __await(v) {
  74773. return this instanceof __await ? (this.v = v, this) : new __await(v);
  74774. }
  74775. function __asyncGenerator(thisArg, _arguments, generator) {
  74776. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  74777. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  74778. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  74779. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  74780. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  74781. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  74782. function fulfill(value) { resume("next", value); }
  74783. function reject(value) { resume("throw", value); }
  74784. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  74785. }
  74786. function __asyncDelegator(o) {
  74787. var i, p;
  74788. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  74789. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  74790. }
  74791. function __asyncValues(o) {
  74792. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  74793. var m = o[Symbol.asyncIterator], i;
  74794. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  74795. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  74796. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  74797. }
  74798. function __makeTemplateObject(cooked, raw) {
  74799. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  74800. return cooked;
  74801. };
  74802. var __setModuleDefault = Object.create ? (function(o, v) {
  74803. Object.defineProperty(o, "default", { enumerable: true, value: v });
  74804. }) : function(o, v) {
  74805. o["default"] = v;
  74806. };
  74807. function __importStar(mod) {
  74808. if (mod && mod.__esModule) return mod;
  74809. var result = {};
  74810. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  74811. __setModuleDefault(result, mod);
  74812. return result;
  74813. }
  74814. function __importDefault(mod) {
  74815. return (mod && mod.__esModule) ? mod : { default: mod };
  74816. }
  74817. function __classPrivateFieldGet(receiver, state, kind, f) {
  74818. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
  74819. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  74820. return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
  74821. }
  74822. function __classPrivateFieldSet(receiver, state, value, kind, f) {
  74823. if (kind === "m") throw new TypeError("Private method is not writable");
  74824. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
  74825. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  74826. return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
  74827. }
  74828. /***/ }),
  74829. /***/ "./node_modules/upper-case-first/dist.es2015/index.js":
  74830. /*!************************************************************!*\
  74831. !*** ./node_modules/upper-case-first/dist.es2015/index.js ***!
  74832. \************************************************************/
  74833. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  74834. "use strict";
  74835. __webpack_require__.r(__webpack_exports__);
  74836. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  74837. /* harmony export */ upperCaseFirst: () => (/* binding */ upperCaseFirst)
  74838. /* harmony export */ });
  74839. /**
  74840. * Upper case the first character of an input string.
  74841. */
  74842. function upperCaseFirst(input) {
  74843. return input.charAt(0).toUpperCase() + input.substr(1);
  74844. }
  74845. //# sourceMappingURL=index.js.map
  74846. /***/ }),
  74847. /***/ "./node_modules/upper-case/dist.es2015/index.js":
  74848. /*!******************************************************!*\
  74849. !*** ./node_modules/upper-case/dist.es2015/index.js ***!
  74850. \******************************************************/
  74851. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  74852. "use strict";
  74853. __webpack_require__.r(__webpack_exports__);
  74854. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  74855. /* harmony export */ localeUpperCase: () => (/* binding */ localeUpperCase),
  74856. /* harmony export */ upperCase: () => (/* binding */ upperCase)
  74857. /* harmony export */ });
  74858. /**
  74859. * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  74860. */
  74861. var SUPPORTED_LOCALE = {
  74862. tr: {
  74863. regexp: /[\u0069]/g,
  74864. map: {
  74865. i: "\u0130",
  74866. },
  74867. },
  74868. az: {
  74869. regexp: /[\u0069]/g,
  74870. map: {
  74871. i: "\u0130",
  74872. },
  74873. },
  74874. lt: {
  74875. regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
  74876. map: {
  74877. i̇: "\u0049",
  74878. j̇: "\u004A",
  74879. į̇: "\u012E",
  74880. i̇̀: "\u00CC",
  74881. i̇́: "\u00CD",
  74882. i̇̃: "\u0128",
  74883. },
  74884. },
  74885. };
  74886. /**
  74887. * Localized upper case.
  74888. */
  74889. function localeUpperCase(str, locale) {
  74890. var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
  74891. if (lang)
  74892. return upperCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
  74893. return upperCase(str);
  74894. }
  74895. /**
  74896. * Upper case as a function.
  74897. */
  74898. function upperCase(str) {
  74899. return str.toUpperCase();
  74900. }
  74901. //# sourceMappingURL=index.js.map
  74902. /***/ }),
  74903. /***/ "./node_modules/util-deprecate/browser.js":
  74904. /*!************************************************!*\
  74905. !*** ./node_modules/util-deprecate/browser.js ***!
  74906. \************************************************/
  74907. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  74908. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  74909. /**
  74910. * Module exports.
  74911. */
  74912. module.exports = deprecate;
  74913. /**
  74914. * Mark that a method should not be used.
  74915. * Returns a modified function which warns once by default.
  74916. *
  74917. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  74918. *
  74919. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  74920. * will throw an Error when invoked.
  74921. *
  74922. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  74923. * will invoke `console.trace()` instead of `console.error()`.
  74924. *
  74925. * @param {Function} fn - the function to deprecate
  74926. * @param {String} msg - the string to print to the console when `fn` is invoked
  74927. * @returns {Function} a new "deprecated" version of `fn`
  74928. * @api public
  74929. */
  74930. function deprecate (fn, msg) {
  74931. if (config('noDeprecation')) {
  74932. return fn;
  74933. }
  74934. var warned = false;
  74935. function deprecated() {
  74936. if (!warned) {
  74937. if (config('throwDeprecation')) {
  74938. throw new Error(msg);
  74939. } else if (config('traceDeprecation')) {
  74940. console.trace(msg);
  74941. } else {
  74942. console.warn(msg);
  74943. }
  74944. warned = true;
  74945. }
  74946. return fn.apply(this, arguments);
  74947. }
  74948. return deprecated;
  74949. }
  74950. /**
  74951. * Checks `localStorage` for boolean values for the given `name`.
  74952. *
  74953. * @param {String} name
  74954. * @returns {Boolean}
  74955. * @api private
  74956. */
  74957. function config (name) {
  74958. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  74959. try {
  74960. if (!__webpack_require__.g.localStorage) return false;
  74961. } catch (_) {
  74962. return false;
  74963. }
  74964. var val = __webpack_require__.g.localStorage[name];
  74965. if (null == val) return false;
  74966. return String(val).toLowerCase() === 'true';
  74967. }
  74968. /***/ }),
  74969. /***/ "./node_modules/util/node_modules/inherits/inherits_browser.js":
  74970. /*!*********************************************************************!*\
  74971. !*** ./node_modules/util/node_modules/inherits/inherits_browser.js ***!
  74972. \*********************************************************************/
  74973. /***/ ((module) => {
  74974. if (typeof Object.create === 'function') {
  74975. // implementation from standard node.js 'util' module
  74976. module.exports = function inherits(ctor, superCtor) {
  74977. ctor.super_ = superCtor
  74978. ctor.prototype = Object.create(superCtor.prototype, {
  74979. constructor: {
  74980. value: ctor,
  74981. enumerable: false,
  74982. writable: true,
  74983. configurable: true
  74984. }
  74985. });
  74986. };
  74987. } else {
  74988. // old school shim for old browsers
  74989. module.exports = function inherits(ctor, superCtor) {
  74990. ctor.super_ = superCtor
  74991. var TempCtor = function () {}
  74992. TempCtor.prototype = superCtor.prototype
  74993. ctor.prototype = new TempCtor()
  74994. ctor.prototype.constructor = ctor
  74995. }
  74996. }
  74997. /***/ }),
  74998. /***/ "./node_modules/util/support/isBufferBrowser.js":
  74999. /*!******************************************************!*\
  75000. !*** ./node_modules/util/support/isBufferBrowser.js ***!
  75001. \******************************************************/
  75002. /***/ ((module) => {
  75003. module.exports = function isBuffer(arg) {
  75004. return arg && typeof arg === 'object'
  75005. && typeof arg.copy === 'function'
  75006. && typeof arg.fill === 'function'
  75007. && typeof arg.readUInt8 === 'function';
  75008. }
  75009. /***/ }),
  75010. /***/ "./node_modules/util/util.js":
  75011. /*!***********************************!*\
  75012. !*** ./node_modules/util/util.js ***!
  75013. \***********************************/
  75014. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  75015. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  75016. /* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ "./node_modules/console-browserify/index.js");
  75017. // Copyright Joyent, Inc. and other Node contributors.
  75018. //
  75019. // Permission is hereby granted, free of charge, to any person obtaining a
  75020. // copy of this software and associated documentation files (the
  75021. // "Software"), to deal in the Software without restriction, including
  75022. // without limitation the rights to use, copy, modify, merge, publish,
  75023. // distribute, sublicense, and/or sell copies of the Software, and to permit
  75024. // persons to whom the Software is furnished to do so, subject to the
  75025. // following conditions:
  75026. //
  75027. // The above copyright notice and this permission notice shall be included
  75028. // in all copies or substantial portions of the Software.
  75029. //
  75030. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  75031. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  75032. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  75033. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  75034. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  75035. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  75036. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  75037. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  75038. function getOwnPropertyDescriptors(obj) {
  75039. var keys = Object.keys(obj);
  75040. var descriptors = {};
  75041. for (var i = 0; i < keys.length; i++) {
  75042. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  75043. }
  75044. return descriptors;
  75045. };
  75046. var formatRegExp = /%[sdj%]/g;
  75047. exports.format = function(f) {
  75048. if (!isString(f)) {
  75049. var objects = [];
  75050. for (var i = 0; i < arguments.length; i++) {
  75051. objects.push(inspect(arguments[i]));
  75052. }
  75053. return objects.join(' ');
  75054. }
  75055. var i = 1;
  75056. var args = arguments;
  75057. var len = args.length;
  75058. var str = String(f).replace(formatRegExp, function(x) {
  75059. if (x === '%%') return '%';
  75060. if (i >= len) return x;
  75061. switch (x) {
  75062. case '%s': return String(args[i++]);
  75063. case '%d': return Number(args[i++]);
  75064. case '%j':
  75065. try {
  75066. return JSON.stringify(args[i++]);
  75067. } catch (_) {
  75068. return '[Circular]';
  75069. }
  75070. default:
  75071. return x;
  75072. }
  75073. });
  75074. for (var x = args[i]; i < len; x = args[++i]) {
  75075. if (isNull(x) || !isObject(x)) {
  75076. str += ' ' + x;
  75077. } else {
  75078. str += ' ' + inspect(x);
  75079. }
  75080. }
  75081. return str;
  75082. };
  75083. // Mark that a method should not be used.
  75084. // Returns a modified function which warns once by default.
  75085. // If --no-deprecation is set, then it is a no-op.
  75086. exports.deprecate = function(fn, msg) {
  75087. if (typeof process !== 'undefined' && process.noDeprecation === true) {
  75088. return fn;
  75089. }
  75090. // Allow for deprecating things in the process of starting up.
  75091. if (typeof process === 'undefined') {
  75092. return function() {
  75093. return exports.deprecate(fn, msg).apply(this, arguments);
  75094. };
  75095. }
  75096. var warned = false;
  75097. function deprecated() {
  75098. if (!warned) {
  75099. if (process.throwDeprecation) {
  75100. throw new Error(msg);
  75101. } else if (process.traceDeprecation) {
  75102. console.trace(msg);
  75103. } else {
  75104. console.error(msg);
  75105. }
  75106. warned = true;
  75107. }
  75108. return fn.apply(this, arguments);
  75109. }
  75110. return deprecated;
  75111. };
  75112. var debugs = {};
  75113. var debugEnviron;
  75114. exports.debuglog = function(set) {
  75115. if (isUndefined(debugEnviron))
  75116. debugEnviron = process.env.NODE_DEBUG || '';
  75117. set = set.toUpperCase();
  75118. if (!debugs[set]) {
  75119. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  75120. var pid = process.pid;
  75121. debugs[set] = function() {
  75122. var msg = exports.format.apply(exports, arguments);
  75123. console.error('%s %d: %s', set, pid, msg);
  75124. };
  75125. } else {
  75126. debugs[set] = function() {};
  75127. }
  75128. }
  75129. return debugs[set];
  75130. };
  75131. /**
  75132. * Echos the value of a value. Trys to print the value out
  75133. * in the best way possible given the different types.
  75134. *
  75135. * @param {Object} obj The object to print out.
  75136. * @param {Object} opts Optional options object that alters the output.
  75137. */
  75138. /* legacy: obj, showHidden, depth, colors*/
  75139. function inspect(obj, opts) {
  75140. // default options
  75141. var ctx = {
  75142. seen: [],
  75143. stylize: stylizeNoColor
  75144. };
  75145. // legacy...
  75146. if (arguments.length >= 3) ctx.depth = arguments[2];
  75147. if (arguments.length >= 4) ctx.colors = arguments[3];
  75148. if (isBoolean(opts)) {
  75149. // legacy...
  75150. ctx.showHidden = opts;
  75151. } else if (opts) {
  75152. // got an "options" object
  75153. exports._extend(ctx, opts);
  75154. }
  75155. // set default options
  75156. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  75157. if (isUndefined(ctx.depth)) ctx.depth = 2;
  75158. if (isUndefined(ctx.colors)) ctx.colors = false;
  75159. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  75160. if (ctx.colors) ctx.stylize = stylizeWithColor;
  75161. return formatValue(ctx, obj, ctx.depth);
  75162. }
  75163. exports.inspect = inspect;
  75164. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  75165. inspect.colors = {
  75166. 'bold' : [1, 22],
  75167. 'italic' : [3, 23],
  75168. 'underline' : [4, 24],
  75169. 'inverse' : [7, 27],
  75170. 'white' : [37, 39],
  75171. 'grey' : [90, 39],
  75172. 'black' : [30, 39],
  75173. 'blue' : [34, 39],
  75174. 'cyan' : [36, 39],
  75175. 'green' : [32, 39],
  75176. 'magenta' : [35, 39],
  75177. 'red' : [31, 39],
  75178. 'yellow' : [33, 39]
  75179. };
  75180. // Don't use 'blue' not visible on cmd.exe
  75181. inspect.styles = {
  75182. 'special': 'cyan',
  75183. 'number': 'yellow',
  75184. 'boolean': 'yellow',
  75185. 'undefined': 'grey',
  75186. 'null': 'bold',
  75187. 'string': 'green',
  75188. 'date': 'magenta',
  75189. // "name": intentionally not styling
  75190. 'regexp': 'red'
  75191. };
  75192. function stylizeWithColor(str, styleType) {
  75193. var style = inspect.styles[styleType];
  75194. if (style) {
  75195. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  75196. '\u001b[' + inspect.colors[style][1] + 'm';
  75197. } else {
  75198. return str;
  75199. }
  75200. }
  75201. function stylizeNoColor(str, styleType) {
  75202. return str;
  75203. }
  75204. function arrayToHash(array) {
  75205. var hash = {};
  75206. array.forEach(function(val, idx) {
  75207. hash[val] = true;
  75208. });
  75209. return hash;
  75210. }
  75211. function formatValue(ctx, value, recurseTimes) {
  75212. // Provide a hook for user-specified inspect functions.
  75213. // Check that value is an object with an inspect function on it
  75214. if (ctx.customInspect &&
  75215. value &&
  75216. isFunction(value.inspect) &&
  75217. // Filter out the util module, it's inspect function is special
  75218. value.inspect !== exports.inspect &&
  75219. // Also filter out any prototype objects using the circular check.
  75220. !(value.constructor && value.constructor.prototype === value)) {
  75221. var ret = value.inspect(recurseTimes, ctx);
  75222. if (!isString(ret)) {
  75223. ret = formatValue(ctx, ret, recurseTimes);
  75224. }
  75225. return ret;
  75226. }
  75227. // Primitive types cannot have properties
  75228. var primitive = formatPrimitive(ctx, value);
  75229. if (primitive) {
  75230. return primitive;
  75231. }
  75232. // Look up the keys of the object.
  75233. var keys = Object.keys(value);
  75234. var visibleKeys = arrayToHash(keys);
  75235. if (ctx.showHidden) {
  75236. keys = Object.getOwnPropertyNames(value);
  75237. }
  75238. // IE doesn't make error fields non-enumerable
  75239. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  75240. if (isError(value)
  75241. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  75242. return formatError(value);
  75243. }
  75244. // Some type of object without properties can be shortcutted.
  75245. if (keys.length === 0) {
  75246. if (isFunction(value)) {
  75247. var name = value.name ? ': ' + value.name : '';
  75248. return ctx.stylize('[Function' + name + ']', 'special');
  75249. }
  75250. if (isRegExp(value)) {
  75251. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  75252. }
  75253. if (isDate(value)) {
  75254. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  75255. }
  75256. if (isError(value)) {
  75257. return formatError(value);
  75258. }
  75259. }
  75260. var base = '', array = false, braces = ['{', '}'];
  75261. // Make Array say that they are Array
  75262. if (isArray(value)) {
  75263. array = true;
  75264. braces = ['[', ']'];
  75265. }
  75266. // Make functions say that they are functions
  75267. if (isFunction(value)) {
  75268. var n = value.name ? ': ' + value.name : '';
  75269. base = ' [Function' + n + ']';
  75270. }
  75271. // Make RegExps say that they are RegExps
  75272. if (isRegExp(value)) {
  75273. base = ' ' + RegExp.prototype.toString.call(value);
  75274. }
  75275. // Make dates with properties first say the date
  75276. if (isDate(value)) {
  75277. base = ' ' + Date.prototype.toUTCString.call(value);
  75278. }
  75279. // Make error with message first say the error
  75280. if (isError(value)) {
  75281. base = ' ' + formatError(value);
  75282. }
  75283. if (keys.length === 0 && (!array || value.length == 0)) {
  75284. return braces[0] + base + braces[1];
  75285. }
  75286. if (recurseTimes < 0) {
  75287. if (isRegExp(value)) {
  75288. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  75289. } else {
  75290. return ctx.stylize('[Object]', 'special');
  75291. }
  75292. }
  75293. ctx.seen.push(value);
  75294. var output;
  75295. if (array) {
  75296. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  75297. } else {
  75298. output = keys.map(function(key) {
  75299. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  75300. });
  75301. }
  75302. ctx.seen.pop();
  75303. return reduceToSingleString(output, base, braces);
  75304. }
  75305. function formatPrimitive(ctx, value) {
  75306. if (isUndefined(value))
  75307. return ctx.stylize('undefined', 'undefined');
  75308. if (isString(value)) {
  75309. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  75310. .replace(/'/g, "\\'")
  75311. .replace(/\\"/g, '"') + '\'';
  75312. return ctx.stylize(simple, 'string');
  75313. }
  75314. if (isNumber(value))
  75315. return ctx.stylize('' + value, 'number');
  75316. if (isBoolean(value))
  75317. return ctx.stylize('' + value, 'boolean');
  75318. // For some reason typeof null is "object", so special case here.
  75319. if (isNull(value))
  75320. return ctx.stylize('null', 'null');
  75321. }
  75322. function formatError(value) {
  75323. return '[' + Error.prototype.toString.call(value) + ']';
  75324. }
  75325. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  75326. var output = [];
  75327. for (var i = 0, l = value.length; i < l; ++i) {
  75328. if (hasOwnProperty(value, String(i))) {
  75329. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  75330. String(i), true));
  75331. } else {
  75332. output.push('');
  75333. }
  75334. }
  75335. keys.forEach(function(key) {
  75336. if (!key.match(/^\d+$/)) {
  75337. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  75338. key, true));
  75339. }
  75340. });
  75341. return output;
  75342. }
  75343. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  75344. var name, str, desc;
  75345. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  75346. if (desc.get) {
  75347. if (desc.set) {
  75348. str = ctx.stylize('[Getter/Setter]', 'special');
  75349. } else {
  75350. str = ctx.stylize('[Getter]', 'special');
  75351. }
  75352. } else {
  75353. if (desc.set) {
  75354. str = ctx.stylize('[Setter]', 'special');
  75355. }
  75356. }
  75357. if (!hasOwnProperty(visibleKeys, key)) {
  75358. name = '[' + key + ']';
  75359. }
  75360. if (!str) {
  75361. if (ctx.seen.indexOf(desc.value) < 0) {
  75362. if (isNull(recurseTimes)) {
  75363. str = formatValue(ctx, desc.value, null);
  75364. } else {
  75365. str = formatValue(ctx, desc.value, recurseTimes - 1);
  75366. }
  75367. if (str.indexOf('\n') > -1) {
  75368. if (array) {
  75369. str = str.split('\n').map(function(line) {
  75370. return ' ' + line;
  75371. }).join('\n').substr(2);
  75372. } else {
  75373. str = '\n' + str.split('\n').map(function(line) {
  75374. return ' ' + line;
  75375. }).join('\n');
  75376. }
  75377. }
  75378. } else {
  75379. str = ctx.stylize('[Circular]', 'special');
  75380. }
  75381. }
  75382. if (isUndefined(name)) {
  75383. if (array && key.match(/^\d+$/)) {
  75384. return str;
  75385. }
  75386. name = JSON.stringify('' + key);
  75387. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  75388. name = name.substr(1, name.length - 2);
  75389. name = ctx.stylize(name, 'name');
  75390. } else {
  75391. name = name.replace(/'/g, "\\'")
  75392. .replace(/\\"/g, '"')
  75393. .replace(/(^"|"$)/g, "'");
  75394. name = ctx.stylize(name, 'string');
  75395. }
  75396. }
  75397. return name + ': ' + str;
  75398. }
  75399. function reduceToSingleString(output, base, braces) {
  75400. var numLinesEst = 0;
  75401. var length = output.reduce(function(prev, cur) {
  75402. numLinesEst++;
  75403. if (cur.indexOf('\n') >= 0) numLinesEst++;
  75404. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  75405. }, 0);
  75406. if (length > 60) {
  75407. return braces[0] +
  75408. (base === '' ? '' : base + '\n ') +
  75409. ' ' +
  75410. output.join(',\n ') +
  75411. ' ' +
  75412. braces[1];
  75413. }
  75414. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  75415. }
  75416. // NOTE: These type checking functions intentionally don't use `instanceof`
  75417. // because it is fragile and can be easily faked with `Object.create()`.
  75418. function isArray(ar) {
  75419. return Array.isArray(ar);
  75420. }
  75421. exports.isArray = isArray;
  75422. function isBoolean(arg) {
  75423. return typeof arg === 'boolean';
  75424. }
  75425. exports.isBoolean = isBoolean;
  75426. function isNull(arg) {
  75427. return arg === null;
  75428. }
  75429. exports.isNull = isNull;
  75430. function isNullOrUndefined(arg) {
  75431. return arg == null;
  75432. }
  75433. exports.isNullOrUndefined = isNullOrUndefined;
  75434. function isNumber(arg) {
  75435. return typeof arg === 'number';
  75436. }
  75437. exports.isNumber = isNumber;
  75438. function isString(arg) {
  75439. return typeof arg === 'string';
  75440. }
  75441. exports.isString = isString;
  75442. function isSymbol(arg) {
  75443. return typeof arg === 'symbol';
  75444. }
  75445. exports.isSymbol = isSymbol;
  75446. function isUndefined(arg) {
  75447. return arg === void 0;
  75448. }
  75449. exports.isUndefined = isUndefined;
  75450. function isRegExp(re) {
  75451. return isObject(re) && objectToString(re) === '[object RegExp]';
  75452. }
  75453. exports.isRegExp = isRegExp;
  75454. function isObject(arg) {
  75455. return typeof arg === 'object' && arg !== null;
  75456. }
  75457. exports.isObject = isObject;
  75458. function isDate(d) {
  75459. return isObject(d) && objectToString(d) === '[object Date]';
  75460. }
  75461. exports.isDate = isDate;
  75462. function isError(e) {
  75463. return isObject(e) &&
  75464. (objectToString(e) === '[object Error]' || e instanceof Error);
  75465. }
  75466. exports.isError = isError;
  75467. function isFunction(arg) {
  75468. return typeof arg === 'function';
  75469. }
  75470. exports.isFunction = isFunction;
  75471. function isPrimitive(arg) {
  75472. return arg === null ||
  75473. typeof arg === 'boolean' ||
  75474. typeof arg === 'number' ||
  75475. typeof arg === 'string' ||
  75476. typeof arg === 'symbol' || // ES6 symbol
  75477. typeof arg === 'undefined';
  75478. }
  75479. exports.isPrimitive = isPrimitive;
  75480. exports.isBuffer = __webpack_require__(/*! ./support/isBuffer */ "./node_modules/util/support/isBufferBrowser.js");
  75481. function objectToString(o) {
  75482. return Object.prototype.toString.call(o);
  75483. }
  75484. function pad(n) {
  75485. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  75486. }
  75487. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  75488. 'Oct', 'Nov', 'Dec'];
  75489. // 26 Feb 16:19:34
  75490. function timestamp() {
  75491. var d = new Date();
  75492. var time = [pad(d.getHours()),
  75493. pad(d.getMinutes()),
  75494. pad(d.getSeconds())].join(':');
  75495. return [d.getDate(), months[d.getMonth()], time].join(' ');
  75496. }
  75497. // log is just a thin wrapper to console.log that prepends a timestamp
  75498. exports.log = function() {
  75499. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  75500. };
  75501. /**
  75502. * Inherit the prototype methods from one constructor into another.
  75503. *
  75504. * The Function.prototype.inherits from lang.js rewritten as a standalone
  75505. * function (not on Function.prototype). NOTE: If this file is to be loaded
  75506. * during bootstrapping this function needs to be rewritten using some native
  75507. * functions as prototype setup using normal JavaScript does not work as
  75508. * expected during bootstrapping (see mirror.js in r114903).
  75509. *
  75510. * @param {function} ctor Constructor function which needs to inherit the
  75511. * prototype.
  75512. * @param {function} superCtor Constructor function to inherit prototype from.
  75513. */
  75514. exports.inherits = __webpack_require__(/*! inherits */ "./node_modules/util/node_modules/inherits/inherits_browser.js");
  75515. exports._extend = function(origin, add) {
  75516. // Don't do anything if add isn't an object
  75517. if (!add || !isObject(add)) return origin;
  75518. var keys = Object.keys(add);
  75519. var i = keys.length;
  75520. while (i--) {
  75521. origin[keys[i]] = add[keys[i]];
  75522. }
  75523. return origin;
  75524. };
  75525. function hasOwnProperty(obj, prop) {
  75526. return Object.prototype.hasOwnProperty.call(obj, prop);
  75527. }
  75528. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  75529. exports.promisify = function promisify(original) {
  75530. if (typeof original !== 'function')
  75531. throw new TypeError('The "original" argument must be of type Function');
  75532. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  75533. var fn = original[kCustomPromisifiedSymbol];
  75534. if (typeof fn !== 'function') {
  75535. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  75536. }
  75537. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  75538. value: fn, enumerable: false, writable: false, configurable: true
  75539. });
  75540. return fn;
  75541. }
  75542. function fn() {
  75543. var promiseResolve, promiseReject;
  75544. var promise = new Promise(function (resolve, reject) {
  75545. promiseResolve = resolve;
  75546. promiseReject = reject;
  75547. });
  75548. var args = [];
  75549. for (var i = 0; i < arguments.length; i++) {
  75550. args.push(arguments[i]);
  75551. }
  75552. args.push(function (err, value) {
  75553. if (err) {
  75554. promiseReject(err);
  75555. } else {
  75556. promiseResolve(value);
  75557. }
  75558. });
  75559. try {
  75560. original.apply(this, args);
  75561. } catch (err) {
  75562. promiseReject(err);
  75563. }
  75564. return promise;
  75565. }
  75566. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  75567. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  75568. value: fn, enumerable: false, writable: false, configurable: true
  75569. });
  75570. return Object.defineProperties(
  75571. fn,
  75572. getOwnPropertyDescriptors(original)
  75573. );
  75574. }
  75575. exports.promisify.custom = kCustomPromisifiedSymbol
  75576. function callbackifyOnRejected(reason, cb) {
  75577. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  75578. // Because `null` is a special error value in callbacks which means "no error
  75579. // occurred", we error-wrap so the callback consumer can distinguish between
  75580. // "the promise rejected with null" or "the promise fulfilled with undefined".
  75581. if (!reason) {
  75582. var newReason = new Error('Promise was rejected with a falsy value');
  75583. newReason.reason = reason;
  75584. reason = newReason;
  75585. }
  75586. return cb(reason);
  75587. }
  75588. function callbackify(original) {
  75589. if (typeof original !== 'function') {
  75590. throw new TypeError('The "original" argument must be of type Function');
  75591. }
  75592. // We DO NOT return the promise as it gives the user a false sense that
  75593. // the promise is actually somehow related to the callback's execution
  75594. // and that the callback throwing will reject the promise.
  75595. function callbackified() {
  75596. var args = [];
  75597. for (var i = 0; i < arguments.length; i++) {
  75598. args.push(arguments[i]);
  75599. }
  75600. var maybeCb = args.pop();
  75601. if (typeof maybeCb !== 'function') {
  75602. throw new TypeError('The last argument must be of type Function');
  75603. }
  75604. var self = this;
  75605. var cb = function() {
  75606. return maybeCb.apply(self, arguments);
  75607. };
  75608. // In true node style we process the callback on `nextTick` with all the
  75609. // implications (stack, `uncaughtException`, `async_hooks`)
  75610. original.apply(this, args)
  75611. .then(function(ret) { process.nextTick(cb, null, ret) },
  75612. function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });
  75613. }
  75614. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  75615. Object.defineProperties(callbackified,
  75616. getOwnPropertyDescriptors(original));
  75617. return callbackified;
  75618. }
  75619. exports.callbackify = callbackify;
  75620. /***/ }),
  75621. /***/ "./node_modules/vue-masonry-css/dist/vue-masonry.es2015.js":
  75622. /*!*****************************************************************!*\
  75623. !*** ./node_modules/vue-masonry-css/dist/vue-masonry.es2015.js ***!
  75624. \*****************************************************************/
  75625. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  75626. "use strict";
  75627. __webpack_require__.r(__webpack_exports__);
  75628. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  75629. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  75630. /* harmony export */ });
  75631. /*!
  75632. * vue-masonry-css v1.0.3
  75633. * https://github.com/paulcollett/vue-masonry-css
  75634. * Released under the MIT License.
  75635. */
  75636. // the component name `<masonry />`
  75637. // can be overridden with `Vue.use(Masonry, { name: 'the-masonry' });`
  75638. var componentName = 'masonry';
  75639. var props = {
  75640. tag: {
  75641. type: [String],
  75642. default: 'div'
  75643. },
  75644. cols: {
  75645. type: [Object, Number, String],
  75646. default: 2
  75647. },
  75648. gutter: {
  75649. type: [Object, Number, String],
  75650. default: 0
  75651. },
  75652. css: {
  75653. type: [Boolean],
  75654. default: true
  75655. },
  75656. columnTag: {
  75657. type: [String],
  75658. default: 'div'
  75659. },
  75660. columnClass: {
  75661. type: [String, Array, Object],
  75662. default: function () { return []; }
  75663. },
  75664. columnAttr: {
  75665. type: [Object],
  75666. default: function () { return ({}); }
  75667. }
  75668. };
  75669. // Get the resulting value from `:col=` prop
  75670. // based on the window width
  75671. var breakpointValue = function (mixed, windowWidth) {
  75672. var valueAsNum = parseInt(mixed);
  75673. if(valueAsNum > -1) {
  75674. return mixed;
  75675. }else if(typeof mixed !== 'object') {
  75676. return 0;
  75677. }
  75678. var matchedBreakpoint = Infinity;
  75679. var matchedValue = mixed.default || 0;
  75680. for(var k in mixed) {
  75681. var breakpoint = parseInt(k);
  75682. var breakpointValRaw = mixed[breakpoint];
  75683. var breakpointVal = parseInt(breakpointValRaw);
  75684. if(isNaN(breakpoint) || isNaN(breakpointVal)) {
  75685. continue;
  75686. }
  75687. var isNewBreakpoint = windowWidth <= breakpoint && breakpoint < matchedBreakpoint;
  75688. if(isNewBreakpoint) {
  75689. matchedBreakpoint = breakpoint;
  75690. matchedValue = breakpointValRaw;
  75691. }
  75692. }
  75693. return matchedValue;
  75694. };
  75695. var component = {
  75696. props: props,
  75697. data: function data() {
  75698. return {
  75699. displayColumns: 2,
  75700. displayGutter: 0
  75701. }
  75702. },
  75703. mounted: function mounted() {
  75704. var this$1 = this;
  75705. this.$nextTick(function () {
  75706. this$1.reCalculate();
  75707. });
  75708. // Bind resize handler to page
  75709. if(window) {
  75710. window.addEventListener('resize', this.reCalculate);
  75711. }
  75712. },
  75713. updated: function updated() {
  75714. var this$1 = this;
  75715. this.$nextTick(function () {
  75716. this$1.reCalculate();
  75717. });
  75718. },
  75719. beforeDestroy: function beforeDestroy() {
  75720. if(window) {
  75721. window.removeEventListener('resize', this.reCalculate);
  75722. }
  75723. },
  75724. methods: {
  75725. // Recalculate how many columns to display based on window width
  75726. // and the value of the passed `:cols=` prop
  75727. reCalculate: function reCalculate() {
  75728. var previousWindowWidth = this.windowWidth;
  75729. this.windowWidth = (window ? window.innerWidth : null) || Infinity;
  75730. // Window resize events get triggered on page height
  75731. // change which when loading the page can result in multiple
  75732. // needless calculations. We prevent this here.
  75733. if(previousWindowWidth === this.windowWidth) {
  75734. return;
  75735. }
  75736. this._reCalculateColumnCount(this.windowWidth);
  75737. this._reCalculateGutterSize(this.windowWidth);
  75738. },
  75739. _reCalculateGutterSize: function _reCalculateGutterSize(windowWidth) {
  75740. this.displayGutter = breakpointValue(this.gutter, windowWidth);
  75741. },
  75742. _reCalculateColumnCount: function _reCalculateColumnCount(windowWidth) {
  75743. var newColumns = breakpointValue(this.cols, windowWidth);
  75744. // Make sure we can return a valid value
  75745. newColumns = Math.max(1, Number(newColumns) || 0);
  75746. this.displayColumns = newColumns;
  75747. },
  75748. _getChildItemsInColumnsArray: function _getChildItemsInColumnsArray() {
  75749. var this$1 = this;
  75750. var columns = [];
  75751. var childItems = this.$slots.default || [];
  75752. // This component does not work with a child <transition-group /> ..yet,
  75753. // so for now we think it may be helpful to ignore until we can find a way for support
  75754. if(childItems.length === 1 && childItems[0].componentOptions && childItems[0].componentOptions.tag == 'transition-group') {
  75755. childItems = childItems[0].componentOptions.children;
  75756. }
  75757. // Loop through child elements
  75758. for (var i = 0, visibleItemI = 0; i < childItems.length; i++, visibleItemI++) {
  75759. // skip Vue elements without tags, which includes
  75760. // whitespace elements and also plain text
  75761. if(!childItems[i].tag) {
  75762. visibleItemI--;
  75763. continue;
  75764. }
  75765. // Get the column index the child item will end up in
  75766. var columnIndex = visibleItemI % this$1.displayColumns;
  75767. if(!columns[columnIndex]) {
  75768. columns[columnIndex] = [];
  75769. }
  75770. columns[columnIndex].push(childItems[i]);
  75771. }
  75772. return columns;
  75773. }
  75774. },
  75775. render: function render(createElement) {
  75776. var this$1 = this;
  75777. var columnsContainingChildren = this._getChildItemsInColumnsArray();
  75778. var isGutterSizeUnitless = parseInt(this.displayGutter) === this.displayGutter * 1;
  75779. var gutterSizeWithUnit = isGutterSizeUnitless ? ((this.displayGutter) + "px") : this.displayGutter;
  75780. var columnStyle = {
  75781. boxSizing: 'border-box',
  75782. backgroundClip: 'padding-box',
  75783. width: ((100 / this.displayColumns) + "%"),
  75784. border: '0 solid transparent',
  75785. borderLeftWidth: gutterSizeWithUnit
  75786. };
  75787. var columns = columnsContainingChildren.map(function (children, index) {
  75788. /// Create column element and inject the children
  75789. return createElement(this$1.columnTag, {
  75790. key: index + '-' + columnsContainingChildren.length,
  75791. style: this$1.css ? columnStyle : null,
  75792. class: this$1.columnClass,
  75793. attrs: this$1.columnAttr
  75794. }, children); // specify child items here
  75795. });
  75796. var containerStyle = {
  75797. display: ['-webkit-box', '-ms-flexbox', 'flex'],
  75798. marginLeft: ("-" + gutterSizeWithUnit)
  75799. };
  75800. // Return wrapper with columns
  75801. return createElement(
  75802. this.tag, // tag name
  75803. this.css ? { style: containerStyle } : null, // element options
  75804. columns // column vue elements
  75805. );
  75806. }
  75807. };
  75808. var Plugin = function () {};
  75809. Plugin.install = function (Vue, options) {
  75810. if (Plugin.installed) {
  75811. return;
  75812. }
  75813. if(options && options.name) {
  75814. Vue.component(options.name, component);
  75815. } else {
  75816. Vue.component(componentName, component);
  75817. }
  75818. };
  75819. if (typeof window !== 'undefined' && window.Vue) {
  75820. window.Vue.use(Plugin);
  75821. }
  75822. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Plugin);
  75823. /***/ }),
  75824. /***/ "./node_modules/vuejs-uib-pagination/dist/vuejs-uib-pagination.js":
  75825. /*!************************************************************************!*\
  75826. !*** ./node_modules/vuejs-uib-pagination/dist/vuejs-uib-pagination.js ***!
  75827. \************************************************************************/
  75828. /***/ (function(module) {
  75829. !function(e,t){ true?module.exports=t():0}(this,function(){return function(e){function t(a){if(i[a])return i[a].exports;var n=i[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,a){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,i){"use strict";t.a=function(e){return e},t.b=function(e){return void 0!==e}},function(e,t,i){"use strict";function a(e,t){e.component("uib-pagination",{data:n.a,props:o,watch:r.a,methods:l,template:u.a,computed:c,directives:d})}Object.defineProperty(t,"__esModule",{value:!0}),i.d(t,"install",function(){return a});var n=i(2),r=i(3),s=i(4),u=i.n(s),o=i(5),l=i(6),c=i(7),d=i(8);t.default=a,"undefined"!=typeof window&&window.Vue&&window.Vue.use(a)},function(e,t,i){"use strict";var a=i(0);t.a=function(){return{currentPage:a.b(this.value.currentPage)?this.value.currentPage:1}}},function(e,t,i){"use strict";t.a={"value.currentPage":function(e,t){this.currentPage=e,null!=t&&(this.changeOnClick||this.$emit("change"))}}},function(e,t){e.exports='<ul class=pagination role=menu> <li role=menuitem v-if=boundaryLinks :class="{ disabled: isNoPreviousOrDisabled }" class=pagination-first> <a href @click="selectPage(1, $event)" :disabled=isNoPreviousOrDisabled v-uib-tabindex-toggle=isNoPreviousOrDisabled>{{ getText(\'first\') }}</a> </li> <li role=menuitem v-if=directionLinks :class="{ disabled: isNoPreviousOrDisabled }" class=pagination-prev> <a href @click="selectPage(currentPage - 1, $event)" :disabled=isNoPreviousOrDisabled v-uib-tabindex-toggle=isNoPreviousOrDisabled>{{ getText(\'previous\') }}</a> </li> <li role=menuitem v-for="(page, index) in pages" :key=index :class="{ active: page.active, disabled: disabled && !page.active }" class=pagination-page> <a href @click="selectPage(page.number, $event)" :disabled="disabled && !page.active" v-uib-tabindex-toggle="disabled && !page.active" v-html=page.text></a> </li> <li role=menuitem v-if=directionLinks :class="{ disabled: isNoNextOrDisabled }" class=pagination-next> <a href @click="selectPage(currentPage + 1, $event)" :disabled=isNoNextOrDisabled v-uib-tabindex-toggle=isNoNextOrDisabled>{{ getText(\'next\') }}</a> </li> <li role=menuitem v-if=boundaryLinks :class="{ disabled: isNoNextOrDisabled }" class=pagination-last> <a href @click="selectPage(totalPages, $event)" :disabled=isNoNextOrDisabled v-uib-tabindex-toggle=isNoNextOrDisabled>{{ getText(\'last\') }}</a> </li> </ul>'},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i.d(t,"boundaryLinks",function(){return n}),i.d(t,"boundaryLinkNumbers",function(){return r}),i.d(t,"directionLinks",function(){return s}),i.d(t,"disabled",function(){return u}),i.d(t,"firstText",function(){return o}),i.d(t,"forceEllipses",function(){return l}),i.d(t,"itemsPerPage",function(){return c}),i.d(t,"lastText",function(){return d}),i.d(t,"maxSize",function(){return f}),i.d(t,"nextText",function(){return g}),i.d(t,"changeOnClick",function(){return h}),i.d(t,"value",function(){return b}),i.d(t,"pageLabel",function(){return p}),i.d(t,"previousText",function(){return P}),i.d(t,"rotate",function(){return v}),i.d(t,"totalItems",function(){return m});var a=i(0),n={type:Boolean,default:!1},r={type:Boolean,default:!1},s={type:Boolean,default:!0},u={type:Boolean,default:!1},o={type:String,default:"First"},l={type:Boolean,default:!1},c={type:Number,default:10},d={type:String,default:"Last"},f={type:Number,default:void 0},g={type:String,default:"Next"},h={type:Boolean,default:!1},b={type:Object,required:!0,validator:function(e){return!a.b(e.currentPage)||"number"==typeof e.currentPage}},p={type:Function,default:a.a},P={type:String,default:"Previous"},v={type:Boolean,default:!0},m={type:Number,default:0}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getText=function(e){return this[e+"Text"]},t.selectPage=function(e,t){t&&t.preventDefault(),(!this.disabled||!t)&&this.currentPage!==e&&e>0&&e<=this.totalPages&&(t&&t.target&&t.target.blur(),this.currentPage=e,this.changeOnClick&&this.$emit("change"))},t.makePage=function(e,t,i){return{number:e,text:t,active:i}},t.createDataForModel=function(e,t){var i={currentPage:e,numPages:t};return Object.defineProperties(i,{numPages:{get:function(){return t}}}),i}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNoPreviousOrDisabled=function(){return this.noPrevious||this.disabled},t.isNoNextOrDisabled=function(){return this.noNext||this.disabled},t.noNext=function(){return this.value.currentPage===this.totalPages},t.noPrevious=function(){return 1===this.value.currentPage},t.totalPages=function(){var e=this.itemsPerPage<1?1:Math.ceil(this.totalItems/this.itemsPerPage);return Math.max(e||0,1)},t.pages=function(){var e=[];if(this.currentPage<=0||this.currentPage>this.totalPages)return e;var t=1,i=this.totalPages,n=a.b(this.maxSize)&&this.maxSize<this.totalPages;n&&(this.rotate?(i=(t=Math.max(this.currentPage-Math.floor(this.maxSize/2),1))+this.maxSize-1)>this.totalPages&&(t=(i=this.totalPages)-this.maxSize+1):(t=(Math.ceil(this.currentPage/this.maxSize)-1)*this.maxSize+1,i=Math.min(t+this.maxSize-1,this.totalPages)));for(var r=t;r<=i;r++){var s=this.makePage(r,this.pageLabel(r),r===this.currentPage);e.push(s)}if(n&&this.maxSize>0&&(!this.rotate||this.forceEllipses||this.boundaryLinkNumbers)){if(t>1){if(!this.boundaryLinkNumbers||t>3){var u=this.makePage(t-1,"...",!1);e.unshift(u)}if(this.boundaryLinkNumbers){if(3===t){var o=this.makePage(2,"2",!1);e.unshift(o)}var l=this.makePage(1,"1",!1);e.unshift(l)}}if(i<this.totalPages){if(!this.boundaryLinkNumbers||i<this.totalPages-2){var c=this.makePage(i+1,"...",!1);e.push(c)}if(this.boundaryLinkNumbers){if(i===this.totalPages-2){var d=this.makePage(this.totalPages-1,this.totalPages-1,!1);e.push(d)}var f=this.makePage(this.totalPages,this.totalPages,!1);e.push(f)}}}return this.$emit("input",this.createDataForModel(this.currentPage,this.totalPages)),e};var a=i(0)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uibTabindexToggle=function(e,t){t.value?e.setAttribute("tabindex","-1"):e.removeAttribute("tabindex")}}])});
  75830. //# sourceMappingURL=vuejs-uib-pagination.js.map
  75831. /***/ }),
  75832. /***/ "?248e":
  75833. /*!************************!*\
  75834. !*** buffer (ignored) ***!
  75835. \************************/
  75836. /***/ (() => {
  75837. /* (ignored) */
  75838. /***/ }),
  75839. /***/ "?f4e8":
  75840. /*!************************!*\
  75841. !*** buffer (ignored) ***!
  75842. \************************/
  75843. /***/ (() => {
  75844. /* (ignored) */
  75845. /***/ }),
  75846. /***/ "?8d7a":
  75847. /*!************************!*\
  75848. !*** crypto (ignored) ***!
  75849. \************************/
  75850. /***/ (() => {
  75851. /* (ignored) */
  75852. /***/ }),
  75853. /***/ "?07b7":
  75854. /*!**********************!*\
  75855. !*** util (ignored) ***!
  75856. \**********************/
  75857. /***/ (() => {
  75858. /* (ignored) */
  75859. /***/ }),
  75860. /***/ "?3897":
  75861. /*!**********************!*\
  75862. !*** util (ignored) ***!
  75863. \**********************/
  75864. /***/ (() => {
  75865. /* (ignored) */
  75866. /***/ }),
  75867. /***/ "?5f8c":
  75868. /*!************************!*\
  75869. !*** buffer (ignored) ***!
  75870. \************************/
  75871. /***/ (() => {
  75872. /* (ignored) */
  75873. /***/ }),
  75874. /***/ "?8f95":
  75875. /*!************************!*\
  75876. !*** buffer (ignored) ***!
  75877. \************************/
  75878. /***/ (() => {
  75879. /* (ignored) */
  75880. /***/ }),
  75881. /***/ "?1fc4":
  75882. /*!************************!*\
  75883. !*** buffer (ignored) ***!
  75884. \************************/
  75885. /***/ (() => {
  75886. /* (ignored) */
  75887. /***/ }),
  75888. /***/ "?f84a":
  75889. /*!**********************!*\
  75890. !*** util (ignored) ***!
  75891. \**********************/
  75892. /***/ (() => {
  75893. /* (ignored) */
  75894. /***/ }),
  75895. /***/ "?11f8":
  75896. /*!**********************!*\
  75897. !*** util (ignored) ***!
  75898. \**********************/
  75899. /***/ (() => {
  75900. /* (ignored) */
  75901. /***/ }),
  75902. /***/ "?5588":
  75903. /*!************************!*\
  75904. !*** buffer (ignored) ***!
  75905. \************************/
  75906. /***/ (() => {
  75907. /* (ignored) */
  75908. /***/ }),
  75909. /***/ "?adc3":
  75910. /*!**********************!*\
  75911. !*** util (ignored) ***!
  75912. \**********************/
  75913. /***/ (() => {
  75914. /* (ignored) */
  75915. /***/ }),
  75916. /***/ "?9a2a":
  75917. /*!**********************!*\
  75918. !*** util (ignored) ***!
  75919. \**********************/
  75920. /***/ (() => {
  75921. /* (ignored) */
  75922. /***/ }),
  75923. /***/ "?a44a":
  75924. /*!************************!*\
  75925. !*** buffer (ignored) ***!
  75926. \************************/
  75927. /***/ (() => {
  75928. /* (ignored) */
  75929. /***/ }),
  75930. /***/ "./node_modules/crypto-random-string/index.js":
  75931. /*!****************************************************!*\
  75932. !*** ./node_modules/crypto-random-string/index.js ***!
  75933. \****************************************************/
  75934. /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
  75935. "use strict";
  75936. __webpack_require__.r(__webpack_exports__);
  75937. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  75938. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  75939. /* harmony export */ });
  75940. /* harmony import */ var util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! util */ "./node_modules/util/util.js");
  75941. /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! crypto */ "./node_modules/crypto-browserify/index.js");
  75942. const randomBytesAsync = (0,util__WEBPACK_IMPORTED_MODULE_0__.promisify)(crypto__WEBPACK_IMPORTED_MODULE_1__.randomBytes);
  75943. const urlSafeCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~'.split('');
  75944. const numericCharacters = '0123456789'.split('');
  75945. const distinguishableCharacters = 'CDEHKMPRTUWXY012458'.split('');
  75946. const asciiPrintableCharacters = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.split('');
  75947. const alphanumericCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split('');
  75948. const generateForCustomCharacters = (length, characters) => {
  75949. // Generating entropy is faster than complex math operations, so we use the simplest way
  75950. const characterCount = characters.length;
  75951. const maxValidSelector = (Math.floor(0x10000 / characterCount) * characterCount) - 1; // Using values above this will ruin distribution when using modular division
  75952. const entropyLength = 2 * Math.ceil(1.1 * length); // Generating a bit more than required so chances we need more than one pass will be really low
  75953. let string = '';
  75954. let stringLength = 0;
  75955. while (stringLength < length) { // In case we had many bad values, which may happen for character sets of size above 0x8000 but close to it
  75956. const entropy = crypto__WEBPACK_IMPORTED_MODULE_1__.randomBytes(entropyLength);
  75957. let entropyPosition = 0;
  75958. while (entropyPosition < entropyLength && stringLength < length) {
  75959. const entropyValue = entropy.readUInt16LE(entropyPosition);
  75960. entropyPosition += 2;
  75961. if (entropyValue > maxValidSelector) { // Skip values which will ruin distribution when using modular division
  75962. continue;
  75963. }
  75964. string += characters[entropyValue % characterCount];
  75965. stringLength++;
  75966. }
  75967. }
  75968. return string;
  75969. };
  75970. const generateForCustomCharactersAsync = async (length, characters) => {
  75971. // Generating entropy is faster than complex math operations, so we use the simplest way
  75972. const characterCount = characters.length;
  75973. const maxValidSelector = (Math.floor(0x10000 / characterCount) * characterCount) - 1; // Using values above this will ruin distribution when using modular division
  75974. const entropyLength = 2 * Math.ceil(1.1 * length); // Generating a bit more than required so chances we need more than one pass will be really low
  75975. let string = '';
  75976. let stringLength = 0;
  75977. while (stringLength < length) { // In case we had many bad values, which may happen for character sets of size above 0x8000 but close to it
  75978. const entropy = await randomBytesAsync(entropyLength); // eslint-disable-line no-await-in-loop
  75979. let entropyPosition = 0;
  75980. while (entropyPosition < entropyLength && stringLength < length) {
  75981. const entropyValue = entropy.readUInt16LE(entropyPosition);
  75982. entropyPosition += 2;
  75983. if (entropyValue > maxValidSelector) { // Skip values which will ruin distribution when using modular division
  75984. continue;
  75985. }
  75986. string += characters[entropyValue % characterCount];
  75987. stringLength++;
  75988. }
  75989. }
  75990. return string;
  75991. };
  75992. const generateRandomBytes = (byteLength, type, length) => crypto__WEBPACK_IMPORTED_MODULE_1__.randomBytes(byteLength).toString(type).slice(0, length);
  75993. const generateRandomBytesAsync = async (byteLength, type, length) => {
  75994. const buffer = await randomBytesAsync(byteLength);
  75995. return buffer.toString(type).slice(0, length);
  75996. };
  75997. const allowedTypes = new Set([
  75998. undefined,
  75999. 'hex',
  76000. 'base64',
  76001. 'url-safe',
  76002. 'numeric',
  76003. 'distinguishable',
  76004. 'ascii-printable',
  76005. 'alphanumeric'
  76006. ]);
  76007. const createGenerator = (generateForCustomCharacters, generateRandomBytes) => ({length, type, characters}) => {
  76008. if (!(length >= 0 && Number.isFinite(length))) {
  76009. throw new TypeError('Expected a `length` to be a non-negative finite number');
  76010. }
  76011. if (type !== undefined && characters !== undefined) {
  76012. throw new TypeError('Expected either `type` or `characters`');
  76013. }
  76014. if (characters !== undefined && typeof characters !== 'string') {
  76015. throw new TypeError('Expected `characters` to be string');
  76016. }
  76017. if (!allowedTypes.has(type)) {
  76018. throw new TypeError(`Unknown type: ${type}`);
  76019. }
  76020. if (type === undefined && characters === undefined) {
  76021. type = 'hex';
  76022. }
  76023. if (type === 'hex' || (type === undefined && characters === undefined)) {
  76024. return generateRandomBytes(Math.ceil(length * 0.5), 'hex', length); // Need 0.5 byte entropy per character
  76025. }
  76026. if (type === 'base64') {
  76027. return generateRandomBytes(Math.ceil(length * 0.75), 'base64', length); // Need 0.75 byte of entropy per character
  76028. }
  76029. if (type === 'url-safe') {
  76030. return generateForCustomCharacters(length, urlSafeCharacters);
  76031. }
  76032. if (type === 'numeric') {
  76033. return generateForCustomCharacters(length, numericCharacters);
  76034. }
  76035. if (type === 'distinguishable') {
  76036. return generateForCustomCharacters(length, distinguishableCharacters);
  76037. }
  76038. if (type === 'ascii-printable') {
  76039. return generateForCustomCharacters(length, asciiPrintableCharacters);
  76040. }
  76041. if (type === 'alphanumeric') {
  76042. return generateForCustomCharacters(length, alphanumericCharacters);
  76043. }
  76044. if (characters.length === 0) {
  76045. throw new TypeError('Expected `characters` string length to be greater than or equal to 1');
  76046. }
  76047. if (characters.length > 0x10000) {
  76048. throw new TypeError('Expected `characters` string length to be less or equal to 65536');
  76049. }
  76050. return generateForCustomCharacters(length, characters.split(''));
  76051. };
  76052. const cryptoRandomString = createGenerator(generateForCustomCharacters, generateRandomBytes);
  76053. cryptoRandomString.async = createGenerator(generateForCustomCharactersAsync, generateRandomBytesAsync);
  76054. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (cryptoRandomString);
  76055. /***/ }),
  76056. /***/ "./node_modules/axios/package.json":
  76057. /*!*****************************************!*\
  76058. !*** ./node_modules/axios/package.json ***!
  76059. \*****************************************/
  76060. /***/ ((module) => {
  76061. "use strict";
  76062. module.exports = JSON.parse('{"_args":[["axios@0.21.4","/var/www/html"]],"_development":true,"_from":"axios@0.21.4","_id":"axios@0.21.4","_inBundle":false,"_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"axios@0.21.4","name":"axios","escapedName":"axios","rawSpec":"0.21.4","saveSpec":null,"fetchSpec":"0.21.4"},"_requiredBy":["#DEV:/","/localtunnel"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_spec":"0.21.4","_where":"/var/www/html","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.4"}');
  76063. /***/ }),
  76064. /***/ "./node_modules/browserify-aes/modes/list.json":
  76065. /*!*****************************************************!*\
  76066. !*** ./node_modules/browserify-aes/modes/list.json ***!
  76067. \*****************************************************/
  76068. /***/ ((module) => {
  76069. "use strict";
  76070. module.exports = JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}');
  76071. /***/ }),
  76072. /***/ "./node_modules/browserify-sign/browser/algorithms.json":
  76073. /*!**************************************************************!*\
  76074. !*** ./node_modules/browserify-sign/browser/algorithms.json ***!
  76075. \**************************************************************/
  76076. /***/ ((module) => {
  76077. "use strict";
  76078. module.exports = JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}');
  76079. /***/ }),
  76080. /***/ "./node_modules/browserify-sign/browser/curves.json":
  76081. /*!**********************************************************!*\
  76082. !*** ./node_modules/browserify-sign/browser/curves.json ***!
  76083. \**********************************************************/
  76084. /***/ ((module) => {
  76085. "use strict";
  76086. module.exports = JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}');
  76087. /***/ }),
  76088. /***/ "./node_modules/diffie-hellman/lib/primes.json":
  76089. /*!*****************************************************!*\
  76090. !*** ./node_modules/diffie-hellman/lib/primes.json ***!
  76091. \*****************************************************/
  76092. /***/ ((module) => {
  76093. "use strict";
  76094. module.exports = JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}');
  76095. /***/ }),
  76096. /***/ "./node_modules/elliptic/package.json":
  76097. /*!********************************************!*\
  76098. !*** ./node_modules/elliptic/package.json ***!
  76099. \********************************************/
  76100. /***/ ((module) => {
  76101. "use strict";
  76102. module.exports = JSON.parse('{"_args":[["elliptic@6.5.4","/var/www/html"]],"_from":"elliptic@6.5.4","_id":"elliptic@6.5.4","_inBundle":false,"_integrity":"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==","_location":"/elliptic","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"elliptic@6.5.4","name":"elliptic","escapedName":"elliptic","rawSpec":"6.5.4","saveSpec":null,"fetchSpec":"6.5.4"},"_requiredBy":["/browserify-sign","/create-ecdh"],"_resolved":"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz","_spec":"6.5.4","_where":"/var/www/html","author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"bugs":{"url":"https://github.com/indutny/elliptic/issues"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},"description":"EC cryptography","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"files":["lib"],"homepage":"https://github.com/indutny/elliptic","keywords":["EC","Elliptic","curve","Cryptography"],"license":"MIT","main":"lib/elliptic.js","name":"elliptic","repository":{"type":"git","url":"git+ssh://git@github.com/indutny/elliptic.git"},"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","test":"npm run lint && npm run unit","unit":"istanbul test _mocha --reporter=spec test/index.js","version":"grunt dist && git add dist/"},"version":"6.5.4"}');
  76103. /***/ }),
  76104. /***/ "./node_modules/parse-asn1/aesid.json":
  76105. /*!********************************************!*\
  76106. !*** ./node_modules/parse-asn1/aesid.json ***!
  76107. \********************************************/
  76108. /***/ ((module) => {
  76109. "use strict";
  76110. module.exports = JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}');
  76111. /***/ })
  76112. /******/ });
  76113. /************************************************************************/
  76114. /******/ // The module cache
  76115. /******/ var __webpack_module_cache__ = {};
  76116. /******/
  76117. /******/ // The require function
  76118. /******/ function __webpack_require__(moduleId) {
  76119. /******/ // Check if module is in cache
  76120. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  76121. /******/ if (cachedModule !== undefined) {
  76122. /******/ return cachedModule.exports;
  76123. /******/ }
  76124. /******/ // Create a new module (and put it into the cache)
  76125. /******/ var module = __webpack_module_cache__[moduleId] = {
  76126. /******/ id: moduleId,
  76127. /******/ loaded: false,
  76128. /******/ exports: {}
  76129. /******/ };
  76130. /******/
  76131. /******/ // Execute the module function
  76132. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  76133. /******/
  76134. /******/ // Flag the module as loaded
  76135. /******/ module.loaded = true;
  76136. /******/
  76137. /******/ // Return the exports of the module
  76138. /******/ return module.exports;
  76139. /******/ }
  76140. /******/
  76141. /******/ // expose the modules object (__webpack_modules__)
  76142. /******/ __webpack_require__.m = __webpack_modules__;
  76143. /******/
  76144. /************************************************************************/
  76145. /******/ /* webpack/runtime/chunk loaded */
  76146. /******/ (() => {
  76147. /******/ var deferred = [];
  76148. /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
  76149. /******/ if(chunkIds) {
  76150. /******/ priority = priority || 0;
  76151. /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
  76152. /******/ deferred[i] = [chunkIds, fn, priority];
  76153. /******/ return;
  76154. /******/ }
  76155. /******/ var notFulfilled = Infinity;
  76156. /******/ for (var i = 0; i < deferred.length; i++) {
  76157. /******/ var [chunkIds, fn, priority] = deferred[i];
  76158. /******/ var fulfilled = true;
  76159. /******/ for (var j = 0; j < chunkIds.length; j++) {
  76160. /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
  76161. /******/ chunkIds.splice(j--, 1);
  76162. /******/ } else {
  76163. /******/ fulfilled = false;
  76164. /******/ if(priority < notFulfilled) notFulfilled = priority;
  76165. /******/ }
  76166. /******/ }
  76167. /******/ if(fulfilled) {
  76168. /******/ deferred.splice(i--, 1)
  76169. /******/ var r = fn();
  76170. /******/ if (r !== undefined) result = r;
  76171. /******/ }
  76172. /******/ }
  76173. /******/ return result;
  76174. /******/ };
  76175. /******/ })();
  76176. /******/
  76177. /******/ /* webpack/runtime/compat get default export */
  76178. /******/ (() => {
  76179. /******/ // getDefaultExport function for compatibility with non-harmony modules
  76180. /******/ __webpack_require__.n = (module) => {
  76181. /******/ var getter = module && module.__esModule ?
  76182. /******/ () => (module['default']) :
  76183. /******/ () => (module);
  76184. /******/ __webpack_require__.d(getter, { a: getter });
  76185. /******/ return getter;
  76186. /******/ };
  76187. /******/ })();
  76188. /******/
  76189. /******/ /* webpack/runtime/define property getters */
  76190. /******/ (() => {
  76191. /******/ // define getter functions for harmony exports
  76192. /******/ __webpack_require__.d = (exports, definition) => {
  76193. /******/ for(var key in definition) {
  76194. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  76195. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  76196. /******/ }
  76197. /******/ }
  76198. /******/ };
  76199. /******/ })();
  76200. /******/
  76201. /******/ /* webpack/runtime/global */
  76202. /******/ (() => {
  76203. /******/ __webpack_require__.g = (function() {
  76204. /******/ if (typeof globalThis === 'object') return globalThis;
  76205. /******/ try {
  76206. /******/ return this || new Function('return this')();
  76207. /******/ } catch (e) {
  76208. /******/ if (typeof window === 'object') return window;
  76209. /******/ }
  76210. /******/ })();
  76211. /******/ })();
  76212. /******/
  76213. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  76214. /******/ (() => {
  76215. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  76216. /******/ })();
  76217. /******/
  76218. /******/ /* webpack/runtime/make namespace object */
  76219. /******/ (() => {
  76220. /******/ // define __esModule on exports
  76221. /******/ __webpack_require__.r = (exports) => {
  76222. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  76223. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  76224. /******/ }
  76225. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  76226. /******/ };
  76227. /******/ })();
  76228. /******/
  76229. /******/ /* webpack/runtime/node module decorator */
  76230. /******/ (() => {
  76231. /******/ __webpack_require__.nmd = (module) => {
  76232. /******/ module.paths = [];
  76233. /******/ if (!module.children) module.children = [];
  76234. /******/ return module;
  76235. /******/ };
  76236. /******/ })();
  76237. /******/
  76238. /******/ /* webpack/runtime/jsonp chunk loading */
  76239. /******/ (() => {
  76240. /******/ // no baseURI
  76241. /******/
  76242. /******/ // object to store loaded and loading chunks
  76243. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  76244. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  76245. /******/ var installedChunks = {
  76246. /******/ "/js/app": 0,
  76247. /******/ "css/app": 0
  76248. /******/ };
  76249. /******/
  76250. /******/ // no chunk on demand loading
  76251. /******/
  76252. /******/ // no prefetching
  76253. /******/
  76254. /******/ // no preloaded
  76255. /******/
  76256. /******/ // no HMR
  76257. /******/
  76258. /******/ // no HMR manifest
  76259. /******/
  76260. /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
  76261. /******/
  76262. /******/ // install a JSONP callback for chunk loading
  76263. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  76264. /******/ var [chunkIds, moreModules, runtime] = data;
  76265. /******/ // add "moreModules" to the modules object,
  76266. /******/ // then flag all "chunkIds" as loaded and fire callback
  76267. /******/ var moduleId, chunkId, i = 0;
  76268. /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
  76269. /******/ for(moduleId in moreModules) {
  76270. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  76271. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  76272. /******/ }
  76273. /******/ }
  76274. /******/ if(runtime) var result = runtime(__webpack_require__);
  76275. /******/ }
  76276. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  76277. /******/ for(;i < chunkIds.length; i++) {
  76278. /******/ chunkId = chunkIds[i];
  76279. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  76280. /******/ installedChunks[chunkId][0]();
  76281. /******/ }
  76282. /******/ installedChunks[chunkId] = 0;
  76283. /******/ }
  76284. /******/ return __webpack_require__.O(result);
  76285. /******/ }
  76286. /******/
  76287. /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
  76288. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  76289. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  76290. /******/ })();
  76291. /******/
  76292. /******/ /* webpack/runtime/nonce */
  76293. /******/ (() => {
  76294. /******/ __webpack_require__.nc = undefined;
  76295. /******/ })();
  76296. /******/
  76297. /************************************************************************/
  76298. /******/
  76299. /******/ // startup
  76300. /******/ // Load entry module and return exports
  76301. /******/ // This entry module depends on other loaded chunks and execution need to be delayed
  76302. /******/ __webpack_require__.O(undefined, ["css/app"], () => (__webpack_require__("./resources/js/app.js")))
  76303. /******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["css/app"], () => (__webpack_require__("./resources/css/app.css")))
  76304. /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
  76305. /******/
  76306. /******/ })()
  76307. ;