ezuikit.js 955 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497
  1. 'use strict';
  2. class Core {
  3. constructor(x, y) {
  4. this.coreX = x;
  5. this.coreY = y;
  6. }
  7. toString() {
  8. return `${this.coreX}-${this.coreY}`;
  9. }
  10. }
  11. // eslint-disable-next-line no-extend-native
  12. Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S": this.getMilliseconds() }; if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); } return fmt };
  13. // 加载js
  14. const addJs = (filepath, callback, isReadyFun) => {
  15. var headerScript = document.getElementsByTagName('head')[0].getElementsByTagName("script");
  16. var isReady = false;
  17. if(isReadyFun) {
  18. isReady = isReadyFun();
  19. } else {
  20. for (var i = 0; i < headerScript.length; i++) {
  21. if (headerScript[i].getAttribute("src") == filepath) {
  22. isReady = true;
  23. callback();
  24. }
  25. }
  26. }
  27. if (!isReady) {
  28. var oJs = document.createElement("script");
  29. oJs.setAttribute("src", filepath);
  30. oJs.onload = callback;
  31. document.getElementsByTagName("head")[0].appendChild(oJs);
  32. } else {
  33. callback();
  34. }
  35. };
  36. const addCss = (filepath, callback) => {
  37. var headerLink = document.getElementsByTagName('head')[0].getElementsByTagName("link");
  38. var isReady = false;
  39. for (var i = 0; i < headerLink.length; i++) {
  40. if (headerLink[i].getAttribute("href") == filepath) {
  41. isReady = true;
  42. }
  43. }
  44. if (!isReady) {
  45. var oJs = document.createElement('link');
  46. oJs.rel = 'stylesheet';
  47. oJs.type = 'text/css';
  48. oJs.href = filepath;
  49. oJs.onload = callback;
  50. document.getElementsByTagName("head")[0].appendChild(oJs);
  51. }
  52. };
  53. const isPromise = (obj) => {
  54. return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  55. };
  56. const getQueryString = (name, url) => {
  57. var r = new RegExp("(\\?|#|&)" + name + "=(.*?)(#|&|$)"); var m = (url || window.location.href).match(r); return decodeURIComponent(m ? m[2] : '');
  58. };
  59. const insertAfter$1 = (newElement, targetElement) => {
  60. var parent = targetElement.parentNode; if (parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); }
  61. };
  62. const requestFullScreen = (element) => {
  63. console.log("requestFullScreen", document.getElementById(element));
  64. var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
  65. if (requestMethod) {
  66. requestMethod.call(element);
  67. } else if (typeof window.ActiveXObject !== "undefined") {
  68. var wscript = new window.ActiveXObject("WScript.Shell");
  69. if (wscript !== null) {
  70. wscript.SendKeys("{F11}");
  71. }
  72. }
  73. };
  74. const requestMobileFullScreen = (element) => {
  75. var width = document.documentElement.clientWidth;
  76. var height = document.documentElement.clientHeight;
  77. var wrapper = element;
  78. var style = "";
  79. style += "width:" + height + "px;";// 注意旋转后的宽高切换
  80. style += "height:" + width + "px;";
  81. style += "-webkit-transform: rotate(90.001deg); transform: rotate(90.001deg);";
  82. // 注意旋转中点的处理
  83. style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  84. style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  85. style += 'position: fixed;top: 0;left: 0;z-index:10';
  86. wrapper.style.cssText = style;
  87. };
  88. const requestFullScreenPromise = (element) => {
  89. requestFullScreen(element);
  90. var promise = new Promise(function (resolve, reject) {
  91. var timeInterval = setInterval(() => {
  92. let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  93. if (isFullScreen) {
  94. clearInterval(timeInterval);
  95. return resolve(true);
  96. }
  97. }, 100);
  98. var timeOut = setTimeout(() => {
  99. let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  100. if (!isFullScreen) {
  101. reject(false);
  102. }
  103. clearTimeout(timeOut);
  104. }, 2000);
  105. });
  106. return promise;
  107. };
  108. const cancelMobileFullScreen = (element, width, height) => {
  109. var style = "";
  110. style += "width:" + width + "px;";
  111. style += "height:" + height + "px;";
  112. style += "-webkit-transform: rotate(0); transform: rotate(0);";
  113. style += "-webkit-transform-origin: 0 0;";
  114. style += "transform-origin: 0 0;";
  115. element.style.cssText = style;
  116. };
  117. const cancelFullScreen = () => {
  118. if (document.exitFullscreen) {
  119. document.exitFullscreen();
  120. } else if (document.webkitCancelFullScreen) {
  121. document.webkitCancelFullScreen();
  122. } else if (document.mozCancelFullScreen) {
  123. document.mozCancelFullScreen();
  124. }
  125. };
  126. const cancelFullScreenPromise = (element) => {
  127. cancelFullScreen();
  128. var promise = new Promise(function (resolve, reject) {
  129. var timeInterval = setInterval(() => {
  130. let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  131. if (!isFullScreen) {
  132. clearInterval(timeInterval);
  133. return resolve(true);
  134. }
  135. }, 50);
  136. var timeOut = setTimeout(() => {
  137. let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  138. if (isFullScreen) {
  139. reject(false);
  140. }
  141. clearTimeout(timeOut);
  142. }, 2000);
  143. });
  144. return promise;
  145. };
  146. const matchEzopenUrl = (ezopenUrl) => {
  147. const deviceSerial = ezopenUrl.split("/")[3];
  148. const channelNo = ezopenUrl.split("/")[4].split(".")[0];
  149. const validCode = ezopenUrl.split("/")[2].split("@").length === 2 ? ezopenUrl.split("/")[2].split("@")[0] : "";
  150. const hd = ezopenUrl.indexOf('.hd') !== -1;
  151. let type = ezopenUrl.split("/")[4].split(".")[ezopenUrl.split("/")[4].split(".").length - 1].split("?")[0];
  152. if (type === 'rec' && ezopenUrl.indexOf(".cloud.rec") !== -1) {
  153. type = 'cloud.rec';
  154. }
  155. return {
  156. deviceSerial,
  157. channelNo,
  158. validCode,
  159. hd,
  160. type
  161. };
  162. };
  163. function isJSON(str) {
  164. if (typeof str === 'string') {
  165. try {
  166. var obj = JSON.parse(str); if (typeof obj === 'object' && obj) {
  167. return true;
  168. } return false;
  169. } catch (e) {
  170. return false;
  171. }
  172. } console.log('It is not a string!');
  173. }
  174. const request = (url, method, params, header, success, error) => {
  175. var _url = url;
  176. var http_request = new XMLHttpRequest();
  177. http_request.onreadystatechange = function () {
  178. if (http_request.readyState == 4) {
  179. if (http_request.status == 200) {
  180. if (isJSON(http_request.responseText)) {
  181. var _data = JSON.parse(http_request.responseText);
  182. success(_data);
  183. } else {
  184. success(http_request.responseText);
  185. }
  186. }
  187. }
  188. };
  189. http_request.open(method, _url, true);
  190. // http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  191. var data = new FormData();
  192. for (var i in params) {
  193. data.append(i, params[i]);
  194. }
  195. http_request.send(data);
  196. };
  197. class HLS {
  198. constructor(videoId, url) {
  199. addJs("https://open.ys7.com/sdk/js/2.0/js/hls.min.js", () => {
  200. console.log("加载hls.min.js成功", window.Hls);
  201. console.log("isSupportHls", window.Hls.isSupported());
  202. if (window.Hls.isSupported()) {
  203. this.initHLS(videoId, url);
  204. }
  205. });
  206. }
  207. toString() {
  208. return `hls ${this.coreX}-${this.coreY}`;
  209. }
  210. initHLS(videoId, hlsUrl) {
  211. var video = document.getElementById(videoId);
  212. var hls = new window.Hls({ defaultAudioCodec: 'mp4a.40.2' }); // 萤石设备默认使用 AAC LC 音频编码
  213. hls.loadSource(hlsUrl);
  214. hls.attachMedia(video);
  215. hls.on(window.Hls.Events.MANIFEST_PARSED, function () {
  216. video.play();
  217. });
  218. hls.on(window.Hls.Events.ERROR, function (event, data) {
  219. if (data.fatal) {
  220. switch (data.type) {
  221. case window.Hls.ErrorTypes.NETWORK_ERROR:
  222. // try to recover network error
  223. console.log("fatal network error encountered, try to recover");
  224. hls.startLoad();
  225. break;
  226. case window.Hls.ErrorTypes.MEDIA_ERROR:
  227. console.log("fatal media error encountered, try to recover");
  228. hls.recoverMediaError();
  229. break;
  230. default:
  231. // cannot recover
  232. hls.destroy();
  233. break;
  234. }
  235. }
  236. });
  237. this.hls = hls;
  238. this.video = video;
  239. this.hlsUrl = hlsUrl;
  240. }
  241. play() {
  242. console.log("执行hls播放", this.video);
  243. this.hls.startLoad();
  244. // this.video.src = this.hlsUrl;
  245. this.video.play();
  246. }
  247. stop() {
  248. // 通过暂停停止播放
  249. // this.video.pause();
  250. // this.video.src = "";
  251. this.video.pause();
  252. // 停止取流
  253. this.hls.stopLoad();
  254. // this.hls.destroy();
  255. }
  256. }
  257. class FLV {
  258. constructor(videoId, url) {
  259. addJs("https://open.ys7.com/sdk/js/2.0/js/flv.min.js", () => {
  260. console.log("加载flv.min.js成功", window.flvjs);
  261. console.log("isSupportFlv", window.flvjs.isSupported());
  262. if (window.flvjs.isSupported()) {
  263. this.initFLV(videoId, url);
  264. }
  265. });
  266. }
  267. toString() {
  268. return `Flv ${this.coreX}-${this.coreY}`;
  269. }
  270. initFLV(videoId, flvUrl) {
  271. var video = document.getElementById(videoId);
  272. var hasControls = video.getAttribute('controls');
  273. if (!hasControls) {
  274. video.setAttribute('controls', true);
  275. }
  276. var flvPlayer = window.flvjs.createPlayer({
  277. type: 'flv',
  278. url: flvUrl,
  279. isLive: true,
  280. }, {
  281. enableStashBuffer: true,
  282. stashInitialSize: 128,
  283. enableWorker: true
  284. });
  285. flvPlayer.attachMediaElement(video);
  286. flvPlayer.load();
  287. flvPlayer.play();
  288. this.flvUrl = flvUrl;
  289. this.flv = flvPlayer;
  290. this.video = video;
  291. }
  292. play() {
  293. console.log("执行flv播放", this.video);
  294. this.video.play();
  295. }
  296. stop() {
  297. // 通过暂停停止播放
  298. // this.video.pause();
  299. // this.video.src = "";
  300. this.video.pause();
  301. // 停止取流
  302. this.flv.unload();
  303. // this.hls.destroy();
  304. }
  305. }
  306. /* eslint-disable valid-jsdoc */
  307. /** insertAfter */
  308. function insertAfter(newElement, targetElement) { var parent = targetElement.parentNode; if (parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } }
  309. class Status {
  310. constructor(jSPlugin,id) {
  311. this.id = id;
  312. this.jSPlugin = jSPlugin;
  313. this.state = {
  314. play: false,
  315. loading: false,
  316. };
  317. }
  318. toString() {
  319. return `${this.coreX}-${this.coreY}`;
  320. }
  321. setPlayStatus(options) {
  322. this.state = Object.assign(this.state, options);
  323. }
  324. loadingStart(id) {
  325. var oS = document.createElement('style');
  326. document.getElementsByTagName("head")[0].appendChild(oS);
  327. oS.innerHTML = '@keyframes antRotate {to {transform: rotate(400deg);transform-origin:50% 50%;}} .loading {display: inline-block;z-index: 1000;-webkit-animation: antRotate 1s infinite linear;animation: antRotate 1s infinite linear;}';
  328. var domId = id;
  329. var domElement = document.getElementById(domId);
  330. var windowWidth = domElement.offsetWidth;
  331. var windowHeight = domElement.offsetHeight;
  332. var offsetTop = 0;//`calc(50% - ${(domElement.offsetTop / 2)}px)`;//domElement.offsetTop; // `calc(50% - ${domElement.offsetTop / 2}px)`
  333. var offsetLeft = domElement.offsetLeft;
  334. // 先执行清空loading
  335. if (document.getElementById(`${id}-loading-id-0`)) {
  336. document.getElementById(`${id}-loading-id-0`).parentNode.removeChild(document.getElementById(`${id}-loading-id-0`));
  337. }
  338. var loadingContainerDOM = document.createElement('div');
  339. loadingContainerDOM.setAttribute('id', `${id}-loading-id-0`);
  340. var style = 'position:absolute;outline:none;pointer-events:none;';
  341. // console.log("this.jSPlugin",this.jSPlugin);
  342. if(typeof this.jSPlugin.poster === 'string') {
  343. style += `background: url(${this.jSPlugin.poster}) no-repeat;background-size: cover;`;
  344. }
  345. style += 'width: 100%;';
  346. style += 'height: 100%;';
  347. style += 'top:' + offsetTop + ';';
  348. style += 'left:' + offsetLeft + 'px;';
  349. loadingContainerDOM.setAttribute('style', style);
  350. loadingContainerDOM.style.height = windowHeight;
  351. loadingContainerDOM.setAttribute('class', 'loading-container');
  352. // loadingContainerDOM.innerHTML= loading;
  353. insertAfter(loadingContainerDOM, domElement);
  354. var splitBasis = 1;
  355. var loadingItemContainer = document.createElement('div');
  356. var loadingStatusDOM = document.createElement('div');
  357. loadingItemContainer.setAttribute('class', 'loading-item');
  358. loadingItemContainer.setAttribute('id', `${id}-loading-item-0`);
  359. //loadingContainer.setAttribute('style','display:inline-flex;flex-direction:column;justify-content:center;align-items: center;width:'+(windowWidth / splitBasis)+'px;height:'+(windowHeight /splitBasis )+'px;outline:none;vertical-align: top;position:absolute');
  360. var style = 'display:inline-flex;pointer-events:none;flex-direction:column;justify-content:center;align-items: center;width:100%;height:' + (windowHeight) + 'px;outline:none;vertical-align: top;position:absolute;';
  361. style += ('left:' + calLoadingPostion(windowHeight, windowWidth, splitBasis, 0).left + 'px;');
  362. style += ('top:' + calLoadingPostion(windowHeight, windowWidth, splitBasis, 0).top + 'px;');
  363. loadingItemContainer.setAttribute('style', style);
  364. function calLoadingPostion(windowHeight, windowWidth, splitBasis, i) {
  365. var top = parseInt(i / splitBasis, 10) * (windowHeight / splitBasis);
  366. var left = (i % splitBasis) * (windowWidth / splitBasis);
  367. return {
  368. top: top,
  369. left: left
  370. };
  371. }
  372. var loadingDOM = document.createElement('div');
  373. loadingStatusDOM.innerHTML = "";
  374. loadingStatusDOM.style.color = "#fff";
  375. loadingDOM.setAttribute('class', 'loading');
  376. var loading = '<svg t="1567069979438" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2399" width="32" height="32"><path d="M538.5344 266.4448a133.12 133.12 0 1 1 133.12-133.12 133.4272 133.4272 0 0 1-133.12 133.12zM255.0144 372.1984a121.6768 121.6768 0 1 1 121.6768-121.6768 121.856 121.856 0 0 1-121.6768 121.6768zM134.72 647.424a107.3664 107.3664 0 1 1 107.3664-107.264A107.52 107.52 0 0 1 134.72 647.424z m120.32 272.4608a90.9824 90.9824 0 1 1 90.9824-90.9824A91.1616 91.1616 0 0 1 255.04 919.8848zM538.5344 1024a79.36 79.36 0 1 1 79.36-79.36 79.36 79.36 0 0 1-79.36 79.36z m287.6928-134.144a64.1792 64.1792 0 1 1 64.1792-64.1792 64.3584 64.3584 0 0 1-64.1792 64.1792z m117.76-296.704a52.6336 52.6336 0 1 1 52.6592-52.6336 52.608 52.608 0 0 1-52.6336 52.6336z m-158.72-338.7136a40.96 40.96 0 1 1 12.0064 28.8512 40.5248 40.5248 0 0 1-12.0064-28.8512z" fill="#ffffff" p-id="2400"></path></svg>';
  377. loadingDOM.innerHTML = loading;
  378. loadingItemContainer.appendChild(loadingDOM);
  379. // loadingContainer.appendChild(loading);
  380. loadingItemContainer.appendChild(loadingStatusDOM);
  381. loadingContainerDOM.appendChild(loadingItemContainer);
  382. }
  383. loadingSetText(opt) {
  384. this.loadingClearText();
  385. if (document.getElementById(`${this.id}-loading-item-0`)) {
  386. var textElement = document.getElementById(`${this.id}-loading-item-0`).childNodes[1];
  387. if(!textElement) {
  388. var loadingItemContainer = document.getElementById(`${this.id}-loading-item-0`);
  389. textElement = document.createElement('div');
  390. textElement.innerHTML = opt.text;
  391. loadingItemContainer.appendChild(textElement);
  392. }
  393. textElement.innerHTML = opt.text;
  394. textElement.style.color = opt.color || "#FFFFFF";
  395. }
  396. }
  397. loadingClearText() {
  398. var elements = document.getElementById(`${this.id}-loading-item-0`).childNodes;
  399. if(elements.length > 1) {
  400. elements[1].parentNode.removeChild(elements[1]);
  401. }
  402. }
  403. loadingClear() {
  404. var elements = document.getElementById(`${this.id}-loading-item-0`).childNodes;
  405. for (var i = elements.length - 1; i >= 0; i--) {
  406. elements[i].parentNode.removeChild(elements[i]);
  407. }
  408. if(document.getElementById(`${this.id}-loading-id-0`)) {
  409. document.getElementById(`${this.id}-loading-id-0`).style.background = 'none';
  410. }
  411. }
  412. setPoster(pic) {
  413. if(document.getElementById(`${this.id}-loading-id-0`)) {
  414. document.getElementById(`${this.id}-loading-id-0`).style.backgroundImage = `url(${pic})`;
  415. }
  416. }
  417. loadingEnd() {
  418. var loadingItemContainerDOM = document.getElementById(`${this.id}-loading-item-0`);
  419. if (loadingItemContainerDOM) {
  420. loadingItemContainerDOM.parentNode.removeChild(loadingItemContainerDOM);
  421. var loadingContainerDOM = document.getElementById(`${this.id}-loading-id-0`);
  422. if (loadingContainerDOM && loadingContainerDOM.children.length === 0) {
  423. loadingContainerDOM.parentNode.removeChild(loadingContainerDOM);
  424. }
  425. }
  426. document.getElementById(`${this.id}-loading-item-0`).style.background = 'none';
  427. }
  428. }
  429. var data$5 = [
  430. {
  431. moduleCode: "",
  432. detailCode: "405984",
  433. description: "",
  434. solution: "",
  435. updateTime: 1559564188000
  436. },
  437. {
  438. moduleCode: "",
  439. detailCode: "10035",
  440. description: "获取子账户AccessToken异常,子账户不存在或子账户不属于该开发者",
  441. solution: "",
  442. updateTime: 1559551958000
  443. },
  444. {
  445. moduleCode: "",
  446. detailCode: "1052674",
  447. description: "获取本地录像失败",
  448. solution: "",
  449. updateTime: 1558579653000
  450. },
  451. {
  452. moduleCode: "",
  453. detailCode: "395547",
  454. description: "",
  455. solution: "",
  456. updateTime: 1557367296000
  457. },
  458. {
  459. moduleCode: "",
  460. detailCode: "12",
  461. description: "",
  462. solution: "",
  463. updateTime: 1557229476000
  464. },
  465. {
  466. moduleCode: "",
  467. detailCode: "10052",
  468. description: "余额不足",
  469. solution: "",
  470. updateTime: 1557121463000
  471. },
  472. {
  473. moduleCode: "",
  474. detailCode: "20108",
  475. description: "当前用户和所添加用户不是好友关系",
  476. solution: "",
  477. updateTime: 1556541725000
  478. },
  479. {
  480. moduleCode: "",
  481. detailCode: "10009",
  482. description: "",
  483. solution: "",
  484. updateTime: 1556422452000
  485. },
  486. {
  487. moduleCode: "",
  488. detailCode: "320001",
  489. description: "通道不存在",
  490. solution: "请检查录像机的关联状态是否正常,没有摄像头的通道无法播放",
  491. updateTime: 1556419044000
  492. },
  493. {
  494. moduleCode: "",
  495. detailCode: "120001",
  496. description: "通道不存在",
  497. solution: "请检查录像机的关联状态是否正常,没有摄像头的通道无法播放",
  498. updateTime: 1556419030000
  499. },
  500. {
  501. moduleCode: "",
  502. detailCode: "320049",
  503. description: "",
  504. solution: "",
  505. updateTime: 1556272984000
  506. },
  507. {
  508. moduleCode: "",
  509. detailCode: "380227",
  510. description: "",
  511. solution: "",
  512. updateTime: 1556264379000
  513. },
  514. {
  515. moduleCode: "",
  516. detailCode: "10033",
  517. description: "policy参数信息异常",
  518. solution: "",
  519. updateTime: 1555922124000
  520. },
  521. {
  522. moduleCode: "",
  523. detailCode: "10065",
  524. description: "weakAppKey 不属于accessToken对应的用户",
  525. solution: "",
  526. updateTime: 1555497522000
  527. },
  528. {
  529. moduleCode: "",
  530. detailCode: "395416",
  531. description: "设备达到最大连接数,无法建立连接",
  532. solution: "请升级设备固件版本",
  533. updateTime: 1555394722000
  534. },
  535. {
  536. moduleCode: "",
  537. detailCode: "100001",
  538. description: "",
  539. solution: "",
  540. updateTime: 1555141776000
  541. },
  542. {
  543. moduleCode: "",
  544. detailCode: "395558",
  545. description: "",
  546. solution: "",
  547. updateTime: 1554987121000
  548. },
  549. {
  550. moduleCode: "",
  551. detailCode: "70001",
  552. description: "智能家居买断用户设备受到限制,建议合理选择pagestart和pageSize",
  553. solution: "",
  554. updateTime: 1554691023000
  555. },
  556. {
  557. moduleCode: "",
  558. detailCode: "170001",
  559. description: "",
  560. solution: "",
  561. updateTime: 1554691023000
  562. },
  563. {
  564. moduleCode: "",
  565. detailCode: "1012",
  566. description: "重置失败",
  567. solution: "",
  568. updateTime: 1554645841000
  569. },
  570. {
  571. moduleCode: "",
  572. detailCode: "1043",
  573. description: "重置失败",
  574. solution: "",
  575. updateTime: 1554645834000
  576. },
  577. {
  578. moduleCode: "",
  579. detailCode: "60060",
  580. description: "直播功能未开通",
  581. solution: "通道未开通直播功能,请先开通直播",
  582. updateTime: 1554346018000
  583. },
  584. {
  585. moduleCode: "",
  586. detailCode: "380203",
  587. description: "",
  588. solution: "",
  589. updateTime: 1554093666000
  590. },
  591. {
  592. moduleCode: "",
  593. detailCode: "399048",
  594. description: "免费版并发数达到上限,请升级企业版使用多并发能力",
  595. solution: "升级成为企业版套餐即可取消并发数限制",
  596. updateTime: 1553839878000
  597. },
  598. {
  599. moduleCode: "",
  600. detailCode: "60007",
  601. description: "预置点个数超过最大值",
  602. solution: "",
  603. updateTime: 1553671316000
  604. },
  605. {
  606. moduleCode: "",
  607. detailCode: "1005",
  608. description: "",
  609. solution: "",
  610. updateTime: 1553513701000
  611. },
  612. {
  613. moduleCode: "",
  614. detailCode: "20605",
  615. description: "其他用户正在认证中",
  616. solution: "",
  617. updateTime: 1552976317000
  618. },
  619. {
  620. moduleCode: "",
  621. detailCode: "90004",
  622. description: "当前型号设备暂时不支持AI任务:CS-C3W-3B1WFR-YGL",
  623. solution: "",
  624. updateTime: 1552898525000
  625. },
  626. {
  627. moduleCode: "",
  628. detailCode: "60046",
  629. description: "添加的设备的IP和本设备的IP冲突",
  630. solution: "",
  631. updateTime: 1552872372000
  632. },
  633. {
  634. moduleCode: "",
  635. detailCode: "3",
  636. description: "修改视频清晰度失败!",
  637. solution: "",
  638. updateTime: 1552440229000
  639. },
  640. {
  641. moduleCode: "",
  642. detailCode: "1013",
  643. description: "",
  644. solution: "",
  645. updateTime: 1552035069000
  646. },
  647. {
  648. moduleCode: "",
  649. detailCode: "370007",
  650. description: "",
  651. solution: "",
  652. updateTime: 1551852327000
  653. },
  654. {
  655. moduleCode: "",
  656. detailCode: "-1",
  657. description: "",
  658. solution: "",
  659. updateTime: 1551752889000
  660. },
  661. {
  662. moduleCode: "",
  663. detailCode: "30005",
  664. description: "弱账户不存在",
  665. solution: "",
  666. updateTime: 1551422358000
  667. },
  668. {
  669. moduleCode: "",
  670. detailCode: "90006",
  671. description: "用户操作AI任务受限",
  672. solution: "",
  673. updateTime: 1551073320000
  674. },
  675. {
  676. moduleCode: "",
  677. detailCode: "60203",
  678. description: "未开通相关服务",
  679. solution: "",
  680. updateTime: 1550623070000
  681. },
  682. {
  683. moduleCode: "",
  684. detailCode: "10002",
  685. description: "accessToken过期或异常",
  686. solution: "",
  687. updateTime: 1550300346000
  688. },
  689. {
  690. moduleCode: "",
  691. detailCode: "380339",
  692. description: "",
  693. solution: "",
  694. updateTime: 1549889458000
  695. },
  696. {
  697. moduleCode: "",
  698. detailCode: "90002",
  699. description: "AI任务设备配置数达到上限:3",
  700. solution: "",
  701. updateTime: 1549071664000
  702. },
  703. {
  704. moduleCode: "",
  705. detailCode: "380008",
  706. description: "",
  707. solution: "",
  708. updateTime: 1549005979000
  709. },
  710. {
  711. moduleCode: "",
  712. detailCode: "320227",
  713. description: "",
  714. solution: "",
  715. updateTime: 1548739731000
  716. },
  717. {
  718. moduleCode: "",
  719. detailCode: "60059",
  720. description: "ezopen地址均不可用",
  721. solution: "",
  722. updateTime: 1548395350000
  723. },
  724. {
  725. moduleCode: "",
  726. detailCode: "10005",
  727. description: "appKey异常",
  728. solution: "",
  729. updateTime: 1548317858000
  730. },
  731. {
  732. moduleCode: "",
  733. detailCode: "60045",
  734. description: "添加的设备的IP和其他通道的IP冲突",
  735. solution: "",
  736. updateTime: 1548155085000
  737. },
  738. {
  739. moduleCode: "",
  740. detailCode: "60047",
  741. description: "码流类型不支持",
  742. solution: "",
  743. updateTime: 1547962108000
  744. },
  745. {
  746. moduleCode: "",
  747. detailCode: "60041",
  748. description: "添加的设备被其他设备关联或响应超时",
  749. solution: "",
  750. updateTime: 1547960980000
  751. },
  752. {
  753. moduleCode: "",
  754. detailCode: "110029",
  755. description: "个人用户接口调用频率超限",
  756. solution: "请升级企业版:https://open.ys7.com/price.html",
  757. updateTime: 1547606859000
  758. },
  759. {
  760. moduleCode: "",
  761. detailCode: "380355",
  762. description: "设备直连推流异常结束",
  763. solution: "",
  764. updateTime: 1547106294000
  765. },
  766. {
  767. moduleCode: "",
  768. detailCode: "320081",
  769. description: "",
  770. solution: "",
  771. updateTime: 1547106279000
  772. },
  773. {
  774. moduleCode: "",
  775. detailCode: "60035",
  776. description: "购买云存储服务失败",
  777. solution: "",
  778. updateTime: 1547026959000
  779. },
  780. {
  781. moduleCode: "",
  782. detailCode: "90005",
  783. description: "设备已存在:C75714141",
  784. solution: "",
  785. updateTime: 1546940622000
  786. },
  787. {
  788. moduleCode: "",
  789. detailCode: "1053445",
  790. description: "该时间段没有录像片段",
  791. solution: "",
  792. updateTime: 1546935727000
  793. },
  794. {
  795. moduleCode: "",
  796. detailCode: "90007",
  797. description: "设备未加入到AI任务",
  798. solution: "",
  799. updateTime: 1546932948000
  800. },
  801. {
  802. moduleCode: "",
  803. detailCode: "326000",
  804. description: "",
  805. solution: "",
  806. updateTime: 1546823143000
  807. },
  808. {
  809. moduleCode: "",
  810. detailCode: "1021",
  811. description: "重置失败",
  812. solution: "",
  813. updateTime: 1546781152000
  814. },
  815. {
  816. moduleCode: "",
  817. detailCode: "2001",
  818. description: "删除设备失败!",
  819. solution: "",
  820. updateTime: 1546422886000
  821. },
  822. {
  823. moduleCode: "",
  824. detailCode: "380425",
  825. description: "",
  826. solution: "",
  827. updateTime: 1546407694000
  828. },
  829. {
  830. moduleCode: "",
  831. detailCode: "120097",
  832. description: "",
  833. solution: "",
  834. updateTime: 1546085995000
  835. },
  836. {
  837. moduleCode: "",
  838. detailCode: "10059",
  839. description: "requestId已存在",
  840. solution: "",
  841. updateTime: 1545824509000
  842. },
  843. {
  844. moduleCode: "",
  845. detailCode: "1154723",
  846. description: "",
  847. solution: "",
  848. updateTime: 1545795209000
  849. },
  850. {
  851. moduleCode: "",
  852. detailCode: "60043",
  853. description: "添加的设备超出最大数量",
  854. solution: "",
  855. updateTime: 1545493607000
  856. },
  857. {
  858. moduleCode: "",
  859. detailCode: "1152677",
  860. description: "",
  861. solution: "",
  862. updateTime: 1545313404000
  863. },
  864. {
  865. moduleCode: "",
  866. detailCode: "20097",
  867. description: "设备添加异常,设备验证码为ABCDEF或设备被N1,R1关联",
  868. solution: "",
  869. updateTime: 1545310795000
  870. },
  871. {
  872. moduleCode: "",
  873. detailCode: "10060",
  874. description: "设备不支持该云存储类型",
  875. solution: "",
  876. updateTime: 1545309064000
  877. },
  878. {
  879. moduleCode: "",
  880. detailCode: "20102",
  881. description: "无相应邀请信息,无法接受邀请",
  882. solution: "",
  883. updateTime: 1545204966000
  884. },
  885. {
  886. moduleCode: "",
  887. detailCode: "10053",
  888. description: "云存储开通中",
  889. solution: "",
  890. updateTime: 1545100293000
  891. },
  892. {
  893. moduleCode: "",
  894. detailCode: "20401",
  895. description: "用户云空间信息不存在",
  896. solution: "",
  897. updateTime: 1545017880000
  898. },
  899. {
  900. moduleCode: "",
  901. detailCode: "20600",
  902. description: "临时密码数已达上限",
  903. solution: "",
  904. updateTime: 1544873457000
  905. },
  906. {
  907. moduleCode: "",
  908. detailCode: "901",
  909. description: "",
  910. solution: "",
  911. updateTime: 1544693519000
  912. },
  913. {
  914. moduleCode: "",
  915. detailCode: "60210",
  916. description: "图片数据错误",
  917. solution: "",
  918. updateTime: 1544604457000
  919. },
  920. {
  921. moduleCode: "",
  922. detailCode: "10013",
  923. description: "您的应用没有权限调用",
  924. solution: "",
  925. updateTime: 1544416237000
  926. },
  927. {
  928. moduleCode: "",
  929. detailCode: "70007",
  930. description: "授权码不存在",
  931. solution: "",
  932. updateTime: 1544179533000
  933. },
  934. {
  935. moduleCode: "",
  936. detailCode: "10015",
  937. description: "授权地址不存在",
  938. solution: "",
  939. updateTime: 1544163240000
  940. },
  941. {
  942. moduleCode: "",
  943. detailCode: "320423",
  944. description: "",
  945. solution: "",
  946. updateTime: 1544100685000
  947. },
  948. {
  949. moduleCode: "",
  950. detailCode: "370009",
  951. description: "",
  952. solution: "",
  953. updateTime: 1544077151000
  954. },
  955. {
  956. moduleCode: "",
  957. detailCode: "10031",
  958. description: "子账户或萤石用户没有权限",
  959. solution: "",
  960. updateTime: 1543990462000
  961. },
  962. {
  963. moduleCode: "",
  964. detailCode: "10055",
  965. description: "设备不支持试用云存储服务",
  966. solution: "",
  967. updateTime: 1543986292000
  968. },
  969. {
  970. moduleCode: "",
  971. detailCode: "60042",
  972. description: "添加的设备密码错误",
  973. solution: "",
  974. updateTime: 1543710913000
  975. },
  976. {
  977. moduleCode: "",
  978. detailCode: "60082",
  979. description: "设备正在响应本次声源定位",
  980. solution: "",
  981. updateTime: 1543647426000
  982. },
  983. {
  984. moduleCode: "",
  985. detailCode: "10056",
  986. description: "设备不支持云存储服务转出",
  987. solution: "",
  988. updateTime: 1543558342000
  989. },
  990. {
  991. moduleCode: "",
  992. detailCode: "20104",
  993. description: "好友不存在",
  994. solution: "",
  995. updateTime: 1543492403000
  996. },
  997. {
  998. moduleCode: "",
  999. detailCode: "20111",
  1000. description: "好友不是等待验证状态,无法接受邀请",
  1001. solution: "",
  1002. updateTime: 1543492365000
  1003. },
  1004. {
  1005. moduleCode: "",
  1006. detailCode: "20107",
  1007. description: "不能添加自己为好友",
  1008. solution: "",
  1009. updateTime: 1543480986000
  1010. },
  1011. {
  1012. moduleCode: "",
  1013. detailCode: "1",
  1014. description: "设备返回其他错误",
  1015. solution: "",
  1016. updateTime: 1543459921000
  1017. },
  1018. {
  1019. moduleCode: "",
  1020. detailCode: "60084",
  1021. description: "当前正在关闭隐私遮蔽",
  1022. solution: "",
  1023. updateTime: 1543456515000
  1024. },
  1025. {
  1026. moduleCode: "",
  1027. detailCode: "380255",
  1028. description: "",
  1029. solution: "",
  1030. updateTime: 1543411652000
  1031. },
  1032. {
  1033. moduleCode: "",
  1034. detailCode: "20015",
  1035. description: "设备不支持",
  1036. solution: "",
  1037. updateTime: 1543390936000
  1038. },
  1039. {
  1040. moduleCode: "",
  1041. detailCode: "30003",
  1042. description: "手机验证码错误",
  1043. solution: "",
  1044. updateTime: 1543389137000
  1045. },
  1046. {
  1047. moduleCode: "",
  1048. detailCode: "20615",
  1049. description: "锁用户已存在",
  1050. solution: "",
  1051. updateTime: 1543388325000
  1052. },
  1053. {
  1054. moduleCode: "",
  1055. detailCode: "60061",
  1056. description: "账户流量已超出或未购买,限制开通",
  1057. solution: "",
  1058. updateTime: 1543372581000
  1059. },
  1060. {
  1061. moduleCode: "",
  1062. detailCode: "60020",
  1063. description: "设备不支持该信令",
  1064. solution: "",
  1065. updateTime: 1543321636000
  1066. },
  1067. {
  1068. moduleCode: "",
  1069. detailCode: "320146",
  1070. description: "",
  1071. solution: "",
  1072. updateTime: 1543318472000
  1073. },
  1074. {
  1075. moduleCode: "",
  1076. detailCode: "60018",
  1077. description: "设备升级失败",
  1078. solution: "",
  1079. updateTime: 1543304928000
  1080. },
  1081. {
  1082. moduleCode: "",
  1083. detailCode: "60044",
  1084. description: "添加的设备网络不可达超时",
  1085. solution: "",
  1086. updateTime: 1543304102000
  1087. },
  1088. {
  1089. moduleCode: "",
  1090. detailCode: "20619",
  1091. description: "主用户无法删除",
  1092. solution: "",
  1093. updateTime: 1543290219000
  1094. },
  1095. {
  1096. moduleCode: "",
  1097. detailCode: "20608",
  1098. description: "锁用户不存在",
  1099. solution: "",
  1100. updateTime: 1543281950000
  1101. },
  1102. {
  1103. moduleCode: "",
  1104. detailCode: "20609",
  1105. description: "设备响应超时,门锁通信故障或者电量不足,请重试.",
  1106. solution: "",
  1107. updateTime: 1543281601000
  1108. },
  1109. {
  1110. moduleCode: "",
  1111. detailCode: "1049954",
  1112. description: "升级设备失败",
  1113. solution: "",
  1114. updateTime: 1543279264000
  1115. },
  1116. {
  1117. moduleCode: "",
  1118. detailCode: "60009",
  1119. description: "正在调用预置点",
  1120. solution: "",
  1121. updateTime: 1543238114000
  1122. },
  1123. {
  1124. moduleCode: "",
  1125. detailCode: "1052677",
  1126. description: "获取本地录像失败",
  1127. solution: "",
  1128. updateTime: 1543207604000
  1129. },
  1130. {
  1131. moduleCode: "",
  1132. detailCode: "327000",
  1133. description: "",
  1134. solution: "",
  1135. updateTime: 1543196609000
  1136. },
  1137. {
  1138. moduleCode: "",
  1139. detailCode: "20021",
  1140. description: "设备在线,未被用户添加",
  1141. solution: "",
  1142. updateTime: 1543193436000
  1143. },
  1144. {
  1145. moduleCode: "",
  1146. detailCode: "20202",
  1147. description: "操作留言信息失败",
  1148. solution: "",
  1149. updateTime: 1543191562000
  1150. },
  1151. {
  1152. moduleCode: "",
  1153. detailCode: "1052678",
  1154. description: "获取本地录像失败",
  1155. solution: "",
  1156. updateTime: 1543132218000
  1157. },
  1158. {
  1159. moduleCode: "",
  1160. detailCode: "1054723",
  1161. description: "格式化设备失败",
  1162. solution: "",
  1163. updateTime: 1543129833000
  1164. },
  1165. {
  1166. moduleCode: "",
  1167. detailCode: "20109",
  1168. description: "对应分享不存在",
  1169. solution: "",
  1170. updateTime: 1543129111000
  1171. },
  1172. {
  1173. moduleCode: "",
  1174. detailCode: "60026",
  1175. description: "设备处于隐私遮蔽状态",
  1176. solution: "",
  1177. updateTime: 1543110403000
  1178. },
  1179. {
  1180. moduleCode: "",
  1181. detailCode: "60083",
  1182. description: "当前正在开启隐私遮蔽",
  1183. solution: "",
  1184. updateTime: 1543071148000
  1185. },
  1186. {
  1187. moduleCode: "",
  1188. detailCode: "60001",
  1189. description: "用户无云台控制权限",
  1190. solution: "",
  1191. updateTime: 1543059167000
  1192. },
  1193. {
  1194. moduleCode: "",
  1195. detailCode: "2003",
  1196. description: "设备不在线",
  1197. solution: "",
  1198. updateTime: 1543051046000
  1199. },
  1200. {
  1201. moduleCode: "",
  1202. detailCode: "-24",
  1203. description: "设置设备enable错误",
  1204. solution: "",
  1205. updateTime: 1543042701000
  1206. },
  1207. {
  1208. moduleCode: "",
  1209. detailCode: "10018",
  1210. description: "",
  1211. solution: "",
  1212. updateTime: 1543041564000
  1213. },
  1214. {
  1215. moduleCode: "",
  1216. detailCode: "20103",
  1217. description: "好友已存在",
  1218. solution: "",
  1219. updateTime: 1543038430000
  1220. },
  1221. {
  1222. moduleCode: "",
  1223. detailCode: "70010",
  1224. description: "授权异常请重试",
  1225. solution: "",
  1226. updateTime: 1543035590000
  1227. },
  1228. {
  1229. moduleCode: "",
  1230. detailCode: "60056",
  1231. description: "删除设备失败",
  1232. solution: "",
  1233. updateTime: 1543031275000
  1234. },
  1235. {
  1236. moduleCode: "",
  1237. detailCode: "60040",
  1238. description: "添加的设备不在同一局域网",
  1239. solution: "",
  1240. updateTime: 1543031210000
  1241. },
  1242. {
  1243. moduleCode: "",
  1244. detailCode: "60019",
  1245. description: "加密已开启",
  1246. solution: "",
  1247. updateTime: 1543029931000
  1248. },
  1249. {
  1250. moduleCode: "",
  1251. detailCode: "1054722",
  1252. description: "格式化设备失败",
  1253. solution: "",
  1254. updateTime: 1543028537000
  1255. },
  1256. {
  1257. moduleCode: "",
  1258. detailCode: "20016",
  1259. description: "当前设备正在格式化",
  1260. solution: "",
  1261. updateTime: 1543028537000
  1262. },
  1263. {
  1264. moduleCode: "",
  1265. detailCode: "10024",
  1266. description: "透明通道权限校验不通过",
  1267. solution: "",
  1268. updateTime: 1543025540000
  1269. },
  1270. {
  1271. moduleCode: "",
  1272. detailCode: "6002",
  1273. description: "删除设备失败!",
  1274. solution: "",
  1275. updateTime: 1543025026000
  1276. },
  1277. {
  1278. moduleCode: "",
  1279. detailCode: "1011",
  1280. description: "验证码错误!",
  1281. solution: "",
  1282. updateTime: 1543016865000
  1283. },
  1284. {
  1285. moduleCode: "",
  1286. detailCode: "60032",
  1287. description: "卡密已使用",
  1288. solution: "",
  1289. updateTime: 1543006668000
  1290. },
  1291. {
  1292. moduleCode: "",
  1293. detailCode: "10034",
  1294. description: "子账号已存在",
  1295. solution: "",
  1296. updateTime: 1542989194000
  1297. },
  1298. {
  1299. moduleCode: "",
  1300. detailCode: "20301",
  1301. description: "根据uuid查询联动信息不存在",
  1302. solution: "",
  1303. updateTime: 1542988651000
  1304. },
  1305. {
  1306. moduleCode: "",
  1307. detailCode: "1041",
  1308. description: "获取验证码过于频繁",
  1309. solution: "",
  1310. updateTime: 1542980953000
  1311. },
  1312. {
  1313. moduleCode: "",
  1314. detailCode: "10012",
  1315. description: "该appkey下已绑定重复的phone!",
  1316. solution: "",
  1317. updateTime: 1542980800000
  1318. },
  1319. {
  1320. moduleCode: "",
  1321. detailCode: "1008",
  1322. description: "phone不合法!",
  1323. solution: "",
  1324. updateTime: 1542979812000
  1325. },
  1326. {
  1327. moduleCode: "",
  1328. detailCode: "60023",
  1329. description: "订阅操作失败",
  1330. solution: "",
  1331. updateTime: 1542979006000
  1332. },
  1333. {
  1334. moduleCode: "",
  1335. detailCode: "5",
  1336. description: "设备返回其他错误",
  1337. solution: "",
  1338. updateTime: 1542977828000
  1339. },
  1340. {
  1341. moduleCode: "",
  1342. detailCode: "60006",
  1343. description: "云台当前操作失败",
  1344. solution: "",
  1345. updateTime: 1542977598000
  1346. },
  1347. {
  1348. moduleCode: "",
  1349. detailCode: "131",
  1350. description: "修改视频清晰度失败!",
  1351. solution: "",
  1352. updateTime: 1542977246000
  1353. },
  1354. {
  1355. moduleCode: "",
  1356. detailCode: "10019",
  1357. description: "密码错误",
  1358. solution: "",
  1359. updateTime: 1542976628000
  1360. },
  1361. {
  1362. moduleCode: "",
  1363. detailCode: "10004",
  1364. description: "用户不存在",
  1365. solution: "",
  1366. updateTime: 1542976268000
  1367. },
  1368. {
  1369. moduleCode: "",
  1370. detailCode: "20201",
  1371. description: "操作报警信息失败",
  1372. solution: "",
  1373. updateTime: 1542975906000
  1374. },
  1375. {
  1376. moduleCode: "",
  1377. detailCode: "20024",
  1378. description: "设备不在线,已经被别的用户添加",
  1379. solution: "",
  1380. updateTime: 1542975858000
  1381. },
  1382. {
  1383. moduleCode: "",
  1384. detailCode: "60004",
  1385. description: "设备云台旋转达到左限位",
  1386. solution: "",
  1387. updateTime: 1542975207000
  1388. },
  1389. {
  1390. moduleCode: "",
  1391. detailCode: "1052679",
  1392. description: "修改视频清晰度失败!",
  1393. solution: "",
  1394. updateTime: 1542974886000
  1395. },
  1396. {
  1397. moduleCode: "",
  1398. detailCode: "20031",
  1399. description: "请在萤石客户端关闭终端绑定",
  1400. solution: "",
  1401. updateTime: 1542974756000
  1402. },
  1403. {
  1404. moduleCode: "",
  1405. detailCode: "1053825",
  1406. description: "获取本地录像失败",
  1407. solution: "",
  1408. updateTime: 1542974692000
  1409. },
  1410. {
  1411. moduleCode: "",
  1412. detailCode: "60011",
  1413. description: "预置点不存在",
  1414. solution: "",
  1415. updateTime: 1542974414000
  1416. },
  1417. {
  1418. moduleCode: "",
  1419. detailCode: "1052936",
  1420. description: "修改视频清晰度失败!",
  1421. solution: "",
  1422. updateTime: 1542974390000
  1423. },
  1424. {
  1425. moduleCode: "",
  1426. detailCode: "1016",
  1427. description: "",
  1428. solution: "",
  1429. updateTime: 1542974273000
  1430. },
  1431. {
  1432. moduleCode: "",
  1433. detailCode: "10032",
  1434. description: "子账号不存在",
  1435. solution: "",
  1436. updateTime: 1542973906000
  1437. },
  1438. {
  1439. moduleCode: "",
  1440. detailCode: "20013",
  1441. description: "设备已被别人添加",
  1442. solution: "",
  1443. updateTime: 1542973817000
  1444. },
  1445. {
  1446. moduleCode: "",
  1447. detailCode: "50000",
  1448. description: "服务器错误!",
  1449. solution: "",
  1450. updateTime: 1542973801000
  1451. },
  1452. {
  1453. moduleCode: "",
  1454. detailCode: "60010",
  1455. description: "该预置点已经是当前位置",
  1456. solution: "",
  1457. updateTime: 1542973800000
  1458. },
  1459. {
  1460. moduleCode: "",
  1461. detailCode: "60003",
  1462. description: "设备云台旋转达到下限位",
  1463. solution: "",
  1464. updateTime: 1542973770000
  1465. },
  1466. {
  1467. moduleCode: "",
  1468. detailCode: "4",
  1469. description: "设备返回其他错误",
  1470. solution: "",
  1471. updateTime: 1542973755000
  1472. },
  1473. {
  1474. moduleCode: "",
  1475. detailCode: "60016",
  1476. description: "加密未开启,无需关闭",
  1477. solution: "",
  1478. updateTime: 1542973753000
  1479. },
  1480. {
  1481. moduleCode: "",
  1482. detailCode: "60002",
  1483. description: "设备云台旋转达到上限位",
  1484. solution: "",
  1485. updateTime: 1542973742000
  1486. },
  1487. {
  1488. moduleCode: "",
  1489. detailCode: "20023",
  1490. description: "设备不在线,未被用户添加",
  1491. solution: "",
  1492. updateTime: 1542973685000
  1493. },
  1494. {
  1495. moduleCode: "",
  1496. detailCode: "10008",
  1497. description: "",
  1498. solution: "",
  1499. updateTime: 1542973676000
  1500. },
  1501. {
  1502. moduleCode: "",
  1503. detailCode: "20010",
  1504. description: "设备验证码错误",
  1505. solution: "",
  1506. updateTime: 1542973658000
  1507. },
  1508. {
  1509. moduleCode: "",
  1510. detailCode: "60005",
  1511. description: "设备云台旋转达到右限位",
  1512. solution: "",
  1513. updateTime: 1542973657000
  1514. },
  1515. {
  1516. moduleCode: "",
  1517. detailCode: "20017",
  1518. description: "设备已经被自己添加",
  1519. solution: "",
  1520. updateTime: 1542973648000
  1521. },
  1522. {
  1523. moduleCode: "",
  1524. detailCode: "20020",
  1525. description: "设备在线,已经被自己添加",
  1526. solution: "",
  1527. updateTime: 1542973533000
  1528. },
  1529. {
  1530. moduleCode: "",
  1531. detailCode: "20029",
  1532. description: "设备不在线,已经被自己添加",
  1533. solution: "",
  1534. updateTime: 1542973530000
  1535. },
  1536. {
  1537. moduleCode: "",
  1538. detailCode: "10014",
  1539. description: "APPKEY下对应的第三方userId和phone未绑定!",
  1540. solution: "",
  1541. updateTime: 1542973499000
  1542. },
  1543. {
  1544. moduleCode: "",
  1545. detailCode: "20002",
  1546. description: "设备不存在",
  1547. solution: "",
  1548. updateTime: 1542973499000
  1549. },
  1550. {
  1551. moduleCode: "",
  1552. detailCode: "10030",
  1553. description: "appkey和appsecret不匹配",
  1554. solution: "",
  1555. updateTime: 1542973490000
  1556. },
  1557. {
  1558. moduleCode: "",
  1559. detailCode: "20022",
  1560. description: "设备在线,已经被别的用户添加",
  1561. solution: "",
  1562. updateTime: 1542973486000
  1563. },
  1564. {
  1565. moduleCode: "",
  1566. detailCode: "20008",
  1567. description: "设备响应超时",
  1568. solution: "",
  1569. updateTime: 1542973484000
  1570. },
  1571. {
  1572. moduleCode: "",
  1573. detailCode: "20032",
  1574. description: "该用户下通道不存在",
  1575. solution: "",
  1576. updateTime: 1542973481000
  1577. },
  1578. {
  1579. moduleCode: "",
  1580. detailCode: "20006",
  1581. description: "网络异常",
  1582. solution: "",
  1583. updateTime: 1542973475000
  1584. },
  1585. {
  1586. moduleCode: "",
  1587. detailCode: "20014",
  1588. description: "deviceSerial不合法!",
  1589. solution: "",
  1590. updateTime: 1542973454000
  1591. },
  1592. {
  1593. moduleCode: "",
  1594. detailCode: "20007",
  1595. description: "设备不在线",
  1596. solution: "",
  1597. updateTime: 1542973454000
  1598. },
  1599. {
  1600. moduleCode: "",
  1601. detailCode: "20018",
  1602. description: "该用户不拥有该设备",
  1603. solution: "",
  1604. updateTime: 1542973453000
  1605. },
  1606. {
  1607. moduleCode: "",
  1608. detailCode: "10010",
  1609. description: "",
  1610. solution: "",
  1611. updateTime: 1542973453000
  1612. },
  1613. {
  1614. moduleCode: "",
  1615. detailCode: "10011",
  1616. description: "未绑定!",
  1617. solution: "",
  1618. updateTime: 1542973453000
  1619. },
  1620. {
  1621. moduleCode: "",
  1622. detailCode: "20001",
  1623. description: "通道不存在!",
  1624. solution: "",
  1625. updateTime: 1542973452000
  1626. },
  1627. {
  1628. moduleCode: "",
  1629. detailCode: "10017",
  1630. description: "appKey不存在",
  1631. solution: "",
  1632. updateTime: 1542973451000
  1633. },
  1634. {
  1635. moduleCode: "",
  1636. detailCode: "400259",
  1637. description: "",
  1638. solution: "",
  1639. updateTime: 1542875643000
  1640. },
  1641. {
  1642. moduleCode: "",
  1643. detailCode: "400004",
  1644. description: "",
  1645. solution: "",
  1646. updateTime: 1542873364000
  1647. },
  1648. {
  1649. moduleCode: "",
  1650. detailCode: "3840",
  1651. description: "",
  1652. solution: "",
  1653. updateTime: 1541860000000
  1654. },
  1655. {
  1656. moduleCode: "",
  1657. detailCode: "-1017",
  1658. description: "",
  1659. solution: "",
  1660. updateTime: 1541733663000
  1661. },
  1662. {
  1663. moduleCode: "",
  1664. detailCode: "320025",
  1665. description: "",
  1666. solution: "",
  1667. updateTime: 1541078281000
  1668. },
  1669. {
  1670. moduleCode: "",
  1671. detailCode: "320024",
  1672. description: "",
  1673. solution: "",
  1674. updateTime: 1540801374000
  1675. },
  1676. {
  1677. moduleCode: "",
  1678. detailCode: "321002",
  1679. description: "",
  1680. solution: "",
  1681. updateTime: 1540631734000
  1682. },
  1683. {
  1684. moduleCode: "",
  1685. detailCode: "321000",
  1686. description: "",
  1687. solution: "",
  1688. updateTime: 1540609178000
  1689. },
  1690. {
  1691. moduleCode: "",
  1692. detailCode: "321022",
  1693. description: "",
  1694. solution: "",
  1695. updateTime: 1540548345000
  1696. },
  1697. {
  1698. moduleCode: "",
  1699. detailCode: "321016",
  1700. description: "",
  1701. solution: "",
  1702. updateTime: 1540287187000
  1703. },
  1704. {
  1705. moduleCode: "",
  1706. detailCode: "320023",
  1707. description: "",
  1708. solution: "",
  1709. updateTime: 1539825993000
  1710. },
  1711. {
  1712. moduleCode: "",
  1713. detailCode: "-1016",
  1714. description: "",
  1715. solution: "",
  1716. updateTime: 1539584931000
  1717. },
  1718. {
  1719. moduleCode: "",
  1720. detailCode: "8",
  1721. description: "",
  1722. solution: "",
  1723. updateTime: 1539391812000
  1724. },
  1725. {
  1726. moduleCode: "",
  1727. detailCode: "1075127593",
  1728. description: "",
  1729. solution: "",
  1730. updateTime: 1538959251000
  1731. },
  1732. {
  1733. moduleCode: "",
  1734. detailCode: "380421",
  1735. description: "",
  1736. solution: "",
  1737. updateTime: 1537288465000
  1738. },
  1739. {
  1740. moduleCode: "",
  1741. detailCode: "322000",
  1742. description: "麦克风权限未开启",
  1743. solution: "",
  1744. updateTime: 1536820136000
  1745. },
  1746. {
  1747. moduleCode: "",
  1748. detailCode: "1152678",
  1749. description: "",
  1750. solution: "",
  1751. updateTime: 1536738348000
  1752. },
  1753. {
  1754. moduleCode: "",
  1755. detailCode: "320047",
  1756. description: "",
  1757. solution: "",
  1758. updateTime: 1536664472000
  1759. },
  1760. {
  1761. moduleCode: "",
  1762. detailCode: "327006",
  1763. description: "",
  1764. solution: "",
  1765. updateTime: 1536136120000
  1766. },
  1767. {
  1768. moduleCode: "",
  1769. detailCode: "1074807593",
  1770. description: "",
  1771. solution: "",
  1772. updateTime: 1536135035000
  1773. },
  1774. {
  1775. moduleCode: "",
  1776. detailCode: "320291",
  1777. description: "",
  1778. solution: "",
  1779. updateTime: 1536110836000
  1780. },
  1781. {
  1782. moduleCode: "",
  1783. detailCode: "320045",
  1784. description: "",
  1785. solution: "",
  1786. updateTime: 1535963775000
  1787. },
  1788. {
  1789. moduleCode: "",
  1790. detailCode: "370004",
  1791. description: "",
  1792. solution: "",
  1793. updateTime: 1535883699000
  1794. },
  1795. {
  1796. moduleCode: "",
  1797. detailCode: "1149954",
  1798. description: "",
  1799. solution: "",
  1800. updateTime: 1535700674000
  1801. },
  1802. {
  1803. moduleCode: "",
  1804. detailCode: "320053",
  1805. description: "",
  1806. solution: "",
  1807. updateTime: 1535681079000
  1808. },
  1809. {
  1810. moduleCode: "",
  1811. detailCode: "400000",
  1812. description: "",
  1813. solution: "",
  1814. updateTime: 1535532332000
  1815. },
  1816. {
  1817. moduleCode: "",
  1818. detailCode: "110028",
  1819. description: "个人版抓图接口日调用次数超出限制",
  1820. solution: "请升级企业版:https://open.ys7.com/price.html",
  1821. updateTime: 1535348756000
  1822. },
  1823. {
  1824. moduleCode: "",
  1825. detailCode: "110027",
  1826. description: "个人版帐号数量超出安全限制,无法调用",
  1827. solution: "请升级企业版:https://open.ys7.com/price.html",
  1828. updateTime: 1535348734000
  1829. },
  1830. {
  1831. moduleCode: "",
  1832. detailCode: "110026",
  1833. description: "设备数量超出个人版限制,当前设备无法操作",
  1834. solution: "请升级企业版:https://open.ys7.com/price.html",
  1835. updateTime: 1535348588000
  1836. },
  1837. {
  1838. moduleCode: "",
  1839. detailCode: "100000",
  1840. description: "",
  1841. solution: "",
  1842. updateTime: 1534980008000
  1843. },
  1844. {
  1845. moduleCode: "",
  1846. detailCode: "324004",
  1847. description: "",
  1848. solution: "",
  1849. updateTime: 1534927762000
  1850. },
  1851. {
  1852. moduleCode: "",
  1853. detailCode: "360104",
  1854. description: "",
  1855. solution: "",
  1856. updateTime: 1534761006000
  1857. },
  1858. {
  1859. moduleCode: "",
  1860. detailCode: "320204",
  1861. description: "",
  1862. solution: "",
  1863. updateTime: 1534584221000
  1864. },
  1865. {
  1866. moduleCode: "",
  1867. detailCode: "380001",
  1868. description: "",
  1869. solution: "",
  1870. updateTime: 1534404715000
  1871. },
  1872. {
  1873. moduleCode: "",
  1874. detailCode: "380204",
  1875. description: "",
  1876. solution: "",
  1877. updateTime: 1534401682000
  1878. },
  1879. {
  1880. moduleCode: "",
  1881. detailCode: "328006",
  1882. description: "",
  1883. solution: "",
  1884. updateTime: 1534144407000
  1885. },
  1886. {
  1887. moduleCode: "",
  1888. detailCode: "321703",
  1889. description: "",
  1890. solution: "",
  1891. updateTime: 1534127274000
  1892. },
  1893. {
  1894. moduleCode: "",
  1895. detailCode: "321510",
  1896. description: "",
  1897. solution: "",
  1898. updateTime: 1533428892000
  1899. },
  1900. {
  1901. moduleCode: "",
  1902. detailCode: "321006",
  1903. description: "",
  1904. solution: "",
  1905. updateTime: 1533036916000
  1906. },
  1907. {
  1908. moduleCode: "",
  1909. detailCode: "50009",
  1910. description: "",
  1911. solution: "",
  1912. updateTime: 1532078548000
  1913. },
  1914. {
  1915. moduleCode: "",
  1916. detailCode: "50007",
  1917. description: "",
  1918. solution: "",
  1919. updateTime: 1531991720000
  1920. },
  1921. {
  1922. moduleCode: "",
  1923. detailCode: "50018",
  1924. description: "",
  1925. solution: "",
  1926. updateTime: 1531912829000
  1927. },
  1928. {
  1929. moduleCode: "",
  1930. detailCode: "380451",
  1931. description: "",
  1932. solution: "",
  1933. updateTime: 1531615700000
  1934. },
  1935. {
  1936. moduleCode: "",
  1937. detailCode: "380336",
  1938. description: "",
  1939. solution: "",
  1940. updateTime: 1531231721000
  1941. },
  1942. {
  1943. moduleCode: "",
  1944. detailCode: "360020",
  1945. description: "",
  1946. solution: "",
  1947. updateTime: 1531117554000
  1948. },
  1949. {
  1950. moduleCode: "",
  1951. detailCode: "380418",
  1952. description: "",
  1953. solution: "",
  1954. updateTime: 1531107070000
  1955. },
  1956. {
  1957. moduleCode: "",
  1958. detailCode: "1153445",
  1959. description: "设备在该时间段内没有录像",
  1960. solution: "",
  1961. updateTime: 1530944007000
  1962. },
  1963. {
  1964. moduleCode: "",
  1965. detailCode: "110007",
  1966. description: "调用接口总次数达到上限",
  1967. solution: "请升级企业版,获取更高能力",
  1968. updateTime: 1530935584000
  1969. },
  1970. {
  1971. moduleCode: "",
  1972. detailCode: "360019",
  1973. description: "",
  1974. solution: "",
  1975. updateTime: 1530869771000
  1976. },
  1977. {
  1978. moduleCode: "",
  1979. detailCode: "360100",
  1980. description: "",
  1981. solution: "",
  1982. updateTime: 1530786188000
  1983. },
  1984. {
  1985. moduleCode: "",
  1986. detailCode: "380042",
  1987. description: "",
  1988. solution: "",
  1989. updateTime: 1530775199000
  1990. },
  1991. {
  1992. moduleCode: "",
  1993. detailCode: "320355",
  1994. description: "",
  1995. solution: "",
  1996. updateTime: 1530716074000
  1997. },
  1998. {
  1999. moduleCode: "",
  2000. detailCode: "100003",
  2001. description: "",
  2002. solution: "",
  2003. updateTime: 1530232541000
  2004. },
  2005. {
  2006. moduleCode: "",
  2007. detailCode: "371026",
  2008. description: "",
  2009. solution: "",
  2010. updateTime: 1530192600000
  2011. },
  2012. {
  2013. moduleCode: "",
  2014. detailCode: "102",
  2015. description: "",
  2016. solution: "",
  2017. updateTime: 1529895641000
  2018. },
  2019. {
  2020. moduleCode: "",
  2021. detailCode: "380201",
  2022. description: "",
  2023. solution: "",
  2024. updateTime: 1529740929000
  2025. },
  2026. {
  2027. moduleCode: "",
  2028. detailCode: "320054",
  2029. description: "",
  2030. solution: "",
  2031. updateTime: 1529544875000
  2032. },
  2033. {
  2034. moduleCode: "",
  2035. detailCode: "500101",
  2036. description: "",
  2037. solution: "",
  2038. updateTime: 1529485953000
  2039. },
  2040. {
  2041. moduleCode: "",
  2042. detailCode: "321001",
  2043. description: "",
  2044. solution: "",
  2045. updateTime: 1529411048000
  2046. },
  2047. {
  2048. moduleCode: "",
  2049. detailCode: "321508",
  2050. description: "",
  2051. solution: "",
  2052. updateTime: 1529393279000
  2053. },
  2054. {
  2055. moduleCode: "",
  2056. detailCode: "405991",
  2057. description: "",
  2058. solution: "",
  2059. updateTime: 1529380238000
  2060. },
  2061. {
  2062. moduleCode: "",
  2063. detailCode: "380461",
  2064. description: "",
  2065. solution: "",
  2066. updateTime: 1529130941000
  2067. },
  2068. {
  2069. moduleCode: "",
  2070. detailCode: "-1019",
  2071. description: "",
  2072. solution: "",
  2073. updateTime: 1529057245000
  2074. },
  2075. {
  2076. moduleCode: "",
  2077. detailCode: "322009",
  2078. description: "",
  2079. solution: "",
  2080. updateTime: 1528965717000
  2081. },
  2082. {
  2083. moduleCode: "",
  2084. detailCode: "324005",
  2085. description: "",
  2086. solution: "",
  2087. updateTime: 1528950153000
  2088. },
  2089. {
  2090. moduleCode: "",
  2091. detailCode: "325000",
  2092. description: "",
  2093. solution: "",
  2094. updateTime: 1528947143000
  2095. },
  2096. {
  2097. moduleCode: "",
  2098. detailCode: "326032",
  2099. description: "",
  2100. solution: "",
  2101. updateTime: 1528872971000
  2102. },
  2103. {
  2104. moduleCode: "",
  2105. detailCode: "325032",
  2106. description: "",
  2107. solution: "",
  2108. updateTime: 1528863189000
  2109. },
  2110. {
  2111. moduleCode: "",
  2112. detailCode: "328000",
  2113. description: "",
  2114. solution: "",
  2115. updateTime: 1528794505000
  2116. },
  2117. {
  2118. moduleCode: "",
  2119. detailCode: "53",
  2120. description: "",
  2121. solution: "",
  2122. updateTime: 1528693249000
  2123. },
  2124. {
  2125. moduleCode: "",
  2126. detailCode: "-1020",
  2127. description: "",
  2128. solution: "",
  2129. updateTime: 1528499440000
  2130. },
  2131. {
  2132. moduleCode: "",
  2133. detailCode: "329032",
  2134. description: "",
  2135. solution: "",
  2136. updateTime: 1528446301000
  2137. },
  2138. {
  2139. moduleCode: "",
  2140. detailCode: "-1202",
  2141. description: "",
  2142. solution: "",
  2143. updateTime: 1528439820000
  2144. },
  2145. {
  2146. moduleCode: "",
  2147. detailCode: "2",
  2148. description: "",
  2149. solution: "",
  2150. updateTime: 1528434175000
  2151. },
  2152. {
  2153. moduleCode: "",
  2154. detailCode: "1152936",
  2155. description: "",
  2156. solution: "",
  2157. updateTime: 1528345986000
  2158. },
  2159. {
  2160. moduleCode: "",
  2161. detailCode: "328011",
  2162. description: "",
  2163. solution: "",
  2164. updateTime: 1528338600000
  2165. },
  2166. {
  2167. moduleCode: "",
  2168. detailCode: "28",
  2169. description: "",
  2170. solution: "",
  2171. updateTime: 1528337530000
  2172. },
  2173. {
  2174. moduleCode: "",
  2175. detailCode: "320356",
  2176. description: "",
  2177. solution: "",
  2178. updateTime: 1528188693000
  2179. },
  2180. {
  2181. moduleCode: "",
  2182. detailCode: "320357",
  2183. description: "",
  2184. solution: "",
  2185. updateTime: 1528188517000
  2186. },
  2187. {
  2188. moduleCode: "",
  2189. detailCode: "405800",
  2190. description: "",
  2191. solution: "",
  2192. updateTime: 1528168732000
  2193. },
  2194. {
  2195. moduleCode: "",
  2196. detailCode: "405996",
  2197. description: "",
  2198. solution: "",
  2199. updateTime: 1528168686000
  2200. },
  2201. {
  2202. moduleCode: "",
  2203. detailCode: "380357",
  2204. description: "",
  2205. solution: "",
  2206. updateTime: 1528011565000
  2207. },
  2208. {
  2209. moduleCode: "",
  2210. detailCode: "328022",
  2211. description: "",
  2212. solution: "",
  2213. updateTime: 1527929065000
  2214. },
  2215. {
  2216. moduleCode: "",
  2217. detailCode: "380003",
  2218. description: "",
  2219. solution: "",
  2220. updateTime: 1527927819000
  2221. },
  2222. {
  2223. moduleCode: "",
  2224. detailCode: "50004",
  2225. description: "",
  2226. solution: "",
  2227. updateTime: 1527770643000
  2228. },
  2229. {
  2230. moduleCode: "",
  2231. detailCode: "50011",
  2232. description: "",
  2233. solution: "",
  2234. updateTime: 1527770635000
  2235. },
  2236. {
  2237. moduleCode: "",
  2238. detailCode: "370017",
  2239. description: "",
  2240. solution: "",
  2241. updateTime: 1527739514000
  2242. },
  2243. {
  2244. moduleCode: "",
  2245. detailCode: "327032",
  2246. description: "",
  2247. solution: "",
  2248. updateTime: 1527726704000
  2249. },
  2250. {
  2251. moduleCode: "",
  2252. detailCode: "324001",
  2253. description: "",
  2254. solution: "",
  2255. updateTime: 1527681892000
  2256. },
  2257. {
  2258. moduleCode: "",
  2259. detailCode: "405997",
  2260. description: "",
  2261. solution: "",
  2262. updateTime: 1527653408000
  2263. },
  2264. {
  2265. moduleCode: "",
  2266. detailCode: "405995",
  2267. description: "",
  2268. solution: "",
  2269. updateTime: 1527647283000
  2270. },
  2271. {
  2272. moduleCode: "",
  2273. detailCode: "1153825",
  2274. description: "",
  2275. solution: "",
  2276. updateTime: 1527601747000
  2277. },
  2278. {
  2279. moduleCode: "",
  2280. detailCode: "328002",
  2281. description: "",
  2282. solution: "",
  2283. updateTime: 1527495292000
  2284. },
  2285. {
  2286. moduleCode: "",
  2287. detailCode: "1152679",
  2288. description: "",
  2289. solution: "",
  2290. updateTime: 1527486665000
  2291. },
  2292. {
  2293. moduleCode: "",
  2294. detailCode: "380356",
  2295. description: "",
  2296. solution: "",
  2297. updateTime: 1527125669000
  2298. },
  2299. {
  2300. moduleCode: "",
  2301. detailCode: "328032",
  2302. description: "",
  2303. solution: "",
  2304. updateTime: 1527069382000
  2305. },
  2306. {
  2307. moduleCode: "",
  2308. detailCode: "22",
  2309. description: "",
  2310. solution: "",
  2311. updateTime: 1527049826000
  2312. },
  2313. {
  2314. moduleCode: "",
  2315. detailCode: "9",
  2316. description: "",
  2317. solution: "",
  2318. updateTime: 1527006778000
  2319. },
  2320. {
  2321. moduleCode: "",
  2322. detailCode: "89",
  2323. description: "",
  2324. solution: "",
  2325. updateTime: 1526622784000
  2326. },
  2327. {
  2328. moduleCode: "",
  2329. detailCode: "328016",
  2330. description: "",
  2331. solution: "",
  2332. updateTime: 1526452365000
  2333. },
  2334. {
  2335. moduleCode: "",
  2336. detailCode: "368005",
  2337. description: "",
  2338. solution: "",
  2339. updateTime: 1525921264000
  2340. },
  2341. {
  2342. moduleCode: "",
  2343. detailCode: "0",
  2344. description: "",
  2345. solution: "",
  2346. updateTime: 1525920242000
  2347. },
  2348. {
  2349. moduleCode: "",
  2350. detailCode: "380006",
  2351. description: "",
  2352. solution: "",
  2353. updateTime: 1525918868000
  2354. },
  2355. {
  2356. moduleCode: "",
  2357. detailCode: "310",
  2358. description: "",
  2359. solution: "",
  2360. updateTime: 1525834436000
  2361. },
  2362. {
  2363. moduleCode: "",
  2364. detailCode: "360011",
  2365. description: "",
  2366. solution: "",
  2367. updateTime: 1525681552000
  2368. },
  2369. {
  2370. moduleCode: "",
  2371. detailCode: "170005",
  2372. description: "",
  2373. solution: "",
  2374. updateTime: 1525433900000
  2375. },
  2376. {
  2377. moduleCode: "",
  2378. detailCode: "50023",
  2379. description: "",
  2380. solution: "",
  2381. updateTime: 1525403338000
  2382. },
  2383. {
  2384. moduleCode: "",
  2385. detailCode: "100131",
  2386. description: "",
  2387. solution: "",
  2388. updateTime: 1525229691000
  2389. },
  2390. {
  2391. moduleCode: "",
  2392. detailCode: "-1018",
  2393. description: "",
  2394. solution: "",
  2395. updateTime: 1525142341000
  2396. },
  2397. {
  2398. moduleCode: "",
  2399. detailCode: "362026",
  2400. description: "",
  2401. solution: "",
  2402. updateTime: 1524882677000
  2403. },
  2404. {
  2405. moduleCode: "",
  2406. detailCode: "368007",
  2407. description: "",
  2408. solution: "",
  2409. updateTime: 1524832269000
  2410. },
  2411. {
  2412. moduleCode: "",
  2413. detailCode: "54",
  2414. description: "",
  2415. solution: "",
  2416. updateTime: 1524793646000
  2417. },
  2418. {
  2419. moduleCode: "",
  2420. detailCode: "1154722",
  2421. description: "",
  2422. solution: "",
  2423. updateTime: 1524620807000
  2424. },
  2425. {
  2426. moduleCode: "",
  2427. detailCode: "320229",
  2428. description: "",
  2429. solution: "",
  2430. updateTime: 1524551682000
  2431. },
  2432. {
  2433. moduleCode: "",
  2434. detailCode: "360012",
  2435. description: "",
  2436. solution: "",
  2437. updateTime: 1524472094000
  2438. },
  2439. {
  2440. moduleCode: "",
  2441. detailCode: "380229",
  2442. description: "",
  2443. solution: "",
  2444. updateTime: 1524110755000
  2445. },
  2446. {
  2447. moduleCode: "",
  2448. detailCode: "360016",
  2449. description: "",
  2450. solution: "",
  2451. updateTime: 1523933518000
  2452. },
  2453. {
  2454. moduleCode: "",
  2455. detailCode: "-1003",
  2456. description: "",
  2457. solution: "",
  2458. updateTime: 1523584804000
  2459. },
  2460. {
  2461. moduleCode: "",
  2462. detailCode: "410026",
  2463. description: "",
  2464. solution: "",
  2465. updateTime: 1523517430000
  2466. },
  2467. {
  2468. moduleCode: "",
  2469. detailCode: "360102",
  2470. description: "TTS初始化失败",
  2471. solution: "",
  2472. updateTime: 1523503528000
  2473. },
  2474. {
  2475. moduleCode: "",
  2476. detailCode: "360013",
  2477. description: "设备开启了隐私保护",
  2478. solution: "",
  2479. updateTime: 1523503507000
  2480. },
  2481. {
  2482. moduleCode: "",
  2483. detailCode: "360010",
  2484. description: "设备正在对讲中",
  2485. solution: "",
  2486. updateTime: 1523503491000
  2487. },
  2488. {
  2489. moduleCode: "",
  2490. detailCode: "360007",
  2491. description: "TTS关闭了与客户端的连接",
  2492. solution: "",
  2493. updateTime: 1523503475000
  2494. },
  2495. {
  2496. moduleCode: "",
  2497. detailCode: "360006",
  2498. description: "客户端接收发生错误",
  2499. solution: "",
  2500. updateTime: 1523503457000
  2501. },
  2502. {
  2503. moduleCode: "",
  2504. detailCode: "360005",
  2505. description: "客户端发送的消息错误",
  2506. solution: "",
  2507. updateTime: 1523503437000
  2508. },
  2509. {
  2510. moduleCode: "",
  2511. detailCode: "360004",
  2512. description: "TTS内部发生错误",
  2513. solution: "",
  2514. updateTime: 1523503421000
  2515. },
  2516. {
  2517. moduleCode: "",
  2518. detailCode: "360003",
  2519. description: "TTS的设备端发生错误",
  2520. solution: "",
  2521. updateTime: 1523503397000
  2522. },
  2523. {
  2524. moduleCode: "",
  2525. detailCode: "360002",
  2526. description: "对讲发起超时",
  2527. solution: "",
  2528. updateTime: 1523503376000
  2529. },
  2530. {
  2531. moduleCode: "",
  2532. detailCode: "360001",
  2533. description: "客户端请求超时",
  2534. solution: "",
  2535. updateTime: 1523503357000
  2536. },
  2537. {
  2538. moduleCode: "",
  2539. detailCode: "320077",
  2540. description: "",
  2541. solution: "",
  2542. updateTime: 1523444274000
  2543. },
  2544. {
  2545. moduleCode: "",
  2546. detailCode: "370047",
  2547. description: "",
  2548. solution: "",
  2549. updateTime: 1523440480000
  2550. },
  2551. {
  2552. moduleCode: "",
  2553. detailCode: "100002",
  2554. description: "",
  2555. solution: "",
  2556. updateTime: 1523413964000
  2557. },
  2558. {
  2559. moduleCode: "",
  2560. detailCode: "-1004",
  2561. description: "",
  2562. solution: "",
  2563. updateTime: 1523336653000
  2564. },
  2565. {
  2566. moduleCode: "",
  2567. detailCode: "380000",
  2568. description: "",
  2569. solution: "",
  2570. updateTime: 1523180856000
  2571. },
  2572. {
  2573. moduleCode: "",
  2574. detailCode: "380213",
  2575. description: "",
  2576. solution: "",
  2577. updateTime: 1523180623000
  2578. },
  2579. {
  2580. moduleCode: "",
  2581. detailCode: "380101",
  2582. description: "",
  2583. solution: "",
  2584. updateTime: 1522834231000
  2585. },
  2586. {
  2587. moduleCode: "",
  2588. detailCode: "50047",
  2589. description: "",
  2590. solution: "",
  2591. updateTime: 1522833243000
  2592. },
  2593. {
  2594. moduleCode: "",
  2595. detailCode: "-999",
  2596. description: "",
  2597. solution: "",
  2598. updateTime: 1522831034000
  2599. },
  2600. {
  2601. moduleCode: "",
  2602. detailCode: "320418",
  2603. description: "",
  2604. solution: "",
  2605. updateTime: 1522829072000
  2606. },
  2607. {
  2608. moduleCode: "",
  2609. detailCode: "-1009",
  2610. description: "",
  2611. solution: "",
  2612. updateTime: 1522746247000
  2613. },
  2614. {
  2615. moduleCode: "",
  2616. detailCode: "320209",
  2617. description: "",
  2618. solution: "",
  2619. updateTime: 1522744395000
  2620. },
  2621. {
  2622. moduleCode: "",
  2623. detailCode: "368006",
  2624. description: "",
  2625. solution: "",
  2626. updateTime: 1522744300000
  2627. },
  2628. {
  2629. moduleCode: "",
  2630. detailCode: "369003",
  2631. description: "",
  2632. solution: "",
  2633. updateTime: 1522736355000
  2634. },
  2635. {
  2636. moduleCode: "",
  2637. detailCode: "405989",
  2638. description: "",
  2639. solution: "",
  2640. updateTime: 1522726571000
  2641. },
  2642. {
  2643. moduleCode: "",
  2644. detailCode: "-1012",
  2645. description: "",
  2646. solution: "",
  2647. updateTime: 1522726203000
  2648. },
  2649. {
  2650. moduleCode: "",
  2651. detailCode: "322016",
  2652. description: "",
  2653. solution: "",
  2654. updateTime: 1522722918000
  2655. },
  2656. {
  2657. moduleCode: "",
  2658. detailCode: "500103",
  2659. description: "",
  2660. solution: "",
  2661. updateTime: 1522655556000
  2662. },
  2663. {
  2664. moduleCode: "",
  2665. detailCode: "405999",
  2666. description: "",
  2667. solution: "",
  2668. updateTime: 1522654716000
  2669. },
  2670. {
  2671. moduleCode: "",
  2672. detailCode: "321032",
  2673. description: "",
  2674. solution: "",
  2675. updateTime: 1522647732000
  2676. },
  2677. {
  2678. moduleCode: "",
  2679. detailCode: "381101",
  2680. description: "",
  2681. solution: "",
  2682. updateTime: 1522392414000
  2683. },
  2684. {
  2685. moduleCode: "",
  2686. detailCode: "399999",
  2687. description: "",
  2688. solution: "",
  2689. updateTime: 1522379834000
  2690. },
  2691. {
  2692. moduleCode: "",
  2693. detailCode: "380103",
  2694. description: "",
  2695. solution: "",
  2696. updateTime: 1522312724000
  2697. },
  2698. {
  2699. moduleCode: "",
  2700. detailCode: "360014",
  2701. description: "",
  2702. solution: "",
  2703. updateTime: 1522304341000
  2704. },
  2705. {
  2706. moduleCode: "",
  2707. detailCode: "-1005",
  2708. description: "",
  2709. solution: "",
  2710. updateTime: 1522288195000
  2711. },
  2712. {
  2713. moduleCode: "",
  2714. detailCode: "395454",
  2715. description: "",
  2716. solution: "",
  2717. updateTime: 1522220180000
  2718. },
  2719. {
  2720. moduleCode: "",
  2721. detailCode: "100005",
  2722. description: "",
  2723. solution: "",
  2724. updateTime: 1522218849000
  2725. },
  2726. {
  2727. moduleCode: "",
  2728. detailCode: "100004",
  2729. description: "",
  2730. solution: "",
  2731. updateTime: 1522209053000
  2732. },
  2733. {
  2734. moduleCode: "",
  2735. detailCode: "106002",
  2736. description: "",
  2737. solution: "",
  2738. updateTime: 1522206200000
  2739. },
  2740. {
  2741. moduleCode: "",
  2742. detailCode: "410030",
  2743. description: "",
  2744. solution: "",
  2745. updateTime: 1522162252000
  2746. },
  2747. {
  2748. moduleCode: "",
  2749. detailCode: "-1002",
  2750. description: "",
  2751. solution: "",
  2752. updateTime: 1522150690000
  2753. },
  2754. {
  2755. moduleCode: "",
  2756. detailCode: "-1200",
  2757. description: "",
  2758. solution: "",
  2759. updateTime: 1522139025000
  2760. },
  2761. {
  2762. moduleCode: "",
  2763. detailCode: "-1001",
  2764. description: "",
  2765. solution: "",
  2766. updateTime: 1522046436000
  2767. },
  2768. {
  2769. moduleCode: "",
  2770. detailCode: "-1011",
  2771. description: "",
  2772. solution: "",
  2773. updateTime: 1522045931000
  2774. },
  2775. {
  2776. moduleCode: "",
  2777. detailCode: "381102",
  2778. description: "",
  2779. solution: "",
  2780. updateTime: 1522044953000
  2781. },
  2782. {
  2783. moduleCode: "",
  2784. detailCode: "381103",
  2785. description: "",
  2786. solution: "",
  2787. updateTime: 1522044953000
  2788. },
  2789. {
  2790. moduleCode: "",
  2791. detailCode: "391205",
  2792. description: "vtdu解析服务器ip失败",
  2793. solution: "",
  2794. updateTime: 1522034841000
  2795. },
  2796. {
  2797. moduleCode: "",
  2798. detailCode: "391206",
  2799. description: "vtdu描述符select失败",
  2800. solution: "",
  2801. updateTime: 1522034841000
  2802. },
  2803. {
  2804. moduleCode: "",
  2805. detailCode: "391207",
  2806. description: "vtdu文件描述符不在可读中",
  2807. solution: "",
  2808. updateTime: 1522034841000
  2809. },
  2810. {
  2811. moduleCode: "",
  2812. detailCode: "391208",
  2813. description: "vtdu网络发生错误getsockopt",
  2814. solution: "",
  2815. updateTime: 1522034841000
  2816. },
  2817. {
  2818. moduleCode: "",
  2819. detailCode: "391209",
  2820. description: "vtdu描述符select超时",
  2821. solution: "",
  2822. updateTime: 1522034841000
  2823. },
  2824. {
  2825. moduleCode: "",
  2826. detailCode: "395000",
  2827. description: "cas回复信令,发现内存已经释放(和设备之间异常断开)",
  2828. solution: "检查设备网络;刷新重试",
  2829. updateTime: 1522034841000
  2830. },
  2831. {
  2832. moduleCode: "",
  2833. detailCode: "395400",
  2834. description: "私有化协议vtm检测私有化协议中码流类型小于0或者设备序列号为空等非法参数场景返回(app不重试取流)",
  2835. solution: "刷新重试",
  2836. updateTime: 1522034841000
  2837. },
  2838. {
  2839. moduleCode: "",
  2840. detailCode: "395402",
  2841. description: "回放找不到录像文件",
  2842. solution: "检查是否有存储卡并且接触良好",
  2843. updateTime: 1522034841000
  2844. },
  2845. {
  2846. moduleCode: "",
  2847. detailCode: "395403",
  2848. description: "操作码或信令密钥与设备不匹配",
  2849. solution: "",
  2850. updateTime: 1522034841000
  2851. },
  2852. {
  2853. moduleCode: "",
  2854. detailCode: "395404",
  2855. description: "设备不在线",
  2856. solution: "检查设备网络;重启设备接入",
  2857. updateTime: 1522034841000
  2858. },
  2859. {
  2860. moduleCode: "",
  2861. detailCode: "395405",
  2862. description: "流媒体向设备发送或接受信令超时/cas响应超时",
  2863. solution: "检查设备网络;重启设备",
  2864. updateTime: 1522034841000
  2865. },
  2866. {
  2867. moduleCode: "",
  2868. detailCode: "395406",
  2869. description: "token失效",
  2870. solution: "刷新重试或者重启设备",
  2871. updateTime: 1522034841000
  2872. },
  2873. {
  2874. moduleCode: "",
  2875. detailCode: "395407",
  2876. description: "客户端的URL格式错误",
  2877. solution: "刷新重试",
  2878. updateTime: 1522034841000
  2879. },
  2880. {
  2881. moduleCode: "",
  2882. detailCode: "395409",
  2883. description: "预览开启隐私保护",
  2884. solution: "",
  2885. updateTime: 1522034841000
  2886. },
  2887. {
  2888. moduleCode: "",
  2889. detailCode: "395410",
  2890. description: "设备达到最大连接数",
  2891. solution: "请升级设备固件版本",
  2892. updateTime: 1522034841000
  2893. },
  2894. {
  2895. moduleCode: "",
  2896. detailCode: "395411",
  2897. description: "token无权限",
  2898. solution: "刷新重试",
  2899. updateTime: 1522034841000
  2900. },
  2901. {
  2902. moduleCode: "",
  2903. detailCode: "395412",
  2904. description: "session不存在 ",
  2905. solution: "",
  2906. updateTime: 1522034841000
  2907. },
  2908. {
  2909. moduleCode: "",
  2910. detailCode: "395413",
  2911. description: "验证token的他异常(不具体) ",
  2912. solution: "刷新重试",
  2913. updateTime: 1522034841000
  2914. },
  2915. {
  2916. moduleCode: "",
  2917. detailCode: "395415",
  2918. description: "设备通道错",
  2919. solution: "刷新重试",
  2920. updateTime: 1522034841000
  2921. },
  2922. {
  2923. moduleCode: "",
  2924. detailCode: "395451",
  2925. description: "设备不支持的码流类型",
  2926. solution: "刷新重试或者切换到高清模式",
  2927. updateTime: 1522034841000
  2928. },
  2929. {
  2930. moduleCode: "",
  2931. detailCode: "395452",
  2932. description: "设备链接流媒体服务器失败 ",
  2933. solution: "检查设备网络,重启设备,刷新重试",
  2934. updateTime: 1522034841000
  2935. },
  2936. {
  2937. moduleCode: "",
  2938. detailCode: "395500",
  2939. description: "服务器处理失败 ",
  2940. solution: "刷新重试",
  2941. updateTime: 1522034841000
  2942. },
  2943. {
  2944. moduleCode: "",
  2945. detailCode: "395501",
  2946. description: "流媒体vtdu达到最大负载,请扩容",
  2947. solution: "服务器负载达到上限,请稍后重试",
  2948. updateTime: 1522034841000
  2949. },
  2950. {
  2951. moduleCode: "",
  2952. detailCode: "395503",
  2953. description: "vtm返回分配vtdu失败",
  2954. solution: "服务器负载达到上限,请稍后重试",
  2955. updateTime: 1522034841000
  2956. },
  2957. {
  2958. moduleCode: "",
  2959. detailCode: "395544",
  2960. description: "设备返回无视频源 ",
  2961. solution: "设备是否接触良好;",
  2962. updateTime: 1522034841000
  2963. },
  2964. {
  2965. moduleCode: "",
  2966. detailCode: "395545",
  2967. description: "视频分享时间已经结束",
  2968. solution: "",
  2969. updateTime: 1522034841000
  2970. },
  2971. {
  2972. moduleCode: "",
  2973. detailCode: "395546",
  2974. description: "vtdu返回达到取流并发路数限制",
  2975. solution: "请升级为企业版,放开并发限制",
  2976. updateTime: 1522034841000
  2977. },
  2978. {
  2979. moduleCode: "",
  2980. detailCode: "395560",
  2981. description: "蚁兵代理不支持的用户取流类型,会重定向到vtdu取流",
  2982. solution: "",
  2983. updateTime: 1522034841000
  2984. },
  2985. {
  2986. moduleCode: "",
  2987. detailCode: "395557",
  2988. description: "回放服务器等待流头超时",
  2989. solution: "刷新重试,检测设备网络,重启设备",
  2990. updateTime: 1522034841000
  2991. },
  2992. {
  2993. moduleCode: "",
  2994. detailCode: "395600",
  2995. description: "分享设备不在分享时间内",
  2996. solution: "",
  2997. updateTime: 1522034841000
  2998. },
  2999. {
  3000. moduleCode: "",
  3001. detailCode: "395601",
  3002. description: "群组分享用户没权限",
  3003. solution: "",
  3004. updateTime: 1522034841000
  3005. },
  3006. {
  3007. moduleCode: "",
  3008. detailCode: "395602",
  3009. description: "群组分享权限变更",
  3010. solution: "",
  3011. updateTime: 1522034841000
  3012. },
  3013. {
  3014. moduleCode: "",
  3015. detailCode: "395556",
  3016. description: "ticket取流验证失败",
  3017. solution: "",
  3018. updateTime: 1522034841000
  3019. },
  3020. {
  3021. moduleCode: "",
  3022. detailCode: "395530",
  3023. description: "机房故障不可用",
  3024. solution: "刷新重试",
  3025. updateTime: 1522034841000
  3026. },
  3027. {
  3028. moduleCode: "",
  3029. detailCode: "395701",
  3030. description: "cas信令返回格式错误",
  3031. solution: "刷新重试",
  3032. updateTime: 1522034841000
  3033. },
  3034. {
  3035. moduleCode: "",
  3036. detailCode: "396001",
  3037. description: "客户端参数出错",
  3038. solution: "刷新重试",
  3039. updateTime: 1522034841000
  3040. },
  3041. {
  3042. moduleCode: "",
  3043. detailCode: "396099",
  3044. description: "客户端默认错误",
  3045. solution: "",
  3046. updateTime: 1522034841000
  3047. },
  3048. {
  3049. moduleCode: "",
  3050. detailCode: "396101",
  3051. description: "不支持的命令",
  3052. solution: "刷新重试",
  3053. updateTime: 1522034841000
  3054. },
  3055. {
  3056. moduleCode: "",
  3057. detailCode: "396102",
  3058. description: "设备流头发送失败",
  3059. solution: "",
  3060. updateTime: 1522034841000
  3061. },
  3062. {
  3063. moduleCode: "",
  3064. detailCode: "396103",
  3065. description: "cas/设备返回错误1",
  3066. solution: "刷新重试",
  3067. updateTime: 1522034841000
  3068. },
  3069. {
  3070. moduleCode: "",
  3071. detailCode: "396104",
  3072. description: "cas/设备返回错误-1",
  3073. solution: "刷新重试",
  3074. updateTime: 1522034841000
  3075. },
  3076. {
  3077. moduleCode: "",
  3078. detailCode: "396105",
  3079. description: "设备返回错误码3",
  3080. solution: "刷新重试",
  3081. updateTime: 1522034841000
  3082. },
  3083. {
  3084. moduleCode: "",
  3085. detailCode: "396106",
  3086. description: "设备返回错误码4",
  3087. solution: "刷新重试",
  3088. updateTime: 1522034841000
  3089. },
  3090. {
  3091. moduleCode: "",
  3092. detailCode: "396107",
  3093. description: "设备返回错误码5",
  3094. solution: "刷新重试",
  3095. updateTime: 1522034841000
  3096. },
  3097. {
  3098. moduleCode: "",
  3099. detailCode: "396108",
  3100. description: "cas信令回应重复",
  3101. solution: "刷新重试",
  3102. updateTime: 1522034841000
  3103. },
  3104. {
  3105. moduleCode: "",
  3106. detailCode: "396109",
  3107. description: "视频广场取消分享",
  3108. solution: "",
  3109. updateTime: 1522034841000
  3110. },
  3111. {
  3112. moduleCode: "",
  3113. detailCode: "396110",
  3114. description: "设备信令默认错误",
  3115. solution: "",
  3116. updateTime: 1522034841000
  3117. },
  3118. {
  3119. moduleCode: "",
  3120. detailCode: "396501",
  3121. description: "设备数据链路和实际链路不匹配",
  3122. solution: "刷新重试",
  3123. updateTime: 1522034841000
  3124. },
  3125. {
  3126. moduleCode: "",
  3127. detailCode: "396502",
  3128. description: "设备数据链路重复建立连接",
  3129. solution: "刷新重试",
  3130. updateTime: 1522034841000
  3131. },
  3132. {
  3133. moduleCode: "",
  3134. detailCode: "396503",
  3135. description: "设备数据链路端口不匹配",
  3136. solution: "刷新重试",
  3137. updateTime: 1522034841000
  3138. },
  3139. {
  3140. moduleCode: "",
  3141. detailCode: "396504",
  3142. description: "缓存设备数据链路失败(内存块不足)",
  3143. solution: "刷新重试",
  3144. updateTime: 1522034841000
  3145. },
  3146. {
  3147. moduleCode: "",
  3148. detailCode: "396505",
  3149. description: "设备发送确认头消息重复",
  3150. solution: "刷新重试",
  3151. updateTime: 1522034841000
  3152. },
  3153. {
  3154. moduleCode: "",
  3155. detailCode: "396506",
  3156. description: "设备数据先于确定头部到达",
  3157. solution: "刷新重试",
  3158. updateTime: 1522034841000
  3159. },
  3160. {
  3161. moduleCode: "",
  3162. detailCode: "396508",
  3163. description: "设备数据头部长度非法",
  3164. solution: "刷新重试,或者重启设备",
  3165. updateTime: 1522034841000
  3166. },
  3167. {
  3168. moduleCode: "",
  3169. detailCode: "396509",
  3170. description: "索引找不到设备数据管理块",
  3171. solution: "刷新重试",
  3172. updateTime: 1522034841000
  3173. },
  3174. {
  3175. moduleCode: "",
  3176. detailCode: "396510",
  3177. description: "设备数据链路vtdu内存块协议状态不匹配",
  3178. solution: "",
  3179. updateTime: 1522034841000
  3180. },
  3181. {
  3182. moduleCode: "",
  3183. detailCode: "396511",
  3184. description: "设备数据头部没有streamkey错误",
  3185. solution: "",
  3186. updateTime: 1522034841000
  3187. },
  3188. {
  3189. moduleCode: "",
  3190. detailCode: "396512",
  3191. description: "设备数据头部非法(较笼统)",
  3192. solution: "",
  3193. updateTime: 1522034841000
  3194. },
  3195. {
  3196. moduleCode: "",
  3197. detailCode: "396513",
  3198. description: "设备数据长度过小",
  3199. solution: "",
  3200. updateTime: 1522034841000
  3201. },
  3202. {
  3203. moduleCode: "",
  3204. detailCode: "396514",
  3205. description: "设备老协议推流头部没有streamkey错误",
  3206. solution: "",
  3207. updateTime: 1522034841000
  3208. },
  3209. {
  3210. moduleCode: "",
  3211. detailCode: "396515",
  3212. description: "设备老协议推流数据非法",
  3213. solution: "",
  3214. updateTime: 1522034841000
  3215. },
  3216. {
  3217. moduleCode: "",
  3218. detailCode: "396516",
  3219. description: "设备老协议索引找不到内存管理块",
  3220. solution: "",
  3221. updateTime: 1522034841000
  3222. },
  3223. {
  3224. moduleCode: "",
  3225. detailCode: "396517",
  3226. description: "设备老协议推流数据非法",
  3227. solution: "",
  3228. updateTime: 1522034841000
  3229. },
  3230. {
  3231. moduleCode: "",
  3232. detailCode: "396518",
  3233. description: "设备数据包过大",
  3234. solution: "刷新重试,或者重启设备",
  3235. updateTime: 1522034841000
  3236. },
  3237. {
  3238. moduleCode: "",
  3239. detailCode: "396519",
  3240. description: "设备推流链路网络不稳定",
  3241. solution: "",
  3242. updateTime: 1522034841000
  3243. },
  3244. {
  3245. moduleCode: "",
  3246. detailCode: "396520",
  3247. description: "设备推流链路网络不稳定(默认)",
  3248. solution: "",
  3249. updateTime: 1522034841000
  3250. },
  3251. {
  3252. moduleCode: "",
  3253. detailCode: "170003",
  3254. description: "refreshToken不存在",
  3255. solution: "建议用户重新调用logout接口,然后调用openLoginPage接口重新启动登录页面登录",
  3256. updateTime: 1522034841000
  3257. },
  3258. {
  3259. moduleCode: "",
  3260. detailCode: "170004",
  3261. description: "refreshToken已过期",
  3262. solution: "建议用户重新调用logout接口,然后调用openLoginPage接口重新启动登录页面登录",
  3263. updateTime: 1522034841000
  3264. },
  3265. {
  3266. moduleCode: "",
  3267. detailCode: "380011",
  3268. description: "设备隐私保护中",
  3269. solution: "",
  3270. updateTime: 1522034841000
  3271. },
  3272. {
  3273. moduleCode: "",
  3274. detailCode: "380045",
  3275. description: "设备直连取流连接数量过大",
  3276. solution: "",
  3277. updateTime: 1522034841000
  3278. },
  3279. {
  3280. moduleCode: "",
  3281. detailCode: "380047",
  3282. description: "设备不支持该命令",
  3283. solution: "",
  3284. updateTime: 1522034841000
  3285. },
  3286. {
  3287. moduleCode: "",
  3288. detailCode: "380077",
  3289. description: "设备正在对讲中",
  3290. solution: "",
  3291. updateTime: 1522034841000
  3292. },
  3293. {
  3294. moduleCode: "",
  3295. detailCode: "380102",
  3296. description: "数据接收异常",
  3297. solution: "",
  3298. updateTime: 1522034841000
  3299. },
  3300. {
  3301. moduleCode: "",
  3302. detailCode: "380205",
  3303. description: "设备检测入参异常",
  3304. solution: "",
  3305. updateTime: 1522034841000
  3306. },
  3307. {
  3308. moduleCode: "",
  3309. detailCode: "380209",
  3310. description: "网络连接超时",
  3311. solution: "",
  3312. updateTime: 1522034841000
  3313. },
  3314. {
  3315. moduleCode: "",
  3316. detailCode: "380212",
  3317. description: "设备端网络连接超时",
  3318. solution: "",
  3319. updateTime: 1522034841000
  3320. },
  3321. {
  3322. moduleCode: "",
  3323. detailCode: "101007",
  3324. description: "手机号未注册",
  3325. solution: "",
  3326. updateTime: 1522034840000
  3327. },
  3328. {
  3329. moduleCode: "",
  3330. detailCode: "120503",
  3331. description: "正在响铃",
  3332. solution: "",
  3333. updateTime: 1522034840000
  3334. },
  3335. {
  3336. moduleCode: "",
  3337. detailCode: "390016",
  3338. description: "vtdu成功响应未携带流头",
  3339. solution: "",
  3340. updateTime: 1522034840000
  3341. },
  3342. {
  3343. moduleCode: "",
  3344. detailCode: "101008",
  3345. description: "手机号码不合法",
  3346. solution: "",
  3347. updateTime: 1522034840000
  3348. },
  3349. {
  3350. moduleCode: "",
  3351. detailCode: "120504",
  3352. description: "室内机正在通话",
  3353. solution: "",
  3354. updateTime: 1522034840000
  3355. },
  3356. {
  3357. moduleCode: "",
  3358. detailCode: "390017",
  3359. description: "无数据流,尚未使用",
  3360. solution: "",
  3361. updateTime: 1522034840000
  3362. },
  3363. {
  3364. moduleCode: "",
  3365. detailCode: "101009",
  3366. description: "用户名与手机不匹配",
  3367. solution: "",
  3368. updateTime: 1522034840000
  3369. },
  3370. {
  3371. moduleCode: "",
  3372. detailCode: "120505",
  3373. description: "设备操作失败",
  3374. solution: "",
  3375. updateTime: 1522034840000
  3376. },
  3377. {
  3378. moduleCode: "",
  3379. detailCode: "390018",
  3380. description: "信令消息体PB解析失败",
  3381. solution: "",
  3382. updateTime: 1522034840000
  3383. },
  3384. {
  3385. moduleCode: "",
  3386. detailCode: "101010",
  3387. description: "获取验证码失败",
  3388. solution: "",
  3389. updateTime: 1522034840000
  3390. },
  3391. {
  3392. moduleCode: "",
  3393. detailCode: "120506",
  3394. description: "非法命令",
  3395. solution: "",
  3396. updateTime: 1522034840000
  3397. },
  3398. {
  3399. moduleCode: "",
  3400. detailCode: "390019",
  3401. description: "信令消息体PB封装失败",
  3402. solution: "",
  3403. updateTime: 1522034840000
  3404. },
  3405. {
  3406. moduleCode: "",
  3407. detailCode: "101011",
  3408. description: "验证码错误",
  3409. solution: "",
  3410. updateTime: 1522034840000
  3411. },
  3412. {
  3413. moduleCode: "",
  3414. detailCode: "120507",
  3415. description: "智能锁密码错误",
  3416. solution: "",
  3417. updateTime: 1522034840000
  3418. },
  3419. {
  3420. moduleCode: "",
  3421. detailCode: "390020",
  3422. description: "申请系统内存资源失败",
  3423. solution: "",
  3424. updateTime: 1522034840000
  3425. },
  3426. {
  3427. moduleCode: "",
  3428. detailCode: "101012",
  3429. description: "验证码失效",
  3430. solution: "",
  3431. updateTime: 1522034840000
  3432. },
  3433. {
  3434. moduleCode: "",
  3435. detailCode: "120508",
  3436. description: "开关锁失败",
  3437. solution: "",
  3438. updateTime: 1522034840000
  3439. },
  3440. {
  3441. moduleCode: "",
  3442. detailCode: "390021",
  3443. description: "vtdu地址尚未获取到",
  3444. solution: "",
  3445. updateTime: 1522034840000
  3446. },
  3447. {
  3448. moduleCode: "",
  3449. detailCode: "101013",
  3450. description: "用户不存在",
  3451. solution: "",
  3452. updateTime: 1522034840000
  3453. },
  3454. {
  3455. moduleCode: "",
  3456. detailCode: "120509",
  3457. description: "开关锁超时",
  3458. solution: "",
  3459. updateTime: 1522034840000
  3460. },
  3461. {
  3462. moduleCode: "",
  3463. detailCode: "390022",
  3464. description: "客户端尚未支持",
  3465. solution: "",
  3466. updateTime: 1522034840000
  3467. },
  3468. {
  3469. moduleCode: "",
  3470. detailCode: "101014",
  3471. description: "密码不正确或者appKey不正确",
  3472. solution: "",
  3473. updateTime: 1522034840000
  3474. },
  3475. {
  3476. moduleCode: "",
  3477. detailCode: "120510",
  3478. description: "智能锁设备繁忙",
  3479. solution: "",
  3480. updateTime: 1522034840000
  3481. },
  3482. {
  3483. moduleCode: "",
  3484. detailCode: "390023",
  3485. description: "获取系统socket资源失败",
  3486. solution: "",
  3487. updateTime: 1522034840000
  3488. },
  3489. {
  3490. moduleCode: "",
  3491. detailCode: "101015",
  3492. description: "用户被锁住",
  3493. solution: "",
  3494. updateTime: 1522034840000
  3495. },
  3496. {
  3497. moduleCode: "",
  3498. detailCode: "120511",
  3499. description: "远程开锁功能未打开",
  3500. solution: "",
  3501. updateTime: 1522034840000
  3502. },
  3503. {
  3504. moduleCode: "",
  3505. detailCode: "390024",
  3506. description: "上层填充的StreamSsnId不匹配",
  3507. solution: "",
  3508. updateTime: 1522034840000
  3509. },
  3510. {
  3511. moduleCode: "",
  3512. detailCode: "101021",
  3513. description: "验证参数异常",
  3514. solution: "",
  3515. updateTime: 1522034840000
  3516. },
  3517. {
  3518. moduleCode: "",
  3519. detailCode: "120600",
  3520. description: "临时密码数已达上限",
  3521. solution: "",
  3522. updateTime: 1522034840000
  3523. },
  3524. {
  3525. moduleCode: "",
  3526. detailCode: "390025",
  3527. description: "链接服务器失败",
  3528. solution: "",
  3529. updateTime: 1522034840000
  3530. },
  3531. {
  3532. moduleCode: "",
  3533. detailCode: "101026",
  3534. description: "邮箱已经被注册",
  3535. solution: "",
  3536. updateTime: 1522034840000
  3537. },
  3538. {
  3539. moduleCode: "",
  3540. detailCode: "120601",
  3541. description: "添加临时密码失败",
  3542. solution: "",
  3543. updateTime: 1522034840000
  3544. },
  3545. {
  3546. moduleCode: "",
  3547. detailCode: "390026",
  3548. description: "客户端请求未收到服务端应答",
  3549. solution: "",
  3550. updateTime: 1522034840000
  3551. },
  3552. {
  3553. moduleCode: "",
  3554. detailCode: "101031",
  3555. description: "邮箱未注册",
  3556. solution: "",
  3557. updateTime: 1522034840000
  3558. },
  3559. {
  3560. moduleCode: "",
  3561. detailCode: "120602",
  3562. description: "删除临时密码失败",
  3563. solution: "",
  3564. updateTime: 1522034840000
  3565. },
  3566. {
  3567. moduleCode: "",
  3568. detailCode: "390027",
  3569. description: "链路断开",
  3570. solution: "",
  3571. updateTime: 1522034840000
  3572. },
  3573. {
  3574. moduleCode: "",
  3575. detailCode: "101032",
  3576. description: "邮箱不合法",
  3577. solution: "",
  3578. updateTime: 1522034840000
  3579. },
  3580. {
  3581. moduleCode: "",
  3582. detailCode: "120603",
  3583. description: "该临时密码不存在",
  3584. solution: "",
  3585. updateTime: 1522034840000
  3586. },
  3587. {
  3588. moduleCode: "",
  3589. detailCode: "390028",
  3590. description: "没有取流链接",
  3591. solution: "",
  3592. updateTime: 1522034840000
  3593. },
  3594. {
  3595. moduleCode: "",
  3596. detailCode: "101041",
  3597. description: "获取验证码过于频繁",
  3598. solution: "",
  3599. updateTime: 1522034840000
  3600. },
  3601. {
  3602. moduleCode: "",
  3603. detailCode: "120604",
  3604. description: "指纹锁射频通信失败,请稍后再试",
  3605. solution: "",
  3606. updateTime: 1522034840000
  3607. },
  3608. {
  3609. moduleCode: "",
  3610. detailCode: "390029",
  3611. description: "流成功停止",
  3612. solution: "",
  3613. updateTime: 1522034840000
  3614. },
  3615. {
  3616. moduleCode: "",
  3617. detailCode: "101043",
  3618. description: "手机验证码输入错误超过规定次数",
  3619. solution: "",
  3620. updateTime: 1522034840000
  3621. },
  3622. {
  3623. moduleCode: "",
  3624. detailCode: "120605",
  3625. description: "其他用户正在认证中",
  3626. solution: "",
  3627. updateTime: 1522034840000
  3628. },
  3629. {
  3630. moduleCode: "",
  3631. detailCode: "390030",
  3632. description: "客户端防串流校验失败",
  3633. solution: "",
  3634. updateTime: 1522034840000
  3635. },
  3636. {
  3637. moduleCode: "",
  3638. detailCode: "102000",
  3639. description: "设备不存在",
  3640. solution: "",
  3641. updateTime: 1522034840000
  3642. },
  3643. {
  3644. moduleCode: "",
  3645. detailCode: "120606",
  3646. description: "验证已启动,请在120s内进行本地验证和调用添加设备接口",
  3647. solution: "",
  3648. updateTime: 1522034840000
  3649. },
  3650. {
  3651. moduleCode: "",
  3652. detailCode: "390031",
  3653. description: "应用层tcp粘包处理缓冲区满",
  3654. solution: "",
  3655. updateTime: 1522034840000
  3656. },
  3657. {
  3658. moduleCode: "",
  3659. detailCode: "102001",
  3660. description: "摄像机不存在",
  3661. solution: "摄像机未注册到平台,请仔细检查摄像机的网络配置,确保连接到网络",
  3662. updateTime: 1522034840000
  3663. },
  3664. {
  3665. moduleCode: "",
  3666. detailCode: "120607",
  3667. description: "删除用户失败",
  3668. solution: "",
  3669. updateTime: 1522034840000
  3670. },
  3671. {
  3672. moduleCode: "",
  3673. detailCode: "390032",
  3674. description: "无效状态迁移",
  3675. solution: "",
  3676. updateTime: 1522034840000
  3677. },
  3678. {
  3679. moduleCode: "",
  3680. detailCode: "102003",
  3681. description: "设备不在线",
  3682. solution: "参考服务中心排查方法",
  3683. updateTime: 1522034840000
  3684. },
  3685. {
  3686. moduleCode: "",
  3687. detailCode: "120608",
  3688. description: "用户不存在",
  3689. solution: "",
  3690. updateTime: 1522034840000
  3691. },
  3692. {
  3693. moduleCode: "",
  3694. detailCode: "390033",
  3695. description: "无效客户端状态",
  3696. solution: "",
  3697. updateTime: 1522034840000
  3698. },
  3699. {
  3700. moduleCode: "",
  3701. detailCode: "102004",
  3702. description: "设备异常",
  3703. solution: "",
  3704. updateTime: 1522034840000
  3705. },
  3706. {
  3707. moduleCode: "",
  3708. detailCode: "120609",
  3709. description: "设备响应超时,门锁通信故障或者电量不足,请重试.",
  3710. solution: "",
  3711. updateTime: 1522034840000
  3712. },
  3713. {
  3714. moduleCode: "",
  3715. detailCode: "390034",
  3716. description: "向vtm取流流媒体信息请求超时",
  3717. solution: "",
  3718. updateTime: 1522034840000
  3719. },
  3720. {
  3721. moduleCode: "",
  3722. detailCode: "102007",
  3723. description: "设备序列号不正确",
  3724. solution: "",
  3725. updateTime: 1522034840000
  3726. },
  3727. {
  3728. moduleCode: "",
  3729. detailCode: "120610",
  3730. description: "获取临时密码列表失败",
  3731. solution: "",
  3732. updateTime: 1522034840000
  3733. },
  3734. {
  3735. moduleCode: "",
  3736. detailCode: "390035",
  3737. description: "向代理取流请求超时",
  3738. solution: "",
  3739. updateTime: 1522034840000
  3740. },
  3741. {
  3742. moduleCode: "",
  3743. detailCode: "102009",
  3744. description: "设备请求响应超时异常",
  3745. solution: "",
  3746. updateTime: 1522034840000
  3747. },
  3748. {
  3749. moduleCode: "",
  3750. detailCode: "130001",
  3751. description: "用户不存在",
  3752. solution: "",
  3753. updateTime: 1522034840000
  3754. },
  3755. {
  3756. moduleCode: "",
  3757. detailCode: "390036",
  3758. description: "向代理保活取流请求超时",
  3759. solution: "",
  3760. updateTime: 1522034840000
  3761. },
  3762. {
  3763. moduleCode: "",
  3764. detailCode: "105000",
  3765. description: "设备已被自己添加",
  3766. solution: "",
  3767. updateTime: 1522034840000
  3768. },
  3769. {
  3770. moduleCode: "",
  3771. detailCode: "130002",
  3772. description: "手机号码已经注册",
  3773. solution: "",
  3774. updateTime: 1522034840000
  3775. },
  3776. {
  3777. moduleCode: "",
  3778. detailCode: "390037",
  3779. description: "向vtdu取流请求超时",
  3780. solution: "",
  3781. updateTime: 1522034840000
  3782. },
  3783. {
  3784. moduleCode: "",
  3785. detailCode: "105001",
  3786. description: "设备已被别人添加",
  3787. solution: "",
  3788. updateTime: 1522034840000
  3789. },
  3790. {
  3791. moduleCode: "",
  3792. detailCode: "130003",
  3793. description: "手机验证码错误",
  3794. solution: "",
  3795. updateTime: 1522034840000
  3796. },
  3797. {
  3798. moduleCode: "",
  3799. detailCode: "390038",
  3800. description: "向vtdu保活取流请求超时",
  3801. solution: "",
  3802. updateTime: 1522034840000
  3803. },
  3804. {
  3805. moduleCode: "",
  3806. detailCode: "105002",
  3807. description: "设备验证码错误",
  3808. solution: "",
  3809. updateTime: 1522034840000
  3810. },
  3811. {
  3812. moduleCode: "",
  3813. detailCode: "130004",
  3814. description: "终端绑定操作失败",
  3815. solution: "",
  3816. updateTime: 1522034840000
  3817. },
  3818. {
  3819. moduleCode: "",
  3820. detailCode: "391001",
  3821. description: "vtm地址或端口非法",
  3822. solution: "",
  3823. updateTime: 1522034840000
  3824. },
  3825. {
  3826. moduleCode: "",
  3827. detailCode: "107001",
  3828. description: "邀请不存在",
  3829. solution: "",
  3830. updateTime: 1522034840000
  3831. },
  3832. {
  3833. moduleCode: "",
  3834. detailCode: "149999",
  3835. description: "数据异常",
  3836. solution: "",
  3837. updateTime: 1522034840000
  3838. },
  3839. {
  3840. moduleCode: "",
  3841. detailCode: "391002",
  3842. description: "vtm生成文件描述符失败",
  3843. solution: "",
  3844. updateTime: 1522034840000
  3845. },
  3846. {
  3847. moduleCode: "",
  3848. detailCode: "107002",
  3849. description: "邀请验证失败",
  3850. solution: "",
  3851. updateTime: 1522034840000
  3852. },
  3853. {
  3854. moduleCode: "",
  3855. detailCode: "150000",
  3856. description: "服务器异常",
  3857. solution: "",
  3858. updateTime: 1522034840000
  3859. },
  3860. {
  3861. moduleCode: "",
  3862. detailCode: "391003",
  3863. description: "vtm设置文件描述符非阻塞失败",
  3864. solution: "",
  3865. updateTime: 1522034840000
  3866. },
  3867. {
  3868. moduleCode: "",
  3869. detailCode: "107003",
  3870. description: "邀请用户不匹配",
  3871. solution: "",
  3872. updateTime: 1522034840000
  3873. },
  3874. {
  3875. moduleCode: "",
  3876. detailCode: "160000",
  3877. description: "设备不支持云台控制",
  3878. solution: "",
  3879. updateTime: 1522034840000
  3880. },
  3881. {
  3882. moduleCode: "",
  3883. detailCode: "391004",
  3884. description: "vtm设置文件描述符阻塞失败",
  3885. solution: "",
  3886. updateTime: 1522034840000
  3887. },
  3888. {
  3889. moduleCode: "",
  3890. detailCode: "107004",
  3891. description: "云存储连接失败",
  3892. solution: "",
  3893. updateTime: 1522034840000
  3894. },
  3895. {
  3896. moduleCode: "",
  3897. detailCode: "160001",
  3898. description: "用户无云台控制权限",
  3899. solution: "",
  3900. updateTime: 1522034840000
  3901. },
  3902. {
  3903. moduleCode: "",
  3904. detailCode: "391005",
  3905. description: "vtm解析服务器ip失败",
  3906. solution: "",
  3907. updateTime: 1522034840000
  3908. },
  3909. {
  3910. moduleCode: "",
  3911. detailCode: "7005",
  3912. description: "VTDU主动断开连接",
  3913. solution: "",
  3914. updateTime: 1522034840000
  3915. },
  3916. {
  3917. moduleCode: "",
  3918. detailCode: "107005",
  3919. description: "VTDU主动断开连接",
  3920. solution: "",
  3921. updateTime: 1522034840000
  3922. },
  3923. {
  3924. moduleCode: "",
  3925. detailCode: "160002",
  3926. description: "设备云台旋转达到上限位",
  3927. solution: "",
  3928. updateTime: 1522034840000
  3929. },
  3930. {
  3931. moduleCode: "",
  3932. detailCode: "391006",
  3933. description: "vtm描述符select失败",
  3934. solution: "",
  3935. updateTime: 1522034840000
  3936. },
  3937. {
  3938. moduleCode: "",
  3939. detailCode: "107006",
  3940. description: "不能邀请自己",
  3941. solution: "",
  3942. updateTime: 1522034840000
  3943. },
  3944. {
  3945. moduleCode: "",
  3946. detailCode: "160003",
  3947. description: "设备云台旋转达到下限位",
  3948. solution: "",
  3949. updateTime: 1522034840000
  3950. },
  3951. {
  3952. moduleCode: "",
  3953. detailCode: "391007",
  3954. description: "vtm文件描述符不在可读中",
  3955. solution: "",
  3956. updateTime: 1522034840000
  3957. },
  3958. {
  3959. moduleCode: "",
  3960. detailCode: "107007",
  3961. description: "重复邀请",
  3962. solution: "分享和删除分享必须全部由接口形式操作,如果与萤石客户端混用会造成这个问题,解决办法:在萤石客户端清空所有相关分享数据并重新添加设备,再通过接口操作即可",
  3963. updateTime: 1522034840000
  3964. },
  3965. {
  3966. moduleCode: "",
  3967. detailCode: "160004",
  3968. description: "设备云台旋转达到左限位",
  3969. solution: "",
  3970. updateTime: 1522034840000
  3971. },
  3972. {
  3973. moduleCode: "",
  3974. detailCode: "391008",
  3975. description: "vtm网络发生错误getsockopt",
  3976. solution: "",
  3977. updateTime: 1522034840000
  3978. },
  3979. {
  3980. moduleCode: "",
  3981. detailCode: "110001",
  3982. description: "参数错误",
  3983. solution: "参数为空或者格式不对",
  3984. updateTime: 1522034840000
  3985. },
  3986. {
  3987. moduleCode: "",
  3988. detailCode: "160005",
  3989. description: "设备云台旋转达到右限位",
  3990. solution: "",
  3991. updateTime: 1522034840000
  3992. },
  3993. {
  3994. moduleCode: "",
  3995. detailCode: "391009",
  3996. description: "vtm描述符select超时",
  3997. solution: "",
  3998. updateTime: 1522034840000
  3999. },
  4000. {
  4001. moduleCode: "",
  4002. detailCode: "110002",
  4003. description: "accessToken异常或过期",
  4004. solution: "accessToken有效期为七天,建议在accessToken即将过期或者出现10002错误码的时候重新获取accessToken",
  4005. updateTime: 1522034840000
  4006. },
  4007. {
  4008. moduleCode: "",
  4009. detailCode: "160006",
  4010. description: "云台当前操作失败",
  4011. solution: "",
  4012. updateTime: 1522034840000
  4013. },
  4014. {
  4015. moduleCode: "",
  4016. detailCode: "391101",
  4017. description: "proxy地址或端口非法",
  4018. solution: "",
  4019. updateTime: 1522034840000
  4020. },
  4021. {
  4022. moduleCode: "",
  4023. detailCode: "110004",
  4024. description: "用户不存在",
  4025. solution: "",
  4026. updateTime: 1522034840000
  4027. },
  4028. {
  4029. moduleCode: "",
  4030. detailCode: "160007",
  4031. description: "预置点个数超过最大值",
  4032. solution: "",
  4033. updateTime: 1522034840000
  4034. },
  4035. {
  4036. moduleCode: "",
  4037. detailCode: "391102",
  4038. description: "proxy生成文件描述符失败",
  4039. solution: "",
  4040. updateTime: 1522034840000
  4041. },
  4042. {
  4043. moduleCode: "",
  4044. detailCode: "110005",
  4045. description: "appKey异常",
  4046. solution: "确认appKey状态,不通过或者冻结状态会返回该错误码",
  4047. updateTime: 1522034840000
  4048. },
  4049. {
  4050. moduleCode: "",
  4051. detailCode: "160009",
  4052. description: "正在调用预置点",
  4053. solution: "",
  4054. updateTime: 1522034840000
  4055. },
  4056. {
  4057. moduleCode: "",
  4058. detailCode: "391103",
  4059. description: "proxy设置文件描述符非阻塞失败",
  4060. solution: "",
  4061. updateTime: 1522034840000
  4062. },
  4063. {
  4064. moduleCode: "",
  4065. detailCode: "110006",
  4066. description: "ip受限",
  4067. solution: "",
  4068. updateTime: 1522034840000
  4069. },
  4070. {
  4071. moduleCode: "",
  4072. detailCode: "160010",
  4073. description: "该预置点已经是当前位置",
  4074. solution: "",
  4075. updateTime: 1522034840000
  4076. },
  4077. {
  4078. moduleCode: "",
  4079. detailCode: "391104",
  4080. description: "proxy设置文件描述符阻塞失败",
  4081. solution: "",
  4082. updateTime: 1522034840000
  4083. },
  4084. {
  4085. moduleCode: "",
  4086. detailCode: "160011",
  4087. description: "预置点不存在",
  4088. solution: "",
  4089. updateTime: 1522034840000
  4090. },
  4091. {
  4092. moduleCode: "",
  4093. detailCode: "391105",
  4094. description: "proxy解析服务器ip失败",
  4095. solution: "",
  4096. updateTime: 1522034840000
  4097. },
  4098. {
  4099. moduleCode: "",
  4100. detailCode: "110008",
  4101. description: "签名错误",
  4102. solution: "①获取签名方式详见apidemo及[旧]API文档 ②注意编码格式为UTF-8",
  4103. updateTime: 1522034840000
  4104. },
  4105. {
  4106. moduleCode: "",
  4107. detailCode: "160013",
  4108. description: "设备版本已是最新",
  4109. solution: "",
  4110. updateTime: 1522034840000
  4111. },
  4112. {
  4113. moduleCode: "",
  4114. detailCode: "391106",
  4115. description: "proxy描述符select失败",
  4116. solution: "",
  4117. updateTime: 1522034840000
  4118. },
  4119. {
  4120. moduleCode: "",
  4121. detailCode: "110009",
  4122. description: "签名参数错误",
  4123. solution: "",
  4124. updateTime: 1522034840000
  4125. },
  4126. {
  4127. moduleCode: "",
  4128. detailCode: "160014",
  4129. description: "设备正在升级",
  4130. solution: "",
  4131. updateTime: 1522034840000
  4132. },
  4133. {
  4134. moduleCode: "",
  4135. detailCode: "391107",
  4136. description: "proxy文件描述符不在可读中",
  4137. solution: "",
  4138. updateTime: 1522034840000
  4139. },
  4140. {
  4141. moduleCode: "",
  4142. detailCode: "110010",
  4143. description: "签名超时",
  4144. solution: "请调用同步服务器时间接口进行校时",
  4145. updateTime: 1522034840000
  4146. },
  4147. {
  4148. moduleCode: "",
  4149. detailCode: "160015",
  4150. description: "设备正在重启",
  4151. solution: "",
  4152. updateTime: 1522034840000
  4153. },
  4154. {
  4155. moduleCode: "",
  4156. detailCode: "391108",
  4157. description: "proxy网络发生错误getsockopt",
  4158. solution: "",
  4159. updateTime: 1522034840000
  4160. },
  4161. {
  4162. moduleCode: "",
  4163. detailCode: "110011",
  4164. description: "未开通服务",
  4165. solution: "参照绑定流程",
  4166. updateTime: 1522034840000
  4167. },
  4168. {
  4169. moduleCode: "",
  4170. detailCode: "160016",
  4171. description: "加密未开启,无须关闭",
  4172. solution: "",
  4173. updateTime: 1522034840000
  4174. },
  4175. {
  4176. moduleCode: "",
  4177. detailCode: "391109",
  4178. description: "proxy描述符select超时",
  4179. solution: "",
  4180. updateTime: 1522034840000
  4181. },
  4182. {
  4183. moduleCode: "",
  4184. detailCode: "110012",
  4185. description: "第三方账户与萤石账号已经绑定",
  4186. solution: "",
  4187. updateTime: 1522034840000
  4188. },
  4189. {
  4190. moduleCode: "",
  4191. detailCode: "160017",
  4192. description: "设备抓图失败",
  4193. solution: "",
  4194. updateTime: 1522034840000
  4195. },
  4196. {
  4197. moduleCode: "",
  4198. detailCode: "391201",
  4199. description: "vtdu地址或端口非法",
  4200. solution: "",
  4201. updateTime: 1522034840000
  4202. },
  4203. {
  4204. moduleCode: "",
  4205. detailCode: "110013",
  4206. description: "应用没有权限调用此接口",
  4207. solution: "",
  4208. updateTime: 1522034840000
  4209. },
  4210. {
  4211. moduleCode: "",
  4212. detailCode: "160018",
  4213. description: "设备升级失败",
  4214. solution: "",
  4215. updateTime: 1522034840000
  4216. },
  4217. {
  4218. moduleCode: "",
  4219. detailCode: "391202",
  4220. description: "vtdu生成文件描述符失败",
  4221. solution: "",
  4222. updateTime: 1522034840000
  4223. },
  4224. {
  4225. moduleCode: "",
  4226. detailCode: "110014",
  4227. description: "APPKEY下对应的第三方userId和phone未绑定",
  4228. solution: "获取AccessToken时所用appKey与SDK所用appKey不一致",
  4229. updateTime: 1522034840000
  4230. },
  4231. {
  4232. moduleCode: "",
  4233. detailCode: "160019",
  4234. description: "加密已开启",
  4235. solution: "",
  4236. updateTime: 1522034840000
  4237. },
  4238. {
  4239. moduleCode: "",
  4240. detailCode: "391203",
  4241. description: "vtdu设置文件描述符非阻塞失败",
  4242. solution: "",
  4243. updateTime: 1522034840000
  4244. },
  4245. {
  4246. moduleCode: "",
  4247. detailCode: "110017",
  4248. description: "appKey不存在",
  4249. solution: "请填写在官网申请的应用秘钥",
  4250. updateTime: 1522034840000
  4251. },
  4252. {
  4253. moduleCode: "",
  4254. detailCode: "160020",
  4255. description: "不支持该命令",
  4256. solution: "请确认设备是否支持该命令",
  4257. updateTime: 1522034840000
  4258. },
  4259. {
  4260. moduleCode: "",
  4261. detailCode: "391204",
  4262. description: "vtdu设置文件描述符阻塞失败",
  4263. solution: "",
  4264. updateTime: 1522034840000
  4265. },
  4266. {
  4267. moduleCode: "",
  4268. detailCode: "110018",
  4269. description: "AccessToken与Appkey不匹配",
  4270. solution: "请检查获取accessToken对应的appKey和SDK中设置的appKey是否一致",
  4271. updateTime: 1522034840000
  4272. },
  4273. {
  4274. moduleCode: "",
  4275. detailCode: "160023",
  4276. description: "订阅操作失败",
  4277. solution: "",
  4278. updateTime: 1522034840000
  4279. },
  4280. {
  4281. moduleCode: "",
  4282. detailCode: "110019",
  4283. description: "密码错误",
  4284. solution: "",
  4285. updateTime: 1522034840000
  4286. },
  4287. {
  4288. moduleCode: "",
  4289. detailCode: "160024",
  4290. description: "取消订阅操作失败",
  4291. solution: "",
  4292. updateTime: 1522034840000
  4293. },
  4294. {
  4295. moduleCode: "",
  4296. detailCode: "110020",
  4297. description: "请求方法为空",
  4298. solution: "",
  4299. updateTime: 1522034840000
  4300. },
  4301. {
  4302. moduleCode: "",
  4303. detailCode: "160025",
  4304. description: "客流统计配置失败",
  4305. solution: "",
  4306. updateTime: 1522034840000
  4307. },
  4308. {
  4309. moduleCode: "",
  4310. detailCode: "110021",
  4311. description: "ticket校验失败",
  4312. solution: "",
  4313. updateTime: 1522034840000
  4314. },
  4315. {
  4316. moduleCode: "",
  4317. detailCode: "160026",
  4318. description: "设备处于隐私遮蔽状态",
  4319. solution: "",
  4320. updateTime: 1522034840000
  4321. },
  4322. {
  4323. moduleCode: "",
  4324. detailCode: "110022",
  4325. description: "透传目的地非法",
  4326. solution: "",
  4327. updateTime: 1522034840000
  4328. },
  4329. {
  4330. moduleCode: "",
  4331. detailCode: "160027",
  4332. description: "设备正在镜像操作",
  4333. solution: "",
  4334. updateTime: 1522034840000
  4335. },
  4336. {
  4337. moduleCode: "",
  4338. detailCode: "110024",
  4339. description: "无透传权限",
  4340. solution: "",
  4341. updateTime: 1522034840000
  4342. },
  4343. {
  4344. moduleCode: "",
  4345. detailCode: "160028",
  4346. description: "设备正在键控动作",
  4347. solution: "",
  4348. updateTime: 1522034840000
  4349. },
  4350. {
  4351. moduleCode: "",
  4352. detailCode: "110025",
  4353. description: "appKey被禁止使用通明通道",
  4354. solution: "",
  4355. updateTime: 1522034840000
  4356. },
  4357. {
  4358. moduleCode: "",
  4359. detailCode: "160029",
  4360. description: "设备处于语音对讲状态",
  4361. solution: "",
  4362. updateTime: 1522034840000
  4363. },
  4364. {
  4365. moduleCode: "",
  4366. detailCode: "160030",
  4367. description: "卡密输入错误次数过多,24小时后再输入",
  4368. solution: "",
  4369. updateTime: 1522034840000
  4370. },
  4371. {
  4372. moduleCode: "",
  4373. detailCode: "160031",
  4374. description: "卡密信息不存在",
  4375. solution: "",
  4376. updateTime: 1522034840000
  4377. },
  4378. {
  4379. moduleCode: "",
  4380. detailCode: "160032",
  4381. description: "卡密状态不对或已过期",
  4382. solution: "",
  4383. updateTime: 1522034840000
  4384. },
  4385. {
  4386. moduleCode: "",
  4387. detailCode: "160033",
  4388. description: "卡密非卖品,只能开通对应的绑定设备",
  4389. solution: "",
  4390. updateTime: 1522034840000
  4391. },
  4392. {
  4393. moduleCode: "",
  4394. detailCode: "110030",
  4395. description: "appKey和appSecret不匹配",
  4396. solution: "请检查appKey和appSecret是否对应",
  4397. updateTime: 1522034840000
  4398. },
  4399. {
  4400. moduleCode: "",
  4401. detailCode: "160035",
  4402. description: "购买云存储服务失败",
  4403. solution: "",
  4404. updateTime: 1522034840000
  4405. },
  4406. {
  4407. moduleCode: "",
  4408. detailCode: "110031",
  4409. description: "子账户或萤石用户没有权限",
  4410. solution: "",
  4411. updateTime: 1522034840000
  4412. },
  4413. {
  4414. moduleCode: "",
  4415. detailCode: "160040",
  4416. description: "添加的设备不在同一局域网",
  4417. solution: "",
  4418. updateTime: 1522034840000
  4419. },
  4420. {
  4421. moduleCode: "",
  4422. detailCode: "110032",
  4423. description: "子账户不存在",
  4424. solution: "",
  4425. updateTime: 1522034840000
  4426. },
  4427. {
  4428. moduleCode: "",
  4429. detailCode: "160041",
  4430. description: "添加的设备被其他设备关联或响应超时",
  4431. solution: "",
  4432. updateTime: 1522034840000
  4433. },
  4434. {
  4435. moduleCode: "",
  4436. detailCode: "110033",
  4437. description: "子账户未设置授权策略",
  4438. solution: "",
  4439. updateTime: 1522034840000
  4440. },
  4441. {
  4442. moduleCode: "",
  4443. detailCode: "160042",
  4444. description: "添加的设备密码错误",
  4445. solution: "",
  4446. updateTime: 1522034840000
  4447. },
  4448. {
  4449. moduleCode: "",
  4450. detailCode: "110034",
  4451. description: "子账户已存在",
  4452. solution: "",
  4453. updateTime: 1522034840000
  4454. },
  4455. {
  4456. moduleCode: "",
  4457. detailCode: "160043",
  4458. description: "添加的设备超出最大数量",
  4459. solution: "",
  4460. updateTime: 1522034840000
  4461. },
  4462. {
  4463. moduleCode: "",
  4464. detailCode: "110035",
  4465. description: "获取子账户AccessToken异常",
  4466. solution: "",
  4467. updateTime: 1522034840000
  4468. },
  4469. {
  4470. moduleCode: "",
  4471. detailCode: "160044",
  4472. description: "添加的设备网络不可达超时",
  4473. solution: "",
  4474. updateTime: 1522034840000
  4475. },
  4476. {
  4477. moduleCode: "",
  4478. detailCode: "110036",
  4479. description: "子账户被禁用",
  4480. solution: "",
  4481. updateTime: 1522034840000
  4482. },
  4483. {
  4484. moduleCode: "",
  4485. detailCode: "160045",
  4486. description: "添加的设备的IP和其他通道的IP冲突",
  4487. solution: "",
  4488. updateTime: 1522034840000
  4489. },
  4490. {
  4491. moduleCode: "",
  4492. detailCode: "110051",
  4493. description: "无权限进行抓图",
  4494. solution: "",
  4495. updateTime: 1522034840000
  4496. },
  4497. {
  4498. moduleCode: "",
  4499. detailCode: "160046",
  4500. description: "添加的设备的IP和本设备的IP冲突",
  4501. solution: "",
  4502. updateTime: 1522034840000
  4503. },
  4504. {
  4505. moduleCode: "",
  4506. detailCode: "160047",
  4507. description: "码流类型不支持",
  4508. solution: "",
  4509. updateTime: 1522034840000
  4510. },
  4511. {
  4512. moduleCode: "",
  4513. detailCode: "120002",
  4514. description: "设备不存在",
  4515. solution: "①设备没有注册到平台,请检查下设备网络参数,确保能正常连接网络②设备序列号不存在",
  4516. updateTime: 1522034840000
  4517. },
  4518. {
  4519. moduleCode: "",
  4520. detailCode: "160048",
  4521. description: "带宽超出系统接入带宽",
  4522. solution: "",
  4523. updateTime: 1522034840000
  4524. },
  4525. {
  4526. moduleCode: "",
  4527. detailCode: "120003",
  4528. description: "参数异常,SDK版本过低",
  4529. solution: "",
  4530. updateTime: 1522034840000
  4531. },
  4532. {
  4533. moduleCode: "",
  4534. detailCode: "160049",
  4535. description: "IP或者端口不合法",
  4536. solution: "",
  4537. updateTime: 1522034840000
  4538. },
  4539. {
  4540. moduleCode: "",
  4541. detailCode: "120004",
  4542. description: "参数异常,SDK版本过低",
  4543. solution: "",
  4544. updateTime: 1522034840000
  4545. },
  4546. {
  4547. moduleCode: "",
  4548. detailCode: "160050",
  4549. description: "添加的设备版本不支持需要升级才能接入",
  4550. solution: "",
  4551. updateTime: 1522034840000
  4552. },
  4553. {
  4554. moduleCode: "",
  4555. detailCode: "120005",
  4556. description: "安全认证失败,需进行SDK安全认证",
  4557. solution: "已去掉安全验证",
  4558. updateTime: 1522034840000
  4559. },
  4560. {
  4561. moduleCode: "",
  4562. detailCode: "160051",
  4563. description: "添加的设备不支持接入",
  4564. solution: "",
  4565. updateTime: 1522034840000
  4566. },
  4567. {
  4568. moduleCode: "",
  4569. detailCode: "120006",
  4570. description: "网络异常",
  4571. solution: "",
  4572. updateTime: 1522034840000
  4573. },
  4574. {
  4575. moduleCode: "",
  4576. detailCode: "160052",
  4577. description: "添加的设备通道号出错",
  4578. solution: "",
  4579. updateTime: 1522034840000
  4580. },
  4581. {
  4582. moduleCode: "",
  4583. detailCode: "120007",
  4584. description: "设备不在线",
  4585. solution: "参考服务中心排查方法",
  4586. updateTime: 1522034840000
  4587. },
  4588. {
  4589. moduleCode: "",
  4590. detailCode: "160053",
  4591. description: "添加的设备分辨率不支持",
  4592. solution: "",
  4593. updateTime: 1522034840000
  4594. },
  4595. {
  4596. moduleCode: "",
  4597. detailCode: "120008",
  4598. description: "设备响应超时",
  4599. solution: "设备响应超时,请检测设备网络或重试",
  4600. updateTime: 1522034840000
  4601. },
  4602. {
  4603. moduleCode: "",
  4604. detailCode: "160054",
  4605. description: "添加的设备账号被锁定",
  4606. solution: "",
  4607. updateTime: 1522034840000
  4608. },
  4609. {
  4610. moduleCode: "",
  4611. detailCode: "120009",
  4612. description: "子账号不能添加设备",
  4613. solution: "",
  4614. updateTime: 1522034840000
  4615. },
  4616. {
  4617. moduleCode: "",
  4618. detailCode: "160055",
  4619. description: "添加的设备取码流出错",
  4620. solution: "",
  4621. updateTime: 1522034840000
  4622. },
  4623. {
  4624. moduleCode: "",
  4625. detailCode: "120010",
  4626. description: "设备验证码错误",
  4627. solution: "验证码在设备标签上,六位大写字母,注意大小写",
  4628. updateTime: 1522034840000
  4629. },
  4630. {
  4631. moduleCode: "",
  4632. detailCode: "160056",
  4633. description: "删除设备失败",
  4634. solution: "",
  4635. updateTime: 1522034840000
  4636. },
  4637. {
  4638. moduleCode: "",
  4639. detailCode: "120012",
  4640. description: "设备添加失败",
  4641. solution: "",
  4642. updateTime: 1522034840000
  4643. },
  4644. {
  4645. moduleCode: "",
  4646. detailCode: "160057",
  4647. description: "删除的设备未关联",
  4648. solution: "检查IPC与NVR是否有关联关系",
  4649. updateTime: 1522034840000
  4650. },
  4651. {
  4652. moduleCode: "",
  4653. detailCode: "120013",
  4654. description: "设备已被别人添加",
  4655. solution: "",
  4656. updateTime: 1522034840000
  4657. },
  4658. {
  4659. moduleCode: "",
  4660. detailCode: "160060",
  4661. description: "地址未绑定",
  4662. solution: "请前往官网设置直播",
  4663. updateTime: 1522034840000
  4664. },
  4665. {
  4666. moduleCode: "",
  4667. detailCode: "120014",
  4668. description: "设备序列号不正确",
  4669. solution: "",
  4670. updateTime: 1522034840000
  4671. },
  4672. {
  4673. moduleCode: "",
  4674. detailCode: "160061",
  4675. description: "账户流量已超出或未购买,限制开通",
  4676. solution: "",
  4677. updateTime: 1522034840000
  4678. },
  4679. {
  4680. moduleCode: "",
  4681. detailCode: "120015",
  4682. description: "设备不支持该功能",
  4683. solution: "",
  4684. updateTime: 1522034840000
  4685. },
  4686. {
  4687. moduleCode: "",
  4688. detailCode: "160062",
  4689. description: "该通道直播已开通",
  4690. solution: "",
  4691. updateTime: 1522034840000
  4692. },
  4693. {
  4694. moduleCode: "",
  4695. detailCode: "120016",
  4696. description: "当前设备正在格式化",
  4697. solution: "",
  4698. updateTime: 1522034840000
  4699. },
  4700. {
  4701. moduleCode: "",
  4702. detailCode: "160063",
  4703. description: "直播未使用或直播已关闭",
  4704. solution: "",
  4705. updateTime: 1522034840000
  4706. },
  4707. {
  4708. moduleCode: "",
  4709. detailCode: "120017",
  4710. description: "设备已被自己添加",
  4711. solution: "",
  4712. updateTime: 1522034840000
  4713. },
  4714. {
  4715. moduleCode: "",
  4716. detailCode: "160070",
  4717. description: "设备不能转移给自己",
  4718. solution: "",
  4719. updateTime: 1522034840000
  4720. },
  4721. {
  4722. moduleCode: "",
  4723. detailCode: "120018",
  4724. description: "该用户不拥有该设备",
  4725. solution: "确认设备是否属于用户",
  4726. updateTime: 1522034840000
  4727. },
  4728. {
  4729. moduleCode: "",
  4730. detailCode: "160071",
  4731. description: "设备不能转移,设备与其他设备存在关联关系",
  4732. solution: "",
  4733. updateTime: 1522034840000
  4734. },
  4735. {
  4736. moduleCode: "",
  4737. detailCode: "400001",
  4738. description: "参数为空",
  4739. solution: "",
  4740. updateTime: 1522034840000
  4741. },
  4742. {
  4743. moduleCode: "",
  4744. detailCode: "120019",
  4745. description: "设备不支持云存储服务",
  4746. solution: "",
  4747. updateTime: 1522034840000
  4748. },
  4749. {
  4750. moduleCode: "",
  4751. detailCode: "160072",
  4752. description: "设备不能转移,通道被分享给其他用户或者分享到视频广场",
  4753. solution: "",
  4754. updateTime: 1522034840000
  4755. },
  4756. {
  4757. moduleCode: "",
  4758. detailCode: "400002",
  4759. description: "参数错误",
  4760. solution: "",
  4761. updateTime: 1522034840000
  4762. },
  4763. {
  4764. moduleCode: "",
  4765. detailCode: "120020",
  4766. description: "设备在线,被自己添加",
  4767. solution: "",
  4768. updateTime: 1522034840000
  4769. },
  4770. {
  4771. moduleCode: "",
  4772. detailCode: "160073",
  4773. description: "云存储转移失败",
  4774. solution: "",
  4775. updateTime: 1522034840000
  4776. },
  4777. {
  4778. moduleCode: "",
  4779. detailCode: "400025",
  4780. description: "设备不支持对讲",
  4781. solution: "",
  4782. updateTime: 1522034840000
  4783. },
  4784. {
  4785. moduleCode: "",
  4786. detailCode: "120021",
  4787. description: "设备在线,但是未被用户添加",
  4788. solution: "",
  4789. updateTime: 1522034840000
  4790. },
  4791. {
  4792. moduleCode: "",
  4793. detailCode: "160080",
  4794. description: "当前正在声源定位",
  4795. solution: "",
  4796. updateTime: 1522034840000
  4797. },
  4798. {
  4799. moduleCode: "",
  4800. detailCode: "400029",
  4801. description: "没有初始化或资源被释放",
  4802. solution: "",
  4803. updateTime: 1522034840000
  4804. },
  4805. {
  4806. moduleCode: "",
  4807. detailCode: "120022",
  4808. description: "设备在线,但是已经被别的用户添加",
  4809. solution: "",
  4810. updateTime: 1522034840000
  4811. },
  4812. {
  4813. moduleCode: "",
  4814. detailCode: "160081",
  4815. description: "当前正在轨迹巡航",
  4816. solution: "",
  4817. updateTime: 1522034840000
  4818. },
  4819. {
  4820. moduleCode: "",
  4821. detailCode: "400030",
  4822. description: "json解析异常",
  4823. solution: "",
  4824. updateTime: 1522034840000
  4825. },
  4826. {
  4827. moduleCode: "",
  4828. detailCode: "120023",
  4829. description: "设备不在线,未被用户添加",
  4830. solution: "",
  4831. updateTime: 1522034840000
  4832. },
  4833. {
  4834. moduleCode: "",
  4835. detailCode: "160082",
  4836. description: "设备正在响应本次声源定位",
  4837. solution: "",
  4838. updateTime: 1522034840000
  4839. },
  4840. {
  4841. moduleCode: "",
  4842. detailCode: "400031",
  4843. description: "网络异常",
  4844. solution: "",
  4845. updateTime: 1522034840000
  4846. },
  4847. {
  4848. moduleCode: "",
  4849. detailCode: "120024",
  4850. description: "设备不在线,但是已经被别的用户添加",
  4851. solution: "",
  4852. updateTime: 1522034840000
  4853. },
  4854. {
  4855. moduleCode: "",
  4856. detailCode: "160083",
  4857. description: "当前正在开启隐私遮蔽",
  4858. solution: "设备正在操作隐私遮蔽,无法进行当前操作",
  4859. updateTime: 1522034840000
  4860. },
  4861. {
  4862. moduleCode: "",
  4863. detailCode: "400032",
  4864. description: "设备信息异常为空",
  4865. solution: "",
  4866. updateTime: 1522034840000
  4867. },
  4868. {
  4869. moduleCode: "",
  4870. detailCode: "120025",
  4871. description: "重复申请分享",
  4872. solution: "确认设备是否由添加过该设备且申请过分享的账户下是否还存在分享记录",
  4873. updateTime: 1522034840000
  4874. },
  4875. {
  4876. moduleCode: "",
  4877. detailCode: "160084",
  4878. description: "当前正在关闭隐私遮蔽",
  4879. solution: "设备正在操作隐私遮蔽,无法进行当前操作",
  4880. updateTime: 1522034840000
  4881. },
  4882. {
  4883. moduleCode: "",
  4884. detailCode: "400034",
  4885. description: "取流超时",
  4886. solution: "一般是由于网络状况不好导致,可以尝试下让用户重新播放",
  4887. updateTime: 1522034840000
  4888. },
  4889. {
  4890. moduleCode: "",
  4891. detailCode: "120026",
  4892. description: "视频广场不存在该视频",
  4893. solution: "",
  4894. updateTime: 1522034840000
  4895. },
  4896. {
  4897. moduleCode: "",
  4898. detailCode: "380290",
  4899. description: " 连接CAS服务器失败",
  4900. solution: "",
  4901. updateTime: 1522034840000
  4902. },
  4903. {
  4904. moduleCode: "",
  4905. detailCode: "400035",
  4906. description: "设备已加密,需要输入验证码",
  4907. solution: "收到此错误码,需要让用户输入验证码后,调用EZPlayer.setPlayKey传入验证码,并重新调用播放函数",
  4908. updateTime: 1522034840000
  4909. },
  4910. {
  4911. moduleCode: "",
  4912. detailCode: "120027",
  4913. description: "视频转码失败",
  4914. solution: "",
  4915. updateTime: 1522034840000
  4916. },
  4917. {
  4918. moduleCode: "",
  4919. detailCode: "361001",
  4920. description: "对讲服务端排队超时",
  4921. solution: "",
  4922. updateTime: 1522034840000
  4923. },
  4924. {
  4925. moduleCode: "",
  4926. detailCode: "400036",
  4927. description: "播放验证码错误",
  4928. solution: "收到此错误码,需要让用户输入验证码后,调用EZPlayer.setPlayKey传入验证码,并重新调用播放函数",
  4929. updateTime: 1522034840000
  4930. },
  4931. {
  4932. moduleCode: "",
  4933. detailCode: "120028",
  4934. description: "设备固件升级包不存在",
  4935. solution: "",
  4936. updateTime: 1522034840000
  4937. },
  4938. {
  4939. moduleCode: "",
  4940. detailCode: "361002",
  4941. description: "对讲服务端处理超时",
  4942. solution: "",
  4943. updateTime: 1522034840000
  4944. },
  4945. {
  4946. moduleCode: "",
  4947. detailCode: "400037",
  4948. description: "surfacehold错误",
  4949. solution: "请检查是否是播放之前销毁了surface,收到此错误也可以重新建立surface后播放",
  4950. updateTime: 1522034840000
  4951. },
  4952. {
  4953. moduleCode: "",
  4954. detailCode: "120029",
  4955. description: "设备不在线,但是已经被自己添加",
  4956. solution: "",
  4957. updateTime: 1522034840000
  4958. },
  4959. {
  4960. moduleCode: "",
  4961. detailCode: "361003",
  4962. description: "设备链接对讲服务器超时",
  4963. solution: "",
  4964. updateTime: 1522034840000
  4965. },
  4966. {
  4967. moduleCode: "",
  4968. detailCode: "400100",
  4969. description: "未知错误",
  4970. solution: "",
  4971. updateTime: 1522034840000
  4972. },
  4973. {
  4974. moduleCode: "",
  4975. detailCode: "120030",
  4976. description: "该用户不拥有该视频广场视频",
  4977. solution: "",
  4978. updateTime: 1522034840000
  4979. },
  4980. {
  4981. moduleCode: "",
  4982. detailCode: "361004",
  4983. description: "服务器内部错误",
  4984. solution: "",
  4985. updateTime: 1522034840000
  4986. },
  4987. {
  4988. moduleCode: "",
  4989. detailCode: "400200",
  4990. description: "player sdk出错,这种错误一般开发者也是无法解决,不具体分类传出,传一个统一的inner错误码出去",
  4991. solution: "",
  4992. updateTime: 1522034840000
  4993. },
  4994. {
  4995. moduleCode: "",
  4996. detailCode: "120031",
  4997. description: "开启终端绑定,硬件特征码验证失败",
  4998. solution: "请在萤石客户端关闭终端绑定,参考此步骤",
  4999. updateTime: 1522034840000
  5000. },
  5001. {
  5002. moduleCode: "",
  5003. detailCode: "361005",
  5004. description: "解析消息失败",
  5005. solution: "",
  5006. updateTime: 1522034840000
  5007. },
  5008. {
  5009. moduleCode: "",
  5010. detailCode: "400300",
  5011. description: "内存溢出",
  5012. solution: "",
  5013. updateTime: 1522034840000
  5014. },
  5015. {
  5016. moduleCode: "",
  5017. detailCode: "120032",
  5018. description: "该用户下通道不存在",
  5019. solution: "",
  5020. updateTime: 1522034840000
  5021. },
  5022. {
  5023. moduleCode: "",
  5024. detailCode: "361006",
  5025. description: "请求重定向--需要向其他服务申请对讲",
  5026. solution: "",
  5027. updateTime: 1522034840000
  5028. },
  5029. {
  5030. moduleCode: "",
  5031. detailCode: "400901",
  5032. description: "设备不在线,可以提示用户",
  5033. solution: "",
  5034. updateTime: 1522034840000
  5035. },
  5036. {
  5037. moduleCode: "",
  5038. detailCode: "120033",
  5039. description: "无法收藏自己分享的视频",
  5040. solution: "",
  5041. updateTime: 1522034840000
  5042. },
  5043. {
  5044. moduleCode: "",
  5045. detailCode: "361007",
  5046. description: "请求url非法",
  5047. solution: "",
  5048. updateTime: 1522034840000
  5049. },
  5050. {
  5051. moduleCode: "",
  5052. detailCode: "400902",
  5053. description: "accesstoken异常或失效,需要重新获取accesstoken,并传入到sdk",
  5054. solution: "",
  5055. updateTime: 1522034840000
  5056. },
  5057. {
  5058. moduleCode: "",
  5059. detailCode: "120034",
  5060. description: "该用户下无设备",
  5061. solution: "",
  5062. updateTime: 1522034840000
  5063. },
  5064. {
  5065. moduleCode: "",
  5066. detailCode: "361008",
  5067. description: "token失效",
  5068. solution: "",
  5069. updateTime: 1522034840000
  5070. },
  5071. {
  5072. moduleCode: "",
  5073. detailCode: "400903",
  5074. description: "当前账号开启了终端绑定,只允许指定设备登录操作,提示用户登录i.ys7.com解除终端绑定",
  5075. solution: "",
  5076. updateTime: 1522034840000
  5077. },
  5078. {
  5079. moduleCode: "",
  5080. detailCode: "120090",
  5081. description: "用户反馈失败",
  5082. solution: "",
  5083. updateTime: 1522034840000
  5084. },
  5085. {
  5086. moduleCode: "",
  5087. detailCode: "361009",
  5088. description: "设备验证码或者通信秘钥不匹配",
  5089. solution: "",
  5090. updateTime: 1522034840000
  5091. },
  5092. {
  5093. moduleCode: "",
  5094. detailCode: "400904",
  5095. description: "设备正在对讲中",
  5096. solution: "",
  5097. updateTime: 1522034840000
  5098. },
  5099. {
  5100. moduleCode: "",
  5101. detailCode: "120095",
  5102. description: "APP包下载失败",
  5103. solution: "",
  5104. updateTime: 1522034840000
  5105. },
  5106. {
  5107. moduleCode: "",
  5108. detailCode: "361010",
  5109. description: "设备已经在对讲",
  5110. solution: "",
  5111. updateTime: 1522034840000
  5112. },
  5113. {
  5114. moduleCode: "",
  5115. detailCode: "400905",
  5116. description: "设备开启了隐私保护,不允许预览、对讲等",
  5117. solution: "",
  5118. updateTime: 1522034840000
  5119. },
  5120. {
  5121. moduleCode: "",
  5122. detailCode: "120096",
  5123. description: "APP包信息删除失败",
  5124. solution: "",
  5125. updateTime: 1522034840000
  5126. },
  5127. {
  5128. moduleCode: "",
  5129. detailCode: "361011",
  5130. description: "设备10s响应超时",
  5131. solution: "",
  5132. updateTime: 1522034840000
  5133. },
  5134. {
  5135. moduleCode: "",
  5136. detailCode: "120101",
  5137. description: "视频不支持分享给本人",
  5138. solution: "",
  5139. updateTime: 1522034840000
  5140. },
  5141. {
  5142. moduleCode: "",
  5143. detailCode: "361012",
  5144. description: "设备不在线",
  5145. solution: "",
  5146. updateTime: 1522034840000
  5147. },
  5148. {
  5149. moduleCode: "",
  5150. detailCode: "320002",
  5151. description: "参数无效",
  5152. solution: "",
  5153. updateTime: 1522034840000
  5154. },
  5155. {
  5156. moduleCode: "",
  5157. detailCode: "120102",
  5158. description: "无相应邀请信息",
  5159. solution: "",
  5160. updateTime: 1522034840000
  5161. },
  5162. {
  5163. moduleCode: "",
  5164. detailCode: "361013",
  5165. description: "设备开启隐私保护拒绝对讲",
  5166. solution: "",
  5167. updateTime: 1522034840000
  5168. },
  5169. {
  5170. moduleCode: "",
  5171. detailCode: "320003",
  5172. description: "暂不支持此操作",
  5173. solution: "",
  5174. updateTime: 1522034840000
  5175. },
  5176. {
  5177. moduleCode: "",
  5178. detailCode: "120103",
  5179. description: "好友已存在",
  5180. solution: "",
  5181. updateTime: 1522034840000
  5182. },
  5183. {
  5184. moduleCode: "",
  5185. detailCode: "361014",
  5186. description: "token无权限",
  5187. solution: "",
  5188. updateTime: 1522034840000
  5189. },
  5190. {
  5191. moduleCode: "",
  5192. detailCode: "320004",
  5193. description: "内存溢出",
  5194. solution: "",
  5195. updateTime: 1522034840000
  5196. },
  5197. {
  5198. moduleCode: "",
  5199. detailCode: "120104",
  5200. description: "好友不存在",
  5201. solution: "",
  5202. updateTime: 1522034840000
  5203. },
  5204. {
  5205. moduleCode: "",
  5206. detailCode: "361015",
  5207. description: "设备返回session不存在",
  5208. solution: "",
  5209. updateTime: 1522034840000
  5210. },
  5211. {
  5212. moduleCode: "",
  5213. detailCode: "320005",
  5214. description: "创建CAS session失败",
  5215. solution: "",
  5216. updateTime: 1522034840000
  5217. },
  5218. {
  5219. moduleCode: "",
  5220. detailCode: "120105",
  5221. description: "好友状态错误",
  5222. solution: "",
  5223. updateTime: 1522034840000
  5224. },
  5225. {
  5226. moduleCode: "",
  5227. detailCode: "361016",
  5228. description: "验证token其他异常错误",
  5229. solution: "",
  5230. updateTime: 1522034840000
  5231. },
  5232. {
  5233. moduleCode: "",
  5234. detailCode: "320006",
  5235. description: "创建cloud session失败",
  5236. solution: "",
  5237. updateTime: 1522034840000
  5238. },
  5239. {
  5240. moduleCode: "",
  5241. detailCode: "120106",
  5242. description: "对应群组不存在",
  5243. solution: "",
  5244. updateTime: 1522034840000
  5245. },
  5246. {
  5247. moduleCode: "",
  5248. detailCode: "361017",
  5249. description: "服务端监听设备建立端口超时",
  5250. solution: "",
  5251. updateTime: 1522034840000
  5252. },
  5253. {
  5254. moduleCode: "",
  5255. detailCode: "320007",
  5256. description: "token失效",
  5257. solution: "重新设置token后再重试",
  5258. updateTime: 1522034840000
  5259. },
  5260. {
  5261. moduleCode: "",
  5262. detailCode: "120107",
  5263. description: "不能添加自己为好友",
  5264. solution: "",
  5265. updateTime: 1522034840000
  5266. },
  5267. {
  5268. moduleCode: "",
  5269. detailCode: "361018",
  5270. description: "设备链路异常",
  5271. solution: "",
  5272. updateTime: 1522034840000
  5273. },
  5274. {
  5275. moduleCode: "",
  5276. detailCode: "320008",
  5277. description: "token池里面没有token,请传入token",
  5278. solution: "",
  5279. updateTime: 1522034840000
  5280. },
  5281. {
  5282. moduleCode: "",
  5283. detailCode: "120108",
  5284. description: "当前用户和所添加用户不是好友关系",
  5285. solution: "",
  5286. updateTime: 1522034840000
  5287. },
  5288. {
  5289. moduleCode: "",
  5290. detailCode: "361019",
  5291. description: "对讲服务端不支持的信令消息",
  5292. solution: "",
  5293. updateTime: 1522034840000
  5294. },
  5295. {
  5296. moduleCode: "",
  5297. detailCode: "320009",
  5298. description: "传入新的INIT_PARAM并reset(保留,目前未用)",
  5299. solution: "",
  5300. updateTime: 1522034840000
  5301. },
  5302. {
  5303. moduleCode: "",
  5304. detailCode: "120109",
  5305. description: "对应分享不存在",
  5306. solution: "",
  5307. updateTime: 1522034840000
  5308. },
  5309. {
  5310. moduleCode: "",
  5311. detailCode: "361020",
  5312. description: "对讲服务端解析对讲请求未携带会话描述能力集",
  5313. solution: "",
  5314. updateTime: 1522034840000
  5315. },
  5316. {
  5317. moduleCode: "",
  5318. detailCode: "320010",
  5319. description: "请重试",
  5320. solution: "",
  5321. updateTime: 1522034840000
  5322. },
  5323. {
  5324. moduleCode: "",
  5325. detailCode: "120110",
  5326. description: "好友群组不属于当前用户",
  5327. solution: "",
  5328. updateTime: 1522034840000
  5329. },
  5330. {
  5331. moduleCode: "",
  5332. detailCode: "361021",
  5333. description: "对讲服务端优先能力集结果为空",
  5334. solution: "",
  5335. updateTime: 1522034840000
  5336. },
  5337. {
  5338. moduleCode: "",
  5339. detailCode: "320011",
  5340. description: "500毫秒后请重试",
  5341. solution: "",
  5342. updateTime: 1522034840000
  5343. },
  5344. {
  5345. moduleCode: "",
  5346. detailCode: "120111",
  5347. description: "好友不是等待验证状态",
  5348. solution: "",
  5349. updateTime: 1522034840000
  5350. },
  5351. {
  5352. moduleCode: "",
  5353. detailCode: "361022",
  5354. description: "cas链路异常",
  5355. solution: "",
  5356. updateTime: 1522034840000
  5357. },
  5358. {
  5359. moduleCode: "",
  5360. detailCode: "320012",
  5361. description: "token池已满",
  5362. solution: "",
  5363. updateTime: 1522034840000
  5364. },
  5365. {
  5366. moduleCode: "",
  5367. detailCode: "120112",
  5368. description: "添加应用下的用户为好友失败",
  5369. solution: "",
  5370. updateTime: 1522034840000
  5371. },
  5372. {
  5373. moduleCode: "",
  5374. detailCode: "361023",
  5375. description: "对讲服务端分配对讲会话资源失败",
  5376. solution: "",
  5377. updateTime: 1522034840000
  5378. },
  5379. {
  5380. moduleCode: "",
  5381. detailCode: "320013",
  5382. description: "P2P client超过限制",
  5383. solution: "",
  5384. updateTime: 1522034840000
  5385. },
  5386. {
  5387. moduleCode: "",
  5388. detailCode: "120201",
  5389. description: "操作报警信息失败",
  5390. solution: "",
  5391. updateTime: 1522034840000
  5392. },
  5393. {
  5394. moduleCode: "",
  5395. detailCode: "361024",
  5396. description: "对讲服务端解析信令消息失败",
  5397. solution: "",
  5398. updateTime: 1522034840000
  5399. },
  5400. {
  5401. moduleCode: "",
  5402. detailCode: "320014",
  5403. description: "sdk未初始化",
  5404. solution: "",
  5405. updateTime: 1522034840000
  5406. },
  5407. {
  5408. moduleCode: "",
  5409. detailCode: "120202",
  5410. description: "操作留言信息失败",
  5411. solution: "",
  5412. updateTime: 1522034840000
  5413. },
  5414. {
  5415. moduleCode: "",
  5416. detailCode: "390001",
  5417. description: "通用错误返回",
  5418. solution: "",
  5419. updateTime: 1522034840000
  5420. },
  5421. {
  5422. moduleCode: "",
  5423. detailCode: "320015",
  5424. description: "超时",
  5425. solution: "",
  5426. updateTime: 1522034840000
  5427. },
  5428. {
  5429. moduleCode: "",
  5430. detailCode: "120301",
  5431. description: "根据UUID查询报警消息不存在",
  5432. solution: "",
  5433. updateTime: 1522034840000
  5434. },
  5435. {
  5436. moduleCode: "",
  5437. detailCode: "390002",
  5438. description: "入参为空指针",
  5439. solution: "",
  5440. updateTime: 1522034840000
  5441. },
  5442. {
  5443. moduleCode: "",
  5444. detailCode: "320016",
  5445. description: "正在打洞中",
  5446. solution: "",
  5447. updateTime: 1522034840000
  5448. },
  5449. {
  5450. moduleCode: "",
  5451. detailCode: "120302",
  5452. description: "根据UUID查询图片不存在",
  5453. solution: "",
  5454. updateTime: 1522034840000
  5455. },
  5456. {
  5457. moduleCode: "",
  5458. detailCode: "390003",
  5459. description: "入参值无效",
  5460. solution: "",
  5461. updateTime: 1522034840000
  5462. },
  5463. {
  5464. moduleCode: "",
  5465. detailCode: "320017",
  5466. description: "没有视频文件头(播放器层面产生和处理此错误)",
  5467. solution: "",
  5468. updateTime: 1522034840000
  5469. },
  5470. {
  5471. moduleCode: "",
  5472. detailCode: "120303",
  5473. description: "根据FID查询图片不存在",
  5474. solution: "",
  5475. updateTime: 1522034840000
  5476. },
  5477. {
  5478. moduleCode: "",
  5479. detailCode: "390004",
  5480. description: "信令消息解析非法",
  5481. solution: "",
  5482. updateTime: 1522034840000
  5483. },
  5484. {
  5485. moduleCode: "",
  5486. detailCode: "320018",
  5487. description: "解码错误/超时(播放器层面产生和处理此错误)",
  5488. solution: "",
  5489. updateTime: 1522034840000
  5490. },
  5491. {
  5492. moduleCode: "",
  5493. detailCode: "120305",
  5494. description: "设备ip解析错误",
  5495. solution: "",
  5496. updateTime: 1522034840000
  5497. },
  5498. {
  5499. moduleCode: "",
  5500. detailCode: "390005",
  5501. description: "内存资源不足",
  5502. solution: "",
  5503. updateTime: 1522034840000
  5504. },
  5505. {
  5506. moduleCode: "",
  5507. detailCode: "320019",
  5508. description: "取消(保留,用户不用处理)",
  5509. solution: "",
  5510. updateTime: 1522034840000
  5511. },
  5512. {
  5513. moduleCode: "",
  5514. detailCode: "120401",
  5515. description: "用户云空间信息不存在",
  5516. solution: "",
  5517. updateTime: 1522034840000
  5518. },
  5519. {
  5520. moduleCode: "",
  5521. detailCode: "390006",
  5522. description: "协议格式不对或者消息体长度超过STREAM_MAX_MSGBODY_LEN",
  5523. solution: "",
  5524. updateTime: 1522034840000
  5525. },
  5526. {
  5527. moduleCode: "",
  5528. detailCode: "320020",
  5529. description: "播放过程中预连接被用户清除预操作信息",
  5530. solution: "",
  5531. updateTime: 1522034840000
  5532. },
  5533. {
  5534. moduleCode: "",
  5535. detailCode: "120402",
  5536. description: "云空间操作失败",
  5537. solution: "",
  5538. updateTime: 1522034840000
  5539. },
  5540. {
  5541. moduleCode: "",
  5542. detailCode: "390007",
  5543. description: "设备序列号长度不合法",
  5544. solution: "",
  5545. updateTime: 1522034840000
  5546. },
  5547. {
  5548. moduleCode: "",
  5549. detailCode: "320021",
  5550. description: "流加密码不对",
  5551. solution: "",
  5552. updateTime: 1522034840000
  5553. },
  5554. {
  5555. moduleCode: "",
  5556. detailCode: "120403",
  5557. description: "用户目录不存在",
  5558. solution: "",
  5559. updateTime: 1522034840000
  5560. },
  5561. {
  5562. moduleCode: "",
  5563. detailCode: "390008",
  5564. description: "取流url长度不合法",
  5565. solution: "",
  5566. updateTime: 1522034840000
  5567. },
  5568. {
  5569. moduleCode: "",
  5570. detailCode: "320022",
  5571. description: "未传入播放窗口",
  5572. solution: "",
  5573. updateTime: 1522034840000
  5574. },
  5575. {
  5576. moduleCode: "",
  5577. detailCode: "120404",
  5578. description: "要操作的目标目录不存在",
  5579. solution: "",
  5580. updateTime: 1522034840000
  5581. },
  5582. {
  5583. moduleCode: "",
  5584. detailCode: "390009",
  5585. description: "解析vtm返回vtdu地址不合法",
  5586. solution: "",
  5587. updateTime: 1522034840000
  5588. },
  5589. {
  5590. moduleCode: "",
  5591. detailCode: "100200",
  5592. description: "操作成功",
  5593. solution: "",
  5594. updateTime: 1522034840000
  5595. },
  5596. {
  5597. moduleCode: "",
  5598. detailCode: "120405",
  5599. description: "要删除的文件信息不存在",
  5600. solution: "",
  5601. updateTime: 1522034840000
  5602. },
  5603. {
  5604. moduleCode: "",
  5605. detailCode: "390010",
  5606. description: "解析vtm返回级联vtdu地址不合法",
  5607. solution: "",
  5608. updateTime: 1522034840000
  5609. },
  5610. {
  5611. moduleCode: "",
  5612. detailCode: "101001",
  5613. description: "用户名不合法",
  5614. solution: "",
  5615. updateTime: 1522034840000
  5616. },
  5617. {
  5618. moduleCode: "",
  5619. detailCode: "120406",
  5620. description: "已开通云存储",
  5621. solution: "",
  5622. updateTime: 1522034840000
  5623. },
  5624. {
  5625. moduleCode: "",
  5626. detailCode: "390011",
  5627. description: "解析vtm返回会话标识长度不合法",
  5628. solution: "",
  5629. updateTime: 1522034840000
  5630. },
  5631. {
  5632. moduleCode: "",
  5633. detailCode: "101002",
  5634. description: "用户名已被占用",
  5635. solution: "",
  5636. updateTime: 1522034840000
  5637. },
  5638. {
  5639. moduleCode: "",
  5640. detailCode: "120407",
  5641. description: "开通记录失败",
  5642. solution: "",
  5643. updateTime: 1522034840000
  5644. },
  5645. {
  5646. moduleCode: "",
  5647. detailCode: "390012",
  5648. description: "vtdu返回流头长度不合法",
  5649. solution: "",
  5650. updateTime: 1522034840000
  5651. },
  5652. {
  5653. moduleCode: "",
  5654. detailCode: "101003",
  5655. description: "密码不合法",
  5656. solution: "",
  5657. updateTime: 1522034840000
  5658. },
  5659. {
  5660. moduleCode: "",
  5661. detailCode: "120500",
  5662. description: "获取数据错误",
  5663. solution: "",
  5664. updateTime: 1522034840000
  5665. },
  5666. {
  5667. moduleCode: "",
  5668. detailCode: "390013",
  5669. description: "vtdu会话长度非法",
  5670. solution: "",
  5671. updateTime: 1522034840000
  5672. },
  5673. {
  5674. moduleCode: "",
  5675. detailCode: "101004",
  5676. description: "密码为同一字符",
  5677. solution: "",
  5678. updateTime: 1522034840000
  5679. },
  5680. {
  5681. moduleCode: "",
  5682. detailCode: "120501",
  5683. description: "开锁失败",
  5684. solution: "",
  5685. updateTime: 1522034840000
  5686. },
  5687. {
  5688. moduleCode: "",
  5689. detailCode: "390014",
  5690. description: "回调函数未注册",
  5691. solution: "",
  5692. updateTime: 1522034840000
  5693. },
  5694. {
  5695. moduleCode: "",
  5696. detailCode: "101006",
  5697. description: "手机号码已经被注册",
  5698. solution: "",
  5699. updateTime: 1522034840000
  5700. },
  5701. {
  5702. moduleCode: "",
  5703. detailCode: "120502",
  5704. description: "室内机未收到呼叫",
  5705. solution: "",
  5706. updateTime: 1522034840000
  5707. },
  5708. {
  5709. moduleCode: "",
  5710. detailCode: "390015",
  5711. description: "vtdu成功响应未携带会话标识",
  5712. solution: "",
  5713. updateTime: 1522034840000
  5714. }
  5715. ];
  5716. var code = "200";
  5717. var msg$5 = "操作成功!";
  5718. var errorCode = {
  5719. data: data$5,
  5720. code: code,
  5721. msg: msg$5
  5722. };
  5723. class Code {
  5724. constructor(x, y) {
  5725. this.coreX = x;
  5726. this.coreY = y;
  5727. // console.log("ErrorCode", errorCode);
  5728. }
  5729. toString() {
  5730. return `${this.coreX}-${this.coreY}`;
  5731. }
  5732. matchErrorInfo(code) {
  5733. return errorCode.data.find(function (item) {
  5734. return item.detailCode.substr(-4) == code;
  5735. });
  5736. }
  5737. }
  5738. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  5739. function createCommonjsModule(fn, module) {
  5740. return module = { exports: {} }, fn(module, module.exports), module.exports;
  5741. }
  5742. var lodash = createCommonjsModule(function (module, exports) {
  5743. (function() {
  5744. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  5745. var undefined$1;
  5746. /** Used as the semantic version number. */
  5747. var VERSION = '4.17.21';
  5748. /** Used as the size to enable large array optimizations. */
  5749. var LARGE_ARRAY_SIZE = 200;
  5750. /** Error message constants. */
  5751. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  5752. FUNC_ERROR_TEXT = 'Expected a function',
  5753. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  5754. /** Used to stand-in for `undefined` hash values. */
  5755. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  5756. /** Used as the maximum memoize cache size. */
  5757. var MAX_MEMOIZE_SIZE = 500;
  5758. /** Used as the internal argument placeholder. */
  5759. var PLACEHOLDER = '__lodash_placeholder__';
  5760. /** Used to compose bitmasks for cloning. */
  5761. var CLONE_DEEP_FLAG = 1,
  5762. CLONE_FLAT_FLAG = 2,
  5763. CLONE_SYMBOLS_FLAG = 4;
  5764. /** Used to compose bitmasks for value comparisons. */
  5765. var COMPARE_PARTIAL_FLAG = 1,
  5766. COMPARE_UNORDERED_FLAG = 2;
  5767. /** Used to compose bitmasks for function metadata. */
  5768. var WRAP_BIND_FLAG = 1,
  5769. WRAP_BIND_KEY_FLAG = 2,
  5770. WRAP_CURRY_BOUND_FLAG = 4,
  5771. WRAP_CURRY_FLAG = 8,
  5772. WRAP_CURRY_RIGHT_FLAG = 16,
  5773. WRAP_PARTIAL_FLAG = 32,
  5774. WRAP_PARTIAL_RIGHT_FLAG = 64,
  5775. WRAP_ARY_FLAG = 128,
  5776. WRAP_REARG_FLAG = 256,
  5777. WRAP_FLIP_FLAG = 512;
  5778. /** Used as default options for `_.truncate`. */
  5779. var DEFAULT_TRUNC_LENGTH = 30,
  5780. DEFAULT_TRUNC_OMISSION = '...';
  5781. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  5782. var HOT_COUNT = 800,
  5783. HOT_SPAN = 16;
  5784. /** Used to indicate the type of lazy iteratees. */
  5785. var LAZY_FILTER_FLAG = 1,
  5786. LAZY_MAP_FLAG = 2,
  5787. LAZY_WHILE_FLAG = 3;
  5788. /** Used as references for various `Number` constants. */
  5789. var INFINITY = 1 / 0,
  5790. MAX_SAFE_INTEGER = 9007199254740991,
  5791. MAX_INTEGER = 1.7976931348623157e+308,
  5792. NAN = 0 / 0;
  5793. /** Used as references for the maximum length and index of an array. */
  5794. var MAX_ARRAY_LENGTH = 4294967295,
  5795. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  5796. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  5797. /** Used to associate wrap methods with their bit flags. */
  5798. var wrapFlags = [
  5799. ['ary', WRAP_ARY_FLAG],
  5800. ['bind', WRAP_BIND_FLAG],
  5801. ['bindKey', WRAP_BIND_KEY_FLAG],
  5802. ['curry', WRAP_CURRY_FLAG],
  5803. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  5804. ['flip', WRAP_FLIP_FLAG],
  5805. ['partial', WRAP_PARTIAL_FLAG],
  5806. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  5807. ['rearg', WRAP_REARG_FLAG]
  5808. ];
  5809. /** `Object#toString` result references. */
  5810. var argsTag = '[object Arguments]',
  5811. arrayTag = '[object Array]',
  5812. asyncTag = '[object AsyncFunction]',
  5813. boolTag = '[object Boolean]',
  5814. dateTag = '[object Date]',
  5815. domExcTag = '[object DOMException]',
  5816. errorTag = '[object Error]',
  5817. funcTag = '[object Function]',
  5818. genTag = '[object GeneratorFunction]',
  5819. mapTag = '[object Map]',
  5820. numberTag = '[object Number]',
  5821. nullTag = '[object Null]',
  5822. objectTag = '[object Object]',
  5823. promiseTag = '[object Promise]',
  5824. proxyTag = '[object Proxy]',
  5825. regexpTag = '[object RegExp]',
  5826. setTag = '[object Set]',
  5827. stringTag = '[object String]',
  5828. symbolTag = '[object Symbol]',
  5829. undefinedTag = '[object Undefined]',
  5830. weakMapTag = '[object WeakMap]',
  5831. weakSetTag = '[object WeakSet]';
  5832. var arrayBufferTag = '[object ArrayBuffer]',
  5833. dataViewTag = '[object DataView]',
  5834. float32Tag = '[object Float32Array]',
  5835. float64Tag = '[object Float64Array]',
  5836. int8Tag = '[object Int8Array]',
  5837. int16Tag = '[object Int16Array]',
  5838. int32Tag = '[object Int32Array]',
  5839. uint8Tag = '[object Uint8Array]',
  5840. uint8ClampedTag = '[object Uint8ClampedArray]',
  5841. uint16Tag = '[object Uint16Array]',
  5842. uint32Tag = '[object Uint32Array]';
  5843. /** Used to match empty string literals in compiled template source. */
  5844. var reEmptyStringLeading = /\b__p \+= '';/g,
  5845. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  5846. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  5847. /** Used to match HTML entities and HTML characters. */
  5848. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  5849. reUnescapedHtml = /[&<>"']/g,
  5850. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  5851. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  5852. /** Used to match template delimiters. */
  5853. var reEscape = /<%-([\s\S]+?)%>/g,
  5854. reEvaluate = /<%([\s\S]+?)%>/g,
  5855. reInterpolate = /<%=([\s\S]+?)%>/g;
  5856. /** Used to match property names within property paths. */
  5857. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  5858. reIsPlainProp = /^\w*$/,
  5859. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  5860. /**
  5861. * Used to match `RegExp`
  5862. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  5863. */
  5864. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  5865. reHasRegExpChar = RegExp(reRegExpChar.source);
  5866. /** Used to match leading whitespace. */
  5867. var reTrimStart = /^\s+/;
  5868. /** Used to match a single whitespace character. */
  5869. var reWhitespace = /\s/;
  5870. /** Used to match wrap detail comments. */
  5871. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  5872. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  5873. reSplitDetails = /,? & /;
  5874. /** Used to match words composed of alphanumeric characters. */
  5875. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  5876. /**
  5877. * Used to validate the `validate` option in `_.template` variable.
  5878. *
  5879. * Forbids characters which could potentially change the meaning of the function argument definition:
  5880. * - "()," (modification of function parameters)
  5881. * - "=" (default value)
  5882. * - "[]{}" (destructuring of function parameters)
  5883. * - "/" (beginning of a comment)
  5884. * - whitespace
  5885. */
  5886. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  5887. /** Used to match backslashes in property paths. */
  5888. var reEscapeChar = /\\(\\)?/g;
  5889. /**
  5890. * Used to match
  5891. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  5892. */
  5893. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  5894. /** Used to match `RegExp` flags from their coerced string values. */
  5895. var reFlags = /\w*$/;
  5896. /** Used to detect bad signed hexadecimal string values. */
  5897. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  5898. /** Used to detect binary string values. */
  5899. var reIsBinary = /^0b[01]+$/i;
  5900. /** Used to detect host constructors (Safari). */
  5901. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  5902. /** Used to detect octal string values. */
  5903. var reIsOctal = /^0o[0-7]+$/i;
  5904. /** Used to detect unsigned integer values. */
  5905. var reIsUint = /^(?:0|[1-9]\d*)$/;
  5906. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  5907. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  5908. /** Used to ensure capturing order of template delimiters. */
  5909. var reNoMatch = /($^)/;
  5910. /** Used to match unescaped characters in compiled string literals. */
  5911. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  5912. /** Used to compose unicode character classes. */
  5913. var rsAstralRange = '\\ud800-\\udfff',
  5914. rsComboMarksRange = '\\u0300-\\u036f',
  5915. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  5916. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  5917. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  5918. rsDingbatRange = '\\u2700-\\u27bf',
  5919. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  5920. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  5921. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  5922. rsPunctuationRange = '\\u2000-\\u206f',
  5923. 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',
  5924. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  5925. rsVarRange = '\\ufe0e\\ufe0f',
  5926. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  5927. /** Used to compose unicode capture groups. */
  5928. var rsApos = "['\u2019]",
  5929. rsAstral = '[' + rsAstralRange + ']',
  5930. rsBreak = '[' + rsBreakRange + ']',
  5931. rsCombo = '[' + rsComboRange + ']',
  5932. rsDigits = '\\d+',
  5933. rsDingbat = '[' + rsDingbatRange + ']',
  5934. rsLower = '[' + rsLowerRange + ']',
  5935. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  5936. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  5937. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  5938. rsNonAstral = '[^' + rsAstralRange + ']',
  5939. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  5940. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  5941. rsUpper = '[' + rsUpperRange + ']',
  5942. rsZWJ = '\\u200d';
  5943. /** Used to compose unicode regexes. */
  5944. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  5945. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  5946. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  5947. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  5948. reOptMod = rsModifier + '?',
  5949. rsOptVar = '[' + rsVarRange + ']?',
  5950. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  5951. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  5952. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  5953. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  5954. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  5955. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  5956. /** Used to match apostrophes. */
  5957. var reApos = RegExp(rsApos, 'g');
  5958. /**
  5959. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  5960. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  5961. */
  5962. var reComboMark = RegExp(rsCombo, 'g');
  5963. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  5964. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  5965. /** Used to match complex or compound words. */
  5966. var reUnicodeWord = RegExp([
  5967. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  5968. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  5969. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  5970. rsUpper + '+' + rsOptContrUpper,
  5971. rsOrdUpper,
  5972. rsOrdLower,
  5973. rsDigits,
  5974. rsEmoji
  5975. ].join('|'), 'g');
  5976. /** 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/). */
  5977. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  5978. /** Used to detect strings that need a more robust regexp to match words. */
  5979. 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 ]/;
  5980. /** Used to assign default `context` object properties. */
  5981. var contextProps = [
  5982. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  5983. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  5984. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  5985. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  5986. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  5987. ];
  5988. /** Used to make template sourceURLs easier to identify. */
  5989. var templateCounter = -1;
  5990. /** Used to identify `toStringTag` values of typed arrays. */
  5991. var typedArrayTags = {};
  5992. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  5993. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  5994. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  5995. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  5996. typedArrayTags[uint32Tag] = true;
  5997. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  5998. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  5999. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  6000. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  6001. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  6002. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  6003. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  6004. typedArrayTags[weakMapTag] = false;
  6005. /** Used to identify `toStringTag` values supported by `_.clone`. */
  6006. var cloneableTags = {};
  6007. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  6008. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  6009. cloneableTags[boolTag] = cloneableTags[dateTag] =
  6010. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  6011. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  6012. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  6013. cloneableTags[numberTag] = cloneableTags[objectTag] =
  6014. cloneableTags[regexpTag] = cloneableTags[setTag] =
  6015. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  6016. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  6017. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  6018. cloneableTags[errorTag] = cloneableTags[funcTag] =
  6019. cloneableTags[weakMapTag] = false;
  6020. /** Used to map Latin Unicode letters to basic Latin letters. */
  6021. var deburredLetters = {
  6022. // Latin-1 Supplement block.
  6023. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  6024. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  6025. '\xc7': 'C', '\xe7': 'c',
  6026. '\xd0': 'D', '\xf0': 'd',
  6027. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  6028. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  6029. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  6030. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  6031. '\xd1': 'N', '\xf1': 'n',
  6032. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  6033. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  6034. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  6035. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  6036. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  6037. '\xc6': 'Ae', '\xe6': 'ae',
  6038. '\xde': 'Th', '\xfe': 'th',
  6039. '\xdf': 'ss',
  6040. // Latin Extended-A block.
  6041. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  6042. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  6043. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  6044. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  6045. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  6046. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  6047. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  6048. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  6049. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  6050. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  6051. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  6052. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  6053. '\u0134': 'J', '\u0135': 'j',
  6054. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  6055. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  6056. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  6057. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  6058. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  6059. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  6060. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  6061. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  6062. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  6063. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  6064. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  6065. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  6066. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  6067. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  6068. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  6069. '\u0174': 'W', '\u0175': 'w',
  6070. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  6071. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  6072. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  6073. '\u0132': 'IJ', '\u0133': 'ij',
  6074. '\u0152': 'Oe', '\u0153': 'oe',
  6075. '\u0149': "'n", '\u017f': 's'
  6076. };
  6077. /** Used to map characters to HTML entities. */
  6078. var htmlEscapes = {
  6079. '&': '&amp;',
  6080. '<': '&lt;',
  6081. '>': '&gt;',
  6082. '"': '&quot;',
  6083. "'": '&#39;'
  6084. };
  6085. /** Used to map HTML entities to characters. */
  6086. var htmlUnescapes = {
  6087. '&amp;': '&',
  6088. '&lt;': '<',
  6089. '&gt;': '>',
  6090. '&quot;': '"',
  6091. '&#39;': "'"
  6092. };
  6093. /** Used to escape characters for inclusion in compiled string literals. */
  6094. var stringEscapes = {
  6095. '\\': '\\',
  6096. "'": "'",
  6097. '\n': 'n',
  6098. '\r': 'r',
  6099. '\u2028': 'u2028',
  6100. '\u2029': 'u2029'
  6101. };
  6102. /** Built-in method references without a dependency on `root`. */
  6103. var freeParseFloat = parseFloat,
  6104. freeParseInt = parseInt;
  6105. /** Detect free variable `global` from Node.js. */
  6106. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  6107. /** Detect free variable `self`. */
  6108. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  6109. /** Used as a reference to the global object. */
  6110. var root = freeGlobal || freeSelf || Function('return this')();
  6111. /** Detect free variable `exports`. */
  6112. var freeExports = exports && !exports.nodeType && exports;
  6113. /** Detect free variable `module`. */
  6114. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  6115. /** Detect the popular CommonJS extension `module.exports`. */
  6116. var moduleExports = freeModule && freeModule.exports === freeExports;
  6117. /** Detect free variable `process` from Node.js. */
  6118. var freeProcess = moduleExports && freeGlobal.process;
  6119. /** Used to access faster Node.js helpers. */
  6120. var nodeUtil = (function() {
  6121. try {
  6122. // Use `util.types` for Node.js 10+.
  6123. var types = freeModule && freeModule.require && freeModule.require('util').types;
  6124. if (types) {
  6125. return types;
  6126. }
  6127. // Legacy `process.binding('util')` for Node.js < 10.
  6128. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  6129. } catch (e) {}
  6130. }());
  6131. /* Node.js helper references. */
  6132. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  6133. nodeIsDate = nodeUtil && nodeUtil.isDate,
  6134. nodeIsMap = nodeUtil && nodeUtil.isMap,
  6135. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  6136. nodeIsSet = nodeUtil && nodeUtil.isSet,
  6137. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  6138. /*--------------------------------------------------------------------------*/
  6139. /**
  6140. * A faster alternative to `Function#apply`, this function invokes `func`
  6141. * with the `this` binding of `thisArg` and the arguments of `args`.
  6142. *
  6143. * @private
  6144. * @param {Function} func The function to invoke.
  6145. * @param {*} thisArg The `this` binding of `func`.
  6146. * @param {Array} args The arguments to invoke `func` with.
  6147. * @returns {*} Returns the result of `func`.
  6148. */
  6149. function apply(func, thisArg, args) {
  6150. switch (args.length) {
  6151. case 0: return func.call(thisArg);
  6152. case 1: return func.call(thisArg, args[0]);
  6153. case 2: return func.call(thisArg, args[0], args[1]);
  6154. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  6155. }
  6156. return func.apply(thisArg, args);
  6157. }
  6158. /**
  6159. * A specialized version of `baseAggregator` for arrays.
  6160. *
  6161. * @private
  6162. * @param {Array} [array] The array to iterate over.
  6163. * @param {Function} setter The function to set `accumulator` values.
  6164. * @param {Function} iteratee The iteratee to transform keys.
  6165. * @param {Object} accumulator The initial aggregated object.
  6166. * @returns {Function} Returns `accumulator`.
  6167. */
  6168. function arrayAggregator(array, setter, iteratee, accumulator) {
  6169. var index = -1,
  6170. length = array == null ? 0 : array.length;
  6171. while (++index < length) {
  6172. var value = array[index];
  6173. setter(accumulator, value, iteratee(value), array);
  6174. }
  6175. return accumulator;
  6176. }
  6177. /**
  6178. * A specialized version of `_.forEach` for arrays without support for
  6179. * iteratee shorthands.
  6180. *
  6181. * @private
  6182. * @param {Array} [array] The array to iterate over.
  6183. * @param {Function} iteratee The function invoked per iteration.
  6184. * @returns {Array} Returns `array`.
  6185. */
  6186. function arrayEach(array, iteratee) {
  6187. var index = -1,
  6188. length = array == null ? 0 : array.length;
  6189. while (++index < length) {
  6190. if (iteratee(array[index], index, array) === false) {
  6191. break;
  6192. }
  6193. }
  6194. return array;
  6195. }
  6196. /**
  6197. * A specialized version of `_.forEachRight` for arrays without support for
  6198. * iteratee shorthands.
  6199. *
  6200. * @private
  6201. * @param {Array} [array] The array to iterate over.
  6202. * @param {Function} iteratee The function invoked per iteration.
  6203. * @returns {Array} Returns `array`.
  6204. */
  6205. function arrayEachRight(array, iteratee) {
  6206. var length = array == null ? 0 : array.length;
  6207. while (length--) {
  6208. if (iteratee(array[length], length, array) === false) {
  6209. break;
  6210. }
  6211. }
  6212. return array;
  6213. }
  6214. /**
  6215. * A specialized version of `_.every` for arrays without support for
  6216. * iteratee shorthands.
  6217. *
  6218. * @private
  6219. * @param {Array} [array] The array to iterate over.
  6220. * @param {Function} predicate The function invoked per iteration.
  6221. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  6222. * else `false`.
  6223. */
  6224. function arrayEvery(array, predicate) {
  6225. var index = -1,
  6226. length = array == null ? 0 : array.length;
  6227. while (++index < length) {
  6228. if (!predicate(array[index], index, array)) {
  6229. return false;
  6230. }
  6231. }
  6232. return true;
  6233. }
  6234. /**
  6235. * A specialized version of `_.filter` for arrays without support for
  6236. * iteratee shorthands.
  6237. *
  6238. * @private
  6239. * @param {Array} [array] The array to iterate over.
  6240. * @param {Function} predicate The function invoked per iteration.
  6241. * @returns {Array} Returns the new filtered array.
  6242. */
  6243. function arrayFilter(array, predicate) {
  6244. var index = -1,
  6245. length = array == null ? 0 : array.length,
  6246. resIndex = 0,
  6247. result = [];
  6248. while (++index < length) {
  6249. var value = array[index];
  6250. if (predicate(value, index, array)) {
  6251. result[resIndex++] = value;
  6252. }
  6253. }
  6254. return result;
  6255. }
  6256. /**
  6257. * A specialized version of `_.includes` for arrays without support for
  6258. * specifying an index to search from.
  6259. *
  6260. * @private
  6261. * @param {Array} [array] The array to inspect.
  6262. * @param {*} target The value to search for.
  6263. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  6264. */
  6265. function arrayIncludes(array, value) {
  6266. var length = array == null ? 0 : array.length;
  6267. return !!length && baseIndexOf(array, value, 0) > -1;
  6268. }
  6269. /**
  6270. * This function is like `arrayIncludes` except that it accepts a comparator.
  6271. *
  6272. * @private
  6273. * @param {Array} [array] The array to inspect.
  6274. * @param {*} target The value to search for.
  6275. * @param {Function} comparator The comparator invoked per element.
  6276. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  6277. */
  6278. function arrayIncludesWith(array, value, comparator) {
  6279. var index = -1,
  6280. length = array == null ? 0 : array.length;
  6281. while (++index < length) {
  6282. if (comparator(value, array[index])) {
  6283. return true;
  6284. }
  6285. }
  6286. return false;
  6287. }
  6288. /**
  6289. * A specialized version of `_.map` for arrays without support for iteratee
  6290. * shorthands.
  6291. *
  6292. * @private
  6293. * @param {Array} [array] The array to iterate over.
  6294. * @param {Function} iteratee The function invoked per iteration.
  6295. * @returns {Array} Returns the new mapped array.
  6296. */
  6297. function arrayMap(array, iteratee) {
  6298. var index = -1,
  6299. length = array == null ? 0 : array.length,
  6300. result = Array(length);
  6301. while (++index < length) {
  6302. result[index] = iteratee(array[index], index, array);
  6303. }
  6304. return result;
  6305. }
  6306. /**
  6307. * Appends the elements of `values` to `array`.
  6308. *
  6309. * @private
  6310. * @param {Array} array The array to modify.
  6311. * @param {Array} values The values to append.
  6312. * @returns {Array} Returns `array`.
  6313. */
  6314. function arrayPush(array, values) {
  6315. var index = -1,
  6316. length = values.length,
  6317. offset = array.length;
  6318. while (++index < length) {
  6319. array[offset + index] = values[index];
  6320. }
  6321. return array;
  6322. }
  6323. /**
  6324. * A specialized version of `_.reduce` for arrays without support for
  6325. * iteratee shorthands.
  6326. *
  6327. * @private
  6328. * @param {Array} [array] The array to iterate over.
  6329. * @param {Function} iteratee The function invoked per iteration.
  6330. * @param {*} [accumulator] The initial value.
  6331. * @param {boolean} [initAccum] Specify using the first element of `array` as
  6332. * the initial value.
  6333. * @returns {*} Returns the accumulated value.
  6334. */
  6335. function arrayReduce(array, iteratee, accumulator, initAccum) {
  6336. var index = -1,
  6337. length = array == null ? 0 : array.length;
  6338. if (initAccum && length) {
  6339. accumulator = array[++index];
  6340. }
  6341. while (++index < length) {
  6342. accumulator = iteratee(accumulator, array[index], index, array);
  6343. }
  6344. return accumulator;
  6345. }
  6346. /**
  6347. * A specialized version of `_.reduceRight` for arrays without support for
  6348. * iteratee shorthands.
  6349. *
  6350. * @private
  6351. * @param {Array} [array] The array to iterate over.
  6352. * @param {Function} iteratee The function invoked per iteration.
  6353. * @param {*} [accumulator] The initial value.
  6354. * @param {boolean} [initAccum] Specify using the last element of `array` as
  6355. * the initial value.
  6356. * @returns {*} Returns the accumulated value.
  6357. */
  6358. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  6359. var length = array == null ? 0 : array.length;
  6360. if (initAccum && length) {
  6361. accumulator = array[--length];
  6362. }
  6363. while (length--) {
  6364. accumulator = iteratee(accumulator, array[length], length, array);
  6365. }
  6366. return accumulator;
  6367. }
  6368. /**
  6369. * A specialized version of `_.some` for arrays without support for iteratee
  6370. * shorthands.
  6371. *
  6372. * @private
  6373. * @param {Array} [array] The array to iterate over.
  6374. * @param {Function} predicate The function invoked per iteration.
  6375. * @returns {boolean} Returns `true` if any element passes the predicate check,
  6376. * else `false`.
  6377. */
  6378. function arraySome(array, predicate) {
  6379. var index = -1,
  6380. length = array == null ? 0 : array.length;
  6381. while (++index < length) {
  6382. if (predicate(array[index], index, array)) {
  6383. return true;
  6384. }
  6385. }
  6386. return false;
  6387. }
  6388. /**
  6389. * Gets the size of an ASCII `string`.
  6390. *
  6391. * @private
  6392. * @param {string} string The string inspect.
  6393. * @returns {number} Returns the string size.
  6394. */
  6395. var asciiSize = baseProperty('length');
  6396. /**
  6397. * Converts an ASCII `string` to an array.
  6398. *
  6399. * @private
  6400. * @param {string} string The string to convert.
  6401. * @returns {Array} Returns the converted array.
  6402. */
  6403. function asciiToArray(string) {
  6404. return string.split('');
  6405. }
  6406. /**
  6407. * Splits an ASCII `string` into an array of its words.
  6408. *
  6409. * @private
  6410. * @param {string} The string to inspect.
  6411. * @returns {Array} Returns the words of `string`.
  6412. */
  6413. function asciiWords(string) {
  6414. return string.match(reAsciiWord) || [];
  6415. }
  6416. /**
  6417. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  6418. * without support for iteratee shorthands, which iterates over `collection`
  6419. * using `eachFunc`.
  6420. *
  6421. * @private
  6422. * @param {Array|Object} collection The collection to inspect.
  6423. * @param {Function} predicate The function invoked per iteration.
  6424. * @param {Function} eachFunc The function to iterate over `collection`.
  6425. * @returns {*} Returns the found element or its key, else `undefined`.
  6426. */
  6427. function baseFindKey(collection, predicate, eachFunc) {
  6428. var result;
  6429. eachFunc(collection, function(value, key, collection) {
  6430. if (predicate(value, key, collection)) {
  6431. result = key;
  6432. return false;
  6433. }
  6434. });
  6435. return result;
  6436. }
  6437. /**
  6438. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  6439. * support for iteratee shorthands.
  6440. *
  6441. * @private
  6442. * @param {Array} array The array to inspect.
  6443. * @param {Function} predicate The function invoked per iteration.
  6444. * @param {number} fromIndex The index to search from.
  6445. * @param {boolean} [fromRight] Specify iterating from right to left.
  6446. * @returns {number} Returns the index of the matched value, else `-1`.
  6447. */
  6448. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  6449. var length = array.length,
  6450. index = fromIndex + (fromRight ? 1 : -1);
  6451. while ((fromRight ? index-- : ++index < length)) {
  6452. if (predicate(array[index], index, array)) {
  6453. return index;
  6454. }
  6455. }
  6456. return -1;
  6457. }
  6458. /**
  6459. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  6460. *
  6461. * @private
  6462. * @param {Array} array The array to inspect.
  6463. * @param {*} value The value to search for.
  6464. * @param {number} fromIndex The index to search from.
  6465. * @returns {number} Returns the index of the matched value, else `-1`.
  6466. */
  6467. function baseIndexOf(array, value, fromIndex) {
  6468. return value === value
  6469. ? strictIndexOf(array, value, fromIndex)
  6470. : baseFindIndex(array, baseIsNaN, fromIndex);
  6471. }
  6472. /**
  6473. * This function is like `baseIndexOf` except that it accepts a comparator.
  6474. *
  6475. * @private
  6476. * @param {Array} array The array to inspect.
  6477. * @param {*} value The value to search for.
  6478. * @param {number} fromIndex The index to search from.
  6479. * @param {Function} comparator The comparator invoked per element.
  6480. * @returns {number} Returns the index of the matched value, else `-1`.
  6481. */
  6482. function baseIndexOfWith(array, value, fromIndex, comparator) {
  6483. var index = fromIndex - 1,
  6484. length = array.length;
  6485. while (++index < length) {
  6486. if (comparator(array[index], value)) {
  6487. return index;
  6488. }
  6489. }
  6490. return -1;
  6491. }
  6492. /**
  6493. * The base implementation of `_.isNaN` without support for number objects.
  6494. *
  6495. * @private
  6496. * @param {*} value The value to check.
  6497. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  6498. */
  6499. function baseIsNaN(value) {
  6500. return value !== value;
  6501. }
  6502. /**
  6503. * The base implementation of `_.mean` and `_.meanBy` without support for
  6504. * iteratee shorthands.
  6505. *
  6506. * @private
  6507. * @param {Array} array The array to iterate over.
  6508. * @param {Function} iteratee The function invoked per iteration.
  6509. * @returns {number} Returns the mean.
  6510. */
  6511. function baseMean(array, iteratee) {
  6512. var length = array == null ? 0 : array.length;
  6513. return length ? (baseSum(array, iteratee) / length) : NAN;
  6514. }
  6515. /**
  6516. * The base implementation of `_.property` without support for deep paths.
  6517. *
  6518. * @private
  6519. * @param {string} key The key of the property to get.
  6520. * @returns {Function} Returns the new accessor function.
  6521. */
  6522. function baseProperty(key) {
  6523. return function(object) {
  6524. return object == null ? undefined$1 : object[key];
  6525. };
  6526. }
  6527. /**
  6528. * The base implementation of `_.propertyOf` without support for deep paths.
  6529. *
  6530. * @private
  6531. * @param {Object} object The object to query.
  6532. * @returns {Function} Returns the new accessor function.
  6533. */
  6534. function basePropertyOf(object) {
  6535. return function(key) {
  6536. return object == null ? undefined$1 : object[key];
  6537. };
  6538. }
  6539. /**
  6540. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  6541. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  6542. *
  6543. * @private
  6544. * @param {Array|Object} collection The collection to iterate over.
  6545. * @param {Function} iteratee The function invoked per iteration.
  6546. * @param {*} accumulator The initial value.
  6547. * @param {boolean} initAccum Specify using the first or last element of
  6548. * `collection` as the initial value.
  6549. * @param {Function} eachFunc The function to iterate over `collection`.
  6550. * @returns {*} Returns the accumulated value.
  6551. */
  6552. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  6553. eachFunc(collection, function(value, index, collection) {
  6554. accumulator = initAccum
  6555. ? (initAccum = false, value)
  6556. : iteratee(accumulator, value, index, collection);
  6557. });
  6558. return accumulator;
  6559. }
  6560. /**
  6561. * The base implementation of `_.sortBy` which uses `comparer` to define the
  6562. * sort order of `array` and replaces criteria objects with their corresponding
  6563. * values.
  6564. *
  6565. * @private
  6566. * @param {Array} array The array to sort.
  6567. * @param {Function} comparer The function to define sort order.
  6568. * @returns {Array} Returns `array`.
  6569. */
  6570. function baseSortBy(array, comparer) {
  6571. var length = array.length;
  6572. array.sort(comparer);
  6573. while (length--) {
  6574. array[length] = array[length].value;
  6575. }
  6576. return array;
  6577. }
  6578. /**
  6579. * The base implementation of `_.sum` and `_.sumBy` without support for
  6580. * iteratee shorthands.
  6581. *
  6582. * @private
  6583. * @param {Array} array The array to iterate over.
  6584. * @param {Function} iteratee The function invoked per iteration.
  6585. * @returns {number} Returns the sum.
  6586. */
  6587. function baseSum(array, iteratee) {
  6588. var result,
  6589. index = -1,
  6590. length = array.length;
  6591. while (++index < length) {
  6592. var current = iteratee(array[index]);
  6593. if (current !== undefined$1) {
  6594. result = result === undefined$1 ? current : (result + current);
  6595. }
  6596. }
  6597. return result;
  6598. }
  6599. /**
  6600. * The base implementation of `_.times` without support for iteratee shorthands
  6601. * or max array length checks.
  6602. *
  6603. * @private
  6604. * @param {number} n The number of times to invoke `iteratee`.
  6605. * @param {Function} iteratee The function invoked per iteration.
  6606. * @returns {Array} Returns the array of results.
  6607. */
  6608. function baseTimes(n, iteratee) {
  6609. var index = -1,
  6610. result = Array(n);
  6611. while (++index < n) {
  6612. result[index] = iteratee(index);
  6613. }
  6614. return result;
  6615. }
  6616. /**
  6617. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  6618. * of key-value pairs for `object` corresponding to the property names of `props`.
  6619. *
  6620. * @private
  6621. * @param {Object} object The object to query.
  6622. * @param {Array} props The property names to get values for.
  6623. * @returns {Object} Returns the key-value pairs.
  6624. */
  6625. function baseToPairs(object, props) {
  6626. return arrayMap(props, function(key) {
  6627. return [key, object[key]];
  6628. });
  6629. }
  6630. /**
  6631. * The base implementation of `_.trim`.
  6632. *
  6633. * @private
  6634. * @param {string} string The string to trim.
  6635. * @returns {string} Returns the trimmed string.
  6636. */
  6637. function baseTrim(string) {
  6638. return string
  6639. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  6640. : string;
  6641. }
  6642. /**
  6643. * The base implementation of `_.unary` without support for storing metadata.
  6644. *
  6645. * @private
  6646. * @param {Function} func The function to cap arguments for.
  6647. * @returns {Function} Returns the new capped function.
  6648. */
  6649. function baseUnary(func) {
  6650. return function(value) {
  6651. return func(value);
  6652. };
  6653. }
  6654. /**
  6655. * The base implementation of `_.values` and `_.valuesIn` which creates an
  6656. * array of `object` property values corresponding to the property names
  6657. * of `props`.
  6658. *
  6659. * @private
  6660. * @param {Object} object The object to query.
  6661. * @param {Array} props The property names to get values for.
  6662. * @returns {Object} Returns the array of property values.
  6663. */
  6664. function baseValues(object, props) {
  6665. return arrayMap(props, function(key) {
  6666. return object[key];
  6667. });
  6668. }
  6669. /**
  6670. * Checks if a `cache` value for `key` exists.
  6671. *
  6672. * @private
  6673. * @param {Object} cache The cache to query.
  6674. * @param {string} key The key of the entry to check.
  6675. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6676. */
  6677. function cacheHas(cache, key) {
  6678. return cache.has(key);
  6679. }
  6680. /**
  6681. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  6682. * that is not found in the character symbols.
  6683. *
  6684. * @private
  6685. * @param {Array} strSymbols The string symbols to inspect.
  6686. * @param {Array} chrSymbols The character symbols to find.
  6687. * @returns {number} Returns the index of the first unmatched string symbol.
  6688. */
  6689. function charsStartIndex(strSymbols, chrSymbols) {
  6690. var index = -1,
  6691. length = strSymbols.length;
  6692. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  6693. return index;
  6694. }
  6695. /**
  6696. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  6697. * that is not found in the character symbols.
  6698. *
  6699. * @private
  6700. * @param {Array} strSymbols The string symbols to inspect.
  6701. * @param {Array} chrSymbols The character symbols to find.
  6702. * @returns {number} Returns the index of the last unmatched string symbol.
  6703. */
  6704. function charsEndIndex(strSymbols, chrSymbols) {
  6705. var index = strSymbols.length;
  6706. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  6707. return index;
  6708. }
  6709. /**
  6710. * Gets the number of `placeholder` occurrences in `array`.
  6711. *
  6712. * @private
  6713. * @param {Array} array The array to inspect.
  6714. * @param {*} placeholder The placeholder to search for.
  6715. * @returns {number} Returns the placeholder count.
  6716. */
  6717. function countHolders(array, placeholder) {
  6718. var length = array.length,
  6719. result = 0;
  6720. while (length--) {
  6721. if (array[length] === placeholder) {
  6722. ++result;
  6723. }
  6724. }
  6725. return result;
  6726. }
  6727. /**
  6728. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  6729. * letters to basic Latin letters.
  6730. *
  6731. * @private
  6732. * @param {string} letter The matched letter to deburr.
  6733. * @returns {string} Returns the deburred letter.
  6734. */
  6735. var deburrLetter = basePropertyOf(deburredLetters);
  6736. /**
  6737. * Used by `_.escape` to convert characters to HTML entities.
  6738. *
  6739. * @private
  6740. * @param {string} chr The matched character to escape.
  6741. * @returns {string} Returns the escaped character.
  6742. */
  6743. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  6744. /**
  6745. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  6746. *
  6747. * @private
  6748. * @param {string} chr The matched character to escape.
  6749. * @returns {string} Returns the escaped character.
  6750. */
  6751. function escapeStringChar(chr) {
  6752. return '\\' + stringEscapes[chr];
  6753. }
  6754. /**
  6755. * Gets the value at `key` of `object`.
  6756. *
  6757. * @private
  6758. * @param {Object} [object] The object to query.
  6759. * @param {string} key The key of the property to get.
  6760. * @returns {*} Returns the property value.
  6761. */
  6762. function getValue(object, key) {
  6763. return object == null ? undefined$1 : object[key];
  6764. }
  6765. /**
  6766. * Checks if `string` contains Unicode symbols.
  6767. *
  6768. * @private
  6769. * @param {string} string The string to inspect.
  6770. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  6771. */
  6772. function hasUnicode(string) {
  6773. return reHasUnicode.test(string);
  6774. }
  6775. /**
  6776. * Checks if `string` contains a word composed of Unicode symbols.
  6777. *
  6778. * @private
  6779. * @param {string} string The string to inspect.
  6780. * @returns {boolean} Returns `true` if a word is found, else `false`.
  6781. */
  6782. function hasUnicodeWord(string) {
  6783. return reHasUnicodeWord.test(string);
  6784. }
  6785. /**
  6786. * Converts `iterator` to an array.
  6787. *
  6788. * @private
  6789. * @param {Object} iterator The iterator to convert.
  6790. * @returns {Array} Returns the converted array.
  6791. */
  6792. function iteratorToArray(iterator) {
  6793. var data,
  6794. result = [];
  6795. while (!(data = iterator.next()).done) {
  6796. result.push(data.value);
  6797. }
  6798. return result;
  6799. }
  6800. /**
  6801. * Converts `map` to its key-value pairs.
  6802. *
  6803. * @private
  6804. * @param {Object} map The map to convert.
  6805. * @returns {Array} Returns the key-value pairs.
  6806. */
  6807. function mapToArray(map) {
  6808. var index = -1,
  6809. result = Array(map.size);
  6810. map.forEach(function(value, key) {
  6811. result[++index] = [key, value];
  6812. });
  6813. return result;
  6814. }
  6815. /**
  6816. * Creates a unary function that invokes `func` with its argument transformed.
  6817. *
  6818. * @private
  6819. * @param {Function} func The function to wrap.
  6820. * @param {Function} transform The argument transform.
  6821. * @returns {Function} Returns the new function.
  6822. */
  6823. function overArg(func, transform) {
  6824. return function(arg) {
  6825. return func(transform(arg));
  6826. };
  6827. }
  6828. /**
  6829. * Replaces all `placeholder` elements in `array` with an internal placeholder
  6830. * and returns an array of their indexes.
  6831. *
  6832. * @private
  6833. * @param {Array} array The array to modify.
  6834. * @param {*} placeholder The placeholder to replace.
  6835. * @returns {Array} Returns the new array of placeholder indexes.
  6836. */
  6837. function replaceHolders(array, placeholder) {
  6838. var index = -1,
  6839. length = array.length,
  6840. resIndex = 0,
  6841. result = [];
  6842. while (++index < length) {
  6843. var value = array[index];
  6844. if (value === placeholder || value === PLACEHOLDER) {
  6845. array[index] = PLACEHOLDER;
  6846. result[resIndex++] = index;
  6847. }
  6848. }
  6849. return result;
  6850. }
  6851. /**
  6852. * Converts `set` to an array of its values.
  6853. *
  6854. * @private
  6855. * @param {Object} set The set to convert.
  6856. * @returns {Array} Returns the values.
  6857. */
  6858. function setToArray(set) {
  6859. var index = -1,
  6860. result = Array(set.size);
  6861. set.forEach(function(value) {
  6862. result[++index] = value;
  6863. });
  6864. return result;
  6865. }
  6866. /**
  6867. * Converts `set` to its value-value pairs.
  6868. *
  6869. * @private
  6870. * @param {Object} set The set to convert.
  6871. * @returns {Array} Returns the value-value pairs.
  6872. */
  6873. function setToPairs(set) {
  6874. var index = -1,
  6875. result = Array(set.size);
  6876. set.forEach(function(value) {
  6877. result[++index] = [value, value];
  6878. });
  6879. return result;
  6880. }
  6881. /**
  6882. * A specialized version of `_.indexOf` which performs strict equality
  6883. * comparisons of values, i.e. `===`.
  6884. *
  6885. * @private
  6886. * @param {Array} array The array to inspect.
  6887. * @param {*} value The value to search for.
  6888. * @param {number} fromIndex The index to search from.
  6889. * @returns {number} Returns the index of the matched value, else `-1`.
  6890. */
  6891. function strictIndexOf(array, value, fromIndex) {
  6892. var index = fromIndex - 1,
  6893. length = array.length;
  6894. while (++index < length) {
  6895. if (array[index] === value) {
  6896. return index;
  6897. }
  6898. }
  6899. return -1;
  6900. }
  6901. /**
  6902. * A specialized version of `_.lastIndexOf` which performs strict equality
  6903. * comparisons of values, i.e. `===`.
  6904. *
  6905. * @private
  6906. * @param {Array} array The array to inspect.
  6907. * @param {*} value The value to search for.
  6908. * @param {number} fromIndex The index to search from.
  6909. * @returns {number} Returns the index of the matched value, else `-1`.
  6910. */
  6911. function strictLastIndexOf(array, value, fromIndex) {
  6912. var index = fromIndex + 1;
  6913. while (index--) {
  6914. if (array[index] === value) {
  6915. return index;
  6916. }
  6917. }
  6918. return index;
  6919. }
  6920. /**
  6921. * Gets the number of symbols in `string`.
  6922. *
  6923. * @private
  6924. * @param {string} string The string to inspect.
  6925. * @returns {number} Returns the string size.
  6926. */
  6927. function stringSize(string) {
  6928. return hasUnicode(string)
  6929. ? unicodeSize(string)
  6930. : asciiSize(string);
  6931. }
  6932. /**
  6933. * Converts `string` to an array.
  6934. *
  6935. * @private
  6936. * @param {string} string The string to convert.
  6937. * @returns {Array} Returns the converted array.
  6938. */
  6939. function stringToArray(string) {
  6940. return hasUnicode(string)
  6941. ? unicodeToArray(string)
  6942. : asciiToArray(string);
  6943. }
  6944. /**
  6945. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  6946. * character of `string`.
  6947. *
  6948. * @private
  6949. * @param {string} string The string to inspect.
  6950. * @returns {number} Returns the index of the last non-whitespace character.
  6951. */
  6952. function trimmedEndIndex(string) {
  6953. var index = string.length;
  6954. while (index-- && reWhitespace.test(string.charAt(index))) {}
  6955. return index;
  6956. }
  6957. /**
  6958. * Used by `_.unescape` to convert HTML entities to characters.
  6959. *
  6960. * @private
  6961. * @param {string} chr The matched character to unescape.
  6962. * @returns {string} Returns the unescaped character.
  6963. */
  6964. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  6965. /**
  6966. * Gets the size of a Unicode `string`.
  6967. *
  6968. * @private
  6969. * @param {string} string The string inspect.
  6970. * @returns {number} Returns the string size.
  6971. */
  6972. function unicodeSize(string) {
  6973. var result = reUnicode.lastIndex = 0;
  6974. while (reUnicode.test(string)) {
  6975. ++result;
  6976. }
  6977. return result;
  6978. }
  6979. /**
  6980. * Converts a Unicode `string` to an array.
  6981. *
  6982. * @private
  6983. * @param {string} string The string to convert.
  6984. * @returns {Array} Returns the converted array.
  6985. */
  6986. function unicodeToArray(string) {
  6987. return string.match(reUnicode) || [];
  6988. }
  6989. /**
  6990. * Splits a Unicode `string` into an array of its words.
  6991. *
  6992. * @private
  6993. * @param {string} The string to inspect.
  6994. * @returns {Array} Returns the words of `string`.
  6995. */
  6996. function unicodeWords(string) {
  6997. return string.match(reUnicodeWord) || [];
  6998. }
  6999. /*--------------------------------------------------------------------------*/
  7000. /**
  7001. * Create a new pristine `lodash` function using the `context` object.
  7002. *
  7003. * @static
  7004. * @memberOf _
  7005. * @since 1.1.0
  7006. * @category Util
  7007. * @param {Object} [context=root] The context object.
  7008. * @returns {Function} Returns a new `lodash` function.
  7009. * @example
  7010. *
  7011. * _.mixin({ 'foo': _.constant('foo') });
  7012. *
  7013. * var lodash = _.runInContext();
  7014. * lodash.mixin({ 'bar': lodash.constant('bar') });
  7015. *
  7016. * _.isFunction(_.foo);
  7017. * // => true
  7018. * _.isFunction(_.bar);
  7019. * // => false
  7020. *
  7021. * lodash.isFunction(lodash.foo);
  7022. * // => false
  7023. * lodash.isFunction(lodash.bar);
  7024. * // => true
  7025. *
  7026. * // Create a suped-up `defer` in Node.js.
  7027. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  7028. */
  7029. var runInContext = (function runInContext(context) {
  7030. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  7031. /** Built-in constructor references. */
  7032. var Array = context.Array,
  7033. Date = context.Date,
  7034. Error = context.Error,
  7035. Function = context.Function,
  7036. Math = context.Math,
  7037. Object = context.Object,
  7038. RegExp = context.RegExp,
  7039. String = context.String,
  7040. TypeError = context.TypeError;
  7041. /** Used for built-in method references. */
  7042. var arrayProto = Array.prototype,
  7043. funcProto = Function.prototype,
  7044. objectProto = Object.prototype;
  7045. /** Used to detect overreaching core-js shims. */
  7046. var coreJsData = context['__core-js_shared__'];
  7047. /** Used to resolve the decompiled source of functions. */
  7048. var funcToString = funcProto.toString;
  7049. /** Used to check objects for own properties. */
  7050. var hasOwnProperty = objectProto.hasOwnProperty;
  7051. /** Used to generate unique IDs. */
  7052. var idCounter = 0;
  7053. /** Used to detect methods masquerading as native. */
  7054. var maskSrcKey = (function() {
  7055. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  7056. return uid ? ('Symbol(src)_1.' + uid) : '';
  7057. }());
  7058. /**
  7059. * Used to resolve the
  7060. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  7061. * of values.
  7062. */
  7063. var nativeObjectToString = objectProto.toString;
  7064. /** Used to infer the `Object` constructor. */
  7065. var objectCtorString = funcToString.call(Object);
  7066. /** Used to restore the original `_` reference in `_.noConflict`. */
  7067. var oldDash = root._;
  7068. /** Used to detect if a method is native. */
  7069. var reIsNative = RegExp('^' +
  7070. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  7071. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  7072. );
  7073. /** Built-in value references. */
  7074. var Buffer = moduleExports ? context.Buffer : undefined$1,
  7075. Symbol = context.Symbol,
  7076. Uint8Array = context.Uint8Array,
  7077. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined$1,
  7078. getPrototype = overArg(Object.getPrototypeOf, Object),
  7079. objectCreate = Object.create,
  7080. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  7081. splice = arrayProto.splice,
  7082. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined$1,
  7083. symIterator = Symbol ? Symbol.iterator : undefined$1,
  7084. symToStringTag = Symbol ? Symbol.toStringTag : undefined$1;
  7085. var defineProperty = (function() {
  7086. try {
  7087. var func = getNative(Object, 'defineProperty');
  7088. func({}, '', {});
  7089. return func;
  7090. } catch (e) {}
  7091. }());
  7092. /** Mocked built-ins. */
  7093. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  7094. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  7095. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  7096. /* Built-in method references for those with the same name as other `lodash` methods. */
  7097. var nativeCeil = Math.ceil,
  7098. nativeFloor = Math.floor,
  7099. nativeGetSymbols = Object.getOwnPropertySymbols,
  7100. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1,
  7101. nativeIsFinite = context.isFinite,
  7102. nativeJoin = arrayProto.join,
  7103. nativeKeys = overArg(Object.keys, Object),
  7104. nativeMax = Math.max,
  7105. nativeMin = Math.min,
  7106. nativeNow = Date.now,
  7107. nativeParseInt = context.parseInt,
  7108. nativeRandom = Math.random,
  7109. nativeReverse = arrayProto.reverse;
  7110. /* Built-in method references that are verified to be native. */
  7111. var DataView = getNative(context, 'DataView'),
  7112. Map = getNative(context, 'Map'),
  7113. Promise = getNative(context, 'Promise'),
  7114. Set = getNative(context, 'Set'),
  7115. WeakMap = getNative(context, 'WeakMap'),
  7116. nativeCreate = getNative(Object, 'create');
  7117. /** Used to store function metadata. */
  7118. var metaMap = WeakMap && new WeakMap;
  7119. /** Used to lookup unminified function names. */
  7120. var realNames = {};
  7121. /** Used to detect maps, sets, and weakmaps. */
  7122. var dataViewCtorString = toSource(DataView),
  7123. mapCtorString = toSource(Map),
  7124. promiseCtorString = toSource(Promise),
  7125. setCtorString = toSource(Set),
  7126. weakMapCtorString = toSource(WeakMap);
  7127. /** Used to convert symbols to primitives and strings. */
  7128. var symbolProto = Symbol ? Symbol.prototype : undefined$1,
  7129. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined$1,
  7130. symbolToString = symbolProto ? symbolProto.toString : undefined$1;
  7131. /*------------------------------------------------------------------------*/
  7132. /**
  7133. * Creates a `lodash` object which wraps `value` to enable implicit method
  7134. * chain sequences. Methods that operate on and return arrays, collections,
  7135. * and functions can be chained together. Methods that retrieve a single value
  7136. * or may return a primitive value will automatically end the chain sequence
  7137. * and return the unwrapped value. Otherwise, the value must be unwrapped
  7138. * with `_#value`.
  7139. *
  7140. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  7141. * enabled using `_.chain`.
  7142. *
  7143. * The execution of chained methods is lazy, that is, it's deferred until
  7144. * `_#value` is implicitly or explicitly called.
  7145. *
  7146. * Lazy evaluation allows several methods to support shortcut fusion.
  7147. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  7148. * the creation of intermediate arrays and can greatly reduce the number of
  7149. * iteratee executions. Sections of a chain sequence qualify for shortcut
  7150. * fusion if the section is applied to an array and iteratees accept only
  7151. * one argument. The heuristic for whether a section qualifies for shortcut
  7152. * fusion is subject to change.
  7153. *
  7154. * Chaining is supported in custom builds as long as the `_#value` method is
  7155. * directly or indirectly included in the build.
  7156. *
  7157. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  7158. *
  7159. * The wrapper `Array` methods are:
  7160. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  7161. *
  7162. * The wrapper `String` methods are:
  7163. * `replace` and `split`
  7164. *
  7165. * The wrapper methods that support shortcut fusion are:
  7166. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  7167. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  7168. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  7169. *
  7170. * The chainable wrapper methods are:
  7171. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  7172. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  7173. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  7174. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  7175. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  7176. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  7177. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  7178. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  7179. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  7180. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  7181. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  7182. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  7183. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  7184. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  7185. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  7186. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  7187. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  7188. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  7189. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  7190. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  7191. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  7192. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  7193. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  7194. * `zipObject`, `zipObjectDeep`, and `zipWith`
  7195. *
  7196. * The wrapper methods that are **not** chainable by default are:
  7197. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  7198. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  7199. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  7200. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  7201. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  7202. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  7203. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  7204. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  7205. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  7206. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  7207. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  7208. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  7209. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  7210. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  7211. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  7212. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  7213. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  7214. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  7215. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  7216. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  7217. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  7218. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  7219. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  7220. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  7221. * `upperFirst`, `value`, and `words`
  7222. *
  7223. * @name _
  7224. * @constructor
  7225. * @category Seq
  7226. * @param {*} value The value to wrap in a `lodash` instance.
  7227. * @returns {Object} Returns the new `lodash` wrapper instance.
  7228. * @example
  7229. *
  7230. * function square(n) {
  7231. * return n * n;
  7232. * }
  7233. *
  7234. * var wrapped = _([1, 2, 3]);
  7235. *
  7236. * // Returns an unwrapped value.
  7237. * wrapped.reduce(_.add);
  7238. * // => 6
  7239. *
  7240. * // Returns a wrapped value.
  7241. * var squares = wrapped.map(square);
  7242. *
  7243. * _.isArray(squares);
  7244. * // => false
  7245. *
  7246. * _.isArray(squares.value());
  7247. * // => true
  7248. */
  7249. function lodash(value) {
  7250. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  7251. if (value instanceof LodashWrapper) {
  7252. return value;
  7253. }
  7254. if (hasOwnProperty.call(value, '__wrapped__')) {
  7255. return wrapperClone(value);
  7256. }
  7257. }
  7258. return new LodashWrapper(value);
  7259. }
  7260. /**
  7261. * The base implementation of `_.create` without support for assigning
  7262. * properties to the created object.
  7263. *
  7264. * @private
  7265. * @param {Object} proto The object to inherit from.
  7266. * @returns {Object} Returns the new object.
  7267. */
  7268. var baseCreate = (function() {
  7269. function object() {}
  7270. return function(proto) {
  7271. if (!isObject(proto)) {
  7272. return {};
  7273. }
  7274. if (objectCreate) {
  7275. return objectCreate(proto);
  7276. }
  7277. object.prototype = proto;
  7278. var result = new object;
  7279. object.prototype = undefined$1;
  7280. return result;
  7281. };
  7282. }());
  7283. /**
  7284. * The function whose prototype chain sequence wrappers inherit from.
  7285. *
  7286. * @private
  7287. */
  7288. function baseLodash() {
  7289. // No operation performed.
  7290. }
  7291. /**
  7292. * The base constructor for creating `lodash` wrapper objects.
  7293. *
  7294. * @private
  7295. * @param {*} value The value to wrap.
  7296. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  7297. */
  7298. function LodashWrapper(value, chainAll) {
  7299. this.__wrapped__ = value;
  7300. this.__actions__ = [];
  7301. this.__chain__ = !!chainAll;
  7302. this.__index__ = 0;
  7303. this.__values__ = undefined$1;
  7304. }
  7305. /**
  7306. * By default, the template delimiters used by lodash are like those in
  7307. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  7308. * following template settings to use alternative delimiters.
  7309. *
  7310. * @static
  7311. * @memberOf _
  7312. * @type {Object}
  7313. */
  7314. lodash.templateSettings = {
  7315. /**
  7316. * Used to detect `data` property values to be HTML-escaped.
  7317. *
  7318. * @memberOf _.templateSettings
  7319. * @type {RegExp}
  7320. */
  7321. 'escape': reEscape,
  7322. /**
  7323. * Used to detect code to be evaluated.
  7324. *
  7325. * @memberOf _.templateSettings
  7326. * @type {RegExp}
  7327. */
  7328. 'evaluate': reEvaluate,
  7329. /**
  7330. * Used to detect `data` property values to inject.
  7331. *
  7332. * @memberOf _.templateSettings
  7333. * @type {RegExp}
  7334. */
  7335. 'interpolate': reInterpolate,
  7336. /**
  7337. * Used to reference the data object in the template text.
  7338. *
  7339. * @memberOf _.templateSettings
  7340. * @type {string}
  7341. */
  7342. 'variable': '',
  7343. /**
  7344. * Used to import variables into the compiled template.
  7345. *
  7346. * @memberOf _.templateSettings
  7347. * @type {Object}
  7348. */
  7349. 'imports': {
  7350. /**
  7351. * A reference to the `lodash` function.
  7352. *
  7353. * @memberOf _.templateSettings.imports
  7354. * @type {Function}
  7355. */
  7356. '_': lodash
  7357. }
  7358. };
  7359. // Ensure wrappers are instances of `baseLodash`.
  7360. lodash.prototype = baseLodash.prototype;
  7361. lodash.prototype.constructor = lodash;
  7362. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  7363. LodashWrapper.prototype.constructor = LodashWrapper;
  7364. /*------------------------------------------------------------------------*/
  7365. /**
  7366. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  7367. *
  7368. * @private
  7369. * @constructor
  7370. * @param {*} value The value to wrap.
  7371. */
  7372. function LazyWrapper(value) {
  7373. this.__wrapped__ = value;
  7374. this.__actions__ = [];
  7375. this.__dir__ = 1;
  7376. this.__filtered__ = false;
  7377. this.__iteratees__ = [];
  7378. this.__takeCount__ = MAX_ARRAY_LENGTH;
  7379. this.__views__ = [];
  7380. }
  7381. /**
  7382. * Creates a clone of the lazy wrapper object.
  7383. *
  7384. * @private
  7385. * @name clone
  7386. * @memberOf LazyWrapper
  7387. * @returns {Object} Returns the cloned `LazyWrapper` object.
  7388. */
  7389. function lazyClone() {
  7390. var result = new LazyWrapper(this.__wrapped__);
  7391. result.__actions__ = copyArray(this.__actions__);
  7392. result.__dir__ = this.__dir__;
  7393. result.__filtered__ = this.__filtered__;
  7394. result.__iteratees__ = copyArray(this.__iteratees__);
  7395. result.__takeCount__ = this.__takeCount__;
  7396. result.__views__ = copyArray(this.__views__);
  7397. return result;
  7398. }
  7399. /**
  7400. * Reverses the direction of lazy iteration.
  7401. *
  7402. * @private
  7403. * @name reverse
  7404. * @memberOf LazyWrapper
  7405. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  7406. */
  7407. function lazyReverse() {
  7408. if (this.__filtered__) {
  7409. var result = new LazyWrapper(this);
  7410. result.__dir__ = -1;
  7411. result.__filtered__ = true;
  7412. } else {
  7413. result = this.clone();
  7414. result.__dir__ *= -1;
  7415. }
  7416. return result;
  7417. }
  7418. /**
  7419. * Extracts the unwrapped value from its lazy wrapper.
  7420. *
  7421. * @private
  7422. * @name value
  7423. * @memberOf LazyWrapper
  7424. * @returns {*} Returns the unwrapped value.
  7425. */
  7426. function lazyValue() {
  7427. var array = this.__wrapped__.value(),
  7428. dir = this.__dir__,
  7429. isArr = isArray(array),
  7430. isRight = dir < 0,
  7431. arrLength = isArr ? array.length : 0,
  7432. view = getView(0, arrLength, this.__views__),
  7433. start = view.start,
  7434. end = view.end,
  7435. length = end - start,
  7436. index = isRight ? end : (start - 1),
  7437. iteratees = this.__iteratees__,
  7438. iterLength = iteratees.length,
  7439. resIndex = 0,
  7440. takeCount = nativeMin(length, this.__takeCount__);
  7441. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  7442. return baseWrapperValue(array, this.__actions__);
  7443. }
  7444. var result = [];
  7445. outer:
  7446. while (length-- && resIndex < takeCount) {
  7447. index += dir;
  7448. var iterIndex = -1,
  7449. value = array[index];
  7450. while (++iterIndex < iterLength) {
  7451. var data = iteratees[iterIndex],
  7452. iteratee = data.iteratee,
  7453. type = data.type,
  7454. computed = iteratee(value);
  7455. if (type == LAZY_MAP_FLAG) {
  7456. value = computed;
  7457. } else if (!computed) {
  7458. if (type == LAZY_FILTER_FLAG) {
  7459. continue outer;
  7460. } else {
  7461. break outer;
  7462. }
  7463. }
  7464. }
  7465. result[resIndex++] = value;
  7466. }
  7467. return result;
  7468. }
  7469. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  7470. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  7471. LazyWrapper.prototype.constructor = LazyWrapper;
  7472. /*------------------------------------------------------------------------*/
  7473. /**
  7474. * Creates a hash object.
  7475. *
  7476. * @private
  7477. * @constructor
  7478. * @param {Array} [entries] The key-value pairs to cache.
  7479. */
  7480. function Hash(entries) {
  7481. var index = -1,
  7482. length = entries == null ? 0 : entries.length;
  7483. this.clear();
  7484. while (++index < length) {
  7485. var entry = entries[index];
  7486. this.set(entry[0], entry[1]);
  7487. }
  7488. }
  7489. /**
  7490. * Removes all key-value entries from the hash.
  7491. *
  7492. * @private
  7493. * @name clear
  7494. * @memberOf Hash
  7495. */
  7496. function hashClear() {
  7497. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  7498. this.size = 0;
  7499. }
  7500. /**
  7501. * Removes `key` and its value from the hash.
  7502. *
  7503. * @private
  7504. * @name delete
  7505. * @memberOf Hash
  7506. * @param {Object} hash The hash to modify.
  7507. * @param {string} key The key of the value to remove.
  7508. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7509. */
  7510. function hashDelete(key) {
  7511. var result = this.has(key) && delete this.__data__[key];
  7512. this.size -= result ? 1 : 0;
  7513. return result;
  7514. }
  7515. /**
  7516. * Gets the hash value for `key`.
  7517. *
  7518. * @private
  7519. * @name get
  7520. * @memberOf Hash
  7521. * @param {string} key The key of the value to get.
  7522. * @returns {*} Returns the entry value.
  7523. */
  7524. function hashGet(key) {
  7525. var data = this.__data__;
  7526. if (nativeCreate) {
  7527. var result = data[key];
  7528. return result === HASH_UNDEFINED ? undefined$1 : result;
  7529. }
  7530. return hasOwnProperty.call(data, key) ? data[key] : undefined$1;
  7531. }
  7532. /**
  7533. * Checks if a hash value for `key` exists.
  7534. *
  7535. * @private
  7536. * @name has
  7537. * @memberOf Hash
  7538. * @param {string} key The key of the entry to check.
  7539. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7540. */
  7541. function hashHas(key) {
  7542. var data = this.__data__;
  7543. return nativeCreate ? (data[key] !== undefined$1) : hasOwnProperty.call(data, key);
  7544. }
  7545. /**
  7546. * Sets the hash `key` to `value`.
  7547. *
  7548. * @private
  7549. * @name set
  7550. * @memberOf Hash
  7551. * @param {string} key The key of the value to set.
  7552. * @param {*} value The value to set.
  7553. * @returns {Object} Returns the hash instance.
  7554. */
  7555. function hashSet(key, value) {
  7556. var data = this.__data__;
  7557. this.size += this.has(key) ? 0 : 1;
  7558. data[key] = (nativeCreate && value === undefined$1) ? HASH_UNDEFINED : value;
  7559. return this;
  7560. }
  7561. // Add methods to `Hash`.
  7562. Hash.prototype.clear = hashClear;
  7563. Hash.prototype['delete'] = hashDelete;
  7564. Hash.prototype.get = hashGet;
  7565. Hash.prototype.has = hashHas;
  7566. Hash.prototype.set = hashSet;
  7567. /*------------------------------------------------------------------------*/
  7568. /**
  7569. * Creates an list cache object.
  7570. *
  7571. * @private
  7572. * @constructor
  7573. * @param {Array} [entries] The key-value pairs to cache.
  7574. */
  7575. function ListCache(entries) {
  7576. var index = -1,
  7577. length = entries == null ? 0 : entries.length;
  7578. this.clear();
  7579. while (++index < length) {
  7580. var entry = entries[index];
  7581. this.set(entry[0], entry[1]);
  7582. }
  7583. }
  7584. /**
  7585. * Removes all key-value entries from the list cache.
  7586. *
  7587. * @private
  7588. * @name clear
  7589. * @memberOf ListCache
  7590. */
  7591. function listCacheClear() {
  7592. this.__data__ = [];
  7593. this.size = 0;
  7594. }
  7595. /**
  7596. * Removes `key` and its value from the list cache.
  7597. *
  7598. * @private
  7599. * @name delete
  7600. * @memberOf ListCache
  7601. * @param {string} key The key of the value to remove.
  7602. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7603. */
  7604. function listCacheDelete(key) {
  7605. var data = this.__data__,
  7606. index = assocIndexOf(data, key);
  7607. if (index < 0) {
  7608. return false;
  7609. }
  7610. var lastIndex = data.length - 1;
  7611. if (index == lastIndex) {
  7612. data.pop();
  7613. } else {
  7614. splice.call(data, index, 1);
  7615. }
  7616. --this.size;
  7617. return true;
  7618. }
  7619. /**
  7620. * Gets the list cache value for `key`.
  7621. *
  7622. * @private
  7623. * @name get
  7624. * @memberOf ListCache
  7625. * @param {string} key The key of the value to get.
  7626. * @returns {*} Returns the entry value.
  7627. */
  7628. function listCacheGet(key) {
  7629. var data = this.__data__,
  7630. index = assocIndexOf(data, key);
  7631. return index < 0 ? undefined$1 : data[index][1];
  7632. }
  7633. /**
  7634. * Checks if a list cache value for `key` exists.
  7635. *
  7636. * @private
  7637. * @name has
  7638. * @memberOf ListCache
  7639. * @param {string} key The key of the entry to check.
  7640. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7641. */
  7642. function listCacheHas(key) {
  7643. return assocIndexOf(this.__data__, key) > -1;
  7644. }
  7645. /**
  7646. * Sets the list cache `key` to `value`.
  7647. *
  7648. * @private
  7649. * @name set
  7650. * @memberOf ListCache
  7651. * @param {string} key The key of the value to set.
  7652. * @param {*} value The value to set.
  7653. * @returns {Object} Returns the list cache instance.
  7654. */
  7655. function listCacheSet(key, value) {
  7656. var data = this.__data__,
  7657. index = assocIndexOf(data, key);
  7658. if (index < 0) {
  7659. ++this.size;
  7660. data.push([key, value]);
  7661. } else {
  7662. data[index][1] = value;
  7663. }
  7664. return this;
  7665. }
  7666. // Add methods to `ListCache`.
  7667. ListCache.prototype.clear = listCacheClear;
  7668. ListCache.prototype['delete'] = listCacheDelete;
  7669. ListCache.prototype.get = listCacheGet;
  7670. ListCache.prototype.has = listCacheHas;
  7671. ListCache.prototype.set = listCacheSet;
  7672. /*------------------------------------------------------------------------*/
  7673. /**
  7674. * Creates a map cache object to store key-value pairs.
  7675. *
  7676. * @private
  7677. * @constructor
  7678. * @param {Array} [entries] The key-value pairs to cache.
  7679. */
  7680. function MapCache(entries) {
  7681. var index = -1,
  7682. length = entries == null ? 0 : entries.length;
  7683. this.clear();
  7684. while (++index < length) {
  7685. var entry = entries[index];
  7686. this.set(entry[0], entry[1]);
  7687. }
  7688. }
  7689. /**
  7690. * Removes all key-value entries from the map.
  7691. *
  7692. * @private
  7693. * @name clear
  7694. * @memberOf MapCache
  7695. */
  7696. function mapCacheClear() {
  7697. this.size = 0;
  7698. this.__data__ = {
  7699. 'hash': new Hash,
  7700. 'map': new (Map || ListCache),
  7701. 'string': new Hash
  7702. };
  7703. }
  7704. /**
  7705. * Removes `key` and its value from the map.
  7706. *
  7707. * @private
  7708. * @name delete
  7709. * @memberOf MapCache
  7710. * @param {string} key The key of the value to remove.
  7711. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7712. */
  7713. function mapCacheDelete(key) {
  7714. var result = getMapData(this, key)['delete'](key);
  7715. this.size -= result ? 1 : 0;
  7716. return result;
  7717. }
  7718. /**
  7719. * Gets the map value for `key`.
  7720. *
  7721. * @private
  7722. * @name get
  7723. * @memberOf MapCache
  7724. * @param {string} key The key of the value to get.
  7725. * @returns {*} Returns the entry value.
  7726. */
  7727. function mapCacheGet(key) {
  7728. return getMapData(this, key).get(key);
  7729. }
  7730. /**
  7731. * Checks if a map value for `key` exists.
  7732. *
  7733. * @private
  7734. * @name has
  7735. * @memberOf MapCache
  7736. * @param {string} key The key of the entry to check.
  7737. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7738. */
  7739. function mapCacheHas(key) {
  7740. return getMapData(this, key).has(key);
  7741. }
  7742. /**
  7743. * Sets the map `key` to `value`.
  7744. *
  7745. * @private
  7746. * @name set
  7747. * @memberOf MapCache
  7748. * @param {string} key The key of the value to set.
  7749. * @param {*} value The value to set.
  7750. * @returns {Object} Returns the map cache instance.
  7751. */
  7752. function mapCacheSet(key, value) {
  7753. var data = getMapData(this, key),
  7754. size = data.size;
  7755. data.set(key, value);
  7756. this.size += data.size == size ? 0 : 1;
  7757. return this;
  7758. }
  7759. // Add methods to `MapCache`.
  7760. MapCache.prototype.clear = mapCacheClear;
  7761. MapCache.prototype['delete'] = mapCacheDelete;
  7762. MapCache.prototype.get = mapCacheGet;
  7763. MapCache.prototype.has = mapCacheHas;
  7764. MapCache.prototype.set = mapCacheSet;
  7765. /*------------------------------------------------------------------------*/
  7766. /**
  7767. *
  7768. * Creates an array cache object to store unique values.
  7769. *
  7770. * @private
  7771. * @constructor
  7772. * @param {Array} [values] The values to cache.
  7773. */
  7774. function SetCache(values) {
  7775. var index = -1,
  7776. length = values == null ? 0 : values.length;
  7777. this.__data__ = new MapCache;
  7778. while (++index < length) {
  7779. this.add(values[index]);
  7780. }
  7781. }
  7782. /**
  7783. * Adds `value` to the array cache.
  7784. *
  7785. * @private
  7786. * @name add
  7787. * @memberOf SetCache
  7788. * @alias push
  7789. * @param {*} value The value to cache.
  7790. * @returns {Object} Returns the cache instance.
  7791. */
  7792. function setCacheAdd(value) {
  7793. this.__data__.set(value, HASH_UNDEFINED);
  7794. return this;
  7795. }
  7796. /**
  7797. * Checks if `value` is in the array cache.
  7798. *
  7799. * @private
  7800. * @name has
  7801. * @memberOf SetCache
  7802. * @param {*} value The value to search for.
  7803. * @returns {number} Returns `true` if `value` is found, else `false`.
  7804. */
  7805. function setCacheHas(value) {
  7806. return this.__data__.has(value);
  7807. }
  7808. // Add methods to `SetCache`.
  7809. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  7810. SetCache.prototype.has = setCacheHas;
  7811. /*------------------------------------------------------------------------*/
  7812. /**
  7813. * Creates a stack cache object to store key-value pairs.
  7814. *
  7815. * @private
  7816. * @constructor
  7817. * @param {Array} [entries] The key-value pairs to cache.
  7818. */
  7819. function Stack(entries) {
  7820. var data = this.__data__ = new ListCache(entries);
  7821. this.size = data.size;
  7822. }
  7823. /**
  7824. * Removes all key-value entries from the stack.
  7825. *
  7826. * @private
  7827. * @name clear
  7828. * @memberOf Stack
  7829. */
  7830. function stackClear() {
  7831. this.__data__ = new ListCache;
  7832. this.size = 0;
  7833. }
  7834. /**
  7835. * Removes `key` and its value from the stack.
  7836. *
  7837. * @private
  7838. * @name delete
  7839. * @memberOf Stack
  7840. * @param {string} key The key of the value to remove.
  7841. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  7842. */
  7843. function stackDelete(key) {
  7844. var data = this.__data__,
  7845. result = data['delete'](key);
  7846. this.size = data.size;
  7847. return result;
  7848. }
  7849. /**
  7850. * Gets the stack value for `key`.
  7851. *
  7852. * @private
  7853. * @name get
  7854. * @memberOf Stack
  7855. * @param {string} key The key of the value to get.
  7856. * @returns {*} Returns the entry value.
  7857. */
  7858. function stackGet(key) {
  7859. return this.__data__.get(key);
  7860. }
  7861. /**
  7862. * Checks if a stack value for `key` exists.
  7863. *
  7864. * @private
  7865. * @name has
  7866. * @memberOf Stack
  7867. * @param {string} key The key of the entry to check.
  7868. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7869. */
  7870. function stackHas(key) {
  7871. return this.__data__.has(key);
  7872. }
  7873. /**
  7874. * Sets the stack `key` to `value`.
  7875. *
  7876. * @private
  7877. * @name set
  7878. * @memberOf Stack
  7879. * @param {string} key The key of the value to set.
  7880. * @param {*} value The value to set.
  7881. * @returns {Object} Returns the stack cache instance.
  7882. */
  7883. function stackSet(key, value) {
  7884. var data = this.__data__;
  7885. if (data instanceof ListCache) {
  7886. var pairs = data.__data__;
  7887. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  7888. pairs.push([key, value]);
  7889. this.size = ++data.size;
  7890. return this;
  7891. }
  7892. data = this.__data__ = new MapCache(pairs);
  7893. }
  7894. data.set(key, value);
  7895. this.size = data.size;
  7896. return this;
  7897. }
  7898. // Add methods to `Stack`.
  7899. Stack.prototype.clear = stackClear;
  7900. Stack.prototype['delete'] = stackDelete;
  7901. Stack.prototype.get = stackGet;
  7902. Stack.prototype.has = stackHas;
  7903. Stack.prototype.set = stackSet;
  7904. /*------------------------------------------------------------------------*/
  7905. /**
  7906. * Creates an array of the enumerable property names of the array-like `value`.
  7907. *
  7908. * @private
  7909. * @param {*} value The value to query.
  7910. * @param {boolean} inherited Specify returning inherited property names.
  7911. * @returns {Array} Returns the array of property names.
  7912. */
  7913. function arrayLikeKeys(value, inherited) {
  7914. var isArr = isArray(value),
  7915. isArg = !isArr && isArguments(value),
  7916. isBuff = !isArr && !isArg && isBuffer(value),
  7917. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  7918. skipIndexes = isArr || isArg || isBuff || isType,
  7919. result = skipIndexes ? baseTimes(value.length, String) : [],
  7920. length = result.length;
  7921. for (var key in value) {
  7922. if ((inherited || hasOwnProperty.call(value, key)) &&
  7923. !(skipIndexes && (
  7924. // Safari 9 has enumerable `arguments.length` in strict mode.
  7925. key == 'length' ||
  7926. // Node.js 0.10 has enumerable non-index properties on buffers.
  7927. (isBuff && (key == 'offset' || key == 'parent')) ||
  7928. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  7929. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  7930. // Skip index properties.
  7931. isIndex(key, length)
  7932. ))) {
  7933. result.push(key);
  7934. }
  7935. }
  7936. return result;
  7937. }
  7938. /**
  7939. * A specialized version of `_.sample` for arrays.
  7940. *
  7941. * @private
  7942. * @param {Array} array The array to sample.
  7943. * @returns {*} Returns the random element.
  7944. */
  7945. function arraySample(array) {
  7946. var length = array.length;
  7947. return length ? array[baseRandom(0, length - 1)] : undefined$1;
  7948. }
  7949. /**
  7950. * A specialized version of `_.sampleSize` for arrays.
  7951. *
  7952. * @private
  7953. * @param {Array} array The array to sample.
  7954. * @param {number} n The number of elements to sample.
  7955. * @returns {Array} Returns the random elements.
  7956. */
  7957. function arraySampleSize(array, n) {
  7958. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  7959. }
  7960. /**
  7961. * A specialized version of `_.shuffle` for arrays.
  7962. *
  7963. * @private
  7964. * @param {Array} array The array to shuffle.
  7965. * @returns {Array} Returns the new shuffled array.
  7966. */
  7967. function arrayShuffle(array) {
  7968. return shuffleSelf(copyArray(array));
  7969. }
  7970. /**
  7971. * This function is like `assignValue` except that it doesn't assign
  7972. * `undefined` values.
  7973. *
  7974. * @private
  7975. * @param {Object} object The object to modify.
  7976. * @param {string} key The key of the property to assign.
  7977. * @param {*} value The value to assign.
  7978. */
  7979. function assignMergeValue(object, key, value) {
  7980. if ((value !== undefined$1 && !eq(object[key], value)) ||
  7981. (value === undefined$1 && !(key in object))) {
  7982. baseAssignValue(object, key, value);
  7983. }
  7984. }
  7985. /**
  7986. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  7987. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7988. * for equality comparisons.
  7989. *
  7990. * @private
  7991. * @param {Object} object The object to modify.
  7992. * @param {string} key The key of the property to assign.
  7993. * @param {*} value The value to assign.
  7994. */
  7995. function assignValue(object, key, value) {
  7996. var objValue = object[key];
  7997. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  7998. (value === undefined$1 && !(key in object))) {
  7999. baseAssignValue(object, key, value);
  8000. }
  8001. }
  8002. /**
  8003. * Gets the index at which the `key` is found in `array` of key-value pairs.
  8004. *
  8005. * @private
  8006. * @param {Array} array The array to inspect.
  8007. * @param {*} key The key to search for.
  8008. * @returns {number} Returns the index of the matched value, else `-1`.
  8009. */
  8010. function assocIndexOf(array, key) {
  8011. var length = array.length;
  8012. while (length--) {
  8013. if (eq(array[length][0], key)) {
  8014. return length;
  8015. }
  8016. }
  8017. return -1;
  8018. }
  8019. /**
  8020. * Aggregates elements of `collection` on `accumulator` with keys transformed
  8021. * by `iteratee` and values set by `setter`.
  8022. *
  8023. * @private
  8024. * @param {Array|Object} collection The collection to iterate over.
  8025. * @param {Function} setter The function to set `accumulator` values.
  8026. * @param {Function} iteratee The iteratee to transform keys.
  8027. * @param {Object} accumulator The initial aggregated object.
  8028. * @returns {Function} Returns `accumulator`.
  8029. */
  8030. function baseAggregator(collection, setter, iteratee, accumulator) {
  8031. baseEach(collection, function(value, key, collection) {
  8032. setter(accumulator, value, iteratee(value), collection);
  8033. });
  8034. return accumulator;
  8035. }
  8036. /**
  8037. * The base implementation of `_.assign` without support for multiple sources
  8038. * or `customizer` functions.
  8039. *
  8040. * @private
  8041. * @param {Object} object The destination object.
  8042. * @param {Object} source The source object.
  8043. * @returns {Object} Returns `object`.
  8044. */
  8045. function baseAssign(object, source) {
  8046. return object && copyObject(source, keys(source), object);
  8047. }
  8048. /**
  8049. * The base implementation of `_.assignIn` without support for multiple sources
  8050. * or `customizer` functions.
  8051. *
  8052. * @private
  8053. * @param {Object} object The destination object.
  8054. * @param {Object} source The source object.
  8055. * @returns {Object} Returns `object`.
  8056. */
  8057. function baseAssignIn(object, source) {
  8058. return object && copyObject(source, keysIn(source), object);
  8059. }
  8060. /**
  8061. * The base implementation of `assignValue` and `assignMergeValue` without
  8062. * value checks.
  8063. *
  8064. * @private
  8065. * @param {Object} object The object to modify.
  8066. * @param {string} key The key of the property to assign.
  8067. * @param {*} value The value to assign.
  8068. */
  8069. function baseAssignValue(object, key, value) {
  8070. if (key == '__proto__' && defineProperty) {
  8071. defineProperty(object, key, {
  8072. 'configurable': true,
  8073. 'enumerable': true,
  8074. 'value': value,
  8075. 'writable': true
  8076. });
  8077. } else {
  8078. object[key] = value;
  8079. }
  8080. }
  8081. /**
  8082. * The base implementation of `_.at` without support for individual paths.
  8083. *
  8084. * @private
  8085. * @param {Object} object The object to iterate over.
  8086. * @param {string[]} paths The property paths to pick.
  8087. * @returns {Array} Returns the picked elements.
  8088. */
  8089. function baseAt(object, paths) {
  8090. var index = -1,
  8091. length = paths.length,
  8092. result = Array(length),
  8093. skip = object == null;
  8094. while (++index < length) {
  8095. result[index] = skip ? undefined$1 : get(object, paths[index]);
  8096. }
  8097. return result;
  8098. }
  8099. /**
  8100. * The base implementation of `_.clamp` which doesn't coerce arguments.
  8101. *
  8102. * @private
  8103. * @param {number} number The number to clamp.
  8104. * @param {number} [lower] The lower bound.
  8105. * @param {number} upper The upper bound.
  8106. * @returns {number} Returns the clamped number.
  8107. */
  8108. function baseClamp(number, lower, upper) {
  8109. if (number === number) {
  8110. if (upper !== undefined$1) {
  8111. number = number <= upper ? number : upper;
  8112. }
  8113. if (lower !== undefined$1) {
  8114. number = number >= lower ? number : lower;
  8115. }
  8116. }
  8117. return number;
  8118. }
  8119. /**
  8120. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  8121. * traversed objects.
  8122. *
  8123. * @private
  8124. * @param {*} value The value to clone.
  8125. * @param {boolean} bitmask The bitmask flags.
  8126. * 1 - Deep clone
  8127. * 2 - Flatten inherited properties
  8128. * 4 - Clone symbols
  8129. * @param {Function} [customizer] The function to customize cloning.
  8130. * @param {string} [key] The key of `value`.
  8131. * @param {Object} [object] The parent object of `value`.
  8132. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  8133. * @returns {*} Returns the cloned value.
  8134. */
  8135. function baseClone(value, bitmask, customizer, key, object, stack) {
  8136. var result,
  8137. isDeep = bitmask & CLONE_DEEP_FLAG,
  8138. isFlat = bitmask & CLONE_FLAT_FLAG,
  8139. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  8140. if (customizer) {
  8141. result = object ? customizer(value, key, object, stack) : customizer(value);
  8142. }
  8143. if (result !== undefined$1) {
  8144. return result;
  8145. }
  8146. if (!isObject(value)) {
  8147. return value;
  8148. }
  8149. var isArr = isArray(value);
  8150. if (isArr) {
  8151. result = initCloneArray(value);
  8152. if (!isDeep) {
  8153. return copyArray(value, result);
  8154. }
  8155. } else {
  8156. var tag = getTag(value),
  8157. isFunc = tag == funcTag || tag == genTag;
  8158. if (isBuffer(value)) {
  8159. return cloneBuffer(value, isDeep);
  8160. }
  8161. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  8162. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  8163. if (!isDeep) {
  8164. return isFlat
  8165. ? copySymbolsIn(value, baseAssignIn(result, value))
  8166. : copySymbols(value, baseAssign(result, value));
  8167. }
  8168. } else {
  8169. if (!cloneableTags[tag]) {
  8170. return object ? value : {};
  8171. }
  8172. result = initCloneByTag(value, tag, isDeep);
  8173. }
  8174. }
  8175. // Check for circular references and return its corresponding clone.
  8176. stack || (stack = new Stack);
  8177. var stacked = stack.get(value);
  8178. if (stacked) {
  8179. return stacked;
  8180. }
  8181. stack.set(value, result);
  8182. if (isSet(value)) {
  8183. value.forEach(function(subValue) {
  8184. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  8185. });
  8186. } else if (isMap(value)) {
  8187. value.forEach(function(subValue, key) {
  8188. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  8189. });
  8190. }
  8191. var keysFunc = isFull
  8192. ? (isFlat ? getAllKeysIn : getAllKeys)
  8193. : (isFlat ? keysIn : keys);
  8194. var props = isArr ? undefined$1 : keysFunc(value);
  8195. arrayEach(props || value, function(subValue, key) {
  8196. if (props) {
  8197. key = subValue;
  8198. subValue = value[key];
  8199. }
  8200. // Recursively populate clone (susceptible to call stack limits).
  8201. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  8202. });
  8203. return result;
  8204. }
  8205. /**
  8206. * The base implementation of `_.conforms` which doesn't clone `source`.
  8207. *
  8208. * @private
  8209. * @param {Object} source The object of property predicates to conform to.
  8210. * @returns {Function} Returns the new spec function.
  8211. */
  8212. function baseConforms(source) {
  8213. var props = keys(source);
  8214. return function(object) {
  8215. return baseConformsTo(object, source, props);
  8216. };
  8217. }
  8218. /**
  8219. * The base implementation of `_.conformsTo` which accepts `props` to check.
  8220. *
  8221. * @private
  8222. * @param {Object} object The object to inspect.
  8223. * @param {Object} source The object of property predicates to conform to.
  8224. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  8225. */
  8226. function baseConformsTo(object, source, props) {
  8227. var length = props.length;
  8228. if (object == null) {
  8229. return !length;
  8230. }
  8231. object = Object(object);
  8232. while (length--) {
  8233. var key = props[length],
  8234. predicate = source[key],
  8235. value = object[key];
  8236. if ((value === undefined$1 && !(key in object)) || !predicate(value)) {
  8237. return false;
  8238. }
  8239. }
  8240. return true;
  8241. }
  8242. /**
  8243. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  8244. * to provide to `func`.
  8245. *
  8246. * @private
  8247. * @param {Function} func The function to delay.
  8248. * @param {number} wait The number of milliseconds to delay invocation.
  8249. * @param {Array} args The arguments to provide to `func`.
  8250. * @returns {number|Object} Returns the timer id or timeout object.
  8251. */
  8252. function baseDelay(func, wait, args) {
  8253. if (typeof func != 'function') {
  8254. throw new TypeError(FUNC_ERROR_TEXT);
  8255. }
  8256. return setTimeout(function() { func.apply(undefined$1, args); }, wait);
  8257. }
  8258. /**
  8259. * The base implementation of methods like `_.difference` without support
  8260. * for excluding multiple arrays or iteratee shorthands.
  8261. *
  8262. * @private
  8263. * @param {Array} array The array to inspect.
  8264. * @param {Array} values The values to exclude.
  8265. * @param {Function} [iteratee] The iteratee invoked per element.
  8266. * @param {Function} [comparator] The comparator invoked per element.
  8267. * @returns {Array} Returns the new array of filtered values.
  8268. */
  8269. function baseDifference(array, values, iteratee, comparator) {
  8270. var index = -1,
  8271. includes = arrayIncludes,
  8272. isCommon = true,
  8273. length = array.length,
  8274. result = [],
  8275. valuesLength = values.length;
  8276. if (!length) {
  8277. return result;
  8278. }
  8279. if (iteratee) {
  8280. values = arrayMap(values, baseUnary(iteratee));
  8281. }
  8282. if (comparator) {
  8283. includes = arrayIncludesWith;
  8284. isCommon = false;
  8285. }
  8286. else if (values.length >= LARGE_ARRAY_SIZE) {
  8287. includes = cacheHas;
  8288. isCommon = false;
  8289. values = new SetCache(values);
  8290. }
  8291. outer:
  8292. while (++index < length) {
  8293. var value = array[index],
  8294. computed = iteratee == null ? value : iteratee(value);
  8295. value = (comparator || value !== 0) ? value : 0;
  8296. if (isCommon && computed === computed) {
  8297. var valuesIndex = valuesLength;
  8298. while (valuesIndex--) {
  8299. if (values[valuesIndex] === computed) {
  8300. continue outer;
  8301. }
  8302. }
  8303. result.push(value);
  8304. }
  8305. else if (!includes(values, computed, comparator)) {
  8306. result.push(value);
  8307. }
  8308. }
  8309. return result;
  8310. }
  8311. /**
  8312. * The base implementation of `_.forEach` without support for iteratee shorthands.
  8313. *
  8314. * @private
  8315. * @param {Array|Object} collection The collection to iterate over.
  8316. * @param {Function} iteratee The function invoked per iteration.
  8317. * @returns {Array|Object} Returns `collection`.
  8318. */
  8319. var baseEach = createBaseEach(baseForOwn);
  8320. /**
  8321. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  8322. *
  8323. * @private
  8324. * @param {Array|Object} collection The collection to iterate over.
  8325. * @param {Function} iteratee The function invoked per iteration.
  8326. * @returns {Array|Object} Returns `collection`.
  8327. */
  8328. var baseEachRight = createBaseEach(baseForOwnRight, true);
  8329. /**
  8330. * The base implementation of `_.every` without support for iteratee shorthands.
  8331. *
  8332. * @private
  8333. * @param {Array|Object} collection The collection to iterate over.
  8334. * @param {Function} predicate The function invoked per iteration.
  8335. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  8336. * else `false`
  8337. */
  8338. function baseEvery(collection, predicate) {
  8339. var result = true;
  8340. baseEach(collection, function(value, index, collection) {
  8341. result = !!predicate(value, index, collection);
  8342. return result;
  8343. });
  8344. return result;
  8345. }
  8346. /**
  8347. * The base implementation of methods like `_.max` and `_.min` which accepts a
  8348. * `comparator` to determine the extremum value.
  8349. *
  8350. * @private
  8351. * @param {Array} array The array to iterate over.
  8352. * @param {Function} iteratee The iteratee invoked per iteration.
  8353. * @param {Function} comparator The comparator used to compare values.
  8354. * @returns {*} Returns the extremum value.
  8355. */
  8356. function baseExtremum(array, iteratee, comparator) {
  8357. var index = -1,
  8358. length = array.length;
  8359. while (++index < length) {
  8360. var value = array[index],
  8361. current = iteratee(value);
  8362. if (current != null && (computed === undefined$1
  8363. ? (current === current && !isSymbol(current))
  8364. : comparator(current, computed)
  8365. )) {
  8366. var computed = current,
  8367. result = value;
  8368. }
  8369. }
  8370. return result;
  8371. }
  8372. /**
  8373. * The base implementation of `_.fill` without an iteratee call guard.
  8374. *
  8375. * @private
  8376. * @param {Array} array The array to fill.
  8377. * @param {*} value The value to fill `array` with.
  8378. * @param {number} [start=0] The start position.
  8379. * @param {number} [end=array.length] The end position.
  8380. * @returns {Array} Returns `array`.
  8381. */
  8382. function baseFill(array, value, start, end) {
  8383. var length = array.length;
  8384. start = toInteger(start);
  8385. if (start < 0) {
  8386. start = -start > length ? 0 : (length + start);
  8387. }
  8388. end = (end === undefined$1 || end > length) ? length : toInteger(end);
  8389. if (end < 0) {
  8390. end += length;
  8391. }
  8392. end = start > end ? 0 : toLength(end);
  8393. while (start < end) {
  8394. array[start++] = value;
  8395. }
  8396. return array;
  8397. }
  8398. /**
  8399. * The base implementation of `_.filter` without support for iteratee shorthands.
  8400. *
  8401. * @private
  8402. * @param {Array|Object} collection The collection to iterate over.
  8403. * @param {Function} predicate The function invoked per iteration.
  8404. * @returns {Array} Returns the new filtered array.
  8405. */
  8406. function baseFilter(collection, predicate) {
  8407. var result = [];
  8408. baseEach(collection, function(value, index, collection) {
  8409. if (predicate(value, index, collection)) {
  8410. result.push(value);
  8411. }
  8412. });
  8413. return result;
  8414. }
  8415. /**
  8416. * The base implementation of `_.flatten` with support for restricting flattening.
  8417. *
  8418. * @private
  8419. * @param {Array} array The array to flatten.
  8420. * @param {number} depth The maximum recursion depth.
  8421. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  8422. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  8423. * @param {Array} [result=[]] The initial result value.
  8424. * @returns {Array} Returns the new flattened array.
  8425. */
  8426. function baseFlatten(array, depth, predicate, isStrict, result) {
  8427. var index = -1,
  8428. length = array.length;
  8429. predicate || (predicate = isFlattenable);
  8430. result || (result = []);
  8431. while (++index < length) {
  8432. var value = array[index];
  8433. if (depth > 0 && predicate(value)) {
  8434. if (depth > 1) {
  8435. // Recursively flatten arrays (susceptible to call stack limits).
  8436. baseFlatten(value, depth - 1, predicate, isStrict, result);
  8437. } else {
  8438. arrayPush(result, value);
  8439. }
  8440. } else if (!isStrict) {
  8441. result[result.length] = value;
  8442. }
  8443. }
  8444. return result;
  8445. }
  8446. /**
  8447. * The base implementation of `baseForOwn` which iterates over `object`
  8448. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  8449. * Iteratee functions may exit iteration early by explicitly returning `false`.
  8450. *
  8451. * @private
  8452. * @param {Object} object The object to iterate over.
  8453. * @param {Function} iteratee The function invoked per iteration.
  8454. * @param {Function} keysFunc The function to get the keys of `object`.
  8455. * @returns {Object} Returns `object`.
  8456. */
  8457. var baseFor = createBaseFor();
  8458. /**
  8459. * This function is like `baseFor` except that it iterates over properties
  8460. * in the opposite order.
  8461. *
  8462. * @private
  8463. * @param {Object} object The object to iterate over.
  8464. * @param {Function} iteratee The function invoked per iteration.
  8465. * @param {Function} keysFunc The function to get the keys of `object`.
  8466. * @returns {Object} Returns `object`.
  8467. */
  8468. var baseForRight = createBaseFor(true);
  8469. /**
  8470. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  8471. *
  8472. * @private
  8473. * @param {Object} object The object to iterate over.
  8474. * @param {Function} iteratee The function invoked per iteration.
  8475. * @returns {Object} Returns `object`.
  8476. */
  8477. function baseForOwn(object, iteratee) {
  8478. return object && baseFor(object, iteratee, keys);
  8479. }
  8480. /**
  8481. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  8482. *
  8483. * @private
  8484. * @param {Object} object The object to iterate over.
  8485. * @param {Function} iteratee The function invoked per iteration.
  8486. * @returns {Object} Returns `object`.
  8487. */
  8488. function baseForOwnRight(object, iteratee) {
  8489. return object && baseForRight(object, iteratee, keys);
  8490. }
  8491. /**
  8492. * The base implementation of `_.functions` which creates an array of
  8493. * `object` function property names filtered from `props`.
  8494. *
  8495. * @private
  8496. * @param {Object} object The object to inspect.
  8497. * @param {Array} props The property names to filter.
  8498. * @returns {Array} Returns the function names.
  8499. */
  8500. function baseFunctions(object, props) {
  8501. return arrayFilter(props, function(key) {
  8502. return isFunction(object[key]);
  8503. });
  8504. }
  8505. /**
  8506. * The base implementation of `_.get` without support for default values.
  8507. *
  8508. * @private
  8509. * @param {Object} object The object to query.
  8510. * @param {Array|string} path The path of the property to get.
  8511. * @returns {*} Returns the resolved value.
  8512. */
  8513. function baseGet(object, path) {
  8514. path = castPath(path, object);
  8515. var index = 0,
  8516. length = path.length;
  8517. while (object != null && index < length) {
  8518. object = object[toKey(path[index++])];
  8519. }
  8520. return (index && index == length) ? object : undefined$1;
  8521. }
  8522. /**
  8523. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  8524. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  8525. * symbols of `object`.
  8526. *
  8527. * @private
  8528. * @param {Object} object The object to query.
  8529. * @param {Function} keysFunc The function to get the keys of `object`.
  8530. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  8531. * @returns {Array} Returns the array of property names and symbols.
  8532. */
  8533. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  8534. var result = keysFunc(object);
  8535. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  8536. }
  8537. /**
  8538. * The base implementation of `getTag` without fallbacks for buggy environments.
  8539. *
  8540. * @private
  8541. * @param {*} value The value to query.
  8542. * @returns {string} Returns the `toStringTag`.
  8543. */
  8544. function baseGetTag(value) {
  8545. if (value == null) {
  8546. return value === undefined$1 ? undefinedTag : nullTag;
  8547. }
  8548. return (symToStringTag && symToStringTag in Object(value))
  8549. ? getRawTag(value)
  8550. : objectToString(value);
  8551. }
  8552. /**
  8553. * The base implementation of `_.gt` which doesn't coerce arguments.
  8554. *
  8555. * @private
  8556. * @param {*} value The value to compare.
  8557. * @param {*} other The other value to compare.
  8558. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  8559. * else `false`.
  8560. */
  8561. function baseGt(value, other) {
  8562. return value > other;
  8563. }
  8564. /**
  8565. * The base implementation of `_.has` without support for deep paths.
  8566. *
  8567. * @private
  8568. * @param {Object} [object] The object to query.
  8569. * @param {Array|string} key The key to check.
  8570. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  8571. */
  8572. function baseHas(object, key) {
  8573. return object != null && hasOwnProperty.call(object, key);
  8574. }
  8575. /**
  8576. * The base implementation of `_.hasIn` without support for deep paths.
  8577. *
  8578. * @private
  8579. * @param {Object} [object] The object to query.
  8580. * @param {Array|string} key The key to check.
  8581. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  8582. */
  8583. function baseHasIn(object, key) {
  8584. return object != null && key in Object(object);
  8585. }
  8586. /**
  8587. * The base implementation of `_.inRange` which doesn't coerce arguments.
  8588. *
  8589. * @private
  8590. * @param {number} number The number to check.
  8591. * @param {number} start The start of the range.
  8592. * @param {number} end The end of the range.
  8593. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  8594. */
  8595. function baseInRange(number, start, end) {
  8596. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  8597. }
  8598. /**
  8599. * The base implementation of methods like `_.intersection`, without support
  8600. * for iteratee shorthands, that accepts an array of arrays to inspect.
  8601. *
  8602. * @private
  8603. * @param {Array} arrays The arrays to inspect.
  8604. * @param {Function} [iteratee] The iteratee invoked per element.
  8605. * @param {Function} [comparator] The comparator invoked per element.
  8606. * @returns {Array} Returns the new array of shared values.
  8607. */
  8608. function baseIntersection(arrays, iteratee, comparator) {
  8609. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  8610. length = arrays[0].length,
  8611. othLength = arrays.length,
  8612. othIndex = othLength,
  8613. caches = Array(othLength),
  8614. maxLength = Infinity,
  8615. result = [];
  8616. while (othIndex--) {
  8617. var array = arrays[othIndex];
  8618. if (othIndex && iteratee) {
  8619. array = arrayMap(array, baseUnary(iteratee));
  8620. }
  8621. maxLength = nativeMin(array.length, maxLength);
  8622. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  8623. ? new SetCache(othIndex && array)
  8624. : undefined$1;
  8625. }
  8626. array = arrays[0];
  8627. var index = -1,
  8628. seen = caches[0];
  8629. outer:
  8630. while (++index < length && result.length < maxLength) {
  8631. var value = array[index],
  8632. computed = iteratee ? iteratee(value) : value;
  8633. value = (comparator || value !== 0) ? value : 0;
  8634. if (!(seen
  8635. ? cacheHas(seen, computed)
  8636. : includes(result, computed, comparator)
  8637. )) {
  8638. othIndex = othLength;
  8639. while (--othIndex) {
  8640. var cache = caches[othIndex];
  8641. if (!(cache
  8642. ? cacheHas(cache, computed)
  8643. : includes(arrays[othIndex], computed, comparator))
  8644. ) {
  8645. continue outer;
  8646. }
  8647. }
  8648. if (seen) {
  8649. seen.push(computed);
  8650. }
  8651. result.push(value);
  8652. }
  8653. }
  8654. return result;
  8655. }
  8656. /**
  8657. * The base implementation of `_.invert` and `_.invertBy` which inverts
  8658. * `object` with values transformed by `iteratee` and set by `setter`.
  8659. *
  8660. * @private
  8661. * @param {Object} object The object to iterate over.
  8662. * @param {Function} setter The function to set `accumulator` values.
  8663. * @param {Function} iteratee The iteratee to transform values.
  8664. * @param {Object} accumulator The initial inverted object.
  8665. * @returns {Function} Returns `accumulator`.
  8666. */
  8667. function baseInverter(object, setter, iteratee, accumulator) {
  8668. baseForOwn(object, function(value, key, object) {
  8669. setter(accumulator, iteratee(value), key, object);
  8670. });
  8671. return accumulator;
  8672. }
  8673. /**
  8674. * The base implementation of `_.invoke` without support for individual
  8675. * method arguments.
  8676. *
  8677. * @private
  8678. * @param {Object} object The object to query.
  8679. * @param {Array|string} path The path of the method to invoke.
  8680. * @param {Array} args The arguments to invoke the method with.
  8681. * @returns {*} Returns the result of the invoked method.
  8682. */
  8683. function baseInvoke(object, path, args) {
  8684. path = castPath(path, object);
  8685. object = parent(object, path);
  8686. var func = object == null ? object : object[toKey(last(path))];
  8687. return func == null ? undefined$1 : apply(func, object, args);
  8688. }
  8689. /**
  8690. * The base implementation of `_.isArguments`.
  8691. *
  8692. * @private
  8693. * @param {*} value The value to check.
  8694. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  8695. */
  8696. function baseIsArguments(value) {
  8697. return isObjectLike(value) && baseGetTag(value) == argsTag;
  8698. }
  8699. /**
  8700. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  8701. *
  8702. * @private
  8703. * @param {*} value The value to check.
  8704. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  8705. */
  8706. function baseIsArrayBuffer(value) {
  8707. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  8708. }
  8709. /**
  8710. * The base implementation of `_.isDate` without Node.js optimizations.
  8711. *
  8712. * @private
  8713. * @param {*} value The value to check.
  8714. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  8715. */
  8716. function baseIsDate(value) {
  8717. return isObjectLike(value) && baseGetTag(value) == dateTag;
  8718. }
  8719. /**
  8720. * The base implementation of `_.isEqual` which supports partial comparisons
  8721. * and tracks traversed objects.
  8722. *
  8723. * @private
  8724. * @param {*} value The value to compare.
  8725. * @param {*} other The other value to compare.
  8726. * @param {boolean} bitmask The bitmask flags.
  8727. * 1 - Unordered comparison
  8728. * 2 - Partial comparison
  8729. * @param {Function} [customizer] The function to customize comparisons.
  8730. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  8731. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  8732. */
  8733. function baseIsEqual(value, other, bitmask, customizer, stack) {
  8734. if (value === other) {
  8735. return true;
  8736. }
  8737. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  8738. return value !== value && other !== other;
  8739. }
  8740. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  8741. }
  8742. /**
  8743. * A specialized version of `baseIsEqual` for arrays and objects which performs
  8744. * deep comparisons and tracks traversed objects enabling objects with circular
  8745. * references to be compared.
  8746. *
  8747. * @private
  8748. * @param {Object} object The object to compare.
  8749. * @param {Object} other The other object to compare.
  8750. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  8751. * @param {Function} customizer The function to customize comparisons.
  8752. * @param {Function} equalFunc The function to determine equivalents of values.
  8753. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  8754. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  8755. */
  8756. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  8757. var objIsArr = isArray(object),
  8758. othIsArr = isArray(other),
  8759. objTag = objIsArr ? arrayTag : getTag(object),
  8760. othTag = othIsArr ? arrayTag : getTag(other);
  8761. objTag = objTag == argsTag ? objectTag : objTag;
  8762. othTag = othTag == argsTag ? objectTag : othTag;
  8763. var objIsObj = objTag == objectTag,
  8764. othIsObj = othTag == objectTag,
  8765. isSameTag = objTag == othTag;
  8766. if (isSameTag && isBuffer(object)) {
  8767. if (!isBuffer(other)) {
  8768. return false;
  8769. }
  8770. objIsArr = true;
  8771. objIsObj = false;
  8772. }
  8773. if (isSameTag && !objIsObj) {
  8774. stack || (stack = new Stack);
  8775. return (objIsArr || isTypedArray(object))
  8776. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  8777. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  8778. }
  8779. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  8780. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  8781. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  8782. if (objIsWrapped || othIsWrapped) {
  8783. var objUnwrapped = objIsWrapped ? object.value() : object,
  8784. othUnwrapped = othIsWrapped ? other.value() : other;
  8785. stack || (stack = new Stack);
  8786. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  8787. }
  8788. }
  8789. if (!isSameTag) {
  8790. return false;
  8791. }
  8792. stack || (stack = new Stack);
  8793. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  8794. }
  8795. /**
  8796. * The base implementation of `_.isMap` without Node.js optimizations.
  8797. *
  8798. * @private
  8799. * @param {*} value The value to check.
  8800. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  8801. */
  8802. function baseIsMap(value) {
  8803. return isObjectLike(value) && getTag(value) == mapTag;
  8804. }
  8805. /**
  8806. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  8807. *
  8808. * @private
  8809. * @param {Object} object The object to inspect.
  8810. * @param {Object} source The object of property values to match.
  8811. * @param {Array} matchData The property names, values, and compare flags to match.
  8812. * @param {Function} [customizer] The function to customize comparisons.
  8813. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  8814. */
  8815. function baseIsMatch(object, source, matchData, customizer) {
  8816. var index = matchData.length,
  8817. length = index,
  8818. noCustomizer = !customizer;
  8819. if (object == null) {
  8820. return !length;
  8821. }
  8822. object = Object(object);
  8823. while (index--) {
  8824. var data = matchData[index];
  8825. if ((noCustomizer && data[2])
  8826. ? data[1] !== object[data[0]]
  8827. : !(data[0] in object)
  8828. ) {
  8829. return false;
  8830. }
  8831. }
  8832. while (++index < length) {
  8833. data = matchData[index];
  8834. var key = data[0],
  8835. objValue = object[key],
  8836. srcValue = data[1];
  8837. if (noCustomizer && data[2]) {
  8838. if (objValue === undefined$1 && !(key in object)) {
  8839. return false;
  8840. }
  8841. } else {
  8842. var stack = new Stack;
  8843. if (customizer) {
  8844. var result = customizer(objValue, srcValue, key, object, source, stack);
  8845. }
  8846. if (!(result === undefined$1
  8847. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  8848. : result
  8849. )) {
  8850. return false;
  8851. }
  8852. }
  8853. }
  8854. return true;
  8855. }
  8856. /**
  8857. * The base implementation of `_.isNative` without bad shim checks.
  8858. *
  8859. * @private
  8860. * @param {*} value The value to check.
  8861. * @returns {boolean} Returns `true` if `value` is a native function,
  8862. * else `false`.
  8863. */
  8864. function baseIsNative(value) {
  8865. if (!isObject(value) || isMasked(value)) {
  8866. return false;
  8867. }
  8868. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  8869. return pattern.test(toSource(value));
  8870. }
  8871. /**
  8872. * The base implementation of `_.isRegExp` without Node.js optimizations.
  8873. *
  8874. * @private
  8875. * @param {*} value The value to check.
  8876. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  8877. */
  8878. function baseIsRegExp(value) {
  8879. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  8880. }
  8881. /**
  8882. * The base implementation of `_.isSet` without Node.js optimizations.
  8883. *
  8884. * @private
  8885. * @param {*} value The value to check.
  8886. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  8887. */
  8888. function baseIsSet(value) {
  8889. return isObjectLike(value) && getTag(value) == setTag;
  8890. }
  8891. /**
  8892. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  8893. *
  8894. * @private
  8895. * @param {*} value The value to check.
  8896. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  8897. */
  8898. function baseIsTypedArray(value) {
  8899. return isObjectLike(value) &&
  8900. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  8901. }
  8902. /**
  8903. * The base implementation of `_.iteratee`.
  8904. *
  8905. * @private
  8906. * @param {*} [value=_.identity] The value to convert to an iteratee.
  8907. * @returns {Function} Returns the iteratee.
  8908. */
  8909. function baseIteratee(value) {
  8910. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  8911. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  8912. if (typeof value == 'function') {
  8913. return value;
  8914. }
  8915. if (value == null) {
  8916. return identity;
  8917. }
  8918. if (typeof value == 'object') {
  8919. return isArray(value)
  8920. ? baseMatchesProperty(value[0], value[1])
  8921. : baseMatches(value);
  8922. }
  8923. return property(value);
  8924. }
  8925. /**
  8926. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  8927. *
  8928. * @private
  8929. * @param {Object} object The object to query.
  8930. * @returns {Array} Returns the array of property names.
  8931. */
  8932. function baseKeys(object) {
  8933. if (!isPrototype(object)) {
  8934. return nativeKeys(object);
  8935. }
  8936. var result = [];
  8937. for (var key in Object(object)) {
  8938. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  8939. result.push(key);
  8940. }
  8941. }
  8942. return result;
  8943. }
  8944. /**
  8945. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  8946. *
  8947. * @private
  8948. * @param {Object} object The object to query.
  8949. * @returns {Array} Returns the array of property names.
  8950. */
  8951. function baseKeysIn(object) {
  8952. if (!isObject(object)) {
  8953. return nativeKeysIn(object);
  8954. }
  8955. var isProto = isPrototype(object),
  8956. result = [];
  8957. for (var key in object) {
  8958. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  8959. result.push(key);
  8960. }
  8961. }
  8962. return result;
  8963. }
  8964. /**
  8965. * The base implementation of `_.lt` which doesn't coerce arguments.
  8966. *
  8967. * @private
  8968. * @param {*} value The value to compare.
  8969. * @param {*} other The other value to compare.
  8970. * @returns {boolean} Returns `true` if `value` is less than `other`,
  8971. * else `false`.
  8972. */
  8973. function baseLt(value, other) {
  8974. return value < other;
  8975. }
  8976. /**
  8977. * The base implementation of `_.map` without support for iteratee shorthands.
  8978. *
  8979. * @private
  8980. * @param {Array|Object} collection The collection to iterate over.
  8981. * @param {Function} iteratee The function invoked per iteration.
  8982. * @returns {Array} Returns the new mapped array.
  8983. */
  8984. function baseMap(collection, iteratee) {
  8985. var index = -1,
  8986. result = isArrayLike(collection) ? Array(collection.length) : [];
  8987. baseEach(collection, function(value, key, collection) {
  8988. result[++index] = iteratee(value, key, collection);
  8989. });
  8990. return result;
  8991. }
  8992. /**
  8993. * The base implementation of `_.matches` which doesn't clone `source`.
  8994. *
  8995. * @private
  8996. * @param {Object} source The object of property values to match.
  8997. * @returns {Function} Returns the new spec function.
  8998. */
  8999. function baseMatches(source) {
  9000. var matchData = getMatchData(source);
  9001. if (matchData.length == 1 && matchData[0][2]) {
  9002. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  9003. }
  9004. return function(object) {
  9005. return object === source || baseIsMatch(object, source, matchData);
  9006. };
  9007. }
  9008. /**
  9009. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  9010. *
  9011. * @private
  9012. * @param {string} path The path of the property to get.
  9013. * @param {*} srcValue The value to match.
  9014. * @returns {Function} Returns the new spec function.
  9015. */
  9016. function baseMatchesProperty(path, srcValue) {
  9017. if (isKey(path) && isStrictComparable(srcValue)) {
  9018. return matchesStrictComparable(toKey(path), srcValue);
  9019. }
  9020. return function(object) {
  9021. var objValue = get(object, path);
  9022. return (objValue === undefined$1 && objValue === srcValue)
  9023. ? hasIn(object, path)
  9024. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  9025. };
  9026. }
  9027. /**
  9028. * The base implementation of `_.merge` without support for multiple sources.
  9029. *
  9030. * @private
  9031. * @param {Object} object The destination object.
  9032. * @param {Object} source The source object.
  9033. * @param {number} srcIndex The index of `source`.
  9034. * @param {Function} [customizer] The function to customize merged values.
  9035. * @param {Object} [stack] Tracks traversed source values and their merged
  9036. * counterparts.
  9037. */
  9038. function baseMerge(object, source, srcIndex, customizer, stack) {
  9039. if (object === source) {
  9040. return;
  9041. }
  9042. baseFor(source, function(srcValue, key) {
  9043. stack || (stack = new Stack);
  9044. if (isObject(srcValue)) {
  9045. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  9046. }
  9047. else {
  9048. var newValue = customizer
  9049. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  9050. : undefined$1;
  9051. if (newValue === undefined$1) {
  9052. newValue = srcValue;
  9053. }
  9054. assignMergeValue(object, key, newValue);
  9055. }
  9056. }, keysIn);
  9057. }
  9058. /**
  9059. * A specialized version of `baseMerge` for arrays and objects which performs
  9060. * deep merges and tracks traversed objects enabling objects with circular
  9061. * references to be merged.
  9062. *
  9063. * @private
  9064. * @param {Object} object The destination object.
  9065. * @param {Object} source The source object.
  9066. * @param {string} key The key of the value to merge.
  9067. * @param {number} srcIndex The index of `source`.
  9068. * @param {Function} mergeFunc The function to merge values.
  9069. * @param {Function} [customizer] The function to customize assigned values.
  9070. * @param {Object} [stack] Tracks traversed source values and their merged
  9071. * counterparts.
  9072. */
  9073. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  9074. var objValue = safeGet(object, key),
  9075. srcValue = safeGet(source, key),
  9076. stacked = stack.get(srcValue);
  9077. if (stacked) {
  9078. assignMergeValue(object, key, stacked);
  9079. return;
  9080. }
  9081. var newValue = customizer
  9082. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  9083. : undefined$1;
  9084. var isCommon = newValue === undefined$1;
  9085. if (isCommon) {
  9086. var isArr = isArray(srcValue),
  9087. isBuff = !isArr && isBuffer(srcValue),
  9088. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  9089. newValue = srcValue;
  9090. if (isArr || isBuff || isTyped) {
  9091. if (isArray(objValue)) {
  9092. newValue = objValue;
  9093. }
  9094. else if (isArrayLikeObject(objValue)) {
  9095. newValue = copyArray(objValue);
  9096. }
  9097. else if (isBuff) {
  9098. isCommon = false;
  9099. newValue = cloneBuffer(srcValue, true);
  9100. }
  9101. else if (isTyped) {
  9102. isCommon = false;
  9103. newValue = cloneTypedArray(srcValue, true);
  9104. }
  9105. else {
  9106. newValue = [];
  9107. }
  9108. }
  9109. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  9110. newValue = objValue;
  9111. if (isArguments(objValue)) {
  9112. newValue = toPlainObject(objValue);
  9113. }
  9114. else if (!isObject(objValue) || isFunction(objValue)) {
  9115. newValue = initCloneObject(srcValue);
  9116. }
  9117. }
  9118. else {
  9119. isCommon = false;
  9120. }
  9121. }
  9122. if (isCommon) {
  9123. // Recursively merge objects and arrays (susceptible to call stack limits).
  9124. stack.set(srcValue, newValue);
  9125. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  9126. stack['delete'](srcValue);
  9127. }
  9128. assignMergeValue(object, key, newValue);
  9129. }
  9130. /**
  9131. * The base implementation of `_.nth` which doesn't coerce arguments.
  9132. *
  9133. * @private
  9134. * @param {Array} array The array to query.
  9135. * @param {number} n The index of the element to return.
  9136. * @returns {*} Returns the nth element of `array`.
  9137. */
  9138. function baseNth(array, n) {
  9139. var length = array.length;
  9140. if (!length) {
  9141. return;
  9142. }
  9143. n += n < 0 ? length : 0;
  9144. return isIndex(n, length) ? array[n] : undefined$1;
  9145. }
  9146. /**
  9147. * The base implementation of `_.orderBy` without param guards.
  9148. *
  9149. * @private
  9150. * @param {Array|Object} collection The collection to iterate over.
  9151. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  9152. * @param {string[]} orders The sort orders of `iteratees`.
  9153. * @returns {Array} Returns the new sorted array.
  9154. */
  9155. function baseOrderBy(collection, iteratees, orders) {
  9156. if (iteratees.length) {
  9157. iteratees = arrayMap(iteratees, function(iteratee) {
  9158. if (isArray(iteratee)) {
  9159. return function(value) {
  9160. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  9161. }
  9162. }
  9163. return iteratee;
  9164. });
  9165. } else {
  9166. iteratees = [identity];
  9167. }
  9168. var index = -1;
  9169. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  9170. var result = baseMap(collection, function(value, key, collection) {
  9171. var criteria = arrayMap(iteratees, function(iteratee) {
  9172. return iteratee(value);
  9173. });
  9174. return { 'criteria': criteria, 'index': ++index, 'value': value };
  9175. });
  9176. return baseSortBy(result, function(object, other) {
  9177. return compareMultiple(object, other, orders);
  9178. });
  9179. }
  9180. /**
  9181. * The base implementation of `_.pick` without support for individual
  9182. * property identifiers.
  9183. *
  9184. * @private
  9185. * @param {Object} object The source object.
  9186. * @param {string[]} paths The property paths to pick.
  9187. * @returns {Object} Returns the new object.
  9188. */
  9189. function basePick(object, paths) {
  9190. return basePickBy(object, paths, function(value, path) {
  9191. return hasIn(object, path);
  9192. });
  9193. }
  9194. /**
  9195. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  9196. *
  9197. * @private
  9198. * @param {Object} object The source object.
  9199. * @param {string[]} paths The property paths to pick.
  9200. * @param {Function} predicate The function invoked per property.
  9201. * @returns {Object} Returns the new object.
  9202. */
  9203. function basePickBy(object, paths, predicate) {
  9204. var index = -1,
  9205. length = paths.length,
  9206. result = {};
  9207. while (++index < length) {
  9208. var path = paths[index],
  9209. value = baseGet(object, path);
  9210. if (predicate(value, path)) {
  9211. baseSet(result, castPath(path, object), value);
  9212. }
  9213. }
  9214. return result;
  9215. }
  9216. /**
  9217. * A specialized version of `baseProperty` which supports deep paths.
  9218. *
  9219. * @private
  9220. * @param {Array|string} path The path of the property to get.
  9221. * @returns {Function} Returns the new accessor function.
  9222. */
  9223. function basePropertyDeep(path) {
  9224. return function(object) {
  9225. return baseGet(object, path);
  9226. };
  9227. }
  9228. /**
  9229. * The base implementation of `_.pullAllBy` without support for iteratee
  9230. * shorthands.
  9231. *
  9232. * @private
  9233. * @param {Array} array The array to modify.
  9234. * @param {Array} values The values to remove.
  9235. * @param {Function} [iteratee] The iteratee invoked per element.
  9236. * @param {Function} [comparator] The comparator invoked per element.
  9237. * @returns {Array} Returns `array`.
  9238. */
  9239. function basePullAll(array, values, iteratee, comparator) {
  9240. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  9241. index = -1,
  9242. length = values.length,
  9243. seen = array;
  9244. if (array === values) {
  9245. values = copyArray(values);
  9246. }
  9247. if (iteratee) {
  9248. seen = arrayMap(array, baseUnary(iteratee));
  9249. }
  9250. while (++index < length) {
  9251. var fromIndex = 0,
  9252. value = values[index],
  9253. computed = iteratee ? iteratee(value) : value;
  9254. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  9255. if (seen !== array) {
  9256. splice.call(seen, fromIndex, 1);
  9257. }
  9258. splice.call(array, fromIndex, 1);
  9259. }
  9260. }
  9261. return array;
  9262. }
  9263. /**
  9264. * The base implementation of `_.pullAt` without support for individual
  9265. * indexes or capturing the removed elements.
  9266. *
  9267. * @private
  9268. * @param {Array} array The array to modify.
  9269. * @param {number[]} indexes The indexes of elements to remove.
  9270. * @returns {Array} Returns `array`.
  9271. */
  9272. function basePullAt(array, indexes) {
  9273. var length = array ? indexes.length : 0,
  9274. lastIndex = length - 1;
  9275. while (length--) {
  9276. var index = indexes[length];
  9277. if (length == lastIndex || index !== previous) {
  9278. var previous = index;
  9279. if (isIndex(index)) {
  9280. splice.call(array, index, 1);
  9281. } else {
  9282. baseUnset(array, index);
  9283. }
  9284. }
  9285. }
  9286. return array;
  9287. }
  9288. /**
  9289. * The base implementation of `_.random` without support for returning
  9290. * floating-point numbers.
  9291. *
  9292. * @private
  9293. * @param {number} lower The lower bound.
  9294. * @param {number} upper The upper bound.
  9295. * @returns {number} Returns the random number.
  9296. */
  9297. function baseRandom(lower, upper) {
  9298. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  9299. }
  9300. /**
  9301. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  9302. * coerce arguments.
  9303. *
  9304. * @private
  9305. * @param {number} start The start of the range.
  9306. * @param {number} end The end of the range.
  9307. * @param {number} step The value to increment or decrement by.
  9308. * @param {boolean} [fromRight] Specify iterating from right to left.
  9309. * @returns {Array} Returns the range of numbers.
  9310. */
  9311. function baseRange(start, end, step, fromRight) {
  9312. var index = -1,
  9313. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  9314. result = Array(length);
  9315. while (length--) {
  9316. result[fromRight ? length : ++index] = start;
  9317. start += step;
  9318. }
  9319. return result;
  9320. }
  9321. /**
  9322. * The base implementation of `_.repeat` which doesn't coerce arguments.
  9323. *
  9324. * @private
  9325. * @param {string} string The string to repeat.
  9326. * @param {number} n The number of times to repeat the string.
  9327. * @returns {string} Returns the repeated string.
  9328. */
  9329. function baseRepeat(string, n) {
  9330. var result = '';
  9331. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  9332. return result;
  9333. }
  9334. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  9335. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  9336. do {
  9337. if (n % 2) {
  9338. result += string;
  9339. }
  9340. n = nativeFloor(n / 2);
  9341. if (n) {
  9342. string += string;
  9343. }
  9344. } while (n);
  9345. return result;
  9346. }
  9347. /**
  9348. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  9349. *
  9350. * @private
  9351. * @param {Function} func The function to apply a rest parameter to.
  9352. * @param {number} [start=func.length-1] The start position of the rest parameter.
  9353. * @returns {Function} Returns the new function.
  9354. */
  9355. function baseRest(func, start) {
  9356. return setToString(overRest(func, start, identity), func + '');
  9357. }
  9358. /**
  9359. * The base implementation of `_.sample`.
  9360. *
  9361. * @private
  9362. * @param {Array|Object} collection The collection to sample.
  9363. * @returns {*} Returns the random element.
  9364. */
  9365. function baseSample(collection) {
  9366. return arraySample(values(collection));
  9367. }
  9368. /**
  9369. * The base implementation of `_.sampleSize` without param guards.
  9370. *
  9371. * @private
  9372. * @param {Array|Object} collection The collection to sample.
  9373. * @param {number} n The number of elements to sample.
  9374. * @returns {Array} Returns the random elements.
  9375. */
  9376. function baseSampleSize(collection, n) {
  9377. var array = values(collection);
  9378. return shuffleSelf(array, baseClamp(n, 0, array.length));
  9379. }
  9380. /**
  9381. * The base implementation of `_.set`.
  9382. *
  9383. * @private
  9384. * @param {Object} object The object to modify.
  9385. * @param {Array|string} path The path of the property to set.
  9386. * @param {*} value The value to set.
  9387. * @param {Function} [customizer] The function to customize path creation.
  9388. * @returns {Object} Returns `object`.
  9389. */
  9390. function baseSet(object, path, value, customizer) {
  9391. if (!isObject(object)) {
  9392. return object;
  9393. }
  9394. path = castPath(path, object);
  9395. var index = -1,
  9396. length = path.length,
  9397. lastIndex = length - 1,
  9398. nested = object;
  9399. while (nested != null && ++index < length) {
  9400. var key = toKey(path[index]),
  9401. newValue = value;
  9402. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  9403. return object;
  9404. }
  9405. if (index != lastIndex) {
  9406. var objValue = nested[key];
  9407. newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
  9408. if (newValue === undefined$1) {
  9409. newValue = isObject(objValue)
  9410. ? objValue
  9411. : (isIndex(path[index + 1]) ? [] : {});
  9412. }
  9413. }
  9414. assignValue(nested, key, newValue);
  9415. nested = nested[key];
  9416. }
  9417. return object;
  9418. }
  9419. /**
  9420. * The base implementation of `setData` without support for hot loop shorting.
  9421. *
  9422. * @private
  9423. * @param {Function} func The function to associate metadata with.
  9424. * @param {*} data The metadata.
  9425. * @returns {Function} Returns `func`.
  9426. */
  9427. var baseSetData = !metaMap ? identity : function(func, data) {
  9428. metaMap.set(func, data);
  9429. return func;
  9430. };
  9431. /**
  9432. * The base implementation of `setToString` without support for hot loop shorting.
  9433. *
  9434. * @private
  9435. * @param {Function} func The function to modify.
  9436. * @param {Function} string The `toString` result.
  9437. * @returns {Function} Returns `func`.
  9438. */
  9439. var baseSetToString = !defineProperty ? identity : function(func, string) {
  9440. return defineProperty(func, 'toString', {
  9441. 'configurable': true,
  9442. 'enumerable': false,
  9443. 'value': constant(string),
  9444. 'writable': true
  9445. });
  9446. };
  9447. /**
  9448. * The base implementation of `_.shuffle`.
  9449. *
  9450. * @private
  9451. * @param {Array|Object} collection The collection to shuffle.
  9452. * @returns {Array} Returns the new shuffled array.
  9453. */
  9454. function baseShuffle(collection) {
  9455. return shuffleSelf(values(collection));
  9456. }
  9457. /**
  9458. * The base implementation of `_.slice` without an iteratee call guard.
  9459. *
  9460. * @private
  9461. * @param {Array} array The array to slice.
  9462. * @param {number} [start=0] The start position.
  9463. * @param {number} [end=array.length] The end position.
  9464. * @returns {Array} Returns the slice of `array`.
  9465. */
  9466. function baseSlice(array, start, end) {
  9467. var index = -1,
  9468. length = array.length;
  9469. if (start < 0) {
  9470. start = -start > length ? 0 : (length + start);
  9471. }
  9472. end = end > length ? length : end;
  9473. if (end < 0) {
  9474. end += length;
  9475. }
  9476. length = start > end ? 0 : ((end - start) >>> 0);
  9477. start >>>= 0;
  9478. var result = Array(length);
  9479. while (++index < length) {
  9480. result[index] = array[index + start];
  9481. }
  9482. return result;
  9483. }
  9484. /**
  9485. * The base implementation of `_.some` without support for iteratee shorthands.
  9486. *
  9487. * @private
  9488. * @param {Array|Object} collection The collection to iterate over.
  9489. * @param {Function} predicate The function invoked per iteration.
  9490. * @returns {boolean} Returns `true` if any element passes the predicate check,
  9491. * else `false`.
  9492. */
  9493. function baseSome(collection, predicate) {
  9494. var result;
  9495. baseEach(collection, function(value, index, collection) {
  9496. result = predicate(value, index, collection);
  9497. return !result;
  9498. });
  9499. return !!result;
  9500. }
  9501. /**
  9502. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  9503. * performs a binary search of `array` to determine the index at which `value`
  9504. * should be inserted into `array` in order to maintain its sort order.
  9505. *
  9506. * @private
  9507. * @param {Array} array The sorted array to inspect.
  9508. * @param {*} value The value to evaluate.
  9509. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  9510. * @returns {number} Returns the index at which `value` should be inserted
  9511. * into `array`.
  9512. */
  9513. function baseSortedIndex(array, value, retHighest) {
  9514. var low = 0,
  9515. high = array == null ? low : array.length;
  9516. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  9517. while (low < high) {
  9518. var mid = (low + high) >>> 1,
  9519. computed = array[mid];
  9520. if (computed !== null && !isSymbol(computed) &&
  9521. (retHighest ? (computed <= value) : (computed < value))) {
  9522. low = mid + 1;
  9523. } else {
  9524. high = mid;
  9525. }
  9526. }
  9527. return high;
  9528. }
  9529. return baseSortedIndexBy(array, value, identity, retHighest);
  9530. }
  9531. /**
  9532. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  9533. * which invokes `iteratee` for `value` and each element of `array` to compute
  9534. * their sort ranking. The iteratee is invoked with one argument; (value).
  9535. *
  9536. * @private
  9537. * @param {Array} array The sorted array to inspect.
  9538. * @param {*} value The value to evaluate.
  9539. * @param {Function} iteratee The iteratee invoked per element.
  9540. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  9541. * @returns {number} Returns the index at which `value` should be inserted
  9542. * into `array`.
  9543. */
  9544. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  9545. var low = 0,
  9546. high = array == null ? 0 : array.length;
  9547. if (high === 0) {
  9548. return 0;
  9549. }
  9550. value = iteratee(value);
  9551. var valIsNaN = value !== value,
  9552. valIsNull = value === null,
  9553. valIsSymbol = isSymbol(value),
  9554. valIsUndefined = value === undefined$1;
  9555. while (low < high) {
  9556. var mid = nativeFloor((low + high) / 2),
  9557. computed = iteratee(array[mid]),
  9558. othIsDefined = computed !== undefined$1,
  9559. othIsNull = computed === null,
  9560. othIsReflexive = computed === computed,
  9561. othIsSymbol = isSymbol(computed);
  9562. if (valIsNaN) {
  9563. var setLow = retHighest || othIsReflexive;
  9564. } else if (valIsUndefined) {
  9565. setLow = othIsReflexive && (retHighest || othIsDefined);
  9566. } else if (valIsNull) {
  9567. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  9568. } else if (valIsSymbol) {
  9569. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  9570. } else if (othIsNull || othIsSymbol) {
  9571. setLow = false;
  9572. } else {
  9573. setLow = retHighest ? (computed <= value) : (computed < value);
  9574. }
  9575. if (setLow) {
  9576. low = mid + 1;
  9577. } else {
  9578. high = mid;
  9579. }
  9580. }
  9581. return nativeMin(high, MAX_ARRAY_INDEX);
  9582. }
  9583. /**
  9584. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  9585. * support for iteratee shorthands.
  9586. *
  9587. * @private
  9588. * @param {Array} array The array to inspect.
  9589. * @param {Function} [iteratee] The iteratee invoked per element.
  9590. * @returns {Array} Returns the new duplicate free array.
  9591. */
  9592. function baseSortedUniq(array, iteratee) {
  9593. var index = -1,
  9594. length = array.length,
  9595. resIndex = 0,
  9596. result = [];
  9597. while (++index < length) {
  9598. var value = array[index],
  9599. computed = iteratee ? iteratee(value) : value;
  9600. if (!index || !eq(computed, seen)) {
  9601. var seen = computed;
  9602. result[resIndex++] = value === 0 ? 0 : value;
  9603. }
  9604. }
  9605. return result;
  9606. }
  9607. /**
  9608. * The base implementation of `_.toNumber` which doesn't ensure correct
  9609. * conversions of binary, hexadecimal, or octal string values.
  9610. *
  9611. * @private
  9612. * @param {*} value The value to process.
  9613. * @returns {number} Returns the number.
  9614. */
  9615. function baseToNumber(value) {
  9616. if (typeof value == 'number') {
  9617. return value;
  9618. }
  9619. if (isSymbol(value)) {
  9620. return NAN;
  9621. }
  9622. return +value;
  9623. }
  9624. /**
  9625. * The base implementation of `_.toString` which doesn't convert nullish
  9626. * values to empty strings.
  9627. *
  9628. * @private
  9629. * @param {*} value The value to process.
  9630. * @returns {string} Returns the string.
  9631. */
  9632. function baseToString(value) {
  9633. // Exit early for strings to avoid a performance hit in some environments.
  9634. if (typeof value == 'string') {
  9635. return value;
  9636. }
  9637. if (isArray(value)) {
  9638. // Recursively convert values (susceptible to call stack limits).
  9639. return arrayMap(value, baseToString) + '';
  9640. }
  9641. if (isSymbol(value)) {
  9642. return symbolToString ? symbolToString.call(value) : '';
  9643. }
  9644. var result = (value + '');
  9645. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  9646. }
  9647. /**
  9648. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  9649. *
  9650. * @private
  9651. * @param {Array} array The array to inspect.
  9652. * @param {Function} [iteratee] The iteratee invoked per element.
  9653. * @param {Function} [comparator] The comparator invoked per element.
  9654. * @returns {Array} Returns the new duplicate free array.
  9655. */
  9656. function baseUniq(array, iteratee, comparator) {
  9657. var index = -1,
  9658. includes = arrayIncludes,
  9659. length = array.length,
  9660. isCommon = true,
  9661. result = [],
  9662. seen = result;
  9663. if (comparator) {
  9664. isCommon = false;
  9665. includes = arrayIncludesWith;
  9666. }
  9667. else if (length >= LARGE_ARRAY_SIZE) {
  9668. var set = iteratee ? null : createSet(array);
  9669. if (set) {
  9670. return setToArray(set);
  9671. }
  9672. isCommon = false;
  9673. includes = cacheHas;
  9674. seen = new SetCache;
  9675. }
  9676. else {
  9677. seen = iteratee ? [] : result;
  9678. }
  9679. outer:
  9680. while (++index < length) {
  9681. var value = array[index],
  9682. computed = iteratee ? iteratee(value) : value;
  9683. value = (comparator || value !== 0) ? value : 0;
  9684. if (isCommon && computed === computed) {
  9685. var seenIndex = seen.length;
  9686. while (seenIndex--) {
  9687. if (seen[seenIndex] === computed) {
  9688. continue outer;
  9689. }
  9690. }
  9691. if (iteratee) {
  9692. seen.push(computed);
  9693. }
  9694. result.push(value);
  9695. }
  9696. else if (!includes(seen, computed, comparator)) {
  9697. if (seen !== result) {
  9698. seen.push(computed);
  9699. }
  9700. result.push(value);
  9701. }
  9702. }
  9703. return result;
  9704. }
  9705. /**
  9706. * The base implementation of `_.unset`.
  9707. *
  9708. * @private
  9709. * @param {Object} object The object to modify.
  9710. * @param {Array|string} path The property path to unset.
  9711. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  9712. */
  9713. function baseUnset(object, path) {
  9714. path = castPath(path, object);
  9715. object = parent(object, path);
  9716. return object == null || delete object[toKey(last(path))];
  9717. }
  9718. /**
  9719. * The base implementation of `_.update`.
  9720. *
  9721. * @private
  9722. * @param {Object} object The object to modify.
  9723. * @param {Array|string} path The path of the property to update.
  9724. * @param {Function} updater The function to produce the updated value.
  9725. * @param {Function} [customizer] The function to customize path creation.
  9726. * @returns {Object} Returns `object`.
  9727. */
  9728. function baseUpdate(object, path, updater, customizer) {
  9729. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  9730. }
  9731. /**
  9732. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  9733. * without support for iteratee shorthands.
  9734. *
  9735. * @private
  9736. * @param {Array} array The array to query.
  9737. * @param {Function} predicate The function invoked per iteration.
  9738. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  9739. * @param {boolean} [fromRight] Specify iterating from right to left.
  9740. * @returns {Array} Returns the slice of `array`.
  9741. */
  9742. function baseWhile(array, predicate, isDrop, fromRight) {
  9743. var length = array.length,
  9744. index = fromRight ? length : -1;
  9745. while ((fromRight ? index-- : ++index < length) &&
  9746. predicate(array[index], index, array)) {}
  9747. return isDrop
  9748. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  9749. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  9750. }
  9751. /**
  9752. * The base implementation of `wrapperValue` which returns the result of
  9753. * performing a sequence of actions on the unwrapped `value`, where each
  9754. * successive action is supplied the return value of the previous.
  9755. *
  9756. * @private
  9757. * @param {*} value The unwrapped value.
  9758. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  9759. * @returns {*} Returns the resolved value.
  9760. */
  9761. function baseWrapperValue(value, actions) {
  9762. var result = value;
  9763. if (result instanceof LazyWrapper) {
  9764. result = result.value();
  9765. }
  9766. return arrayReduce(actions, function(result, action) {
  9767. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  9768. }, result);
  9769. }
  9770. /**
  9771. * The base implementation of methods like `_.xor`, without support for
  9772. * iteratee shorthands, that accepts an array of arrays to inspect.
  9773. *
  9774. * @private
  9775. * @param {Array} arrays The arrays to inspect.
  9776. * @param {Function} [iteratee] The iteratee invoked per element.
  9777. * @param {Function} [comparator] The comparator invoked per element.
  9778. * @returns {Array} Returns the new array of values.
  9779. */
  9780. function baseXor(arrays, iteratee, comparator) {
  9781. var length = arrays.length;
  9782. if (length < 2) {
  9783. return length ? baseUniq(arrays[0]) : [];
  9784. }
  9785. var index = -1,
  9786. result = Array(length);
  9787. while (++index < length) {
  9788. var array = arrays[index],
  9789. othIndex = -1;
  9790. while (++othIndex < length) {
  9791. if (othIndex != index) {
  9792. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  9793. }
  9794. }
  9795. }
  9796. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  9797. }
  9798. /**
  9799. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  9800. *
  9801. * @private
  9802. * @param {Array} props The property identifiers.
  9803. * @param {Array} values The property values.
  9804. * @param {Function} assignFunc The function to assign values.
  9805. * @returns {Object} Returns the new object.
  9806. */
  9807. function baseZipObject(props, values, assignFunc) {
  9808. var index = -1,
  9809. length = props.length,
  9810. valsLength = values.length,
  9811. result = {};
  9812. while (++index < length) {
  9813. var value = index < valsLength ? values[index] : undefined$1;
  9814. assignFunc(result, props[index], value);
  9815. }
  9816. return result;
  9817. }
  9818. /**
  9819. * Casts `value` to an empty array if it's not an array like object.
  9820. *
  9821. * @private
  9822. * @param {*} value The value to inspect.
  9823. * @returns {Array|Object} Returns the cast array-like object.
  9824. */
  9825. function castArrayLikeObject(value) {
  9826. return isArrayLikeObject(value) ? value : [];
  9827. }
  9828. /**
  9829. * Casts `value` to `identity` if it's not a function.
  9830. *
  9831. * @private
  9832. * @param {*} value The value to inspect.
  9833. * @returns {Function} Returns cast function.
  9834. */
  9835. function castFunction(value) {
  9836. return typeof value == 'function' ? value : identity;
  9837. }
  9838. /**
  9839. * Casts `value` to a path array if it's not one.
  9840. *
  9841. * @private
  9842. * @param {*} value The value to inspect.
  9843. * @param {Object} [object] The object to query keys on.
  9844. * @returns {Array} Returns the cast property path array.
  9845. */
  9846. function castPath(value, object) {
  9847. if (isArray(value)) {
  9848. return value;
  9849. }
  9850. return isKey(value, object) ? [value] : stringToPath(toString(value));
  9851. }
  9852. /**
  9853. * A `baseRest` alias which can be replaced with `identity` by module
  9854. * replacement plugins.
  9855. *
  9856. * @private
  9857. * @type {Function}
  9858. * @param {Function} func The function to apply a rest parameter to.
  9859. * @returns {Function} Returns the new function.
  9860. */
  9861. var castRest = baseRest;
  9862. /**
  9863. * Casts `array` to a slice if it's needed.
  9864. *
  9865. * @private
  9866. * @param {Array} array The array to inspect.
  9867. * @param {number} start The start position.
  9868. * @param {number} [end=array.length] The end position.
  9869. * @returns {Array} Returns the cast slice.
  9870. */
  9871. function castSlice(array, start, end) {
  9872. var length = array.length;
  9873. end = end === undefined$1 ? length : end;
  9874. return (!start && end >= length) ? array : baseSlice(array, start, end);
  9875. }
  9876. /**
  9877. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  9878. *
  9879. * @private
  9880. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  9881. */
  9882. var clearTimeout = ctxClearTimeout || function(id) {
  9883. return root.clearTimeout(id);
  9884. };
  9885. /**
  9886. * Creates a clone of `buffer`.
  9887. *
  9888. * @private
  9889. * @param {Buffer} buffer The buffer to clone.
  9890. * @param {boolean} [isDeep] Specify a deep clone.
  9891. * @returns {Buffer} Returns the cloned buffer.
  9892. */
  9893. function cloneBuffer(buffer, isDeep) {
  9894. if (isDeep) {
  9895. return buffer.slice();
  9896. }
  9897. var length = buffer.length,
  9898. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  9899. buffer.copy(result);
  9900. return result;
  9901. }
  9902. /**
  9903. * Creates a clone of `arrayBuffer`.
  9904. *
  9905. * @private
  9906. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  9907. * @returns {ArrayBuffer} Returns the cloned array buffer.
  9908. */
  9909. function cloneArrayBuffer(arrayBuffer) {
  9910. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  9911. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  9912. return result;
  9913. }
  9914. /**
  9915. * Creates a clone of `dataView`.
  9916. *
  9917. * @private
  9918. * @param {Object} dataView The data view to clone.
  9919. * @param {boolean} [isDeep] Specify a deep clone.
  9920. * @returns {Object} Returns the cloned data view.
  9921. */
  9922. function cloneDataView(dataView, isDeep) {
  9923. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  9924. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  9925. }
  9926. /**
  9927. * Creates a clone of `regexp`.
  9928. *
  9929. * @private
  9930. * @param {Object} regexp The regexp to clone.
  9931. * @returns {Object} Returns the cloned regexp.
  9932. */
  9933. function cloneRegExp(regexp) {
  9934. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  9935. result.lastIndex = regexp.lastIndex;
  9936. return result;
  9937. }
  9938. /**
  9939. * Creates a clone of the `symbol` object.
  9940. *
  9941. * @private
  9942. * @param {Object} symbol The symbol object to clone.
  9943. * @returns {Object} Returns the cloned symbol object.
  9944. */
  9945. function cloneSymbol(symbol) {
  9946. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  9947. }
  9948. /**
  9949. * Creates a clone of `typedArray`.
  9950. *
  9951. * @private
  9952. * @param {Object} typedArray The typed array to clone.
  9953. * @param {boolean} [isDeep] Specify a deep clone.
  9954. * @returns {Object} Returns the cloned typed array.
  9955. */
  9956. function cloneTypedArray(typedArray, isDeep) {
  9957. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  9958. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  9959. }
  9960. /**
  9961. * Compares values to sort them in ascending order.
  9962. *
  9963. * @private
  9964. * @param {*} value The value to compare.
  9965. * @param {*} other The other value to compare.
  9966. * @returns {number} Returns the sort order indicator for `value`.
  9967. */
  9968. function compareAscending(value, other) {
  9969. if (value !== other) {
  9970. var valIsDefined = value !== undefined$1,
  9971. valIsNull = value === null,
  9972. valIsReflexive = value === value,
  9973. valIsSymbol = isSymbol(value);
  9974. var othIsDefined = other !== undefined$1,
  9975. othIsNull = other === null,
  9976. othIsReflexive = other === other,
  9977. othIsSymbol = isSymbol(other);
  9978. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  9979. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  9980. (valIsNull && othIsDefined && othIsReflexive) ||
  9981. (!valIsDefined && othIsReflexive) ||
  9982. !valIsReflexive) {
  9983. return 1;
  9984. }
  9985. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  9986. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  9987. (othIsNull && valIsDefined && valIsReflexive) ||
  9988. (!othIsDefined && valIsReflexive) ||
  9989. !othIsReflexive) {
  9990. return -1;
  9991. }
  9992. }
  9993. return 0;
  9994. }
  9995. /**
  9996. * Used by `_.orderBy` to compare multiple properties of a value to another
  9997. * and stable sort them.
  9998. *
  9999. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  10000. * specify an order of "desc" for descending or "asc" for ascending sort order
  10001. * of corresponding values.
  10002. *
  10003. * @private
  10004. * @param {Object} object The object to compare.
  10005. * @param {Object} other The other object to compare.
  10006. * @param {boolean[]|string[]} orders The order to sort by for each property.
  10007. * @returns {number} Returns the sort order indicator for `object`.
  10008. */
  10009. function compareMultiple(object, other, orders) {
  10010. var index = -1,
  10011. objCriteria = object.criteria,
  10012. othCriteria = other.criteria,
  10013. length = objCriteria.length,
  10014. ordersLength = orders.length;
  10015. while (++index < length) {
  10016. var result = compareAscending(objCriteria[index], othCriteria[index]);
  10017. if (result) {
  10018. if (index >= ordersLength) {
  10019. return result;
  10020. }
  10021. var order = orders[index];
  10022. return result * (order == 'desc' ? -1 : 1);
  10023. }
  10024. }
  10025. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  10026. // that causes it, under certain circumstances, to provide the same value for
  10027. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  10028. // for more details.
  10029. //
  10030. // This also ensures a stable sort in V8 and other engines.
  10031. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  10032. return object.index - other.index;
  10033. }
  10034. /**
  10035. * Creates an array that is the composition of partially applied arguments,
  10036. * placeholders, and provided arguments into a single array of arguments.
  10037. *
  10038. * @private
  10039. * @param {Array} args The provided arguments.
  10040. * @param {Array} partials The arguments to prepend to those provided.
  10041. * @param {Array} holders The `partials` placeholder indexes.
  10042. * @params {boolean} [isCurried] Specify composing for a curried function.
  10043. * @returns {Array} Returns the new array of composed arguments.
  10044. */
  10045. function composeArgs(args, partials, holders, isCurried) {
  10046. var argsIndex = -1,
  10047. argsLength = args.length,
  10048. holdersLength = holders.length,
  10049. leftIndex = -1,
  10050. leftLength = partials.length,
  10051. rangeLength = nativeMax(argsLength - holdersLength, 0),
  10052. result = Array(leftLength + rangeLength),
  10053. isUncurried = !isCurried;
  10054. while (++leftIndex < leftLength) {
  10055. result[leftIndex] = partials[leftIndex];
  10056. }
  10057. while (++argsIndex < holdersLength) {
  10058. if (isUncurried || argsIndex < argsLength) {
  10059. result[holders[argsIndex]] = args[argsIndex];
  10060. }
  10061. }
  10062. while (rangeLength--) {
  10063. result[leftIndex++] = args[argsIndex++];
  10064. }
  10065. return result;
  10066. }
  10067. /**
  10068. * This function is like `composeArgs` except that the arguments composition
  10069. * is tailored for `_.partialRight`.
  10070. *
  10071. * @private
  10072. * @param {Array} args The provided arguments.
  10073. * @param {Array} partials The arguments to append to those provided.
  10074. * @param {Array} holders The `partials` placeholder indexes.
  10075. * @params {boolean} [isCurried] Specify composing for a curried function.
  10076. * @returns {Array} Returns the new array of composed arguments.
  10077. */
  10078. function composeArgsRight(args, partials, holders, isCurried) {
  10079. var argsIndex = -1,
  10080. argsLength = args.length,
  10081. holdersIndex = -1,
  10082. holdersLength = holders.length,
  10083. rightIndex = -1,
  10084. rightLength = partials.length,
  10085. rangeLength = nativeMax(argsLength - holdersLength, 0),
  10086. result = Array(rangeLength + rightLength),
  10087. isUncurried = !isCurried;
  10088. while (++argsIndex < rangeLength) {
  10089. result[argsIndex] = args[argsIndex];
  10090. }
  10091. var offset = argsIndex;
  10092. while (++rightIndex < rightLength) {
  10093. result[offset + rightIndex] = partials[rightIndex];
  10094. }
  10095. while (++holdersIndex < holdersLength) {
  10096. if (isUncurried || argsIndex < argsLength) {
  10097. result[offset + holders[holdersIndex]] = args[argsIndex++];
  10098. }
  10099. }
  10100. return result;
  10101. }
  10102. /**
  10103. * Copies the values of `source` to `array`.
  10104. *
  10105. * @private
  10106. * @param {Array} source The array to copy values from.
  10107. * @param {Array} [array=[]] The array to copy values to.
  10108. * @returns {Array} Returns `array`.
  10109. */
  10110. function copyArray(source, array) {
  10111. var index = -1,
  10112. length = source.length;
  10113. array || (array = Array(length));
  10114. while (++index < length) {
  10115. array[index] = source[index];
  10116. }
  10117. return array;
  10118. }
  10119. /**
  10120. * Copies properties of `source` to `object`.
  10121. *
  10122. * @private
  10123. * @param {Object} source The object to copy properties from.
  10124. * @param {Array} props The property identifiers to copy.
  10125. * @param {Object} [object={}] The object to copy properties to.
  10126. * @param {Function} [customizer] The function to customize copied values.
  10127. * @returns {Object} Returns `object`.
  10128. */
  10129. function copyObject(source, props, object, customizer) {
  10130. var isNew = !object;
  10131. object || (object = {});
  10132. var index = -1,
  10133. length = props.length;
  10134. while (++index < length) {
  10135. var key = props[index];
  10136. var newValue = customizer
  10137. ? customizer(object[key], source[key], key, object, source)
  10138. : undefined$1;
  10139. if (newValue === undefined$1) {
  10140. newValue = source[key];
  10141. }
  10142. if (isNew) {
  10143. baseAssignValue(object, key, newValue);
  10144. } else {
  10145. assignValue(object, key, newValue);
  10146. }
  10147. }
  10148. return object;
  10149. }
  10150. /**
  10151. * Copies own symbols of `source` to `object`.
  10152. *
  10153. * @private
  10154. * @param {Object} source The object to copy symbols from.
  10155. * @param {Object} [object={}] The object to copy symbols to.
  10156. * @returns {Object} Returns `object`.
  10157. */
  10158. function copySymbols(source, object) {
  10159. return copyObject(source, getSymbols(source), object);
  10160. }
  10161. /**
  10162. * Copies own and inherited symbols of `source` to `object`.
  10163. *
  10164. * @private
  10165. * @param {Object} source The object to copy symbols from.
  10166. * @param {Object} [object={}] The object to copy symbols to.
  10167. * @returns {Object} Returns `object`.
  10168. */
  10169. function copySymbolsIn(source, object) {
  10170. return copyObject(source, getSymbolsIn(source), object);
  10171. }
  10172. /**
  10173. * Creates a function like `_.groupBy`.
  10174. *
  10175. * @private
  10176. * @param {Function} setter The function to set accumulator values.
  10177. * @param {Function} [initializer] The accumulator object initializer.
  10178. * @returns {Function} Returns the new aggregator function.
  10179. */
  10180. function createAggregator(setter, initializer) {
  10181. return function(collection, iteratee) {
  10182. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  10183. accumulator = initializer ? initializer() : {};
  10184. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  10185. };
  10186. }
  10187. /**
  10188. * Creates a function like `_.assign`.
  10189. *
  10190. * @private
  10191. * @param {Function} assigner The function to assign values.
  10192. * @returns {Function} Returns the new assigner function.
  10193. */
  10194. function createAssigner(assigner) {
  10195. return baseRest(function(object, sources) {
  10196. var index = -1,
  10197. length = sources.length,
  10198. customizer = length > 1 ? sources[length - 1] : undefined$1,
  10199. guard = length > 2 ? sources[2] : undefined$1;
  10200. customizer = (assigner.length > 3 && typeof customizer == 'function')
  10201. ? (length--, customizer)
  10202. : undefined$1;
  10203. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  10204. customizer = length < 3 ? undefined$1 : customizer;
  10205. length = 1;
  10206. }
  10207. object = Object(object);
  10208. while (++index < length) {
  10209. var source = sources[index];
  10210. if (source) {
  10211. assigner(object, source, index, customizer);
  10212. }
  10213. }
  10214. return object;
  10215. });
  10216. }
  10217. /**
  10218. * Creates a `baseEach` or `baseEachRight` function.
  10219. *
  10220. * @private
  10221. * @param {Function} eachFunc The function to iterate over a collection.
  10222. * @param {boolean} [fromRight] Specify iterating from right to left.
  10223. * @returns {Function} Returns the new base function.
  10224. */
  10225. function createBaseEach(eachFunc, fromRight) {
  10226. return function(collection, iteratee) {
  10227. if (collection == null) {
  10228. return collection;
  10229. }
  10230. if (!isArrayLike(collection)) {
  10231. return eachFunc(collection, iteratee);
  10232. }
  10233. var length = collection.length,
  10234. index = fromRight ? length : -1,
  10235. iterable = Object(collection);
  10236. while ((fromRight ? index-- : ++index < length)) {
  10237. if (iteratee(iterable[index], index, iterable) === false) {
  10238. break;
  10239. }
  10240. }
  10241. return collection;
  10242. };
  10243. }
  10244. /**
  10245. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  10246. *
  10247. * @private
  10248. * @param {boolean} [fromRight] Specify iterating from right to left.
  10249. * @returns {Function} Returns the new base function.
  10250. */
  10251. function createBaseFor(fromRight) {
  10252. return function(object, iteratee, keysFunc) {
  10253. var index = -1,
  10254. iterable = Object(object),
  10255. props = keysFunc(object),
  10256. length = props.length;
  10257. while (length--) {
  10258. var key = props[fromRight ? length : ++index];
  10259. if (iteratee(iterable[key], key, iterable) === false) {
  10260. break;
  10261. }
  10262. }
  10263. return object;
  10264. };
  10265. }
  10266. /**
  10267. * Creates a function that wraps `func` to invoke it with the optional `this`
  10268. * binding of `thisArg`.
  10269. *
  10270. * @private
  10271. * @param {Function} func The function to wrap.
  10272. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10273. * @param {*} [thisArg] The `this` binding of `func`.
  10274. * @returns {Function} Returns the new wrapped function.
  10275. */
  10276. function createBind(func, bitmask, thisArg) {
  10277. var isBind = bitmask & WRAP_BIND_FLAG,
  10278. Ctor = createCtor(func);
  10279. function wrapper() {
  10280. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  10281. return fn.apply(isBind ? thisArg : this, arguments);
  10282. }
  10283. return wrapper;
  10284. }
  10285. /**
  10286. * Creates a function like `_.lowerFirst`.
  10287. *
  10288. * @private
  10289. * @param {string} methodName The name of the `String` case method to use.
  10290. * @returns {Function} Returns the new case function.
  10291. */
  10292. function createCaseFirst(methodName) {
  10293. return function(string) {
  10294. string = toString(string);
  10295. var strSymbols = hasUnicode(string)
  10296. ? stringToArray(string)
  10297. : undefined$1;
  10298. var chr = strSymbols
  10299. ? strSymbols[0]
  10300. : string.charAt(0);
  10301. var trailing = strSymbols
  10302. ? castSlice(strSymbols, 1).join('')
  10303. : string.slice(1);
  10304. return chr[methodName]() + trailing;
  10305. };
  10306. }
  10307. /**
  10308. * Creates a function like `_.camelCase`.
  10309. *
  10310. * @private
  10311. * @param {Function} callback The function to combine each word.
  10312. * @returns {Function} Returns the new compounder function.
  10313. */
  10314. function createCompounder(callback) {
  10315. return function(string) {
  10316. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  10317. };
  10318. }
  10319. /**
  10320. * Creates a function that produces an instance of `Ctor` regardless of
  10321. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  10322. *
  10323. * @private
  10324. * @param {Function} Ctor The constructor to wrap.
  10325. * @returns {Function} Returns the new wrapped function.
  10326. */
  10327. function createCtor(Ctor) {
  10328. return function() {
  10329. // Use a `switch` statement to work with class constructors. See
  10330. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  10331. // for more details.
  10332. var args = arguments;
  10333. switch (args.length) {
  10334. case 0: return new Ctor;
  10335. case 1: return new Ctor(args[0]);
  10336. case 2: return new Ctor(args[0], args[1]);
  10337. case 3: return new Ctor(args[0], args[1], args[2]);
  10338. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  10339. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  10340. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  10341. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  10342. }
  10343. var thisBinding = baseCreate(Ctor.prototype),
  10344. result = Ctor.apply(thisBinding, args);
  10345. // Mimic the constructor's `return` behavior.
  10346. // See https://es5.github.io/#x13.2.2 for more details.
  10347. return isObject(result) ? result : thisBinding;
  10348. };
  10349. }
  10350. /**
  10351. * Creates a function that wraps `func` to enable currying.
  10352. *
  10353. * @private
  10354. * @param {Function} func The function to wrap.
  10355. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10356. * @param {number} arity The arity of `func`.
  10357. * @returns {Function} Returns the new wrapped function.
  10358. */
  10359. function createCurry(func, bitmask, arity) {
  10360. var Ctor = createCtor(func);
  10361. function wrapper() {
  10362. var length = arguments.length,
  10363. args = Array(length),
  10364. index = length,
  10365. placeholder = getHolder(wrapper);
  10366. while (index--) {
  10367. args[index] = arguments[index];
  10368. }
  10369. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  10370. ? []
  10371. : replaceHolders(args, placeholder);
  10372. length -= holders.length;
  10373. if (length < arity) {
  10374. return createRecurry(
  10375. func, bitmask, createHybrid, wrapper.placeholder, undefined$1,
  10376. args, holders, undefined$1, undefined$1, arity - length);
  10377. }
  10378. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  10379. return apply(fn, this, args);
  10380. }
  10381. return wrapper;
  10382. }
  10383. /**
  10384. * Creates a `_.find` or `_.findLast` function.
  10385. *
  10386. * @private
  10387. * @param {Function} findIndexFunc The function to find the collection index.
  10388. * @returns {Function} Returns the new find function.
  10389. */
  10390. function createFind(findIndexFunc) {
  10391. return function(collection, predicate, fromIndex) {
  10392. var iterable = Object(collection);
  10393. if (!isArrayLike(collection)) {
  10394. var iteratee = getIteratee(predicate, 3);
  10395. collection = keys(collection);
  10396. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  10397. }
  10398. var index = findIndexFunc(collection, predicate, fromIndex);
  10399. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined$1;
  10400. };
  10401. }
  10402. /**
  10403. * Creates a `_.flow` or `_.flowRight` function.
  10404. *
  10405. * @private
  10406. * @param {boolean} [fromRight] Specify iterating from right to left.
  10407. * @returns {Function} Returns the new flow function.
  10408. */
  10409. function createFlow(fromRight) {
  10410. return flatRest(function(funcs) {
  10411. var length = funcs.length,
  10412. index = length,
  10413. prereq = LodashWrapper.prototype.thru;
  10414. if (fromRight) {
  10415. funcs.reverse();
  10416. }
  10417. while (index--) {
  10418. var func = funcs[index];
  10419. if (typeof func != 'function') {
  10420. throw new TypeError(FUNC_ERROR_TEXT);
  10421. }
  10422. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  10423. var wrapper = new LodashWrapper([], true);
  10424. }
  10425. }
  10426. index = wrapper ? index : length;
  10427. while (++index < length) {
  10428. func = funcs[index];
  10429. var funcName = getFuncName(func),
  10430. data = funcName == 'wrapper' ? getData(func) : undefined$1;
  10431. if (data && isLaziable(data[0]) &&
  10432. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  10433. !data[4].length && data[9] == 1
  10434. ) {
  10435. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  10436. } else {
  10437. wrapper = (func.length == 1 && isLaziable(func))
  10438. ? wrapper[funcName]()
  10439. : wrapper.thru(func);
  10440. }
  10441. }
  10442. return function() {
  10443. var args = arguments,
  10444. value = args[0];
  10445. if (wrapper && args.length == 1 && isArray(value)) {
  10446. return wrapper.plant(value).value();
  10447. }
  10448. var index = 0,
  10449. result = length ? funcs[index].apply(this, args) : value;
  10450. while (++index < length) {
  10451. result = funcs[index].call(this, result);
  10452. }
  10453. return result;
  10454. };
  10455. });
  10456. }
  10457. /**
  10458. * Creates a function that wraps `func` to invoke it with optional `this`
  10459. * binding of `thisArg`, partial application, and currying.
  10460. *
  10461. * @private
  10462. * @param {Function|string} func The function or method name to wrap.
  10463. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10464. * @param {*} [thisArg] The `this` binding of `func`.
  10465. * @param {Array} [partials] The arguments to prepend to those provided to
  10466. * the new function.
  10467. * @param {Array} [holders] The `partials` placeholder indexes.
  10468. * @param {Array} [partialsRight] The arguments to append to those provided
  10469. * to the new function.
  10470. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  10471. * @param {Array} [argPos] The argument positions of the new function.
  10472. * @param {number} [ary] The arity cap of `func`.
  10473. * @param {number} [arity] The arity of `func`.
  10474. * @returns {Function} Returns the new wrapped function.
  10475. */
  10476. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  10477. var isAry = bitmask & WRAP_ARY_FLAG,
  10478. isBind = bitmask & WRAP_BIND_FLAG,
  10479. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  10480. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  10481. isFlip = bitmask & WRAP_FLIP_FLAG,
  10482. Ctor = isBindKey ? undefined$1 : createCtor(func);
  10483. function wrapper() {
  10484. var length = arguments.length,
  10485. args = Array(length),
  10486. index = length;
  10487. while (index--) {
  10488. args[index] = arguments[index];
  10489. }
  10490. if (isCurried) {
  10491. var placeholder = getHolder(wrapper),
  10492. holdersCount = countHolders(args, placeholder);
  10493. }
  10494. if (partials) {
  10495. args = composeArgs(args, partials, holders, isCurried);
  10496. }
  10497. if (partialsRight) {
  10498. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  10499. }
  10500. length -= holdersCount;
  10501. if (isCurried && length < arity) {
  10502. var newHolders = replaceHolders(args, placeholder);
  10503. return createRecurry(
  10504. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  10505. args, newHolders, argPos, ary, arity - length
  10506. );
  10507. }
  10508. var thisBinding = isBind ? thisArg : this,
  10509. fn = isBindKey ? thisBinding[func] : func;
  10510. length = args.length;
  10511. if (argPos) {
  10512. args = reorder(args, argPos);
  10513. } else if (isFlip && length > 1) {
  10514. args.reverse();
  10515. }
  10516. if (isAry && ary < length) {
  10517. args.length = ary;
  10518. }
  10519. if (this && this !== root && this instanceof wrapper) {
  10520. fn = Ctor || createCtor(fn);
  10521. }
  10522. return fn.apply(thisBinding, args);
  10523. }
  10524. return wrapper;
  10525. }
  10526. /**
  10527. * Creates a function like `_.invertBy`.
  10528. *
  10529. * @private
  10530. * @param {Function} setter The function to set accumulator values.
  10531. * @param {Function} toIteratee The function to resolve iteratees.
  10532. * @returns {Function} Returns the new inverter function.
  10533. */
  10534. function createInverter(setter, toIteratee) {
  10535. return function(object, iteratee) {
  10536. return baseInverter(object, setter, toIteratee(iteratee), {});
  10537. };
  10538. }
  10539. /**
  10540. * Creates a function that performs a mathematical operation on two values.
  10541. *
  10542. * @private
  10543. * @param {Function} operator The function to perform the operation.
  10544. * @param {number} [defaultValue] The value used for `undefined` arguments.
  10545. * @returns {Function} Returns the new mathematical operation function.
  10546. */
  10547. function createMathOperation(operator, defaultValue) {
  10548. return function(value, other) {
  10549. var result;
  10550. if (value === undefined$1 && other === undefined$1) {
  10551. return defaultValue;
  10552. }
  10553. if (value !== undefined$1) {
  10554. result = value;
  10555. }
  10556. if (other !== undefined$1) {
  10557. if (result === undefined$1) {
  10558. return other;
  10559. }
  10560. if (typeof value == 'string' || typeof other == 'string') {
  10561. value = baseToString(value);
  10562. other = baseToString(other);
  10563. } else {
  10564. value = baseToNumber(value);
  10565. other = baseToNumber(other);
  10566. }
  10567. result = operator(value, other);
  10568. }
  10569. return result;
  10570. };
  10571. }
  10572. /**
  10573. * Creates a function like `_.over`.
  10574. *
  10575. * @private
  10576. * @param {Function} arrayFunc The function to iterate over iteratees.
  10577. * @returns {Function} Returns the new over function.
  10578. */
  10579. function createOver(arrayFunc) {
  10580. return flatRest(function(iteratees) {
  10581. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  10582. return baseRest(function(args) {
  10583. var thisArg = this;
  10584. return arrayFunc(iteratees, function(iteratee) {
  10585. return apply(iteratee, thisArg, args);
  10586. });
  10587. });
  10588. });
  10589. }
  10590. /**
  10591. * Creates the padding for `string` based on `length`. The `chars` string
  10592. * is truncated if the number of characters exceeds `length`.
  10593. *
  10594. * @private
  10595. * @param {number} length The padding length.
  10596. * @param {string} [chars=' '] The string used as padding.
  10597. * @returns {string} Returns the padding for `string`.
  10598. */
  10599. function createPadding(length, chars) {
  10600. chars = chars === undefined$1 ? ' ' : baseToString(chars);
  10601. var charsLength = chars.length;
  10602. if (charsLength < 2) {
  10603. return charsLength ? baseRepeat(chars, length) : chars;
  10604. }
  10605. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  10606. return hasUnicode(chars)
  10607. ? castSlice(stringToArray(result), 0, length).join('')
  10608. : result.slice(0, length);
  10609. }
  10610. /**
  10611. * Creates a function that wraps `func` to invoke it with the `this` binding
  10612. * of `thisArg` and `partials` prepended to the arguments it receives.
  10613. *
  10614. * @private
  10615. * @param {Function} func The function to wrap.
  10616. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10617. * @param {*} thisArg The `this` binding of `func`.
  10618. * @param {Array} partials The arguments to prepend to those provided to
  10619. * the new function.
  10620. * @returns {Function} Returns the new wrapped function.
  10621. */
  10622. function createPartial(func, bitmask, thisArg, partials) {
  10623. var isBind = bitmask & WRAP_BIND_FLAG,
  10624. Ctor = createCtor(func);
  10625. function wrapper() {
  10626. var argsIndex = -1,
  10627. argsLength = arguments.length,
  10628. leftIndex = -1,
  10629. leftLength = partials.length,
  10630. args = Array(leftLength + argsLength),
  10631. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  10632. while (++leftIndex < leftLength) {
  10633. args[leftIndex] = partials[leftIndex];
  10634. }
  10635. while (argsLength--) {
  10636. args[leftIndex++] = arguments[++argsIndex];
  10637. }
  10638. return apply(fn, isBind ? thisArg : this, args);
  10639. }
  10640. return wrapper;
  10641. }
  10642. /**
  10643. * Creates a `_.range` or `_.rangeRight` function.
  10644. *
  10645. * @private
  10646. * @param {boolean} [fromRight] Specify iterating from right to left.
  10647. * @returns {Function} Returns the new range function.
  10648. */
  10649. function createRange(fromRight) {
  10650. return function(start, end, step) {
  10651. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  10652. end = step = undefined$1;
  10653. }
  10654. // Ensure the sign of `-0` is preserved.
  10655. start = toFinite(start);
  10656. if (end === undefined$1) {
  10657. end = start;
  10658. start = 0;
  10659. } else {
  10660. end = toFinite(end);
  10661. }
  10662. step = step === undefined$1 ? (start < end ? 1 : -1) : toFinite(step);
  10663. return baseRange(start, end, step, fromRight);
  10664. };
  10665. }
  10666. /**
  10667. * Creates a function that performs a relational operation on two values.
  10668. *
  10669. * @private
  10670. * @param {Function} operator The function to perform the operation.
  10671. * @returns {Function} Returns the new relational operation function.
  10672. */
  10673. function createRelationalOperation(operator) {
  10674. return function(value, other) {
  10675. if (!(typeof value == 'string' && typeof other == 'string')) {
  10676. value = toNumber(value);
  10677. other = toNumber(other);
  10678. }
  10679. return operator(value, other);
  10680. };
  10681. }
  10682. /**
  10683. * Creates a function that wraps `func` to continue currying.
  10684. *
  10685. * @private
  10686. * @param {Function} func The function to wrap.
  10687. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  10688. * @param {Function} wrapFunc The function to create the `func` wrapper.
  10689. * @param {*} placeholder The placeholder value.
  10690. * @param {*} [thisArg] The `this` binding of `func`.
  10691. * @param {Array} [partials] The arguments to prepend to those provided to
  10692. * the new function.
  10693. * @param {Array} [holders] The `partials` placeholder indexes.
  10694. * @param {Array} [argPos] The argument positions of the new function.
  10695. * @param {number} [ary] The arity cap of `func`.
  10696. * @param {number} [arity] The arity of `func`.
  10697. * @returns {Function} Returns the new wrapped function.
  10698. */
  10699. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  10700. var isCurry = bitmask & WRAP_CURRY_FLAG,
  10701. newHolders = isCurry ? holders : undefined$1,
  10702. newHoldersRight = isCurry ? undefined$1 : holders,
  10703. newPartials = isCurry ? partials : undefined$1,
  10704. newPartialsRight = isCurry ? undefined$1 : partials;
  10705. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  10706. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  10707. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  10708. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  10709. }
  10710. var newData = [
  10711. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  10712. newHoldersRight, argPos, ary, arity
  10713. ];
  10714. var result = wrapFunc.apply(undefined$1, newData);
  10715. if (isLaziable(func)) {
  10716. setData(result, newData);
  10717. }
  10718. result.placeholder = placeholder;
  10719. return setWrapToString(result, func, bitmask);
  10720. }
  10721. /**
  10722. * Creates a function like `_.round`.
  10723. *
  10724. * @private
  10725. * @param {string} methodName The name of the `Math` method to use when rounding.
  10726. * @returns {Function} Returns the new round function.
  10727. */
  10728. function createRound(methodName) {
  10729. var func = Math[methodName];
  10730. return function(number, precision) {
  10731. number = toNumber(number);
  10732. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  10733. if (precision && nativeIsFinite(number)) {
  10734. // Shift with exponential notation to avoid floating-point issues.
  10735. // See [MDN](https://mdn.io/round#Examples) for more details.
  10736. var pair = (toString(number) + 'e').split('e'),
  10737. value = func(pair[0] + 'e' + (+pair[1] + precision));
  10738. pair = (toString(value) + 'e').split('e');
  10739. return +(pair[0] + 'e' + (+pair[1] - precision));
  10740. }
  10741. return func(number);
  10742. };
  10743. }
  10744. /**
  10745. * Creates a set object of `values`.
  10746. *
  10747. * @private
  10748. * @param {Array} values The values to add to the set.
  10749. * @returns {Object} Returns the new set.
  10750. */
  10751. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  10752. return new Set(values);
  10753. };
  10754. /**
  10755. * Creates a `_.toPairs` or `_.toPairsIn` function.
  10756. *
  10757. * @private
  10758. * @param {Function} keysFunc The function to get the keys of a given object.
  10759. * @returns {Function} Returns the new pairs function.
  10760. */
  10761. function createToPairs(keysFunc) {
  10762. return function(object) {
  10763. var tag = getTag(object);
  10764. if (tag == mapTag) {
  10765. return mapToArray(object);
  10766. }
  10767. if (tag == setTag) {
  10768. return setToPairs(object);
  10769. }
  10770. return baseToPairs(object, keysFunc(object));
  10771. };
  10772. }
  10773. /**
  10774. * Creates a function that either curries or invokes `func` with optional
  10775. * `this` binding and partially applied arguments.
  10776. *
  10777. * @private
  10778. * @param {Function|string} func The function or method name to wrap.
  10779. * @param {number} bitmask The bitmask flags.
  10780. * 1 - `_.bind`
  10781. * 2 - `_.bindKey`
  10782. * 4 - `_.curry` or `_.curryRight` of a bound function
  10783. * 8 - `_.curry`
  10784. * 16 - `_.curryRight`
  10785. * 32 - `_.partial`
  10786. * 64 - `_.partialRight`
  10787. * 128 - `_.rearg`
  10788. * 256 - `_.ary`
  10789. * 512 - `_.flip`
  10790. * @param {*} [thisArg] The `this` binding of `func`.
  10791. * @param {Array} [partials] The arguments to be partially applied.
  10792. * @param {Array} [holders] The `partials` placeholder indexes.
  10793. * @param {Array} [argPos] The argument positions of the new function.
  10794. * @param {number} [ary] The arity cap of `func`.
  10795. * @param {number} [arity] The arity of `func`.
  10796. * @returns {Function} Returns the new wrapped function.
  10797. */
  10798. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  10799. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  10800. if (!isBindKey && typeof func != 'function') {
  10801. throw new TypeError(FUNC_ERROR_TEXT);
  10802. }
  10803. var length = partials ? partials.length : 0;
  10804. if (!length) {
  10805. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  10806. partials = holders = undefined$1;
  10807. }
  10808. ary = ary === undefined$1 ? ary : nativeMax(toInteger(ary), 0);
  10809. arity = arity === undefined$1 ? arity : toInteger(arity);
  10810. length -= holders ? holders.length : 0;
  10811. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  10812. var partialsRight = partials,
  10813. holdersRight = holders;
  10814. partials = holders = undefined$1;
  10815. }
  10816. var data = isBindKey ? undefined$1 : getData(func);
  10817. var newData = [
  10818. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  10819. argPos, ary, arity
  10820. ];
  10821. if (data) {
  10822. mergeData(newData, data);
  10823. }
  10824. func = newData[0];
  10825. bitmask = newData[1];
  10826. thisArg = newData[2];
  10827. partials = newData[3];
  10828. holders = newData[4];
  10829. arity = newData[9] = newData[9] === undefined$1
  10830. ? (isBindKey ? 0 : func.length)
  10831. : nativeMax(newData[9] - length, 0);
  10832. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  10833. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  10834. }
  10835. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  10836. var result = createBind(func, bitmask, thisArg);
  10837. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  10838. result = createCurry(func, bitmask, arity);
  10839. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  10840. result = createPartial(func, bitmask, thisArg, partials);
  10841. } else {
  10842. result = createHybrid.apply(undefined$1, newData);
  10843. }
  10844. var setter = data ? baseSetData : setData;
  10845. return setWrapToString(setter(result, newData), func, bitmask);
  10846. }
  10847. /**
  10848. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  10849. * of source objects to the destination object for all destination properties
  10850. * that resolve to `undefined`.
  10851. *
  10852. * @private
  10853. * @param {*} objValue The destination value.
  10854. * @param {*} srcValue The source value.
  10855. * @param {string} key The key of the property to assign.
  10856. * @param {Object} object The parent object of `objValue`.
  10857. * @returns {*} Returns the value to assign.
  10858. */
  10859. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  10860. if (objValue === undefined$1 ||
  10861. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  10862. return srcValue;
  10863. }
  10864. return objValue;
  10865. }
  10866. /**
  10867. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  10868. * objects into destination objects that are passed thru.
  10869. *
  10870. * @private
  10871. * @param {*} objValue The destination value.
  10872. * @param {*} srcValue The source value.
  10873. * @param {string} key The key of the property to merge.
  10874. * @param {Object} object The parent object of `objValue`.
  10875. * @param {Object} source The parent object of `srcValue`.
  10876. * @param {Object} [stack] Tracks traversed source values and their merged
  10877. * counterparts.
  10878. * @returns {*} Returns the value to assign.
  10879. */
  10880. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  10881. if (isObject(objValue) && isObject(srcValue)) {
  10882. // Recursively merge objects and arrays (susceptible to call stack limits).
  10883. stack.set(srcValue, objValue);
  10884. baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
  10885. stack['delete'](srcValue);
  10886. }
  10887. return objValue;
  10888. }
  10889. /**
  10890. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  10891. * objects.
  10892. *
  10893. * @private
  10894. * @param {*} value The value to inspect.
  10895. * @param {string} key The key of the property to inspect.
  10896. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  10897. */
  10898. function customOmitClone(value) {
  10899. return isPlainObject(value) ? undefined$1 : value;
  10900. }
  10901. /**
  10902. * A specialized version of `baseIsEqualDeep` for arrays with support for
  10903. * partial deep comparisons.
  10904. *
  10905. * @private
  10906. * @param {Array} array The array to compare.
  10907. * @param {Array} other The other array to compare.
  10908. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  10909. * @param {Function} customizer The function to customize comparisons.
  10910. * @param {Function} equalFunc The function to determine equivalents of values.
  10911. * @param {Object} stack Tracks traversed `array` and `other` objects.
  10912. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  10913. */
  10914. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  10915. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  10916. arrLength = array.length,
  10917. othLength = other.length;
  10918. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  10919. return false;
  10920. }
  10921. // Check that cyclic values are equal.
  10922. var arrStacked = stack.get(array);
  10923. var othStacked = stack.get(other);
  10924. if (arrStacked && othStacked) {
  10925. return arrStacked == other && othStacked == array;
  10926. }
  10927. var index = -1,
  10928. result = true,
  10929. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined$1;
  10930. stack.set(array, other);
  10931. stack.set(other, array);
  10932. // Ignore non-index properties.
  10933. while (++index < arrLength) {
  10934. var arrValue = array[index],
  10935. othValue = other[index];
  10936. if (customizer) {
  10937. var compared = isPartial
  10938. ? customizer(othValue, arrValue, index, other, array, stack)
  10939. : customizer(arrValue, othValue, index, array, other, stack);
  10940. }
  10941. if (compared !== undefined$1) {
  10942. if (compared) {
  10943. continue;
  10944. }
  10945. result = false;
  10946. break;
  10947. }
  10948. // Recursively compare arrays (susceptible to call stack limits).
  10949. if (seen) {
  10950. if (!arraySome(other, function(othValue, othIndex) {
  10951. if (!cacheHas(seen, othIndex) &&
  10952. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  10953. return seen.push(othIndex);
  10954. }
  10955. })) {
  10956. result = false;
  10957. break;
  10958. }
  10959. } else if (!(
  10960. arrValue === othValue ||
  10961. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  10962. )) {
  10963. result = false;
  10964. break;
  10965. }
  10966. }
  10967. stack['delete'](array);
  10968. stack['delete'](other);
  10969. return result;
  10970. }
  10971. /**
  10972. * A specialized version of `baseIsEqualDeep` for comparing objects of
  10973. * the same `toStringTag`.
  10974. *
  10975. * **Note:** This function only supports comparing values with tags of
  10976. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  10977. *
  10978. * @private
  10979. * @param {Object} object The object to compare.
  10980. * @param {Object} other The other object to compare.
  10981. * @param {string} tag The `toStringTag` of the objects to compare.
  10982. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  10983. * @param {Function} customizer The function to customize comparisons.
  10984. * @param {Function} equalFunc The function to determine equivalents of values.
  10985. * @param {Object} stack Tracks traversed `object` and `other` objects.
  10986. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  10987. */
  10988. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  10989. switch (tag) {
  10990. case dataViewTag:
  10991. if ((object.byteLength != other.byteLength) ||
  10992. (object.byteOffset != other.byteOffset)) {
  10993. return false;
  10994. }
  10995. object = object.buffer;
  10996. other = other.buffer;
  10997. case arrayBufferTag:
  10998. if ((object.byteLength != other.byteLength) ||
  10999. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  11000. return false;
  11001. }
  11002. return true;
  11003. case boolTag:
  11004. case dateTag:
  11005. case numberTag:
  11006. // Coerce booleans to `1` or `0` and dates to milliseconds.
  11007. // Invalid dates are coerced to `NaN`.
  11008. return eq(+object, +other);
  11009. case errorTag:
  11010. return object.name == other.name && object.message == other.message;
  11011. case regexpTag:
  11012. case stringTag:
  11013. // Coerce regexes to strings and treat strings, primitives and objects,
  11014. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  11015. // for more details.
  11016. return object == (other + '');
  11017. case mapTag:
  11018. var convert = mapToArray;
  11019. case setTag:
  11020. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  11021. convert || (convert = setToArray);
  11022. if (object.size != other.size && !isPartial) {
  11023. return false;
  11024. }
  11025. // Assume cyclic values are equal.
  11026. var stacked = stack.get(object);
  11027. if (stacked) {
  11028. return stacked == other;
  11029. }
  11030. bitmask |= COMPARE_UNORDERED_FLAG;
  11031. // Recursively compare objects (susceptible to call stack limits).
  11032. stack.set(object, other);
  11033. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  11034. stack['delete'](object);
  11035. return result;
  11036. case symbolTag:
  11037. if (symbolValueOf) {
  11038. return symbolValueOf.call(object) == symbolValueOf.call(other);
  11039. }
  11040. }
  11041. return false;
  11042. }
  11043. /**
  11044. * A specialized version of `baseIsEqualDeep` for objects with support for
  11045. * partial deep comparisons.
  11046. *
  11047. * @private
  11048. * @param {Object} object The object to compare.
  11049. * @param {Object} other The other object to compare.
  11050. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11051. * @param {Function} customizer The function to customize comparisons.
  11052. * @param {Function} equalFunc The function to determine equivalents of values.
  11053. * @param {Object} stack Tracks traversed `object` and `other` objects.
  11054. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11055. */
  11056. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  11057. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  11058. objProps = getAllKeys(object),
  11059. objLength = objProps.length,
  11060. othProps = getAllKeys(other),
  11061. othLength = othProps.length;
  11062. if (objLength != othLength && !isPartial) {
  11063. return false;
  11064. }
  11065. var index = objLength;
  11066. while (index--) {
  11067. var key = objProps[index];
  11068. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  11069. return false;
  11070. }
  11071. }
  11072. // Check that cyclic values are equal.
  11073. var objStacked = stack.get(object);
  11074. var othStacked = stack.get(other);
  11075. if (objStacked && othStacked) {
  11076. return objStacked == other && othStacked == object;
  11077. }
  11078. var result = true;
  11079. stack.set(object, other);
  11080. stack.set(other, object);
  11081. var skipCtor = isPartial;
  11082. while (++index < objLength) {
  11083. key = objProps[index];
  11084. var objValue = object[key],
  11085. othValue = other[key];
  11086. if (customizer) {
  11087. var compared = isPartial
  11088. ? customizer(othValue, objValue, key, other, object, stack)
  11089. : customizer(objValue, othValue, key, object, other, stack);
  11090. }
  11091. // Recursively compare objects (susceptible to call stack limits).
  11092. if (!(compared === undefined$1
  11093. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  11094. : compared
  11095. )) {
  11096. result = false;
  11097. break;
  11098. }
  11099. skipCtor || (skipCtor = key == 'constructor');
  11100. }
  11101. if (result && !skipCtor) {
  11102. var objCtor = object.constructor,
  11103. othCtor = other.constructor;
  11104. // Non `Object` object instances with different constructors are not equal.
  11105. if (objCtor != othCtor &&
  11106. ('constructor' in object && 'constructor' in other) &&
  11107. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  11108. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  11109. result = false;
  11110. }
  11111. }
  11112. stack['delete'](object);
  11113. stack['delete'](other);
  11114. return result;
  11115. }
  11116. /**
  11117. * A specialized version of `baseRest` which flattens the rest array.
  11118. *
  11119. * @private
  11120. * @param {Function} func The function to apply a rest parameter to.
  11121. * @returns {Function} Returns the new function.
  11122. */
  11123. function flatRest(func) {
  11124. return setToString(overRest(func, undefined$1, flatten), func + '');
  11125. }
  11126. /**
  11127. * Creates an array of own enumerable property names and symbols of `object`.
  11128. *
  11129. * @private
  11130. * @param {Object} object The object to query.
  11131. * @returns {Array} Returns the array of property names and symbols.
  11132. */
  11133. function getAllKeys(object) {
  11134. return baseGetAllKeys(object, keys, getSymbols);
  11135. }
  11136. /**
  11137. * Creates an array of own and inherited enumerable property names and
  11138. * symbols of `object`.
  11139. *
  11140. * @private
  11141. * @param {Object} object The object to query.
  11142. * @returns {Array} Returns the array of property names and symbols.
  11143. */
  11144. function getAllKeysIn(object) {
  11145. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  11146. }
  11147. /**
  11148. * Gets metadata for `func`.
  11149. *
  11150. * @private
  11151. * @param {Function} func The function to query.
  11152. * @returns {*} Returns the metadata for `func`.
  11153. */
  11154. var getData = !metaMap ? noop : function(func) {
  11155. return metaMap.get(func);
  11156. };
  11157. /**
  11158. * Gets the name of `func`.
  11159. *
  11160. * @private
  11161. * @param {Function} func The function to query.
  11162. * @returns {string} Returns the function name.
  11163. */
  11164. function getFuncName(func) {
  11165. var result = (func.name + ''),
  11166. array = realNames[result],
  11167. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  11168. while (length--) {
  11169. var data = array[length],
  11170. otherFunc = data.func;
  11171. if (otherFunc == null || otherFunc == func) {
  11172. return data.name;
  11173. }
  11174. }
  11175. return result;
  11176. }
  11177. /**
  11178. * Gets the argument placeholder value for `func`.
  11179. *
  11180. * @private
  11181. * @param {Function} func The function to inspect.
  11182. * @returns {*} Returns the placeholder value.
  11183. */
  11184. function getHolder(func) {
  11185. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  11186. return object.placeholder;
  11187. }
  11188. /**
  11189. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  11190. * this function returns the custom method, otherwise it returns `baseIteratee`.
  11191. * If arguments are provided, the chosen function is invoked with them and
  11192. * its result is returned.
  11193. *
  11194. * @private
  11195. * @param {*} [value] The value to convert to an iteratee.
  11196. * @param {number} [arity] The arity of the created iteratee.
  11197. * @returns {Function} Returns the chosen function or its result.
  11198. */
  11199. function getIteratee() {
  11200. var result = lodash.iteratee || iteratee;
  11201. result = result === iteratee ? baseIteratee : result;
  11202. return arguments.length ? result(arguments[0], arguments[1]) : result;
  11203. }
  11204. /**
  11205. * Gets the data for `map`.
  11206. *
  11207. * @private
  11208. * @param {Object} map The map to query.
  11209. * @param {string} key The reference key.
  11210. * @returns {*} Returns the map data.
  11211. */
  11212. function getMapData(map, key) {
  11213. var data = map.__data__;
  11214. return isKeyable(key)
  11215. ? data[typeof key == 'string' ? 'string' : 'hash']
  11216. : data.map;
  11217. }
  11218. /**
  11219. * Gets the property names, values, and compare flags of `object`.
  11220. *
  11221. * @private
  11222. * @param {Object} object The object to query.
  11223. * @returns {Array} Returns the match data of `object`.
  11224. */
  11225. function getMatchData(object) {
  11226. var result = keys(object),
  11227. length = result.length;
  11228. while (length--) {
  11229. var key = result[length],
  11230. value = object[key];
  11231. result[length] = [key, value, isStrictComparable(value)];
  11232. }
  11233. return result;
  11234. }
  11235. /**
  11236. * Gets the native function at `key` of `object`.
  11237. *
  11238. * @private
  11239. * @param {Object} object The object to query.
  11240. * @param {string} key The key of the method to get.
  11241. * @returns {*} Returns the function if it's native, else `undefined`.
  11242. */
  11243. function getNative(object, key) {
  11244. var value = getValue(object, key);
  11245. return baseIsNative(value) ? value : undefined$1;
  11246. }
  11247. /**
  11248. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  11249. *
  11250. * @private
  11251. * @param {*} value The value to query.
  11252. * @returns {string} Returns the raw `toStringTag`.
  11253. */
  11254. function getRawTag(value) {
  11255. var isOwn = hasOwnProperty.call(value, symToStringTag),
  11256. tag = value[symToStringTag];
  11257. try {
  11258. value[symToStringTag] = undefined$1;
  11259. var unmasked = true;
  11260. } catch (e) {}
  11261. var result = nativeObjectToString.call(value);
  11262. if (unmasked) {
  11263. if (isOwn) {
  11264. value[symToStringTag] = tag;
  11265. } else {
  11266. delete value[symToStringTag];
  11267. }
  11268. }
  11269. return result;
  11270. }
  11271. /**
  11272. * Creates an array of the own enumerable symbols of `object`.
  11273. *
  11274. * @private
  11275. * @param {Object} object The object to query.
  11276. * @returns {Array} Returns the array of symbols.
  11277. */
  11278. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  11279. if (object == null) {
  11280. return [];
  11281. }
  11282. object = Object(object);
  11283. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  11284. return propertyIsEnumerable.call(object, symbol);
  11285. });
  11286. };
  11287. /**
  11288. * Creates an array of the own and inherited enumerable symbols of `object`.
  11289. *
  11290. * @private
  11291. * @param {Object} object The object to query.
  11292. * @returns {Array} Returns the array of symbols.
  11293. */
  11294. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  11295. var result = [];
  11296. while (object) {
  11297. arrayPush(result, getSymbols(object));
  11298. object = getPrototype(object);
  11299. }
  11300. return result;
  11301. };
  11302. /**
  11303. * Gets the `toStringTag` of `value`.
  11304. *
  11305. * @private
  11306. * @param {*} value The value to query.
  11307. * @returns {string} Returns the `toStringTag`.
  11308. */
  11309. var getTag = baseGetTag;
  11310. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  11311. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  11312. (Map && getTag(new Map) != mapTag) ||
  11313. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  11314. (Set && getTag(new Set) != setTag) ||
  11315. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  11316. getTag = function(value) {
  11317. var result = baseGetTag(value),
  11318. Ctor = result == objectTag ? value.constructor : undefined$1,
  11319. ctorString = Ctor ? toSource(Ctor) : '';
  11320. if (ctorString) {
  11321. switch (ctorString) {
  11322. case dataViewCtorString: return dataViewTag;
  11323. case mapCtorString: return mapTag;
  11324. case promiseCtorString: return promiseTag;
  11325. case setCtorString: return setTag;
  11326. case weakMapCtorString: return weakMapTag;
  11327. }
  11328. }
  11329. return result;
  11330. };
  11331. }
  11332. /**
  11333. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  11334. *
  11335. * @private
  11336. * @param {number} start The start of the view.
  11337. * @param {number} end The end of the view.
  11338. * @param {Array} transforms The transformations to apply to the view.
  11339. * @returns {Object} Returns an object containing the `start` and `end`
  11340. * positions of the view.
  11341. */
  11342. function getView(start, end, transforms) {
  11343. var index = -1,
  11344. length = transforms.length;
  11345. while (++index < length) {
  11346. var data = transforms[index],
  11347. size = data.size;
  11348. switch (data.type) {
  11349. case 'drop': start += size; break;
  11350. case 'dropRight': end -= size; break;
  11351. case 'take': end = nativeMin(end, start + size); break;
  11352. case 'takeRight': start = nativeMax(start, end - size); break;
  11353. }
  11354. }
  11355. return { 'start': start, 'end': end };
  11356. }
  11357. /**
  11358. * Extracts wrapper details from the `source` body comment.
  11359. *
  11360. * @private
  11361. * @param {string} source The source to inspect.
  11362. * @returns {Array} Returns the wrapper details.
  11363. */
  11364. function getWrapDetails(source) {
  11365. var match = source.match(reWrapDetails);
  11366. return match ? match[1].split(reSplitDetails) : [];
  11367. }
  11368. /**
  11369. * Checks if `path` exists on `object`.
  11370. *
  11371. * @private
  11372. * @param {Object} object The object to query.
  11373. * @param {Array|string} path The path to check.
  11374. * @param {Function} hasFunc The function to check properties.
  11375. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  11376. */
  11377. function hasPath(object, path, hasFunc) {
  11378. path = castPath(path, object);
  11379. var index = -1,
  11380. length = path.length,
  11381. result = false;
  11382. while (++index < length) {
  11383. var key = toKey(path[index]);
  11384. if (!(result = object != null && hasFunc(object, key))) {
  11385. break;
  11386. }
  11387. object = object[key];
  11388. }
  11389. if (result || ++index != length) {
  11390. return result;
  11391. }
  11392. length = object == null ? 0 : object.length;
  11393. return !!length && isLength(length) && isIndex(key, length) &&
  11394. (isArray(object) || isArguments(object));
  11395. }
  11396. /**
  11397. * Initializes an array clone.
  11398. *
  11399. * @private
  11400. * @param {Array} array The array to clone.
  11401. * @returns {Array} Returns the initialized clone.
  11402. */
  11403. function initCloneArray(array) {
  11404. var length = array.length,
  11405. result = new array.constructor(length);
  11406. // Add properties assigned by `RegExp#exec`.
  11407. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  11408. result.index = array.index;
  11409. result.input = array.input;
  11410. }
  11411. return result;
  11412. }
  11413. /**
  11414. * Initializes an object clone.
  11415. *
  11416. * @private
  11417. * @param {Object} object The object to clone.
  11418. * @returns {Object} Returns the initialized clone.
  11419. */
  11420. function initCloneObject(object) {
  11421. return (typeof object.constructor == 'function' && !isPrototype(object))
  11422. ? baseCreate(getPrototype(object))
  11423. : {};
  11424. }
  11425. /**
  11426. * Initializes an object clone based on its `toStringTag`.
  11427. *
  11428. * **Note:** This function only supports cloning values with tags of
  11429. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  11430. *
  11431. * @private
  11432. * @param {Object} object The object to clone.
  11433. * @param {string} tag The `toStringTag` of the object to clone.
  11434. * @param {boolean} [isDeep] Specify a deep clone.
  11435. * @returns {Object} Returns the initialized clone.
  11436. */
  11437. function initCloneByTag(object, tag, isDeep) {
  11438. var Ctor = object.constructor;
  11439. switch (tag) {
  11440. case arrayBufferTag:
  11441. return cloneArrayBuffer(object);
  11442. case boolTag:
  11443. case dateTag:
  11444. return new Ctor(+object);
  11445. case dataViewTag:
  11446. return cloneDataView(object, isDeep);
  11447. case float32Tag: case float64Tag:
  11448. case int8Tag: case int16Tag: case int32Tag:
  11449. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  11450. return cloneTypedArray(object, isDeep);
  11451. case mapTag:
  11452. return new Ctor;
  11453. case numberTag:
  11454. case stringTag:
  11455. return new Ctor(object);
  11456. case regexpTag:
  11457. return cloneRegExp(object);
  11458. case setTag:
  11459. return new Ctor;
  11460. case symbolTag:
  11461. return cloneSymbol(object);
  11462. }
  11463. }
  11464. /**
  11465. * Inserts wrapper `details` in a comment at the top of the `source` body.
  11466. *
  11467. * @private
  11468. * @param {string} source The source to modify.
  11469. * @returns {Array} details The details to insert.
  11470. * @returns {string} Returns the modified source.
  11471. */
  11472. function insertWrapDetails(source, details) {
  11473. var length = details.length;
  11474. if (!length) {
  11475. return source;
  11476. }
  11477. var lastIndex = length - 1;
  11478. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  11479. details = details.join(length > 2 ? ', ' : ' ');
  11480. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  11481. }
  11482. /**
  11483. * Checks if `value` is a flattenable `arguments` object or array.
  11484. *
  11485. * @private
  11486. * @param {*} value The value to check.
  11487. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  11488. */
  11489. function isFlattenable(value) {
  11490. return isArray(value) || isArguments(value) ||
  11491. !!(spreadableSymbol && value && value[spreadableSymbol]);
  11492. }
  11493. /**
  11494. * Checks if `value` is a valid array-like index.
  11495. *
  11496. * @private
  11497. * @param {*} value The value to check.
  11498. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  11499. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  11500. */
  11501. function isIndex(value, length) {
  11502. var type = typeof value;
  11503. length = length == null ? MAX_SAFE_INTEGER : length;
  11504. return !!length &&
  11505. (type == 'number' ||
  11506. (type != 'symbol' && reIsUint.test(value))) &&
  11507. (value > -1 && value % 1 == 0 && value < length);
  11508. }
  11509. /**
  11510. * Checks if the given arguments are from an iteratee call.
  11511. *
  11512. * @private
  11513. * @param {*} value The potential iteratee value argument.
  11514. * @param {*} index The potential iteratee index or key argument.
  11515. * @param {*} object The potential iteratee object argument.
  11516. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  11517. * else `false`.
  11518. */
  11519. function isIterateeCall(value, index, object) {
  11520. if (!isObject(object)) {
  11521. return false;
  11522. }
  11523. var type = typeof index;
  11524. if (type == 'number'
  11525. ? (isArrayLike(object) && isIndex(index, object.length))
  11526. : (type == 'string' && index in object)
  11527. ) {
  11528. return eq(object[index], value);
  11529. }
  11530. return false;
  11531. }
  11532. /**
  11533. * Checks if `value` is a property name and not a property path.
  11534. *
  11535. * @private
  11536. * @param {*} value The value to check.
  11537. * @param {Object} [object] The object to query keys on.
  11538. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  11539. */
  11540. function isKey(value, object) {
  11541. if (isArray(value)) {
  11542. return false;
  11543. }
  11544. var type = typeof value;
  11545. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  11546. value == null || isSymbol(value)) {
  11547. return true;
  11548. }
  11549. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  11550. (object != null && value in Object(object));
  11551. }
  11552. /**
  11553. * Checks if `value` is suitable for use as unique object key.
  11554. *
  11555. * @private
  11556. * @param {*} value The value to check.
  11557. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  11558. */
  11559. function isKeyable(value) {
  11560. var type = typeof value;
  11561. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  11562. ? (value !== '__proto__')
  11563. : (value === null);
  11564. }
  11565. /**
  11566. * Checks if `func` has a lazy counterpart.
  11567. *
  11568. * @private
  11569. * @param {Function} func The function to check.
  11570. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  11571. * else `false`.
  11572. */
  11573. function isLaziable(func) {
  11574. var funcName = getFuncName(func),
  11575. other = lodash[funcName];
  11576. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  11577. return false;
  11578. }
  11579. if (func === other) {
  11580. return true;
  11581. }
  11582. var data = getData(other);
  11583. return !!data && func === data[0];
  11584. }
  11585. /**
  11586. * Checks if `func` has its source masked.
  11587. *
  11588. * @private
  11589. * @param {Function} func The function to check.
  11590. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  11591. */
  11592. function isMasked(func) {
  11593. return !!maskSrcKey && (maskSrcKey in func);
  11594. }
  11595. /**
  11596. * Checks if `func` is capable of being masked.
  11597. *
  11598. * @private
  11599. * @param {*} value The value to check.
  11600. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  11601. */
  11602. var isMaskable = coreJsData ? isFunction : stubFalse;
  11603. /**
  11604. * Checks if `value` is likely a prototype object.
  11605. *
  11606. * @private
  11607. * @param {*} value The value to check.
  11608. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  11609. */
  11610. function isPrototype(value) {
  11611. var Ctor = value && value.constructor,
  11612. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  11613. return value === proto;
  11614. }
  11615. /**
  11616. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  11617. *
  11618. * @private
  11619. * @param {*} value The value to check.
  11620. * @returns {boolean} Returns `true` if `value` if suitable for strict
  11621. * equality comparisons, else `false`.
  11622. */
  11623. function isStrictComparable(value) {
  11624. return value === value && !isObject(value);
  11625. }
  11626. /**
  11627. * A specialized version of `matchesProperty` for source values suitable
  11628. * for strict equality comparisons, i.e. `===`.
  11629. *
  11630. * @private
  11631. * @param {string} key The key of the property to get.
  11632. * @param {*} srcValue The value to match.
  11633. * @returns {Function} Returns the new spec function.
  11634. */
  11635. function matchesStrictComparable(key, srcValue) {
  11636. return function(object) {
  11637. if (object == null) {
  11638. return false;
  11639. }
  11640. return object[key] === srcValue &&
  11641. (srcValue !== undefined$1 || (key in Object(object)));
  11642. };
  11643. }
  11644. /**
  11645. * A specialized version of `_.memoize` which clears the memoized function's
  11646. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  11647. *
  11648. * @private
  11649. * @param {Function} func The function to have its output memoized.
  11650. * @returns {Function} Returns the new memoized function.
  11651. */
  11652. function memoizeCapped(func) {
  11653. var result = memoize(func, function(key) {
  11654. if (cache.size === MAX_MEMOIZE_SIZE) {
  11655. cache.clear();
  11656. }
  11657. return key;
  11658. });
  11659. var cache = result.cache;
  11660. return result;
  11661. }
  11662. /**
  11663. * Merges the function metadata of `source` into `data`.
  11664. *
  11665. * Merging metadata reduces the number of wrappers used to invoke a function.
  11666. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  11667. * may be applied regardless of execution order. Methods like `_.ary` and
  11668. * `_.rearg` modify function arguments, making the order in which they are
  11669. * executed important, preventing the merging of metadata. However, we make
  11670. * an exception for a safe combined case where curried functions have `_.ary`
  11671. * and or `_.rearg` applied.
  11672. *
  11673. * @private
  11674. * @param {Array} data The destination metadata.
  11675. * @param {Array} source The source metadata.
  11676. * @returns {Array} Returns `data`.
  11677. */
  11678. function mergeData(data, source) {
  11679. var bitmask = data[1],
  11680. srcBitmask = source[1],
  11681. newBitmask = bitmask | srcBitmask,
  11682. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  11683. var isCombo =
  11684. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  11685. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  11686. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  11687. // Exit early if metadata can't be merged.
  11688. if (!(isCommon || isCombo)) {
  11689. return data;
  11690. }
  11691. // Use source `thisArg` if available.
  11692. if (srcBitmask & WRAP_BIND_FLAG) {
  11693. data[2] = source[2];
  11694. // Set when currying a bound function.
  11695. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  11696. }
  11697. // Compose partial arguments.
  11698. var value = source[3];
  11699. if (value) {
  11700. var partials = data[3];
  11701. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  11702. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  11703. }
  11704. // Compose partial right arguments.
  11705. value = source[5];
  11706. if (value) {
  11707. partials = data[5];
  11708. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  11709. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  11710. }
  11711. // Use source `argPos` if available.
  11712. value = source[7];
  11713. if (value) {
  11714. data[7] = value;
  11715. }
  11716. // Use source `ary` if it's smaller.
  11717. if (srcBitmask & WRAP_ARY_FLAG) {
  11718. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  11719. }
  11720. // Use source `arity` if one is not provided.
  11721. if (data[9] == null) {
  11722. data[9] = source[9];
  11723. }
  11724. // Use source `func` and merge bitmasks.
  11725. data[0] = source[0];
  11726. data[1] = newBitmask;
  11727. return data;
  11728. }
  11729. /**
  11730. * This function is like
  11731. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11732. * except that it includes inherited enumerable properties.
  11733. *
  11734. * @private
  11735. * @param {Object} object The object to query.
  11736. * @returns {Array} Returns the array of property names.
  11737. */
  11738. function nativeKeysIn(object) {
  11739. var result = [];
  11740. if (object != null) {
  11741. for (var key in Object(object)) {
  11742. result.push(key);
  11743. }
  11744. }
  11745. return result;
  11746. }
  11747. /**
  11748. * Converts `value` to a string using `Object.prototype.toString`.
  11749. *
  11750. * @private
  11751. * @param {*} value The value to convert.
  11752. * @returns {string} Returns the converted string.
  11753. */
  11754. function objectToString(value) {
  11755. return nativeObjectToString.call(value);
  11756. }
  11757. /**
  11758. * A specialized version of `baseRest` which transforms the rest array.
  11759. *
  11760. * @private
  11761. * @param {Function} func The function to apply a rest parameter to.
  11762. * @param {number} [start=func.length-1] The start position of the rest parameter.
  11763. * @param {Function} transform The rest array transform.
  11764. * @returns {Function} Returns the new function.
  11765. */
  11766. function overRest(func, start, transform) {
  11767. start = nativeMax(start === undefined$1 ? (func.length - 1) : start, 0);
  11768. return function() {
  11769. var args = arguments,
  11770. index = -1,
  11771. length = nativeMax(args.length - start, 0),
  11772. array = Array(length);
  11773. while (++index < length) {
  11774. array[index] = args[start + index];
  11775. }
  11776. index = -1;
  11777. var otherArgs = Array(start + 1);
  11778. while (++index < start) {
  11779. otherArgs[index] = args[index];
  11780. }
  11781. otherArgs[start] = transform(array);
  11782. return apply(func, this, otherArgs);
  11783. };
  11784. }
  11785. /**
  11786. * Gets the parent value at `path` of `object`.
  11787. *
  11788. * @private
  11789. * @param {Object} object The object to query.
  11790. * @param {Array} path The path to get the parent value of.
  11791. * @returns {*} Returns the parent value.
  11792. */
  11793. function parent(object, path) {
  11794. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  11795. }
  11796. /**
  11797. * Reorder `array` according to the specified indexes where the element at
  11798. * the first index is assigned as the first element, the element at
  11799. * the second index is assigned as the second element, and so on.
  11800. *
  11801. * @private
  11802. * @param {Array} array The array to reorder.
  11803. * @param {Array} indexes The arranged array indexes.
  11804. * @returns {Array} Returns `array`.
  11805. */
  11806. function reorder(array, indexes) {
  11807. var arrLength = array.length,
  11808. length = nativeMin(indexes.length, arrLength),
  11809. oldArray = copyArray(array);
  11810. while (length--) {
  11811. var index = indexes[length];
  11812. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined$1;
  11813. }
  11814. return array;
  11815. }
  11816. /**
  11817. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  11818. *
  11819. * @private
  11820. * @param {Object} object The object to query.
  11821. * @param {string} key The key of the property to get.
  11822. * @returns {*} Returns the property value.
  11823. */
  11824. function safeGet(object, key) {
  11825. if (key === 'constructor' && typeof object[key] === 'function') {
  11826. return;
  11827. }
  11828. if (key == '__proto__') {
  11829. return;
  11830. }
  11831. return object[key];
  11832. }
  11833. /**
  11834. * Sets metadata for `func`.
  11835. *
  11836. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  11837. * period of time, it will trip its breaker and transition to an identity
  11838. * function to avoid garbage collection pauses in V8. See
  11839. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  11840. * for more details.
  11841. *
  11842. * @private
  11843. * @param {Function} func The function to associate metadata with.
  11844. * @param {*} data The metadata.
  11845. * @returns {Function} Returns `func`.
  11846. */
  11847. var setData = shortOut(baseSetData);
  11848. /**
  11849. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  11850. *
  11851. * @private
  11852. * @param {Function} func The function to delay.
  11853. * @param {number} wait The number of milliseconds to delay invocation.
  11854. * @returns {number|Object} Returns the timer id or timeout object.
  11855. */
  11856. var setTimeout = ctxSetTimeout || function(func, wait) {
  11857. return root.setTimeout(func, wait);
  11858. };
  11859. /**
  11860. * Sets the `toString` method of `func` to return `string`.
  11861. *
  11862. * @private
  11863. * @param {Function} func The function to modify.
  11864. * @param {Function} string The `toString` result.
  11865. * @returns {Function} Returns `func`.
  11866. */
  11867. var setToString = shortOut(baseSetToString);
  11868. /**
  11869. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  11870. * with wrapper details in a comment at the top of the source body.
  11871. *
  11872. * @private
  11873. * @param {Function} wrapper The function to modify.
  11874. * @param {Function} reference The reference function.
  11875. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  11876. * @returns {Function} Returns `wrapper`.
  11877. */
  11878. function setWrapToString(wrapper, reference, bitmask) {
  11879. var source = (reference + '');
  11880. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  11881. }
  11882. /**
  11883. * Creates a function that'll short out and invoke `identity` instead
  11884. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  11885. * milliseconds.
  11886. *
  11887. * @private
  11888. * @param {Function} func The function to restrict.
  11889. * @returns {Function} Returns the new shortable function.
  11890. */
  11891. function shortOut(func) {
  11892. var count = 0,
  11893. lastCalled = 0;
  11894. return function() {
  11895. var stamp = nativeNow(),
  11896. remaining = HOT_SPAN - (stamp - lastCalled);
  11897. lastCalled = stamp;
  11898. if (remaining > 0) {
  11899. if (++count >= HOT_COUNT) {
  11900. return arguments[0];
  11901. }
  11902. } else {
  11903. count = 0;
  11904. }
  11905. return func.apply(undefined$1, arguments);
  11906. };
  11907. }
  11908. /**
  11909. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  11910. *
  11911. * @private
  11912. * @param {Array} array The array to shuffle.
  11913. * @param {number} [size=array.length] The size of `array`.
  11914. * @returns {Array} Returns `array`.
  11915. */
  11916. function shuffleSelf(array, size) {
  11917. var index = -1,
  11918. length = array.length,
  11919. lastIndex = length - 1;
  11920. size = size === undefined$1 ? length : size;
  11921. while (++index < size) {
  11922. var rand = baseRandom(index, lastIndex),
  11923. value = array[rand];
  11924. array[rand] = array[index];
  11925. array[index] = value;
  11926. }
  11927. array.length = size;
  11928. return array;
  11929. }
  11930. /**
  11931. * Converts `string` to a property path array.
  11932. *
  11933. * @private
  11934. * @param {string} string The string to convert.
  11935. * @returns {Array} Returns the property path array.
  11936. */
  11937. var stringToPath = memoizeCapped(function(string) {
  11938. var result = [];
  11939. if (string.charCodeAt(0) === 46 /* . */) {
  11940. result.push('');
  11941. }
  11942. string.replace(rePropName, function(match, number, quote, subString) {
  11943. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  11944. });
  11945. return result;
  11946. });
  11947. /**
  11948. * Converts `value` to a string key if it's not a string or symbol.
  11949. *
  11950. * @private
  11951. * @param {*} value The value to inspect.
  11952. * @returns {string|symbol} Returns the key.
  11953. */
  11954. function toKey(value) {
  11955. if (typeof value == 'string' || isSymbol(value)) {
  11956. return value;
  11957. }
  11958. var result = (value + '');
  11959. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  11960. }
  11961. /**
  11962. * Converts `func` to its source code.
  11963. *
  11964. * @private
  11965. * @param {Function} func The function to convert.
  11966. * @returns {string} Returns the source code.
  11967. */
  11968. function toSource(func) {
  11969. if (func != null) {
  11970. try {
  11971. return funcToString.call(func);
  11972. } catch (e) {}
  11973. try {
  11974. return (func + '');
  11975. } catch (e) {}
  11976. }
  11977. return '';
  11978. }
  11979. /**
  11980. * Updates wrapper `details` based on `bitmask` flags.
  11981. *
  11982. * @private
  11983. * @returns {Array} details The details to modify.
  11984. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  11985. * @returns {Array} Returns `details`.
  11986. */
  11987. function updateWrapDetails(details, bitmask) {
  11988. arrayEach(wrapFlags, function(pair) {
  11989. var value = '_.' + pair[0];
  11990. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  11991. details.push(value);
  11992. }
  11993. });
  11994. return details.sort();
  11995. }
  11996. /**
  11997. * Creates a clone of `wrapper`.
  11998. *
  11999. * @private
  12000. * @param {Object} wrapper The wrapper to clone.
  12001. * @returns {Object} Returns the cloned wrapper.
  12002. */
  12003. function wrapperClone(wrapper) {
  12004. if (wrapper instanceof LazyWrapper) {
  12005. return wrapper.clone();
  12006. }
  12007. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  12008. result.__actions__ = copyArray(wrapper.__actions__);
  12009. result.__index__ = wrapper.__index__;
  12010. result.__values__ = wrapper.__values__;
  12011. return result;
  12012. }
  12013. /*------------------------------------------------------------------------*/
  12014. /**
  12015. * Creates an array of elements split into groups the length of `size`.
  12016. * If `array` can't be split evenly, the final chunk will be the remaining
  12017. * elements.
  12018. *
  12019. * @static
  12020. * @memberOf _
  12021. * @since 3.0.0
  12022. * @category Array
  12023. * @param {Array} array The array to process.
  12024. * @param {number} [size=1] The length of each chunk
  12025. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12026. * @returns {Array} Returns the new array of chunks.
  12027. * @example
  12028. *
  12029. * _.chunk(['a', 'b', 'c', 'd'], 2);
  12030. * // => [['a', 'b'], ['c', 'd']]
  12031. *
  12032. * _.chunk(['a', 'b', 'c', 'd'], 3);
  12033. * // => [['a', 'b', 'c'], ['d']]
  12034. */
  12035. function chunk(array, size, guard) {
  12036. if ((guard ? isIterateeCall(array, size, guard) : size === undefined$1)) {
  12037. size = 1;
  12038. } else {
  12039. size = nativeMax(toInteger(size), 0);
  12040. }
  12041. var length = array == null ? 0 : array.length;
  12042. if (!length || size < 1) {
  12043. return [];
  12044. }
  12045. var index = 0,
  12046. resIndex = 0,
  12047. result = Array(nativeCeil(length / size));
  12048. while (index < length) {
  12049. result[resIndex++] = baseSlice(array, index, (index += size));
  12050. }
  12051. return result;
  12052. }
  12053. /**
  12054. * Creates an array with all falsey values removed. The values `false`, `null`,
  12055. * `0`, `""`, `undefined`, and `NaN` are falsey.
  12056. *
  12057. * @static
  12058. * @memberOf _
  12059. * @since 0.1.0
  12060. * @category Array
  12061. * @param {Array} array The array to compact.
  12062. * @returns {Array} Returns the new array of filtered values.
  12063. * @example
  12064. *
  12065. * _.compact([0, 1, false, 2, '', 3]);
  12066. * // => [1, 2, 3]
  12067. */
  12068. function compact(array) {
  12069. var index = -1,
  12070. length = array == null ? 0 : array.length,
  12071. resIndex = 0,
  12072. result = [];
  12073. while (++index < length) {
  12074. var value = array[index];
  12075. if (value) {
  12076. result[resIndex++] = value;
  12077. }
  12078. }
  12079. return result;
  12080. }
  12081. /**
  12082. * Creates a new array concatenating `array` with any additional arrays
  12083. * and/or values.
  12084. *
  12085. * @static
  12086. * @memberOf _
  12087. * @since 4.0.0
  12088. * @category Array
  12089. * @param {Array} array The array to concatenate.
  12090. * @param {...*} [values] The values to concatenate.
  12091. * @returns {Array} Returns the new concatenated array.
  12092. * @example
  12093. *
  12094. * var array = [1];
  12095. * var other = _.concat(array, 2, [3], [[4]]);
  12096. *
  12097. * console.log(other);
  12098. * // => [1, 2, 3, [4]]
  12099. *
  12100. * console.log(array);
  12101. * // => [1]
  12102. */
  12103. function concat() {
  12104. var length = arguments.length;
  12105. if (!length) {
  12106. return [];
  12107. }
  12108. var args = Array(length - 1),
  12109. array = arguments[0],
  12110. index = length;
  12111. while (index--) {
  12112. args[index - 1] = arguments[index];
  12113. }
  12114. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  12115. }
  12116. /**
  12117. * Creates an array of `array` values not included in the other given arrays
  12118. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12119. * for equality comparisons. The order and references of result values are
  12120. * determined by the first array.
  12121. *
  12122. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  12123. *
  12124. * @static
  12125. * @memberOf _
  12126. * @since 0.1.0
  12127. * @category Array
  12128. * @param {Array} array The array to inspect.
  12129. * @param {...Array} [values] The values to exclude.
  12130. * @returns {Array} Returns the new array of filtered values.
  12131. * @see _.without, _.xor
  12132. * @example
  12133. *
  12134. * _.difference([2, 1], [2, 3]);
  12135. * // => [1]
  12136. */
  12137. var difference = baseRest(function(array, values) {
  12138. return isArrayLikeObject(array)
  12139. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  12140. : [];
  12141. });
  12142. /**
  12143. * This method is like `_.difference` except that it accepts `iteratee` which
  12144. * is invoked for each element of `array` and `values` to generate the criterion
  12145. * by which they're compared. The order and references of result values are
  12146. * determined by the first array. The iteratee is invoked with one argument:
  12147. * (value).
  12148. *
  12149. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  12150. *
  12151. * @static
  12152. * @memberOf _
  12153. * @since 4.0.0
  12154. * @category Array
  12155. * @param {Array} array The array to inspect.
  12156. * @param {...Array} [values] The values to exclude.
  12157. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12158. * @returns {Array} Returns the new array of filtered values.
  12159. * @example
  12160. *
  12161. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  12162. * // => [1.2]
  12163. *
  12164. * // The `_.property` iteratee shorthand.
  12165. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  12166. * // => [{ 'x': 2 }]
  12167. */
  12168. var differenceBy = baseRest(function(array, values) {
  12169. var iteratee = last(values);
  12170. if (isArrayLikeObject(iteratee)) {
  12171. iteratee = undefined$1;
  12172. }
  12173. return isArrayLikeObject(array)
  12174. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  12175. : [];
  12176. });
  12177. /**
  12178. * This method is like `_.difference` except that it accepts `comparator`
  12179. * which is invoked to compare elements of `array` to `values`. The order and
  12180. * references of result values are determined by the first array. The comparator
  12181. * is invoked with two arguments: (arrVal, othVal).
  12182. *
  12183. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  12184. *
  12185. * @static
  12186. * @memberOf _
  12187. * @since 4.0.0
  12188. * @category Array
  12189. * @param {Array} array The array to inspect.
  12190. * @param {...Array} [values] The values to exclude.
  12191. * @param {Function} [comparator] The comparator invoked per element.
  12192. * @returns {Array} Returns the new array of filtered values.
  12193. * @example
  12194. *
  12195. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  12196. *
  12197. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  12198. * // => [{ 'x': 2, 'y': 1 }]
  12199. */
  12200. var differenceWith = baseRest(function(array, values) {
  12201. var comparator = last(values);
  12202. if (isArrayLikeObject(comparator)) {
  12203. comparator = undefined$1;
  12204. }
  12205. return isArrayLikeObject(array)
  12206. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined$1, comparator)
  12207. : [];
  12208. });
  12209. /**
  12210. * Creates a slice of `array` with `n` elements dropped from the beginning.
  12211. *
  12212. * @static
  12213. * @memberOf _
  12214. * @since 0.5.0
  12215. * @category Array
  12216. * @param {Array} array The array to query.
  12217. * @param {number} [n=1] The number of elements to drop.
  12218. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12219. * @returns {Array} Returns the slice of `array`.
  12220. * @example
  12221. *
  12222. * _.drop([1, 2, 3]);
  12223. * // => [2, 3]
  12224. *
  12225. * _.drop([1, 2, 3], 2);
  12226. * // => [3]
  12227. *
  12228. * _.drop([1, 2, 3], 5);
  12229. * // => []
  12230. *
  12231. * _.drop([1, 2, 3], 0);
  12232. * // => [1, 2, 3]
  12233. */
  12234. function drop(array, n, guard) {
  12235. var length = array == null ? 0 : array.length;
  12236. if (!length) {
  12237. return [];
  12238. }
  12239. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  12240. return baseSlice(array, n < 0 ? 0 : n, length);
  12241. }
  12242. /**
  12243. * Creates a slice of `array` with `n` elements dropped from the end.
  12244. *
  12245. * @static
  12246. * @memberOf _
  12247. * @since 3.0.0
  12248. * @category Array
  12249. * @param {Array} array The array to query.
  12250. * @param {number} [n=1] The number of elements to drop.
  12251. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12252. * @returns {Array} Returns the slice of `array`.
  12253. * @example
  12254. *
  12255. * _.dropRight([1, 2, 3]);
  12256. * // => [1, 2]
  12257. *
  12258. * _.dropRight([1, 2, 3], 2);
  12259. * // => [1]
  12260. *
  12261. * _.dropRight([1, 2, 3], 5);
  12262. * // => []
  12263. *
  12264. * _.dropRight([1, 2, 3], 0);
  12265. * // => [1, 2, 3]
  12266. */
  12267. function dropRight(array, n, guard) {
  12268. var length = array == null ? 0 : array.length;
  12269. if (!length) {
  12270. return [];
  12271. }
  12272. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  12273. n = length - n;
  12274. return baseSlice(array, 0, n < 0 ? 0 : n);
  12275. }
  12276. /**
  12277. * Creates a slice of `array` excluding elements dropped from the end.
  12278. * Elements are dropped until `predicate` returns falsey. The predicate is
  12279. * invoked with three arguments: (value, index, array).
  12280. *
  12281. * @static
  12282. * @memberOf _
  12283. * @since 3.0.0
  12284. * @category Array
  12285. * @param {Array} array The array to query.
  12286. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12287. * @returns {Array} Returns the slice of `array`.
  12288. * @example
  12289. *
  12290. * var users = [
  12291. * { 'user': 'barney', 'active': true },
  12292. * { 'user': 'fred', 'active': false },
  12293. * { 'user': 'pebbles', 'active': false }
  12294. * ];
  12295. *
  12296. * _.dropRightWhile(users, function(o) { return !o.active; });
  12297. * // => objects for ['barney']
  12298. *
  12299. * // The `_.matches` iteratee shorthand.
  12300. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  12301. * // => objects for ['barney', 'fred']
  12302. *
  12303. * // The `_.matchesProperty` iteratee shorthand.
  12304. * _.dropRightWhile(users, ['active', false]);
  12305. * // => objects for ['barney']
  12306. *
  12307. * // The `_.property` iteratee shorthand.
  12308. * _.dropRightWhile(users, 'active');
  12309. * // => objects for ['barney', 'fred', 'pebbles']
  12310. */
  12311. function dropRightWhile(array, predicate) {
  12312. return (array && array.length)
  12313. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  12314. : [];
  12315. }
  12316. /**
  12317. * Creates a slice of `array` excluding elements dropped from the beginning.
  12318. * Elements are dropped until `predicate` returns falsey. The predicate is
  12319. * invoked with three arguments: (value, index, array).
  12320. *
  12321. * @static
  12322. * @memberOf _
  12323. * @since 3.0.0
  12324. * @category Array
  12325. * @param {Array} array The array to query.
  12326. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12327. * @returns {Array} Returns the slice of `array`.
  12328. * @example
  12329. *
  12330. * var users = [
  12331. * { 'user': 'barney', 'active': false },
  12332. * { 'user': 'fred', 'active': false },
  12333. * { 'user': 'pebbles', 'active': true }
  12334. * ];
  12335. *
  12336. * _.dropWhile(users, function(o) { return !o.active; });
  12337. * // => objects for ['pebbles']
  12338. *
  12339. * // The `_.matches` iteratee shorthand.
  12340. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  12341. * // => objects for ['fred', 'pebbles']
  12342. *
  12343. * // The `_.matchesProperty` iteratee shorthand.
  12344. * _.dropWhile(users, ['active', false]);
  12345. * // => objects for ['pebbles']
  12346. *
  12347. * // The `_.property` iteratee shorthand.
  12348. * _.dropWhile(users, 'active');
  12349. * // => objects for ['barney', 'fred', 'pebbles']
  12350. */
  12351. function dropWhile(array, predicate) {
  12352. return (array && array.length)
  12353. ? baseWhile(array, getIteratee(predicate, 3), true)
  12354. : [];
  12355. }
  12356. /**
  12357. * Fills elements of `array` with `value` from `start` up to, but not
  12358. * including, `end`.
  12359. *
  12360. * **Note:** This method mutates `array`.
  12361. *
  12362. * @static
  12363. * @memberOf _
  12364. * @since 3.2.0
  12365. * @category Array
  12366. * @param {Array} array The array to fill.
  12367. * @param {*} value The value to fill `array` with.
  12368. * @param {number} [start=0] The start position.
  12369. * @param {number} [end=array.length] The end position.
  12370. * @returns {Array} Returns `array`.
  12371. * @example
  12372. *
  12373. * var array = [1, 2, 3];
  12374. *
  12375. * _.fill(array, 'a');
  12376. * console.log(array);
  12377. * // => ['a', 'a', 'a']
  12378. *
  12379. * _.fill(Array(3), 2);
  12380. * // => [2, 2, 2]
  12381. *
  12382. * _.fill([4, 6, 8, 10], '*', 1, 3);
  12383. * // => [4, '*', '*', 10]
  12384. */
  12385. function fill(array, value, start, end) {
  12386. var length = array == null ? 0 : array.length;
  12387. if (!length) {
  12388. return [];
  12389. }
  12390. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  12391. start = 0;
  12392. end = length;
  12393. }
  12394. return baseFill(array, value, start, end);
  12395. }
  12396. /**
  12397. * This method is like `_.find` except that it returns the index of the first
  12398. * element `predicate` returns truthy for instead of the element itself.
  12399. *
  12400. * @static
  12401. * @memberOf _
  12402. * @since 1.1.0
  12403. * @category Array
  12404. * @param {Array} array The array to inspect.
  12405. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12406. * @param {number} [fromIndex=0] The index to search from.
  12407. * @returns {number} Returns the index of the found element, else `-1`.
  12408. * @example
  12409. *
  12410. * var users = [
  12411. * { 'user': 'barney', 'active': false },
  12412. * { 'user': 'fred', 'active': false },
  12413. * { 'user': 'pebbles', 'active': true }
  12414. * ];
  12415. *
  12416. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  12417. * // => 0
  12418. *
  12419. * // The `_.matches` iteratee shorthand.
  12420. * _.findIndex(users, { 'user': 'fred', 'active': false });
  12421. * // => 1
  12422. *
  12423. * // The `_.matchesProperty` iteratee shorthand.
  12424. * _.findIndex(users, ['active', false]);
  12425. * // => 0
  12426. *
  12427. * // The `_.property` iteratee shorthand.
  12428. * _.findIndex(users, 'active');
  12429. * // => 2
  12430. */
  12431. function findIndex(array, predicate, fromIndex) {
  12432. var length = array == null ? 0 : array.length;
  12433. if (!length) {
  12434. return -1;
  12435. }
  12436. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  12437. if (index < 0) {
  12438. index = nativeMax(length + index, 0);
  12439. }
  12440. return baseFindIndex(array, getIteratee(predicate, 3), index);
  12441. }
  12442. /**
  12443. * This method is like `_.findIndex` except that it iterates over elements
  12444. * of `collection` from right to left.
  12445. *
  12446. * @static
  12447. * @memberOf _
  12448. * @since 2.0.0
  12449. * @category Array
  12450. * @param {Array} array The array to inspect.
  12451. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12452. * @param {number} [fromIndex=array.length-1] The index to search from.
  12453. * @returns {number} Returns the index of the found element, else `-1`.
  12454. * @example
  12455. *
  12456. * var users = [
  12457. * { 'user': 'barney', 'active': true },
  12458. * { 'user': 'fred', 'active': false },
  12459. * { 'user': 'pebbles', 'active': false }
  12460. * ];
  12461. *
  12462. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  12463. * // => 2
  12464. *
  12465. * // The `_.matches` iteratee shorthand.
  12466. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  12467. * // => 0
  12468. *
  12469. * // The `_.matchesProperty` iteratee shorthand.
  12470. * _.findLastIndex(users, ['active', false]);
  12471. * // => 2
  12472. *
  12473. * // The `_.property` iteratee shorthand.
  12474. * _.findLastIndex(users, 'active');
  12475. * // => 0
  12476. */
  12477. function findLastIndex(array, predicate, fromIndex) {
  12478. var length = array == null ? 0 : array.length;
  12479. if (!length) {
  12480. return -1;
  12481. }
  12482. var index = length - 1;
  12483. if (fromIndex !== undefined$1) {
  12484. index = toInteger(fromIndex);
  12485. index = fromIndex < 0
  12486. ? nativeMax(length + index, 0)
  12487. : nativeMin(index, length - 1);
  12488. }
  12489. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  12490. }
  12491. /**
  12492. * Flattens `array` a single level deep.
  12493. *
  12494. * @static
  12495. * @memberOf _
  12496. * @since 0.1.0
  12497. * @category Array
  12498. * @param {Array} array The array to flatten.
  12499. * @returns {Array} Returns the new flattened array.
  12500. * @example
  12501. *
  12502. * _.flatten([1, [2, [3, [4]], 5]]);
  12503. * // => [1, 2, [3, [4]], 5]
  12504. */
  12505. function flatten(array) {
  12506. var length = array == null ? 0 : array.length;
  12507. return length ? baseFlatten(array, 1) : [];
  12508. }
  12509. /**
  12510. * Recursively flattens `array`.
  12511. *
  12512. * @static
  12513. * @memberOf _
  12514. * @since 3.0.0
  12515. * @category Array
  12516. * @param {Array} array The array to flatten.
  12517. * @returns {Array} Returns the new flattened array.
  12518. * @example
  12519. *
  12520. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  12521. * // => [1, 2, 3, 4, 5]
  12522. */
  12523. function flattenDeep(array) {
  12524. var length = array == null ? 0 : array.length;
  12525. return length ? baseFlatten(array, INFINITY) : [];
  12526. }
  12527. /**
  12528. * Recursively flatten `array` up to `depth` times.
  12529. *
  12530. * @static
  12531. * @memberOf _
  12532. * @since 4.4.0
  12533. * @category Array
  12534. * @param {Array} array The array to flatten.
  12535. * @param {number} [depth=1] The maximum recursion depth.
  12536. * @returns {Array} Returns the new flattened array.
  12537. * @example
  12538. *
  12539. * var array = [1, [2, [3, [4]], 5]];
  12540. *
  12541. * _.flattenDepth(array, 1);
  12542. * // => [1, 2, [3, [4]], 5]
  12543. *
  12544. * _.flattenDepth(array, 2);
  12545. * // => [1, 2, 3, [4], 5]
  12546. */
  12547. function flattenDepth(array, depth) {
  12548. var length = array == null ? 0 : array.length;
  12549. if (!length) {
  12550. return [];
  12551. }
  12552. depth = depth === undefined$1 ? 1 : toInteger(depth);
  12553. return baseFlatten(array, depth);
  12554. }
  12555. /**
  12556. * The inverse of `_.toPairs`; this method returns an object composed
  12557. * from key-value `pairs`.
  12558. *
  12559. * @static
  12560. * @memberOf _
  12561. * @since 4.0.0
  12562. * @category Array
  12563. * @param {Array} pairs The key-value pairs.
  12564. * @returns {Object} Returns the new object.
  12565. * @example
  12566. *
  12567. * _.fromPairs([['a', 1], ['b', 2]]);
  12568. * // => { 'a': 1, 'b': 2 }
  12569. */
  12570. function fromPairs(pairs) {
  12571. var index = -1,
  12572. length = pairs == null ? 0 : pairs.length,
  12573. result = {};
  12574. while (++index < length) {
  12575. var pair = pairs[index];
  12576. result[pair[0]] = pair[1];
  12577. }
  12578. return result;
  12579. }
  12580. /**
  12581. * Gets the first element of `array`.
  12582. *
  12583. * @static
  12584. * @memberOf _
  12585. * @since 0.1.0
  12586. * @alias first
  12587. * @category Array
  12588. * @param {Array} array The array to query.
  12589. * @returns {*} Returns the first element of `array`.
  12590. * @example
  12591. *
  12592. * _.head([1, 2, 3]);
  12593. * // => 1
  12594. *
  12595. * _.head([]);
  12596. * // => undefined
  12597. */
  12598. function head(array) {
  12599. return (array && array.length) ? array[0] : undefined$1;
  12600. }
  12601. /**
  12602. * Gets the index at which the first occurrence of `value` is found in `array`
  12603. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12604. * for equality comparisons. If `fromIndex` is negative, it's used as the
  12605. * offset from the end of `array`.
  12606. *
  12607. * @static
  12608. * @memberOf _
  12609. * @since 0.1.0
  12610. * @category Array
  12611. * @param {Array} array The array to inspect.
  12612. * @param {*} value The value to search for.
  12613. * @param {number} [fromIndex=0] The index to search from.
  12614. * @returns {number} Returns the index of the matched value, else `-1`.
  12615. * @example
  12616. *
  12617. * _.indexOf([1, 2, 1, 2], 2);
  12618. * // => 1
  12619. *
  12620. * // Search from the `fromIndex`.
  12621. * _.indexOf([1, 2, 1, 2], 2, 2);
  12622. * // => 3
  12623. */
  12624. function indexOf(array, value, fromIndex) {
  12625. var length = array == null ? 0 : array.length;
  12626. if (!length) {
  12627. return -1;
  12628. }
  12629. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  12630. if (index < 0) {
  12631. index = nativeMax(length + index, 0);
  12632. }
  12633. return baseIndexOf(array, value, index);
  12634. }
  12635. /**
  12636. * Gets all but the last element of `array`.
  12637. *
  12638. * @static
  12639. * @memberOf _
  12640. * @since 0.1.0
  12641. * @category Array
  12642. * @param {Array} array The array to query.
  12643. * @returns {Array} Returns the slice of `array`.
  12644. * @example
  12645. *
  12646. * _.initial([1, 2, 3]);
  12647. * // => [1, 2]
  12648. */
  12649. function initial(array) {
  12650. var length = array == null ? 0 : array.length;
  12651. return length ? baseSlice(array, 0, -1) : [];
  12652. }
  12653. /**
  12654. * Creates an array of unique values that are included in all given arrays
  12655. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12656. * for equality comparisons. The order and references of result values are
  12657. * determined by the first array.
  12658. *
  12659. * @static
  12660. * @memberOf _
  12661. * @since 0.1.0
  12662. * @category Array
  12663. * @param {...Array} [arrays] The arrays to inspect.
  12664. * @returns {Array} Returns the new array of intersecting values.
  12665. * @example
  12666. *
  12667. * _.intersection([2, 1], [2, 3]);
  12668. * // => [2]
  12669. */
  12670. var intersection = baseRest(function(arrays) {
  12671. var mapped = arrayMap(arrays, castArrayLikeObject);
  12672. return (mapped.length && mapped[0] === arrays[0])
  12673. ? baseIntersection(mapped)
  12674. : [];
  12675. });
  12676. /**
  12677. * This method is like `_.intersection` except that it accepts `iteratee`
  12678. * which is invoked for each element of each `arrays` to generate the criterion
  12679. * by which they're compared. The order and references of result values are
  12680. * determined by the first array. The iteratee is invoked with one argument:
  12681. * (value).
  12682. *
  12683. * @static
  12684. * @memberOf _
  12685. * @since 4.0.0
  12686. * @category Array
  12687. * @param {...Array} [arrays] The arrays to inspect.
  12688. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12689. * @returns {Array} Returns the new array of intersecting values.
  12690. * @example
  12691. *
  12692. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  12693. * // => [2.1]
  12694. *
  12695. * // The `_.property` iteratee shorthand.
  12696. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  12697. * // => [{ 'x': 1 }]
  12698. */
  12699. var intersectionBy = baseRest(function(arrays) {
  12700. var iteratee = last(arrays),
  12701. mapped = arrayMap(arrays, castArrayLikeObject);
  12702. if (iteratee === last(mapped)) {
  12703. iteratee = undefined$1;
  12704. } else {
  12705. mapped.pop();
  12706. }
  12707. return (mapped.length && mapped[0] === arrays[0])
  12708. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  12709. : [];
  12710. });
  12711. /**
  12712. * This method is like `_.intersection` except that it accepts `comparator`
  12713. * which is invoked to compare elements of `arrays`. The order and references
  12714. * of result values are determined by the first array. The comparator is
  12715. * invoked with two arguments: (arrVal, othVal).
  12716. *
  12717. * @static
  12718. * @memberOf _
  12719. * @since 4.0.0
  12720. * @category Array
  12721. * @param {...Array} [arrays] The arrays to inspect.
  12722. * @param {Function} [comparator] The comparator invoked per element.
  12723. * @returns {Array} Returns the new array of intersecting values.
  12724. * @example
  12725. *
  12726. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  12727. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12728. *
  12729. * _.intersectionWith(objects, others, _.isEqual);
  12730. * // => [{ 'x': 1, 'y': 2 }]
  12731. */
  12732. var intersectionWith = baseRest(function(arrays) {
  12733. var comparator = last(arrays),
  12734. mapped = arrayMap(arrays, castArrayLikeObject);
  12735. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  12736. if (comparator) {
  12737. mapped.pop();
  12738. }
  12739. return (mapped.length && mapped[0] === arrays[0])
  12740. ? baseIntersection(mapped, undefined$1, comparator)
  12741. : [];
  12742. });
  12743. /**
  12744. * Converts all elements in `array` into a string separated by `separator`.
  12745. *
  12746. * @static
  12747. * @memberOf _
  12748. * @since 4.0.0
  12749. * @category Array
  12750. * @param {Array} array The array to convert.
  12751. * @param {string} [separator=','] The element separator.
  12752. * @returns {string} Returns the joined string.
  12753. * @example
  12754. *
  12755. * _.join(['a', 'b', 'c'], '~');
  12756. * // => 'a~b~c'
  12757. */
  12758. function join(array, separator) {
  12759. return array == null ? '' : nativeJoin.call(array, separator);
  12760. }
  12761. /**
  12762. * Gets the last element of `array`.
  12763. *
  12764. * @static
  12765. * @memberOf _
  12766. * @since 0.1.0
  12767. * @category Array
  12768. * @param {Array} array The array to query.
  12769. * @returns {*} Returns the last element of `array`.
  12770. * @example
  12771. *
  12772. * _.last([1, 2, 3]);
  12773. * // => 3
  12774. */
  12775. function last(array) {
  12776. var length = array == null ? 0 : array.length;
  12777. return length ? array[length - 1] : undefined$1;
  12778. }
  12779. /**
  12780. * This method is like `_.indexOf` except that it iterates over elements of
  12781. * `array` from right to left.
  12782. *
  12783. * @static
  12784. * @memberOf _
  12785. * @since 0.1.0
  12786. * @category Array
  12787. * @param {Array} array The array to inspect.
  12788. * @param {*} value The value to search for.
  12789. * @param {number} [fromIndex=array.length-1] The index to search from.
  12790. * @returns {number} Returns the index of the matched value, else `-1`.
  12791. * @example
  12792. *
  12793. * _.lastIndexOf([1, 2, 1, 2], 2);
  12794. * // => 3
  12795. *
  12796. * // Search from the `fromIndex`.
  12797. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  12798. * // => 1
  12799. */
  12800. function lastIndexOf(array, value, fromIndex) {
  12801. var length = array == null ? 0 : array.length;
  12802. if (!length) {
  12803. return -1;
  12804. }
  12805. var index = length;
  12806. if (fromIndex !== undefined$1) {
  12807. index = toInteger(fromIndex);
  12808. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  12809. }
  12810. return value === value
  12811. ? strictLastIndexOf(array, value, index)
  12812. : baseFindIndex(array, baseIsNaN, index, true);
  12813. }
  12814. /**
  12815. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  12816. * element from the end is returned.
  12817. *
  12818. * @static
  12819. * @memberOf _
  12820. * @since 4.11.0
  12821. * @category Array
  12822. * @param {Array} array The array to query.
  12823. * @param {number} [n=0] The index of the element to return.
  12824. * @returns {*} Returns the nth element of `array`.
  12825. * @example
  12826. *
  12827. * var array = ['a', 'b', 'c', 'd'];
  12828. *
  12829. * _.nth(array, 1);
  12830. * // => 'b'
  12831. *
  12832. * _.nth(array, -2);
  12833. * // => 'c';
  12834. */
  12835. function nth(array, n) {
  12836. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined$1;
  12837. }
  12838. /**
  12839. * Removes all given values from `array` using
  12840. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12841. * for equality comparisons.
  12842. *
  12843. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  12844. * to remove elements from an array by predicate.
  12845. *
  12846. * @static
  12847. * @memberOf _
  12848. * @since 2.0.0
  12849. * @category Array
  12850. * @param {Array} array The array to modify.
  12851. * @param {...*} [values] The values to remove.
  12852. * @returns {Array} Returns `array`.
  12853. * @example
  12854. *
  12855. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  12856. *
  12857. * _.pull(array, 'a', 'c');
  12858. * console.log(array);
  12859. * // => ['b', 'b']
  12860. */
  12861. var pull = baseRest(pullAll);
  12862. /**
  12863. * This method is like `_.pull` except that it accepts an array of values to remove.
  12864. *
  12865. * **Note:** Unlike `_.difference`, this method mutates `array`.
  12866. *
  12867. * @static
  12868. * @memberOf _
  12869. * @since 4.0.0
  12870. * @category Array
  12871. * @param {Array} array The array to modify.
  12872. * @param {Array} values The values to remove.
  12873. * @returns {Array} Returns `array`.
  12874. * @example
  12875. *
  12876. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  12877. *
  12878. * _.pullAll(array, ['a', 'c']);
  12879. * console.log(array);
  12880. * // => ['b', 'b']
  12881. */
  12882. function pullAll(array, values) {
  12883. return (array && array.length && values && values.length)
  12884. ? basePullAll(array, values)
  12885. : array;
  12886. }
  12887. /**
  12888. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  12889. * invoked for each element of `array` and `values` to generate the criterion
  12890. * by which they're compared. The iteratee is invoked with one argument: (value).
  12891. *
  12892. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  12893. *
  12894. * @static
  12895. * @memberOf _
  12896. * @since 4.0.0
  12897. * @category Array
  12898. * @param {Array} array The array to modify.
  12899. * @param {Array} values The values to remove.
  12900. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12901. * @returns {Array} Returns `array`.
  12902. * @example
  12903. *
  12904. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  12905. *
  12906. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  12907. * console.log(array);
  12908. * // => [{ 'x': 2 }]
  12909. */
  12910. function pullAllBy(array, values, iteratee) {
  12911. return (array && array.length && values && values.length)
  12912. ? basePullAll(array, values, getIteratee(iteratee, 2))
  12913. : array;
  12914. }
  12915. /**
  12916. * This method is like `_.pullAll` except that it accepts `comparator` which
  12917. * is invoked to compare elements of `array` to `values`. The comparator is
  12918. * invoked with two arguments: (arrVal, othVal).
  12919. *
  12920. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  12921. *
  12922. * @static
  12923. * @memberOf _
  12924. * @since 4.6.0
  12925. * @category Array
  12926. * @param {Array} array The array to modify.
  12927. * @param {Array} values The values to remove.
  12928. * @param {Function} [comparator] The comparator invoked per element.
  12929. * @returns {Array} Returns `array`.
  12930. * @example
  12931. *
  12932. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  12933. *
  12934. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  12935. * console.log(array);
  12936. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  12937. */
  12938. function pullAllWith(array, values, comparator) {
  12939. return (array && array.length && values && values.length)
  12940. ? basePullAll(array, values, undefined$1, comparator)
  12941. : array;
  12942. }
  12943. /**
  12944. * Removes elements from `array` corresponding to `indexes` and returns an
  12945. * array of removed elements.
  12946. *
  12947. * **Note:** Unlike `_.at`, this method mutates `array`.
  12948. *
  12949. * @static
  12950. * @memberOf _
  12951. * @since 3.0.0
  12952. * @category Array
  12953. * @param {Array} array The array to modify.
  12954. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  12955. * @returns {Array} Returns the new array of removed elements.
  12956. * @example
  12957. *
  12958. * var array = ['a', 'b', 'c', 'd'];
  12959. * var pulled = _.pullAt(array, [1, 3]);
  12960. *
  12961. * console.log(array);
  12962. * // => ['a', 'c']
  12963. *
  12964. * console.log(pulled);
  12965. * // => ['b', 'd']
  12966. */
  12967. var pullAt = flatRest(function(array, indexes) {
  12968. var length = array == null ? 0 : array.length,
  12969. result = baseAt(array, indexes);
  12970. basePullAt(array, arrayMap(indexes, function(index) {
  12971. return isIndex(index, length) ? +index : index;
  12972. }).sort(compareAscending));
  12973. return result;
  12974. });
  12975. /**
  12976. * Removes all elements from `array` that `predicate` returns truthy for
  12977. * and returns an array of the removed elements. The predicate is invoked
  12978. * with three arguments: (value, index, array).
  12979. *
  12980. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  12981. * to pull elements from an array by value.
  12982. *
  12983. * @static
  12984. * @memberOf _
  12985. * @since 2.0.0
  12986. * @category Array
  12987. * @param {Array} array The array to modify.
  12988. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12989. * @returns {Array} Returns the new array of removed elements.
  12990. * @example
  12991. *
  12992. * var array = [1, 2, 3, 4];
  12993. * var evens = _.remove(array, function(n) {
  12994. * return n % 2 == 0;
  12995. * });
  12996. *
  12997. * console.log(array);
  12998. * // => [1, 3]
  12999. *
  13000. * console.log(evens);
  13001. * // => [2, 4]
  13002. */
  13003. function remove(array, predicate) {
  13004. var result = [];
  13005. if (!(array && array.length)) {
  13006. return result;
  13007. }
  13008. var index = -1,
  13009. indexes = [],
  13010. length = array.length;
  13011. predicate = getIteratee(predicate, 3);
  13012. while (++index < length) {
  13013. var value = array[index];
  13014. if (predicate(value, index, array)) {
  13015. result.push(value);
  13016. indexes.push(index);
  13017. }
  13018. }
  13019. basePullAt(array, indexes);
  13020. return result;
  13021. }
  13022. /**
  13023. * Reverses `array` so that the first element becomes the last, the second
  13024. * element becomes the second to last, and so on.
  13025. *
  13026. * **Note:** This method mutates `array` and is based on
  13027. * [`Array#reverse`](https://mdn.io/Array/reverse).
  13028. *
  13029. * @static
  13030. * @memberOf _
  13031. * @since 4.0.0
  13032. * @category Array
  13033. * @param {Array} array The array to modify.
  13034. * @returns {Array} Returns `array`.
  13035. * @example
  13036. *
  13037. * var array = [1, 2, 3];
  13038. *
  13039. * _.reverse(array);
  13040. * // => [3, 2, 1]
  13041. *
  13042. * console.log(array);
  13043. * // => [3, 2, 1]
  13044. */
  13045. function reverse(array) {
  13046. return array == null ? array : nativeReverse.call(array);
  13047. }
  13048. /**
  13049. * Creates a slice of `array` from `start` up to, but not including, `end`.
  13050. *
  13051. * **Note:** This method is used instead of
  13052. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  13053. * returned.
  13054. *
  13055. * @static
  13056. * @memberOf _
  13057. * @since 3.0.0
  13058. * @category Array
  13059. * @param {Array} array The array to slice.
  13060. * @param {number} [start=0] The start position.
  13061. * @param {number} [end=array.length] The end position.
  13062. * @returns {Array} Returns the slice of `array`.
  13063. */
  13064. function slice(array, start, end) {
  13065. var length = array == null ? 0 : array.length;
  13066. if (!length) {
  13067. return [];
  13068. }
  13069. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  13070. start = 0;
  13071. end = length;
  13072. }
  13073. else {
  13074. start = start == null ? 0 : toInteger(start);
  13075. end = end === undefined$1 ? length : toInteger(end);
  13076. }
  13077. return baseSlice(array, start, end);
  13078. }
  13079. /**
  13080. * Uses a binary search to determine the lowest index at which `value`
  13081. * should be inserted into `array` in order to maintain its sort order.
  13082. *
  13083. * @static
  13084. * @memberOf _
  13085. * @since 0.1.0
  13086. * @category Array
  13087. * @param {Array} array The sorted array to inspect.
  13088. * @param {*} value The value to evaluate.
  13089. * @returns {number} Returns the index at which `value` should be inserted
  13090. * into `array`.
  13091. * @example
  13092. *
  13093. * _.sortedIndex([30, 50], 40);
  13094. * // => 1
  13095. */
  13096. function sortedIndex(array, value) {
  13097. return baseSortedIndex(array, value);
  13098. }
  13099. /**
  13100. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  13101. * which is invoked for `value` and each element of `array` to compute their
  13102. * sort ranking. The iteratee is invoked with one argument: (value).
  13103. *
  13104. * @static
  13105. * @memberOf _
  13106. * @since 4.0.0
  13107. * @category Array
  13108. * @param {Array} array The sorted array to inspect.
  13109. * @param {*} value The value to evaluate.
  13110. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13111. * @returns {number} Returns the index at which `value` should be inserted
  13112. * into `array`.
  13113. * @example
  13114. *
  13115. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  13116. *
  13117. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  13118. * // => 0
  13119. *
  13120. * // The `_.property` iteratee shorthand.
  13121. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  13122. * // => 0
  13123. */
  13124. function sortedIndexBy(array, value, iteratee) {
  13125. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  13126. }
  13127. /**
  13128. * This method is like `_.indexOf` except that it performs a binary
  13129. * search on a sorted `array`.
  13130. *
  13131. * @static
  13132. * @memberOf _
  13133. * @since 4.0.0
  13134. * @category Array
  13135. * @param {Array} array The array to inspect.
  13136. * @param {*} value The value to search for.
  13137. * @returns {number} Returns the index of the matched value, else `-1`.
  13138. * @example
  13139. *
  13140. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  13141. * // => 1
  13142. */
  13143. function sortedIndexOf(array, value) {
  13144. var length = array == null ? 0 : array.length;
  13145. if (length) {
  13146. var index = baseSortedIndex(array, value);
  13147. if (index < length && eq(array[index], value)) {
  13148. return index;
  13149. }
  13150. }
  13151. return -1;
  13152. }
  13153. /**
  13154. * This method is like `_.sortedIndex` except that it returns the highest
  13155. * index at which `value` should be inserted into `array` in order to
  13156. * maintain its sort order.
  13157. *
  13158. * @static
  13159. * @memberOf _
  13160. * @since 3.0.0
  13161. * @category Array
  13162. * @param {Array} array The sorted array to inspect.
  13163. * @param {*} value The value to evaluate.
  13164. * @returns {number} Returns the index at which `value` should be inserted
  13165. * into `array`.
  13166. * @example
  13167. *
  13168. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  13169. * // => 4
  13170. */
  13171. function sortedLastIndex(array, value) {
  13172. return baseSortedIndex(array, value, true);
  13173. }
  13174. /**
  13175. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  13176. * which is invoked for `value` and each element of `array` to compute their
  13177. * sort ranking. The iteratee is invoked with one argument: (value).
  13178. *
  13179. * @static
  13180. * @memberOf _
  13181. * @since 4.0.0
  13182. * @category Array
  13183. * @param {Array} array The sorted array to inspect.
  13184. * @param {*} value The value to evaluate.
  13185. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13186. * @returns {number} Returns the index at which `value` should be inserted
  13187. * into `array`.
  13188. * @example
  13189. *
  13190. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  13191. *
  13192. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  13193. * // => 1
  13194. *
  13195. * // The `_.property` iteratee shorthand.
  13196. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  13197. * // => 1
  13198. */
  13199. function sortedLastIndexBy(array, value, iteratee) {
  13200. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  13201. }
  13202. /**
  13203. * This method is like `_.lastIndexOf` except that it performs a binary
  13204. * search on a sorted `array`.
  13205. *
  13206. * @static
  13207. * @memberOf _
  13208. * @since 4.0.0
  13209. * @category Array
  13210. * @param {Array} array The array to inspect.
  13211. * @param {*} value The value to search for.
  13212. * @returns {number} Returns the index of the matched value, else `-1`.
  13213. * @example
  13214. *
  13215. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  13216. * // => 3
  13217. */
  13218. function sortedLastIndexOf(array, value) {
  13219. var length = array == null ? 0 : array.length;
  13220. if (length) {
  13221. var index = baseSortedIndex(array, value, true) - 1;
  13222. if (eq(array[index], value)) {
  13223. return index;
  13224. }
  13225. }
  13226. return -1;
  13227. }
  13228. /**
  13229. * This method is like `_.uniq` except that it's designed and optimized
  13230. * for sorted arrays.
  13231. *
  13232. * @static
  13233. * @memberOf _
  13234. * @since 4.0.0
  13235. * @category Array
  13236. * @param {Array} array The array to inspect.
  13237. * @returns {Array} Returns the new duplicate free array.
  13238. * @example
  13239. *
  13240. * _.sortedUniq([1, 1, 2]);
  13241. * // => [1, 2]
  13242. */
  13243. function sortedUniq(array) {
  13244. return (array && array.length)
  13245. ? baseSortedUniq(array)
  13246. : [];
  13247. }
  13248. /**
  13249. * This method is like `_.uniqBy` except that it's designed and optimized
  13250. * for sorted arrays.
  13251. *
  13252. * @static
  13253. * @memberOf _
  13254. * @since 4.0.0
  13255. * @category Array
  13256. * @param {Array} array The array to inspect.
  13257. * @param {Function} [iteratee] The iteratee invoked per element.
  13258. * @returns {Array} Returns the new duplicate free array.
  13259. * @example
  13260. *
  13261. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  13262. * // => [1.1, 2.3]
  13263. */
  13264. function sortedUniqBy(array, iteratee) {
  13265. return (array && array.length)
  13266. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  13267. : [];
  13268. }
  13269. /**
  13270. * Gets all but the first element of `array`.
  13271. *
  13272. * @static
  13273. * @memberOf _
  13274. * @since 4.0.0
  13275. * @category Array
  13276. * @param {Array} array The array to query.
  13277. * @returns {Array} Returns the slice of `array`.
  13278. * @example
  13279. *
  13280. * _.tail([1, 2, 3]);
  13281. * // => [2, 3]
  13282. */
  13283. function tail(array) {
  13284. var length = array == null ? 0 : array.length;
  13285. return length ? baseSlice(array, 1, length) : [];
  13286. }
  13287. /**
  13288. * Creates a slice of `array` with `n` elements taken from the beginning.
  13289. *
  13290. * @static
  13291. * @memberOf _
  13292. * @since 0.1.0
  13293. * @category Array
  13294. * @param {Array} array The array to query.
  13295. * @param {number} [n=1] The number of elements to take.
  13296. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  13297. * @returns {Array} Returns the slice of `array`.
  13298. * @example
  13299. *
  13300. * _.take([1, 2, 3]);
  13301. * // => [1]
  13302. *
  13303. * _.take([1, 2, 3], 2);
  13304. * // => [1, 2]
  13305. *
  13306. * _.take([1, 2, 3], 5);
  13307. * // => [1, 2, 3]
  13308. *
  13309. * _.take([1, 2, 3], 0);
  13310. * // => []
  13311. */
  13312. function take(array, n, guard) {
  13313. if (!(array && array.length)) {
  13314. return [];
  13315. }
  13316. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  13317. return baseSlice(array, 0, n < 0 ? 0 : n);
  13318. }
  13319. /**
  13320. * Creates a slice of `array` with `n` elements taken from the end.
  13321. *
  13322. * @static
  13323. * @memberOf _
  13324. * @since 3.0.0
  13325. * @category Array
  13326. * @param {Array} array The array to query.
  13327. * @param {number} [n=1] The number of elements to take.
  13328. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  13329. * @returns {Array} Returns the slice of `array`.
  13330. * @example
  13331. *
  13332. * _.takeRight([1, 2, 3]);
  13333. * // => [3]
  13334. *
  13335. * _.takeRight([1, 2, 3], 2);
  13336. * // => [2, 3]
  13337. *
  13338. * _.takeRight([1, 2, 3], 5);
  13339. * // => [1, 2, 3]
  13340. *
  13341. * _.takeRight([1, 2, 3], 0);
  13342. * // => []
  13343. */
  13344. function takeRight(array, n, guard) {
  13345. var length = array == null ? 0 : array.length;
  13346. if (!length) {
  13347. return [];
  13348. }
  13349. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  13350. n = length - n;
  13351. return baseSlice(array, n < 0 ? 0 : n, length);
  13352. }
  13353. /**
  13354. * Creates a slice of `array` with elements taken from the end. Elements are
  13355. * taken until `predicate` returns falsey. The predicate is invoked with
  13356. * three arguments: (value, index, array).
  13357. *
  13358. * @static
  13359. * @memberOf _
  13360. * @since 3.0.0
  13361. * @category Array
  13362. * @param {Array} array The array to query.
  13363. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13364. * @returns {Array} Returns the slice of `array`.
  13365. * @example
  13366. *
  13367. * var users = [
  13368. * { 'user': 'barney', 'active': true },
  13369. * { 'user': 'fred', 'active': false },
  13370. * { 'user': 'pebbles', 'active': false }
  13371. * ];
  13372. *
  13373. * _.takeRightWhile(users, function(o) { return !o.active; });
  13374. * // => objects for ['fred', 'pebbles']
  13375. *
  13376. * // The `_.matches` iteratee shorthand.
  13377. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  13378. * // => objects for ['pebbles']
  13379. *
  13380. * // The `_.matchesProperty` iteratee shorthand.
  13381. * _.takeRightWhile(users, ['active', false]);
  13382. * // => objects for ['fred', 'pebbles']
  13383. *
  13384. * // The `_.property` iteratee shorthand.
  13385. * _.takeRightWhile(users, 'active');
  13386. * // => []
  13387. */
  13388. function takeRightWhile(array, predicate) {
  13389. return (array && array.length)
  13390. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  13391. : [];
  13392. }
  13393. /**
  13394. * Creates a slice of `array` with elements taken from the beginning. Elements
  13395. * are taken until `predicate` returns falsey. The predicate is invoked with
  13396. * three arguments: (value, index, array).
  13397. *
  13398. * @static
  13399. * @memberOf _
  13400. * @since 3.0.0
  13401. * @category Array
  13402. * @param {Array} array The array to query.
  13403. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13404. * @returns {Array} Returns the slice of `array`.
  13405. * @example
  13406. *
  13407. * var users = [
  13408. * { 'user': 'barney', 'active': false },
  13409. * { 'user': 'fred', 'active': false },
  13410. * { 'user': 'pebbles', 'active': true }
  13411. * ];
  13412. *
  13413. * _.takeWhile(users, function(o) { return !o.active; });
  13414. * // => objects for ['barney', 'fred']
  13415. *
  13416. * // The `_.matches` iteratee shorthand.
  13417. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  13418. * // => objects for ['barney']
  13419. *
  13420. * // The `_.matchesProperty` iteratee shorthand.
  13421. * _.takeWhile(users, ['active', false]);
  13422. * // => objects for ['barney', 'fred']
  13423. *
  13424. * // The `_.property` iteratee shorthand.
  13425. * _.takeWhile(users, 'active');
  13426. * // => []
  13427. */
  13428. function takeWhile(array, predicate) {
  13429. return (array && array.length)
  13430. ? baseWhile(array, getIteratee(predicate, 3))
  13431. : [];
  13432. }
  13433. /**
  13434. * Creates an array of unique values, in order, from all given arrays using
  13435. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13436. * for equality comparisons.
  13437. *
  13438. * @static
  13439. * @memberOf _
  13440. * @since 0.1.0
  13441. * @category Array
  13442. * @param {...Array} [arrays] The arrays to inspect.
  13443. * @returns {Array} Returns the new array of combined values.
  13444. * @example
  13445. *
  13446. * _.union([2], [1, 2]);
  13447. * // => [2, 1]
  13448. */
  13449. var union = baseRest(function(arrays) {
  13450. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  13451. });
  13452. /**
  13453. * This method is like `_.union` except that it accepts `iteratee` which is
  13454. * invoked for each element of each `arrays` to generate the criterion by
  13455. * which uniqueness is computed. Result values are chosen from the first
  13456. * array in which the value occurs. The iteratee is invoked with one argument:
  13457. * (value).
  13458. *
  13459. * @static
  13460. * @memberOf _
  13461. * @since 4.0.0
  13462. * @category Array
  13463. * @param {...Array} [arrays] The arrays to inspect.
  13464. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13465. * @returns {Array} Returns the new array of combined values.
  13466. * @example
  13467. *
  13468. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  13469. * // => [2.1, 1.2]
  13470. *
  13471. * // The `_.property` iteratee shorthand.
  13472. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  13473. * // => [{ 'x': 1 }, { 'x': 2 }]
  13474. */
  13475. var unionBy = baseRest(function(arrays) {
  13476. var iteratee = last(arrays);
  13477. if (isArrayLikeObject(iteratee)) {
  13478. iteratee = undefined$1;
  13479. }
  13480. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  13481. });
  13482. /**
  13483. * This method is like `_.union` except that it accepts `comparator` which
  13484. * is invoked to compare elements of `arrays`. Result values are chosen from
  13485. * the first array in which the value occurs. The comparator is invoked
  13486. * with two arguments: (arrVal, othVal).
  13487. *
  13488. * @static
  13489. * @memberOf _
  13490. * @since 4.0.0
  13491. * @category Array
  13492. * @param {...Array} [arrays] The arrays to inspect.
  13493. * @param {Function} [comparator] The comparator invoked per element.
  13494. * @returns {Array} Returns the new array of combined values.
  13495. * @example
  13496. *
  13497. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  13498. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  13499. *
  13500. * _.unionWith(objects, others, _.isEqual);
  13501. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  13502. */
  13503. var unionWith = baseRest(function(arrays) {
  13504. var comparator = last(arrays);
  13505. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  13506. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined$1, comparator);
  13507. });
  13508. /**
  13509. * Creates a duplicate-free version of an array, using
  13510. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13511. * for equality comparisons, in which only the first occurrence of each element
  13512. * is kept. The order of result values is determined by the order they occur
  13513. * in the array.
  13514. *
  13515. * @static
  13516. * @memberOf _
  13517. * @since 0.1.0
  13518. * @category Array
  13519. * @param {Array} array The array to inspect.
  13520. * @returns {Array} Returns the new duplicate free array.
  13521. * @example
  13522. *
  13523. * _.uniq([2, 1, 2]);
  13524. * // => [2, 1]
  13525. */
  13526. function uniq(array) {
  13527. return (array && array.length) ? baseUniq(array) : [];
  13528. }
  13529. /**
  13530. * This method is like `_.uniq` except that it accepts `iteratee` which is
  13531. * invoked for each element in `array` to generate the criterion by which
  13532. * uniqueness is computed. The order of result values is determined by the
  13533. * order they occur in the array. The iteratee is invoked with one argument:
  13534. * (value).
  13535. *
  13536. * @static
  13537. * @memberOf _
  13538. * @since 4.0.0
  13539. * @category Array
  13540. * @param {Array} array The array to inspect.
  13541. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13542. * @returns {Array} Returns the new duplicate free array.
  13543. * @example
  13544. *
  13545. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  13546. * // => [2.1, 1.2]
  13547. *
  13548. * // The `_.property` iteratee shorthand.
  13549. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  13550. * // => [{ 'x': 1 }, { 'x': 2 }]
  13551. */
  13552. function uniqBy(array, iteratee) {
  13553. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  13554. }
  13555. /**
  13556. * This method is like `_.uniq` except that it accepts `comparator` which
  13557. * is invoked to compare elements of `array`. The order of result values is
  13558. * determined by the order they occur in the array.The comparator is invoked
  13559. * with two arguments: (arrVal, othVal).
  13560. *
  13561. * @static
  13562. * @memberOf _
  13563. * @since 4.0.0
  13564. * @category Array
  13565. * @param {Array} array The array to inspect.
  13566. * @param {Function} [comparator] The comparator invoked per element.
  13567. * @returns {Array} Returns the new duplicate free array.
  13568. * @example
  13569. *
  13570. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  13571. *
  13572. * _.uniqWith(objects, _.isEqual);
  13573. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  13574. */
  13575. function uniqWith(array, comparator) {
  13576. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  13577. return (array && array.length) ? baseUniq(array, undefined$1, comparator) : [];
  13578. }
  13579. /**
  13580. * This method is like `_.zip` except that it accepts an array of grouped
  13581. * elements and creates an array regrouping the elements to their pre-zip
  13582. * configuration.
  13583. *
  13584. * @static
  13585. * @memberOf _
  13586. * @since 1.2.0
  13587. * @category Array
  13588. * @param {Array} array The array of grouped elements to process.
  13589. * @returns {Array} Returns the new array of regrouped elements.
  13590. * @example
  13591. *
  13592. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  13593. * // => [['a', 1, true], ['b', 2, false]]
  13594. *
  13595. * _.unzip(zipped);
  13596. * // => [['a', 'b'], [1, 2], [true, false]]
  13597. */
  13598. function unzip(array) {
  13599. if (!(array && array.length)) {
  13600. return [];
  13601. }
  13602. var length = 0;
  13603. array = arrayFilter(array, function(group) {
  13604. if (isArrayLikeObject(group)) {
  13605. length = nativeMax(group.length, length);
  13606. return true;
  13607. }
  13608. });
  13609. return baseTimes(length, function(index) {
  13610. return arrayMap(array, baseProperty(index));
  13611. });
  13612. }
  13613. /**
  13614. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  13615. * how regrouped values should be combined. The iteratee is invoked with the
  13616. * elements of each group: (...group).
  13617. *
  13618. * @static
  13619. * @memberOf _
  13620. * @since 3.8.0
  13621. * @category Array
  13622. * @param {Array} array The array of grouped elements to process.
  13623. * @param {Function} [iteratee=_.identity] The function to combine
  13624. * regrouped values.
  13625. * @returns {Array} Returns the new array of regrouped elements.
  13626. * @example
  13627. *
  13628. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  13629. * // => [[1, 10, 100], [2, 20, 200]]
  13630. *
  13631. * _.unzipWith(zipped, _.add);
  13632. * // => [3, 30, 300]
  13633. */
  13634. function unzipWith(array, iteratee) {
  13635. if (!(array && array.length)) {
  13636. return [];
  13637. }
  13638. var result = unzip(array);
  13639. if (iteratee == null) {
  13640. return result;
  13641. }
  13642. return arrayMap(result, function(group) {
  13643. return apply(iteratee, undefined$1, group);
  13644. });
  13645. }
  13646. /**
  13647. * Creates an array excluding all given values using
  13648. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13649. * for equality comparisons.
  13650. *
  13651. * **Note:** Unlike `_.pull`, this method returns a new array.
  13652. *
  13653. * @static
  13654. * @memberOf _
  13655. * @since 0.1.0
  13656. * @category Array
  13657. * @param {Array} array The array to inspect.
  13658. * @param {...*} [values] The values to exclude.
  13659. * @returns {Array} Returns the new array of filtered values.
  13660. * @see _.difference, _.xor
  13661. * @example
  13662. *
  13663. * _.without([2, 1, 2, 3], 1, 2);
  13664. * // => [3]
  13665. */
  13666. var without = baseRest(function(array, values) {
  13667. return isArrayLikeObject(array)
  13668. ? baseDifference(array, values)
  13669. : [];
  13670. });
  13671. /**
  13672. * Creates an array of unique values that is the
  13673. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  13674. * of the given arrays. The order of result values is determined by the order
  13675. * they occur in the arrays.
  13676. *
  13677. * @static
  13678. * @memberOf _
  13679. * @since 2.4.0
  13680. * @category Array
  13681. * @param {...Array} [arrays] The arrays to inspect.
  13682. * @returns {Array} Returns the new array of filtered values.
  13683. * @see _.difference, _.without
  13684. * @example
  13685. *
  13686. * _.xor([2, 1], [2, 3]);
  13687. * // => [1, 3]
  13688. */
  13689. var xor = baseRest(function(arrays) {
  13690. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  13691. });
  13692. /**
  13693. * This method is like `_.xor` except that it accepts `iteratee` which is
  13694. * invoked for each element of each `arrays` to generate the criterion by
  13695. * which by which they're compared. The order of result values is determined
  13696. * by the order they occur in the arrays. The iteratee is invoked with one
  13697. * argument: (value).
  13698. *
  13699. * @static
  13700. * @memberOf _
  13701. * @since 4.0.0
  13702. * @category Array
  13703. * @param {...Array} [arrays] The arrays to inspect.
  13704. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13705. * @returns {Array} Returns the new array of filtered values.
  13706. * @example
  13707. *
  13708. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  13709. * // => [1.2, 3.4]
  13710. *
  13711. * // The `_.property` iteratee shorthand.
  13712. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  13713. * // => [{ 'x': 2 }]
  13714. */
  13715. var xorBy = baseRest(function(arrays) {
  13716. var iteratee = last(arrays);
  13717. if (isArrayLikeObject(iteratee)) {
  13718. iteratee = undefined$1;
  13719. }
  13720. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  13721. });
  13722. /**
  13723. * This method is like `_.xor` except that it accepts `comparator` which is
  13724. * invoked to compare elements of `arrays`. The order of result values is
  13725. * determined by the order they occur in the arrays. The comparator is invoked
  13726. * with two arguments: (arrVal, othVal).
  13727. *
  13728. * @static
  13729. * @memberOf _
  13730. * @since 4.0.0
  13731. * @category Array
  13732. * @param {...Array} [arrays] The arrays to inspect.
  13733. * @param {Function} [comparator] The comparator invoked per element.
  13734. * @returns {Array} Returns the new array of filtered values.
  13735. * @example
  13736. *
  13737. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  13738. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  13739. *
  13740. * _.xorWith(objects, others, _.isEqual);
  13741. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  13742. */
  13743. var xorWith = baseRest(function(arrays) {
  13744. var comparator = last(arrays);
  13745. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  13746. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined$1, comparator);
  13747. });
  13748. /**
  13749. * Creates an array of grouped elements, the first of which contains the
  13750. * first elements of the given arrays, the second of which contains the
  13751. * second elements of the given arrays, and so on.
  13752. *
  13753. * @static
  13754. * @memberOf _
  13755. * @since 0.1.0
  13756. * @category Array
  13757. * @param {...Array} [arrays] The arrays to process.
  13758. * @returns {Array} Returns the new array of grouped elements.
  13759. * @example
  13760. *
  13761. * _.zip(['a', 'b'], [1, 2], [true, false]);
  13762. * // => [['a', 1, true], ['b', 2, false]]
  13763. */
  13764. var zip = baseRest(unzip);
  13765. /**
  13766. * This method is like `_.fromPairs` except that it accepts two arrays,
  13767. * one of property identifiers and one of corresponding values.
  13768. *
  13769. * @static
  13770. * @memberOf _
  13771. * @since 0.4.0
  13772. * @category Array
  13773. * @param {Array} [props=[]] The property identifiers.
  13774. * @param {Array} [values=[]] The property values.
  13775. * @returns {Object} Returns the new object.
  13776. * @example
  13777. *
  13778. * _.zipObject(['a', 'b'], [1, 2]);
  13779. * // => { 'a': 1, 'b': 2 }
  13780. */
  13781. function zipObject(props, values) {
  13782. return baseZipObject(props || [], values || [], assignValue);
  13783. }
  13784. /**
  13785. * This method is like `_.zipObject` except that it supports property paths.
  13786. *
  13787. * @static
  13788. * @memberOf _
  13789. * @since 4.1.0
  13790. * @category Array
  13791. * @param {Array} [props=[]] The property identifiers.
  13792. * @param {Array} [values=[]] The property values.
  13793. * @returns {Object} Returns the new object.
  13794. * @example
  13795. *
  13796. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  13797. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  13798. */
  13799. function zipObjectDeep(props, values) {
  13800. return baseZipObject(props || [], values || [], baseSet);
  13801. }
  13802. /**
  13803. * This method is like `_.zip` except that it accepts `iteratee` to specify
  13804. * how grouped values should be combined. The iteratee is invoked with the
  13805. * elements of each group: (...group).
  13806. *
  13807. * @static
  13808. * @memberOf _
  13809. * @since 3.8.0
  13810. * @category Array
  13811. * @param {...Array} [arrays] The arrays to process.
  13812. * @param {Function} [iteratee=_.identity] The function to combine
  13813. * grouped values.
  13814. * @returns {Array} Returns the new array of grouped elements.
  13815. * @example
  13816. *
  13817. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  13818. * return a + b + c;
  13819. * });
  13820. * // => [111, 222]
  13821. */
  13822. var zipWith = baseRest(function(arrays) {
  13823. var length = arrays.length,
  13824. iteratee = length > 1 ? arrays[length - 1] : undefined$1;
  13825. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined$1;
  13826. return unzipWith(arrays, iteratee);
  13827. });
  13828. /*------------------------------------------------------------------------*/
  13829. /**
  13830. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  13831. * chain sequences enabled. The result of such sequences must be unwrapped
  13832. * with `_#value`.
  13833. *
  13834. * @static
  13835. * @memberOf _
  13836. * @since 1.3.0
  13837. * @category Seq
  13838. * @param {*} value The value to wrap.
  13839. * @returns {Object} Returns the new `lodash` wrapper instance.
  13840. * @example
  13841. *
  13842. * var users = [
  13843. * { 'user': 'barney', 'age': 36 },
  13844. * { 'user': 'fred', 'age': 40 },
  13845. * { 'user': 'pebbles', 'age': 1 }
  13846. * ];
  13847. *
  13848. * var youngest = _
  13849. * .chain(users)
  13850. * .sortBy('age')
  13851. * .map(function(o) {
  13852. * return o.user + ' is ' + o.age;
  13853. * })
  13854. * .head()
  13855. * .value();
  13856. * // => 'pebbles is 1'
  13857. */
  13858. function chain(value) {
  13859. var result = lodash(value);
  13860. result.__chain__ = true;
  13861. return result;
  13862. }
  13863. /**
  13864. * This method invokes `interceptor` and returns `value`. The interceptor
  13865. * is invoked with one argument; (value). The purpose of this method is to
  13866. * "tap into" a method chain sequence in order to modify intermediate results.
  13867. *
  13868. * @static
  13869. * @memberOf _
  13870. * @since 0.1.0
  13871. * @category Seq
  13872. * @param {*} value The value to provide to `interceptor`.
  13873. * @param {Function} interceptor The function to invoke.
  13874. * @returns {*} Returns `value`.
  13875. * @example
  13876. *
  13877. * _([1, 2, 3])
  13878. * .tap(function(array) {
  13879. * // Mutate input array.
  13880. * array.pop();
  13881. * })
  13882. * .reverse()
  13883. * .value();
  13884. * // => [2, 1]
  13885. */
  13886. function tap(value, interceptor) {
  13887. interceptor(value);
  13888. return value;
  13889. }
  13890. /**
  13891. * This method is like `_.tap` except that it returns the result of `interceptor`.
  13892. * The purpose of this method is to "pass thru" values replacing intermediate
  13893. * results in a method chain sequence.
  13894. *
  13895. * @static
  13896. * @memberOf _
  13897. * @since 3.0.0
  13898. * @category Seq
  13899. * @param {*} value The value to provide to `interceptor`.
  13900. * @param {Function} interceptor The function to invoke.
  13901. * @returns {*} Returns the result of `interceptor`.
  13902. * @example
  13903. *
  13904. * _(' abc ')
  13905. * .chain()
  13906. * .trim()
  13907. * .thru(function(value) {
  13908. * return [value];
  13909. * })
  13910. * .value();
  13911. * // => ['abc']
  13912. */
  13913. function thru(value, interceptor) {
  13914. return interceptor(value);
  13915. }
  13916. /**
  13917. * This method is the wrapper version of `_.at`.
  13918. *
  13919. * @name at
  13920. * @memberOf _
  13921. * @since 1.0.0
  13922. * @category Seq
  13923. * @param {...(string|string[])} [paths] The property paths to pick.
  13924. * @returns {Object} Returns the new `lodash` wrapper instance.
  13925. * @example
  13926. *
  13927. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  13928. *
  13929. * _(object).at(['a[0].b.c', 'a[1]']).value();
  13930. * // => [3, 4]
  13931. */
  13932. var wrapperAt = flatRest(function(paths) {
  13933. var length = paths.length,
  13934. start = length ? paths[0] : 0,
  13935. value = this.__wrapped__,
  13936. interceptor = function(object) { return baseAt(object, paths); };
  13937. if (length > 1 || this.__actions__.length ||
  13938. !(value instanceof LazyWrapper) || !isIndex(start)) {
  13939. return this.thru(interceptor);
  13940. }
  13941. value = value.slice(start, +start + (length ? 1 : 0));
  13942. value.__actions__.push({
  13943. 'func': thru,
  13944. 'args': [interceptor],
  13945. 'thisArg': undefined$1
  13946. });
  13947. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  13948. if (length && !array.length) {
  13949. array.push(undefined$1);
  13950. }
  13951. return array;
  13952. });
  13953. });
  13954. /**
  13955. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  13956. *
  13957. * @name chain
  13958. * @memberOf _
  13959. * @since 0.1.0
  13960. * @category Seq
  13961. * @returns {Object} Returns the new `lodash` wrapper instance.
  13962. * @example
  13963. *
  13964. * var users = [
  13965. * { 'user': 'barney', 'age': 36 },
  13966. * { 'user': 'fred', 'age': 40 }
  13967. * ];
  13968. *
  13969. * // A sequence without explicit chaining.
  13970. * _(users).head();
  13971. * // => { 'user': 'barney', 'age': 36 }
  13972. *
  13973. * // A sequence with explicit chaining.
  13974. * _(users)
  13975. * .chain()
  13976. * .head()
  13977. * .pick('user')
  13978. * .value();
  13979. * // => { 'user': 'barney' }
  13980. */
  13981. function wrapperChain() {
  13982. return chain(this);
  13983. }
  13984. /**
  13985. * Executes the chain sequence and returns the wrapped result.
  13986. *
  13987. * @name commit
  13988. * @memberOf _
  13989. * @since 3.2.0
  13990. * @category Seq
  13991. * @returns {Object} Returns the new `lodash` wrapper instance.
  13992. * @example
  13993. *
  13994. * var array = [1, 2];
  13995. * var wrapped = _(array).push(3);
  13996. *
  13997. * console.log(array);
  13998. * // => [1, 2]
  13999. *
  14000. * wrapped = wrapped.commit();
  14001. * console.log(array);
  14002. * // => [1, 2, 3]
  14003. *
  14004. * wrapped.last();
  14005. * // => 3
  14006. *
  14007. * console.log(array);
  14008. * // => [1, 2, 3]
  14009. */
  14010. function wrapperCommit() {
  14011. return new LodashWrapper(this.value(), this.__chain__);
  14012. }
  14013. /**
  14014. * Gets the next value on a wrapped object following the
  14015. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  14016. *
  14017. * @name next
  14018. * @memberOf _
  14019. * @since 4.0.0
  14020. * @category Seq
  14021. * @returns {Object} Returns the next iterator value.
  14022. * @example
  14023. *
  14024. * var wrapped = _([1, 2]);
  14025. *
  14026. * wrapped.next();
  14027. * // => { 'done': false, 'value': 1 }
  14028. *
  14029. * wrapped.next();
  14030. * // => { 'done': false, 'value': 2 }
  14031. *
  14032. * wrapped.next();
  14033. * // => { 'done': true, 'value': undefined }
  14034. */
  14035. function wrapperNext() {
  14036. if (this.__values__ === undefined$1) {
  14037. this.__values__ = toArray(this.value());
  14038. }
  14039. var done = this.__index__ >= this.__values__.length,
  14040. value = done ? undefined$1 : this.__values__[this.__index__++];
  14041. return { 'done': done, 'value': value };
  14042. }
  14043. /**
  14044. * Enables the wrapper to be iterable.
  14045. *
  14046. * @name Symbol.iterator
  14047. * @memberOf _
  14048. * @since 4.0.0
  14049. * @category Seq
  14050. * @returns {Object} Returns the wrapper object.
  14051. * @example
  14052. *
  14053. * var wrapped = _([1, 2]);
  14054. *
  14055. * wrapped[Symbol.iterator]() === wrapped;
  14056. * // => true
  14057. *
  14058. * Array.from(wrapped);
  14059. * // => [1, 2]
  14060. */
  14061. function wrapperToIterator() {
  14062. return this;
  14063. }
  14064. /**
  14065. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  14066. *
  14067. * @name plant
  14068. * @memberOf _
  14069. * @since 3.2.0
  14070. * @category Seq
  14071. * @param {*} value The value to plant.
  14072. * @returns {Object} Returns the new `lodash` wrapper instance.
  14073. * @example
  14074. *
  14075. * function square(n) {
  14076. * return n * n;
  14077. * }
  14078. *
  14079. * var wrapped = _([1, 2]).map(square);
  14080. * var other = wrapped.plant([3, 4]);
  14081. *
  14082. * other.value();
  14083. * // => [9, 16]
  14084. *
  14085. * wrapped.value();
  14086. * // => [1, 4]
  14087. */
  14088. function wrapperPlant(value) {
  14089. var result,
  14090. parent = this;
  14091. while (parent instanceof baseLodash) {
  14092. var clone = wrapperClone(parent);
  14093. clone.__index__ = 0;
  14094. clone.__values__ = undefined$1;
  14095. if (result) {
  14096. previous.__wrapped__ = clone;
  14097. } else {
  14098. result = clone;
  14099. }
  14100. var previous = clone;
  14101. parent = parent.__wrapped__;
  14102. }
  14103. previous.__wrapped__ = value;
  14104. return result;
  14105. }
  14106. /**
  14107. * This method is the wrapper version of `_.reverse`.
  14108. *
  14109. * **Note:** This method mutates the wrapped array.
  14110. *
  14111. * @name reverse
  14112. * @memberOf _
  14113. * @since 0.1.0
  14114. * @category Seq
  14115. * @returns {Object} Returns the new `lodash` wrapper instance.
  14116. * @example
  14117. *
  14118. * var array = [1, 2, 3];
  14119. *
  14120. * _(array).reverse().value()
  14121. * // => [3, 2, 1]
  14122. *
  14123. * console.log(array);
  14124. * // => [3, 2, 1]
  14125. */
  14126. function wrapperReverse() {
  14127. var value = this.__wrapped__;
  14128. if (value instanceof LazyWrapper) {
  14129. var wrapped = value;
  14130. if (this.__actions__.length) {
  14131. wrapped = new LazyWrapper(this);
  14132. }
  14133. wrapped = wrapped.reverse();
  14134. wrapped.__actions__.push({
  14135. 'func': thru,
  14136. 'args': [reverse],
  14137. 'thisArg': undefined$1
  14138. });
  14139. return new LodashWrapper(wrapped, this.__chain__);
  14140. }
  14141. return this.thru(reverse);
  14142. }
  14143. /**
  14144. * Executes the chain sequence to resolve the unwrapped value.
  14145. *
  14146. * @name value
  14147. * @memberOf _
  14148. * @since 0.1.0
  14149. * @alias toJSON, valueOf
  14150. * @category Seq
  14151. * @returns {*} Returns the resolved unwrapped value.
  14152. * @example
  14153. *
  14154. * _([1, 2, 3]).value();
  14155. * // => [1, 2, 3]
  14156. */
  14157. function wrapperValue() {
  14158. return baseWrapperValue(this.__wrapped__, this.__actions__);
  14159. }
  14160. /*------------------------------------------------------------------------*/
  14161. /**
  14162. * Creates an object composed of keys generated from the results of running
  14163. * each element of `collection` thru `iteratee`. The corresponding value of
  14164. * each key is the number of times the key was returned by `iteratee`. The
  14165. * iteratee is invoked with one argument: (value).
  14166. *
  14167. * @static
  14168. * @memberOf _
  14169. * @since 0.5.0
  14170. * @category Collection
  14171. * @param {Array|Object} collection The collection to iterate over.
  14172. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  14173. * @returns {Object} Returns the composed aggregate object.
  14174. * @example
  14175. *
  14176. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  14177. * // => { '4': 1, '6': 2 }
  14178. *
  14179. * // The `_.property` iteratee shorthand.
  14180. * _.countBy(['one', 'two', 'three'], 'length');
  14181. * // => { '3': 2, '5': 1 }
  14182. */
  14183. var countBy = createAggregator(function(result, value, key) {
  14184. if (hasOwnProperty.call(result, key)) {
  14185. ++result[key];
  14186. } else {
  14187. baseAssignValue(result, key, 1);
  14188. }
  14189. });
  14190. /**
  14191. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  14192. * Iteration is stopped once `predicate` returns falsey. The predicate is
  14193. * invoked with three arguments: (value, index|key, collection).
  14194. *
  14195. * **Note:** This method returns `true` for
  14196. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  14197. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  14198. * elements of empty collections.
  14199. *
  14200. * @static
  14201. * @memberOf _
  14202. * @since 0.1.0
  14203. * @category Collection
  14204. * @param {Array|Object} collection The collection to iterate over.
  14205. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14206. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14207. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  14208. * else `false`.
  14209. * @example
  14210. *
  14211. * _.every([true, 1, null, 'yes'], Boolean);
  14212. * // => false
  14213. *
  14214. * var users = [
  14215. * { 'user': 'barney', 'age': 36, 'active': false },
  14216. * { 'user': 'fred', 'age': 40, 'active': false }
  14217. * ];
  14218. *
  14219. * // The `_.matches` iteratee shorthand.
  14220. * _.every(users, { 'user': 'barney', 'active': false });
  14221. * // => false
  14222. *
  14223. * // The `_.matchesProperty` iteratee shorthand.
  14224. * _.every(users, ['active', false]);
  14225. * // => true
  14226. *
  14227. * // The `_.property` iteratee shorthand.
  14228. * _.every(users, 'active');
  14229. * // => false
  14230. */
  14231. function every(collection, predicate, guard) {
  14232. var func = isArray(collection) ? arrayEvery : baseEvery;
  14233. if (guard && isIterateeCall(collection, predicate, guard)) {
  14234. predicate = undefined$1;
  14235. }
  14236. return func(collection, getIteratee(predicate, 3));
  14237. }
  14238. /**
  14239. * Iterates over elements of `collection`, returning an array of all elements
  14240. * `predicate` returns truthy for. The predicate is invoked with three
  14241. * arguments: (value, index|key, collection).
  14242. *
  14243. * **Note:** Unlike `_.remove`, this method returns a new array.
  14244. *
  14245. * @static
  14246. * @memberOf _
  14247. * @since 0.1.0
  14248. * @category Collection
  14249. * @param {Array|Object} collection The collection to iterate over.
  14250. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14251. * @returns {Array} Returns the new filtered array.
  14252. * @see _.reject
  14253. * @example
  14254. *
  14255. * var users = [
  14256. * { 'user': 'barney', 'age': 36, 'active': true },
  14257. * { 'user': 'fred', 'age': 40, 'active': false }
  14258. * ];
  14259. *
  14260. * _.filter(users, function(o) { return !o.active; });
  14261. * // => objects for ['fred']
  14262. *
  14263. * // The `_.matches` iteratee shorthand.
  14264. * _.filter(users, { 'age': 36, 'active': true });
  14265. * // => objects for ['barney']
  14266. *
  14267. * // The `_.matchesProperty` iteratee shorthand.
  14268. * _.filter(users, ['active', false]);
  14269. * // => objects for ['fred']
  14270. *
  14271. * // The `_.property` iteratee shorthand.
  14272. * _.filter(users, 'active');
  14273. * // => objects for ['barney']
  14274. *
  14275. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  14276. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  14277. * // => objects for ['fred', 'barney']
  14278. */
  14279. function filter(collection, predicate) {
  14280. var func = isArray(collection) ? arrayFilter : baseFilter;
  14281. return func(collection, getIteratee(predicate, 3));
  14282. }
  14283. /**
  14284. * Iterates over elements of `collection`, returning the first element
  14285. * `predicate` returns truthy for. The predicate is invoked with three
  14286. * arguments: (value, index|key, collection).
  14287. *
  14288. * @static
  14289. * @memberOf _
  14290. * @since 0.1.0
  14291. * @category Collection
  14292. * @param {Array|Object} collection The collection to inspect.
  14293. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14294. * @param {number} [fromIndex=0] The index to search from.
  14295. * @returns {*} Returns the matched element, else `undefined`.
  14296. * @example
  14297. *
  14298. * var users = [
  14299. * { 'user': 'barney', 'age': 36, 'active': true },
  14300. * { 'user': 'fred', 'age': 40, 'active': false },
  14301. * { 'user': 'pebbles', 'age': 1, 'active': true }
  14302. * ];
  14303. *
  14304. * _.find(users, function(o) { return o.age < 40; });
  14305. * // => object for 'barney'
  14306. *
  14307. * // The `_.matches` iteratee shorthand.
  14308. * _.find(users, { 'age': 1, 'active': true });
  14309. * // => object for 'pebbles'
  14310. *
  14311. * // The `_.matchesProperty` iteratee shorthand.
  14312. * _.find(users, ['active', false]);
  14313. * // => object for 'fred'
  14314. *
  14315. * // The `_.property` iteratee shorthand.
  14316. * _.find(users, 'active');
  14317. * // => object for 'barney'
  14318. */
  14319. var find = createFind(findIndex);
  14320. /**
  14321. * This method is like `_.find` except that it iterates over elements of
  14322. * `collection` from right to left.
  14323. *
  14324. * @static
  14325. * @memberOf _
  14326. * @since 2.0.0
  14327. * @category Collection
  14328. * @param {Array|Object} collection The collection to inspect.
  14329. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14330. * @param {number} [fromIndex=collection.length-1] The index to search from.
  14331. * @returns {*} Returns the matched element, else `undefined`.
  14332. * @example
  14333. *
  14334. * _.findLast([1, 2, 3, 4], function(n) {
  14335. * return n % 2 == 1;
  14336. * });
  14337. * // => 3
  14338. */
  14339. var findLast = createFind(findLastIndex);
  14340. /**
  14341. * Creates a flattened array of values by running each element in `collection`
  14342. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  14343. * with three arguments: (value, index|key, collection).
  14344. *
  14345. * @static
  14346. * @memberOf _
  14347. * @since 4.0.0
  14348. * @category Collection
  14349. * @param {Array|Object} collection The collection to iterate over.
  14350. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14351. * @returns {Array} Returns the new flattened array.
  14352. * @example
  14353. *
  14354. * function duplicate(n) {
  14355. * return [n, n];
  14356. * }
  14357. *
  14358. * _.flatMap([1, 2], duplicate);
  14359. * // => [1, 1, 2, 2]
  14360. */
  14361. function flatMap(collection, iteratee) {
  14362. return baseFlatten(map(collection, iteratee), 1);
  14363. }
  14364. /**
  14365. * This method is like `_.flatMap` except that it recursively flattens the
  14366. * mapped results.
  14367. *
  14368. * @static
  14369. * @memberOf _
  14370. * @since 4.7.0
  14371. * @category Collection
  14372. * @param {Array|Object} collection The collection to iterate over.
  14373. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14374. * @returns {Array} Returns the new flattened array.
  14375. * @example
  14376. *
  14377. * function duplicate(n) {
  14378. * return [[[n, n]]];
  14379. * }
  14380. *
  14381. * _.flatMapDeep([1, 2], duplicate);
  14382. * // => [1, 1, 2, 2]
  14383. */
  14384. function flatMapDeep(collection, iteratee) {
  14385. return baseFlatten(map(collection, iteratee), INFINITY);
  14386. }
  14387. /**
  14388. * This method is like `_.flatMap` except that it recursively flattens the
  14389. * mapped results up to `depth` times.
  14390. *
  14391. * @static
  14392. * @memberOf _
  14393. * @since 4.7.0
  14394. * @category Collection
  14395. * @param {Array|Object} collection The collection to iterate over.
  14396. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14397. * @param {number} [depth=1] The maximum recursion depth.
  14398. * @returns {Array} Returns the new flattened array.
  14399. * @example
  14400. *
  14401. * function duplicate(n) {
  14402. * return [[[n, n]]];
  14403. * }
  14404. *
  14405. * _.flatMapDepth([1, 2], duplicate, 2);
  14406. * // => [[1, 1], [2, 2]]
  14407. */
  14408. function flatMapDepth(collection, iteratee, depth) {
  14409. depth = depth === undefined$1 ? 1 : toInteger(depth);
  14410. return baseFlatten(map(collection, iteratee), depth);
  14411. }
  14412. /**
  14413. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  14414. * The iteratee is invoked with three arguments: (value, index|key, collection).
  14415. * Iteratee functions may exit iteration early by explicitly returning `false`.
  14416. *
  14417. * **Note:** As with other "Collections" methods, objects with a "length"
  14418. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  14419. * or `_.forOwn` for object iteration.
  14420. *
  14421. * @static
  14422. * @memberOf _
  14423. * @since 0.1.0
  14424. * @alias each
  14425. * @category Collection
  14426. * @param {Array|Object} collection The collection to iterate over.
  14427. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14428. * @returns {Array|Object} Returns `collection`.
  14429. * @see _.forEachRight
  14430. * @example
  14431. *
  14432. * _.forEach([1, 2], function(value) {
  14433. * console.log(value);
  14434. * });
  14435. * // => Logs `1` then `2`.
  14436. *
  14437. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  14438. * console.log(key);
  14439. * });
  14440. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  14441. */
  14442. function forEach(collection, iteratee) {
  14443. var func = isArray(collection) ? arrayEach : baseEach;
  14444. return func(collection, getIteratee(iteratee, 3));
  14445. }
  14446. /**
  14447. * This method is like `_.forEach` except that it iterates over elements of
  14448. * `collection` from right to left.
  14449. *
  14450. * @static
  14451. * @memberOf _
  14452. * @since 2.0.0
  14453. * @alias eachRight
  14454. * @category Collection
  14455. * @param {Array|Object} collection The collection to iterate over.
  14456. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14457. * @returns {Array|Object} Returns `collection`.
  14458. * @see _.forEach
  14459. * @example
  14460. *
  14461. * _.forEachRight([1, 2], function(value) {
  14462. * console.log(value);
  14463. * });
  14464. * // => Logs `2` then `1`.
  14465. */
  14466. function forEachRight(collection, iteratee) {
  14467. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  14468. return func(collection, getIteratee(iteratee, 3));
  14469. }
  14470. /**
  14471. * Creates an object composed of keys generated from the results of running
  14472. * each element of `collection` thru `iteratee`. The order of grouped values
  14473. * is determined by the order they occur in `collection`. The corresponding
  14474. * value of each key is an array of elements responsible for generating the
  14475. * key. The iteratee is invoked with one argument: (value).
  14476. *
  14477. * @static
  14478. * @memberOf _
  14479. * @since 0.1.0
  14480. * @category Collection
  14481. * @param {Array|Object} collection The collection to iterate over.
  14482. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  14483. * @returns {Object} Returns the composed aggregate object.
  14484. * @example
  14485. *
  14486. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  14487. * // => { '4': [4.2], '6': [6.1, 6.3] }
  14488. *
  14489. * // The `_.property` iteratee shorthand.
  14490. * _.groupBy(['one', 'two', 'three'], 'length');
  14491. * // => { '3': ['one', 'two'], '5': ['three'] }
  14492. */
  14493. var groupBy = createAggregator(function(result, value, key) {
  14494. if (hasOwnProperty.call(result, key)) {
  14495. result[key].push(value);
  14496. } else {
  14497. baseAssignValue(result, key, [value]);
  14498. }
  14499. });
  14500. /**
  14501. * Checks if `value` is in `collection`. If `collection` is a string, it's
  14502. * checked for a substring of `value`, otherwise
  14503. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  14504. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  14505. * the offset from the end of `collection`.
  14506. *
  14507. * @static
  14508. * @memberOf _
  14509. * @since 0.1.0
  14510. * @category Collection
  14511. * @param {Array|Object|string} collection The collection to inspect.
  14512. * @param {*} value The value to search for.
  14513. * @param {number} [fromIndex=0] The index to search from.
  14514. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  14515. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  14516. * @example
  14517. *
  14518. * _.includes([1, 2, 3], 1);
  14519. * // => true
  14520. *
  14521. * _.includes([1, 2, 3], 1, 2);
  14522. * // => false
  14523. *
  14524. * _.includes({ 'a': 1, 'b': 2 }, 1);
  14525. * // => true
  14526. *
  14527. * _.includes('abcd', 'bc');
  14528. * // => true
  14529. */
  14530. function includes(collection, value, fromIndex, guard) {
  14531. collection = isArrayLike(collection) ? collection : values(collection);
  14532. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  14533. var length = collection.length;
  14534. if (fromIndex < 0) {
  14535. fromIndex = nativeMax(length + fromIndex, 0);
  14536. }
  14537. return isString(collection)
  14538. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  14539. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  14540. }
  14541. /**
  14542. * Invokes the method at `path` of each element in `collection`, returning
  14543. * an array of the results of each invoked method. Any additional arguments
  14544. * are provided to each invoked method. If `path` is a function, it's invoked
  14545. * for, and `this` bound to, each element in `collection`.
  14546. *
  14547. * @static
  14548. * @memberOf _
  14549. * @since 4.0.0
  14550. * @category Collection
  14551. * @param {Array|Object} collection The collection to iterate over.
  14552. * @param {Array|Function|string} path The path of the method to invoke or
  14553. * the function invoked per iteration.
  14554. * @param {...*} [args] The arguments to invoke each method with.
  14555. * @returns {Array} Returns the array of results.
  14556. * @example
  14557. *
  14558. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  14559. * // => [[1, 5, 7], [1, 2, 3]]
  14560. *
  14561. * _.invokeMap([123, 456], String.prototype.split, '');
  14562. * // => [['1', '2', '3'], ['4', '5', '6']]
  14563. */
  14564. var invokeMap = baseRest(function(collection, path, args) {
  14565. var index = -1,
  14566. isFunc = typeof path == 'function',
  14567. result = isArrayLike(collection) ? Array(collection.length) : [];
  14568. baseEach(collection, function(value) {
  14569. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  14570. });
  14571. return result;
  14572. });
  14573. /**
  14574. * Creates an object composed of keys generated from the results of running
  14575. * each element of `collection` thru `iteratee`. The corresponding value of
  14576. * each key is the last element responsible for generating the key. The
  14577. * iteratee is invoked with one argument: (value).
  14578. *
  14579. * @static
  14580. * @memberOf _
  14581. * @since 4.0.0
  14582. * @category Collection
  14583. * @param {Array|Object} collection The collection to iterate over.
  14584. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  14585. * @returns {Object} Returns the composed aggregate object.
  14586. * @example
  14587. *
  14588. * var array = [
  14589. * { 'dir': 'left', 'code': 97 },
  14590. * { 'dir': 'right', 'code': 100 }
  14591. * ];
  14592. *
  14593. * _.keyBy(array, function(o) {
  14594. * return String.fromCharCode(o.code);
  14595. * });
  14596. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  14597. *
  14598. * _.keyBy(array, 'dir');
  14599. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  14600. */
  14601. var keyBy = createAggregator(function(result, value, key) {
  14602. baseAssignValue(result, key, value);
  14603. });
  14604. /**
  14605. * Creates an array of values by running each element in `collection` thru
  14606. * `iteratee`. The iteratee is invoked with three arguments:
  14607. * (value, index|key, collection).
  14608. *
  14609. * Many lodash methods are guarded to work as iteratees for methods like
  14610. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  14611. *
  14612. * The guarded methods are:
  14613. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  14614. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  14615. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  14616. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  14617. *
  14618. * @static
  14619. * @memberOf _
  14620. * @since 0.1.0
  14621. * @category Collection
  14622. * @param {Array|Object} collection The collection to iterate over.
  14623. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14624. * @returns {Array} Returns the new mapped array.
  14625. * @example
  14626. *
  14627. * function square(n) {
  14628. * return n * n;
  14629. * }
  14630. *
  14631. * _.map([4, 8], square);
  14632. * // => [16, 64]
  14633. *
  14634. * _.map({ 'a': 4, 'b': 8 }, square);
  14635. * // => [16, 64] (iteration order is not guaranteed)
  14636. *
  14637. * var users = [
  14638. * { 'user': 'barney' },
  14639. * { 'user': 'fred' }
  14640. * ];
  14641. *
  14642. * // The `_.property` iteratee shorthand.
  14643. * _.map(users, 'user');
  14644. * // => ['barney', 'fred']
  14645. */
  14646. function map(collection, iteratee) {
  14647. var func = isArray(collection) ? arrayMap : baseMap;
  14648. return func(collection, getIteratee(iteratee, 3));
  14649. }
  14650. /**
  14651. * This method is like `_.sortBy` except that it allows specifying the sort
  14652. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  14653. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  14654. * descending or "asc" for ascending sort order of corresponding values.
  14655. *
  14656. * @static
  14657. * @memberOf _
  14658. * @since 4.0.0
  14659. * @category Collection
  14660. * @param {Array|Object} collection The collection to iterate over.
  14661. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  14662. * The iteratees to sort by.
  14663. * @param {string[]} [orders] The sort orders of `iteratees`.
  14664. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  14665. * @returns {Array} Returns the new sorted array.
  14666. * @example
  14667. *
  14668. * var users = [
  14669. * { 'user': 'fred', 'age': 48 },
  14670. * { 'user': 'barney', 'age': 34 },
  14671. * { 'user': 'fred', 'age': 40 },
  14672. * { 'user': 'barney', 'age': 36 }
  14673. * ];
  14674. *
  14675. * // Sort by `user` in ascending order and by `age` in descending order.
  14676. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  14677. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  14678. */
  14679. function orderBy(collection, iteratees, orders, guard) {
  14680. if (collection == null) {
  14681. return [];
  14682. }
  14683. if (!isArray(iteratees)) {
  14684. iteratees = iteratees == null ? [] : [iteratees];
  14685. }
  14686. orders = guard ? undefined$1 : orders;
  14687. if (!isArray(orders)) {
  14688. orders = orders == null ? [] : [orders];
  14689. }
  14690. return baseOrderBy(collection, iteratees, orders);
  14691. }
  14692. /**
  14693. * Creates an array of elements split into two groups, the first of which
  14694. * contains elements `predicate` returns truthy for, the second of which
  14695. * contains elements `predicate` returns falsey for. The predicate is
  14696. * invoked with one argument: (value).
  14697. *
  14698. * @static
  14699. * @memberOf _
  14700. * @since 3.0.0
  14701. * @category Collection
  14702. * @param {Array|Object} collection The collection to iterate over.
  14703. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14704. * @returns {Array} Returns the array of grouped elements.
  14705. * @example
  14706. *
  14707. * var users = [
  14708. * { 'user': 'barney', 'age': 36, 'active': false },
  14709. * { 'user': 'fred', 'age': 40, 'active': true },
  14710. * { 'user': 'pebbles', 'age': 1, 'active': false }
  14711. * ];
  14712. *
  14713. * _.partition(users, function(o) { return o.active; });
  14714. * // => objects for [['fred'], ['barney', 'pebbles']]
  14715. *
  14716. * // The `_.matches` iteratee shorthand.
  14717. * _.partition(users, { 'age': 1, 'active': false });
  14718. * // => objects for [['pebbles'], ['barney', 'fred']]
  14719. *
  14720. * // The `_.matchesProperty` iteratee shorthand.
  14721. * _.partition(users, ['active', false]);
  14722. * // => objects for [['barney', 'pebbles'], ['fred']]
  14723. *
  14724. * // The `_.property` iteratee shorthand.
  14725. * _.partition(users, 'active');
  14726. * // => objects for [['fred'], ['barney', 'pebbles']]
  14727. */
  14728. var partition = createAggregator(function(result, value, key) {
  14729. result[key ? 0 : 1].push(value);
  14730. }, function() { return [[], []]; });
  14731. /**
  14732. * Reduces `collection` to a value which is the accumulated result of running
  14733. * each element in `collection` thru `iteratee`, where each successive
  14734. * invocation is supplied the return value of the previous. If `accumulator`
  14735. * is not given, the first element of `collection` is used as the initial
  14736. * value. The iteratee is invoked with four arguments:
  14737. * (accumulator, value, index|key, collection).
  14738. *
  14739. * Many lodash methods are guarded to work as iteratees for methods like
  14740. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  14741. *
  14742. * The guarded methods are:
  14743. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  14744. * and `sortBy`
  14745. *
  14746. * @static
  14747. * @memberOf _
  14748. * @since 0.1.0
  14749. * @category Collection
  14750. * @param {Array|Object} collection The collection to iterate over.
  14751. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14752. * @param {*} [accumulator] The initial value.
  14753. * @returns {*} Returns the accumulated value.
  14754. * @see _.reduceRight
  14755. * @example
  14756. *
  14757. * _.reduce([1, 2], function(sum, n) {
  14758. * return sum + n;
  14759. * }, 0);
  14760. * // => 3
  14761. *
  14762. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  14763. * (result[value] || (result[value] = [])).push(key);
  14764. * return result;
  14765. * }, {});
  14766. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  14767. */
  14768. function reduce(collection, iteratee, accumulator) {
  14769. var func = isArray(collection) ? arrayReduce : baseReduce,
  14770. initAccum = arguments.length < 3;
  14771. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  14772. }
  14773. /**
  14774. * This method is like `_.reduce` except that it iterates over elements of
  14775. * `collection` from right to left.
  14776. *
  14777. * @static
  14778. * @memberOf _
  14779. * @since 0.1.0
  14780. * @category Collection
  14781. * @param {Array|Object} collection The collection to iterate over.
  14782. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14783. * @param {*} [accumulator] The initial value.
  14784. * @returns {*} Returns the accumulated value.
  14785. * @see _.reduce
  14786. * @example
  14787. *
  14788. * var array = [[0, 1], [2, 3], [4, 5]];
  14789. *
  14790. * _.reduceRight(array, function(flattened, other) {
  14791. * return flattened.concat(other);
  14792. * }, []);
  14793. * // => [4, 5, 2, 3, 0, 1]
  14794. */
  14795. function reduceRight(collection, iteratee, accumulator) {
  14796. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  14797. initAccum = arguments.length < 3;
  14798. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  14799. }
  14800. /**
  14801. * The opposite of `_.filter`; this method returns the elements of `collection`
  14802. * that `predicate` does **not** return truthy for.
  14803. *
  14804. * @static
  14805. * @memberOf _
  14806. * @since 0.1.0
  14807. * @category Collection
  14808. * @param {Array|Object} collection The collection to iterate over.
  14809. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14810. * @returns {Array} Returns the new filtered array.
  14811. * @see _.filter
  14812. * @example
  14813. *
  14814. * var users = [
  14815. * { 'user': 'barney', 'age': 36, 'active': false },
  14816. * { 'user': 'fred', 'age': 40, 'active': true }
  14817. * ];
  14818. *
  14819. * _.reject(users, function(o) { return !o.active; });
  14820. * // => objects for ['fred']
  14821. *
  14822. * // The `_.matches` iteratee shorthand.
  14823. * _.reject(users, { 'age': 40, 'active': true });
  14824. * // => objects for ['barney']
  14825. *
  14826. * // The `_.matchesProperty` iteratee shorthand.
  14827. * _.reject(users, ['active', false]);
  14828. * // => objects for ['fred']
  14829. *
  14830. * // The `_.property` iteratee shorthand.
  14831. * _.reject(users, 'active');
  14832. * // => objects for ['barney']
  14833. */
  14834. function reject(collection, predicate) {
  14835. var func = isArray(collection) ? arrayFilter : baseFilter;
  14836. return func(collection, negate(getIteratee(predicate, 3)));
  14837. }
  14838. /**
  14839. * Gets a random element from `collection`.
  14840. *
  14841. * @static
  14842. * @memberOf _
  14843. * @since 2.0.0
  14844. * @category Collection
  14845. * @param {Array|Object} collection The collection to sample.
  14846. * @returns {*} Returns the random element.
  14847. * @example
  14848. *
  14849. * _.sample([1, 2, 3, 4]);
  14850. * // => 2
  14851. */
  14852. function sample(collection) {
  14853. var func = isArray(collection) ? arraySample : baseSample;
  14854. return func(collection);
  14855. }
  14856. /**
  14857. * Gets `n` random elements at unique keys from `collection` up to the
  14858. * size of `collection`.
  14859. *
  14860. * @static
  14861. * @memberOf _
  14862. * @since 4.0.0
  14863. * @category Collection
  14864. * @param {Array|Object} collection The collection to sample.
  14865. * @param {number} [n=1] The number of elements to sample.
  14866. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14867. * @returns {Array} Returns the random elements.
  14868. * @example
  14869. *
  14870. * _.sampleSize([1, 2, 3], 2);
  14871. * // => [3, 1]
  14872. *
  14873. * _.sampleSize([1, 2, 3], 4);
  14874. * // => [2, 3, 1]
  14875. */
  14876. function sampleSize(collection, n, guard) {
  14877. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined$1)) {
  14878. n = 1;
  14879. } else {
  14880. n = toInteger(n);
  14881. }
  14882. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  14883. return func(collection, n);
  14884. }
  14885. /**
  14886. * Creates an array of shuffled values, using a version of the
  14887. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  14888. *
  14889. * @static
  14890. * @memberOf _
  14891. * @since 0.1.0
  14892. * @category Collection
  14893. * @param {Array|Object} collection The collection to shuffle.
  14894. * @returns {Array} Returns the new shuffled array.
  14895. * @example
  14896. *
  14897. * _.shuffle([1, 2, 3, 4]);
  14898. * // => [4, 1, 3, 2]
  14899. */
  14900. function shuffle(collection) {
  14901. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  14902. return func(collection);
  14903. }
  14904. /**
  14905. * Gets the size of `collection` by returning its length for array-like
  14906. * values or the number of own enumerable string keyed properties for objects.
  14907. *
  14908. * @static
  14909. * @memberOf _
  14910. * @since 0.1.0
  14911. * @category Collection
  14912. * @param {Array|Object|string} collection The collection to inspect.
  14913. * @returns {number} Returns the collection size.
  14914. * @example
  14915. *
  14916. * _.size([1, 2, 3]);
  14917. * // => 3
  14918. *
  14919. * _.size({ 'a': 1, 'b': 2 });
  14920. * // => 2
  14921. *
  14922. * _.size('pebbles');
  14923. * // => 7
  14924. */
  14925. function size(collection) {
  14926. if (collection == null) {
  14927. return 0;
  14928. }
  14929. if (isArrayLike(collection)) {
  14930. return isString(collection) ? stringSize(collection) : collection.length;
  14931. }
  14932. var tag = getTag(collection);
  14933. if (tag == mapTag || tag == setTag) {
  14934. return collection.size;
  14935. }
  14936. return baseKeys(collection).length;
  14937. }
  14938. /**
  14939. * Checks if `predicate` returns truthy for **any** element of `collection`.
  14940. * Iteration is stopped once `predicate` returns truthy. The predicate is
  14941. * invoked with three arguments: (value, index|key, collection).
  14942. *
  14943. * @static
  14944. * @memberOf _
  14945. * @since 0.1.0
  14946. * @category Collection
  14947. * @param {Array|Object} collection The collection to iterate over.
  14948. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14949. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14950. * @returns {boolean} Returns `true` if any element passes the predicate check,
  14951. * else `false`.
  14952. * @example
  14953. *
  14954. * _.some([null, 0, 'yes', false], Boolean);
  14955. * // => true
  14956. *
  14957. * var users = [
  14958. * { 'user': 'barney', 'active': true },
  14959. * { 'user': 'fred', 'active': false }
  14960. * ];
  14961. *
  14962. * // The `_.matches` iteratee shorthand.
  14963. * _.some(users, { 'user': 'barney', 'active': false });
  14964. * // => false
  14965. *
  14966. * // The `_.matchesProperty` iteratee shorthand.
  14967. * _.some(users, ['active', false]);
  14968. * // => true
  14969. *
  14970. * // The `_.property` iteratee shorthand.
  14971. * _.some(users, 'active');
  14972. * // => true
  14973. */
  14974. function some(collection, predicate, guard) {
  14975. var func = isArray(collection) ? arraySome : baseSome;
  14976. if (guard && isIterateeCall(collection, predicate, guard)) {
  14977. predicate = undefined$1;
  14978. }
  14979. return func(collection, getIteratee(predicate, 3));
  14980. }
  14981. /**
  14982. * Creates an array of elements, sorted in ascending order by the results of
  14983. * running each element in a collection thru each iteratee. This method
  14984. * performs a stable sort, that is, it preserves the original sort order of
  14985. * equal elements. The iteratees are invoked with one argument: (value).
  14986. *
  14987. * @static
  14988. * @memberOf _
  14989. * @since 0.1.0
  14990. * @category Collection
  14991. * @param {Array|Object} collection The collection to iterate over.
  14992. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  14993. * The iteratees to sort by.
  14994. * @returns {Array} Returns the new sorted array.
  14995. * @example
  14996. *
  14997. * var users = [
  14998. * { 'user': 'fred', 'age': 48 },
  14999. * { 'user': 'barney', 'age': 36 },
  15000. * { 'user': 'fred', 'age': 30 },
  15001. * { 'user': 'barney', 'age': 34 }
  15002. * ];
  15003. *
  15004. * _.sortBy(users, [function(o) { return o.user; }]);
  15005. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  15006. *
  15007. * _.sortBy(users, ['user', 'age']);
  15008. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  15009. */
  15010. var sortBy = baseRest(function(collection, iteratees) {
  15011. if (collection == null) {
  15012. return [];
  15013. }
  15014. var length = iteratees.length;
  15015. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  15016. iteratees = [];
  15017. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  15018. iteratees = [iteratees[0]];
  15019. }
  15020. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  15021. });
  15022. /*------------------------------------------------------------------------*/
  15023. /**
  15024. * Gets the timestamp of the number of milliseconds that have elapsed since
  15025. * the Unix epoch (1 January 1970 00:00:00 UTC).
  15026. *
  15027. * @static
  15028. * @memberOf _
  15029. * @since 2.4.0
  15030. * @category Date
  15031. * @returns {number} Returns the timestamp.
  15032. * @example
  15033. *
  15034. * _.defer(function(stamp) {
  15035. * console.log(_.now() - stamp);
  15036. * }, _.now());
  15037. * // => Logs the number of milliseconds it took for the deferred invocation.
  15038. */
  15039. var now = ctxNow || function() {
  15040. return root.Date.now();
  15041. };
  15042. /*------------------------------------------------------------------------*/
  15043. /**
  15044. * The opposite of `_.before`; this method creates a function that invokes
  15045. * `func` once it's called `n` or more times.
  15046. *
  15047. * @static
  15048. * @memberOf _
  15049. * @since 0.1.0
  15050. * @category Function
  15051. * @param {number} n The number of calls before `func` is invoked.
  15052. * @param {Function} func The function to restrict.
  15053. * @returns {Function} Returns the new restricted function.
  15054. * @example
  15055. *
  15056. * var saves = ['profile', 'settings'];
  15057. *
  15058. * var done = _.after(saves.length, function() {
  15059. * console.log('done saving!');
  15060. * });
  15061. *
  15062. * _.forEach(saves, function(type) {
  15063. * asyncSave({ 'type': type, 'complete': done });
  15064. * });
  15065. * // => Logs 'done saving!' after the two async saves have completed.
  15066. */
  15067. function after(n, func) {
  15068. if (typeof func != 'function') {
  15069. throw new TypeError(FUNC_ERROR_TEXT);
  15070. }
  15071. n = toInteger(n);
  15072. return function() {
  15073. if (--n < 1) {
  15074. return func.apply(this, arguments);
  15075. }
  15076. };
  15077. }
  15078. /**
  15079. * Creates a function that invokes `func`, with up to `n` arguments,
  15080. * ignoring any additional arguments.
  15081. *
  15082. * @static
  15083. * @memberOf _
  15084. * @since 3.0.0
  15085. * @category Function
  15086. * @param {Function} func The function to cap arguments for.
  15087. * @param {number} [n=func.length] The arity cap.
  15088. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15089. * @returns {Function} Returns the new capped function.
  15090. * @example
  15091. *
  15092. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  15093. * // => [6, 8, 10]
  15094. */
  15095. function ary(func, n, guard) {
  15096. n = guard ? undefined$1 : n;
  15097. n = (func && n == null) ? func.length : n;
  15098. return createWrap(func, WRAP_ARY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, n);
  15099. }
  15100. /**
  15101. * Creates a function that invokes `func`, with the `this` binding and arguments
  15102. * of the created function, while it's called less than `n` times. Subsequent
  15103. * calls to the created function return the result of the last `func` invocation.
  15104. *
  15105. * @static
  15106. * @memberOf _
  15107. * @since 3.0.0
  15108. * @category Function
  15109. * @param {number} n The number of calls at which `func` is no longer invoked.
  15110. * @param {Function} func The function to restrict.
  15111. * @returns {Function} Returns the new restricted function.
  15112. * @example
  15113. *
  15114. * jQuery(element).on('click', _.before(5, addContactToList));
  15115. * // => Allows adding up to 4 contacts to the list.
  15116. */
  15117. function before(n, func) {
  15118. var result;
  15119. if (typeof func != 'function') {
  15120. throw new TypeError(FUNC_ERROR_TEXT);
  15121. }
  15122. n = toInteger(n);
  15123. return function() {
  15124. if (--n > 0) {
  15125. result = func.apply(this, arguments);
  15126. }
  15127. if (n <= 1) {
  15128. func = undefined$1;
  15129. }
  15130. return result;
  15131. };
  15132. }
  15133. /**
  15134. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  15135. * and `partials` prepended to the arguments it receives.
  15136. *
  15137. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  15138. * may be used as a placeholder for partially applied arguments.
  15139. *
  15140. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  15141. * property of bound functions.
  15142. *
  15143. * @static
  15144. * @memberOf _
  15145. * @since 0.1.0
  15146. * @category Function
  15147. * @param {Function} func The function to bind.
  15148. * @param {*} thisArg The `this` binding of `func`.
  15149. * @param {...*} [partials] The arguments to be partially applied.
  15150. * @returns {Function} Returns the new bound function.
  15151. * @example
  15152. *
  15153. * function greet(greeting, punctuation) {
  15154. * return greeting + ' ' + this.user + punctuation;
  15155. * }
  15156. *
  15157. * var object = { 'user': 'fred' };
  15158. *
  15159. * var bound = _.bind(greet, object, 'hi');
  15160. * bound('!');
  15161. * // => 'hi fred!'
  15162. *
  15163. * // Bound with placeholders.
  15164. * var bound = _.bind(greet, object, _, '!');
  15165. * bound('hi');
  15166. * // => 'hi fred!'
  15167. */
  15168. var bind = baseRest(function(func, thisArg, partials) {
  15169. var bitmask = WRAP_BIND_FLAG;
  15170. if (partials.length) {
  15171. var holders = replaceHolders(partials, getHolder(bind));
  15172. bitmask |= WRAP_PARTIAL_FLAG;
  15173. }
  15174. return createWrap(func, bitmask, thisArg, partials, holders);
  15175. });
  15176. /**
  15177. * Creates a function that invokes the method at `object[key]` with `partials`
  15178. * prepended to the arguments it receives.
  15179. *
  15180. * This method differs from `_.bind` by allowing bound functions to reference
  15181. * methods that may be redefined or don't yet exist. See
  15182. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  15183. * for more details.
  15184. *
  15185. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  15186. * builds, may be used as a placeholder for partially applied arguments.
  15187. *
  15188. * @static
  15189. * @memberOf _
  15190. * @since 0.10.0
  15191. * @category Function
  15192. * @param {Object} object The object to invoke the method on.
  15193. * @param {string} key The key of the method.
  15194. * @param {...*} [partials] The arguments to be partially applied.
  15195. * @returns {Function} Returns the new bound function.
  15196. * @example
  15197. *
  15198. * var object = {
  15199. * 'user': 'fred',
  15200. * 'greet': function(greeting, punctuation) {
  15201. * return greeting + ' ' + this.user + punctuation;
  15202. * }
  15203. * };
  15204. *
  15205. * var bound = _.bindKey(object, 'greet', 'hi');
  15206. * bound('!');
  15207. * // => 'hi fred!'
  15208. *
  15209. * object.greet = function(greeting, punctuation) {
  15210. * return greeting + 'ya ' + this.user + punctuation;
  15211. * };
  15212. *
  15213. * bound('!');
  15214. * // => 'hiya fred!'
  15215. *
  15216. * // Bound with placeholders.
  15217. * var bound = _.bindKey(object, 'greet', _, '!');
  15218. * bound('hi');
  15219. * // => 'hiya fred!'
  15220. */
  15221. var bindKey = baseRest(function(object, key, partials) {
  15222. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  15223. if (partials.length) {
  15224. var holders = replaceHolders(partials, getHolder(bindKey));
  15225. bitmask |= WRAP_PARTIAL_FLAG;
  15226. }
  15227. return createWrap(key, bitmask, object, partials, holders);
  15228. });
  15229. /**
  15230. * Creates a function that accepts arguments of `func` and either invokes
  15231. * `func` returning its result, if at least `arity` number of arguments have
  15232. * been provided, or returns a function that accepts the remaining `func`
  15233. * arguments, and so on. The arity of `func` may be specified if `func.length`
  15234. * is not sufficient.
  15235. *
  15236. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  15237. * may be used as a placeholder for provided arguments.
  15238. *
  15239. * **Note:** This method doesn't set the "length" property of curried functions.
  15240. *
  15241. * @static
  15242. * @memberOf _
  15243. * @since 2.0.0
  15244. * @category Function
  15245. * @param {Function} func The function to curry.
  15246. * @param {number} [arity=func.length] The arity of `func`.
  15247. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15248. * @returns {Function} Returns the new curried function.
  15249. * @example
  15250. *
  15251. * var abc = function(a, b, c) {
  15252. * return [a, b, c];
  15253. * };
  15254. *
  15255. * var curried = _.curry(abc);
  15256. *
  15257. * curried(1)(2)(3);
  15258. * // => [1, 2, 3]
  15259. *
  15260. * curried(1, 2)(3);
  15261. * // => [1, 2, 3]
  15262. *
  15263. * curried(1, 2, 3);
  15264. * // => [1, 2, 3]
  15265. *
  15266. * // Curried with placeholders.
  15267. * curried(1)(_, 3)(2);
  15268. * // => [1, 2, 3]
  15269. */
  15270. function curry(func, arity, guard) {
  15271. arity = guard ? undefined$1 : arity;
  15272. var result = createWrap(func, WRAP_CURRY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
  15273. result.placeholder = curry.placeholder;
  15274. return result;
  15275. }
  15276. /**
  15277. * This method is like `_.curry` except that arguments are applied to `func`
  15278. * in the manner of `_.partialRight` instead of `_.partial`.
  15279. *
  15280. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  15281. * builds, may be used as a placeholder for provided arguments.
  15282. *
  15283. * **Note:** This method doesn't set the "length" property of curried functions.
  15284. *
  15285. * @static
  15286. * @memberOf _
  15287. * @since 3.0.0
  15288. * @category Function
  15289. * @param {Function} func The function to curry.
  15290. * @param {number} [arity=func.length] The arity of `func`.
  15291. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15292. * @returns {Function} Returns the new curried function.
  15293. * @example
  15294. *
  15295. * var abc = function(a, b, c) {
  15296. * return [a, b, c];
  15297. * };
  15298. *
  15299. * var curried = _.curryRight(abc);
  15300. *
  15301. * curried(3)(2)(1);
  15302. * // => [1, 2, 3]
  15303. *
  15304. * curried(2, 3)(1);
  15305. * // => [1, 2, 3]
  15306. *
  15307. * curried(1, 2, 3);
  15308. * // => [1, 2, 3]
  15309. *
  15310. * // Curried with placeholders.
  15311. * curried(3)(1, _)(2);
  15312. * // => [1, 2, 3]
  15313. */
  15314. function curryRight(func, arity, guard) {
  15315. arity = guard ? undefined$1 : arity;
  15316. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
  15317. result.placeholder = curryRight.placeholder;
  15318. return result;
  15319. }
  15320. /**
  15321. * Creates a debounced function that delays invoking `func` until after `wait`
  15322. * milliseconds have elapsed since the last time the debounced function was
  15323. * invoked. The debounced function comes with a `cancel` method to cancel
  15324. * delayed `func` invocations and a `flush` method to immediately invoke them.
  15325. * Provide `options` to indicate whether `func` should be invoked on the
  15326. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  15327. * with the last arguments provided to the debounced function. Subsequent
  15328. * calls to the debounced function return the result of the last `func`
  15329. * invocation.
  15330. *
  15331. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  15332. * invoked on the trailing edge of the timeout only if the debounced function
  15333. * is invoked more than once during the `wait` timeout.
  15334. *
  15335. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  15336. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  15337. *
  15338. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  15339. * for details over the differences between `_.debounce` and `_.throttle`.
  15340. *
  15341. * @static
  15342. * @memberOf _
  15343. * @since 0.1.0
  15344. * @category Function
  15345. * @param {Function} func The function to debounce.
  15346. * @param {number} [wait=0] The number of milliseconds to delay.
  15347. * @param {Object} [options={}] The options object.
  15348. * @param {boolean} [options.leading=false]
  15349. * Specify invoking on the leading edge of the timeout.
  15350. * @param {number} [options.maxWait]
  15351. * The maximum time `func` is allowed to be delayed before it's invoked.
  15352. * @param {boolean} [options.trailing=true]
  15353. * Specify invoking on the trailing edge of the timeout.
  15354. * @returns {Function} Returns the new debounced function.
  15355. * @example
  15356. *
  15357. * // Avoid costly calculations while the window size is in flux.
  15358. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  15359. *
  15360. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  15361. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  15362. * 'leading': true,
  15363. * 'trailing': false
  15364. * }));
  15365. *
  15366. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  15367. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  15368. * var source = new EventSource('/stream');
  15369. * jQuery(source).on('message', debounced);
  15370. *
  15371. * // Cancel the trailing debounced invocation.
  15372. * jQuery(window).on('popstate', debounced.cancel);
  15373. */
  15374. function debounce(func, wait, options) {
  15375. var lastArgs,
  15376. lastThis,
  15377. maxWait,
  15378. result,
  15379. timerId,
  15380. lastCallTime,
  15381. lastInvokeTime = 0,
  15382. leading = false,
  15383. maxing = false,
  15384. trailing = true;
  15385. if (typeof func != 'function') {
  15386. throw new TypeError(FUNC_ERROR_TEXT);
  15387. }
  15388. wait = toNumber(wait) || 0;
  15389. if (isObject(options)) {
  15390. leading = !!options.leading;
  15391. maxing = 'maxWait' in options;
  15392. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  15393. trailing = 'trailing' in options ? !!options.trailing : trailing;
  15394. }
  15395. function invokeFunc(time) {
  15396. var args = lastArgs,
  15397. thisArg = lastThis;
  15398. lastArgs = lastThis = undefined$1;
  15399. lastInvokeTime = time;
  15400. result = func.apply(thisArg, args);
  15401. return result;
  15402. }
  15403. function leadingEdge(time) {
  15404. // Reset any `maxWait` timer.
  15405. lastInvokeTime = time;
  15406. // Start the timer for the trailing edge.
  15407. timerId = setTimeout(timerExpired, wait);
  15408. // Invoke the leading edge.
  15409. return leading ? invokeFunc(time) : result;
  15410. }
  15411. function remainingWait(time) {
  15412. var timeSinceLastCall = time - lastCallTime,
  15413. timeSinceLastInvoke = time - lastInvokeTime,
  15414. timeWaiting = wait - timeSinceLastCall;
  15415. return maxing
  15416. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  15417. : timeWaiting;
  15418. }
  15419. function shouldInvoke(time) {
  15420. var timeSinceLastCall = time - lastCallTime,
  15421. timeSinceLastInvoke = time - lastInvokeTime;
  15422. // Either this is the first call, activity has stopped and we're at the
  15423. // trailing edge, the system time has gone backwards and we're treating
  15424. // it as the trailing edge, or we've hit the `maxWait` limit.
  15425. return (lastCallTime === undefined$1 || (timeSinceLastCall >= wait) ||
  15426. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  15427. }
  15428. function timerExpired() {
  15429. var time = now();
  15430. if (shouldInvoke(time)) {
  15431. return trailingEdge(time);
  15432. }
  15433. // Restart the timer.
  15434. timerId = setTimeout(timerExpired, remainingWait(time));
  15435. }
  15436. function trailingEdge(time) {
  15437. timerId = undefined$1;
  15438. // Only invoke if we have `lastArgs` which means `func` has been
  15439. // debounced at least once.
  15440. if (trailing && lastArgs) {
  15441. return invokeFunc(time);
  15442. }
  15443. lastArgs = lastThis = undefined$1;
  15444. return result;
  15445. }
  15446. function cancel() {
  15447. if (timerId !== undefined$1) {
  15448. clearTimeout(timerId);
  15449. }
  15450. lastInvokeTime = 0;
  15451. lastArgs = lastCallTime = lastThis = timerId = undefined$1;
  15452. }
  15453. function flush() {
  15454. return timerId === undefined$1 ? result : trailingEdge(now());
  15455. }
  15456. function debounced() {
  15457. var time = now(),
  15458. isInvoking = shouldInvoke(time);
  15459. lastArgs = arguments;
  15460. lastThis = this;
  15461. lastCallTime = time;
  15462. if (isInvoking) {
  15463. if (timerId === undefined$1) {
  15464. return leadingEdge(lastCallTime);
  15465. }
  15466. if (maxing) {
  15467. // Handle invocations in a tight loop.
  15468. clearTimeout(timerId);
  15469. timerId = setTimeout(timerExpired, wait);
  15470. return invokeFunc(lastCallTime);
  15471. }
  15472. }
  15473. if (timerId === undefined$1) {
  15474. timerId = setTimeout(timerExpired, wait);
  15475. }
  15476. return result;
  15477. }
  15478. debounced.cancel = cancel;
  15479. debounced.flush = flush;
  15480. return debounced;
  15481. }
  15482. /**
  15483. * Defers invoking the `func` until the current call stack has cleared. Any
  15484. * additional arguments are provided to `func` when it's invoked.
  15485. *
  15486. * @static
  15487. * @memberOf _
  15488. * @since 0.1.0
  15489. * @category Function
  15490. * @param {Function} func The function to defer.
  15491. * @param {...*} [args] The arguments to invoke `func` with.
  15492. * @returns {number} Returns the timer id.
  15493. * @example
  15494. *
  15495. * _.defer(function(text) {
  15496. * console.log(text);
  15497. * }, 'deferred');
  15498. * // => Logs 'deferred' after one millisecond.
  15499. */
  15500. var defer = baseRest(function(func, args) {
  15501. return baseDelay(func, 1, args);
  15502. });
  15503. /**
  15504. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  15505. * provided to `func` when it's invoked.
  15506. *
  15507. * @static
  15508. * @memberOf _
  15509. * @since 0.1.0
  15510. * @category Function
  15511. * @param {Function} func The function to delay.
  15512. * @param {number} wait The number of milliseconds to delay invocation.
  15513. * @param {...*} [args] The arguments to invoke `func` with.
  15514. * @returns {number} Returns the timer id.
  15515. * @example
  15516. *
  15517. * _.delay(function(text) {
  15518. * console.log(text);
  15519. * }, 1000, 'later');
  15520. * // => Logs 'later' after one second.
  15521. */
  15522. var delay = baseRest(function(func, wait, args) {
  15523. return baseDelay(func, toNumber(wait) || 0, args);
  15524. });
  15525. /**
  15526. * Creates a function that invokes `func` with arguments reversed.
  15527. *
  15528. * @static
  15529. * @memberOf _
  15530. * @since 4.0.0
  15531. * @category Function
  15532. * @param {Function} func The function to flip arguments for.
  15533. * @returns {Function} Returns the new flipped function.
  15534. * @example
  15535. *
  15536. * var flipped = _.flip(function() {
  15537. * return _.toArray(arguments);
  15538. * });
  15539. *
  15540. * flipped('a', 'b', 'c', 'd');
  15541. * // => ['d', 'c', 'b', 'a']
  15542. */
  15543. function flip(func) {
  15544. return createWrap(func, WRAP_FLIP_FLAG);
  15545. }
  15546. /**
  15547. * Creates a function that memoizes the result of `func`. If `resolver` is
  15548. * provided, it determines the cache key for storing the result based on the
  15549. * arguments provided to the memoized function. By default, the first argument
  15550. * provided to the memoized function is used as the map cache key. The `func`
  15551. * is invoked with the `this` binding of the memoized function.
  15552. *
  15553. * **Note:** The cache is exposed as the `cache` property on the memoized
  15554. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  15555. * constructor with one whose instances implement the
  15556. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  15557. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  15558. *
  15559. * @static
  15560. * @memberOf _
  15561. * @since 0.1.0
  15562. * @category Function
  15563. * @param {Function} func The function to have its output memoized.
  15564. * @param {Function} [resolver] The function to resolve the cache key.
  15565. * @returns {Function} Returns the new memoized function.
  15566. * @example
  15567. *
  15568. * var object = { 'a': 1, 'b': 2 };
  15569. * var other = { 'c': 3, 'd': 4 };
  15570. *
  15571. * var values = _.memoize(_.values);
  15572. * values(object);
  15573. * // => [1, 2]
  15574. *
  15575. * values(other);
  15576. * // => [3, 4]
  15577. *
  15578. * object.a = 2;
  15579. * values(object);
  15580. * // => [1, 2]
  15581. *
  15582. * // Modify the result cache.
  15583. * values.cache.set(object, ['a', 'b']);
  15584. * values(object);
  15585. * // => ['a', 'b']
  15586. *
  15587. * // Replace `_.memoize.Cache`.
  15588. * _.memoize.Cache = WeakMap;
  15589. */
  15590. function memoize(func, resolver) {
  15591. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  15592. throw new TypeError(FUNC_ERROR_TEXT);
  15593. }
  15594. var memoized = function() {
  15595. var args = arguments,
  15596. key = resolver ? resolver.apply(this, args) : args[0],
  15597. cache = memoized.cache;
  15598. if (cache.has(key)) {
  15599. return cache.get(key);
  15600. }
  15601. var result = func.apply(this, args);
  15602. memoized.cache = cache.set(key, result) || cache;
  15603. return result;
  15604. };
  15605. memoized.cache = new (memoize.Cache || MapCache);
  15606. return memoized;
  15607. }
  15608. // Expose `MapCache`.
  15609. memoize.Cache = MapCache;
  15610. /**
  15611. * Creates a function that negates the result of the predicate `func`. The
  15612. * `func` predicate is invoked with the `this` binding and arguments of the
  15613. * created function.
  15614. *
  15615. * @static
  15616. * @memberOf _
  15617. * @since 3.0.0
  15618. * @category Function
  15619. * @param {Function} predicate The predicate to negate.
  15620. * @returns {Function} Returns the new negated function.
  15621. * @example
  15622. *
  15623. * function isEven(n) {
  15624. * return n % 2 == 0;
  15625. * }
  15626. *
  15627. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  15628. * // => [1, 3, 5]
  15629. */
  15630. function negate(predicate) {
  15631. if (typeof predicate != 'function') {
  15632. throw new TypeError(FUNC_ERROR_TEXT);
  15633. }
  15634. return function() {
  15635. var args = arguments;
  15636. switch (args.length) {
  15637. case 0: return !predicate.call(this);
  15638. case 1: return !predicate.call(this, args[0]);
  15639. case 2: return !predicate.call(this, args[0], args[1]);
  15640. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  15641. }
  15642. return !predicate.apply(this, args);
  15643. };
  15644. }
  15645. /**
  15646. * Creates a function that is restricted to invoking `func` once. Repeat calls
  15647. * to the function return the value of the first invocation. The `func` is
  15648. * invoked with the `this` binding and arguments of the created function.
  15649. *
  15650. * @static
  15651. * @memberOf _
  15652. * @since 0.1.0
  15653. * @category Function
  15654. * @param {Function} func The function to restrict.
  15655. * @returns {Function} Returns the new restricted function.
  15656. * @example
  15657. *
  15658. * var initialize = _.once(createApplication);
  15659. * initialize();
  15660. * initialize();
  15661. * // => `createApplication` is invoked once
  15662. */
  15663. function once(func) {
  15664. return before(2, func);
  15665. }
  15666. /**
  15667. * Creates a function that invokes `func` with its arguments transformed.
  15668. *
  15669. * @static
  15670. * @since 4.0.0
  15671. * @memberOf _
  15672. * @category Function
  15673. * @param {Function} func The function to wrap.
  15674. * @param {...(Function|Function[])} [transforms=[_.identity]]
  15675. * The argument transforms.
  15676. * @returns {Function} Returns the new function.
  15677. * @example
  15678. *
  15679. * function doubled(n) {
  15680. * return n * 2;
  15681. * }
  15682. *
  15683. * function square(n) {
  15684. * return n * n;
  15685. * }
  15686. *
  15687. * var func = _.overArgs(function(x, y) {
  15688. * return [x, y];
  15689. * }, [square, doubled]);
  15690. *
  15691. * func(9, 3);
  15692. * // => [81, 6]
  15693. *
  15694. * func(10, 5);
  15695. * // => [100, 10]
  15696. */
  15697. var overArgs = castRest(function(func, transforms) {
  15698. transforms = (transforms.length == 1 && isArray(transforms[0]))
  15699. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  15700. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  15701. var funcsLength = transforms.length;
  15702. return baseRest(function(args) {
  15703. var index = -1,
  15704. length = nativeMin(args.length, funcsLength);
  15705. while (++index < length) {
  15706. args[index] = transforms[index].call(this, args[index]);
  15707. }
  15708. return apply(func, this, args);
  15709. });
  15710. });
  15711. /**
  15712. * Creates a function that invokes `func` with `partials` prepended to the
  15713. * arguments it receives. This method is like `_.bind` except it does **not**
  15714. * alter the `this` binding.
  15715. *
  15716. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  15717. * builds, may be used as a placeholder for partially applied arguments.
  15718. *
  15719. * **Note:** This method doesn't set the "length" property of partially
  15720. * applied functions.
  15721. *
  15722. * @static
  15723. * @memberOf _
  15724. * @since 0.2.0
  15725. * @category Function
  15726. * @param {Function} func The function to partially apply arguments to.
  15727. * @param {...*} [partials] The arguments to be partially applied.
  15728. * @returns {Function} Returns the new partially applied function.
  15729. * @example
  15730. *
  15731. * function greet(greeting, name) {
  15732. * return greeting + ' ' + name;
  15733. * }
  15734. *
  15735. * var sayHelloTo = _.partial(greet, 'hello');
  15736. * sayHelloTo('fred');
  15737. * // => 'hello fred'
  15738. *
  15739. * // Partially applied with placeholders.
  15740. * var greetFred = _.partial(greet, _, 'fred');
  15741. * greetFred('hi');
  15742. * // => 'hi fred'
  15743. */
  15744. var partial = baseRest(function(func, partials) {
  15745. var holders = replaceHolders(partials, getHolder(partial));
  15746. return createWrap(func, WRAP_PARTIAL_FLAG, undefined$1, partials, holders);
  15747. });
  15748. /**
  15749. * This method is like `_.partial` except that partially applied arguments
  15750. * are appended to the arguments it receives.
  15751. *
  15752. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  15753. * builds, may be used as a placeholder for partially applied arguments.
  15754. *
  15755. * **Note:** This method doesn't set the "length" property of partially
  15756. * applied functions.
  15757. *
  15758. * @static
  15759. * @memberOf _
  15760. * @since 1.0.0
  15761. * @category Function
  15762. * @param {Function} func The function to partially apply arguments to.
  15763. * @param {...*} [partials] The arguments to be partially applied.
  15764. * @returns {Function} Returns the new partially applied function.
  15765. * @example
  15766. *
  15767. * function greet(greeting, name) {
  15768. * return greeting + ' ' + name;
  15769. * }
  15770. *
  15771. * var greetFred = _.partialRight(greet, 'fred');
  15772. * greetFred('hi');
  15773. * // => 'hi fred'
  15774. *
  15775. * // Partially applied with placeholders.
  15776. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  15777. * sayHelloTo('fred');
  15778. * // => 'hello fred'
  15779. */
  15780. var partialRight = baseRest(function(func, partials) {
  15781. var holders = replaceHolders(partials, getHolder(partialRight));
  15782. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined$1, partials, holders);
  15783. });
  15784. /**
  15785. * Creates a function that invokes `func` with arguments arranged according
  15786. * to the specified `indexes` where the argument value at the first index is
  15787. * provided as the first argument, the argument value at the second index is
  15788. * provided as the second argument, and so on.
  15789. *
  15790. * @static
  15791. * @memberOf _
  15792. * @since 3.0.0
  15793. * @category Function
  15794. * @param {Function} func The function to rearrange arguments for.
  15795. * @param {...(number|number[])} indexes The arranged argument indexes.
  15796. * @returns {Function} Returns the new function.
  15797. * @example
  15798. *
  15799. * var rearged = _.rearg(function(a, b, c) {
  15800. * return [a, b, c];
  15801. * }, [2, 0, 1]);
  15802. *
  15803. * rearged('b', 'c', 'a')
  15804. * // => ['a', 'b', 'c']
  15805. */
  15806. var rearg = flatRest(function(func, indexes) {
  15807. return createWrap(func, WRAP_REARG_FLAG, undefined$1, undefined$1, undefined$1, indexes);
  15808. });
  15809. /**
  15810. * Creates a function that invokes `func` with the `this` binding of the
  15811. * created function and arguments from `start` and beyond provided as
  15812. * an array.
  15813. *
  15814. * **Note:** This method is based on the
  15815. * [rest parameter](https://mdn.io/rest_parameters).
  15816. *
  15817. * @static
  15818. * @memberOf _
  15819. * @since 4.0.0
  15820. * @category Function
  15821. * @param {Function} func The function to apply a rest parameter to.
  15822. * @param {number} [start=func.length-1] The start position of the rest parameter.
  15823. * @returns {Function} Returns the new function.
  15824. * @example
  15825. *
  15826. * var say = _.rest(function(what, names) {
  15827. * return what + ' ' + _.initial(names).join(', ') +
  15828. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  15829. * });
  15830. *
  15831. * say('hello', 'fred', 'barney', 'pebbles');
  15832. * // => 'hello fred, barney, & pebbles'
  15833. */
  15834. function rest(func, start) {
  15835. if (typeof func != 'function') {
  15836. throw new TypeError(FUNC_ERROR_TEXT);
  15837. }
  15838. start = start === undefined$1 ? start : toInteger(start);
  15839. return baseRest(func, start);
  15840. }
  15841. /**
  15842. * Creates a function that invokes `func` with the `this` binding of the
  15843. * create function and an array of arguments much like
  15844. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  15845. *
  15846. * **Note:** This method is based on the
  15847. * [spread operator](https://mdn.io/spread_operator).
  15848. *
  15849. * @static
  15850. * @memberOf _
  15851. * @since 3.2.0
  15852. * @category Function
  15853. * @param {Function} func The function to spread arguments over.
  15854. * @param {number} [start=0] The start position of the spread.
  15855. * @returns {Function} Returns the new function.
  15856. * @example
  15857. *
  15858. * var say = _.spread(function(who, what) {
  15859. * return who + ' says ' + what;
  15860. * });
  15861. *
  15862. * say(['fred', 'hello']);
  15863. * // => 'fred says hello'
  15864. *
  15865. * var numbers = Promise.all([
  15866. * Promise.resolve(40),
  15867. * Promise.resolve(36)
  15868. * ]);
  15869. *
  15870. * numbers.then(_.spread(function(x, y) {
  15871. * return x + y;
  15872. * }));
  15873. * // => a Promise of 76
  15874. */
  15875. function spread(func, start) {
  15876. if (typeof func != 'function') {
  15877. throw new TypeError(FUNC_ERROR_TEXT);
  15878. }
  15879. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  15880. return baseRest(function(args) {
  15881. var array = args[start],
  15882. otherArgs = castSlice(args, 0, start);
  15883. if (array) {
  15884. arrayPush(otherArgs, array);
  15885. }
  15886. return apply(func, this, otherArgs);
  15887. });
  15888. }
  15889. /**
  15890. * Creates a throttled function that only invokes `func` at most once per
  15891. * every `wait` milliseconds. The throttled function comes with a `cancel`
  15892. * method to cancel delayed `func` invocations and a `flush` method to
  15893. * immediately invoke them. Provide `options` to indicate whether `func`
  15894. * should be invoked on the leading and/or trailing edge of the `wait`
  15895. * timeout. The `func` is invoked with the last arguments provided to the
  15896. * throttled function. Subsequent calls to the throttled function return the
  15897. * result of the last `func` invocation.
  15898. *
  15899. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  15900. * invoked on the trailing edge of the timeout only if the throttled function
  15901. * is invoked more than once during the `wait` timeout.
  15902. *
  15903. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  15904. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  15905. *
  15906. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  15907. * for details over the differences between `_.throttle` and `_.debounce`.
  15908. *
  15909. * @static
  15910. * @memberOf _
  15911. * @since 0.1.0
  15912. * @category Function
  15913. * @param {Function} func The function to throttle.
  15914. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  15915. * @param {Object} [options={}] The options object.
  15916. * @param {boolean} [options.leading=true]
  15917. * Specify invoking on the leading edge of the timeout.
  15918. * @param {boolean} [options.trailing=true]
  15919. * Specify invoking on the trailing edge of the timeout.
  15920. * @returns {Function} Returns the new throttled function.
  15921. * @example
  15922. *
  15923. * // Avoid excessively updating the position while scrolling.
  15924. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  15925. *
  15926. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  15927. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  15928. * jQuery(element).on('click', throttled);
  15929. *
  15930. * // Cancel the trailing throttled invocation.
  15931. * jQuery(window).on('popstate', throttled.cancel);
  15932. */
  15933. function throttle(func, wait, options) {
  15934. var leading = true,
  15935. trailing = true;
  15936. if (typeof func != 'function') {
  15937. throw new TypeError(FUNC_ERROR_TEXT);
  15938. }
  15939. if (isObject(options)) {
  15940. leading = 'leading' in options ? !!options.leading : leading;
  15941. trailing = 'trailing' in options ? !!options.trailing : trailing;
  15942. }
  15943. return debounce(func, wait, {
  15944. 'leading': leading,
  15945. 'maxWait': wait,
  15946. 'trailing': trailing
  15947. });
  15948. }
  15949. /**
  15950. * Creates a function that accepts up to one argument, ignoring any
  15951. * additional arguments.
  15952. *
  15953. * @static
  15954. * @memberOf _
  15955. * @since 4.0.0
  15956. * @category Function
  15957. * @param {Function} func The function to cap arguments for.
  15958. * @returns {Function} Returns the new capped function.
  15959. * @example
  15960. *
  15961. * _.map(['6', '8', '10'], _.unary(parseInt));
  15962. * // => [6, 8, 10]
  15963. */
  15964. function unary(func) {
  15965. return ary(func, 1);
  15966. }
  15967. /**
  15968. * Creates a function that provides `value` to `wrapper` as its first
  15969. * argument. Any additional arguments provided to the function are appended
  15970. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  15971. * binding of the created function.
  15972. *
  15973. * @static
  15974. * @memberOf _
  15975. * @since 0.1.0
  15976. * @category Function
  15977. * @param {*} value The value to wrap.
  15978. * @param {Function} [wrapper=identity] The wrapper function.
  15979. * @returns {Function} Returns the new function.
  15980. * @example
  15981. *
  15982. * var p = _.wrap(_.escape, function(func, text) {
  15983. * return '<p>' + func(text) + '</p>';
  15984. * });
  15985. *
  15986. * p('fred, barney, & pebbles');
  15987. * // => '<p>fred, barney, &amp; pebbles</p>'
  15988. */
  15989. function wrap(value, wrapper) {
  15990. return partial(castFunction(wrapper), value);
  15991. }
  15992. /*------------------------------------------------------------------------*/
  15993. /**
  15994. * Casts `value` as an array if it's not one.
  15995. *
  15996. * @static
  15997. * @memberOf _
  15998. * @since 4.4.0
  15999. * @category Lang
  16000. * @param {*} value The value to inspect.
  16001. * @returns {Array} Returns the cast array.
  16002. * @example
  16003. *
  16004. * _.castArray(1);
  16005. * // => [1]
  16006. *
  16007. * _.castArray({ 'a': 1 });
  16008. * // => [{ 'a': 1 }]
  16009. *
  16010. * _.castArray('abc');
  16011. * // => ['abc']
  16012. *
  16013. * _.castArray(null);
  16014. * // => [null]
  16015. *
  16016. * _.castArray(undefined);
  16017. * // => [undefined]
  16018. *
  16019. * _.castArray();
  16020. * // => []
  16021. *
  16022. * var array = [1, 2, 3];
  16023. * console.log(_.castArray(array) === array);
  16024. * // => true
  16025. */
  16026. function castArray() {
  16027. if (!arguments.length) {
  16028. return [];
  16029. }
  16030. var value = arguments[0];
  16031. return isArray(value) ? value : [value];
  16032. }
  16033. /**
  16034. * Creates a shallow clone of `value`.
  16035. *
  16036. * **Note:** This method is loosely based on the
  16037. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  16038. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  16039. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  16040. * arrays. The own enumerable properties of `arguments` objects are cloned
  16041. * as plain objects. An empty object is returned for uncloneable values such
  16042. * as error objects, functions, DOM nodes, and WeakMaps.
  16043. *
  16044. * @static
  16045. * @memberOf _
  16046. * @since 0.1.0
  16047. * @category Lang
  16048. * @param {*} value The value to clone.
  16049. * @returns {*} Returns the cloned value.
  16050. * @see _.cloneDeep
  16051. * @example
  16052. *
  16053. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  16054. *
  16055. * var shallow = _.clone(objects);
  16056. * console.log(shallow[0] === objects[0]);
  16057. * // => true
  16058. */
  16059. function clone(value) {
  16060. return baseClone(value, CLONE_SYMBOLS_FLAG);
  16061. }
  16062. /**
  16063. * This method is like `_.clone` except that it accepts `customizer` which
  16064. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  16065. * cloning is handled by the method instead. The `customizer` is invoked with
  16066. * up to four arguments; (value [, index|key, object, stack]).
  16067. *
  16068. * @static
  16069. * @memberOf _
  16070. * @since 4.0.0
  16071. * @category Lang
  16072. * @param {*} value The value to clone.
  16073. * @param {Function} [customizer] The function to customize cloning.
  16074. * @returns {*} Returns the cloned value.
  16075. * @see _.cloneDeepWith
  16076. * @example
  16077. *
  16078. * function customizer(value) {
  16079. * if (_.isElement(value)) {
  16080. * return value.cloneNode(false);
  16081. * }
  16082. * }
  16083. *
  16084. * var el = _.cloneWith(document.body, customizer);
  16085. *
  16086. * console.log(el === document.body);
  16087. * // => false
  16088. * console.log(el.nodeName);
  16089. * // => 'BODY'
  16090. * console.log(el.childNodes.length);
  16091. * // => 0
  16092. */
  16093. function cloneWith(value, customizer) {
  16094. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  16095. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  16096. }
  16097. /**
  16098. * This method is like `_.clone` except that it recursively clones `value`.
  16099. *
  16100. * @static
  16101. * @memberOf _
  16102. * @since 1.0.0
  16103. * @category Lang
  16104. * @param {*} value The value to recursively clone.
  16105. * @returns {*} Returns the deep cloned value.
  16106. * @see _.clone
  16107. * @example
  16108. *
  16109. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  16110. *
  16111. * var deep = _.cloneDeep(objects);
  16112. * console.log(deep[0] === objects[0]);
  16113. * // => false
  16114. */
  16115. function cloneDeep(value) {
  16116. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  16117. }
  16118. /**
  16119. * This method is like `_.cloneWith` except that it recursively clones `value`.
  16120. *
  16121. * @static
  16122. * @memberOf _
  16123. * @since 4.0.0
  16124. * @category Lang
  16125. * @param {*} value The value to recursively clone.
  16126. * @param {Function} [customizer] The function to customize cloning.
  16127. * @returns {*} Returns the deep cloned value.
  16128. * @see _.cloneWith
  16129. * @example
  16130. *
  16131. * function customizer(value) {
  16132. * if (_.isElement(value)) {
  16133. * return value.cloneNode(true);
  16134. * }
  16135. * }
  16136. *
  16137. * var el = _.cloneDeepWith(document.body, customizer);
  16138. *
  16139. * console.log(el === document.body);
  16140. * // => false
  16141. * console.log(el.nodeName);
  16142. * // => 'BODY'
  16143. * console.log(el.childNodes.length);
  16144. * // => 20
  16145. */
  16146. function cloneDeepWith(value, customizer) {
  16147. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  16148. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  16149. }
  16150. /**
  16151. * Checks if `object` conforms to `source` by invoking the predicate
  16152. * properties of `source` with the corresponding property values of `object`.
  16153. *
  16154. * **Note:** This method is equivalent to `_.conforms` when `source` is
  16155. * partially applied.
  16156. *
  16157. * @static
  16158. * @memberOf _
  16159. * @since 4.14.0
  16160. * @category Lang
  16161. * @param {Object} object The object to inspect.
  16162. * @param {Object} source The object of property predicates to conform to.
  16163. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  16164. * @example
  16165. *
  16166. * var object = { 'a': 1, 'b': 2 };
  16167. *
  16168. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  16169. * // => true
  16170. *
  16171. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  16172. * // => false
  16173. */
  16174. function conformsTo(object, source) {
  16175. return source == null || baseConformsTo(object, source, keys(source));
  16176. }
  16177. /**
  16178. * Performs a
  16179. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  16180. * comparison between two values to determine if they are equivalent.
  16181. *
  16182. * @static
  16183. * @memberOf _
  16184. * @since 4.0.0
  16185. * @category Lang
  16186. * @param {*} value The value to compare.
  16187. * @param {*} other The other value to compare.
  16188. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  16189. * @example
  16190. *
  16191. * var object = { 'a': 1 };
  16192. * var other = { 'a': 1 };
  16193. *
  16194. * _.eq(object, object);
  16195. * // => true
  16196. *
  16197. * _.eq(object, other);
  16198. * // => false
  16199. *
  16200. * _.eq('a', 'a');
  16201. * // => true
  16202. *
  16203. * _.eq('a', Object('a'));
  16204. * // => false
  16205. *
  16206. * _.eq(NaN, NaN);
  16207. * // => true
  16208. */
  16209. function eq(value, other) {
  16210. return value === other || (value !== value && other !== other);
  16211. }
  16212. /**
  16213. * Checks if `value` is greater than `other`.
  16214. *
  16215. * @static
  16216. * @memberOf _
  16217. * @since 3.9.0
  16218. * @category Lang
  16219. * @param {*} value The value to compare.
  16220. * @param {*} other The other value to compare.
  16221. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  16222. * else `false`.
  16223. * @see _.lt
  16224. * @example
  16225. *
  16226. * _.gt(3, 1);
  16227. * // => true
  16228. *
  16229. * _.gt(3, 3);
  16230. * // => false
  16231. *
  16232. * _.gt(1, 3);
  16233. * // => false
  16234. */
  16235. var gt = createRelationalOperation(baseGt);
  16236. /**
  16237. * Checks if `value` is greater than or equal to `other`.
  16238. *
  16239. * @static
  16240. * @memberOf _
  16241. * @since 3.9.0
  16242. * @category Lang
  16243. * @param {*} value The value to compare.
  16244. * @param {*} other The other value to compare.
  16245. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  16246. * `other`, else `false`.
  16247. * @see _.lte
  16248. * @example
  16249. *
  16250. * _.gte(3, 1);
  16251. * // => true
  16252. *
  16253. * _.gte(3, 3);
  16254. * // => true
  16255. *
  16256. * _.gte(1, 3);
  16257. * // => false
  16258. */
  16259. var gte = createRelationalOperation(function(value, other) {
  16260. return value >= other;
  16261. });
  16262. /**
  16263. * Checks if `value` is likely an `arguments` object.
  16264. *
  16265. * @static
  16266. * @memberOf _
  16267. * @since 0.1.0
  16268. * @category Lang
  16269. * @param {*} value The value to check.
  16270. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  16271. * else `false`.
  16272. * @example
  16273. *
  16274. * _.isArguments(function() { return arguments; }());
  16275. * // => true
  16276. *
  16277. * _.isArguments([1, 2, 3]);
  16278. * // => false
  16279. */
  16280. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  16281. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  16282. !propertyIsEnumerable.call(value, 'callee');
  16283. };
  16284. /**
  16285. * Checks if `value` is classified as an `Array` object.
  16286. *
  16287. * @static
  16288. * @memberOf _
  16289. * @since 0.1.0
  16290. * @category Lang
  16291. * @param {*} value The value to check.
  16292. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  16293. * @example
  16294. *
  16295. * _.isArray([1, 2, 3]);
  16296. * // => true
  16297. *
  16298. * _.isArray(document.body.children);
  16299. * // => false
  16300. *
  16301. * _.isArray('abc');
  16302. * // => false
  16303. *
  16304. * _.isArray(_.noop);
  16305. * // => false
  16306. */
  16307. var isArray = Array.isArray;
  16308. /**
  16309. * Checks if `value` is classified as an `ArrayBuffer` object.
  16310. *
  16311. * @static
  16312. * @memberOf _
  16313. * @since 4.3.0
  16314. * @category Lang
  16315. * @param {*} value The value to check.
  16316. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  16317. * @example
  16318. *
  16319. * _.isArrayBuffer(new ArrayBuffer(2));
  16320. * // => true
  16321. *
  16322. * _.isArrayBuffer(new Array(2));
  16323. * // => false
  16324. */
  16325. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  16326. /**
  16327. * Checks if `value` is array-like. A value is considered array-like if it's
  16328. * not a function and has a `value.length` that's an integer greater than or
  16329. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  16330. *
  16331. * @static
  16332. * @memberOf _
  16333. * @since 4.0.0
  16334. * @category Lang
  16335. * @param {*} value The value to check.
  16336. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  16337. * @example
  16338. *
  16339. * _.isArrayLike([1, 2, 3]);
  16340. * // => true
  16341. *
  16342. * _.isArrayLike(document.body.children);
  16343. * // => true
  16344. *
  16345. * _.isArrayLike('abc');
  16346. * // => true
  16347. *
  16348. * _.isArrayLike(_.noop);
  16349. * // => false
  16350. */
  16351. function isArrayLike(value) {
  16352. return value != null && isLength(value.length) && !isFunction(value);
  16353. }
  16354. /**
  16355. * This method is like `_.isArrayLike` except that it also checks if `value`
  16356. * is an object.
  16357. *
  16358. * @static
  16359. * @memberOf _
  16360. * @since 4.0.0
  16361. * @category Lang
  16362. * @param {*} value The value to check.
  16363. * @returns {boolean} Returns `true` if `value` is an array-like object,
  16364. * else `false`.
  16365. * @example
  16366. *
  16367. * _.isArrayLikeObject([1, 2, 3]);
  16368. * // => true
  16369. *
  16370. * _.isArrayLikeObject(document.body.children);
  16371. * // => true
  16372. *
  16373. * _.isArrayLikeObject('abc');
  16374. * // => false
  16375. *
  16376. * _.isArrayLikeObject(_.noop);
  16377. * // => false
  16378. */
  16379. function isArrayLikeObject(value) {
  16380. return isObjectLike(value) && isArrayLike(value);
  16381. }
  16382. /**
  16383. * Checks if `value` is classified as a boolean primitive or object.
  16384. *
  16385. * @static
  16386. * @memberOf _
  16387. * @since 0.1.0
  16388. * @category Lang
  16389. * @param {*} value The value to check.
  16390. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  16391. * @example
  16392. *
  16393. * _.isBoolean(false);
  16394. * // => true
  16395. *
  16396. * _.isBoolean(null);
  16397. * // => false
  16398. */
  16399. function isBoolean(value) {
  16400. return value === true || value === false ||
  16401. (isObjectLike(value) && baseGetTag(value) == boolTag);
  16402. }
  16403. /**
  16404. * Checks if `value` is a buffer.
  16405. *
  16406. * @static
  16407. * @memberOf _
  16408. * @since 4.3.0
  16409. * @category Lang
  16410. * @param {*} value The value to check.
  16411. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  16412. * @example
  16413. *
  16414. * _.isBuffer(new Buffer(2));
  16415. * // => true
  16416. *
  16417. * _.isBuffer(new Uint8Array(2));
  16418. * // => false
  16419. */
  16420. var isBuffer = nativeIsBuffer || stubFalse;
  16421. /**
  16422. * Checks if `value` is classified as a `Date` object.
  16423. *
  16424. * @static
  16425. * @memberOf _
  16426. * @since 0.1.0
  16427. * @category Lang
  16428. * @param {*} value The value to check.
  16429. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  16430. * @example
  16431. *
  16432. * _.isDate(new Date);
  16433. * // => true
  16434. *
  16435. * _.isDate('Mon April 23 2012');
  16436. * // => false
  16437. */
  16438. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  16439. /**
  16440. * Checks if `value` is likely a DOM element.
  16441. *
  16442. * @static
  16443. * @memberOf _
  16444. * @since 0.1.0
  16445. * @category Lang
  16446. * @param {*} value The value to check.
  16447. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  16448. * @example
  16449. *
  16450. * _.isElement(document.body);
  16451. * // => true
  16452. *
  16453. * _.isElement('<body>');
  16454. * // => false
  16455. */
  16456. function isElement(value) {
  16457. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  16458. }
  16459. /**
  16460. * Checks if `value` is an empty object, collection, map, or set.
  16461. *
  16462. * Objects are considered empty if they have no own enumerable string keyed
  16463. * properties.
  16464. *
  16465. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  16466. * jQuery-like collections are considered empty if they have a `length` of `0`.
  16467. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  16468. *
  16469. * @static
  16470. * @memberOf _
  16471. * @since 0.1.0
  16472. * @category Lang
  16473. * @param {*} value The value to check.
  16474. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  16475. * @example
  16476. *
  16477. * _.isEmpty(null);
  16478. * // => true
  16479. *
  16480. * _.isEmpty(true);
  16481. * // => true
  16482. *
  16483. * _.isEmpty(1);
  16484. * // => true
  16485. *
  16486. * _.isEmpty([1, 2, 3]);
  16487. * // => false
  16488. *
  16489. * _.isEmpty({ 'a': 1 });
  16490. * // => false
  16491. */
  16492. function isEmpty(value) {
  16493. if (value == null) {
  16494. return true;
  16495. }
  16496. if (isArrayLike(value) &&
  16497. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  16498. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  16499. return !value.length;
  16500. }
  16501. var tag = getTag(value);
  16502. if (tag == mapTag || tag == setTag) {
  16503. return !value.size;
  16504. }
  16505. if (isPrototype(value)) {
  16506. return !baseKeys(value).length;
  16507. }
  16508. for (var key in value) {
  16509. if (hasOwnProperty.call(value, key)) {
  16510. return false;
  16511. }
  16512. }
  16513. return true;
  16514. }
  16515. /**
  16516. * Performs a deep comparison between two values to determine if they are
  16517. * equivalent.
  16518. *
  16519. * **Note:** This method supports comparing arrays, array buffers, booleans,
  16520. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  16521. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  16522. * by their own, not inherited, enumerable properties. Functions and DOM
  16523. * nodes are compared by strict equality, i.e. `===`.
  16524. *
  16525. * @static
  16526. * @memberOf _
  16527. * @since 0.1.0
  16528. * @category Lang
  16529. * @param {*} value The value to compare.
  16530. * @param {*} other The other value to compare.
  16531. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  16532. * @example
  16533. *
  16534. * var object = { 'a': 1 };
  16535. * var other = { 'a': 1 };
  16536. *
  16537. * _.isEqual(object, other);
  16538. * // => true
  16539. *
  16540. * object === other;
  16541. * // => false
  16542. */
  16543. function isEqual(value, other) {
  16544. return baseIsEqual(value, other);
  16545. }
  16546. /**
  16547. * This method is like `_.isEqual` except that it accepts `customizer` which
  16548. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  16549. * are handled by the method instead. The `customizer` is invoked with up to
  16550. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  16551. *
  16552. * @static
  16553. * @memberOf _
  16554. * @since 4.0.0
  16555. * @category Lang
  16556. * @param {*} value The value to compare.
  16557. * @param {*} other The other value to compare.
  16558. * @param {Function} [customizer] The function to customize comparisons.
  16559. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  16560. * @example
  16561. *
  16562. * function isGreeting(value) {
  16563. * return /^h(?:i|ello)$/.test(value);
  16564. * }
  16565. *
  16566. * function customizer(objValue, othValue) {
  16567. * if (isGreeting(objValue) && isGreeting(othValue)) {
  16568. * return true;
  16569. * }
  16570. * }
  16571. *
  16572. * var array = ['hello', 'goodbye'];
  16573. * var other = ['hi', 'goodbye'];
  16574. *
  16575. * _.isEqualWith(array, other, customizer);
  16576. * // => true
  16577. */
  16578. function isEqualWith(value, other, customizer) {
  16579. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  16580. var result = customizer ? customizer(value, other) : undefined$1;
  16581. return result === undefined$1 ? baseIsEqual(value, other, undefined$1, customizer) : !!result;
  16582. }
  16583. /**
  16584. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  16585. * `SyntaxError`, `TypeError`, or `URIError` object.
  16586. *
  16587. * @static
  16588. * @memberOf _
  16589. * @since 3.0.0
  16590. * @category Lang
  16591. * @param {*} value The value to check.
  16592. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  16593. * @example
  16594. *
  16595. * _.isError(new Error);
  16596. * // => true
  16597. *
  16598. * _.isError(Error);
  16599. * // => false
  16600. */
  16601. function isError(value) {
  16602. if (!isObjectLike(value)) {
  16603. return false;
  16604. }
  16605. var tag = baseGetTag(value);
  16606. return tag == errorTag || tag == domExcTag ||
  16607. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  16608. }
  16609. /**
  16610. * Checks if `value` is a finite primitive number.
  16611. *
  16612. * **Note:** This method is based on
  16613. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  16614. *
  16615. * @static
  16616. * @memberOf _
  16617. * @since 0.1.0
  16618. * @category Lang
  16619. * @param {*} value The value to check.
  16620. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  16621. * @example
  16622. *
  16623. * _.isFinite(3);
  16624. * // => true
  16625. *
  16626. * _.isFinite(Number.MIN_VALUE);
  16627. * // => true
  16628. *
  16629. * _.isFinite(Infinity);
  16630. * // => false
  16631. *
  16632. * _.isFinite('3');
  16633. * // => false
  16634. */
  16635. function isFinite(value) {
  16636. return typeof value == 'number' && nativeIsFinite(value);
  16637. }
  16638. /**
  16639. * Checks if `value` is classified as a `Function` object.
  16640. *
  16641. * @static
  16642. * @memberOf _
  16643. * @since 0.1.0
  16644. * @category Lang
  16645. * @param {*} value The value to check.
  16646. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  16647. * @example
  16648. *
  16649. * _.isFunction(_);
  16650. * // => true
  16651. *
  16652. * _.isFunction(/abc/);
  16653. * // => false
  16654. */
  16655. function isFunction(value) {
  16656. if (!isObject(value)) {
  16657. return false;
  16658. }
  16659. // The use of `Object#toString` avoids issues with the `typeof` operator
  16660. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  16661. var tag = baseGetTag(value);
  16662. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  16663. }
  16664. /**
  16665. * Checks if `value` is an integer.
  16666. *
  16667. * **Note:** This method is based on
  16668. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  16669. *
  16670. * @static
  16671. * @memberOf _
  16672. * @since 4.0.0
  16673. * @category Lang
  16674. * @param {*} value The value to check.
  16675. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  16676. * @example
  16677. *
  16678. * _.isInteger(3);
  16679. * // => true
  16680. *
  16681. * _.isInteger(Number.MIN_VALUE);
  16682. * // => false
  16683. *
  16684. * _.isInteger(Infinity);
  16685. * // => false
  16686. *
  16687. * _.isInteger('3');
  16688. * // => false
  16689. */
  16690. function isInteger(value) {
  16691. return typeof value == 'number' && value == toInteger(value);
  16692. }
  16693. /**
  16694. * Checks if `value` is a valid array-like length.
  16695. *
  16696. * **Note:** This method is loosely based on
  16697. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  16698. *
  16699. * @static
  16700. * @memberOf _
  16701. * @since 4.0.0
  16702. * @category Lang
  16703. * @param {*} value The value to check.
  16704. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  16705. * @example
  16706. *
  16707. * _.isLength(3);
  16708. * // => true
  16709. *
  16710. * _.isLength(Number.MIN_VALUE);
  16711. * // => false
  16712. *
  16713. * _.isLength(Infinity);
  16714. * // => false
  16715. *
  16716. * _.isLength('3');
  16717. * // => false
  16718. */
  16719. function isLength(value) {
  16720. return typeof value == 'number' &&
  16721. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  16722. }
  16723. /**
  16724. * Checks if `value` is the
  16725. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  16726. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  16727. *
  16728. * @static
  16729. * @memberOf _
  16730. * @since 0.1.0
  16731. * @category Lang
  16732. * @param {*} value The value to check.
  16733. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  16734. * @example
  16735. *
  16736. * _.isObject({});
  16737. * // => true
  16738. *
  16739. * _.isObject([1, 2, 3]);
  16740. * // => true
  16741. *
  16742. * _.isObject(_.noop);
  16743. * // => true
  16744. *
  16745. * _.isObject(null);
  16746. * // => false
  16747. */
  16748. function isObject(value) {
  16749. var type = typeof value;
  16750. return value != null && (type == 'object' || type == 'function');
  16751. }
  16752. /**
  16753. * Checks if `value` is object-like. A value is object-like if it's not `null`
  16754. * and has a `typeof` result of "object".
  16755. *
  16756. * @static
  16757. * @memberOf _
  16758. * @since 4.0.0
  16759. * @category Lang
  16760. * @param {*} value The value to check.
  16761. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  16762. * @example
  16763. *
  16764. * _.isObjectLike({});
  16765. * // => true
  16766. *
  16767. * _.isObjectLike([1, 2, 3]);
  16768. * // => true
  16769. *
  16770. * _.isObjectLike(_.noop);
  16771. * // => false
  16772. *
  16773. * _.isObjectLike(null);
  16774. * // => false
  16775. */
  16776. function isObjectLike(value) {
  16777. return value != null && typeof value == 'object';
  16778. }
  16779. /**
  16780. * Checks if `value` is classified as a `Map` object.
  16781. *
  16782. * @static
  16783. * @memberOf _
  16784. * @since 4.3.0
  16785. * @category Lang
  16786. * @param {*} value The value to check.
  16787. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  16788. * @example
  16789. *
  16790. * _.isMap(new Map);
  16791. * // => true
  16792. *
  16793. * _.isMap(new WeakMap);
  16794. * // => false
  16795. */
  16796. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  16797. /**
  16798. * Performs a partial deep comparison between `object` and `source` to
  16799. * determine if `object` contains equivalent property values.
  16800. *
  16801. * **Note:** This method is equivalent to `_.matches` when `source` is
  16802. * partially applied.
  16803. *
  16804. * Partial comparisons will match empty array and empty object `source`
  16805. * values against any array or object value, respectively. See `_.isEqual`
  16806. * for a list of supported value comparisons.
  16807. *
  16808. * @static
  16809. * @memberOf _
  16810. * @since 3.0.0
  16811. * @category Lang
  16812. * @param {Object} object The object to inspect.
  16813. * @param {Object} source The object of property values to match.
  16814. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  16815. * @example
  16816. *
  16817. * var object = { 'a': 1, 'b': 2 };
  16818. *
  16819. * _.isMatch(object, { 'b': 2 });
  16820. * // => true
  16821. *
  16822. * _.isMatch(object, { 'b': 1 });
  16823. * // => false
  16824. */
  16825. function isMatch(object, source) {
  16826. return object === source || baseIsMatch(object, source, getMatchData(source));
  16827. }
  16828. /**
  16829. * This method is like `_.isMatch` except that it accepts `customizer` which
  16830. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  16831. * are handled by the method instead. The `customizer` is invoked with five
  16832. * arguments: (objValue, srcValue, index|key, object, source).
  16833. *
  16834. * @static
  16835. * @memberOf _
  16836. * @since 4.0.0
  16837. * @category Lang
  16838. * @param {Object} object The object to inspect.
  16839. * @param {Object} source The object of property values to match.
  16840. * @param {Function} [customizer] The function to customize comparisons.
  16841. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  16842. * @example
  16843. *
  16844. * function isGreeting(value) {
  16845. * return /^h(?:i|ello)$/.test(value);
  16846. * }
  16847. *
  16848. * function customizer(objValue, srcValue) {
  16849. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  16850. * return true;
  16851. * }
  16852. * }
  16853. *
  16854. * var object = { 'greeting': 'hello' };
  16855. * var source = { 'greeting': 'hi' };
  16856. *
  16857. * _.isMatchWith(object, source, customizer);
  16858. * // => true
  16859. */
  16860. function isMatchWith(object, source, customizer) {
  16861. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  16862. return baseIsMatch(object, source, getMatchData(source), customizer);
  16863. }
  16864. /**
  16865. * Checks if `value` is `NaN`.
  16866. *
  16867. * **Note:** This method is based on
  16868. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  16869. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  16870. * `undefined` and other non-number values.
  16871. *
  16872. * @static
  16873. * @memberOf _
  16874. * @since 0.1.0
  16875. * @category Lang
  16876. * @param {*} value The value to check.
  16877. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  16878. * @example
  16879. *
  16880. * _.isNaN(NaN);
  16881. * // => true
  16882. *
  16883. * _.isNaN(new Number(NaN));
  16884. * // => true
  16885. *
  16886. * isNaN(undefined);
  16887. * // => true
  16888. *
  16889. * _.isNaN(undefined);
  16890. * // => false
  16891. */
  16892. function isNaN(value) {
  16893. // An `NaN` primitive is the only value that is not equal to itself.
  16894. // Perform the `toStringTag` check first to avoid errors with some
  16895. // ActiveX objects in IE.
  16896. return isNumber(value) && value != +value;
  16897. }
  16898. /**
  16899. * Checks if `value` is a pristine native function.
  16900. *
  16901. * **Note:** This method can't reliably detect native functions in the presence
  16902. * of the core-js package because core-js circumvents this kind of detection.
  16903. * Despite multiple requests, the core-js maintainer has made it clear: any
  16904. * attempt to fix the detection will be obstructed. As a result, we're left
  16905. * with little choice but to throw an error. Unfortunately, this also affects
  16906. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  16907. * which rely on core-js.
  16908. *
  16909. * @static
  16910. * @memberOf _
  16911. * @since 3.0.0
  16912. * @category Lang
  16913. * @param {*} value The value to check.
  16914. * @returns {boolean} Returns `true` if `value` is a native function,
  16915. * else `false`.
  16916. * @example
  16917. *
  16918. * _.isNative(Array.prototype.push);
  16919. * // => true
  16920. *
  16921. * _.isNative(_);
  16922. * // => false
  16923. */
  16924. function isNative(value) {
  16925. if (isMaskable(value)) {
  16926. throw new Error(CORE_ERROR_TEXT);
  16927. }
  16928. return baseIsNative(value);
  16929. }
  16930. /**
  16931. * Checks if `value` is `null`.
  16932. *
  16933. * @static
  16934. * @memberOf _
  16935. * @since 0.1.0
  16936. * @category Lang
  16937. * @param {*} value The value to check.
  16938. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  16939. * @example
  16940. *
  16941. * _.isNull(null);
  16942. * // => true
  16943. *
  16944. * _.isNull(void 0);
  16945. * // => false
  16946. */
  16947. function isNull(value) {
  16948. return value === null;
  16949. }
  16950. /**
  16951. * Checks if `value` is `null` or `undefined`.
  16952. *
  16953. * @static
  16954. * @memberOf _
  16955. * @since 4.0.0
  16956. * @category Lang
  16957. * @param {*} value The value to check.
  16958. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  16959. * @example
  16960. *
  16961. * _.isNil(null);
  16962. * // => true
  16963. *
  16964. * _.isNil(void 0);
  16965. * // => true
  16966. *
  16967. * _.isNil(NaN);
  16968. * // => false
  16969. */
  16970. function isNil(value) {
  16971. return value == null;
  16972. }
  16973. /**
  16974. * Checks if `value` is classified as a `Number` primitive or object.
  16975. *
  16976. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  16977. * classified as numbers, use the `_.isFinite` method.
  16978. *
  16979. * @static
  16980. * @memberOf _
  16981. * @since 0.1.0
  16982. * @category Lang
  16983. * @param {*} value The value to check.
  16984. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  16985. * @example
  16986. *
  16987. * _.isNumber(3);
  16988. * // => true
  16989. *
  16990. * _.isNumber(Number.MIN_VALUE);
  16991. * // => true
  16992. *
  16993. * _.isNumber(Infinity);
  16994. * // => true
  16995. *
  16996. * _.isNumber('3');
  16997. * // => false
  16998. */
  16999. function isNumber(value) {
  17000. return typeof value == 'number' ||
  17001. (isObjectLike(value) && baseGetTag(value) == numberTag);
  17002. }
  17003. /**
  17004. * Checks if `value` is a plain object, that is, an object created by the
  17005. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  17006. *
  17007. * @static
  17008. * @memberOf _
  17009. * @since 0.8.0
  17010. * @category Lang
  17011. * @param {*} value The value to check.
  17012. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  17013. * @example
  17014. *
  17015. * function Foo() {
  17016. * this.a = 1;
  17017. * }
  17018. *
  17019. * _.isPlainObject(new Foo);
  17020. * // => false
  17021. *
  17022. * _.isPlainObject([1, 2, 3]);
  17023. * // => false
  17024. *
  17025. * _.isPlainObject({ 'x': 0, 'y': 0 });
  17026. * // => true
  17027. *
  17028. * _.isPlainObject(Object.create(null));
  17029. * // => true
  17030. */
  17031. function isPlainObject(value) {
  17032. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  17033. return false;
  17034. }
  17035. var proto = getPrototype(value);
  17036. if (proto === null) {
  17037. return true;
  17038. }
  17039. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  17040. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  17041. funcToString.call(Ctor) == objectCtorString;
  17042. }
  17043. /**
  17044. * Checks if `value` is classified as a `RegExp` object.
  17045. *
  17046. * @static
  17047. * @memberOf _
  17048. * @since 0.1.0
  17049. * @category Lang
  17050. * @param {*} value The value to check.
  17051. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  17052. * @example
  17053. *
  17054. * _.isRegExp(/abc/);
  17055. * // => true
  17056. *
  17057. * _.isRegExp('/abc/');
  17058. * // => false
  17059. */
  17060. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  17061. /**
  17062. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  17063. * double precision number which isn't the result of a rounded unsafe integer.
  17064. *
  17065. * **Note:** This method is based on
  17066. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  17067. *
  17068. * @static
  17069. * @memberOf _
  17070. * @since 4.0.0
  17071. * @category Lang
  17072. * @param {*} value The value to check.
  17073. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  17074. * @example
  17075. *
  17076. * _.isSafeInteger(3);
  17077. * // => true
  17078. *
  17079. * _.isSafeInteger(Number.MIN_VALUE);
  17080. * // => false
  17081. *
  17082. * _.isSafeInteger(Infinity);
  17083. * // => false
  17084. *
  17085. * _.isSafeInteger('3');
  17086. * // => false
  17087. */
  17088. function isSafeInteger(value) {
  17089. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  17090. }
  17091. /**
  17092. * Checks if `value` is classified as a `Set` object.
  17093. *
  17094. * @static
  17095. * @memberOf _
  17096. * @since 4.3.0
  17097. * @category Lang
  17098. * @param {*} value The value to check.
  17099. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  17100. * @example
  17101. *
  17102. * _.isSet(new Set);
  17103. * // => true
  17104. *
  17105. * _.isSet(new WeakSet);
  17106. * // => false
  17107. */
  17108. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  17109. /**
  17110. * Checks if `value` is classified as a `String` primitive or object.
  17111. *
  17112. * @static
  17113. * @since 0.1.0
  17114. * @memberOf _
  17115. * @category Lang
  17116. * @param {*} value The value to check.
  17117. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  17118. * @example
  17119. *
  17120. * _.isString('abc');
  17121. * // => true
  17122. *
  17123. * _.isString(1);
  17124. * // => false
  17125. */
  17126. function isString(value) {
  17127. return typeof value == 'string' ||
  17128. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  17129. }
  17130. /**
  17131. * Checks if `value` is classified as a `Symbol` primitive or object.
  17132. *
  17133. * @static
  17134. * @memberOf _
  17135. * @since 4.0.0
  17136. * @category Lang
  17137. * @param {*} value The value to check.
  17138. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  17139. * @example
  17140. *
  17141. * _.isSymbol(Symbol.iterator);
  17142. * // => true
  17143. *
  17144. * _.isSymbol('abc');
  17145. * // => false
  17146. */
  17147. function isSymbol(value) {
  17148. return typeof value == 'symbol' ||
  17149. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  17150. }
  17151. /**
  17152. * Checks if `value` is classified as a typed array.
  17153. *
  17154. * @static
  17155. * @memberOf _
  17156. * @since 3.0.0
  17157. * @category Lang
  17158. * @param {*} value The value to check.
  17159. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  17160. * @example
  17161. *
  17162. * _.isTypedArray(new Uint8Array);
  17163. * // => true
  17164. *
  17165. * _.isTypedArray([]);
  17166. * // => false
  17167. */
  17168. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  17169. /**
  17170. * Checks if `value` is `undefined`.
  17171. *
  17172. * @static
  17173. * @since 0.1.0
  17174. * @memberOf _
  17175. * @category Lang
  17176. * @param {*} value The value to check.
  17177. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  17178. * @example
  17179. *
  17180. * _.isUndefined(void 0);
  17181. * // => true
  17182. *
  17183. * _.isUndefined(null);
  17184. * // => false
  17185. */
  17186. function isUndefined(value) {
  17187. return value === undefined$1;
  17188. }
  17189. /**
  17190. * Checks if `value` is classified as a `WeakMap` object.
  17191. *
  17192. * @static
  17193. * @memberOf _
  17194. * @since 4.3.0
  17195. * @category Lang
  17196. * @param {*} value The value to check.
  17197. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  17198. * @example
  17199. *
  17200. * _.isWeakMap(new WeakMap);
  17201. * // => true
  17202. *
  17203. * _.isWeakMap(new Map);
  17204. * // => false
  17205. */
  17206. function isWeakMap(value) {
  17207. return isObjectLike(value) && getTag(value) == weakMapTag;
  17208. }
  17209. /**
  17210. * Checks if `value` is classified as a `WeakSet` object.
  17211. *
  17212. * @static
  17213. * @memberOf _
  17214. * @since 4.3.0
  17215. * @category Lang
  17216. * @param {*} value The value to check.
  17217. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  17218. * @example
  17219. *
  17220. * _.isWeakSet(new WeakSet);
  17221. * // => true
  17222. *
  17223. * _.isWeakSet(new Set);
  17224. * // => false
  17225. */
  17226. function isWeakSet(value) {
  17227. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  17228. }
  17229. /**
  17230. * Checks if `value` is less than `other`.
  17231. *
  17232. * @static
  17233. * @memberOf _
  17234. * @since 3.9.0
  17235. * @category Lang
  17236. * @param {*} value The value to compare.
  17237. * @param {*} other The other value to compare.
  17238. * @returns {boolean} Returns `true` if `value` is less than `other`,
  17239. * else `false`.
  17240. * @see _.gt
  17241. * @example
  17242. *
  17243. * _.lt(1, 3);
  17244. * // => true
  17245. *
  17246. * _.lt(3, 3);
  17247. * // => false
  17248. *
  17249. * _.lt(3, 1);
  17250. * // => false
  17251. */
  17252. var lt = createRelationalOperation(baseLt);
  17253. /**
  17254. * Checks if `value` is less than or equal to `other`.
  17255. *
  17256. * @static
  17257. * @memberOf _
  17258. * @since 3.9.0
  17259. * @category Lang
  17260. * @param {*} value The value to compare.
  17261. * @param {*} other The other value to compare.
  17262. * @returns {boolean} Returns `true` if `value` is less than or equal to
  17263. * `other`, else `false`.
  17264. * @see _.gte
  17265. * @example
  17266. *
  17267. * _.lte(1, 3);
  17268. * // => true
  17269. *
  17270. * _.lte(3, 3);
  17271. * // => true
  17272. *
  17273. * _.lte(3, 1);
  17274. * // => false
  17275. */
  17276. var lte = createRelationalOperation(function(value, other) {
  17277. return value <= other;
  17278. });
  17279. /**
  17280. * Converts `value` to an array.
  17281. *
  17282. * @static
  17283. * @since 0.1.0
  17284. * @memberOf _
  17285. * @category Lang
  17286. * @param {*} value The value to convert.
  17287. * @returns {Array} Returns the converted array.
  17288. * @example
  17289. *
  17290. * _.toArray({ 'a': 1, 'b': 2 });
  17291. * // => [1, 2]
  17292. *
  17293. * _.toArray('abc');
  17294. * // => ['a', 'b', 'c']
  17295. *
  17296. * _.toArray(1);
  17297. * // => []
  17298. *
  17299. * _.toArray(null);
  17300. * // => []
  17301. */
  17302. function toArray(value) {
  17303. if (!value) {
  17304. return [];
  17305. }
  17306. if (isArrayLike(value)) {
  17307. return isString(value) ? stringToArray(value) : copyArray(value);
  17308. }
  17309. if (symIterator && value[symIterator]) {
  17310. return iteratorToArray(value[symIterator]());
  17311. }
  17312. var tag = getTag(value),
  17313. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  17314. return func(value);
  17315. }
  17316. /**
  17317. * Converts `value` to a finite number.
  17318. *
  17319. * @static
  17320. * @memberOf _
  17321. * @since 4.12.0
  17322. * @category Lang
  17323. * @param {*} value The value to convert.
  17324. * @returns {number} Returns the converted number.
  17325. * @example
  17326. *
  17327. * _.toFinite(3.2);
  17328. * // => 3.2
  17329. *
  17330. * _.toFinite(Number.MIN_VALUE);
  17331. * // => 5e-324
  17332. *
  17333. * _.toFinite(Infinity);
  17334. * // => 1.7976931348623157e+308
  17335. *
  17336. * _.toFinite('3.2');
  17337. * // => 3.2
  17338. */
  17339. function toFinite(value) {
  17340. if (!value) {
  17341. return value === 0 ? value : 0;
  17342. }
  17343. value = toNumber(value);
  17344. if (value === INFINITY || value === -INFINITY) {
  17345. var sign = (value < 0 ? -1 : 1);
  17346. return sign * MAX_INTEGER;
  17347. }
  17348. return value === value ? value : 0;
  17349. }
  17350. /**
  17351. * Converts `value` to an integer.
  17352. *
  17353. * **Note:** This method is loosely based on
  17354. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  17355. *
  17356. * @static
  17357. * @memberOf _
  17358. * @since 4.0.0
  17359. * @category Lang
  17360. * @param {*} value The value to convert.
  17361. * @returns {number} Returns the converted integer.
  17362. * @example
  17363. *
  17364. * _.toInteger(3.2);
  17365. * // => 3
  17366. *
  17367. * _.toInteger(Number.MIN_VALUE);
  17368. * // => 0
  17369. *
  17370. * _.toInteger(Infinity);
  17371. * // => 1.7976931348623157e+308
  17372. *
  17373. * _.toInteger('3.2');
  17374. * // => 3
  17375. */
  17376. function toInteger(value) {
  17377. var result = toFinite(value),
  17378. remainder = result % 1;
  17379. return result === result ? (remainder ? result - remainder : result) : 0;
  17380. }
  17381. /**
  17382. * Converts `value` to an integer suitable for use as the length of an
  17383. * array-like object.
  17384. *
  17385. * **Note:** This method is based on
  17386. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  17387. *
  17388. * @static
  17389. * @memberOf _
  17390. * @since 4.0.0
  17391. * @category Lang
  17392. * @param {*} value The value to convert.
  17393. * @returns {number} Returns the converted integer.
  17394. * @example
  17395. *
  17396. * _.toLength(3.2);
  17397. * // => 3
  17398. *
  17399. * _.toLength(Number.MIN_VALUE);
  17400. * // => 0
  17401. *
  17402. * _.toLength(Infinity);
  17403. * // => 4294967295
  17404. *
  17405. * _.toLength('3.2');
  17406. * // => 3
  17407. */
  17408. function toLength(value) {
  17409. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  17410. }
  17411. /**
  17412. * Converts `value` to a number.
  17413. *
  17414. * @static
  17415. * @memberOf _
  17416. * @since 4.0.0
  17417. * @category Lang
  17418. * @param {*} value The value to process.
  17419. * @returns {number} Returns the number.
  17420. * @example
  17421. *
  17422. * _.toNumber(3.2);
  17423. * // => 3.2
  17424. *
  17425. * _.toNumber(Number.MIN_VALUE);
  17426. * // => 5e-324
  17427. *
  17428. * _.toNumber(Infinity);
  17429. * // => Infinity
  17430. *
  17431. * _.toNumber('3.2');
  17432. * // => 3.2
  17433. */
  17434. function toNumber(value) {
  17435. if (typeof value == 'number') {
  17436. return value;
  17437. }
  17438. if (isSymbol(value)) {
  17439. return NAN;
  17440. }
  17441. if (isObject(value)) {
  17442. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  17443. value = isObject(other) ? (other + '') : other;
  17444. }
  17445. if (typeof value != 'string') {
  17446. return value === 0 ? value : +value;
  17447. }
  17448. value = baseTrim(value);
  17449. var isBinary = reIsBinary.test(value);
  17450. return (isBinary || reIsOctal.test(value))
  17451. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  17452. : (reIsBadHex.test(value) ? NAN : +value);
  17453. }
  17454. /**
  17455. * Converts `value` to a plain object flattening inherited enumerable string
  17456. * keyed properties of `value` to own properties of the plain object.
  17457. *
  17458. * @static
  17459. * @memberOf _
  17460. * @since 3.0.0
  17461. * @category Lang
  17462. * @param {*} value The value to convert.
  17463. * @returns {Object} Returns the converted plain object.
  17464. * @example
  17465. *
  17466. * function Foo() {
  17467. * this.b = 2;
  17468. * }
  17469. *
  17470. * Foo.prototype.c = 3;
  17471. *
  17472. * _.assign({ 'a': 1 }, new Foo);
  17473. * // => { 'a': 1, 'b': 2 }
  17474. *
  17475. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  17476. * // => { 'a': 1, 'b': 2, 'c': 3 }
  17477. */
  17478. function toPlainObject(value) {
  17479. return copyObject(value, keysIn(value));
  17480. }
  17481. /**
  17482. * Converts `value` to a safe integer. A safe integer can be compared and
  17483. * represented correctly.
  17484. *
  17485. * @static
  17486. * @memberOf _
  17487. * @since 4.0.0
  17488. * @category Lang
  17489. * @param {*} value The value to convert.
  17490. * @returns {number} Returns the converted integer.
  17491. * @example
  17492. *
  17493. * _.toSafeInteger(3.2);
  17494. * // => 3
  17495. *
  17496. * _.toSafeInteger(Number.MIN_VALUE);
  17497. * // => 0
  17498. *
  17499. * _.toSafeInteger(Infinity);
  17500. * // => 9007199254740991
  17501. *
  17502. * _.toSafeInteger('3.2');
  17503. * // => 3
  17504. */
  17505. function toSafeInteger(value) {
  17506. return value
  17507. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  17508. : (value === 0 ? value : 0);
  17509. }
  17510. /**
  17511. * Converts `value` to a string. An empty string is returned for `null`
  17512. * and `undefined` values. The sign of `-0` is preserved.
  17513. *
  17514. * @static
  17515. * @memberOf _
  17516. * @since 4.0.0
  17517. * @category Lang
  17518. * @param {*} value The value to convert.
  17519. * @returns {string} Returns the converted string.
  17520. * @example
  17521. *
  17522. * _.toString(null);
  17523. * // => ''
  17524. *
  17525. * _.toString(-0);
  17526. * // => '-0'
  17527. *
  17528. * _.toString([1, 2, 3]);
  17529. * // => '1,2,3'
  17530. */
  17531. function toString(value) {
  17532. return value == null ? '' : baseToString(value);
  17533. }
  17534. /*------------------------------------------------------------------------*/
  17535. /**
  17536. * Assigns own enumerable string keyed properties of source objects to the
  17537. * destination object. Source objects are applied from left to right.
  17538. * Subsequent sources overwrite property assignments of previous sources.
  17539. *
  17540. * **Note:** This method mutates `object` and is loosely based on
  17541. * [`Object.assign`](https://mdn.io/Object/assign).
  17542. *
  17543. * @static
  17544. * @memberOf _
  17545. * @since 0.10.0
  17546. * @category Object
  17547. * @param {Object} object The destination object.
  17548. * @param {...Object} [sources] The source objects.
  17549. * @returns {Object} Returns `object`.
  17550. * @see _.assignIn
  17551. * @example
  17552. *
  17553. * function Foo() {
  17554. * this.a = 1;
  17555. * }
  17556. *
  17557. * function Bar() {
  17558. * this.c = 3;
  17559. * }
  17560. *
  17561. * Foo.prototype.b = 2;
  17562. * Bar.prototype.d = 4;
  17563. *
  17564. * _.assign({ 'a': 0 }, new Foo, new Bar);
  17565. * // => { 'a': 1, 'c': 3 }
  17566. */
  17567. var assign = createAssigner(function(object, source) {
  17568. if (isPrototype(source) || isArrayLike(source)) {
  17569. copyObject(source, keys(source), object);
  17570. return;
  17571. }
  17572. for (var key in source) {
  17573. if (hasOwnProperty.call(source, key)) {
  17574. assignValue(object, key, source[key]);
  17575. }
  17576. }
  17577. });
  17578. /**
  17579. * This method is like `_.assign` except that it iterates over own and
  17580. * inherited source properties.
  17581. *
  17582. * **Note:** This method mutates `object`.
  17583. *
  17584. * @static
  17585. * @memberOf _
  17586. * @since 4.0.0
  17587. * @alias extend
  17588. * @category Object
  17589. * @param {Object} object The destination object.
  17590. * @param {...Object} [sources] The source objects.
  17591. * @returns {Object} Returns `object`.
  17592. * @see _.assign
  17593. * @example
  17594. *
  17595. * function Foo() {
  17596. * this.a = 1;
  17597. * }
  17598. *
  17599. * function Bar() {
  17600. * this.c = 3;
  17601. * }
  17602. *
  17603. * Foo.prototype.b = 2;
  17604. * Bar.prototype.d = 4;
  17605. *
  17606. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  17607. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  17608. */
  17609. var assignIn = createAssigner(function(object, source) {
  17610. copyObject(source, keysIn(source), object);
  17611. });
  17612. /**
  17613. * This method is like `_.assignIn` except that it accepts `customizer`
  17614. * which is invoked to produce the assigned values. If `customizer` returns
  17615. * `undefined`, assignment is handled by the method instead. The `customizer`
  17616. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  17617. *
  17618. * **Note:** This method mutates `object`.
  17619. *
  17620. * @static
  17621. * @memberOf _
  17622. * @since 4.0.0
  17623. * @alias extendWith
  17624. * @category Object
  17625. * @param {Object} object The destination object.
  17626. * @param {...Object} sources The source objects.
  17627. * @param {Function} [customizer] The function to customize assigned values.
  17628. * @returns {Object} Returns `object`.
  17629. * @see _.assignWith
  17630. * @example
  17631. *
  17632. * function customizer(objValue, srcValue) {
  17633. * return _.isUndefined(objValue) ? srcValue : objValue;
  17634. * }
  17635. *
  17636. * var defaults = _.partialRight(_.assignInWith, customizer);
  17637. *
  17638. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  17639. * // => { 'a': 1, 'b': 2 }
  17640. */
  17641. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  17642. copyObject(source, keysIn(source), object, customizer);
  17643. });
  17644. /**
  17645. * This method is like `_.assign` except that it accepts `customizer`
  17646. * which is invoked to produce the assigned values. If `customizer` returns
  17647. * `undefined`, assignment is handled by the method instead. The `customizer`
  17648. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  17649. *
  17650. * **Note:** This method mutates `object`.
  17651. *
  17652. * @static
  17653. * @memberOf _
  17654. * @since 4.0.0
  17655. * @category Object
  17656. * @param {Object} object The destination object.
  17657. * @param {...Object} sources The source objects.
  17658. * @param {Function} [customizer] The function to customize assigned values.
  17659. * @returns {Object} Returns `object`.
  17660. * @see _.assignInWith
  17661. * @example
  17662. *
  17663. * function customizer(objValue, srcValue) {
  17664. * return _.isUndefined(objValue) ? srcValue : objValue;
  17665. * }
  17666. *
  17667. * var defaults = _.partialRight(_.assignWith, customizer);
  17668. *
  17669. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  17670. * // => { 'a': 1, 'b': 2 }
  17671. */
  17672. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  17673. copyObject(source, keys(source), object, customizer);
  17674. });
  17675. /**
  17676. * Creates an array of values corresponding to `paths` of `object`.
  17677. *
  17678. * @static
  17679. * @memberOf _
  17680. * @since 1.0.0
  17681. * @category Object
  17682. * @param {Object} object The object to iterate over.
  17683. * @param {...(string|string[])} [paths] The property paths to pick.
  17684. * @returns {Array} Returns the picked values.
  17685. * @example
  17686. *
  17687. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  17688. *
  17689. * _.at(object, ['a[0].b.c', 'a[1]']);
  17690. * // => [3, 4]
  17691. */
  17692. var at = flatRest(baseAt);
  17693. /**
  17694. * Creates an object that inherits from the `prototype` object. If a
  17695. * `properties` object is given, its own enumerable string keyed properties
  17696. * are assigned to the created object.
  17697. *
  17698. * @static
  17699. * @memberOf _
  17700. * @since 2.3.0
  17701. * @category Object
  17702. * @param {Object} prototype The object to inherit from.
  17703. * @param {Object} [properties] The properties to assign to the object.
  17704. * @returns {Object} Returns the new object.
  17705. * @example
  17706. *
  17707. * function Shape() {
  17708. * this.x = 0;
  17709. * this.y = 0;
  17710. * }
  17711. *
  17712. * function Circle() {
  17713. * Shape.call(this);
  17714. * }
  17715. *
  17716. * Circle.prototype = _.create(Shape.prototype, {
  17717. * 'constructor': Circle
  17718. * });
  17719. *
  17720. * var circle = new Circle;
  17721. * circle instanceof Circle;
  17722. * // => true
  17723. *
  17724. * circle instanceof Shape;
  17725. * // => true
  17726. */
  17727. function create(prototype, properties) {
  17728. var result = baseCreate(prototype);
  17729. return properties == null ? result : baseAssign(result, properties);
  17730. }
  17731. /**
  17732. * Assigns own and inherited enumerable string keyed properties of source
  17733. * objects to the destination object for all destination properties that
  17734. * resolve to `undefined`. Source objects are applied from left to right.
  17735. * Once a property is set, additional values of the same property are ignored.
  17736. *
  17737. * **Note:** This method mutates `object`.
  17738. *
  17739. * @static
  17740. * @since 0.1.0
  17741. * @memberOf _
  17742. * @category Object
  17743. * @param {Object} object The destination object.
  17744. * @param {...Object} [sources] The source objects.
  17745. * @returns {Object} Returns `object`.
  17746. * @see _.defaultsDeep
  17747. * @example
  17748. *
  17749. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  17750. * // => { 'a': 1, 'b': 2 }
  17751. */
  17752. var defaults = baseRest(function(object, sources) {
  17753. object = Object(object);
  17754. var index = -1;
  17755. var length = sources.length;
  17756. var guard = length > 2 ? sources[2] : undefined$1;
  17757. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  17758. length = 1;
  17759. }
  17760. while (++index < length) {
  17761. var source = sources[index];
  17762. var props = keysIn(source);
  17763. var propsIndex = -1;
  17764. var propsLength = props.length;
  17765. while (++propsIndex < propsLength) {
  17766. var key = props[propsIndex];
  17767. var value = object[key];
  17768. if (value === undefined$1 ||
  17769. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  17770. object[key] = source[key];
  17771. }
  17772. }
  17773. }
  17774. return object;
  17775. });
  17776. /**
  17777. * This method is like `_.defaults` except that it recursively assigns
  17778. * default properties.
  17779. *
  17780. * **Note:** This method mutates `object`.
  17781. *
  17782. * @static
  17783. * @memberOf _
  17784. * @since 3.10.0
  17785. * @category Object
  17786. * @param {Object} object The destination object.
  17787. * @param {...Object} [sources] The source objects.
  17788. * @returns {Object} Returns `object`.
  17789. * @see _.defaults
  17790. * @example
  17791. *
  17792. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  17793. * // => { 'a': { 'b': 2, 'c': 3 } }
  17794. */
  17795. var defaultsDeep = baseRest(function(args) {
  17796. args.push(undefined$1, customDefaultsMerge);
  17797. return apply(mergeWith, undefined$1, args);
  17798. });
  17799. /**
  17800. * This method is like `_.find` except that it returns the key of the first
  17801. * element `predicate` returns truthy for instead of the element itself.
  17802. *
  17803. * @static
  17804. * @memberOf _
  17805. * @since 1.1.0
  17806. * @category Object
  17807. * @param {Object} object The object to inspect.
  17808. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  17809. * @returns {string|undefined} Returns the key of the matched element,
  17810. * else `undefined`.
  17811. * @example
  17812. *
  17813. * var users = {
  17814. * 'barney': { 'age': 36, 'active': true },
  17815. * 'fred': { 'age': 40, 'active': false },
  17816. * 'pebbles': { 'age': 1, 'active': true }
  17817. * };
  17818. *
  17819. * _.findKey(users, function(o) { return o.age < 40; });
  17820. * // => 'barney' (iteration order is not guaranteed)
  17821. *
  17822. * // The `_.matches` iteratee shorthand.
  17823. * _.findKey(users, { 'age': 1, 'active': true });
  17824. * // => 'pebbles'
  17825. *
  17826. * // The `_.matchesProperty` iteratee shorthand.
  17827. * _.findKey(users, ['active', false]);
  17828. * // => 'fred'
  17829. *
  17830. * // The `_.property` iteratee shorthand.
  17831. * _.findKey(users, 'active');
  17832. * // => 'barney'
  17833. */
  17834. function findKey(object, predicate) {
  17835. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  17836. }
  17837. /**
  17838. * This method is like `_.findKey` except that it iterates over elements of
  17839. * a collection in the opposite order.
  17840. *
  17841. * @static
  17842. * @memberOf _
  17843. * @since 2.0.0
  17844. * @category Object
  17845. * @param {Object} object The object to inspect.
  17846. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  17847. * @returns {string|undefined} Returns the key of the matched element,
  17848. * else `undefined`.
  17849. * @example
  17850. *
  17851. * var users = {
  17852. * 'barney': { 'age': 36, 'active': true },
  17853. * 'fred': { 'age': 40, 'active': false },
  17854. * 'pebbles': { 'age': 1, 'active': true }
  17855. * };
  17856. *
  17857. * _.findLastKey(users, function(o) { return o.age < 40; });
  17858. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  17859. *
  17860. * // The `_.matches` iteratee shorthand.
  17861. * _.findLastKey(users, { 'age': 36, 'active': true });
  17862. * // => 'barney'
  17863. *
  17864. * // The `_.matchesProperty` iteratee shorthand.
  17865. * _.findLastKey(users, ['active', false]);
  17866. * // => 'fred'
  17867. *
  17868. * // The `_.property` iteratee shorthand.
  17869. * _.findLastKey(users, 'active');
  17870. * // => 'pebbles'
  17871. */
  17872. function findLastKey(object, predicate) {
  17873. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  17874. }
  17875. /**
  17876. * Iterates over own and inherited enumerable string keyed properties of an
  17877. * object and invokes `iteratee` for each property. The iteratee is invoked
  17878. * with three arguments: (value, key, object). Iteratee functions may exit
  17879. * iteration early by explicitly returning `false`.
  17880. *
  17881. * @static
  17882. * @memberOf _
  17883. * @since 0.3.0
  17884. * @category Object
  17885. * @param {Object} object The object to iterate over.
  17886. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17887. * @returns {Object} Returns `object`.
  17888. * @see _.forInRight
  17889. * @example
  17890. *
  17891. * function Foo() {
  17892. * this.a = 1;
  17893. * this.b = 2;
  17894. * }
  17895. *
  17896. * Foo.prototype.c = 3;
  17897. *
  17898. * _.forIn(new Foo, function(value, key) {
  17899. * console.log(key);
  17900. * });
  17901. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  17902. */
  17903. function forIn(object, iteratee) {
  17904. return object == null
  17905. ? object
  17906. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  17907. }
  17908. /**
  17909. * This method is like `_.forIn` except that it iterates over properties of
  17910. * `object` in the opposite order.
  17911. *
  17912. * @static
  17913. * @memberOf _
  17914. * @since 2.0.0
  17915. * @category Object
  17916. * @param {Object} object The object to iterate over.
  17917. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17918. * @returns {Object} Returns `object`.
  17919. * @see _.forIn
  17920. * @example
  17921. *
  17922. * function Foo() {
  17923. * this.a = 1;
  17924. * this.b = 2;
  17925. * }
  17926. *
  17927. * Foo.prototype.c = 3;
  17928. *
  17929. * _.forInRight(new Foo, function(value, key) {
  17930. * console.log(key);
  17931. * });
  17932. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  17933. */
  17934. function forInRight(object, iteratee) {
  17935. return object == null
  17936. ? object
  17937. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  17938. }
  17939. /**
  17940. * Iterates over own enumerable string keyed properties of an object and
  17941. * invokes `iteratee` for each property. The iteratee is invoked with three
  17942. * arguments: (value, key, object). Iteratee functions may exit iteration
  17943. * early by explicitly returning `false`.
  17944. *
  17945. * @static
  17946. * @memberOf _
  17947. * @since 0.3.0
  17948. * @category Object
  17949. * @param {Object} object The object to iterate over.
  17950. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17951. * @returns {Object} Returns `object`.
  17952. * @see _.forOwnRight
  17953. * @example
  17954. *
  17955. * function Foo() {
  17956. * this.a = 1;
  17957. * this.b = 2;
  17958. * }
  17959. *
  17960. * Foo.prototype.c = 3;
  17961. *
  17962. * _.forOwn(new Foo, function(value, key) {
  17963. * console.log(key);
  17964. * });
  17965. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  17966. */
  17967. function forOwn(object, iteratee) {
  17968. return object && baseForOwn(object, getIteratee(iteratee, 3));
  17969. }
  17970. /**
  17971. * This method is like `_.forOwn` except that it iterates over properties of
  17972. * `object` in the opposite order.
  17973. *
  17974. * @static
  17975. * @memberOf _
  17976. * @since 2.0.0
  17977. * @category Object
  17978. * @param {Object} object The object to iterate over.
  17979. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17980. * @returns {Object} Returns `object`.
  17981. * @see _.forOwn
  17982. * @example
  17983. *
  17984. * function Foo() {
  17985. * this.a = 1;
  17986. * this.b = 2;
  17987. * }
  17988. *
  17989. * Foo.prototype.c = 3;
  17990. *
  17991. * _.forOwnRight(new Foo, function(value, key) {
  17992. * console.log(key);
  17993. * });
  17994. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  17995. */
  17996. function forOwnRight(object, iteratee) {
  17997. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  17998. }
  17999. /**
  18000. * Creates an array of function property names from own enumerable properties
  18001. * of `object`.
  18002. *
  18003. * @static
  18004. * @since 0.1.0
  18005. * @memberOf _
  18006. * @category Object
  18007. * @param {Object} object The object to inspect.
  18008. * @returns {Array} Returns the function names.
  18009. * @see _.functionsIn
  18010. * @example
  18011. *
  18012. * function Foo() {
  18013. * this.a = _.constant('a');
  18014. * this.b = _.constant('b');
  18015. * }
  18016. *
  18017. * Foo.prototype.c = _.constant('c');
  18018. *
  18019. * _.functions(new Foo);
  18020. * // => ['a', 'b']
  18021. */
  18022. function functions(object) {
  18023. return object == null ? [] : baseFunctions(object, keys(object));
  18024. }
  18025. /**
  18026. * Creates an array of function property names from own and inherited
  18027. * enumerable properties of `object`.
  18028. *
  18029. * @static
  18030. * @memberOf _
  18031. * @since 4.0.0
  18032. * @category Object
  18033. * @param {Object} object The object to inspect.
  18034. * @returns {Array} Returns the function names.
  18035. * @see _.functions
  18036. * @example
  18037. *
  18038. * function Foo() {
  18039. * this.a = _.constant('a');
  18040. * this.b = _.constant('b');
  18041. * }
  18042. *
  18043. * Foo.prototype.c = _.constant('c');
  18044. *
  18045. * _.functionsIn(new Foo);
  18046. * // => ['a', 'b', 'c']
  18047. */
  18048. function functionsIn(object) {
  18049. return object == null ? [] : baseFunctions(object, keysIn(object));
  18050. }
  18051. /**
  18052. * Gets the value at `path` of `object`. If the resolved value is
  18053. * `undefined`, the `defaultValue` is returned in its place.
  18054. *
  18055. * @static
  18056. * @memberOf _
  18057. * @since 3.7.0
  18058. * @category Object
  18059. * @param {Object} object The object to query.
  18060. * @param {Array|string} path The path of the property to get.
  18061. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  18062. * @returns {*} Returns the resolved value.
  18063. * @example
  18064. *
  18065. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  18066. *
  18067. * _.get(object, 'a[0].b.c');
  18068. * // => 3
  18069. *
  18070. * _.get(object, ['a', '0', 'b', 'c']);
  18071. * // => 3
  18072. *
  18073. * _.get(object, 'a.b.c', 'default');
  18074. * // => 'default'
  18075. */
  18076. function get(object, path, defaultValue) {
  18077. var result = object == null ? undefined$1 : baseGet(object, path);
  18078. return result === undefined$1 ? defaultValue : result;
  18079. }
  18080. /**
  18081. * Checks if `path` is a direct property of `object`.
  18082. *
  18083. * @static
  18084. * @since 0.1.0
  18085. * @memberOf _
  18086. * @category Object
  18087. * @param {Object} object The object to query.
  18088. * @param {Array|string} path The path to check.
  18089. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  18090. * @example
  18091. *
  18092. * var object = { 'a': { 'b': 2 } };
  18093. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  18094. *
  18095. * _.has(object, 'a');
  18096. * // => true
  18097. *
  18098. * _.has(object, 'a.b');
  18099. * // => true
  18100. *
  18101. * _.has(object, ['a', 'b']);
  18102. * // => true
  18103. *
  18104. * _.has(other, 'a');
  18105. * // => false
  18106. */
  18107. function has(object, path) {
  18108. return object != null && hasPath(object, path, baseHas);
  18109. }
  18110. /**
  18111. * Checks if `path` is a direct or inherited property of `object`.
  18112. *
  18113. * @static
  18114. * @memberOf _
  18115. * @since 4.0.0
  18116. * @category Object
  18117. * @param {Object} object The object to query.
  18118. * @param {Array|string} path The path to check.
  18119. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  18120. * @example
  18121. *
  18122. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  18123. *
  18124. * _.hasIn(object, 'a');
  18125. * // => true
  18126. *
  18127. * _.hasIn(object, 'a.b');
  18128. * // => true
  18129. *
  18130. * _.hasIn(object, ['a', 'b']);
  18131. * // => true
  18132. *
  18133. * _.hasIn(object, 'b');
  18134. * // => false
  18135. */
  18136. function hasIn(object, path) {
  18137. return object != null && hasPath(object, path, baseHasIn);
  18138. }
  18139. /**
  18140. * Creates an object composed of the inverted keys and values of `object`.
  18141. * If `object` contains duplicate values, subsequent values overwrite
  18142. * property assignments of previous values.
  18143. *
  18144. * @static
  18145. * @memberOf _
  18146. * @since 0.7.0
  18147. * @category Object
  18148. * @param {Object} object The object to invert.
  18149. * @returns {Object} Returns the new inverted object.
  18150. * @example
  18151. *
  18152. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  18153. *
  18154. * _.invert(object);
  18155. * // => { '1': 'c', '2': 'b' }
  18156. */
  18157. var invert = createInverter(function(result, value, key) {
  18158. if (value != null &&
  18159. typeof value.toString != 'function') {
  18160. value = nativeObjectToString.call(value);
  18161. }
  18162. result[value] = key;
  18163. }, constant(identity));
  18164. /**
  18165. * This method is like `_.invert` except that the inverted object is generated
  18166. * from the results of running each element of `object` thru `iteratee`. The
  18167. * corresponding inverted value of each inverted key is an array of keys
  18168. * responsible for generating the inverted value. The iteratee is invoked
  18169. * with one argument: (value).
  18170. *
  18171. * @static
  18172. * @memberOf _
  18173. * @since 4.1.0
  18174. * @category Object
  18175. * @param {Object} object The object to invert.
  18176. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  18177. * @returns {Object} Returns the new inverted object.
  18178. * @example
  18179. *
  18180. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  18181. *
  18182. * _.invertBy(object);
  18183. * // => { '1': ['a', 'c'], '2': ['b'] }
  18184. *
  18185. * _.invertBy(object, function(value) {
  18186. * return 'group' + value;
  18187. * });
  18188. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  18189. */
  18190. var invertBy = createInverter(function(result, value, key) {
  18191. if (value != null &&
  18192. typeof value.toString != 'function') {
  18193. value = nativeObjectToString.call(value);
  18194. }
  18195. if (hasOwnProperty.call(result, value)) {
  18196. result[value].push(key);
  18197. } else {
  18198. result[value] = [key];
  18199. }
  18200. }, getIteratee);
  18201. /**
  18202. * Invokes the method at `path` of `object`.
  18203. *
  18204. * @static
  18205. * @memberOf _
  18206. * @since 4.0.0
  18207. * @category Object
  18208. * @param {Object} object The object to query.
  18209. * @param {Array|string} path The path of the method to invoke.
  18210. * @param {...*} [args] The arguments to invoke the method with.
  18211. * @returns {*} Returns the result of the invoked method.
  18212. * @example
  18213. *
  18214. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  18215. *
  18216. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  18217. * // => [2, 3]
  18218. */
  18219. var invoke = baseRest(baseInvoke);
  18220. /**
  18221. * Creates an array of the own enumerable property names of `object`.
  18222. *
  18223. * **Note:** Non-object values are coerced to objects. See the
  18224. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  18225. * for more details.
  18226. *
  18227. * @static
  18228. * @since 0.1.0
  18229. * @memberOf _
  18230. * @category Object
  18231. * @param {Object} object The object to query.
  18232. * @returns {Array} Returns the array of property names.
  18233. * @example
  18234. *
  18235. * function Foo() {
  18236. * this.a = 1;
  18237. * this.b = 2;
  18238. * }
  18239. *
  18240. * Foo.prototype.c = 3;
  18241. *
  18242. * _.keys(new Foo);
  18243. * // => ['a', 'b'] (iteration order is not guaranteed)
  18244. *
  18245. * _.keys('hi');
  18246. * // => ['0', '1']
  18247. */
  18248. function keys(object) {
  18249. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  18250. }
  18251. /**
  18252. * Creates an array of the own and inherited enumerable property names of `object`.
  18253. *
  18254. * **Note:** Non-object values are coerced to objects.
  18255. *
  18256. * @static
  18257. * @memberOf _
  18258. * @since 3.0.0
  18259. * @category Object
  18260. * @param {Object} object The object to query.
  18261. * @returns {Array} Returns the array of property names.
  18262. * @example
  18263. *
  18264. * function Foo() {
  18265. * this.a = 1;
  18266. * this.b = 2;
  18267. * }
  18268. *
  18269. * Foo.prototype.c = 3;
  18270. *
  18271. * _.keysIn(new Foo);
  18272. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  18273. */
  18274. function keysIn(object) {
  18275. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  18276. }
  18277. /**
  18278. * The opposite of `_.mapValues`; this method creates an object with the
  18279. * same values as `object` and keys generated by running each own enumerable
  18280. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  18281. * with three arguments: (value, key, object).
  18282. *
  18283. * @static
  18284. * @memberOf _
  18285. * @since 3.8.0
  18286. * @category Object
  18287. * @param {Object} object The object to iterate over.
  18288. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18289. * @returns {Object} Returns the new mapped object.
  18290. * @see _.mapValues
  18291. * @example
  18292. *
  18293. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  18294. * return key + value;
  18295. * });
  18296. * // => { 'a1': 1, 'b2': 2 }
  18297. */
  18298. function mapKeys(object, iteratee) {
  18299. var result = {};
  18300. iteratee = getIteratee(iteratee, 3);
  18301. baseForOwn(object, function(value, key, object) {
  18302. baseAssignValue(result, iteratee(value, key, object), value);
  18303. });
  18304. return result;
  18305. }
  18306. /**
  18307. * Creates an object with the same keys as `object` and values generated
  18308. * by running each own enumerable string keyed property of `object` thru
  18309. * `iteratee`. The iteratee is invoked with three arguments:
  18310. * (value, key, object).
  18311. *
  18312. * @static
  18313. * @memberOf _
  18314. * @since 2.4.0
  18315. * @category Object
  18316. * @param {Object} object The object to iterate over.
  18317. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18318. * @returns {Object} Returns the new mapped object.
  18319. * @see _.mapKeys
  18320. * @example
  18321. *
  18322. * var users = {
  18323. * 'fred': { 'user': 'fred', 'age': 40 },
  18324. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  18325. * };
  18326. *
  18327. * _.mapValues(users, function(o) { return o.age; });
  18328. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  18329. *
  18330. * // The `_.property` iteratee shorthand.
  18331. * _.mapValues(users, 'age');
  18332. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  18333. */
  18334. function mapValues(object, iteratee) {
  18335. var result = {};
  18336. iteratee = getIteratee(iteratee, 3);
  18337. baseForOwn(object, function(value, key, object) {
  18338. baseAssignValue(result, key, iteratee(value, key, object));
  18339. });
  18340. return result;
  18341. }
  18342. /**
  18343. * This method is like `_.assign` except that it recursively merges own and
  18344. * inherited enumerable string keyed properties of source objects into the
  18345. * destination object. Source properties that resolve to `undefined` are
  18346. * skipped if a destination value exists. Array and plain object properties
  18347. * are merged recursively. Other objects and value types are overridden by
  18348. * assignment. Source objects are applied from left to right. Subsequent
  18349. * sources overwrite property assignments of previous sources.
  18350. *
  18351. * **Note:** This method mutates `object`.
  18352. *
  18353. * @static
  18354. * @memberOf _
  18355. * @since 0.5.0
  18356. * @category Object
  18357. * @param {Object} object The destination object.
  18358. * @param {...Object} [sources] The source objects.
  18359. * @returns {Object} Returns `object`.
  18360. * @example
  18361. *
  18362. * var object = {
  18363. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  18364. * };
  18365. *
  18366. * var other = {
  18367. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  18368. * };
  18369. *
  18370. * _.merge(object, other);
  18371. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  18372. */
  18373. var merge = createAssigner(function(object, source, srcIndex) {
  18374. baseMerge(object, source, srcIndex);
  18375. });
  18376. /**
  18377. * This method is like `_.merge` except that it accepts `customizer` which
  18378. * is invoked to produce the merged values of the destination and source
  18379. * properties. If `customizer` returns `undefined`, merging is handled by the
  18380. * method instead. The `customizer` is invoked with six arguments:
  18381. * (objValue, srcValue, key, object, source, stack).
  18382. *
  18383. * **Note:** This method mutates `object`.
  18384. *
  18385. * @static
  18386. * @memberOf _
  18387. * @since 4.0.0
  18388. * @category Object
  18389. * @param {Object} object The destination object.
  18390. * @param {...Object} sources The source objects.
  18391. * @param {Function} customizer The function to customize assigned values.
  18392. * @returns {Object} Returns `object`.
  18393. * @example
  18394. *
  18395. * function customizer(objValue, srcValue) {
  18396. * if (_.isArray(objValue)) {
  18397. * return objValue.concat(srcValue);
  18398. * }
  18399. * }
  18400. *
  18401. * var object = { 'a': [1], 'b': [2] };
  18402. * var other = { 'a': [3], 'b': [4] };
  18403. *
  18404. * _.mergeWith(object, other, customizer);
  18405. * // => { 'a': [1, 3], 'b': [2, 4] }
  18406. */
  18407. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  18408. baseMerge(object, source, srcIndex, customizer);
  18409. });
  18410. /**
  18411. * The opposite of `_.pick`; this method creates an object composed of the
  18412. * own and inherited enumerable property paths of `object` that are not omitted.
  18413. *
  18414. * **Note:** This method is considerably slower than `_.pick`.
  18415. *
  18416. * @static
  18417. * @since 0.1.0
  18418. * @memberOf _
  18419. * @category Object
  18420. * @param {Object} object The source object.
  18421. * @param {...(string|string[])} [paths] The property paths to omit.
  18422. * @returns {Object} Returns the new object.
  18423. * @example
  18424. *
  18425. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  18426. *
  18427. * _.omit(object, ['a', 'c']);
  18428. * // => { 'b': '2' }
  18429. */
  18430. var omit = flatRest(function(object, paths) {
  18431. var result = {};
  18432. if (object == null) {
  18433. return result;
  18434. }
  18435. var isDeep = false;
  18436. paths = arrayMap(paths, function(path) {
  18437. path = castPath(path, object);
  18438. isDeep || (isDeep = path.length > 1);
  18439. return path;
  18440. });
  18441. copyObject(object, getAllKeysIn(object), result);
  18442. if (isDeep) {
  18443. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  18444. }
  18445. var length = paths.length;
  18446. while (length--) {
  18447. baseUnset(result, paths[length]);
  18448. }
  18449. return result;
  18450. });
  18451. /**
  18452. * The opposite of `_.pickBy`; this method creates an object composed of
  18453. * the own and inherited enumerable string keyed properties of `object` that
  18454. * `predicate` doesn't return truthy for. The predicate is invoked with two
  18455. * arguments: (value, key).
  18456. *
  18457. * @static
  18458. * @memberOf _
  18459. * @since 4.0.0
  18460. * @category Object
  18461. * @param {Object} object The source object.
  18462. * @param {Function} [predicate=_.identity] The function invoked per property.
  18463. * @returns {Object} Returns the new object.
  18464. * @example
  18465. *
  18466. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  18467. *
  18468. * _.omitBy(object, _.isNumber);
  18469. * // => { 'b': '2' }
  18470. */
  18471. function omitBy(object, predicate) {
  18472. return pickBy(object, negate(getIteratee(predicate)));
  18473. }
  18474. /**
  18475. * Creates an object composed of the picked `object` properties.
  18476. *
  18477. * @static
  18478. * @since 0.1.0
  18479. * @memberOf _
  18480. * @category Object
  18481. * @param {Object} object The source object.
  18482. * @param {...(string|string[])} [paths] The property paths to pick.
  18483. * @returns {Object} Returns the new object.
  18484. * @example
  18485. *
  18486. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  18487. *
  18488. * _.pick(object, ['a', 'c']);
  18489. * // => { 'a': 1, 'c': 3 }
  18490. */
  18491. var pick = flatRest(function(object, paths) {
  18492. return object == null ? {} : basePick(object, paths);
  18493. });
  18494. /**
  18495. * Creates an object composed of the `object` properties `predicate` returns
  18496. * truthy for. The predicate is invoked with two arguments: (value, key).
  18497. *
  18498. * @static
  18499. * @memberOf _
  18500. * @since 4.0.0
  18501. * @category Object
  18502. * @param {Object} object The source object.
  18503. * @param {Function} [predicate=_.identity] The function invoked per property.
  18504. * @returns {Object} Returns the new object.
  18505. * @example
  18506. *
  18507. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  18508. *
  18509. * _.pickBy(object, _.isNumber);
  18510. * // => { 'a': 1, 'c': 3 }
  18511. */
  18512. function pickBy(object, predicate) {
  18513. if (object == null) {
  18514. return {};
  18515. }
  18516. var props = arrayMap(getAllKeysIn(object), function(prop) {
  18517. return [prop];
  18518. });
  18519. predicate = getIteratee(predicate);
  18520. return basePickBy(object, props, function(value, path) {
  18521. return predicate(value, path[0]);
  18522. });
  18523. }
  18524. /**
  18525. * This method is like `_.get` except that if the resolved value is a
  18526. * function it's invoked with the `this` binding of its parent object and
  18527. * its result is returned.
  18528. *
  18529. * @static
  18530. * @since 0.1.0
  18531. * @memberOf _
  18532. * @category Object
  18533. * @param {Object} object The object to query.
  18534. * @param {Array|string} path The path of the property to resolve.
  18535. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  18536. * @returns {*} Returns the resolved value.
  18537. * @example
  18538. *
  18539. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  18540. *
  18541. * _.result(object, 'a[0].b.c1');
  18542. * // => 3
  18543. *
  18544. * _.result(object, 'a[0].b.c2');
  18545. * // => 4
  18546. *
  18547. * _.result(object, 'a[0].b.c3', 'default');
  18548. * // => 'default'
  18549. *
  18550. * _.result(object, 'a[0].b.c3', _.constant('default'));
  18551. * // => 'default'
  18552. */
  18553. function result(object, path, defaultValue) {
  18554. path = castPath(path, object);
  18555. var index = -1,
  18556. length = path.length;
  18557. // Ensure the loop is entered when path is empty.
  18558. if (!length) {
  18559. length = 1;
  18560. object = undefined$1;
  18561. }
  18562. while (++index < length) {
  18563. var value = object == null ? undefined$1 : object[toKey(path[index])];
  18564. if (value === undefined$1) {
  18565. index = length;
  18566. value = defaultValue;
  18567. }
  18568. object = isFunction(value) ? value.call(object) : value;
  18569. }
  18570. return object;
  18571. }
  18572. /**
  18573. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  18574. * it's created. Arrays are created for missing index properties while objects
  18575. * are created for all other missing properties. Use `_.setWith` to customize
  18576. * `path` creation.
  18577. *
  18578. * **Note:** This method mutates `object`.
  18579. *
  18580. * @static
  18581. * @memberOf _
  18582. * @since 3.7.0
  18583. * @category Object
  18584. * @param {Object} object The object to modify.
  18585. * @param {Array|string} path The path of the property to set.
  18586. * @param {*} value The value to set.
  18587. * @returns {Object} Returns `object`.
  18588. * @example
  18589. *
  18590. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  18591. *
  18592. * _.set(object, 'a[0].b.c', 4);
  18593. * console.log(object.a[0].b.c);
  18594. * // => 4
  18595. *
  18596. * _.set(object, ['x', '0', 'y', 'z'], 5);
  18597. * console.log(object.x[0].y.z);
  18598. * // => 5
  18599. */
  18600. function set(object, path, value) {
  18601. return object == null ? object : baseSet(object, path, value);
  18602. }
  18603. /**
  18604. * This method is like `_.set` except that it accepts `customizer` which is
  18605. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  18606. * path creation is handled by the method instead. The `customizer` is invoked
  18607. * with three arguments: (nsValue, key, nsObject).
  18608. *
  18609. * **Note:** This method mutates `object`.
  18610. *
  18611. * @static
  18612. * @memberOf _
  18613. * @since 4.0.0
  18614. * @category Object
  18615. * @param {Object} object The object to modify.
  18616. * @param {Array|string} path The path of the property to set.
  18617. * @param {*} value The value to set.
  18618. * @param {Function} [customizer] The function to customize assigned values.
  18619. * @returns {Object} Returns `object`.
  18620. * @example
  18621. *
  18622. * var object = {};
  18623. *
  18624. * _.setWith(object, '[0][1]', 'a', Object);
  18625. * // => { '0': { '1': 'a' } }
  18626. */
  18627. function setWith(object, path, value, customizer) {
  18628. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  18629. return object == null ? object : baseSet(object, path, value, customizer);
  18630. }
  18631. /**
  18632. * Creates an array of own enumerable string keyed-value pairs for `object`
  18633. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  18634. * entries are returned.
  18635. *
  18636. * @static
  18637. * @memberOf _
  18638. * @since 4.0.0
  18639. * @alias entries
  18640. * @category Object
  18641. * @param {Object} object The object to query.
  18642. * @returns {Array} Returns the key-value pairs.
  18643. * @example
  18644. *
  18645. * function Foo() {
  18646. * this.a = 1;
  18647. * this.b = 2;
  18648. * }
  18649. *
  18650. * Foo.prototype.c = 3;
  18651. *
  18652. * _.toPairs(new Foo);
  18653. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  18654. */
  18655. var toPairs = createToPairs(keys);
  18656. /**
  18657. * Creates an array of own and inherited enumerable string keyed-value pairs
  18658. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  18659. * or set, its entries are returned.
  18660. *
  18661. * @static
  18662. * @memberOf _
  18663. * @since 4.0.0
  18664. * @alias entriesIn
  18665. * @category Object
  18666. * @param {Object} object The object to query.
  18667. * @returns {Array} Returns the key-value pairs.
  18668. * @example
  18669. *
  18670. * function Foo() {
  18671. * this.a = 1;
  18672. * this.b = 2;
  18673. * }
  18674. *
  18675. * Foo.prototype.c = 3;
  18676. *
  18677. * _.toPairsIn(new Foo);
  18678. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  18679. */
  18680. var toPairsIn = createToPairs(keysIn);
  18681. /**
  18682. * An alternative to `_.reduce`; this method transforms `object` to a new
  18683. * `accumulator` object which is the result of running each of its own
  18684. * enumerable string keyed properties thru `iteratee`, with each invocation
  18685. * potentially mutating the `accumulator` object. If `accumulator` is not
  18686. * provided, a new object with the same `[[Prototype]]` will be used. The
  18687. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  18688. * Iteratee functions may exit iteration early by explicitly returning `false`.
  18689. *
  18690. * @static
  18691. * @memberOf _
  18692. * @since 1.3.0
  18693. * @category Object
  18694. * @param {Object} object The object to iterate over.
  18695. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18696. * @param {*} [accumulator] The custom accumulator value.
  18697. * @returns {*} Returns the accumulated value.
  18698. * @example
  18699. *
  18700. * _.transform([2, 3, 4], function(result, n) {
  18701. * result.push(n *= n);
  18702. * return n % 2 == 0;
  18703. * }, []);
  18704. * // => [4, 9]
  18705. *
  18706. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  18707. * (result[value] || (result[value] = [])).push(key);
  18708. * }, {});
  18709. * // => { '1': ['a', 'c'], '2': ['b'] }
  18710. */
  18711. function transform(object, iteratee, accumulator) {
  18712. var isArr = isArray(object),
  18713. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  18714. iteratee = getIteratee(iteratee, 4);
  18715. if (accumulator == null) {
  18716. var Ctor = object && object.constructor;
  18717. if (isArrLike) {
  18718. accumulator = isArr ? new Ctor : [];
  18719. }
  18720. else if (isObject(object)) {
  18721. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  18722. }
  18723. else {
  18724. accumulator = {};
  18725. }
  18726. }
  18727. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  18728. return iteratee(accumulator, value, index, object);
  18729. });
  18730. return accumulator;
  18731. }
  18732. /**
  18733. * Removes the property at `path` of `object`.
  18734. *
  18735. * **Note:** This method mutates `object`.
  18736. *
  18737. * @static
  18738. * @memberOf _
  18739. * @since 4.0.0
  18740. * @category Object
  18741. * @param {Object} object The object to modify.
  18742. * @param {Array|string} path The path of the property to unset.
  18743. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  18744. * @example
  18745. *
  18746. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  18747. * _.unset(object, 'a[0].b.c');
  18748. * // => true
  18749. *
  18750. * console.log(object);
  18751. * // => { 'a': [{ 'b': {} }] };
  18752. *
  18753. * _.unset(object, ['a', '0', 'b', 'c']);
  18754. * // => true
  18755. *
  18756. * console.log(object);
  18757. * // => { 'a': [{ 'b': {} }] };
  18758. */
  18759. function unset(object, path) {
  18760. return object == null ? true : baseUnset(object, path);
  18761. }
  18762. /**
  18763. * This method is like `_.set` except that accepts `updater` to produce the
  18764. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  18765. * is invoked with one argument: (value).
  18766. *
  18767. * **Note:** This method mutates `object`.
  18768. *
  18769. * @static
  18770. * @memberOf _
  18771. * @since 4.6.0
  18772. * @category Object
  18773. * @param {Object} object The object to modify.
  18774. * @param {Array|string} path The path of the property to set.
  18775. * @param {Function} updater The function to produce the updated value.
  18776. * @returns {Object} Returns `object`.
  18777. * @example
  18778. *
  18779. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  18780. *
  18781. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  18782. * console.log(object.a[0].b.c);
  18783. * // => 9
  18784. *
  18785. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  18786. * console.log(object.x[0].y.z);
  18787. * // => 0
  18788. */
  18789. function update(object, path, updater) {
  18790. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  18791. }
  18792. /**
  18793. * This method is like `_.update` except that it accepts `customizer` which is
  18794. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  18795. * path creation is handled by the method instead. The `customizer` is invoked
  18796. * with three arguments: (nsValue, key, nsObject).
  18797. *
  18798. * **Note:** This method mutates `object`.
  18799. *
  18800. * @static
  18801. * @memberOf _
  18802. * @since 4.6.0
  18803. * @category Object
  18804. * @param {Object} object The object to modify.
  18805. * @param {Array|string} path The path of the property to set.
  18806. * @param {Function} updater The function to produce the updated value.
  18807. * @param {Function} [customizer] The function to customize assigned values.
  18808. * @returns {Object} Returns `object`.
  18809. * @example
  18810. *
  18811. * var object = {};
  18812. *
  18813. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  18814. * // => { '0': { '1': 'a' } }
  18815. */
  18816. function updateWith(object, path, updater, customizer) {
  18817. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  18818. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  18819. }
  18820. /**
  18821. * Creates an array of the own enumerable string keyed property values of `object`.
  18822. *
  18823. * **Note:** Non-object values are coerced to objects.
  18824. *
  18825. * @static
  18826. * @since 0.1.0
  18827. * @memberOf _
  18828. * @category Object
  18829. * @param {Object} object The object to query.
  18830. * @returns {Array} Returns the array of property values.
  18831. * @example
  18832. *
  18833. * function Foo() {
  18834. * this.a = 1;
  18835. * this.b = 2;
  18836. * }
  18837. *
  18838. * Foo.prototype.c = 3;
  18839. *
  18840. * _.values(new Foo);
  18841. * // => [1, 2] (iteration order is not guaranteed)
  18842. *
  18843. * _.values('hi');
  18844. * // => ['h', 'i']
  18845. */
  18846. function values(object) {
  18847. return object == null ? [] : baseValues(object, keys(object));
  18848. }
  18849. /**
  18850. * Creates an array of the own and inherited enumerable string keyed property
  18851. * values of `object`.
  18852. *
  18853. * **Note:** Non-object values are coerced to objects.
  18854. *
  18855. * @static
  18856. * @memberOf _
  18857. * @since 3.0.0
  18858. * @category Object
  18859. * @param {Object} object The object to query.
  18860. * @returns {Array} Returns the array of property values.
  18861. * @example
  18862. *
  18863. * function Foo() {
  18864. * this.a = 1;
  18865. * this.b = 2;
  18866. * }
  18867. *
  18868. * Foo.prototype.c = 3;
  18869. *
  18870. * _.valuesIn(new Foo);
  18871. * // => [1, 2, 3] (iteration order is not guaranteed)
  18872. */
  18873. function valuesIn(object) {
  18874. return object == null ? [] : baseValues(object, keysIn(object));
  18875. }
  18876. /*------------------------------------------------------------------------*/
  18877. /**
  18878. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  18879. *
  18880. * @static
  18881. * @memberOf _
  18882. * @since 4.0.0
  18883. * @category Number
  18884. * @param {number} number The number to clamp.
  18885. * @param {number} [lower] The lower bound.
  18886. * @param {number} upper The upper bound.
  18887. * @returns {number} Returns the clamped number.
  18888. * @example
  18889. *
  18890. * _.clamp(-10, -5, 5);
  18891. * // => -5
  18892. *
  18893. * _.clamp(10, -5, 5);
  18894. * // => 5
  18895. */
  18896. function clamp(number, lower, upper) {
  18897. if (upper === undefined$1) {
  18898. upper = lower;
  18899. lower = undefined$1;
  18900. }
  18901. if (upper !== undefined$1) {
  18902. upper = toNumber(upper);
  18903. upper = upper === upper ? upper : 0;
  18904. }
  18905. if (lower !== undefined$1) {
  18906. lower = toNumber(lower);
  18907. lower = lower === lower ? lower : 0;
  18908. }
  18909. return baseClamp(toNumber(number), lower, upper);
  18910. }
  18911. /**
  18912. * Checks if `n` is between `start` and up to, but not including, `end`. If
  18913. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  18914. * If `start` is greater than `end` the params are swapped to support
  18915. * negative ranges.
  18916. *
  18917. * @static
  18918. * @memberOf _
  18919. * @since 3.3.0
  18920. * @category Number
  18921. * @param {number} number The number to check.
  18922. * @param {number} [start=0] The start of the range.
  18923. * @param {number} end The end of the range.
  18924. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  18925. * @see _.range, _.rangeRight
  18926. * @example
  18927. *
  18928. * _.inRange(3, 2, 4);
  18929. * // => true
  18930. *
  18931. * _.inRange(4, 8);
  18932. * // => true
  18933. *
  18934. * _.inRange(4, 2);
  18935. * // => false
  18936. *
  18937. * _.inRange(2, 2);
  18938. * // => false
  18939. *
  18940. * _.inRange(1.2, 2);
  18941. * // => true
  18942. *
  18943. * _.inRange(5.2, 4);
  18944. * // => false
  18945. *
  18946. * _.inRange(-3, -2, -6);
  18947. * // => true
  18948. */
  18949. function inRange(number, start, end) {
  18950. start = toFinite(start);
  18951. if (end === undefined$1) {
  18952. end = start;
  18953. start = 0;
  18954. } else {
  18955. end = toFinite(end);
  18956. }
  18957. number = toNumber(number);
  18958. return baseInRange(number, start, end);
  18959. }
  18960. /**
  18961. * Produces a random number between the inclusive `lower` and `upper` bounds.
  18962. * If only one argument is provided a number between `0` and the given number
  18963. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  18964. * floats, a floating-point number is returned instead of an integer.
  18965. *
  18966. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  18967. * floating-point values which can produce unexpected results.
  18968. *
  18969. * @static
  18970. * @memberOf _
  18971. * @since 0.7.0
  18972. * @category Number
  18973. * @param {number} [lower=0] The lower bound.
  18974. * @param {number} [upper=1] The upper bound.
  18975. * @param {boolean} [floating] Specify returning a floating-point number.
  18976. * @returns {number} Returns the random number.
  18977. * @example
  18978. *
  18979. * _.random(0, 5);
  18980. * // => an integer between 0 and 5
  18981. *
  18982. * _.random(5);
  18983. * // => also an integer between 0 and 5
  18984. *
  18985. * _.random(5, true);
  18986. * // => a floating-point number between 0 and 5
  18987. *
  18988. * _.random(1.2, 5.2);
  18989. * // => a floating-point number between 1.2 and 5.2
  18990. */
  18991. function random(lower, upper, floating) {
  18992. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  18993. upper = floating = undefined$1;
  18994. }
  18995. if (floating === undefined$1) {
  18996. if (typeof upper == 'boolean') {
  18997. floating = upper;
  18998. upper = undefined$1;
  18999. }
  19000. else if (typeof lower == 'boolean') {
  19001. floating = lower;
  19002. lower = undefined$1;
  19003. }
  19004. }
  19005. if (lower === undefined$1 && upper === undefined$1) {
  19006. lower = 0;
  19007. upper = 1;
  19008. }
  19009. else {
  19010. lower = toFinite(lower);
  19011. if (upper === undefined$1) {
  19012. upper = lower;
  19013. lower = 0;
  19014. } else {
  19015. upper = toFinite(upper);
  19016. }
  19017. }
  19018. if (lower > upper) {
  19019. var temp = lower;
  19020. lower = upper;
  19021. upper = temp;
  19022. }
  19023. if (floating || lower % 1 || upper % 1) {
  19024. var rand = nativeRandom();
  19025. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  19026. }
  19027. return baseRandom(lower, upper);
  19028. }
  19029. /*------------------------------------------------------------------------*/
  19030. /**
  19031. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  19032. *
  19033. * @static
  19034. * @memberOf _
  19035. * @since 3.0.0
  19036. * @category String
  19037. * @param {string} [string=''] The string to convert.
  19038. * @returns {string} Returns the camel cased string.
  19039. * @example
  19040. *
  19041. * _.camelCase('Foo Bar');
  19042. * // => 'fooBar'
  19043. *
  19044. * _.camelCase('--foo-bar--');
  19045. * // => 'fooBar'
  19046. *
  19047. * _.camelCase('__FOO_BAR__');
  19048. * // => 'fooBar'
  19049. */
  19050. var camelCase = createCompounder(function(result, word, index) {
  19051. word = word.toLowerCase();
  19052. return result + (index ? capitalize(word) : word);
  19053. });
  19054. /**
  19055. * Converts the first character of `string` to upper case and the remaining
  19056. * to lower case.
  19057. *
  19058. * @static
  19059. * @memberOf _
  19060. * @since 3.0.0
  19061. * @category String
  19062. * @param {string} [string=''] The string to capitalize.
  19063. * @returns {string} Returns the capitalized string.
  19064. * @example
  19065. *
  19066. * _.capitalize('FRED');
  19067. * // => 'Fred'
  19068. */
  19069. function capitalize(string) {
  19070. return upperFirst(toString(string).toLowerCase());
  19071. }
  19072. /**
  19073. * Deburrs `string` by converting
  19074. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  19075. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  19076. * letters to basic Latin letters and removing
  19077. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  19078. *
  19079. * @static
  19080. * @memberOf _
  19081. * @since 3.0.0
  19082. * @category String
  19083. * @param {string} [string=''] The string to deburr.
  19084. * @returns {string} Returns the deburred string.
  19085. * @example
  19086. *
  19087. * _.deburr('déjà vu');
  19088. * // => 'deja vu'
  19089. */
  19090. function deburr(string) {
  19091. string = toString(string);
  19092. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  19093. }
  19094. /**
  19095. * Checks if `string` ends with the given target string.
  19096. *
  19097. * @static
  19098. * @memberOf _
  19099. * @since 3.0.0
  19100. * @category String
  19101. * @param {string} [string=''] The string to inspect.
  19102. * @param {string} [target] The string to search for.
  19103. * @param {number} [position=string.length] The position to search up to.
  19104. * @returns {boolean} Returns `true` if `string` ends with `target`,
  19105. * else `false`.
  19106. * @example
  19107. *
  19108. * _.endsWith('abc', 'c');
  19109. * // => true
  19110. *
  19111. * _.endsWith('abc', 'b');
  19112. * // => false
  19113. *
  19114. * _.endsWith('abc', 'b', 2);
  19115. * // => true
  19116. */
  19117. function endsWith(string, target, position) {
  19118. string = toString(string);
  19119. target = baseToString(target);
  19120. var length = string.length;
  19121. position = position === undefined$1
  19122. ? length
  19123. : baseClamp(toInteger(position), 0, length);
  19124. var end = position;
  19125. position -= target.length;
  19126. return position >= 0 && string.slice(position, end) == target;
  19127. }
  19128. /**
  19129. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  19130. * corresponding HTML entities.
  19131. *
  19132. * **Note:** No other characters are escaped. To escape additional
  19133. * characters use a third-party library like [_he_](https://mths.be/he).
  19134. *
  19135. * Though the ">" character is escaped for symmetry, characters like
  19136. * ">" and "/" don't need escaping in HTML and have no special meaning
  19137. * unless they're part of a tag or unquoted attribute value. See
  19138. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  19139. * (under "semi-related fun fact") for more details.
  19140. *
  19141. * When working with HTML you should always
  19142. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  19143. * XSS vectors.
  19144. *
  19145. * @static
  19146. * @since 0.1.0
  19147. * @memberOf _
  19148. * @category String
  19149. * @param {string} [string=''] The string to escape.
  19150. * @returns {string} Returns the escaped string.
  19151. * @example
  19152. *
  19153. * _.escape('fred, barney, & pebbles');
  19154. * // => 'fred, barney, &amp; pebbles'
  19155. */
  19156. function escape(string) {
  19157. string = toString(string);
  19158. return (string && reHasUnescapedHtml.test(string))
  19159. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  19160. : string;
  19161. }
  19162. /**
  19163. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  19164. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  19165. *
  19166. * @static
  19167. * @memberOf _
  19168. * @since 3.0.0
  19169. * @category String
  19170. * @param {string} [string=''] The string to escape.
  19171. * @returns {string} Returns the escaped string.
  19172. * @example
  19173. *
  19174. * _.escapeRegExp('[lodash](https://lodash.com/)');
  19175. * // => '\[lodash\]\(https://lodash\.com/\)'
  19176. */
  19177. function escapeRegExp(string) {
  19178. string = toString(string);
  19179. return (string && reHasRegExpChar.test(string))
  19180. ? string.replace(reRegExpChar, '\\$&')
  19181. : string;
  19182. }
  19183. /**
  19184. * Converts `string` to
  19185. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  19186. *
  19187. * @static
  19188. * @memberOf _
  19189. * @since 3.0.0
  19190. * @category String
  19191. * @param {string} [string=''] The string to convert.
  19192. * @returns {string} Returns the kebab cased string.
  19193. * @example
  19194. *
  19195. * _.kebabCase('Foo Bar');
  19196. * // => 'foo-bar'
  19197. *
  19198. * _.kebabCase('fooBar');
  19199. * // => 'foo-bar'
  19200. *
  19201. * _.kebabCase('__FOO_BAR__');
  19202. * // => 'foo-bar'
  19203. */
  19204. var kebabCase = createCompounder(function(result, word, index) {
  19205. return result + (index ? '-' : '') + word.toLowerCase();
  19206. });
  19207. /**
  19208. * Converts `string`, as space separated words, to lower case.
  19209. *
  19210. * @static
  19211. * @memberOf _
  19212. * @since 4.0.0
  19213. * @category String
  19214. * @param {string} [string=''] The string to convert.
  19215. * @returns {string} Returns the lower cased string.
  19216. * @example
  19217. *
  19218. * _.lowerCase('--Foo-Bar--');
  19219. * // => 'foo bar'
  19220. *
  19221. * _.lowerCase('fooBar');
  19222. * // => 'foo bar'
  19223. *
  19224. * _.lowerCase('__FOO_BAR__');
  19225. * // => 'foo bar'
  19226. */
  19227. var lowerCase = createCompounder(function(result, word, index) {
  19228. return result + (index ? ' ' : '') + word.toLowerCase();
  19229. });
  19230. /**
  19231. * Converts the first character of `string` to lower case.
  19232. *
  19233. * @static
  19234. * @memberOf _
  19235. * @since 4.0.0
  19236. * @category String
  19237. * @param {string} [string=''] The string to convert.
  19238. * @returns {string} Returns the converted string.
  19239. * @example
  19240. *
  19241. * _.lowerFirst('Fred');
  19242. * // => 'fred'
  19243. *
  19244. * _.lowerFirst('FRED');
  19245. * // => 'fRED'
  19246. */
  19247. var lowerFirst = createCaseFirst('toLowerCase');
  19248. /**
  19249. * Pads `string` on the left and right sides if it's shorter than `length`.
  19250. * Padding characters are truncated if they can't be evenly divided by `length`.
  19251. *
  19252. * @static
  19253. * @memberOf _
  19254. * @since 3.0.0
  19255. * @category String
  19256. * @param {string} [string=''] The string to pad.
  19257. * @param {number} [length=0] The padding length.
  19258. * @param {string} [chars=' '] The string used as padding.
  19259. * @returns {string} Returns the padded string.
  19260. * @example
  19261. *
  19262. * _.pad('abc', 8);
  19263. * // => ' abc '
  19264. *
  19265. * _.pad('abc', 8, '_-');
  19266. * // => '_-abc_-_'
  19267. *
  19268. * _.pad('abc', 3);
  19269. * // => 'abc'
  19270. */
  19271. function pad(string, length, chars) {
  19272. string = toString(string);
  19273. length = toInteger(length);
  19274. var strLength = length ? stringSize(string) : 0;
  19275. if (!length || strLength >= length) {
  19276. return string;
  19277. }
  19278. var mid = (length - strLength) / 2;
  19279. return (
  19280. createPadding(nativeFloor(mid), chars) +
  19281. string +
  19282. createPadding(nativeCeil(mid), chars)
  19283. );
  19284. }
  19285. /**
  19286. * Pads `string` on the right side if it's shorter than `length`. Padding
  19287. * characters are truncated if they exceed `length`.
  19288. *
  19289. * @static
  19290. * @memberOf _
  19291. * @since 4.0.0
  19292. * @category String
  19293. * @param {string} [string=''] The string to pad.
  19294. * @param {number} [length=0] The padding length.
  19295. * @param {string} [chars=' '] The string used as padding.
  19296. * @returns {string} Returns the padded string.
  19297. * @example
  19298. *
  19299. * _.padEnd('abc', 6);
  19300. * // => 'abc '
  19301. *
  19302. * _.padEnd('abc', 6, '_-');
  19303. * // => 'abc_-_'
  19304. *
  19305. * _.padEnd('abc', 3);
  19306. * // => 'abc'
  19307. */
  19308. function padEnd(string, length, chars) {
  19309. string = toString(string);
  19310. length = toInteger(length);
  19311. var strLength = length ? stringSize(string) : 0;
  19312. return (length && strLength < length)
  19313. ? (string + createPadding(length - strLength, chars))
  19314. : string;
  19315. }
  19316. /**
  19317. * Pads `string` on the left side if it's shorter than `length`. Padding
  19318. * characters are truncated if they exceed `length`.
  19319. *
  19320. * @static
  19321. * @memberOf _
  19322. * @since 4.0.0
  19323. * @category String
  19324. * @param {string} [string=''] The string to pad.
  19325. * @param {number} [length=0] The padding length.
  19326. * @param {string} [chars=' '] The string used as padding.
  19327. * @returns {string} Returns the padded string.
  19328. * @example
  19329. *
  19330. * _.padStart('abc', 6);
  19331. * // => ' abc'
  19332. *
  19333. * _.padStart('abc', 6, '_-');
  19334. * // => '_-_abc'
  19335. *
  19336. * _.padStart('abc', 3);
  19337. * // => 'abc'
  19338. */
  19339. function padStart(string, length, chars) {
  19340. string = toString(string);
  19341. length = toInteger(length);
  19342. var strLength = length ? stringSize(string) : 0;
  19343. return (length && strLength < length)
  19344. ? (createPadding(length - strLength, chars) + string)
  19345. : string;
  19346. }
  19347. /**
  19348. * Converts `string` to an integer of the specified radix. If `radix` is
  19349. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  19350. * hexadecimal, in which case a `radix` of `16` is used.
  19351. *
  19352. * **Note:** This method aligns with the
  19353. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  19354. *
  19355. * @static
  19356. * @memberOf _
  19357. * @since 1.1.0
  19358. * @category String
  19359. * @param {string} string The string to convert.
  19360. * @param {number} [radix=10] The radix to interpret `value` by.
  19361. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19362. * @returns {number} Returns the converted integer.
  19363. * @example
  19364. *
  19365. * _.parseInt('08');
  19366. * // => 8
  19367. *
  19368. * _.map(['6', '08', '10'], _.parseInt);
  19369. * // => [6, 8, 10]
  19370. */
  19371. function parseInt(string, radix, guard) {
  19372. if (guard || radix == null) {
  19373. radix = 0;
  19374. } else if (radix) {
  19375. radix = +radix;
  19376. }
  19377. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  19378. }
  19379. /**
  19380. * Repeats the given string `n` times.
  19381. *
  19382. * @static
  19383. * @memberOf _
  19384. * @since 3.0.0
  19385. * @category String
  19386. * @param {string} [string=''] The string to repeat.
  19387. * @param {number} [n=1] The number of times to repeat the string.
  19388. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19389. * @returns {string} Returns the repeated string.
  19390. * @example
  19391. *
  19392. * _.repeat('*', 3);
  19393. * // => '***'
  19394. *
  19395. * _.repeat('abc', 2);
  19396. * // => 'abcabc'
  19397. *
  19398. * _.repeat('abc', 0);
  19399. * // => ''
  19400. */
  19401. function repeat(string, n, guard) {
  19402. if ((guard ? isIterateeCall(string, n, guard) : n === undefined$1)) {
  19403. n = 1;
  19404. } else {
  19405. n = toInteger(n);
  19406. }
  19407. return baseRepeat(toString(string), n);
  19408. }
  19409. /**
  19410. * Replaces matches for `pattern` in `string` with `replacement`.
  19411. *
  19412. * **Note:** This method is based on
  19413. * [`String#replace`](https://mdn.io/String/replace).
  19414. *
  19415. * @static
  19416. * @memberOf _
  19417. * @since 4.0.0
  19418. * @category String
  19419. * @param {string} [string=''] The string to modify.
  19420. * @param {RegExp|string} pattern The pattern to replace.
  19421. * @param {Function|string} replacement The match replacement.
  19422. * @returns {string} Returns the modified string.
  19423. * @example
  19424. *
  19425. * _.replace('Hi Fred', 'Fred', 'Barney');
  19426. * // => 'Hi Barney'
  19427. */
  19428. function replace() {
  19429. var args = arguments,
  19430. string = toString(args[0]);
  19431. return args.length < 3 ? string : string.replace(args[1], args[2]);
  19432. }
  19433. /**
  19434. * Converts `string` to
  19435. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  19436. *
  19437. * @static
  19438. * @memberOf _
  19439. * @since 3.0.0
  19440. * @category String
  19441. * @param {string} [string=''] The string to convert.
  19442. * @returns {string} Returns the snake cased string.
  19443. * @example
  19444. *
  19445. * _.snakeCase('Foo Bar');
  19446. * // => 'foo_bar'
  19447. *
  19448. * _.snakeCase('fooBar');
  19449. * // => 'foo_bar'
  19450. *
  19451. * _.snakeCase('--FOO-BAR--');
  19452. * // => 'foo_bar'
  19453. */
  19454. var snakeCase = createCompounder(function(result, word, index) {
  19455. return result + (index ? '_' : '') + word.toLowerCase();
  19456. });
  19457. /**
  19458. * Splits `string` by `separator`.
  19459. *
  19460. * **Note:** This method is based on
  19461. * [`String#split`](https://mdn.io/String/split).
  19462. *
  19463. * @static
  19464. * @memberOf _
  19465. * @since 4.0.0
  19466. * @category String
  19467. * @param {string} [string=''] The string to split.
  19468. * @param {RegExp|string} separator The separator pattern to split by.
  19469. * @param {number} [limit] The length to truncate results to.
  19470. * @returns {Array} Returns the string segments.
  19471. * @example
  19472. *
  19473. * _.split('a-b-c', '-', 2);
  19474. * // => ['a', 'b']
  19475. */
  19476. function split(string, separator, limit) {
  19477. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  19478. separator = limit = undefined$1;
  19479. }
  19480. limit = limit === undefined$1 ? MAX_ARRAY_LENGTH : limit >>> 0;
  19481. if (!limit) {
  19482. return [];
  19483. }
  19484. string = toString(string);
  19485. if (string && (
  19486. typeof separator == 'string' ||
  19487. (separator != null && !isRegExp(separator))
  19488. )) {
  19489. separator = baseToString(separator);
  19490. if (!separator && hasUnicode(string)) {
  19491. return castSlice(stringToArray(string), 0, limit);
  19492. }
  19493. }
  19494. return string.split(separator, limit);
  19495. }
  19496. /**
  19497. * Converts `string` to
  19498. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  19499. *
  19500. * @static
  19501. * @memberOf _
  19502. * @since 3.1.0
  19503. * @category String
  19504. * @param {string} [string=''] The string to convert.
  19505. * @returns {string} Returns the start cased string.
  19506. * @example
  19507. *
  19508. * _.startCase('--foo-bar--');
  19509. * // => 'Foo Bar'
  19510. *
  19511. * _.startCase('fooBar');
  19512. * // => 'Foo Bar'
  19513. *
  19514. * _.startCase('__FOO_BAR__');
  19515. * // => 'FOO BAR'
  19516. */
  19517. var startCase = createCompounder(function(result, word, index) {
  19518. return result + (index ? ' ' : '') + upperFirst(word);
  19519. });
  19520. /**
  19521. * Checks if `string` starts with the given target string.
  19522. *
  19523. * @static
  19524. * @memberOf _
  19525. * @since 3.0.0
  19526. * @category String
  19527. * @param {string} [string=''] The string to inspect.
  19528. * @param {string} [target] The string to search for.
  19529. * @param {number} [position=0] The position to search from.
  19530. * @returns {boolean} Returns `true` if `string` starts with `target`,
  19531. * else `false`.
  19532. * @example
  19533. *
  19534. * _.startsWith('abc', 'a');
  19535. * // => true
  19536. *
  19537. * _.startsWith('abc', 'b');
  19538. * // => false
  19539. *
  19540. * _.startsWith('abc', 'b', 1);
  19541. * // => true
  19542. */
  19543. function startsWith(string, target, position) {
  19544. string = toString(string);
  19545. position = position == null
  19546. ? 0
  19547. : baseClamp(toInteger(position), 0, string.length);
  19548. target = baseToString(target);
  19549. return string.slice(position, position + target.length) == target;
  19550. }
  19551. /**
  19552. * Creates a compiled template function that can interpolate data properties
  19553. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  19554. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  19555. * properties may be accessed as free variables in the template. If a setting
  19556. * object is given, it takes precedence over `_.templateSettings` values.
  19557. *
  19558. * **Note:** In the development build `_.template` utilizes
  19559. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  19560. * for easier debugging.
  19561. *
  19562. * For more information on precompiling templates see
  19563. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  19564. *
  19565. * For more information on Chrome extension sandboxes see
  19566. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  19567. *
  19568. * @static
  19569. * @since 0.1.0
  19570. * @memberOf _
  19571. * @category String
  19572. * @param {string} [string=''] The template string.
  19573. * @param {Object} [options={}] The options object.
  19574. * @param {RegExp} [options.escape=_.templateSettings.escape]
  19575. * The HTML "escape" delimiter.
  19576. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  19577. * The "evaluate" delimiter.
  19578. * @param {Object} [options.imports=_.templateSettings.imports]
  19579. * An object to import into the template as free variables.
  19580. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  19581. * The "interpolate" delimiter.
  19582. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  19583. * The sourceURL of the compiled template.
  19584. * @param {string} [options.variable='obj']
  19585. * The data object variable name.
  19586. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19587. * @returns {Function} Returns the compiled template function.
  19588. * @example
  19589. *
  19590. * // Use the "interpolate" delimiter to create a compiled template.
  19591. * var compiled = _.template('hello <%= user %>!');
  19592. * compiled({ 'user': 'fred' });
  19593. * // => 'hello fred!'
  19594. *
  19595. * // Use the HTML "escape" delimiter to escape data property values.
  19596. * var compiled = _.template('<b><%- value %></b>');
  19597. * compiled({ 'value': '<script>' });
  19598. * // => '<b>&lt;script&gt;</b>'
  19599. *
  19600. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  19601. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  19602. * compiled({ 'users': ['fred', 'barney'] });
  19603. * // => '<li>fred</li><li>barney</li>'
  19604. *
  19605. * // Use the internal `print` function in "evaluate" delimiters.
  19606. * var compiled = _.template('<% print("hello " + user); %>!');
  19607. * compiled({ 'user': 'barney' });
  19608. * // => 'hello barney!'
  19609. *
  19610. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  19611. * // Disable support by replacing the "interpolate" delimiter.
  19612. * var compiled = _.template('hello ${ user }!');
  19613. * compiled({ 'user': 'pebbles' });
  19614. * // => 'hello pebbles!'
  19615. *
  19616. * // Use backslashes to treat delimiters as plain text.
  19617. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  19618. * compiled({ 'value': 'ignored' });
  19619. * // => '<%- value %>'
  19620. *
  19621. * // Use the `imports` option to import `jQuery` as `jq`.
  19622. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  19623. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  19624. * compiled({ 'users': ['fred', 'barney'] });
  19625. * // => '<li>fred</li><li>barney</li>'
  19626. *
  19627. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  19628. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  19629. * compiled(data);
  19630. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  19631. *
  19632. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  19633. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  19634. * compiled.source;
  19635. * // => function(data) {
  19636. * // var __t, __p = '';
  19637. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  19638. * // return __p;
  19639. * // }
  19640. *
  19641. * // Use custom template delimiters.
  19642. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  19643. * var compiled = _.template('hello {{ user }}!');
  19644. * compiled({ 'user': 'mustache' });
  19645. * // => 'hello mustache!'
  19646. *
  19647. * // Use the `source` property to inline compiled templates for meaningful
  19648. * // line numbers in error messages and stack traces.
  19649. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  19650. * var JST = {\
  19651. * "main": ' + _.template(mainText).source + '\
  19652. * };\
  19653. * ');
  19654. */
  19655. function template(string, options, guard) {
  19656. // Based on John Resig's `tmpl` implementation
  19657. // (http://ejohn.org/blog/javascript-micro-templating/)
  19658. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  19659. var settings = lodash.templateSettings;
  19660. if (guard && isIterateeCall(string, options, guard)) {
  19661. options = undefined$1;
  19662. }
  19663. string = toString(string);
  19664. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  19665. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  19666. importsKeys = keys(imports),
  19667. importsValues = baseValues(imports, importsKeys);
  19668. var isEscaping,
  19669. isEvaluating,
  19670. index = 0,
  19671. interpolate = options.interpolate || reNoMatch,
  19672. source = "__p += '";
  19673. // Compile the regexp to match each delimiter.
  19674. var reDelimiters = RegExp(
  19675. (options.escape || reNoMatch).source + '|' +
  19676. interpolate.source + '|' +
  19677. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  19678. (options.evaluate || reNoMatch).source + '|$'
  19679. , 'g');
  19680. // Use a sourceURL for easier debugging.
  19681. // The sourceURL gets injected into the source that's eval-ed, so be careful
  19682. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  19683. // and escape the comment, thus injecting code that gets evaled.
  19684. var sourceURL = '//# sourceURL=' +
  19685. (hasOwnProperty.call(options, 'sourceURL')
  19686. ? (options.sourceURL + '').replace(/\s/g, ' ')
  19687. : ('lodash.templateSources[' + (++templateCounter) + ']')
  19688. ) + '\n';
  19689. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  19690. interpolateValue || (interpolateValue = esTemplateValue);
  19691. // Escape characters that can't be included in string literals.
  19692. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  19693. // Replace delimiters with snippets.
  19694. if (escapeValue) {
  19695. isEscaping = true;
  19696. source += "' +\n__e(" + escapeValue + ") +\n'";
  19697. }
  19698. if (evaluateValue) {
  19699. isEvaluating = true;
  19700. source += "';\n" + evaluateValue + ";\n__p += '";
  19701. }
  19702. if (interpolateValue) {
  19703. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  19704. }
  19705. index = offset + match.length;
  19706. // The JS engine embedded in Adobe products needs `match` returned in
  19707. // order to produce the correct `offset` value.
  19708. return match;
  19709. });
  19710. source += "';\n";
  19711. // If `variable` is not specified wrap a with-statement around the generated
  19712. // code to add the data object to the top of the scope chain.
  19713. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  19714. if (!variable) {
  19715. source = 'with (obj) {\n' + source + '\n}\n';
  19716. }
  19717. // Throw an error if a forbidden character was found in `variable`, to prevent
  19718. // potential command injection attacks.
  19719. else if (reForbiddenIdentifierChars.test(variable)) {
  19720. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  19721. }
  19722. // Cleanup code by stripping empty strings.
  19723. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  19724. .replace(reEmptyStringMiddle, '$1')
  19725. .replace(reEmptyStringTrailing, '$1;');
  19726. // Frame code as the function body.
  19727. source = 'function(' + (variable || 'obj') + ') {\n' +
  19728. (variable
  19729. ? ''
  19730. : 'obj || (obj = {});\n'
  19731. ) +
  19732. "var __t, __p = ''" +
  19733. (isEscaping
  19734. ? ', __e = _.escape'
  19735. : ''
  19736. ) +
  19737. (isEvaluating
  19738. ? ', __j = Array.prototype.join;\n' +
  19739. "function print() { __p += __j.call(arguments, '') }\n"
  19740. : ';\n'
  19741. ) +
  19742. source +
  19743. 'return __p\n}';
  19744. var result = attempt(function() {
  19745. return Function(importsKeys, sourceURL + 'return ' + source)
  19746. .apply(undefined$1, importsValues);
  19747. });
  19748. // Provide the compiled function's source by its `toString` method or
  19749. // the `source` property as a convenience for inlining compiled templates.
  19750. result.source = source;
  19751. if (isError(result)) {
  19752. throw result;
  19753. }
  19754. return result;
  19755. }
  19756. /**
  19757. * Converts `string`, as a whole, to lower case just like
  19758. * [String#toLowerCase](https://mdn.io/toLowerCase).
  19759. *
  19760. * @static
  19761. * @memberOf _
  19762. * @since 4.0.0
  19763. * @category String
  19764. * @param {string} [string=''] The string to convert.
  19765. * @returns {string} Returns the lower cased string.
  19766. * @example
  19767. *
  19768. * _.toLower('--Foo-Bar--');
  19769. * // => '--foo-bar--'
  19770. *
  19771. * _.toLower('fooBar');
  19772. * // => 'foobar'
  19773. *
  19774. * _.toLower('__FOO_BAR__');
  19775. * // => '__foo_bar__'
  19776. */
  19777. function toLower(value) {
  19778. return toString(value).toLowerCase();
  19779. }
  19780. /**
  19781. * Converts `string`, as a whole, to upper case just like
  19782. * [String#toUpperCase](https://mdn.io/toUpperCase).
  19783. *
  19784. * @static
  19785. * @memberOf _
  19786. * @since 4.0.0
  19787. * @category String
  19788. * @param {string} [string=''] The string to convert.
  19789. * @returns {string} Returns the upper cased string.
  19790. * @example
  19791. *
  19792. * _.toUpper('--foo-bar--');
  19793. * // => '--FOO-BAR--'
  19794. *
  19795. * _.toUpper('fooBar');
  19796. * // => 'FOOBAR'
  19797. *
  19798. * _.toUpper('__foo_bar__');
  19799. * // => '__FOO_BAR__'
  19800. */
  19801. function toUpper(value) {
  19802. return toString(value).toUpperCase();
  19803. }
  19804. /**
  19805. * Removes leading and trailing whitespace or specified characters from `string`.
  19806. *
  19807. * @static
  19808. * @memberOf _
  19809. * @since 3.0.0
  19810. * @category String
  19811. * @param {string} [string=''] The string to trim.
  19812. * @param {string} [chars=whitespace] The characters to trim.
  19813. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19814. * @returns {string} Returns the trimmed string.
  19815. * @example
  19816. *
  19817. * _.trim(' abc ');
  19818. * // => 'abc'
  19819. *
  19820. * _.trim('-_-abc-_-', '_-');
  19821. * // => 'abc'
  19822. *
  19823. * _.map([' foo ', ' bar '], _.trim);
  19824. * // => ['foo', 'bar']
  19825. */
  19826. function trim(string, chars, guard) {
  19827. string = toString(string);
  19828. if (string && (guard || chars === undefined$1)) {
  19829. return baseTrim(string);
  19830. }
  19831. if (!string || !(chars = baseToString(chars))) {
  19832. return string;
  19833. }
  19834. var strSymbols = stringToArray(string),
  19835. chrSymbols = stringToArray(chars),
  19836. start = charsStartIndex(strSymbols, chrSymbols),
  19837. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  19838. return castSlice(strSymbols, start, end).join('');
  19839. }
  19840. /**
  19841. * Removes trailing whitespace or specified characters from `string`.
  19842. *
  19843. * @static
  19844. * @memberOf _
  19845. * @since 4.0.0
  19846. * @category String
  19847. * @param {string} [string=''] The string to trim.
  19848. * @param {string} [chars=whitespace] The characters to trim.
  19849. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19850. * @returns {string} Returns the trimmed string.
  19851. * @example
  19852. *
  19853. * _.trimEnd(' abc ');
  19854. * // => ' abc'
  19855. *
  19856. * _.trimEnd('-_-abc-_-', '_-');
  19857. * // => '-_-abc'
  19858. */
  19859. function trimEnd(string, chars, guard) {
  19860. string = toString(string);
  19861. if (string && (guard || chars === undefined$1)) {
  19862. return string.slice(0, trimmedEndIndex(string) + 1);
  19863. }
  19864. if (!string || !(chars = baseToString(chars))) {
  19865. return string;
  19866. }
  19867. var strSymbols = stringToArray(string),
  19868. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  19869. return castSlice(strSymbols, 0, end).join('');
  19870. }
  19871. /**
  19872. * Removes leading whitespace or specified characters from `string`.
  19873. *
  19874. * @static
  19875. * @memberOf _
  19876. * @since 4.0.0
  19877. * @category String
  19878. * @param {string} [string=''] The string to trim.
  19879. * @param {string} [chars=whitespace] The characters to trim.
  19880. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19881. * @returns {string} Returns the trimmed string.
  19882. * @example
  19883. *
  19884. * _.trimStart(' abc ');
  19885. * // => 'abc '
  19886. *
  19887. * _.trimStart('-_-abc-_-', '_-');
  19888. * // => 'abc-_-'
  19889. */
  19890. function trimStart(string, chars, guard) {
  19891. string = toString(string);
  19892. if (string && (guard || chars === undefined$1)) {
  19893. return string.replace(reTrimStart, '');
  19894. }
  19895. if (!string || !(chars = baseToString(chars))) {
  19896. return string;
  19897. }
  19898. var strSymbols = stringToArray(string),
  19899. start = charsStartIndex(strSymbols, stringToArray(chars));
  19900. return castSlice(strSymbols, start).join('');
  19901. }
  19902. /**
  19903. * Truncates `string` if it's longer than the given maximum string length.
  19904. * The last characters of the truncated string are replaced with the omission
  19905. * string which defaults to "...".
  19906. *
  19907. * @static
  19908. * @memberOf _
  19909. * @since 4.0.0
  19910. * @category String
  19911. * @param {string} [string=''] The string to truncate.
  19912. * @param {Object} [options={}] The options object.
  19913. * @param {number} [options.length=30] The maximum string length.
  19914. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  19915. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  19916. * @returns {string} Returns the truncated string.
  19917. * @example
  19918. *
  19919. * _.truncate('hi-diddly-ho there, neighborino');
  19920. * // => 'hi-diddly-ho there, neighbo...'
  19921. *
  19922. * _.truncate('hi-diddly-ho there, neighborino', {
  19923. * 'length': 24,
  19924. * 'separator': ' '
  19925. * });
  19926. * // => 'hi-diddly-ho there,...'
  19927. *
  19928. * _.truncate('hi-diddly-ho there, neighborino', {
  19929. * 'length': 24,
  19930. * 'separator': /,? +/
  19931. * });
  19932. * // => 'hi-diddly-ho there...'
  19933. *
  19934. * _.truncate('hi-diddly-ho there, neighborino', {
  19935. * 'omission': ' [...]'
  19936. * });
  19937. * // => 'hi-diddly-ho there, neig [...]'
  19938. */
  19939. function truncate(string, options) {
  19940. var length = DEFAULT_TRUNC_LENGTH,
  19941. omission = DEFAULT_TRUNC_OMISSION;
  19942. if (isObject(options)) {
  19943. var separator = 'separator' in options ? options.separator : separator;
  19944. length = 'length' in options ? toInteger(options.length) : length;
  19945. omission = 'omission' in options ? baseToString(options.omission) : omission;
  19946. }
  19947. string = toString(string);
  19948. var strLength = string.length;
  19949. if (hasUnicode(string)) {
  19950. var strSymbols = stringToArray(string);
  19951. strLength = strSymbols.length;
  19952. }
  19953. if (length >= strLength) {
  19954. return string;
  19955. }
  19956. var end = length - stringSize(omission);
  19957. if (end < 1) {
  19958. return omission;
  19959. }
  19960. var result = strSymbols
  19961. ? castSlice(strSymbols, 0, end).join('')
  19962. : string.slice(0, end);
  19963. if (separator === undefined$1) {
  19964. return result + omission;
  19965. }
  19966. if (strSymbols) {
  19967. end += (result.length - end);
  19968. }
  19969. if (isRegExp(separator)) {
  19970. if (string.slice(end).search(separator)) {
  19971. var match,
  19972. substring = result;
  19973. if (!separator.global) {
  19974. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  19975. }
  19976. separator.lastIndex = 0;
  19977. while ((match = separator.exec(substring))) {
  19978. var newEnd = match.index;
  19979. }
  19980. result = result.slice(0, newEnd === undefined$1 ? end : newEnd);
  19981. }
  19982. } else if (string.indexOf(baseToString(separator), end) != end) {
  19983. var index = result.lastIndexOf(separator);
  19984. if (index > -1) {
  19985. result = result.slice(0, index);
  19986. }
  19987. }
  19988. return result + omission;
  19989. }
  19990. /**
  19991. * The inverse of `_.escape`; this method converts the HTML entities
  19992. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  19993. * their corresponding characters.
  19994. *
  19995. * **Note:** No other HTML entities are unescaped. To unescape additional
  19996. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  19997. *
  19998. * @static
  19999. * @memberOf _
  20000. * @since 0.6.0
  20001. * @category String
  20002. * @param {string} [string=''] The string to unescape.
  20003. * @returns {string} Returns the unescaped string.
  20004. * @example
  20005. *
  20006. * _.unescape('fred, barney, &amp; pebbles');
  20007. * // => 'fred, barney, & pebbles'
  20008. */
  20009. function unescape(string) {
  20010. string = toString(string);
  20011. return (string && reHasEscapedHtml.test(string))
  20012. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  20013. : string;
  20014. }
  20015. /**
  20016. * Converts `string`, as space separated words, to upper case.
  20017. *
  20018. * @static
  20019. * @memberOf _
  20020. * @since 4.0.0
  20021. * @category String
  20022. * @param {string} [string=''] The string to convert.
  20023. * @returns {string} Returns the upper cased string.
  20024. * @example
  20025. *
  20026. * _.upperCase('--foo-bar');
  20027. * // => 'FOO BAR'
  20028. *
  20029. * _.upperCase('fooBar');
  20030. * // => 'FOO BAR'
  20031. *
  20032. * _.upperCase('__foo_bar__');
  20033. * // => 'FOO BAR'
  20034. */
  20035. var upperCase = createCompounder(function(result, word, index) {
  20036. return result + (index ? ' ' : '') + word.toUpperCase();
  20037. });
  20038. /**
  20039. * Converts the first character of `string` to upper case.
  20040. *
  20041. * @static
  20042. * @memberOf _
  20043. * @since 4.0.0
  20044. * @category String
  20045. * @param {string} [string=''] The string to convert.
  20046. * @returns {string} Returns the converted string.
  20047. * @example
  20048. *
  20049. * _.upperFirst('fred');
  20050. * // => 'Fred'
  20051. *
  20052. * _.upperFirst('FRED');
  20053. * // => 'FRED'
  20054. */
  20055. var upperFirst = createCaseFirst('toUpperCase');
  20056. /**
  20057. * Splits `string` into an array of its words.
  20058. *
  20059. * @static
  20060. * @memberOf _
  20061. * @since 3.0.0
  20062. * @category String
  20063. * @param {string} [string=''] The string to inspect.
  20064. * @param {RegExp|string} [pattern] The pattern to match words.
  20065. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20066. * @returns {Array} Returns the words of `string`.
  20067. * @example
  20068. *
  20069. * _.words('fred, barney, & pebbles');
  20070. * // => ['fred', 'barney', 'pebbles']
  20071. *
  20072. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  20073. * // => ['fred', 'barney', '&', 'pebbles']
  20074. */
  20075. function words(string, pattern, guard) {
  20076. string = toString(string);
  20077. pattern = guard ? undefined$1 : pattern;
  20078. if (pattern === undefined$1) {
  20079. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  20080. }
  20081. return string.match(pattern) || [];
  20082. }
  20083. /*------------------------------------------------------------------------*/
  20084. /**
  20085. * Attempts to invoke `func`, returning either the result or the caught error
  20086. * object. Any additional arguments are provided to `func` when it's invoked.
  20087. *
  20088. * @static
  20089. * @memberOf _
  20090. * @since 3.0.0
  20091. * @category Util
  20092. * @param {Function} func The function to attempt.
  20093. * @param {...*} [args] The arguments to invoke `func` with.
  20094. * @returns {*} Returns the `func` result or error object.
  20095. * @example
  20096. *
  20097. * // Avoid throwing errors for invalid selectors.
  20098. * var elements = _.attempt(function(selector) {
  20099. * return document.querySelectorAll(selector);
  20100. * }, '>_>');
  20101. *
  20102. * if (_.isError(elements)) {
  20103. * elements = [];
  20104. * }
  20105. */
  20106. var attempt = baseRest(function(func, args) {
  20107. try {
  20108. return apply(func, undefined$1, args);
  20109. } catch (e) {
  20110. return isError(e) ? e : new Error(e);
  20111. }
  20112. });
  20113. /**
  20114. * Binds methods of an object to the object itself, overwriting the existing
  20115. * method.
  20116. *
  20117. * **Note:** This method doesn't set the "length" property of bound functions.
  20118. *
  20119. * @static
  20120. * @since 0.1.0
  20121. * @memberOf _
  20122. * @category Util
  20123. * @param {Object} object The object to bind and assign the bound methods to.
  20124. * @param {...(string|string[])} methodNames The object method names to bind.
  20125. * @returns {Object} Returns `object`.
  20126. * @example
  20127. *
  20128. * var view = {
  20129. * 'label': 'docs',
  20130. * 'click': function() {
  20131. * console.log('clicked ' + this.label);
  20132. * }
  20133. * };
  20134. *
  20135. * _.bindAll(view, ['click']);
  20136. * jQuery(element).on('click', view.click);
  20137. * // => Logs 'clicked docs' when clicked.
  20138. */
  20139. var bindAll = flatRest(function(object, methodNames) {
  20140. arrayEach(methodNames, function(key) {
  20141. key = toKey(key);
  20142. baseAssignValue(object, key, bind(object[key], object));
  20143. });
  20144. return object;
  20145. });
  20146. /**
  20147. * Creates a function that iterates over `pairs` and invokes the corresponding
  20148. * function of the first predicate to return truthy. The predicate-function
  20149. * pairs are invoked with the `this` binding and arguments of the created
  20150. * function.
  20151. *
  20152. * @static
  20153. * @memberOf _
  20154. * @since 4.0.0
  20155. * @category Util
  20156. * @param {Array} pairs The predicate-function pairs.
  20157. * @returns {Function} Returns the new composite function.
  20158. * @example
  20159. *
  20160. * var func = _.cond([
  20161. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  20162. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  20163. * [_.stubTrue, _.constant('no match')]
  20164. * ]);
  20165. *
  20166. * func({ 'a': 1, 'b': 2 });
  20167. * // => 'matches A'
  20168. *
  20169. * func({ 'a': 0, 'b': 1 });
  20170. * // => 'matches B'
  20171. *
  20172. * func({ 'a': '1', 'b': '2' });
  20173. * // => 'no match'
  20174. */
  20175. function cond(pairs) {
  20176. var length = pairs == null ? 0 : pairs.length,
  20177. toIteratee = getIteratee();
  20178. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  20179. if (typeof pair[1] != 'function') {
  20180. throw new TypeError(FUNC_ERROR_TEXT);
  20181. }
  20182. return [toIteratee(pair[0]), pair[1]];
  20183. });
  20184. return baseRest(function(args) {
  20185. var index = -1;
  20186. while (++index < length) {
  20187. var pair = pairs[index];
  20188. if (apply(pair[0], this, args)) {
  20189. return apply(pair[1], this, args);
  20190. }
  20191. }
  20192. });
  20193. }
  20194. /**
  20195. * Creates a function that invokes the predicate properties of `source` with
  20196. * the corresponding property values of a given object, returning `true` if
  20197. * all predicates return truthy, else `false`.
  20198. *
  20199. * **Note:** The created function is equivalent to `_.conformsTo` with
  20200. * `source` partially applied.
  20201. *
  20202. * @static
  20203. * @memberOf _
  20204. * @since 4.0.0
  20205. * @category Util
  20206. * @param {Object} source The object of property predicates to conform to.
  20207. * @returns {Function} Returns the new spec function.
  20208. * @example
  20209. *
  20210. * var objects = [
  20211. * { 'a': 2, 'b': 1 },
  20212. * { 'a': 1, 'b': 2 }
  20213. * ];
  20214. *
  20215. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  20216. * // => [{ 'a': 1, 'b': 2 }]
  20217. */
  20218. function conforms(source) {
  20219. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  20220. }
  20221. /**
  20222. * Creates a function that returns `value`.
  20223. *
  20224. * @static
  20225. * @memberOf _
  20226. * @since 2.4.0
  20227. * @category Util
  20228. * @param {*} value The value to return from the new function.
  20229. * @returns {Function} Returns the new constant function.
  20230. * @example
  20231. *
  20232. * var objects = _.times(2, _.constant({ 'a': 1 }));
  20233. *
  20234. * console.log(objects);
  20235. * // => [{ 'a': 1 }, { 'a': 1 }]
  20236. *
  20237. * console.log(objects[0] === objects[1]);
  20238. * // => true
  20239. */
  20240. function constant(value) {
  20241. return function() {
  20242. return value;
  20243. };
  20244. }
  20245. /**
  20246. * Checks `value` to determine whether a default value should be returned in
  20247. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  20248. * or `undefined`.
  20249. *
  20250. * @static
  20251. * @memberOf _
  20252. * @since 4.14.0
  20253. * @category Util
  20254. * @param {*} value The value to check.
  20255. * @param {*} defaultValue The default value.
  20256. * @returns {*} Returns the resolved value.
  20257. * @example
  20258. *
  20259. * _.defaultTo(1, 10);
  20260. * // => 1
  20261. *
  20262. * _.defaultTo(undefined, 10);
  20263. * // => 10
  20264. */
  20265. function defaultTo(value, defaultValue) {
  20266. return (value == null || value !== value) ? defaultValue : value;
  20267. }
  20268. /**
  20269. * Creates a function that returns the result of invoking the given functions
  20270. * with the `this` binding of the created function, where each successive
  20271. * invocation is supplied the return value of the previous.
  20272. *
  20273. * @static
  20274. * @memberOf _
  20275. * @since 3.0.0
  20276. * @category Util
  20277. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  20278. * @returns {Function} Returns the new composite function.
  20279. * @see _.flowRight
  20280. * @example
  20281. *
  20282. * function square(n) {
  20283. * return n * n;
  20284. * }
  20285. *
  20286. * var addSquare = _.flow([_.add, square]);
  20287. * addSquare(1, 2);
  20288. * // => 9
  20289. */
  20290. var flow = createFlow();
  20291. /**
  20292. * This method is like `_.flow` except that it creates a function that
  20293. * invokes the given functions from right to left.
  20294. *
  20295. * @static
  20296. * @since 3.0.0
  20297. * @memberOf _
  20298. * @category Util
  20299. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  20300. * @returns {Function} Returns the new composite function.
  20301. * @see _.flow
  20302. * @example
  20303. *
  20304. * function square(n) {
  20305. * return n * n;
  20306. * }
  20307. *
  20308. * var addSquare = _.flowRight([square, _.add]);
  20309. * addSquare(1, 2);
  20310. * // => 9
  20311. */
  20312. var flowRight = createFlow(true);
  20313. /**
  20314. * This method returns the first argument it receives.
  20315. *
  20316. * @static
  20317. * @since 0.1.0
  20318. * @memberOf _
  20319. * @category Util
  20320. * @param {*} value Any value.
  20321. * @returns {*} Returns `value`.
  20322. * @example
  20323. *
  20324. * var object = { 'a': 1 };
  20325. *
  20326. * console.log(_.identity(object) === object);
  20327. * // => true
  20328. */
  20329. function identity(value) {
  20330. return value;
  20331. }
  20332. /**
  20333. * Creates a function that invokes `func` with the arguments of the created
  20334. * function. If `func` is a property name, the created function returns the
  20335. * property value for a given element. If `func` is an array or object, the
  20336. * created function returns `true` for elements that contain the equivalent
  20337. * source properties, otherwise it returns `false`.
  20338. *
  20339. * @static
  20340. * @since 4.0.0
  20341. * @memberOf _
  20342. * @category Util
  20343. * @param {*} [func=_.identity] The value to convert to a callback.
  20344. * @returns {Function} Returns the callback.
  20345. * @example
  20346. *
  20347. * var users = [
  20348. * { 'user': 'barney', 'age': 36, 'active': true },
  20349. * { 'user': 'fred', 'age': 40, 'active': false }
  20350. * ];
  20351. *
  20352. * // The `_.matches` iteratee shorthand.
  20353. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  20354. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  20355. *
  20356. * // The `_.matchesProperty` iteratee shorthand.
  20357. * _.filter(users, _.iteratee(['user', 'fred']));
  20358. * // => [{ 'user': 'fred', 'age': 40 }]
  20359. *
  20360. * // The `_.property` iteratee shorthand.
  20361. * _.map(users, _.iteratee('user'));
  20362. * // => ['barney', 'fred']
  20363. *
  20364. * // Create custom iteratee shorthands.
  20365. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  20366. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  20367. * return func.test(string);
  20368. * };
  20369. * });
  20370. *
  20371. * _.filter(['abc', 'def'], /ef/);
  20372. * // => ['def']
  20373. */
  20374. function iteratee(func) {
  20375. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  20376. }
  20377. /**
  20378. * Creates a function that performs a partial deep comparison between a given
  20379. * object and `source`, returning `true` if the given object has equivalent
  20380. * property values, else `false`.
  20381. *
  20382. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  20383. * partially applied.
  20384. *
  20385. * Partial comparisons will match empty array and empty object `source`
  20386. * values against any array or object value, respectively. See `_.isEqual`
  20387. * for a list of supported value comparisons.
  20388. *
  20389. * **Note:** Multiple values can be checked by combining several matchers
  20390. * using `_.overSome`
  20391. *
  20392. * @static
  20393. * @memberOf _
  20394. * @since 3.0.0
  20395. * @category Util
  20396. * @param {Object} source The object of property values to match.
  20397. * @returns {Function} Returns the new spec function.
  20398. * @example
  20399. *
  20400. * var objects = [
  20401. * { 'a': 1, 'b': 2, 'c': 3 },
  20402. * { 'a': 4, 'b': 5, 'c': 6 }
  20403. * ];
  20404. *
  20405. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  20406. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  20407. *
  20408. * // Checking for several possible values
  20409. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  20410. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  20411. */
  20412. function matches(source) {
  20413. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  20414. }
  20415. /**
  20416. * Creates a function that performs a partial deep comparison between the
  20417. * value at `path` of a given object to `srcValue`, returning `true` if the
  20418. * object value is equivalent, else `false`.
  20419. *
  20420. * **Note:** Partial comparisons will match empty array and empty object
  20421. * `srcValue` values against any array or object value, respectively. See
  20422. * `_.isEqual` for a list of supported value comparisons.
  20423. *
  20424. * **Note:** Multiple values can be checked by combining several matchers
  20425. * using `_.overSome`
  20426. *
  20427. * @static
  20428. * @memberOf _
  20429. * @since 3.2.0
  20430. * @category Util
  20431. * @param {Array|string} path The path of the property to get.
  20432. * @param {*} srcValue The value to match.
  20433. * @returns {Function} Returns the new spec function.
  20434. * @example
  20435. *
  20436. * var objects = [
  20437. * { 'a': 1, 'b': 2, 'c': 3 },
  20438. * { 'a': 4, 'b': 5, 'c': 6 }
  20439. * ];
  20440. *
  20441. * _.find(objects, _.matchesProperty('a', 4));
  20442. * // => { 'a': 4, 'b': 5, 'c': 6 }
  20443. *
  20444. * // Checking for several possible values
  20445. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  20446. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  20447. */
  20448. function matchesProperty(path, srcValue) {
  20449. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  20450. }
  20451. /**
  20452. * Creates a function that invokes the method at `path` of a given object.
  20453. * Any additional arguments are provided to the invoked method.
  20454. *
  20455. * @static
  20456. * @memberOf _
  20457. * @since 3.7.0
  20458. * @category Util
  20459. * @param {Array|string} path The path of the method to invoke.
  20460. * @param {...*} [args] The arguments to invoke the method with.
  20461. * @returns {Function} Returns the new invoker function.
  20462. * @example
  20463. *
  20464. * var objects = [
  20465. * { 'a': { 'b': _.constant(2) } },
  20466. * { 'a': { 'b': _.constant(1) } }
  20467. * ];
  20468. *
  20469. * _.map(objects, _.method('a.b'));
  20470. * // => [2, 1]
  20471. *
  20472. * _.map(objects, _.method(['a', 'b']));
  20473. * // => [2, 1]
  20474. */
  20475. var method = baseRest(function(path, args) {
  20476. return function(object) {
  20477. return baseInvoke(object, path, args);
  20478. };
  20479. });
  20480. /**
  20481. * The opposite of `_.method`; this method creates a function that invokes
  20482. * the method at a given path of `object`. Any additional arguments are
  20483. * provided to the invoked method.
  20484. *
  20485. * @static
  20486. * @memberOf _
  20487. * @since 3.7.0
  20488. * @category Util
  20489. * @param {Object} object The object to query.
  20490. * @param {...*} [args] The arguments to invoke the method with.
  20491. * @returns {Function} Returns the new invoker function.
  20492. * @example
  20493. *
  20494. * var array = _.times(3, _.constant),
  20495. * object = { 'a': array, 'b': array, 'c': array };
  20496. *
  20497. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  20498. * // => [2, 0]
  20499. *
  20500. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  20501. * // => [2, 0]
  20502. */
  20503. var methodOf = baseRest(function(object, args) {
  20504. return function(path) {
  20505. return baseInvoke(object, path, args);
  20506. };
  20507. });
  20508. /**
  20509. * Adds all own enumerable string keyed function properties of a source
  20510. * object to the destination object. If `object` is a function, then methods
  20511. * are added to its prototype as well.
  20512. *
  20513. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  20514. * avoid conflicts caused by modifying the original.
  20515. *
  20516. * @static
  20517. * @since 0.1.0
  20518. * @memberOf _
  20519. * @category Util
  20520. * @param {Function|Object} [object=lodash] The destination object.
  20521. * @param {Object} source The object of functions to add.
  20522. * @param {Object} [options={}] The options object.
  20523. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  20524. * @returns {Function|Object} Returns `object`.
  20525. * @example
  20526. *
  20527. * function vowels(string) {
  20528. * return _.filter(string, function(v) {
  20529. * return /[aeiou]/i.test(v);
  20530. * });
  20531. * }
  20532. *
  20533. * _.mixin({ 'vowels': vowels });
  20534. * _.vowels('fred');
  20535. * // => ['e']
  20536. *
  20537. * _('fred').vowels().value();
  20538. * // => ['e']
  20539. *
  20540. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  20541. * _('fred').vowels();
  20542. * // => ['e']
  20543. */
  20544. function mixin(object, source, options) {
  20545. var props = keys(source),
  20546. methodNames = baseFunctions(source, props);
  20547. if (options == null &&
  20548. !(isObject(source) && (methodNames.length || !props.length))) {
  20549. options = source;
  20550. source = object;
  20551. object = this;
  20552. methodNames = baseFunctions(source, keys(source));
  20553. }
  20554. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  20555. isFunc = isFunction(object);
  20556. arrayEach(methodNames, function(methodName) {
  20557. var func = source[methodName];
  20558. object[methodName] = func;
  20559. if (isFunc) {
  20560. object.prototype[methodName] = function() {
  20561. var chainAll = this.__chain__;
  20562. if (chain || chainAll) {
  20563. var result = object(this.__wrapped__),
  20564. actions = result.__actions__ = copyArray(this.__actions__);
  20565. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  20566. result.__chain__ = chainAll;
  20567. return result;
  20568. }
  20569. return func.apply(object, arrayPush([this.value()], arguments));
  20570. };
  20571. }
  20572. });
  20573. return object;
  20574. }
  20575. /**
  20576. * Reverts the `_` variable to its previous value and returns a reference to
  20577. * the `lodash` function.
  20578. *
  20579. * @static
  20580. * @since 0.1.0
  20581. * @memberOf _
  20582. * @category Util
  20583. * @returns {Function} Returns the `lodash` function.
  20584. * @example
  20585. *
  20586. * var lodash = _.noConflict();
  20587. */
  20588. function noConflict() {
  20589. if (root._ === this) {
  20590. root._ = oldDash;
  20591. }
  20592. return this;
  20593. }
  20594. /**
  20595. * This method returns `undefined`.
  20596. *
  20597. * @static
  20598. * @memberOf _
  20599. * @since 2.3.0
  20600. * @category Util
  20601. * @example
  20602. *
  20603. * _.times(2, _.noop);
  20604. * // => [undefined, undefined]
  20605. */
  20606. function noop() {
  20607. // No operation performed.
  20608. }
  20609. /**
  20610. * Creates a function that gets the argument at index `n`. If `n` is negative,
  20611. * the nth argument from the end is returned.
  20612. *
  20613. * @static
  20614. * @memberOf _
  20615. * @since 4.0.0
  20616. * @category Util
  20617. * @param {number} [n=0] The index of the argument to return.
  20618. * @returns {Function} Returns the new pass-thru function.
  20619. * @example
  20620. *
  20621. * var func = _.nthArg(1);
  20622. * func('a', 'b', 'c', 'd');
  20623. * // => 'b'
  20624. *
  20625. * var func = _.nthArg(-2);
  20626. * func('a', 'b', 'c', 'd');
  20627. * // => 'c'
  20628. */
  20629. function nthArg(n) {
  20630. n = toInteger(n);
  20631. return baseRest(function(args) {
  20632. return baseNth(args, n);
  20633. });
  20634. }
  20635. /**
  20636. * Creates a function that invokes `iteratees` with the arguments it receives
  20637. * and returns their results.
  20638. *
  20639. * @static
  20640. * @memberOf _
  20641. * @since 4.0.0
  20642. * @category Util
  20643. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  20644. * The iteratees to invoke.
  20645. * @returns {Function} Returns the new function.
  20646. * @example
  20647. *
  20648. * var func = _.over([Math.max, Math.min]);
  20649. *
  20650. * func(1, 2, 3, 4);
  20651. * // => [4, 1]
  20652. */
  20653. var over = createOver(arrayMap);
  20654. /**
  20655. * Creates a function that checks if **all** of the `predicates` return
  20656. * truthy when invoked with the arguments it receives.
  20657. *
  20658. * Following shorthands are possible for providing predicates.
  20659. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  20660. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  20661. *
  20662. * @static
  20663. * @memberOf _
  20664. * @since 4.0.0
  20665. * @category Util
  20666. * @param {...(Function|Function[])} [predicates=[_.identity]]
  20667. * The predicates to check.
  20668. * @returns {Function} Returns the new function.
  20669. * @example
  20670. *
  20671. * var func = _.overEvery([Boolean, isFinite]);
  20672. *
  20673. * func('1');
  20674. * // => true
  20675. *
  20676. * func(null);
  20677. * // => false
  20678. *
  20679. * func(NaN);
  20680. * // => false
  20681. */
  20682. var overEvery = createOver(arrayEvery);
  20683. /**
  20684. * Creates a function that checks if **any** of the `predicates` return
  20685. * truthy when invoked with the arguments it receives.
  20686. *
  20687. * Following shorthands are possible for providing predicates.
  20688. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  20689. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  20690. *
  20691. * @static
  20692. * @memberOf _
  20693. * @since 4.0.0
  20694. * @category Util
  20695. * @param {...(Function|Function[])} [predicates=[_.identity]]
  20696. * The predicates to check.
  20697. * @returns {Function} Returns the new function.
  20698. * @example
  20699. *
  20700. * var func = _.overSome([Boolean, isFinite]);
  20701. *
  20702. * func('1');
  20703. * // => true
  20704. *
  20705. * func(null);
  20706. * // => true
  20707. *
  20708. * func(NaN);
  20709. * // => false
  20710. *
  20711. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  20712. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  20713. */
  20714. var overSome = createOver(arraySome);
  20715. /**
  20716. * Creates a function that returns the value at `path` of a given object.
  20717. *
  20718. * @static
  20719. * @memberOf _
  20720. * @since 2.4.0
  20721. * @category Util
  20722. * @param {Array|string} path The path of the property to get.
  20723. * @returns {Function} Returns the new accessor function.
  20724. * @example
  20725. *
  20726. * var objects = [
  20727. * { 'a': { 'b': 2 } },
  20728. * { 'a': { 'b': 1 } }
  20729. * ];
  20730. *
  20731. * _.map(objects, _.property('a.b'));
  20732. * // => [2, 1]
  20733. *
  20734. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  20735. * // => [1, 2]
  20736. */
  20737. function property(path) {
  20738. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  20739. }
  20740. /**
  20741. * The opposite of `_.property`; this method creates a function that returns
  20742. * the value at a given path of `object`.
  20743. *
  20744. * @static
  20745. * @memberOf _
  20746. * @since 3.0.0
  20747. * @category Util
  20748. * @param {Object} object The object to query.
  20749. * @returns {Function} Returns the new accessor function.
  20750. * @example
  20751. *
  20752. * var array = [0, 1, 2],
  20753. * object = { 'a': array, 'b': array, 'c': array };
  20754. *
  20755. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  20756. * // => [2, 0]
  20757. *
  20758. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  20759. * // => [2, 0]
  20760. */
  20761. function propertyOf(object) {
  20762. return function(path) {
  20763. return object == null ? undefined$1 : baseGet(object, path);
  20764. };
  20765. }
  20766. /**
  20767. * Creates an array of numbers (positive and/or negative) progressing from
  20768. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  20769. * `start` is specified without an `end` or `step`. If `end` is not specified,
  20770. * it's set to `start` with `start` then set to `0`.
  20771. *
  20772. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  20773. * floating-point values which can produce unexpected results.
  20774. *
  20775. * @static
  20776. * @since 0.1.0
  20777. * @memberOf _
  20778. * @category Util
  20779. * @param {number} [start=0] The start of the range.
  20780. * @param {number} end The end of the range.
  20781. * @param {number} [step=1] The value to increment or decrement by.
  20782. * @returns {Array} Returns the range of numbers.
  20783. * @see _.inRange, _.rangeRight
  20784. * @example
  20785. *
  20786. * _.range(4);
  20787. * // => [0, 1, 2, 3]
  20788. *
  20789. * _.range(-4);
  20790. * // => [0, -1, -2, -3]
  20791. *
  20792. * _.range(1, 5);
  20793. * // => [1, 2, 3, 4]
  20794. *
  20795. * _.range(0, 20, 5);
  20796. * // => [0, 5, 10, 15]
  20797. *
  20798. * _.range(0, -4, -1);
  20799. * // => [0, -1, -2, -3]
  20800. *
  20801. * _.range(1, 4, 0);
  20802. * // => [1, 1, 1]
  20803. *
  20804. * _.range(0);
  20805. * // => []
  20806. */
  20807. var range = createRange();
  20808. /**
  20809. * This method is like `_.range` except that it populates values in
  20810. * descending order.
  20811. *
  20812. * @static
  20813. * @memberOf _
  20814. * @since 4.0.0
  20815. * @category Util
  20816. * @param {number} [start=0] The start of the range.
  20817. * @param {number} end The end of the range.
  20818. * @param {number} [step=1] The value to increment or decrement by.
  20819. * @returns {Array} Returns the range of numbers.
  20820. * @see _.inRange, _.range
  20821. * @example
  20822. *
  20823. * _.rangeRight(4);
  20824. * // => [3, 2, 1, 0]
  20825. *
  20826. * _.rangeRight(-4);
  20827. * // => [-3, -2, -1, 0]
  20828. *
  20829. * _.rangeRight(1, 5);
  20830. * // => [4, 3, 2, 1]
  20831. *
  20832. * _.rangeRight(0, 20, 5);
  20833. * // => [15, 10, 5, 0]
  20834. *
  20835. * _.rangeRight(0, -4, -1);
  20836. * // => [-3, -2, -1, 0]
  20837. *
  20838. * _.rangeRight(1, 4, 0);
  20839. * // => [1, 1, 1]
  20840. *
  20841. * _.rangeRight(0);
  20842. * // => []
  20843. */
  20844. var rangeRight = createRange(true);
  20845. /**
  20846. * This method returns a new empty array.
  20847. *
  20848. * @static
  20849. * @memberOf _
  20850. * @since 4.13.0
  20851. * @category Util
  20852. * @returns {Array} Returns the new empty array.
  20853. * @example
  20854. *
  20855. * var arrays = _.times(2, _.stubArray);
  20856. *
  20857. * console.log(arrays);
  20858. * // => [[], []]
  20859. *
  20860. * console.log(arrays[0] === arrays[1]);
  20861. * // => false
  20862. */
  20863. function stubArray() {
  20864. return [];
  20865. }
  20866. /**
  20867. * This method returns `false`.
  20868. *
  20869. * @static
  20870. * @memberOf _
  20871. * @since 4.13.0
  20872. * @category Util
  20873. * @returns {boolean} Returns `false`.
  20874. * @example
  20875. *
  20876. * _.times(2, _.stubFalse);
  20877. * // => [false, false]
  20878. */
  20879. function stubFalse() {
  20880. return false;
  20881. }
  20882. /**
  20883. * This method returns a new empty object.
  20884. *
  20885. * @static
  20886. * @memberOf _
  20887. * @since 4.13.0
  20888. * @category Util
  20889. * @returns {Object} Returns the new empty object.
  20890. * @example
  20891. *
  20892. * var objects = _.times(2, _.stubObject);
  20893. *
  20894. * console.log(objects);
  20895. * // => [{}, {}]
  20896. *
  20897. * console.log(objects[0] === objects[1]);
  20898. * // => false
  20899. */
  20900. function stubObject() {
  20901. return {};
  20902. }
  20903. /**
  20904. * This method returns an empty string.
  20905. *
  20906. * @static
  20907. * @memberOf _
  20908. * @since 4.13.0
  20909. * @category Util
  20910. * @returns {string} Returns the empty string.
  20911. * @example
  20912. *
  20913. * _.times(2, _.stubString);
  20914. * // => ['', '']
  20915. */
  20916. function stubString() {
  20917. return '';
  20918. }
  20919. /**
  20920. * This method returns `true`.
  20921. *
  20922. * @static
  20923. * @memberOf _
  20924. * @since 4.13.0
  20925. * @category Util
  20926. * @returns {boolean} Returns `true`.
  20927. * @example
  20928. *
  20929. * _.times(2, _.stubTrue);
  20930. * // => [true, true]
  20931. */
  20932. function stubTrue() {
  20933. return true;
  20934. }
  20935. /**
  20936. * Invokes the iteratee `n` times, returning an array of the results of
  20937. * each invocation. The iteratee is invoked with one argument; (index).
  20938. *
  20939. * @static
  20940. * @since 0.1.0
  20941. * @memberOf _
  20942. * @category Util
  20943. * @param {number} n The number of times to invoke `iteratee`.
  20944. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  20945. * @returns {Array} Returns the array of results.
  20946. * @example
  20947. *
  20948. * _.times(3, String);
  20949. * // => ['0', '1', '2']
  20950. *
  20951. * _.times(4, _.constant(0));
  20952. * // => [0, 0, 0, 0]
  20953. */
  20954. function times(n, iteratee) {
  20955. n = toInteger(n);
  20956. if (n < 1 || n > MAX_SAFE_INTEGER) {
  20957. return [];
  20958. }
  20959. var index = MAX_ARRAY_LENGTH,
  20960. length = nativeMin(n, MAX_ARRAY_LENGTH);
  20961. iteratee = getIteratee(iteratee);
  20962. n -= MAX_ARRAY_LENGTH;
  20963. var result = baseTimes(length, iteratee);
  20964. while (++index < n) {
  20965. iteratee(index);
  20966. }
  20967. return result;
  20968. }
  20969. /**
  20970. * Converts `value` to a property path array.
  20971. *
  20972. * @static
  20973. * @memberOf _
  20974. * @since 4.0.0
  20975. * @category Util
  20976. * @param {*} value The value to convert.
  20977. * @returns {Array} Returns the new property path array.
  20978. * @example
  20979. *
  20980. * _.toPath('a.b.c');
  20981. * // => ['a', 'b', 'c']
  20982. *
  20983. * _.toPath('a[0].b.c');
  20984. * // => ['a', '0', 'b', 'c']
  20985. */
  20986. function toPath(value) {
  20987. if (isArray(value)) {
  20988. return arrayMap(value, toKey);
  20989. }
  20990. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  20991. }
  20992. /**
  20993. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  20994. *
  20995. * @static
  20996. * @since 0.1.0
  20997. * @memberOf _
  20998. * @category Util
  20999. * @param {string} [prefix=''] The value to prefix the ID with.
  21000. * @returns {string} Returns the unique ID.
  21001. * @example
  21002. *
  21003. * _.uniqueId('contact_');
  21004. * // => 'contact_104'
  21005. *
  21006. * _.uniqueId();
  21007. * // => '105'
  21008. */
  21009. function uniqueId(prefix) {
  21010. var id = ++idCounter;
  21011. return toString(prefix) + id;
  21012. }
  21013. /*------------------------------------------------------------------------*/
  21014. /**
  21015. * Adds two numbers.
  21016. *
  21017. * @static
  21018. * @memberOf _
  21019. * @since 3.4.0
  21020. * @category Math
  21021. * @param {number} augend The first number in an addition.
  21022. * @param {number} addend The second number in an addition.
  21023. * @returns {number} Returns the total.
  21024. * @example
  21025. *
  21026. * _.add(6, 4);
  21027. * // => 10
  21028. */
  21029. var add = createMathOperation(function(augend, addend) {
  21030. return augend + addend;
  21031. }, 0);
  21032. /**
  21033. * Computes `number` rounded up to `precision`.
  21034. *
  21035. * @static
  21036. * @memberOf _
  21037. * @since 3.10.0
  21038. * @category Math
  21039. * @param {number} number The number to round up.
  21040. * @param {number} [precision=0] The precision to round up to.
  21041. * @returns {number} Returns the rounded up number.
  21042. * @example
  21043. *
  21044. * _.ceil(4.006);
  21045. * // => 5
  21046. *
  21047. * _.ceil(6.004, 2);
  21048. * // => 6.01
  21049. *
  21050. * _.ceil(6040, -2);
  21051. * // => 6100
  21052. */
  21053. var ceil = createRound('ceil');
  21054. /**
  21055. * Divide two numbers.
  21056. *
  21057. * @static
  21058. * @memberOf _
  21059. * @since 4.7.0
  21060. * @category Math
  21061. * @param {number} dividend The first number in a division.
  21062. * @param {number} divisor The second number in a division.
  21063. * @returns {number} Returns the quotient.
  21064. * @example
  21065. *
  21066. * _.divide(6, 4);
  21067. * // => 1.5
  21068. */
  21069. var divide = createMathOperation(function(dividend, divisor) {
  21070. return dividend / divisor;
  21071. }, 1);
  21072. /**
  21073. * Computes `number` rounded down to `precision`.
  21074. *
  21075. * @static
  21076. * @memberOf _
  21077. * @since 3.10.0
  21078. * @category Math
  21079. * @param {number} number The number to round down.
  21080. * @param {number} [precision=0] The precision to round down to.
  21081. * @returns {number} Returns the rounded down number.
  21082. * @example
  21083. *
  21084. * _.floor(4.006);
  21085. * // => 4
  21086. *
  21087. * _.floor(0.046, 2);
  21088. * // => 0.04
  21089. *
  21090. * _.floor(4060, -2);
  21091. * // => 4000
  21092. */
  21093. var floor = createRound('floor');
  21094. /**
  21095. * Computes the maximum value of `array`. If `array` is empty or falsey,
  21096. * `undefined` is returned.
  21097. *
  21098. * @static
  21099. * @since 0.1.0
  21100. * @memberOf _
  21101. * @category Math
  21102. * @param {Array} array The array to iterate over.
  21103. * @returns {*} Returns the maximum value.
  21104. * @example
  21105. *
  21106. * _.max([4, 2, 8, 6]);
  21107. * // => 8
  21108. *
  21109. * _.max([]);
  21110. * // => undefined
  21111. */
  21112. function max(array) {
  21113. return (array && array.length)
  21114. ? baseExtremum(array, identity, baseGt)
  21115. : undefined$1;
  21116. }
  21117. /**
  21118. * This method is like `_.max` except that it accepts `iteratee` which is
  21119. * invoked for each element in `array` to generate the criterion by which
  21120. * the value is ranked. The iteratee is invoked with one argument: (value).
  21121. *
  21122. * @static
  21123. * @memberOf _
  21124. * @since 4.0.0
  21125. * @category Math
  21126. * @param {Array} array The array to iterate over.
  21127. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21128. * @returns {*} Returns the maximum value.
  21129. * @example
  21130. *
  21131. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  21132. *
  21133. * _.maxBy(objects, function(o) { return o.n; });
  21134. * // => { 'n': 2 }
  21135. *
  21136. * // The `_.property` iteratee shorthand.
  21137. * _.maxBy(objects, 'n');
  21138. * // => { 'n': 2 }
  21139. */
  21140. function maxBy(array, iteratee) {
  21141. return (array && array.length)
  21142. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  21143. : undefined$1;
  21144. }
  21145. /**
  21146. * Computes the mean of the values in `array`.
  21147. *
  21148. * @static
  21149. * @memberOf _
  21150. * @since 4.0.0
  21151. * @category Math
  21152. * @param {Array} array The array to iterate over.
  21153. * @returns {number} Returns the mean.
  21154. * @example
  21155. *
  21156. * _.mean([4, 2, 8, 6]);
  21157. * // => 5
  21158. */
  21159. function mean(array) {
  21160. return baseMean(array, identity);
  21161. }
  21162. /**
  21163. * This method is like `_.mean` except that it accepts `iteratee` which is
  21164. * invoked for each element in `array` to generate the value to be averaged.
  21165. * The iteratee is invoked with one argument: (value).
  21166. *
  21167. * @static
  21168. * @memberOf _
  21169. * @since 4.7.0
  21170. * @category Math
  21171. * @param {Array} array The array to iterate over.
  21172. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21173. * @returns {number} Returns the mean.
  21174. * @example
  21175. *
  21176. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  21177. *
  21178. * _.meanBy(objects, function(o) { return o.n; });
  21179. * // => 5
  21180. *
  21181. * // The `_.property` iteratee shorthand.
  21182. * _.meanBy(objects, 'n');
  21183. * // => 5
  21184. */
  21185. function meanBy(array, iteratee) {
  21186. return baseMean(array, getIteratee(iteratee, 2));
  21187. }
  21188. /**
  21189. * Computes the minimum value of `array`. If `array` is empty or falsey,
  21190. * `undefined` is returned.
  21191. *
  21192. * @static
  21193. * @since 0.1.0
  21194. * @memberOf _
  21195. * @category Math
  21196. * @param {Array} array The array to iterate over.
  21197. * @returns {*} Returns the minimum value.
  21198. * @example
  21199. *
  21200. * _.min([4, 2, 8, 6]);
  21201. * // => 2
  21202. *
  21203. * _.min([]);
  21204. * // => undefined
  21205. */
  21206. function min(array) {
  21207. return (array && array.length)
  21208. ? baseExtremum(array, identity, baseLt)
  21209. : undefined$1;
  21210. }
  21211. /**
  21212. * This method is like `_.min` except that it accepts `iteratee` which is
  21213. * invoked for each element in `array` to generate the criterion by which
  21214. * the value is ranked. The iteratee is invoked with one argument: (value).
  21215. *
  21216. * @static
  21217. * @memberOf _
  21218. * @since 4.0.0
  21219. * @category Math
  21220. * @param {Array} array The array to iterate over.
  21221. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21222. * @returns {*} Returns the minimum value.
  21223. * @example
  21224. *
  21225. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  21226. *
  21227. * _.minBy(objects, function(o) { return o.n; });
  21228. * // => { 'n': 1 }
  21229. *
  21230. * // The `_.property` iteratee shorthand.
  21231. * _.minBy(objects, 'n');
  21232. * // => { 'n': 1 }
  21233. */
  21234. function minBy(array, iteratee) {
  21235. return (array && array.length)
  21236. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  21237. : undefined$1;
  21238. }
  21239. /**
  21240. * Multiply two numbers.
  21241. *
  21242. * @static
  21243. * @memberOf _
  21244. * @since 4.7.0
  21245. * @category Math
  21246. * @param {number} multiplier The first number in a multiplication.
  21247. * @param {number} multiplicand The second number in a multiplication.
  21248. * @returns {number} Returns the product.
  21249. * @example
  21250. *
  21251. * _.multiply(6, 4);
  21252. * // => 24
  21253. */
  21254. var multiply = createMathOperation(function(multiplier, multiplicand) {
  21255. return multiplier * multiplicand;
  21256. }, 1);
  21257. /**
  21258. * Computes `number` rounded to `precision`.
  21259. *
  21260. * @static
  21261. * @memberOf _
  21262. * @since 3.10.0
  21263. * @category Math
  21264. * @param {number} number The number to round.
  21265. * @param {number} [precision=0] The precision to round to.
  21266. * @returns {number} Returns the rounded number.
  21267. * @example
  21268. *
  21269. * _.round(4.006);
  21270. * // => 4
  21271. *
  21272. * _.round(4.006, 2);
  21273. * // => 4.01
  21274. *
  21275. * _.round(4060, -2);
  21276. * // => 4100
  21277. */
  21278. var round = createRound('round');
  21279. /**
  21280. * Subtract two numbers.
  21281. *
  21282. * @static
  21283. * @memberOf _
  21284. * @since 4.0.0
  21285. * @category Math
  21286. * @param {number} minuend The first number in a subtraction.
  21287. * @param {number} subtrahend The second number in a subtraction.
  21288. * @returns {number} Returns the difference.
  21289. * @example
  21290. *
  21291. * _.subtract(6, 4);
  21292. * // => 2
  21293. */
  21294. var subtract = createMathOperation(function(minuend, subtrahend) {
  21295. return minuend - subtrahend;
  21296. }, 0);
  21297. /**
  21298. * Computes the sum of the values in `array`.
  21299. *
  21300. * @static
  21301. * @memberOf _
  21302. * @since 3.4.0
  21303. * @category Math
  21304. * @param {Array} array The array to iterate over.
  21305. * @returns {number} Returns the sum.
  21306. * @example
  21307. *
  21308. * _.sum([4, 2, 8, 6]);
  21309. * // => 20
  21310. */
  21311. function sum(array) {
  21312. return (array && array.length)
  21313. ? baseSum(array, identity)
  21314. : 0;
  21315. }
  21316. /**
  21317. * This method is like `_.sum` except that it accepts `iteratee` which is
  21318. * invoked for each element in `array` to generate the value to be summed.
  21319. * The iteratee is invoked with one argument: (value).
  21320. *
  21321. * @static
  21322. * @memberOf _
  21323. * @since 4.0.0
  21324. * @category Math
  21325. * @param {Array} array The array to iterate over.
  21326. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21327. * @returns {number} Returns the sum.
  21328. * @example
  21329. *
  21330. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  21331. *
  21332. * _.sumBy(objects, function(o) { return o.n; });
  21333. * // => 20
  21334. *
  21335. * // The `_.property` iteratee shorthand.
  21336. * _.sumBy(objects, 'n');
  21337. * // => 20
  21338. */
  21339. function sumBy(array, iteratee) {
  21340. return (array && array.length)
  21341. ? baseSum(array, getIteratee(iteratee, 2))
  21342. : 0;
  21343. }
  21344. /*------------------------------------------------------------------------*/
  21345. // Add methods that return wrapped values in chain sequences.
  21346. lodash.after = after;
  21347. lodash.ary = ary;
  21348. lodash.assign = assign;
  21349. lodash.assignIn = assignIn;
  21350. lodash.assignInWith = assignInWith;
  21351. lodash.assignWith = assignWith;
  21352. lodash.at = at;
  21353. lodash.before = before;
  21354. lodash.bind = bind;
  21355. lodash.bindAll = bindAll;
  21356. lodash.bindKey = bindKey;
  21357. lodash.castArray = castArray;
  21358. lodash.chain = chain;
  21359. lodash.chunk = chunk;
  21360. lodash.compact = compact;
  21361. lodash.concat = concat;
  21362. lodash.cond = cond;
  21363. lodash.conforms = conforms;
  21364. lodash.constant = constant;
  21365. lodash.countBy = countBy;
  21366. lodash.create = create;
  21367. lodash.curry = curry;
  21368. lodash.curryRight = curryRight;
  21369. lodash.debounce = debounce;
  21370. lodash.defaults = defaults;
  21371. lodash.defaultsDeep = defaultsDeep;
  21372. lodash.defer = defer;
  21373. lodash.delay = delay;
  21374. lodash.difference = difference;
  21375. lodash.differenceBy = differenceBy;
  21376. lodash.differenceWith = differenceWith;
  21377. lodash.drop = drop;
  21378. lodash.dropRight = dropRight;
  21379. lodash.dropRightWhile = dropRightWhile;
  21380. lodash.dropWhile = dropWhile;
  21381. lodash.fill = fill;
  21382. lodash.filter = filter;
  21383. lodash.flatMap = flatMap;
  21384. lodash.flatMapDeep = flatMapDeep;
  21385. lodash.flatMapDepth = flatMapDepth;
  21386. lodash.flatten = flatten;
  21387. lodash.flattenDeep = flattenDeep;
  21388. lodash.flattenDepth = flattenDepth;
  21389. lodash.flip = flip;
  21390. lodash.flow = flow;
  21391. lodash.flowRight = flowRight;
  21392. lodash.fromPairs = fromPairs;
  21393. lodash.functions = functions;
  21394. lodash.functionsIn = functionsIn;
  21395. lodash.groupBy = groupBy;
  21396. lodash.initial = initial;
  21397. lodash.intersection = intersection;
  21398. lodash.intersectionBy = intersectionBy;
  21399. lodash.intersectionWith = intersectionWith;
  21400. lodash.invert = invert;
  21401. lodash.invertBy = invertBy;
  21402. lodash.invokeMap = invokeMap;
  21403. lodash.iteratee = iteratee;
  21404. lodash.keyBy = keyBy;
  21405. lodash.keys = keys;
  21406. lodash.keysIn = keysIn;
  21407. lodash.map = map;
  21408. lodash.mapKeys = mapKeys;
  21409. lodash.mapValues = mapValues;
  21410. lodash.matches = matches;
  21411. lodash.matchesProperty = matchesProperty;
  21412. lodash.memoize = memoize;
  21413. lodash.merge = merge;
  21414. lodash.mergeWith = mergeWith;
  21415. lodash.method = method;
  21416. lodash.methodOf = methodOf;
  21417. lodash.mixin = mixin;
  21418. lodash.negate = negate;
  21419. lodash.nthArg = nthArg;
  21420. lodash.omit = omit;
  21421. lodash.omitBy = omitBy;
  21422. lodash.once = once;
  21423. lodash.orderBy = orderBy;
  21424. lodash.over = over;
  21425. lodash.overArgs = overArgs;
  21426. lodash.overEvery = overEvery;
  21427. lodash.overSome = overSome;
  21428. lodash.partial = partial;
  21429. lodash.partialRight = partialRight;
  21430. lodash.partition = partition;
  21431. lodash.pick = pick;
  21432. lodash.pickBy = pickBy;
  21433. lodash.property = property;
  21434. lodash.propertyOf = propertyOf;
  21435. lodash.pull = pull;
  21436. lodash.pullAll = pullAll;
  21437. lodash.pullAllBy = pullAllBy;
  21438. lodash.pullAllWith = pullAllWith;
  21439. lodash.pullAt = pullAt;
  21440. lodash.range = range;
  21441. lodash.rangeRight = rangeRight;
  21442. lodash.rearg = rearg;
  21443. lodash.reject = reject;
  21444. lodash.remove = remove;
  21445. lodash.rest = rest;
  21446. lodash.reverse = reverse;
  21447. lodash.sampleSize = sampleSize;
  21448. lodash.set = set;
  21449. lodash.setWith = setWith;
  21450. lodash.shuffle = shuffle;
  21451. lodash.slice = slice;
  21452. lodash.sortBy = sortBy;
  21453. lodash.sortedUniq = sortedUniq;
  21454. lodash.sortedUniqBy = sortedUniqBy;
  21455. lodash.split = split;
  21456. lodash.spread = spread;
  21457. lodash.tail = tail;
  21458. lodash.take = take;
  21459. lodash.takeRight = takeRight;
  21460. lodash.takeRightWhile = takeRightWhile;
  21461. lodash.takeWhile = takeWhile;
  21462. lodash.tap = tap;
  21463. lodash.throttle = throttle;
  21464. lodash.thru = thru;
  21465. lodash.toArray = toArray;
  21466. lodash.toPairs = toPairs;
  21467. lodash.toPairsIn = toPairsIn;
  21468. lodash.toPath = toPath;
  21469. lodash.toPlainObject = toPlainObject;
  21470. lodash.transform = transform;
  21471. lodash.unary = unary;
  21472. lodash.union = union;
  21473. lodash.unionBy = unionBy;
  21474. lodash.unionWith = unionWith;
  21475. lodash.uniq = uniq;
  21476. lodash.uniqBy = uniqBy;
  21477. lodash.uniqWith = uniqWith;
  21478. lodash.unset = unset;
  21479. lodash.unzip = unzip;
  21480. lodash.unzipWith = unzipWith;
  21481. lodash.update = update;
  21482. lodash.updateWith = updateWith;
  21483. lodash.values = values;
  21484. lodash.valuesIn = valuesIn;
  21485. lodash.without = without;
  21486. lodash.words = words;
  21487. lodash.wrap = wrap;
  21488. lodash.xor = xor;
  21489. lodash.xorBy = xorBy;
  21490. lodash.xorWith = xorWith;
  21491. lodash.zip = zip;
  21492. lodash.zipObject = zipObject;
  21493. lodash.zipObjectDeep = zipObjectDeep;
  21494. lodash.zipWith = zipWith;
  21495. // Add aliases.
  21496. lodash.entries = toPairs;
  21497. lodash.entriesIn = toPairsIn;
  21498. lodash.extend = assignIn;
  21499. lodash.extendWith = assignInWith;
  21500. // Add methods to `lodash.prototype`.
  21501. mixin(lodash, lodash);
  21502. /*------------------------------------------------------------------------*/
  21503. // Add methods that return unwrapped values in chain sequences.
  21504. lodash.add = add;
  21505. lodash.attempt = attempt;
  21506. lodash.camelCase = camelCase;
  21507. lodash.capitalize = capitalize;
  21508. lodash.ceil = ceil;
  21509. lodash.clamp = clamp;
  21510. lodash.clone = clone;
  21511. lodash.cloneDeep = cloneDeep;
  21512. lodash.cloneDeepWith = cloneDeepWith;
  21513. lodash.cloneWith = cloneWith;
  21514. lodash.conformsTo = conformsTo;
  21515. lodash.deburr = deburr;
  21516. lodash.defaultTo = defaultTo;
  21517. lodash.divide = divide;
  21518. lodash.endsWith = endsWith;
  21519. lodash.eq = eq;
  21520. lodash.escape = escape;
  21521. lodash.escapeRegExp = escapeRegExp;
  21522. lodash.every = every;
  21523. lodash.find = find;
  21524. lodash.findIndex = findIndex;
  21525. lodash.findKey = findKey;
  21526. lodash.findLast = findLast;
  21527. lodash.findLastIndex = findLastIndex;
  21528. lodash.findLastKey = findLastKey;
  21529. lodash.floor = floor;
  21530. lodash.forEach = forEach;
  21531. lodash.forEachRight = forEachRight;
  21532. lodash.forIn = forIn;
  21533. lodash.forInRight = forInRight;
  21534. lodash.forOwn = forOwn;
  21535. lodash.forOwnRight = forOwnRight;
  21536. lodash.get = get;
  21537. lodash.gt = gt;
  21538. lodash.gte = gte;
  21539. lodash.has = has;
  21540. lodash.hasIn = hasIn;
  21541. lodash.head = head;
  21542. lodash.identity = identity;
  21543. lodash.includes = includes;
  21544. lodash.indexOf = indexOf;
  21545. lodash.inRange = inRange;
  21546. lodash.invoke = invoke;
  21547. lodash.isArguments = isArguments;
  21548. lodash.isArray = isArray;
  21549. lodash.isArrayBuffer = isArrayBuffer;
  21550. lodash.isArrayLike = isArrayLike;
  21551. lodash.isArrayLikeObject = isArrayLikeObject;
  21552. lodash.isBoolean = isBoolean;
  21553. lodash.isBuffer = isBuffer;
  21554. lodash.isDate = isDate;
  21555. lodash.isElement = isElement;
  21556. lodash.isEmpty = isEmpty;
  21557. lodash.isEqual = isEqual;
  21558. lodash.isEqualWith = isEqualWith;
  21559. lodash.isError = isError;
  21560. lodash.isFinite = isFinite;
  21561. lodash.isFunction = isFunction;
  21562. lodash.isInteger = isInteger;
  21563. lodash.isLength = isLength;
  21564. lodash.isMap = isMap;
  21565. lodash.isMatch = isMatch;
  21566. lodash.isMatchWith = isMatchWith;
  21567. lodash.isNaN = isNaN;
  21568. lodash.isNative = isNative;
  21569. lodash.isNil = isNil;
  21570. lodash.isNull = isNull;
  21571. lodash.isNumber = isNumber;
  21572. lodash.isObject = isObject;
  21573. lodash.isObjectLike = isObjectLike;
  21574. lodash.isPlainObject = isPlainObject;
  21575. lodash.isRegExp = isRegExp;
  21576. lodash.isSafeInteger = isSafeInteger;
  21577. lodash.isSet = isSet;
  21578. lodash.isString = isString;
  21579. lodash.isSymbol = isSymbol;
  21580. lodash.isTypedArray = isTypedArray;
  21581. lodash.isUndefined = isUndefined;
  21582. lodash.isWeakMap = isWeakMap;
  21583. lodash.isWeakSet = isWeakSet;
  21584. lodash.join = join;
  21585. lodash.kebabCase = kebabCase;
  21586. lodash.last = last;
  21587. lodash.lastIndexOf = lastIndexOf;
  21588. lodash.lowerCase = lowerCase;
  21589. lodash.lowerFirst = lowerFirst;
  21590. lodash.lt = lt;
  21591. lodash.lte = lte;
  21592. lodash.max = max;
  21593. lodash.maxBy = maxBy;
  21594. lodash.mean = mean;
  21595. lodash.meanBy = meanBy;
  21596. lodash.min = min;
  21597. lodash.minBy = minBy;
  21598. lodash.stubArray = stubArray;
  21599. lodash.stubFalse = stubFalse;
  21600. lodash.stubObject = stubObject;
  21601. lodash.stubString = stubString;
  21602. lodash.stubTrue = stubTrue;
  21603. lodash.multiply = multiply;
  21604. lodash.nth = nth;
  21605. lodash.noConflict = noConflict;
  21606. lodash.noop = noop;
  21607. lodash.now = now;
  21608. lodash.pad = pad;
  21609. lodash.padEnd = padEnd;
  21610. lodash.padStart = padStart;
  21611. lodash.parseInt = parseInt;
  21612. lodash.random = random;
  21613. lodash.reduce = reduce;
  21614. lodash.reduceRight = reduceRight;
  21615. lodash.repeat = repeat;
  21616. lodash.replace = replace;
  21617. lodash.result = result;
  21618. lodash.round = round;
  21619. lodash.runInContext = runInContext;
  21620. lodash.sample = sample;
  21621. lodash.size = size;
  21622. lodash.snakeCase = snakeCase;
  21623. lodash.some = some;
  21624. lodash.sortedIndex = sortedIndex;
  21625. lodash.sortedIndexBy = sortedIndexBy;
  21626. lodash.sortedIndexOf = sortedIndexOf;
  21627. lodash.sortedLastIndex = sortedLastIndex;
  21628. lodash.sortedLastIndexBy = sortedLastIndexBy;
  21629. lodash.sortedLastIndexOf = sortedLastIndexOf;
  21630. lodash.startCase = startCase;
  21631. lodash.startsWith = startsWith;
  21632. lodash.subtract = subtract;
  21633. lodash.sum = sum;
  21634. lodash.sumBy = sumBy;
  21635. lodash.template = template;
  21636. lodash.times = times;
  21637. lodash.toFinite = toFinite;
  21638. lodash.toInteger = toInteger;
  21639. lodash.toLength = toLength;
  21640. lodash.toLower = toLower;
  21641. lodash.toNumber = toNumber;
  21642. lodash.toSafeInteger = toSafeInteger;
  21643. lodash.toString = toString;
  21644. lodash.toUpper = toUpper;
  21645. lodash.trim = trim;
  21646. lodash.trimEnd = trimEnd;
  21647. lodash.trimStart = trimStart;
  21648. lodash.truncate = truncate;
  21649. lodash.unescape = unescape;
  21650. lodash.uniqueId = uniqueId;
  21651. lodash.upperCase = upperCase;
  21652. lodash.upperFirst = upperFirst;
  21653. // Add aliases.
  21654. lodash.each = forEach;
  21655. lodash.eachRight = forEachRight;
  21656. lodash.first = head;
  21657. mixin(lodash, (function() {
  21658. var source = {};
  21659. baseForOwn(lodash, function(func, methodName) {
  21660. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  21661. source[methodName] = func;
  21662. }
  21663. });
  21664. return source;
  21665. }()), { 'chain': false });
  21666. /*------------------------------------------------------------------------*/
  21667. /**
  21668. * The semantic version number.
  21669. *
  21670. * @static
  21671. * @memberOf _
  21672. * @type {string}
  21673. */
  21674. lodash.VERSION = VERSION;
  21675. // Assign default placeholders.
  21676. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  21677. lodash[methodName].placeholder = lodash;
  21678. });
  21679. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  21680. arrayEach(['drop', 'take'], function(methodName, index) {
  21681. LazyWrapper.prototype[methodName] = function(n) {
  21682. n = n === undefined$1 ? 1 : nativeMax(toInteger(n), 0);
  21683. var result = (this.__filtered__ && !index)
  21684. ? new LazyWrapper(this)
  21685. : this.clone();
  21686. if (result.__filtered__) {
  21687. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  21688. } else {
  21689. result.__views__.push({
  21690. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  21691. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  21692. });
  21693. }
  21694. return result;
  21695. };
  21696. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  21697. return this.reverse()[methodName](n).reverse();
  21698. };
  21699. });
  21700. // Add `LazyWrapper` methods that accept an `iteratee` value.
  21701. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  21702. var type = index + 1,
  21703. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  21704. LazyWrapper.prototype[methodName] = function(iteratee) {
  21705. var result = this.clone();
  21706. result.__iteratees__.push({
  21707. 'iteratee': getIteratee(iteratee, 3),
  21708. 'type': type
  21709. });
  21710. result.__filtered__ = result.__filtered__ || isFilter;
  21711. return result;
  21712. };
  21713. });
  21714. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  21715. arrayEach(['head', 'last'], function(methodName, index) {
  21716. var takeName = 'take' + (index ? 'Right' : '');
  21717. LazyWrapper.prototype[methodName] = function() {
  21718. return this[takeName](1).value()[0];
  21719. };
  21720. });
  21721. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  21722. arrayEach(['initial', 'tail'], function(methodName, index) {
  21723. var dropName = 'drop' + (index ? '' : 'Right');
  21724. LazyWrapper.prototype[methodName] = function() {
  21725. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  21726. };
  21727. });
  21728. LazyWrapper.prototype.compact = function() {
  21729. return this.filter(identity);
  21730. };
  21731. LazyWrapper.prototype.find = function(predicate) {
  21732. return this.filter(predicate).head();
  21733. };
  21734. LazyWrapper.prototype.findLast = function(predicate) {
  21735. return this.reverse().find(predicate);
  21736. };
  21737. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  21738. if (typeof path == 'function') {
  21739. return new LazyWrapper(this);
  21740. }
  21741. return this.map(function(value) {
  21742. return baseInvoke(value, path, args);
  21743. });
  21744. });
  21745. LazyWrapper.prototype.reject = function(predicate) {
  21746. return this.filter(negate(getIteratee(predicate)));
  21747. };
  21748. LazyWrapper.prototype.slice = function(start, end) {
  21749. start = toInteger(start);
  21750. var result = this;
  21751. if (result.__filtered__ && (start > 0 || end < 0)) {
  21752. return new LazyWrapper(result);
  21753. }
  21754. if (start < 0) {
  21755. result = result.takeRight(-start);
  21756. } else if (start) {
  21757. result = result.drop(start);
  21758. }
  21759. if (end !== undefined$1) {
  21760. end = toInteger(end);
  21761. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  21762. }
  21763. return result;
  21764. };
  21765. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  21766. return this.reverse().takeWhile(predicate).reverse();
  21767. };
  21768. LazyWrapper.prototype.toArray = function() {
  21769. return this.take(MAX_ARRAY_LENGTH);
  21770. };
  21771. // Add `LazyWrapper` methods to `lodash.prototype`.
  21772. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  21773. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  21774. isTaker = /^(?:head|last)$/.test(methodName),
  21775. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  21776. retUnwrapped = isTaker || /^find/.test(methodName);
  21777. if (!lodashFunc) {
  21778. return;
  21779. }
  21780. lodash.prototype[methodName] = function() {
  21781. var value = this.__wrapped__,
  21782. args = isTaker ? [1] : arguments,
  21783. isLazy = value instanceof LazyWrapper,
  21784. iteratee = args[0],
  21785. useLazy = isLazy || isArray(value);
  21786. var interceptor = function(value) {
  21787. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  21788. return (isTaker && chainAll) ? result[0] : result;
  21789. };
  21790. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  21791. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  21792. isLazy = useLazy = false;
  21793. }
  21794. var chainAll = this.__chain__,
  21795. isHybrid = !!this.__actions__.length,
  21796. isUnwrapped = retUnwrapped && !chainAll,
  21797. onlyLazy = isLazy && !isHybrid;
  21798. if (!retUnwrapped && useLazy) {
  21799. value = onlyLazy ? value : new LazyWrapper(this);
  21800. var result = func.apply(value, args);
  21801. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined$1 });
  21802. return new LodashWrapper(result, chainAll);
  21803. }
  21804. if (isUnwrapped && onlyLazy) {
  21805. return func.apply(this, args);
  21806. }
  21807. result = this.thru(interceptor);
  21808. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  21809. };
  21810. });
  21811. // Add `Array` methods to `lodash.prototype`.
  21812. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  21813. var func = arrayProto[methodName],
  21814. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  21815. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  21816. lodash.prototype[methodName] = function() {
  21817. var args = arguments;
  21818. if (retUnwrapped && !this.__chain__) {
  21819. var value = this.value();
  21820. return func.apply(isArray(value) ? value : [], args);
  21821. }
  21822. return this[chainName](function(value) {
  21823. return func.apply(isArray(value) ? value : [], args);
  21824. });
  21825. };
  21826. });
  21827. // Map minified method names to their real names.
  21828. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  21829. var lodashFunc = lodash[methodName];
  21830. if (lodashFunc) {
  21831. var key = lodashFunc.name + '';
  21832. if (!hasOwnProperty.call(realNames, key)) {
  21833. realNames[key] = [];
  21834. }
  21835. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  21836. }
  21837. });
  21838. realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
  21839. 'name': 'wrapper',
  21840. 'func': undefined$1
  21841. }];
  21842. // Add methods to `LazyWrapper`.
  21843. LazyWrapper.prototype.clone = lazyClone;
  21844. LazyWrapper.prototype.reverse = lazyReverse;
  21845. LazyWrapper.prototype.value = lazyValue;
  21846. // Add chain sequence methods to the `lodash` wrapper.
  21847. lodash.prototype.at = wrapperAt;
  21848. lodash.prototype.chain = wrapperChain;
  21849. lodash.prototype.commit = wrapperCommit;
  21850. lodash.prototype.next = wrapperNext;
  21851. lodash.prototype.plant = wrapperPlant;
  21852. lodash.prototype.reverse = wrapperReverse;
  21853. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  21854. // Add lazy aliases.
  21855. lodash.prototype.first = lodash.prototype.head;
  21856. if (symIterator) {
  21857. lodash.prototype[symIterator] = wrapperToIterator;
  21858. }
  21859. return lodash;
  21860. });
  21861. /*--------------------------------------------------------------------------*/
  21862. // Export lodash.
  21863. var _ = runInContext();
  21864. // Some AMD build optimizers, like r.js, check for condition patterns like:
  21865. if (freeModule) {
  21866. // Export for Node.js.
  21867. (freeModule.exports = _)._ = _;
  21868. // Export for CommonJS support.
  21869. freeExports._ = _;
  21870. }
  21871. else {
  21872. // Export to the global object.
  21873. root._ = _;
  21874. }
  21875. }.call(commonjsGlobal));
  21876. });
  21877. var header = {
  21878. color: "red",
  21879. backgroundColor: "red",
  21880. activeColor: "red",
  21881. btnList: [
  21882. {
  21883. btnKey: "ade5d065a113432e8091a1c5bc819c57-934f270c08b14e928bf0c2ae8e1a937d-header-0",
  21884. iconId: "deviceID",
  21885. part: "left",
  21886. defaultActive: 1,
  21887. isrender: 1,
  21888. themeId: "934f270c08b14e928bf0c2ae8e1a937d"
  21889. },
  21890. {
  21891. btnKey: "ade5d065a113432e8091a1c5bc819c57-934f270c08b14e928bf0c2ae8e1a937d-header-1",
  21892. iconId: "deviceName",
  21893. part: "left",
  21894. defaultActive: 1,
  21895. isrender: 1,
  21896. themeId: "934f270c08b14e928bf0c2ae8e1a937d"
  21897. }
  21898. ]
  21899. };
  21900. var footer = {
  21901. color: "blue",
  21902. backgroundColor: "blue",
  21903. activeColor: "blue",
  21904. btnList: [
  21905. {
  21906. btnKey: "ade5d065a113432e8091a1c5bc819c57-934f270c08b14e928bf0c2ae8e1a937d-footer-0",
  21907. iconId: "play",
  21908. part: "left",
  21909. defaultActive: 0,
  21910. isrender: 0,
  21911. themeId: "934f270c08b14e928bf0c2ae8e1a937d"
  21912. }
  21913. ]
  21914. };
  21915. var defaultTheme = {
  21916. header: header,
  21917. footer: footer
  21918. };
  21919. var TimeLine$1 = function (jsPlugin) {
  21920. this.jsPlugin = jsPlugin;
  21921. var status = {
  21922. isMouseDown: false, // 鼠标是否按下
  21923. isOver: false, // 鼠标是否悬浮在进度条上
  21924. mousePosition: null,
  21925. oldTime: null,
  21926. nowTime: null,
  21927. moved: null,
  21928. hoverTime: '2018-12-07 12:00:00',
  21929. hoverLeft: 0,
  21930. timeTipShow: false,
  21931. randomNum: 123,
  21932. timeWidthTbls: [60, 1800, 3600, 86400, 259200], // 时间宽度单位(秒)
  21933. timeUnits: [
  21934. '范围: 1分钟; 单位: 秒',
  21935. '范围: 30分钟; 单位: 分钟',
  21936. '范围: 1小时; 单位: 分钟',
  21937. '范围: 1天; 单位: 小时',
  21938. '范围: 3天; 单位: 小时'
  21939. ], // 时间单位
  21940. drawPen: null,
  21941. timeSection: [],
  21942. canvasWidth: null,
  21943. canvasHeight: null,
  21944. timeTips: null
  21945. };
  21946. // Object.keys(status).forEach(element => {
  21947. // this[element] = status[element];
  21948. // });
  21949. var _this = this;
  21950. Object.keys(status).forEach(function(element){
  21951. _this[element] = status[element];
  21952. });
  21953. this.options = {
  21954. width: this.canvasWidth,
  21955. height: 48,
  21956. time: new Date().getTime(), //new Date("2019-10-31 00:00:00"),//
  21957. timeSection: [],
  21958. timeWidth: 0 // 0-3
  21959. };
  21960. TimeLine$1.prototype.subTime = function (time) {
  21961. if (time < 10) {
  21962. return '0' + time;
  21963. } else {
  21964. return time;
  21965. }
  21966. };
  21967. TimeLine$1.prototype.tranTime = function(time) {
  21968. var stringTime = time;
  21969. if (time) {
  21970. var newDate = new Date(time);
  21971. stringTime =
  21972. newDate.getFullYear() +
  21973. '/' +
  21974. (newDate.getMonth() + 1) +
  21975. '/' +
  21976. newDate.getDate() +
  21977. ' ' +
  21978. this.subTime(newDate.getHours()) +
  21979. ':' +
  21980. this.subTime(newDate.getMinutes()) +
  21981. ':' +
  21982. this.subTime(newDate.getSeconds());
  21983. }
  21984. return stringTime;
  21985. };
  21986. TimeLine$1.prototype.init = function (params) {
  21987. // document.getElementsByTagName("html")[0].addEventListener("mouseup", this.mouseUpFn(e,params.));
  21988. if(params.width) {
  21989. document.getElementById(params.id).setAttribute("width", parseInt(params.width,10) + 'px');
  21990. }
  21991. var that = this;
  21992. var opts = this.options;
  21993. that.randomNum = (Math.random() + '').split('.').join('');
  21994. that.timeWidthTblIndex = opts.timeWidth; // 当前使用时间宽度索引
  21995. // 12-10
  21996. //that.drawPanal = this.$refs.drawPanal;
  21997. var canvas = document.querySelector(`#${this.jsPlugin.id}-canvas`);
  21998. that.drawPen = canvas.getContext('2d');
  21999. that.nowTime = opts.time || Date.now(); // 当前时间点
  22000. that.timeSection = opts.timeSection || []; // 时间段记录区间
  22001. that.canvasWidth = canvas.offsetWidth;
  22002. that.canvasHeight = canvas.offsetHeight;
  22003. that.updata(); // 展示进度条
  22004. // 事件监听
  22005. document.getElementById(`${this.jsPlugin.id}-canvas`).addEventListener('mousemove', function(e){
  22006. if(that.options.readOnly){
  22007. return;
  22008. }
  22009. that.mousemove(e);
  22010. });
  22011. document.getElementById(`${this.jsPlugin.id}-canvas`).addEventListener('mouseover',function(e){
  22012. if(that.options.readOnly){
  22013. return;
  22014. }
  22015. that.mouseover(e);
  22016. });
  22017. document.getElementById(`${this.jsPlugin.id}-canvas`).addEventListener('mouseleave',function(e){
  22018. if(that.options.readOnly){
  22019. return;
  22020. }
  22021. that.mouseleave(e);
  22022. });
  22023. document.getElementById(`${this.jsPlugin.id}-canvas`).addEventListener('mousedown',function(e){
  22024. if(that.options.readOnly){
  22025. return;
  22026. }
  22027. that.mousedown(e);
  22028. });
  22029. document.getElementById(`${this.jsPlugin.id}-canvas`).addEventListener('mouseup',function(e){
  22030. if(that.options.readOnly){
  22031. return;
  22032. }
  22033. //debugger
  22034. var callback = params.onChange;
  22035. that.mouseUpFn(e,callback);
  22036. });
  22037. };
  22038. TimeLine$1.prototype.mousemove = function (e) {
  22039. // console.log("鼠标移动",e)
  22040. if (this.isMouseDown && this.isOver) {
  22041. var mouseOffset = this.mousePosition - e.pageX;
  22042. // fix点击引起mousemove的问题
  22043. if (mouseOffset === 0) {
  22044. return;
  22045. }
  22046. var timeOffsetUnit = 0;
  22047. switch(this.timeWidth){
  22048. case 60:
  22049. timeOffsetUnit = 1 / 10;
  22050. break;
  22051. case 1800:
  22052. timeOffsetUnit = 1 / 20 * 60;
  22053. break;
  22054. case 3600:
  22055. timeOffsetUnit = 1 / 20 * 60;
  22056. break;
  22057. case 86400:
  22058. //timeOffset =
  22059. timeOffsetUnit = 1 / 30 * 60 * 60;
  22060. break;
  22061. }
  22062. var currentTime = new Date(this.oldTime).getTime() +(mouseOffset * timeOffsetUnit * 1000);
  22063. //console.log("rurrentTime",this.oldTime,mouseOffset,currentTime,new Date(currentTime))
  22064. //console.log("currentTime", new Date(currentTime))
  22065. // var currentTime =
  22066. // this.oldTime +
  22067. // (mouseOffset / this.canvasWidth) *
  22068. // this.timeWidth *
  22069. // 1000;
  22070. // console.log("currentTime",new Date(this.oldTime), new Date(currentTime))
  22071. this.updata({ time: currentTime });
  22072. this.moved = true;
  22073. } else {
  22074. // 12-10
  22075. //var { left, top } = this.$utils.getOffset(this.$refs.drawPanal);
  22076. var left = parseInt(document.getElementById(`${this.jsPlugin.id}-canvas-container`).offsetLeft,10);
  22077. //12 -10
  22078. this.mousePosition = e.pageX - left;
  22079. this.updata(); // 更新画面
  22080. }
  22081. };
  22082. TimeLine$1.prototype.mousedown = function (e) {
  22083. this.isMouseDown = true;
  22084. this.mousePosition = e.pageX;
  22085. this.oldTime = this.nowTime;
  22086. // this.$emit('drag', true);
  22087. };
  22088. TimeLine$1.prototype.mouseover = function (e) {
  22089. this.isOver = true;
  22090. };
  22091. TimeLine$1.prototype.mouseleave = function (e) {
  22092. this.isOver = false;
  22093. this.isMouseDown = false;
  22094. this.updata();
  22095. };
  22096. TimeLine$1.prototype.changeSize = function (timeWidth) {
  22097. console.log("changeSize",timeWidth);
  22098. // if (w) {
  22099. // this.options.width = w;
  22100. // this.canvasWidth = w;
  22101. // }
  22102. // if (h) {
  22103. // this.options.height = h;
  22104. // this.canvasHeight = h;
  22105. // }
  22106. // console.log("tehis.optiosn",this.options)
  22107. this.options.timeWidth = timeWidth;
  22108. this.updata({timeWidth: timeWidth});
  22109. // this.$nextTick(() => {
  22110. // this.updata();
  22111. // });
  22112. };
  22113. TimeLine$1.prototype.mouseUpFn = function (e,callback) {
  22114. if (this.isMouseDown) {
  22115. this.isMouseDown = false;
  22116. if (this.moved) {
  22117. this.moved = false;
  22118. //12 -10
  22119. // this.$emit('change', [
  22120. // parseInt(this.nowTime),
  22121. // parseInt(this.oldTime)
  22122. // ]);
  22123. this.updata({ time: this.nowTime });
  22124. this.oldTime = this.nowTime;
  22125. callback(this.nowTime);
  22126. }
  22127. }
  22128. };
  22129. TimeLine$1.prototype.readOnly = function (data) {
  22130. console.log("更改为只读");
  22131. this.options.readOnly = true;
  22132. document.getElementById(`${this.jsPlugin.id}-canvas`).style.cursor = "not-allowed";
  22133. };
  22134. TimeLine$1.prototype.unReadOnly = function (data) {
  22135. console.log("更改为只读");
  22136. this.options.readOnly = false;
  22137. document.getElementById(`${this.jsPlugin.id}-canvas`).style.cursor = "pointer";
  22138. };
  22139. TimeLine$1.prototype.run = function (data) {
  22140. if (!this.isMouseDown) {
  22141. this.updata(data);
  22142. }
  22143. };
  22144. TimeLine$1.prototype.getTime = function (data) {
  22145. console.log("this",this);
  22146. console.log("当前时间",new Date(this.nowTime));
  22147. };
  22148. TimeLine$1.prototype.updata = function (data) {
  22149. var that = this;
  22150. data = data || {};
  22151. that.nowTime = data.time || that.nowTime;
  22152. that.timeSection = data.timeSection || that.timeSection;
  22153. that.timeWidthTblIndex = data.timeWidth || that.timeWidthTblIndex;
  22154. that.timeWidth = that.timeWidthTbls[data.timeWidth || that.timeWidthTblIndex];
  22155. that.timeUnit = that.timeUnits[data.timeWidth || that.timeWidthTblIndex];
  22156. if (data.timeWidth === 0) {
  22157. that.timeWidthTblIndex = 0;
  22158. that.timeWidth = that.timeWidthTbls[0];
  22159. that.timeUnit = that.timeUnits[0];
  22160. }
  22161. that.drawPen.fillStyle = '#000000';
  22162. that.drawPen.fillRect(0, 0, that.canvasWidth, that.canvasHeight);
  22163. that.drawScale(); // 画刻度
  22164. that.drawRecord(); // 画录像区间
  22165. that.drawOtherMsg(); // 画录像的其他信息
  22166. // 12-10
  22167. //that.$emit('update-time', that.nowTime);
  22168. document.getElementById(`${this.jsPlugin.id}-canvas-container`).style.width = this.options.width + 'px';
  22169. document.getElementById(`${this.jsPlugin.id}-canvas`).style.width = this.options.width + 'px';
  22170. document.getElementById(`${this.jsPlugin.id}-canvas-container`).style.height = this.options.height + 'px';
  22171. document.getElementById(`${this.jsPlugin.id}-canvas`).style.height = this.options.height + 'px';
  22172. };
  22173. TimeLine$1.prototype.drawSolidLine = function (startX, startY, endX, endY, lineWidth, color) {
  22174. this.drawPen.save();
  22175. this.drawPen.strokeStyle = color;
  22176. this.drawPen.lineWidth = lineWidth;
  22177. this.drawPen.beginPath();
  22178. this.drawPen.moveTo(startX, startY);
  22179. this.drawPen.lineTo(endX, endY);
  22180. this.drawPen.stroke();
  22181. this.drawPen.restore();
  22182. };
  22183. TimeLine$1.prototype.drawString = function (text, x, y, aling, color) {
  22184. this.drawPen.font = '12px serif';
  22185. this.drawPen.fillStyle = '#ffffff';
  22186. this.drawPen.textAlign = aling || 'left';
  22187. this.drawPen.fillText(text, x, y + 10);
  22188. };
  22189. TimeLine$1.prototype.drawScale = function () {
  22190. // console.log("drawScale",new Date(this.nowTime))
  22191. var that = this;
  22192. var lineColor = 'rgba(255,255,255)';
  22193. //that.nowTime = new Date("2019-12-31 01:50:00")
  22194. var startDate = new Date(that.nowTime); // 开始时间
  22195. var startYears = startDate.getFullYear(); // 起始的秒数
  22196. var starSecond = startDate.getSeconds(); // 起始的秒数
  22197. var starMin = startDate.getMinutes(); // 起始的分钟数
  22198. var startHours = startDate.getHours(); // 起始的小时
  22199. var startDay = startDate.getDate(); // 起始的日期
  22200. //console.log("startDay",startDay)
  22201. var OffsetLeft = starMin * 60 + starSecond; // 偏移量
  22202. // debugger;
  22203. var curScale = 0; // 计算时间点
  22204. switch (that.timeWidth) {
  22205. case 60: {
  22206. // debugger
  22207. var dotNum = parseInt(that.canvasWidth / 10); // 每10像素一个点
  22208. startDate.setSeconds(startDate.getSeconds() - parseInt(dotNum /2,10)); // 从现在时间的一半开始画起
  22209. startDay = startDate.getDate();
  22210. startHours = startDate.getHours();
  22211. starMin = startDate.getMinutes();
  22212. starSecond = startDate.getSeconds();
  22213. // console.log("domNum",dotNum);
  22214. // console.log("starSecond",starSecond)
  22215. for (var i = 0; i < dotNum; i++) {
  22216. // debugger;
  22217. // debugger;
  22218. // console.log("starSecond",starSecond,curScale)
  22219. curScale = starSecond + i;
  22220. startDate.setSeconds(curScale);
  22221. // debugger;
  22222. //debugger;
  22223. // console.log("startDate",startDate,curScale)
  22224. // 每一个整10秒画一次线和文字
  22225. if (curScale % 10 === 0) {
  22226. that.drawSolidLine(
  22227. (i * that.canvasWidth) / dotNum,
  22228. 8,
  22229. (i * that.canvasWidth) / dotNum ,
  22230. (that.canvasHeight / 5) + 8,
  22231. 1,
  22232. lineColor
  22233. );
  22234. var timeString =
  22235. this.subTime(startDate.getHours()) +
  22236. ':' +
  22237. this.subTime(startDate.getMinutes()) +
  22238. ':' +
  22239. this.subTime(startDate.getSeconds());
  22240. that.drawString(
  22241. timeString,
  22242. (i * that.canvasWidth) / dotNum,
  22243. (that.canvasHeight / 5) * 2.5,
  22244. 'center',
  22245. 'rgba(255,255,255,0.3)'
  22246. );
  22247. // console.log("timeString",timeString)
  22248. } else {
  22249. // console.log("画短线",(i * that.canvasWidth) / 60,0,(i * that.canvasWidth) / 60,(that.canvasHeight / 5) * 0.5,1)
  22250. // 只画一次线
  22251. that.drawSolidLine(
  22252. (i * that.canvasWidth) / dotNum,
  22253. 8,
  22254. (i * that.canvasWidth) / dotNum,
  22255. (that.canvasHeight / 5) * 0.5 + 8,
  22256. 1,
  22257. lineColor
  22258. );
  22259. }
  22260. /**
  22261. * 偏移距离超过60,setSeconds会每次累加1到分钟,因此绘图完成后需要复原到当前分钟,再次计算偏移
  22262. */
  22263. startDate.setDate(startDay);
  22264. startDate.setHours(startHours);
  22265. startDate.setMinutes(starMin);
  22266. }
  22267. // for (var i = 0; i < 60; i++) {
  22268. // curScale = starSecond + i;
  22269. // if (curScale > 60) {
  22270. // curScale = curScale - 60;
  22271. // }
  22272. // startDate.setSeconds(curScale);
  22273. // // 每一个整10秒画一次线和文字
  22274. // if (curScale % 10 === 0) {
  22275. // that.drawSolidLine(
  22276. // (i * that.canvasWidth) / 60,
  22277. // 0,
  22278. // (i * that.canvasWidth) / 60,
  22279. // (that.canvasHeight / 5) * 1.5,
  22280. // 1,
  22281. // lineColor
  22282. // );
  22283. // var timeString =
  22284. // this.subTime(startDate.getHours()) +
  22285. // ':' +
  22286. // this.subTime(startDate.getMinutes()) +
  22287. // ':' +
  22288. // this.subTime(startDate.getSeconds());
  22289. // that.drawString(
  22290. // timeString,
  22291. // (i * that.canvasWidth) / 60,
  22292. // (that.canvasHeight / 5) * 2.5,
  22293. // 'center',
  22294. // 'rgba(255,255,255,0.3)'
  22295. // );
  22296. // } else {
  22297. // // 只画一次线
  22298. // that.drawSolidLine(
  22299. // (i * that.canvasWidth) / 60,
  22300. // 0,
  22301. // (i * that.canvasWidth) / 60,
  22302. // (that.canvasHeight / 5) * 0.5,
  22303. // 1,
  22304. // lineColor
  22305. // );
  22306. // }
  22307. // }
  22308. break;
  22309. }
  22310. case 1800: {
  22311. // 30分钟
  22312. var dotNum = parseInt(that.canvasWidth / 20); // 每10像素一个点
  22313. startDate.setMinutes(startDate.getMinutes() - parseInt(dotNum / 2,10));
  22314. // starSecond = startDate.getSeconds();
  22315. startHours = startDate.getHours();
  22316. starMin = startDate.getMinutes();
  22317. //console.log("dotNum",dotNum,starMin)
  22318. for (var i = 0; i <= dotNum; i++) {
  22319. curScale = starMin + i;
  22320. //console.log("curScale",curScale)
  22321. // if (curScale > 60) {
  22322. // curScale = curScale - 60;
  22323. // }
  22324. startDate.setMinutes(curScale);
  22325. if (curScale % 5 === 0) {
  22326. that.drawSolidLine(
  22327. (i * that.canvasWidth) / dotNum,
  22328. 8,
  22329. (i * that.canvasWidth) / dotNum,
  22330. (that.canvasHeight / 5) * 1.5 + 8,
  22331. 1,
  22332. lineColor
  22333. );
  22334. var timeString =
  22335. this.subTime(startDate.getHours()) +
  22336. ':' +
  22337. this.subTime(startDate.getMinutes());
  22338. that.drawString(
  22339. timeString,
  22340. (i * that.canvasWidth) / dotNum,
  22341. (that.canvasHeight / 5) * 2.5,
  22342. 'center',
  22343. 'rgba(255,255,255,0.3)'
  22344. );
  22345. } else {
  22346. // console.log("画短线",((i - starMin) * that.canvasWidth) / dotNum)
  22347. that.drawSolidLine(
  22348. (i * that.canvasWidth) / dotNum,
  22349. 8,
  22350. (i * that.canvasWidth) / dotNum,
  22351. (that.canvasHeight / 5) * 0.5 + 8,
  22352. 1,
  22353. lineColor
  22354. );
  22355. }
  22356. startDate.setHours(startHours);
  22357. // startDate.setMinutes(starMin);
  22358. }
  22359. // for (var i = 0; i <= 30; i++) {
  22360. // curScale = starMin + i;
  22361. // if (curScale > 60) {
  22362. // curScale = curScale - 60;
  22363. // }
  22364. // startDate.setMinutes(curScale);
  22365. // if (curScale % 5 === 0) {
  22366. // that.drawSolidLine(
  22367. // ((i * 60 - starSecond) * that.canvasWidth) / 1800,
  22368. // 0,
  22369. // ((i * 60 - starSecond) * that.canvasWidth) / 1800,
  22370. // (that.canvasHeight / 5) * 1.5,
  22371. // 1,
  22372. // lineColor
  22373. // );
  22374. // var timeString =
  22375. // this.subTime(startDate.getHours()) +
  22376. // ':' +
  22377. // this.subTime(startDate.getMinutes());
  22378. // that.drawString(
  22379. // timeString,
  22380. // ((i * 60 - starSecond) * that.canvasWidth) / 1800,
  22381. // (that.canvasHeight / 5) * 2.5,
  22382. // 'center',
  22383. // 'rgba(255,255,255,0.3)'
  22384. // );
  22385. // } else {
  22386. // that.drawSolidLine(
  22387. // ((i * 60 - starSecond) * that.canvasWidth) / 1800,
  22388. // 0,
  22389. // ((i * 60 - starSecond) * that.canvasWidth) / 1800,
  22390. // (that.canvasHeight / 5) * 0.5,
  22391. // 1,
  22392. // lineColor
  22393. // );
  22394. // }
  22395. // }
  22396. break;
  22397. }
  22398. case 3600: {
  22399. // 60分钟
  22400. var dotNum = parseInt(that.canvasWidth / 20); // 每10像素一个点
  22401. startDate.setMinutes(startDate.getMinutes() - parseInt(dotNum / 2,10));
  22402. startHours = startDate.getHours();
  22403. starMin = startDate.getMinutes();
  22404. for (var i = 0; i <= dotNum; i++) {
  22405. curScale = starMin + i;
  22406. // if (curScale > 60) {
  22407. // curScale = curScale - 60;
  22408. // }
  22409. startDate.setMinutes(curScale);
  22410. if (curScale % 10 === 0) {
  22411. that.drawSolidLine(
  22412. ((i ) * that.canvasWidth) / dotNum,
  22413. 8,
  22414. ((i ) * that.canvasWidth) / dotNum,
  22415. (that.canvasHeight / 5) * 1.5 + 8,
  22416. 1,
  22417. lineColor
  22418. );
  22419. var timeString =
  22420. this.subTime(startDate.getHours()) +
  22421. ':' +
  22422. this.subTime(startDate.getMinutes());
  22423. that.drawString(
  22424. timeString,
  22425. ((i ) * that.canvasWidth) / dotNum,
  22426. (that.canvasHeight / 5) * 2.5,
  22427. 'center',
  22428. 'rgba(255,255,255,0.3)'
  22429. );
  22430. } else {
  22431. that.drawSolidLine(
  22432. ((i) * that.canvasWidth) / dotNum,
  22433. 8,
  22434. ((i) * that.canvasWidth) / dotNum,
  22435. (that.canvasHeight / 5) * 0.5 + 8,
  22436. 1,
  22437. lineColor
  22438. );
  22439. }
  22440. startDate.setHours(startHours);
  22441. }
  22442. break;
  22443. }
  22444. case 86400: {
  22445. var dotNum = parseInt(that.canvasWidth / 30); // 每10像素一个点
  22446. // 1天,24小时
  22447. //console.log("dotNum",dotNum);
  22448. //startDate.setDate(startDay - parseInt(dotNum / 2,10));
  22449. startDate.setHours(startDate.getHours() - parseInt(dotNum / 2,10));
  22450. // console.log("startDat111e",startDate);
  22451. // debugger;
  22452. starSecond = startDate.getSeconds();
  22453. starMin = startDate.getMinutes();
  22454. startHours = startDate.getHours();
  22455. startDay = startDate.getDate();
  22456. startYears = startDate.getFullYear();
  22457. for (var i = 0; i <= dotNum; i++) {
  22458. curScale = startHours + i;
  22459. // if (curScale >= 24) {
  22460. // curScale = curScale - 24;
  22461. // }
  22462. startDate.setHours(curScale);
  22463. var timeString;
  22464. // 不等于24的时候,画短线
  22465. //console.log("curScale",curScale)
  22466. if (curScale % 24 !=0) {
  22467. // console.log("curScale",curScale)
  22468. timeString = this.subTime(startDate.getHours()) + ":00";
  22469. // timeString = startDate.toLocaleDateString();
  22470. // debugger
  22471. that.drawSolidLine(
  22472. ((i ) * that.canvasWidth) /
  22473. dotNum,
  22474. 8,
  22475. ((i ) * that.canvasWidth) /
  22476. dotNum,
  22477. (that.canvasHeight / 5) * 0.5 + 8,
  22478. 1,
  22479. lineColor
  22480. );
  22481. } else {
  22482. // debugger;
  22483. // console.log("画图")
  22484. // 不等于24的时候,画长线
  22485. timeString = startDate.toLocaleDateString();
  22486. // console.log("startDatestartDate",startDate,i)
  22487. // debugger;
  22488. that.drawSolidLine(
  22489. ((i ) * that.canvasWidth) /
  22490. dotNum,
  22491. 8,
  22492. ((i) * that.canvasWidth) /
  22493. dotNum,
  22494. (that.canvasHeight / 5) * 1 + 8,
  22495. 1,
  22496. lineColor
  22497. );
  22498. }
  22499. // 每2个小时一个时间文字
  22500. if (curScale % 2 === 0) {
  22501. that.drawString(
  22502. timeString,
  22503. ((i) * that.canvasWidth) /
  22504. dotNum,
  22505. (that.canvasHeight / 5) * 2,
  22506. 'center',
  22507. 'rgba(255,255,255,0.3)'
  22508. );
  22509. }
  22510. // console.log("startDay",startDay)
  22511. // startDate.setDate(startDay);
  22512. startDate.setFullYear(startYears);
  22513. startDate.setDate(startDay);
  22514. startDate.setHours(startHours);
  22515. // startDate.setTime(that.nowTime);
  22516. // console.log("haha21",startDay,that.nowTime)
  22517. // console.log("haha",startDate)
  22518. }
  22519. break;
  22520. }
  22521. case 259200: {
  22522. // 3天
  22523. startDate.setHours(startDate.getHours() - 36);
  22524. starSecond = startDate.getSeconds();
  22525. starMin = startDate.getMinutes();
  22526. startHours = startDate.getHours();
  22527. OffsetLeft = starMin * 60 + starSecond;
  22528. for (var i = 0; i <= 72; i++) {
  22529. curScale = startHours + i;
  22530. if (curScale >= 24) {
  22531. curScale = curScale % 24;
  22532. }
  22533. if (curScale === 0) {
  22534. startDate.setHours(24);
  22535. } else {
  22536. startDate.setHours(curScale);
  22537. }
  22538. var timeString = this.subTime(startDate.getHours());
  22539. if (curScale % 3 === 0) {
  22540. // 每3天一个时间文字和刻度
  22541. if (!curScale) {
  22542. timeString = startDate.toLocaleDateString();
  22543. }
  22544. that.drawString(
  22545. timeString,
  22546. ((i * 3600 - OffsetLeft) * that.canvasWidth) /
  22547. 259200,
  22548. (that.canvasHeight / 5) * 2.5,
  22549. 'center',
  22550. 'rgba(255,255,255,0.3)'
  22551. );
  22552. that.drawSolidLine(
  22553. ((i * 3600 - OffsetLeft) * that.canvasWidth) /
  22554. 259200,
  22555. 0,
  22556. ((i * 3600 - OffsetLeft) * that.canvasWidth) /
  22557. 259200,
  22558. (that.canvasHeight / 5) * 1,
  22559. 1,
  22560. lineColor
  22561. );
  22562. } else {
  22563. that.drawSolidLine(
  22564. ((i * 3600 - OffsetLeft) * that.canvasWidth) /
  22565. 259200,
  22566. 0,
  22567. ((i * 3600 - OffsetLeft) * that.canvasWidth) /
  22568. 259200,
  22569. (that.canvasHeight / 5) * 0.5,
  22570. 1,
  22571. lineColor
  22572. );
  22573. }
  22574. }
  22575. break;
  22576. }
  22577. }
  22578. };
  22579. TimeLine$1.prototype.getRecord = function (timeArr,startTime,endTime) {
  22580. // console.log("timeArr,startTime,endTime",timeArr,startTime,endTime);
  22581. // if(timeArr.length > 0 && startTime) {
  22582. // if(timeArr[0].startTime < startTime) {
  22583. // timeArr[0].startTime = startTime;
  22584. // }
  22585. // }
  22586. // if(timeArr.length > 0 && endTime) {
  22587. // if(timeArr[timeArr.length-1].endTime > endTime) {
  22588. // timeArr[timeArr.length-1].endTime = endTime;
  22589. // }
  22590. // }
  22591. this.timeSection = timeArr;
  22592. this.drawRecord();
  22593. };
  22594. TimeLine$1.prototype.drawRecord = function () {
  22595. var timeArr = this.timeSection || [];
  22596. var that = this;
  22597. var drawPen = that.drawPen;
  22598. // var startDate = new Date(that.nowTime);
  22599. // var timeScale = that.canvasWidth / that.timeWidth;
  22600. // 根据时间查找当前位置
  22601. for(var i =0;i<timeArr.length;i++){
  22602. //console.log("timeArr[i]",timeArr[i],findPosition(timeArr[i].startTime),findPosition(timeArr[i].endTime))
  22603. var startPosition = findPosition(timeArr[i].startTime);
  22604. var endPosition = findPosition(timeArr[i].endTime);
  22605. drawPen.fillStyle = '#1890ff80';
  22606. drawPen.fillRect(
  22607. startPosition,
  22608. 0,
  22609. endPosition-startPosition,
  22610. 48
  22611. );
  22612. }
  22613. function findPosition(time){
  22614. var scale = 10;
  22615. switch(that.timeWidth){
  22616. case 60:
  22617. scale = 10;
  22618. break;
  22619. case 1800:
  22620. scale = 20 / 60;
  22621. break;
  22622. case 3600:
  22623. scale = 20 / 60;
  22624. break;
  22625. case 86400:
  22626. scale = 20 / 60 /60;
  22627. break;
  22628. }
  22629. var nowTimePostion = that.canvasWidth/2; //总宽度一半
  22630. var position = nowTimePostion + (time - that.nowTime) / 1000 * scale;
  22631. if(position > that.canvasWidth){
  22632. position = that.canvasWidth;
  22633. }
  22634. if(position <=0){
  22635. position = 0;
  22636. }
  22637. return position;
  22638. }
  22639. // switch (that.timeWidth) {
  22640. // case 60: {
  22641. // startDate.setSeconds(startDate.getSeconds() - 30);
  22642. // break;
  22643. // }
  22644. // case 1800: {
  22645. // startDate.setMinutes(startDate.getMinutes() - 15);
  22646. // break;
  22647. // }
  22648. // case 3600: {
  22649. // startDate.setMinutes(startDate.getMinutes() - 30);
  22650. // break;
  22651. // }
  22652. // case 86400: {
  22653. // startDate.setHours(startDate.getHours() - 12);
  22654. // break;
  22655. // }
  22656. // case 259200: {
  22657. // startDate.setHours(startDate.getHours() - 36);
  22658. // break;
  22659. // }
  22660. // }
  22661. // that.timeSection.forEach(function (item, i) {
  22662. // // 蓝色片段条
  22663. // drawPen.fillStyle = '#4E6FAE';
  22664. // var x = ((item.time[0] - startDate.getTime()) * timeScale) / 1000;
  22665. // var w = ((item.time[1] - item.time[0]) * timeScale) / 1000;
  22666. // drawPen.fillRect(
  22667. // x,
  22668. // (that.canvasHeight / 5) * 3,
  22669. // w,
  22670. // (that.canvasHeight / 5) * 1.5
  22671. // );
  22672. // });
  22673. };
  22674. TimeLine$1.prototype.drawOtherMsg = function () {
  22675. // 画中心线阴影
  22676. // this.drawPen.shadowColor = '#1890FF';
  22677. // this.drawPen.shadowOffsetX = 0;
  22678. // this.drawPen.shadowOffsetY = 0;
  22679. // this.drawPen.shadowBlur = 10;
  22680. // // 绘制中心线上方的三角形
  22681. // this.drawPen.beginPath();
  22682. // this.drawPen.moveTo(this.canvasWidth / 2 - 4.5, 0);
  22683. // this.drawPen.lineTo(this.canvasWidth / 2 + 4.5, 0);
  22684. // this.drawPen.lineTo(this.canvasWidth / 2, 4.5);
  22685. // this.drawPen.fillStyle = '#fff';
  22686. // this.drawPen.closePath();
  22687. // this.drawPen.fill();
  22688. // // 绘制中心线下方的三角形
  22689. // this.drawPen.beginPath();
  22690. // this.drawPen.moveTo(this.canvasWidth / 2 - 4.5, this.canvasHeight);
  22691. // this.drawPen.lineTo(this.canvasWidth / 2 + 4.5, this.canvasHeight);
  22692. // this.drawPen.lineTo(this.canvasWidth / 2, this.canvasHeight - 4.5);
  22693. // this.drawPen.fillStyle = '#fff';
  22694. // this.drawPen.closePath();
  22695. // this.drawPen.fill();
  22696. // 画中心线
  22697. this.drawSolidLine(
  22698. this.canvasWidth / 2,
  22699. 0,
  22700. this.canvasWidth / 2,
  22701. this.canvasHeight,
  22702. 2,
  22703. '#1890FF'
  22704. );
  22705. this.drawPen.shadowBlur = 0;
  22706. if (this.isOver && !this.isMouseDown) {
  22707. this.mouseTime =
  22708. (this.mousePosition / this.canvasWidth) *
  22709. this.timeWidth *
  22710. 1000 +
  22711. this.nowTime -
  22712. (this.timeWidth / 2) * 1000; // 鼠标的悬浮点对应的时间
  22713. this.mouseString = this.tranTime(this.mouseTime); // 鼠标悬浮点显示的文字
  22714. this.hoverTime = this.mouseString;
  22715. this.hoverLeft = this.mousePosition - 60;
  22716. this.timeTipShow = true;
  22717. } else {
  22718. this.timeTipShow = false;
  22719. }
  22720. };
  22721. };
  22722. class Rec {
  22723. constructor(jSPlugin) {
  22724. this.jSPlugin = jSPlugin;
  22725. if(!document.getElementById(`${this.jSPlugin.id}-audioControls`)) {
  22726. return false;
  22727. }
  22728. this.currentTimeWidth = 1; //回放时间轴尺度 1~4
  22729. this.timer = null;
  22730. this.date = new Date();
  22731. this.datepickerVisible = false;
  22732. const canvasItemWidth = parseInt(getComputedStyle(document.getElementById(jSPlugin.id)).width, 10) - 100;
  22733. const canvasContainer = document.createElement('div');
  22734. canvasContainer.style = `display:inline-block;width:${canvasItemWidth}px;height:48px;`;
  22735. canvasContainer.id = this.jSPlugin.id + "-canvas-container";
  22736. const canvasItem = document.createElement('canvas');
  22737. canvasItem.id = this.jSPlugin.id + "-canvas";
  22738. canvasItem.className = "time-line-body";
  22739. canvasItem.height = "48";
  22740. canvasItem.width = canvasItemWidth;
  22741. canvasItem.style = "display:inline-block;";
  22742. canvasItem.innerHTML = "该浏览器不支持canvas";
  22743. canvasContainer.appendChild(canvasItem);
  22744. insertAfter$1(canvasContainer, document.getElementById(`${this.jSPlugin.id}-audioControls`));
  22745. const timeLineControlsContainer = document.createElement('div');
  22746. timeLineControlsContainer.className = "timeline-controls";
  22747. timeLineControlsContainer.style = "display:flex;width:100px;height:48px;text-align:center;line-height: 48px;vertical-align: top;background: #000000;";
  22748. const timeLineControls = `
  22749. <div class="timeline-controls-scale" style="display: inline-flex;flex-direction: column;justify-content: center;vertical-align: top;padding: 0 20px;">
  22750. <span style="vertical-Align: middle;line-height: 14px;height: 18px; width: 18px;" id="${this.jSPlugin.id}-timeline-scale-add">
  22751. <svg fill="#2C2C2C" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20"
  22752. viewBox="0 0 20 20">
  22753. <title>add</title>
  22754. <g>
  22755. <polygon points="0.1,0.5 15,0.5 15,15.4 0.1,15.4 " />
  22756. </g>
  22757. <g>
  22758. <path
  22759. fill="#FFFFFF";
  22760. d="M7.6,12.4c-0.3,0-0.5-0.2-0.5-0.5v-8c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v8C8.1,12.2,7.9,12.4,7.6,12.4z" />
  22761. </g>
  22762. <g>
  22763. <path
  22764. fill="#FFFFFF";
  22765. d="M11.6,8.4h-8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h8c0.3,0,0.5,0.2,0.5,0.5S11.8,8.4,11.6,8.4z" />
  22766. </g>
  22767. </svg>
  22768. </span>
  22769. <span style="vertical-Align: middle;line-height: 14px;height: 18px; width: 18px;" id="${this.jSPlugin.id}-timeline-scale-sub">
  22770. <svg fill="#2C2C2C" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20"
  22771. viewBox="0 0 20 20">
  22772. <title>reduce</title>
  22773. <g>
  22774. <polygon class="st0" points="1,0.8 15.2,0.8 15.2,15 1,15 " />
  22775. </g>
  22776. <g>
  22777. <path class="st1"
  22778. fill="#FFFFFF";
  22779. d="M12.1,8.4h-8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h8c0.3,0,0.5,0.2,0.5,0.5S12.4,8.4,12.1,8.4z" />
  22780. </g>
  22781. </svg>
  22782. </span>
  22783. </div>
  22784. <label for="${this.jSPlugin.id}-datepicker">
  22785. <div class="timeline-controls-date">
  22786. <span>
  22787. <svg fill="#2C2C2C" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20"
  22788. viewBox="0 0 20 20">
  22789. <title>ifttt</title>
  22790. <g id="Rectangle">
  22791. <rect x="0.6" y="0.9" class="st0" width="20" height="20" />
  22792. </g>
  22793. <g id="Stroke-1">
  22794. <path fill="#FFFFFF"; class="st1"
  22795. d="M14,7.2c-0.3,0-0.5-0.2-0.5-0.5V3.4c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v3.3C14.5,7,14.2,7.2,14,7.2z" />
  22796. </g>
  22797. <g id="Stroke-3">
  22798. <path fill="#FFFFFF"; class="st1"
  22799. d="M7.3,7.2C7,7.2,6.8,7,6.8,6.7V3.4c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v3.3C7.8,7,7.6,7.2,7.3,7.2z" />
  22800. </g>
  22801. <g id="Stroke-5">
  22802. <path fill="#FFFFFF"; class="st1"
  22803. d="M18.1,9.7h-15c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h15c0.3,0,0.5,0.2,0.5,0.5S18.4,9.7,18.1,9.7z" />
  22804. </g>
  22805. <g id="Stroke-7">
  22806. <path fill="#FFFFFF"; class="st1" d="M16.5,19.7H4.8c-1.2,0-2.2-1-2.2-2.2V6.7c0-1.2,1-2.2,2.2-2.2h11.7c1.2,0,2.2,1,2.2,2.2v10.8
  22807. C18.6,18.8,17.7,19.7,16.5,19.7z M4.8,5.6c-0.6,0-1.2,0.5-1.2,1.2v10.8c0,0.6,0.5,1.2,1.2,1.2h11.7c0.6,0,1.2-0.5,1.2-1.2V6.7
  22808. c0-0.6-0.5-1.2-1.2-1.2H4.8z" />
  22809. </g>
  22810. <g id="Stroke-9">
  22811. <path fill="#FFFFFF"; class="st1" d="M10.6,13.3c-0.4,0-0.7-0.3-0.7-0.7c0-0.2,0.1-0.4,0.2-0.5s0.3-0.2,0.5-0.2h0h0c0.4,0,0.7,0.3,0.7,0.7
  22812. S11,13.3,10.6,13.3z" />
  22813. </g>
  22814. <g id="Stroke-11">
  22815. <path fill="#FFFFFF"; class="st1" d="M14.8,13.3c-0.4,0-0.7-0.3-0.7-0.7c0-0.2,0.1-0.4,0.2-0.5c0.1-0.1,0.3-0.2,0.5-0.2c0.4,0,0.7,0.3,0.7,0.7
  22816. S15.2,13.3,14.8,13.3z M14.8,12.3c-0.2,0-0.3,0.1-0.3,0.3c0,0.2,0.3,0.4,0.5,0.2c0.1-0.1,0.1-0.1,0.1-0.2
  22817. C15.1,12.4,15,12.3,14.8,12.3z" />
  22818. </g>
  22819. <g id="Stroke-13">
  22820. <path fill="#FFFFFF"; class="st1" d="M6.5,16.6c-0.4,0-0.7-0.3-0.7-0.7c0-0.2,0.1-0.4,0.2-0.5c0.1-0.1,0.3-0.2,0.5-0.2h0h0c0.4,0,0.7,0.3,0.7,0.7
  22821. C7.2,16.3,6.9,16.6,6.5,16.6z" />
  22822. </g>
  22823. <g id="Stroke-15">
  22824. <path fill="#FFFFFF"; class="st1" d="M10.6,16.6c-0.4,0-0.7-0.3-0.7-0.7c0-0.2,0.1-0.4,0.2-0.5c0.1-0.1,0.3-0.2,0.5-0.2h0h0c0.4,0,0.7,0.3,0.7,0.7
  22825. C11.4,16.3,11,16.6,10.6,16.6z" />
  22826. </g>
  22827. </svg>
  22828. </span>
  22829. </div>
  22830. </label>
  22831. <input data-toggle="${this.jSPlugin.id}-datepicker" id="${this.jSPlugin.id}-datepicker" name="${this.jSPlugin.id}-datepicker" style="opacity:0;width:0;margin-left:-4" />
  22832. `;
  22833. timeLineControlsContainer.innerHTML = timeLineControls;
  22834. insertAfter$1(timeLineControlsContainer, canvasContainer);
  22835. this.timeLine = new TimeLine$1(this.jSPlugin);
  22836. this.timeLine.init({
  22837. id: this.jSPlugin.id + '-canvas',
  22838. width: canvasItemWidth,
  22839. onChange: (time) => {
  22840. // console.log("time", time, new Date(time).Format('yyyyMMddhhmmss'));
  22841. // console.log("jSPlugin", this.jSPlugin);
  22842. var newBegin = new Date(time).Format('yyyyMMddhhmmss');
  22843. this.jSPlugin.changePlayUrl({ begin: newBegin });
  22844. }
  22845. });
  22846. this.syncTimeLine();
  22847. // 加载日期选择器
  22848. addCss(`${this.jSPlugin.staticPath}/js/rec/datepicker.min.css`);
  22849. addJs(`${this.jSPlugin.staticPath}/js/jquery.min.js`, () => {
  22850. addJs(`${this.jSPlugin.staticPath}/js/rec/datepicker.js`, () => {
  22851. addJs(`${this.jSPlugin.staticPath}/js/rec/datepicker.zh-CN.js`, () => {
  22852. // 日期选择:
  22853. $(`#${this.jSPlugin.id}-datepicker`).datepicker({
  22854. autoShow: false,
  22855. autoHide: true,
  22856. autoPick: true,
  22857. language: 'zh-CN',
  22858. defaultDate: new Date(),
  22859. format: 'yyyy-mm-dd',
  22860. endDate: new Date()
  22861. });
  22862. $(`#${this.jSPlugin.id}-datepicker`).on('pick.datepicker', (e) => {
  22863. // console.log("重新选择日期", e.date, new Date(e.date).Format('yyyyMMdd'), new Date(document.getElementById(`${this.jSPlugin.id}-datepicker`).value).Format('yyyyMMdd'));
  22864. if (e.date > new Date() || (new Date(e.date).Format('yyyyMMdd') === new Date(document.getElementById(`${this.jSPlugin.id}-datepicker`).value).Format('yyyyMMdd'))) {
  22865. e.preventDefault(); // Prevent to pick the date
  22866. } else {
  22867. this.renderRec(e.date);
  22868. this.jSPlugin.changePlayUrl({ begin: new Date(e.date).Format('yyyyMMdd') });
  22869. }
  22870. $('#datepicker').datepicker('hide');
  22871. this.datepickerVisible = false;
  22872. });
  22873. $(`#${this.jSPlugin.id}-datepicker`).bind("click", (e) => {
  22874. if (this.datepickerVisible) {
  22875. $(`#${this.jSPlugin.id}-datepicker`).datepicker('hide');
  22876. } else {
  22877. $(`#${this.jSPlugin.id}-datepicker`).datepicker('show');
  22878. }
  22879. this.datepickerVisible = !this.datepickerVisible;
  22880. });
  22881. });
  22882. });
  22883. });
  22884. // 尺度变化监听
  22885. document.getElementById(`${this.jSPlugin.id}-timeline-scale-add`).onclick = () => {
  22886. var currentTimeWidth = this.currentTimeWidth;
  22887. if (currentTimeWidth < 3) {
  22888. this.timeLine.changeSize(++this.currentTimeWidth);
  22889. }
  22890. };
  22891. document.getElementById(`${this.jSPlugin.id}-timeline-scale-sub`).onclick = () => {
  22892. var currentTimeWidth = this.currentTimeWidth;
  22893. if (currentTimeWidth > 0) {
  22894. this.timeLine.changeSize(--this.currentTimeWidth);
  22895. }
  22896. };
  22897. // 渲染回放
  22898. var initDate = getQueryString("begin", this.jSPlugin.url) || new Date().Format('yyyyMMdd');
  22899. this.renderRec(`${initDate.slice(0, 4)}-${initDate.slice(4, 6)}-${initDate.slice(6, 8)}`);
  22900. var observer = new MutationObserver((mutations, observer) => {
  22901. mutations.forEach((mutation) => {
  22902. console.log(mutation);
  22903. this.recAutoSize();
  22904. });
  22905. });
  22906. var config = {
  22907. attributes: true,
  22908. attributeOldValue: true,
  22909. attributeFilter: [
  22910. 'style'
  22911. ]
  22912. };
  22913. var el = document.getElementById(this.jSPlugin.id);
  22914. observer.observe(el, config);
  22915. }
  22916. recAutoSize() {
  22917. const canvasItemWidth = parseInt(getComputedStyle(document.getElementById(this.jSPlugin.id)).width, 10) - 100;
  22918. document.getElementById(`${this.jSPlugin.id}-canvas`).width = canvasItemWidth;
  22919. this.timeLine.init({
  22920. id: `${this.jSPlugin.id}-canvas`,
  22921. width: canvasItemWidth,
  22922. onChange: (time) => {
  22923. console.log("time", time, new Date(time).Format('yyyyMMddhhmmss'));
  22924. console.log("jSPlugin", this.jSPlugin);
  22925. var newBegin = new Date(time).Format('yyyyMMddhhmmss');
  22926. this.jSPlugin.changePlayUrl({ begin: newBegin });
  22927. }
  22928. });
  22929. this.renderRec(this.date);
  22930. }
  22931. renderRec(date) {
  22932. this.date = date;
  22933. var dateStart = new Date(new Date(date).Format('yyyy-MM-dd 00:00:00')).getTime();
  22934. var dateEnd = new Date(new Date(date).Format('yyyy-MM-dd 23:59:59')).getTime();
  22935. var recSliceParams = {
  22936. accessToken: this.jSPlugin.accessToken,
  22937. recType: matchEzopenUrl(this.jSPlugin.url).type === 'cloud.rec' ? 1 : 2,
  22938. deviceSerial: matchEzopenUrl(this.jSPlugin.url).deviceSerial,
  22939. channelNo: matchEzopenUrl(this.jSPlugin.url).channelNo,
  22940. startTime: dateStart,
  22941. endTime: dateEnd,
  22942. version: '2.0'
  22943. };
  22944. const recAPISuccess = (data) => {
  22945. if (data.data && data.data.files && data.data.files.length > 0) {
  22946. var dataArr = data.data.files;
  22947. var nextFileTime = new Date().getTime();
  22948. var isAll = data.data.isAll;
  22949. if (isAll) {
  22950. this.timeLine.getRecord(dataArr, dateStart, dateEnd);
  22951. } else {
  22952. recTransaction();
  22953. // 云存储回调事务
  22954. function recTransaction() {
  22955. function recAPIV2Success(data) {
  22956. if (data.data && data.data.files && data.data.files.length > 0) {
  22957. if (data.data.isAll == false) {
  22958. if (data.data.files) {
  22959. dataArr = dataArr.concat(data.data.files);
  22960. }
  22961. nextFileTime = data.data.nextFileTime > 0 ? data.data.nextFileTime : new Date().getTime();
  22962. recTransaction();
  22963. } else {
  22964. console.log("云存储执行渲染片段");
  22965. this.timeLine.getRecord(dataArr, dateStart, dateEnd);
  22966. }
  22967. } else {
  22968. this.timeLine.getRecord(dataArr, dateStart, dateEnd);
  22969. }
  22970. }
  22971. recSliceParams.startTime = nextFileTime;
  22972. request(this.jSPlugin.env.domain + "/api/lapp/video/by/time", 'POST', recSliceParams, '', recAPIV2Success);
  22973. }
  22974. }
  22975. } else if (data.data && data.data.length > 0) {
  22976. // console.log("获取本地录像片段成功", data);
  22977. this.timeLine.getRecord(data.data, dateStart, dateEnd);
  22978. } else ;
  22979. };
  22980. var recAPIUrl = this.jSPlugin.env.domain + "/api/lapp/video/by/time";
  22981. request(recAPIUrl, 'POST', recSliceParams, '', recAPISuccess);
  22982. }
  22983. syncTimeLine() {
  22984. if (this.timer) {
  22985. clearInterval(this.timer);
  22986. }
  22987. this.timer = setInterval(() => {
  22988. var getOSDTimePromise = this.jSPlugin.getOSDTime();
  22989. getOSDTimePromise.then((data) => {
  22990. var v = data.data;
  22991. if (v === -1) {
  22992. console.log("获取播放时间错误");
  22993. } else {
  22994. if (v > 0) {
  22995. //console.log("获取播放时间", v, this.timeLine.run);
  22996. this.timeLine.run({ time: new Date(v > 1000000000000 ? v : v * 1000) });
  22997. //$(".current-time").text(new Date(new Date(v > 1000000000000 ? v : v * 1000)).Format('yyyy-MM-dd hh:mm:ss'))
  22998. }
  22999. }
  23000. })
  23001. .catch((err) => {
  23002. });
  23003. }, 1000);
  23004. }
  23005. unSyncTimeLine() {
  23006. if (this.timer) {
  23007. clearInterval(this.timer);
  23008. }
  23009. }
  23010. }
  23011. var TimeLine = function TimeLine(params) {
  23012. console.log("执行TimeLine - params", params);
  23013. this.state = {
  23014. id: params.id,
  23015. start: '00:00:00', // 传入最近片段起始时刻
  23016. end: '24:00:00', // 传入最近片段结束时刻 默认结束时间为24:00:00, 1440 24
  23017. current: 0, // 当前播放时刻
  23018. // rate: 1, // 1:2小时, 2:1小时, 3:半小时, 4:10分钟, 5:1分钟
  23019. timelag: 30, // 120: 2小时, 60:1小时, 30:半小时,10:10分钟,1:1分钟
  23020. timeArr: [], // 时间轴列表
  23021. availTimeLine: [], // 由实际存在视频片段的时间组成,[{st: '', et: ''}, {st: '', et: ''}, ...]
  23022. scrollTop: 0, // 页面滚动偏移量 页面偏移量由传入时刻决定
  23023. // currentTimer: '', // 时刻定时器
  23024. // timelineTimer: '', //时间轴定时器,
  23025. index: 0, // 初始时刻在availtimeLine中的index
  23026. // playCode: 0, // 当前播放状态值
  23027. date: '',
  23028. noTimeLineTxt: '',
  23029. disabled: false, // 禁用拖动轴
  23030. };
  23031. var _this = this;
  23032. this.setState = function (obj) {
  23033. Object.keys(obj).forEach(function (key) {
  23034. _this.state[key] = obj[key];
  23035. if (key === 'scrollTop') {
  23036. document.getElementById('time-line-item').parentNode.scrollTo(0, obj[key]);
  23037. }
  23038. if (key === 'current') {
  23039. document.getElementById('time-line-current').innerHTML = obj[key];
  23040. }
  23041. });
  23042. };
  23043. this.setDisabled = function (value) {
  23044. this.setState({
  23045. disabled: value
  23046. });
  23047. document.getElementById('time-line-item').parentNode.style.overflowY = value ? 'hidden' : 'scroll';
  23048. // console.log(" document.getElementById('time-line-item').parentNode.style", document.getElementById('time-line-item').parentNode)
  23049. };
  23050. this.timeToSecond = function (time) {
  23051. const e = time.split(':');
  23052. let h = Number(e[0]);
  23053. const m = Number(e[1]);
  23054. const s = Number(e[2]);
  23055. return h * 60 * 60 + m * 60 + (s ? s : 0)
  23056. };
  23057. this.minuteToTime = function (minute) {
  23058. let hour = Math.floor(minute / 60);
  23059. let m = minute % 60;
  23060. return (hour > 9 ? hour : '0' + hour) + ':' + (m > 9 ? m : '0' + m)
  23061. };
  23062. this.timeToMinute = function (time) {
  23063. const e = time.split(':');
  23064. let h = Number(e[0]);
  23065. const m = Number(e[1]);
  23066. // const s = Number(e[2]);
  23067. return h * 60 + m
  23068. };
  23069. this.getPalyParam = params.getPalyParam;
  23070. // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
  23071. document.getElementById('time-line-item').parentNode.ontouchstart = function () {
  23072. if (_this.state.disabled) {
  23073. return false;
  23074. }
  23075. params.ontouchstart();
  23076. };
  23077. // 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
  23078. document.getElementById('time-line-item').parentNode.ontouchmove = function () {
  23079. if (_this.state.disabled) {
  23080. return false;
  23081. }
  23082. params.ontouchmove();
  23083. };
  23084. // 手动滚动停止,选定时刻自动播放
  23085. document.getElementById('time-line-item').parentNode.ontouchend = function () {
  23086. // var _this = this;
  23087. if (_this.state.disabled) {
  23088. return false;
  23089. }
  23090. //
  23091. var timer;
  23092. const scollPromise = new Promise(function (resolve, reject) {
  23093. let preTop = -1;
  23094. timer = setInterval(() => {
  23095. // debugger
  23096. let reactTop = document.getElementById('time-line-item').parentNode.scrollTop; // 实际偏移高度
  23097. if (reactTop !== preTop) {
  23098. console.log("scolling", reactTop, preTop);
  23099. preTop = reactTop;
  23100. } else {
  23101. console.log("scoll stop", reactTop, preTop);
  23102. clearInterval(timer);
  23103. resolve(reactTop);
  23104. }
  23105. }, 100);
  23106. });
  23107. //
  23108. scollPromise.then((reactTop) => {
  23109. console.log("scollPromise: then", reactTop, _this);
  23110. _this.rectTopTotime(reactTop);
  23111. console.log('页面滚动实际高度', reactTop, _this.state);
  23112. _this.getPalyParam({ current: _this.state.current });
  23113. });
  23114. params.ontouchend();
  23115. };
  23116. this.matchTimeDot();
  23117. };
  23118. TimeLine.prototype.changeScale = function (value) {
  23119. this.setState({
  23120. timelag: value, // 120: 2小时, 60:1小时, 30:半小时,10:10分钟,1:1分钟
  23121. });
  23122. this.matchTimeDot();
  23123. };
  23124. TimeLine.prototype.setDateLine = function (news, defaultIndex) {
  23125. // if( news.length > 0 ){
  23126. // if(!defaultIndex){
  23127. // defaultIndex = 0;
  23128. // }
  23129. // this.setState({
  23130. // availTimeLine: news,
  23131. // start: news[defaultIndex].st,
  23132. // end: news[defaultIndex].et,
  23133. // current: news[defaultIndex].st,
  23134. // })
  23135. // console.log("this.state", this.state);
  23136. // this.matchTimeDot();
  23137. // this.primaryOffsetH();
  23138. // // 将当前播放时间片段传给父组件
  23139. // this.getPalyParam(news[defaultIndex]);
  23140. // }
  23141. if (news.length > 0) {
  23142. if (typeof defaultIndex === 'undefined') {
  23143. defaultIndex = news.length - 1;
  23144. }
  23145. this.setState({
  23146. availTimeLine: news,
  23147. start: news[defaultIndex].st,
  23148. end: news[defaultIndex].et,
  23149. current: news[defaultIndex].st,
  23150. });
  23151. console.log("this.state", this.state);
  23152. this.matchRecTimeDot();
  23153. this.primaryOffsetH();
  23154. // 将当前播放时间片段传给父组件
  23155. //this.getPalyParam({ current: news[defaultIndex].st });
  23156. } else {
  23157. this.setState({
  23158. availTimeLine: []
  23159. });
  23160. console.log("this.state", this.state);
  23161. this.matchRecTimeDot();
  23162. }
  23163. };
  23164. TimeLine.prototype.matchTimeDot = function () {
  23165. const { start, end, timelag, availTimeLine } = this.state;
  23166. console.log("start", start, 'end', end);
  23167. var timeArr = [];
  23168. // // 播放时间片段时刻转分钟
  23169. // let availArr = [];
  23170. // let len = availTimeLine.length;
  23171. // for (let i = 0; i < len; i++) {
  23172. // const temp = availTimeLine[i];
  23173. // let st = this.timeToSecond(temp.st);
  23174. // let et = this.timeToSecond(temp.et);
  23175. // // console.log('st: ', st, 'et:', et);
  23176. // let stminute;
  23177. // let etminute;
  23178. // let stAvailPercent = 0;
  23179. // let etAvailPercent = 0;
  23180. // stminute = Math.floor(st / (timelag * 60)) * timelag;
  23181. // stAvailPercent = (st - (stminute * 60)) / timelag;
  23182. // etminute = Math.floor(et / (timelag * 60)) * timelag;
  23183. // etAvailPercent = (et - (etminute * 60)) / timelag;
  23184. // availArr[i] = {
  23185. // st: stminute,
  23186. // et: etminute,
  23187. // stAvailPercent: stAvailPercent,
  23188. // etAvailPercent: etAvailPercent
  23189. // }
  23190. // }
  23191. // console.log('availArr: ', availArr);
  23192. // 时间转分钟
  23193. let minute = this.timeToMinute(end);
  23194. // // 检测是否包含秒,则实际分钟加1
  23195. // const e = end.split(':');
  23196. // const s = Number(e[2]);
  23197. // if (s > 0) {
  23198. // minute = minute + 1
  23199. // }
  23200. minute = Math.floor(minute / timelag) * timelag;
  23201. for (let i = minute; i >= 0;) {
  23202. let marginTop = 0;
  23203. let marginBottom = 0;
  23204. // 视频片段
  23205. let recArr = [];
  23206. if (i == minute) {
  23207. marginTop = 70;
  23208. }
  23209. if (i == 0) {
  23210. marginBottom = 230;
  23211. }
  23212. // for (let j = 0; j < len; j++) {
  23213. // if (i >= availArr[j].st && i <= availArr[j].et) {
  23214. // // borderColor = '#f7a670';
  23215. // // console.log("i",i,availArr[j])
  23216. // if (i == availArr[j].st && i == availArr[j].et) {
  23217. // var height = availArr[j].etAvailPercent - availArr[j].stAvailPercent;
  23218. // var top = 60 - availArr[j].etAvailPercent;
  23219. // recArr.push({
  23220. // height: height,
  23221. // top: top
  23222. // })
  23223. // } else {
  23224. // if (i == availArr[j].st) {
  23225. // recArr.push({
  23226. // height: 60 - availArr[j].stAvailPercent,
  23227. // top: 0
  23228. // })
  23229. // } else if (i == availArr[j].et) {
  23230. // recArr.push({
  23231. // height: availArr[j].etAvailPercent,
  23232. // top: 60 - availArr[j].etAvailPercent,
  23233. // })
  23234. // } else if (i > availArr[j].st && i < availArr[j].et) {
  23235. // // 跨越多个区域
  23236. // recArr.push({
  23237. // height: 60,
  23238. // top: 0,
  23239. // })
  23240. // }
  23241. // }
  23242. // }
  23243. // }
  23244. let time = this.minuteToTime(i);
  23245. timeArr.push({
  23246. id: i,
  23247. current: time,
  23248. label: "a" + i,
  23249. marginTop: marginTop,
  23250. marginBottom: marginBottom,
  23251. recArr: recArr,
  23252. });
  23253. i = i - timelag;
  23254. }
  23255. this.setState({
  23256. timeArr: timeArr
  23257. });
  23258. this.renderDateLine();
  23259. };
  23260. TimeLine.prototype.matchRecTimeDot = function () {
  23261. const { start, end, timelag, availTimeLine, timeArr } = this.state;
  23262. console.log("start", start, 'end', end);
  23263. // 播放时间片段时刻转分钟
  23264. let availArr = [];
  23265. let len = availTimeLine.length;
  23266. if (len === 0) {
  23267. for (var j = 0; j < timeArr.length; j++) {
  23268. timeArr[j].recArr = [];
  23269. }
  23270. } else {
  23271. for (let i = 0; i < len; i++) {
  23272. const temp = availTimeLine[i];
  23273. let st = this.timeToSecond(temp.st);
  23274. let et = this.timeToSecond(temp.et);
  23275. // console.log('st: ', st, 'et:', et);
  23276. let stminute;
  23277. let etminute;
  23278. let stAvailPercent = 0;
  23279. let etAvailPercent = 0;
  23280. stminute = Math.floor(st / (timelag * 60)) * timelag;
  23281. stAvailPercent = (st - (stminute * 60)) / timelag;
  23282. etminute = Math.floor(et / (timelag * 60)) * timelag;
  23283. etAvailPercent = (et - (etminute * 60)) / timelag;
  23284. availArr[i] = {
  23285. st: stminute,
  23286. et: etminute,
  23287. stAvailPercent: stAvailPercent,
  23288. etAvailPercent: etAvailPercent
  23289. };
  23290. for (var j = 0; j < timeArr.length; j++) {
  23291. if (timeArr[j].id == stminute && timeArr[j].id == etminute) {
  23292. var height = etAvailPercent - stAvailPercent;
  23293. var top = 60 - etAvailPercent;
  23294. timeArr[j].recArr.push({
  23295. height: height,
  23296. top: top
  23297. });
  23298. } else {
  23299. if (timeArr[j].id == stminute) {
  23300. timeArr[j].recArr.push({
  23301. height: 60 - stAvailPercent,
  23302. top: 0
  23303. });
  23304. } else if (timeArr[j].id == etminute) {
  23305. timeArr[j].recArr.push({
  23306. height: etAvailPercent,
  23307. top: 60 - etAvailPercent
  23308. });
  23309. } else if (timeArr[j].id > stminute && timeArr[j].id < etminute) {
  23310. timeArr[j].recArr.push({
  23311. height: 60,
  23312. top: 0
  23313. });
  23314. }
  23315. }
  23316. }
  23317. }
  23318. }
  23319. console.log('availArr: ', availArr);
  23320. this.setState({
  23321. timeArr: timeArr,
  23322. });
  23323. console.log('timeArr:', this.state);
  23324. this.renderDateLine();
  23325. };
  23326. TimeLine.prototype.renderDateLine = function () {
  23327. const { id, timeArr } = this.state;
  23328. console.log("id,timeArr", id, timeArr);
  23329. var container = document.getElementById("time-line-item");
  23330. container.innerHTML = "";
  23331. timeArr.forEach((item, index) => {
  23332. var timeItemDOM = document.createElement('div');
  23333. timeItemDOM.setAttribute("class", "time-item");
  23334. timeItemDOM.style = `margin-top: ${item.marginTop}px; margin-bottom: ${item.marginBottom}px; border-right-color: ${item.borderColor};`;
  23335. var scaleDOM = document.createElement('div');
  23336. scaleDOM.setAttribute("class", "scale");
  23337. var timeItemHtml = '<div class="scale"></div><div class="scale"></div><div class="scale"></div><div class="scale"></div><div class="scale"></div><div class="scale" style="width:10px"></div>';
  23338. item.recArr.forEach((i, j) => {
  23339. timeItemHtml += `<div class="item-unavail" style="height: ${i.height}px;background-color:#A8B9ED; top: ${i.top}px"></div>`;
  23340. });
  23341. //timeItemHtml += `<div class="item-unavail" style="height: ${item.availPercent}px; top: ${item.availTop}px"></div>`
  23342. timeItemHtml += `<div id=${item.label} style="position: relative; top: 51px; left: 40%"> ${item.current}</div>`;
  23343. timeItemDOM.innerHTML = timeItemHtml;
  23344. container.appendChild(timeItemDOM);
  23345. });
  23346. };
  23347. // 计算初始偏移量
  23348. TimeLine.prototype.primaryOffsetH = function () {
  23349. const { start, timelag, timeArr } = this.state;
  23350. const currentItem = timeArr[0].current;
  23351. const currentTime = this.timeToSecond(currentItem);
  23352. const startSecond = this.timeToSecond(start);
  23353. const offsetS = currentTime - startSecond;
  23354. const offsetH = Math.ceil(offsetS / timelag) + 60; // offsetS / (timelag * 60) * 60
  23355. this.setState({
  23356. scrollTop: offsetH
  23357. });
  23358. console.log('起始偏移量', offsetH);
  23359. };
  23360. // 计算当前偏移量
  23361. TimeLine.prototype.currentOffsetH = function () {
  23362. const { current, timelag, timeArr } = this.state;
  23363. const startItem = timeArr[0].current;
  23364. const startSecond = this.timeToSecond(startItem);
  23365. const currentSecond = this.timeToSecond(current);
  23366. const offsetS = startSecond - currentSecond;
  23367. const offsetH = Math.ceil(offsetS / timelag) + 60; // offsetS / (timelag * 60) * 60
  23368. this.setState({
  23369. scrollTop: offsetH
  23370. });
  23371. };
  23372. // 通过时间轴位置获取当前时间
  23373. TimeLine.prototype.rectTopTotime = function (reactTop) {
  23374. let { timelag } = this.state;
  23375. // let rectTop = rect.top; // 获取当前元素距离父元素顶部的高度
  23376. // let reactTop = 0 - rectTop; // 实际偏移高度
  23377. let index = Math.floor(reactTop / 60); // 以分钟为刻度时,每个元素初始高度为60px, 向下取整并除以时刻倍数得出偏移item;
  23378. let offsetH = reactTop - (index * 60); // 偏移高度
  23379. let current;
  23380. let offsetSecond;
  23381. console.log('index:', index, 'offsetH:', offsetH);
  23382. if (offsetH == 0) {
  23383. current = this.state.timeArr[index - 1].current;
  23384. offsetSecond = 0;
  23385. } else {
  23386. // 当timelag==120,timelag==60,timelag==30,timelag==10,timelag==1
  23387. const time = this.state.timeArr[index].current;
  23388. let minute = this.timeToMinute(time);
  23389. // 相对于下一元素偏移
  23390. const offsetY = 60 - offsetH;
  23391. const offsetS = (offsetY * timelag); // offsetY / 60 * timelag * 60
  23392. const offsetM = Math.floor(offsetS / 60) + minute;
  23393. const second = (Math.floor(offsetS / 60) * 60);
  23394. offsetSecond = Math.ceil(offsetS - second); // 保留两位小数
  23395. current = this.minuteToTime(offsetM);
  23396. }
  23397. this.setState({
  23398. current: current + ':' + (offsetSecond > 9 ? offsetSecond : '0' + offsetSecond),
  23399. scrollTop: reactTop
  23400. });
  23401. // console.log("rectLeft", reactTop);
  23402. // console.log("currentTime", current + ':' + (offsetSecond > 9 ? offsetSecond : '0' + offsetSecond));
  23403. };
  23404. // 时间轴滚动,根据传参变化
  23405. TimeLine.prototype.stepScrollTimeLine = function (time) {
  23406. this.setState({
  23407. current: time,
  23408. });
  23409. this.currentOffsetH();
  23410. };
  23411. TimeLine.prototype.secondCountDown = function (time) {
  23412. const { current } = this.state;
  23413. // console.log('currentTime', current);
  23414. const temp = current.split(':');
  23415. let hour = Number(temp[0]);
  23416. let minute = Number(temp[1]);
  23417. let second = Number(temp[2]);
  23418. let t = hour * 60 * 60 + minute * 60 + second + 1;
  23419. let h = Math.floor(t / 3600);
  23420. let m = Math.floor((t - h * 3600) / 60);
  23421. let s = t - h * 3600 - m * 60;
  23422. this.setState({
  23423. current: (h > 9 ? h : '0' + h) + ':' + (m > 9 ? m : '0' + m) + ':' + (s > 9 ? s : '0' + s)
  23424. });
  23425. };
  23426. const MobileTimeLine = TimeLine;
  23427. Date.prototype.Format = function (fmt) { //author: meizz
  23428. var o = {
  23429. "M+": this.getMonth() + 1, //月份
  23430. "d+": this.getDate(), //日
  23431. "h+": this.getHours(), //小时
  23432. "m+": this.getMinutes(), //分
  23433. "s+": this.getSeconds(), //秒
  23434. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  23435. "S": this.getMilliseconds() //毫秒
  23436. };
  23437. if (/(y+)/.test(fmt)) {fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));}
  23438. for (var k in o)
  23439. {if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));}
  23440. return fmt;
  23441. };
  23442. function format(now) {
  23443. var time = new Date(now);
  23444. var h = time.getHours(); //返回日期中的小时数(0到23)
  23445. var m = time.getMinutes(); //返回日期中的分钟数(0到59)
  23446. var s = time.getSeconds(); //返回日期中的秒数(0到59)
  23447. return (h > 9 ? h : '0' + h) + ':' + (m > 9 ? m : '0' + m) + ':' + (s > 9 ? s : '0' + s);
  23448. }
  23449. class MobileRec {
  23450. constructor(jSPlugin) {
  23451. this.jSPlugin = jSPlugin;
  23452. this.timer = null;
  23453. this.date = new Date().Format('yyyy-MM-dd');
  23454. this.begin = new Date().Format('yyyy-MM-dd') + ' 00:00:00';
  23455. this.end = new Date().Format('yyyy-MM-dd') + ' 23:59:59';
  23456. this.type = matchEzopenUrl(this.jSPlugin.url).type;
  23457. this.operating = false;
  23458. var oS = document.createElement('style');
  23459. oS.innerHTML = `
  23460. body{
  23461. padding: 0;
  23462. margin: 0;
  23463. }
  23464. .time-line-container {
  23465. height: 300px;
  23466. /* outline: 1px solid red; */
  23467. /* background: gray; */
  23468. position: relative;
  23469. /* padding-top: 60px; */
  23470. margin-top: 20px;
  23471. }
  23472. .time-line-container .time-line-item-container {
  23473. display: inline-block;
  23474. /* height: 400px; */
  23475. width: 30%;
  23476. /* background: indianred; */
  23477. overflow-y: scroll;
  23478. overflow-x: hidden;
  23479. /* padding-top: 60px; */
  23480. height: 300px;
  23481. box-sizing: border-box;
  23482. white-space: nowrap;
  23483. position: relative;
  23484. }
  23485. .time-line-container .time-line-item-container::-webkit-scrollbar {
  23486. width: 0px;
  23487. /*滚动条宽度*/
  23488. height: 0px;
  23489. /*滚动条高度*/
  23490. }
  23491. .time-line-item .time-item {
  23492. position: relative;
  23493. box-sizing: border-box;
  23494. height: 60px;
  23495. font-size: 12px;
  23496. color: rgb(150, 150, 150);
  23497. border-right: 6px solid;
  23498. border-right-color: #ddd;
  23499. }
  23500. .time-line-item .time-item .scale {
  23501. width: 6px;
  23502. height: 9px;
  23503. border-bottom: 1px solid #ccc;
  23504. float: right;
  23505. clear: both;
  23506. }
  23507. .time-line-item .time-item .item-unavail {
  23508. width: 6px;
  23509. position: absolute;
  23510. left: 100%;
  23511. background-color: #ddd;
  23512. }
  23513. .time-line-container .current-time {
  23514. position: absolute;
  23515. left: 0;
  23516. top: 40px;
  23517. height: 29px;
  23518. /* line-height: 58px; */
  23519. border-bottom: 1px solid #648FFC;
  23520. width: 60%;
  23521. margin-left: 26%;
  23522. }
  23523. .time-line-container .current-time .current-time-bg {
  23524. position: relative;
  23525. top: 15px;
  23526. width: 100px;
  23527. height: 29px;
  23528. line-height: 29px;
  23529. left: -70px;
  23530. font-size: 12px;
  23531. color: #2C2C2C;
  23532. }
  23533. .time-line-container .current-time .current-time-bg::before {
  23534. content: '';
  23535. display: inline-block;
  23536. width: 6px;
  23537. height: 6px;
  23538. border-radius: 100%;
  23539. background: #648FFC;
  23540. top: 11px;
  23541. position: absolute;
  23542. right: 30px;
  23543. }
  23544. .date-switch-container {
  23545. height: 40px;
  23546. position: relative;
  23547. text-align: center;
  23548. margin: 20px 10px;
  23549. }
  23550. .date-switch-container .current-date {
  23551. line-height: 40px;
  23552. height: 22px;
  23553. font-size: 16px;
  23554. color: #2C2C2C;
  23555. text-align: center;
  23556. font-weight: bold;
  23557. }
  23558. .date-container {
  23559. width: 40px;
  23560. height: 40px;
  23561. position: absolute;
  23562. right: 0;
  23563. top: 0;
  23564. }
  23565. .rec-type-container {
  23566. display: flex;
  23567. justify-content: space-between;
  23568. }
  23569. .rec-type-container .rec-type-text {
  23570. padding: 0 15px;
  23571. font-size: 12px;
  23572. color: #2C2C2C;
  23573. }
  23574. .rec-type-container .rec-type-switch {
  23575. padding: 0 15px;
  23576. }
  23577. .date-container input {
  23578. position: absolute;
  23579. opacity: 0;
  23580. display: inline-block;
  23581. width: 40px;
  23582. height: 40px;
  23583. z-index: 10;
  23584. left: 0;
  23585. }
  23586. .date-container label {
  23587. position: absolute;
  23588. left: 0;
  23589. top: 0;
  23590. /* display: none; */
  23591. z-index: 0;
  23592. }
  23593. .date-icon {
  23594. display: inline-block;
  23595. width: 40px;
  23596. height: 40px;
  23597. background: url('https://resource.eziot.com/group2/M00/00/6A/CtwQF2F6VieAQrU9AAABP-_Nsqo949.png') no-repeat 100% 100%;
  23598. }
  23599. .select-container {
  23600. padding: 10px;
  23601. display: flex;
  23602. justify-content: space-between;
  23603. }
  23604. .advice {
  23605. height: 24px;
  23606. width: 82px;
  23607. display: flex;
  23608. justify-content: space-between;
  23609. line-height: 24px;
  23610. }
  23611. .advice span {
  23612. width: 40px;
  23613. display: inline-block;
  23614. }
  23615. input[type="checkbox"]:not(:checked)+.advice span:first-child {
  23616. box-shadow: 0px 2px 5px 0px rgb(23 45 101 / 20%);
  23617. border-radius: 8px;
  23618. text-align: center;
  23619. }
  23620. input[type="checkbox"]:checked+.advice span:last-child {
  23621. box-shadow: 0px 2px 5px 0px rgb(23 45 101 / 20%);
  23622. border-radius: 8px;
  23623. text-align: center;
  23624. }
  23625. input[type="checkbox"]:not(:checked)+.advice span:first-child svg {
  23626. fill: #648FFC !important;
  23627. }
  23628. input[type="checkbox"]:checked+.advice span:last-child svg {
  23629. fill: #648FFC !important;
  23630. }`;
  23631. document.getElementsByTagName("head")[0].appendChild(oS);
  23632. if (getQueryString("begin", this.jSPlugin.url)) {
  23633. var begin = getQueryString("begin", this.jSPlugin.url);
  23634. this.date = begin.slice(0, 4) + '-' + begin.slice(4, 6) + '-' + begin.slice(6, 8);
  23635. this.begin = this.date + ' 00:00:00';
  23636. this.end = this.date + ' 23:59:59';
  23637. }
  23638. // 回放时间标题
  23639. const mobileRecTitleWrap = document.createElement('div');
  23640. mobileRecTitleWrap.id = "date-switch-container-wrap";
  23641. mobileRecTitleWrap.className = "date-switch-container-wrap";
  23642. mobileRecTitleWrap.style = "";
  23643. mobileRecTitleWrap.innerHTML = (`
  23644. <div class="date-switch-container">
  23645. <div class="current-date" id="current-date">今日录像</div>
  23646. <div class="date-container">
  23647. <label for="date">
  23648. <div class="date-icon"></div>
  23649. </label>
  23650. <input type="date" name="date" id="date" />
  23651. </div>
  23652. </div>
  23653. `);
  23654. insertAfter$1(mobileRecTitleWrap, document.getElementById(`${this.jSPlugin.id}-wrap`));
  23655. // 回放时间类型选择
  23656. const mobileRecSwitchWrap = document.createElement('div');
  23657. mobileRecSwitchWrap.id = "rec-type-container-wrap";
  23658. mobileRecSwitchWrap.className = "rec-type-container-wrap";
  23659. mobileRecSwitchWrap.style = "";
  23660. mobileRecSwitchWrap.innerHTML = (`
  23661. <div class="rec-type-container">
  23662. <div class="rec-type-text">共个<span id="recCount">0</span>录像</div>
  23663. <div class="rec-type-switch">
  23664. <label>
  23665. <input type="checkbox" name="type" id="cloudType" value="1" hidden />
  23666. <label for="cloudType" class="advice">
  23667. <span>
  23668. <svg fill="#CCCCCC" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="2 0 20 20">
  23669. <path class="st0" d="M12.6,5c-2.3,0.1-4.3,1.4-5.3,3.3L7.2,8.6c-2.4,0.5-4.1,2.5-4.1,4.9c0,2.8,2.4,5,5.2,5h9.9
  23670. c2.4,0,4.3-1.9,4.3-4.2l0-0.2c-0.1-2-1.6-3.5-3.5-3.9l-0.1,0l0-0.2c-0.4-2.8-3-5-6.1-5L12.6,5z"/>
  23671. </svg>
  23672. </span>
  23673. <span>
  23674. <svg fill="#CCCCCC" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="2 0 20 20">
  23675. <path id="形状结合" class="st0" d="M14.3,4c0.6,0,1.2,0.2,1.7,0.7l0,0L18.3,7C18.7,7.4,19,8,19,8.6l0,0v9c0,1.3-1.1,2.3-2.4,2.3
  23676. l0,0H8.4C7.1,20,6,19,6,17.7l0,0V6.3C6,5,7.1,4,8.4,4l0,0H14.3z M9.7,7.2C9.3,7.2,8.9,7.6,8.9,8l0,0v2.5l0,0.1
  23677. c0,0.4,0.4,0.6,0.7,0.6c0.4,0,0.8-0.3,0.8-0.8l0,0V8l0-0.1C10.4,7.5,10,7.2,9.7,7.2z M12.2,7.2c-0.4,0-0.8,0.3-0.8,0.8l0,0v2.5
  23678. l0,0.1c0,0.4,0.4,0.6,0.7,0.6c0.4,0,0.8-0.3,0.8-0.8l0,0V8l0-0.1C12.9,7.5,12.5,7.2,12.2,7.2z M14.7,7.2c-0.4,0-0.8,0.3-0.8,0.8l0,0
  23679. v2.5l0,0.1c0,0.4,0.4,0.6,0.7,0.6c0.4,0,0.8-0.3,0.8-0.8l0,0V8l0-0.1C15.4,7.5,15,7.2,14.7,7.2z"/>
  23680. </svg>
  23681. </span>
  23682. </label>
  23683. </label>
  23684. </div>
  23685. </div>
  23686. `);
  23687. insertAfter$1(mobileRecSwitchWrap, mobileRecTitleWrap);
  23688. // 回放时间轴
  23689. const mobileRecWrap = document.createElement('div');
  23690. mobileRecWrap.id = "mobile-rec-wrap";
  23691. mobileRecWrap.className = "mobileRec-wrap";
  23692. mobileRecWrap.style = "";
  23693. mobileRecWrap.innerHTML = (`
  23694. <div class="time-line-container">
  23695. <div class="current-time">
  23696. <div class="current-time-bg" id="time-line-current">2020-01-01 00:00:00</div>
  23697. </div>
  23698. <div class="time-line-item-container">
  23699. <div class="time-line-item" id="time-line-item">
  23700. </div>
  23701. </div>
  23702. </div>
  23703. `);
  23704. insertAfter$1(mobileRecWrap, mobileRecSwitchWrap);
  23705. const getPalyParam = (data) => {
  23706. console.log("子组件传值到父组件", data, data.current);
  23707. var st = data.current;
  23708. var date = new Date(this.date).Format('yyyyMMdd').substr(0, 8) + (data.current ? st.replace(/:/g, "") : data.current.replace(/:/g, ""));
  23709. this.jSPlugin.changePlayUrl({
  23710. begin: date,
  23711. type: this.type
  23712. }).then(()=> {
  23713. this.syncTimeLine();
  23714. });
  23715. };
  23716. const ontouchstart = () => {
  23717. this.operating = true;
  23718. this.unSyncTimeLine();
  23719. // if (currentTimer) {
  23720. // clearInterval(currentTimer)
  23721. // }
  23722. // if (decoder) {
  23723. // var stopPromise = decoder.stop();
  23724. // stopPromise.then(() => {
  23725. // console.log("停止成功")
  23726. // });
  23727. // }
  23728. };
  23729. const ontouchmove = () => {
  23730. // if (currentTimer) {
  23731. // clearInterval(currentTimer)
  23732. // }
  23733. };
  23734. const ontouchend = () => {
  23735. this.operating = false;
  23736. console.log("ontouchend");
  23737. // if (currentTimer) {
  23738. // clearInterval(currentTimer)
  23739. // }
  23740. };
  23741. this.TimeLineOBJ = new MobileTimeLine({
  23742. id: "time-line-item",
  23743. getPalyParam: getPalyParam,
  23744. ontouchstart: ontouchstart,
  23745. ontouchmove: ontouchmove,
  23746. ontouchend: ontouchend
  23747. });
  23748. this.fetchDeviceRec();
  23749. // 监听日期变化
  23750. document.getElementById("date").addEventListener('change', (e) => {
  23751. console.log("日期变化", e.target.value);
  23752. this.date = new Date(e.target.value).Format("yyyy-MM-dd");
  23753. this.fetchDeviceRec();
  23754. });
  23755. document.getElementById("cloudType").checked = (this.type === 'rec');
  23756. document.getElementById("cloudType").addEventListener('change', (e) => {
  23757. var recType = e.target.checked ? 2 : 1;
  23758. this.type = e.target.checked ? "rec" : 'cloud.rec';
  23759. console.log("recType", recType);
  23760. this.fetchDeviceRec();
  23761. this.jSPlugin.changePlayUrl({
  23762. type: this.type,
  23763. begin: `${new Date(this.date).Format('yyyyMMdd')}000000`
  23764. })
  23765. .then(()=>{
  23766. console.log("切换类型成功");
  23767. this.syncTimeLine();
  23768. },(err)=>{
  23769. console.log("err",err);
  23770. })
  23771. .catch(err=>{
  23772. console.log(err);
  23773. });
  23774. // document.getElementById("cloudType").setAttribute("checked", true);
  23775. // $("#cloudType").attr("checked", recType == '2');
  23776. // $("#cloudType .device svg").attr("checked", recType == '2');
  23777. });
  23778. this.syncTimeLine();
  23779. }
  23780. fetchDeviceRec() {
  23781. const doRender = (result) => {
  23782. const len = result.length;
  23783. document.getElementById("recCount").innerHTML = len;
  23784. let availArr = [];
  23785. for (let i = len - 1; i >= 0; i--) {
  23786. let res = result[i];
  23787. let et = format(res.endTime);
  23788. let st = format(res.startTime);
  23789. availArr.push({
  23790. st: st,
  23791. et: et
  23792. });
  23793. }
  23794. // document.getElementById("time-line-item").style.display = "block";
  23795. {
  23796. this.TimeLineOBJ.setDateLine(availArr);
  23797. }
  23798. };
  23799. var data = new FormData();
  23800. data.append("deviceSerial", matchEzopenUrl(this.jSPlugin.url).deviceSerial);
  23801. data.append("channelNo", matchEzopenUrl(this.jSPlugin.url).channelNo);
  23802. data.append("accessToken", this.jSPlugin.accessToken);
  23803. data.append("recType", this.type === 'cloud.rec' ? 1 : 2);
  23804. data.append("startTime", new Date(this.date + ' 00:00:00').getTime());
  23805. data.append("endTime", new Date(this.date + ' 23:59:59').getTime());
  23806. fetch(this.jSPlugin.env.domain + '/api/lapp/video/by/time', {
  23807. method: "POST",
  23808. body: data
  23809. })
  23810. .then(response => response.json())
  23811. .then((res) => {
  23812. // 本地回放
  23813. if (res.code == 200 && res.data) {
  23814. var result = [];
  23815. result = res.data;
  23816. doRender(result);
  23817. } else {
  23818. doRender([]);
  23819. }
  23820. });
  23821. }
  23822. syncTimeLine() {
  23823. var dateFormat = function (now) {
  23824. var time = new Date(now);
  23825. var h = time.getHours(); //返回日期中的小时数(0到23)
  23826. var m = time.getMinutes(); //返回日期中的分钟数(0到59)
  23827. var s = time.getSeconds(); //返回日期中的秒数(0到59)
  23828. return (h > 9 ? h : '0' + h) + ':' + (m > 9 ? m : '0' + m) + ':' + (s > 9 ? s : '0' + s);
  23829. };
  23830. if (this.timer) {
  23831. clearInterval(this.timer);
  23832. }
  23833. this.timer = setInterval(() => {
  23834. // 定时器
  23835. if (this.operating) {
  23836. console.log("操作中");
  23837. return false;
  23838. }
  23839. this.jSPlugin.getOSDTime()
  23840. .then((res)=>{
  23841. if (res.data > 0) {
  23842. this.TimeLineOBJ.stepScrollTimeLine(dateFormat(res.data * 1000));
  23843. } else {
  23844. console.log("未找到当前获取播放时间,等待中...");
  23845. }
  23846. })
  23847. .catch((err)=>{
  23848. console.log("未找到当前获取播放时间,等待中...");
  23849. });
  23850. }, 1000);
  23851. }
  23852. unSyncTimeLine() {
  23853. if (this.timer) {
  23854. clearInterval(this.timer);
  23855. }
  23856. }
  23857. }
  23858. class Ptz {
  23859. constructor(jSPlugin) {
  23860. this.jSPlugin = jSPlugin;
  23861. const ptzWrap = document.createElement('div');
  23862. ptzWrap.id = this.jSPlugin.id + "-ez-ptz-item";
  23863. ptzWrap.className = "ez-ptz-wrap";
  23864. ptzWrap.style = "display:none";
  23865. var oS = document.createElement('style');
  23866. oS.innerHTML = `
  23867. .ez-ptz-container {
  23868. position: relative;
  23869. width: 80px;
  23870. height: 80px;
  23871. background: rgba(255, 255, 255, 0.80);
  23872. box-shadow: 0px 0px 33px 4px rgb(0 0 0 / 15%);
  23873. border: 1px solid rgba(255, 255, 255, 0.80);
  23874. border-radius: 100%;
  23875. cursor: pointer;
  23876. overflow: hidden;
  23877. user-select: none;
  23878. }
  23879. .ez-ptz-container .ez-ptz-icon.top {
  23880. width: 0;
  23881. height: 0;
  23882. border-left: 3px solid transparent;
  23883. border-right: 3px solid transparent;
  23884. border-bottom: 6px solid #333333;
  23885. position: absolute;
  23886. display: inline-block;
  23887. left: calc(50% - 3px);
  23888. top: 2px;
  23889. }
  23890. .ez-ptz-container .ez-ptz-icon.top.active {
  23891. border-bottom-color: #1890FF;
  23892. }
  23893. .ez-ptz-container .ez-ptz-icon.bottom {
  23894. width: 0;
  23895. height: 0;
  23896. border-left: 3px solid transparent;
  23897. border-right: 3px solid transparent;
  23898. border-top: 6px solid #333333;
  23899. position: absolute;
  23900. display: inline-block;
  23901. left: calc(50% - 3px);
  23902. bottom: 2px;
  23903. }
  23904. .ez-ptz-container .ez-ptz-icon.bottom.active {
  23905. border-top-color: #1890FF;
  23906. }
  23907. .ez-ptz-container .ez-ptz-icon.right {
  23908. width: 0;
  23909. height: 0;
  23910. border-top: 3px solid transparent;
  23911. border-bottom: 3px solid transparent;
  23912. border-left: 6px solid #333333;
  23913. position: absolute;
  23914. display: inline-block;
  23915. top: calc(50% - 3px);
  23916. right: 2px;
  23917. }
  23918. .ez-ptz-container .ez-ptz-icon.right.active {
  23919. border-left-color: #1890FF;
  23920. }
  23921. .ez-ptz-container .ez-ptz-icon.left {
  23922. width: 0;
  23923. height: 0;
  23924. border-top: 3px solid transparent;
  23925. border-bottom: 3px solid transparent;
  23926. border-right: 6px solid #333333;
  23927. position: absolute;
  23928. display: inline-block;
  23929. top: calc(50% - 3px);
  23930. left: 2px;
  23931. }
  23932. .ez-ptz-container .ez-ptz-icon.left.active {
  23933. border-right-color: #1890FF;
  23934. }
  23935. .ez-ptz-container .ez-ptz-main.center {
  23936. width: 23px;
  23937. height: 23px;
  23938. background: #1890FF;
  23939. border-radius: 100%;
  23940. top: calc(50% - 12.3px);
  23941. left: calc(50% - 12.3px);
  23942. position: absolute;
  23943. }
  23944. .ez-ptz-wrap {
  23945. position: absolute;
  23946. right: 20px;
  23947. top: calc(50% - 50px);
  23948. width: 100px;
  23949. height: 100px;
  23950. z-index: 999;
  23951. }
  23952. .ez-ptz-close {
  23953. position: absolute;
  23954. color: #FFFFFF;
  23955. top: 0;
  23956. right: 0px;
  23957. }`;
  23958. document.getElementsByTagName("head")[0].appendChild(oS);
  23959. ptzWrap.innerHTML = (`
  23960. <div class="ez-ptz-container" id="${this.jSPlugin.id}-ez-ptz-container" style="position: relative;width: 80px;height: 80px;background: rgba(255, 255, 255, 0.80);box-shadow: 0px 0px 33px 4px rgba(0, 0, 0, 0.15);border: 1px solid rgba(255, 255, 255, 0.80);border-radius: 100%;cursor: pointer;overflow: hidden;user-select: none;">
  23961. <div class="ez-ptz-main center"></div>
  23962. <div class="ez-ptz-icon top active"></div>
  23963. <div class="ez-ptz-icon left active"></div>
  23964. <div class="ez-ptz-icon bottom active"></div>
  23965. <div class="ez-ptz-icon right active"></div>
  23966. `);
  23967. document.getElementById(jSPlugin.id).appendChild(ptzWrap);
  23968. // 云台控制事件绑定
  23969. // 云台控制
  23970. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).onmousedown = (e) => {
  23971. e.preventDefault();
  23972. console.log("触摸开始");
  23973. this._handlePtzTouch(e, 'start');
  23974. };
  23975. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).onmouseup = (e) => {
  23976. e.preventDefault();
  23977. console.log("触摸结束");
  23978. this._handlePtzTouch(e, 'stop');
  23979. };
  23980. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).ontouchstart = (e) => {
  23981. e.preventDefault();
  23982. console.log("触摸开始");
  23983. this._handlePtzTouch(e, 'start');
  23984. };
  23985. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).ontouchend = (e) => {
  23986. e.preventDefault();
  23987. console.log("触摸结束", e);
  23988. this._handlePtzTouch(e, 'stop');
  23989. };
  23990. }
  23991. show() {
  23992. document.getElementById(`${this.jSPlugin.id}-ez-ptz-item`).style = "display: inline-block";
  23993. }
  23994. hide() {
  23995. document.getElementById(`${this.jSPlugin.id}-ez-ptz-item`).style = "display: none";
  23996. }
  23997. _handlePtzTouch(e, type) {
  23998. var container = document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).getBoundingClientRect();
  23999. var containerCenterX = container.left + 41;
  24000. var containerCenterY = container.top + 41;
  24001. var eventX = e.x || e.changedTouches[0].clientX;
  24002. var eventY = e.y || e.changedTouches[0].clientY;
  24003. var left = eventX - containerCenterX;
  24004. var top = eventY - containerCenterY;
  24005. var direction = 0; //操作命令:0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距
  24006. var url = this.jSPlugin.env.domain + "/api/lapp/device/ptz/start";
  24007. // var nextPtzImg = ptzNormalImg;
  24008. // var nextPtzImgFailed = ptzNormalImg;
  24009. // 判读方位
  24010. if (Math.abs(left) > Math.abs(top)) {
  24011. if (left > 0) {
  24012. direction = 3;
  24013. // nextPtzImg = ptzRightImgSuccess;
  24014. // nextPtzImgFailed = ptzRightImgFailed;
  24015. } else {
  24016. direction = 2;
  24017. // nextPtzImg = ptzLeftImgSuccess;
  24018. // nextPtzImgFailed = ptzLeftImgFailed;
  24019. }
  24020. } else {
  24021. if (top > 0) {
  24022. direction = 1;
  24023. // nextPtzImg = ptzDownImgSuccess;
  24024. // nextPtzImgFailed = ptzDownImgFailed;
  24025. } else {
  24026. direction = 0;
  24027. // nextPtzImg = ptzTopImgSuccess;
  24028. // nextPtzImgFailed = ptzTopImgFailed;
  24029. }
  24030. }
  24031. // 兼容画面旋转90度
  24032. if (/^rotate\(90/.test(document.getElementById(`${this.jSPlugin.id}-wrap`).style.transform)) {
  24033. switch (direction) {
  24034. case 0:
  24035. direction = 2; // 上转化为左
  24036. break;
  24037. case 1:
  24038. direction = 3; // 下转化为右
  24039. break;
  24040. case 2:
  24041. direction = 1; // 左转化为下
  24042. break;
  24043. case 3:
  24044. direction = 0; // 右转化为上
  24045. break;
  24046. }
  24047. }
  24048. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).style = `background-image:linear-gradient(${direction === 0 ? 180 : (direction === 1 ? 0 : (direction === 2 ? 90 : 270))}deg, #1d8dd8 0%, rgba(100,143,252,0.00) 30%)`;
  24049. if (type === 'stop') {
  24050. url = this.jSPlugin.env.domain + '/api/lapp/device/ptz/stop';
  24051. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).style = "";
  24052. }
  24053. var data = new FormData();
  24054. data.append("deviceSerial", matchEzopenUrl(this.jSPlugin.url).deviceSerial);
  24055. data.append("channelNo", matchEzopenUrl(this.jSPlugin.url).channelNo);
  24056. data.append("speed", 1);
  24057. data.append("direction", direction);
  24058. data.append("accessToken", this.jSPlugin.accessToken);
  24059. fetch(url, {
  24060. method: "POST",
  24061. body: data
  24062. })
  24063. .then(response => response.json())
  24064. .then((rt) => {
  24065. if (rt.code == 200) ; else {
  24066. //document.getElementById('ptz-img-container').childNodes[0].src = nextPtzImgFailed;
  24067. // layer.msg(data.msg);
  24068. if (rt.code == 60005 || rt.code == 60002 || rt.code == 60003 || rt.code == 60004) {
  24069. document.getElementById(`${this.jSPlugin.id}-ez-ptz-container`).style = `background-image:linear-gradient(${direction === 0 ? 180 : (direction === 1 ? 0 : (direction === 2 ? 90 : 270))}deg, #f45656 0%, rgba(100,143,252,0.00) 30%)`;
  24070. }
  24071. }
  24072. });
  24073. }
  24074. }
  24075. class Talk {
  24076. constructor(jSPlugin) {
  24077. this.jSPlugin = jSPlugin;
  24078. const audioLeft = document.createElement('div');
  24079. audioLeft.id = "audioleft";
  24080. const audioRight = document.createElement('div');
  24081. audioRight.id = "audioright";
  24082. audioRight.style = "display:none;";
  24083. const audioLeftDOM = document.createElement('audio');
  24084. audioLeftDOM.id = "myaudio";
  24085. audioLeftDOM.muted = true;
  24086. audioLeftDOM.setAttribute("autoplay", true);
  24087. audioLeftDOM.setAttribute("controls", true);
  24088. audioLeft.appendChild(audioLeftDOM);
  24089. audioLeft.style = "display:none;";
  24090. const audioRightDOM = document.createElement('audio');
  24091. audioRightDOM.id = "peeraudio";
  24092. audioRightDOM.setAttribute("autoplay", true);
  24093. audioRightDOM.setAttribute("controls", true);
  24094. audioRight.appendChild(audioRightDOM);
  24095. addJs(`${this.jSPlugin.staticPath}/js/talk/adapeter.js`, () => {
  24096. addJs(`${this.jSPlugin.staticPath}/js/talk/janus.js`, () => {
  24097. addJs(`${this.jSPlugin.staticPath}/js/talk/tts-v4.js`, () => {
  24098. // 临时处理
  24099. window.EZUIKit["handleTalkError"] = {
  24100. handleTalkError: (err)=>{
  24101. console.log("talk err", err);
  24102. }
  24103. };
  24104. window.EZUIKit.opt = {
  24105. rtcUrl: "",
  24106. talkLink: "",
  24107. ttsUrl: "",
  24108. stream: "",
  24109. deviceSerial: matchEzopenUrl(this.jSPlugin.url).deviceSerial,
  24110. channelNo: matchEzopenUrl(this.jSPlugin.url).channelNo
  24111. };
  24112. document.body.appendChild(audioLeft);
  24113. document.body.appendChild(audioRight);
  24114. });
  24115. });
  24116. });
  24117. }
  24118. toString() {
  24119. return `${this.coreX}-${this.coreY}`;
  24120. }
  24121. startTalk() {
  24122. var formData = new FormData();
  24123. formData.append("accessToken", this.jSPlugin.accessToken);
  24124. formData.append("deviceSerial", matchEzopenUrl(this.jSPlugin.url).deviceSerial);
  24125. formData.append("channelNo", matchEzopenUrl(this.jSPlugin.url).channelNo);
  24126. fetch(this.jSPlugin.env.domain + "/api/lapp/live/talk/url", {
  24127. method: "POST",
  24128. // headers: {
  24129. // 'Content-Type': 'application/json'
  24130. // },
  24131. body: formData
  24132. })
  24133. .then(response => response.json())
  24134. .then((data) => {
  24135. if (data.code == 200) {
  24136. var apiResult = data.data;
  24137. if (apiResult) {
  24138. // 临时将https转换为websocket
  24139. var rtcTrunk = apiResult.rtcUrl;
  24140. if (rtcTrunk.indexOf("ws") === -1) {
  24141. rtcTrunk = rtcTrunk.replace("https", "wss").replace("rtcgw", "rtcgw-ws");
  24142. }
  24143. window.EZUIKit.opt.rtcUrl = rtcTrunk;
  24144. window.EZUIKit.opt.ttsUrl = "tts://" + apiResult.ttsUrl;
  24145. var talk = "talk://" + window.EZUIKit.opt.deviceSerial + ":0:" + window.EZUIKit.opt.channelNo + ":cas.ys7.com:6500";
  24146. window.EZUIKit.opt.talkLink = window.EZUIKit.opt.ttsUrl + "/" + talk;
  24147. window.EZUIKit.opt.stream = apiResult.stream;
  24148. window.startTalk();
  24149. }
  24150. }
  24151. }).catch((err)=>{
  24152. console.log("err", err);
  24153. });
  24154. }
  24155. stopTalk() {
  24156. window.stopTalk();
  24157. }
  24158. }
  24159. class MobilePtz {
  24160. constructor(jSPlugin) {
  24161. this.jSPlugin = jSPlugin;
  24162. var oS = document.createElement('style');
  24163. oS.innerHTML = `
  24164. body{
  24165. padding: 0;
  24166. margin: 0;
  24167. }
  24168. #mobile-ez-ptz-container {
  24169. display: inline-block;
  24170. width: 375px;
  24171. text-align: center;
  24172. }
  24173. .live-ptz-title{
  24174. height: 25px;
  24175. font-size: 18px;
  24176. color: #2c2c2c;
  24177. text-align: center;
  24178. font-weight: 700;
  24179. margin: 24px 0;
  24180. }
  24181. #mobile-ez-ptz-container .mobile-ez-ptz-container {
  24182. position: relative;
  24183. width: 260px;
  24184. height: 260px;
  24185. background: rgba(255, 255, 255, 0.80);
  24186. box-shadow: 0px 0px 33px 4px rgba(0, 0, 0, 0.15);
  24187. border: 1px solid rgba(255, 255, 255, 0.80);
  24188. border-radius: 100%;
  24189. cursor: pointer;
  24190. overflow: hidden;
  24191. margin: auto;
  24192. /* background-image:linear-gradient(180deg, #d5e7f3 0%, rgba(100,143,252,0.00) 54%); */
  24193. }
  24194. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.top {
  24195. width: 0;
  24196. height: 0;
  24197. border-left: 6px solid transparent;
  24198. border-right: 6px solid transparent;
  24199. border-bottom: 6px solid #333333;
  24200. position: absolute;
  24201. display: inline-block;
  24202. left: calc(50% - 6px);
  24203. top: 10px;
  24204. }
  24205. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.top.active {
  24206. border-bottom-color: #1890FF;
  24207. }
  24208. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.bottom {
  24209. width: 0;
  24210. height: 0;
  24211. border-left: 6px solid transparent;
  24212. border-right: 6px solid transparent;
  24213. border-top: 6px solid #333333;
  24214. position: absolute;
  24215. display: inline-block;
  24216. left: calc(50% - 6px);
  24217. bottom: 10px;
  24218. }
  24219. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.bottom.active {
  24220. border-top-color: #1890FF;
  24221. }
  24222. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.right {
  24223. width: 0;
  24224. height: 0;
  24225. border-top: 6px solid transparent;
  24226. border-bottom: 6px solid transparent;
  24227. border-left: 6px solid #333333;
  24228. position: absolute;
  24229. display: inline-block;
  24230. top: calc(50% - 6px);
  24231. right: 10px;
  24232. }
  24233. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.right.active {
  24234. border-left-color: #1890FF;
  24235. }
  24236. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.left {
  24237. width: 0;
  24238. height: 0;
  24239. border-top: 6px solid transparent;
  24240. border-bottom: 6px solid transparent;
  24241. border-right: 6px solid #333333;
  24242. position: absolute;
  24243. display: inline-block;
  24244. top: calc(50% - 6px);
  24245. left: 10px;
  24246. }
  24247. #mobile-ez-ptz-container .mobile-ez-ptz-container .mobile-ez-ptz-icon.left.active {
  24248. border-right-color: #1890FF;
  24249. }
  24250. #mobile-ez-ptz-container .mobile-ez-ptz-container .ez-ptz-main.center {
  24251. width: 52px;
  24252. height: 52px;
  24253. background: #FFFFFF;
  24254. border: 2px solid #eee;
  24255. border-radius: 100%;
  24256. top: calc(50% - 26px);
  24257. left: calc(50% - 26px);
  24258. position: absolute;
  24259. /* box-shadow: 0px -39px 40px 6px #1890ff; */
  24260. }
  24261. #mobile-ez-ptz-container .mobile-ez-ptz-wrap {
  24262. display: inline-block;
  24263. padding: 12px 24px;
  24264. border-radius: 100%;
  24265. overflow: hidden;
  24266. }
  24267. #mobile-ez-ptz-container .ez-ptz-close {
  24268. position: absolute;
  24269. color: #FFFFFF;
  24270. top: 0;
  24271. right: 0px;
  24272. }`;
  24273. document.getElementsByTagName("head")[0].appendChild(oS);
  24274. const mobileContainer = document.createElement('div');
  24275. mobileContainer.className = "mobile-ez-ptz-container";
  24276. mobileContainer.id = "mobile-ez-ptz-container";
  24277. mobileContainer.style = `display:inline-block;width: ${this.jSPlugin.width}px;text-align:center;`;
  24278. var mobileContainerTitle = document.createElement('div');
  24279. mobileContainerTitle.className = "live-ptz-title";
  24280. mobileContainerTitle.id = "live-ptz-title";
  24281. mobileContainerTitle.innerHTML = "云台控制";
  24282. const ptzWrap = document.createElement('div');
  24283. ptzWrap.id = "mobile-ez-ptz-item";
  24284. ptzWrap.className = "mobile-ez-ptz-wrap";
  24285. ptzWrap.innerHTML = (`
  24286. <div class="mobile-ez-ptz-container" id="mobile-ez-ptz-container">
  24287. <div class="ez-ptz-main center"></div>
  24288. <div class="mobile-ez-ptz-icon top active"></div>
  24289. <div class="mobile-ez-ptz-icon left active"></div>
  24290. <div class="mobile-ez-ptz-icon bottom active"></div>
  24291. <div class="mobile-ez-ptz-icon right active"></div>
  24292. </div>
  24293. `);
  24294. mobileContainer.appendChild(ptzWrap);
  24295. //document.getElementById(jSPlugin.id).appendChild(mobileContainer);
  24296. insertAfter$1(mobileContainer, document.getElementById(`${this.jSPlugin.id}-wrap`));
  24297. mobileContainer.parentElement.insertBefore(mobileContainerTitle, mobileContainer);
  24298. // 云台控制事件绑定
  24299. // 云台控制
  24300. document.getElementById("mobile-ez-ptz-item").ontouchstart = (e) => {
  24301. e.preventDefault();
  24302. console.log("触摸开始");
  24303. this._handlePtzTouch(e, 'start');
  24304. };
  24305. document.getElementById("mobile-ez-ptz-item").ontouchend = (e) => {
  24306. e.preventDefault();
  24307. console.log("触摸结束", e);
  24308. this._handlePtzTouch(e, 'stop');
  24309. };
  24310. // 云台控制
  24311. document.getElementById("mobile-ez-ptz-item").onmousedown = (e) => {
  24312. e.preventDefault();
  24313. console.log("触摸开始");
  24314. this._handlePtzTouch(e, 'start');
  24315. };
  24316. document.getElementById("mobile-ez-ptz-item").onmouseup = (e) => {
  24317. e.preventDefault();
  24318. console.log("触摸结束", e);
  24319. this._handlePtzTouch(e, 'stop');
  24320. };
  24321. }
  24322. show() {
  24323. document.getElementById("mobile-ez-ptz-item").style = "display: inline-block";
  24324. }
  24325. hide() {
  24326. document.getElementById("mobile-ez-ptz-item").style = "display: none";
  24327. }
  24328. _handlePtzTouch(e, type) {
  24329. var container = document.getElementById('mobile-ez-ptz-item').getBoundingClientRect();
  24330. var containerCenterX = container.left + 130;
  24331. var containerCenterY = container.top + 130;
  24332. var eventX = e.x || e.changedTouches[0].clientX;
  24333. var eventY = e.y || e.changedTouches[0].clientY;
  24334. var left = eventX - containerCenterX;
  24335. var top = eventY - containerCenterY;
  24336. var direction = 0; //操作命令:0-上,1-下,2-左,3右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距
  24337. var url = this.jSPlugin.env.domain + "/api/lapp/device/ptz/start";
  24338. // var nextPtzImg = ptzNormalImg;
  24339. // var nextPtzImgFailed = ptzNormalImg;
  24340. // 判读方位
  24341. if (Math.abs(left) > Math.abs(top)) {
  24342. if (left > 0) {
  24343. direction = 3;
  24344. // nextPtzImg = ptzRightImgSuccess;
  24345. // nextPtzImgFailed = ptzRightImgFailed;
  24346. } else {
  24347. direction = 2;
  24348. // nextPtzImg = ptzLeftImgSuccess;
  24349. // nextPtzImgFailed = ptzLeftImgFailed;
  24350. }
  24351. } else {
  24352. if (top > 0) {
  24353. direction = 1;
  24354. // nextPtzImg = ptzDownImgSuccess;
  24355. // nextPtzImgFailed = ptzDownImgFailed;
  24356. } else {
  24357. direction = 0;
  24358. // nextPtzImg = ptzTopImgSuccess;
  24359. // nextPtzImgFailed = ptzTopImgFailed;
  24360. }
  24361. }
  24362. console.log("direction",direction);
  24363. document.getElementById("mobile-ez-ptz-item").style = `background-image:linear-gradient(${direction === 0 ? 180 : (direction === 1 ? 0 : (direction === 2 ? 90 : 270))}deg, #1d8dd8 0%, rgba(100,143,252,0.00) 30%)`;
  24364. if (type === 'stop') {
  24365. url = this.jSPlugin.env.domain + '/api/lapp/device/ptz/stop';
  24366. document.getElementById("mobile-ez-ptz-item").style = "";
  24367. }
  24368. var data = new FormData();
  24369. data.append("deviceSerial", matchEzopenUrl(this.jSPlugin.url).deviceSerial);
  24370. data.append("channelNo", matchEzopenUrl(this.jSPlugin.url).channelNo);
  24371. data.append("speed", 1);
  24372. data.append("direction", direction);
  24373. data.append("accessToken", this.jSPlugin.accessToken);
  24374. fetch(url, {
  24375. method: "POST",
  24376. body: data
  24377. })
  24378. .then(response => response.json())
  24379. .then((rt) => {
  24380. if (rt.code == 200) ; else {
  24381. //document.getElementById('ptz-img-container').childNodes[0].src = nextPtzImgFailed;
  24382. // layer.msg(data.msg);
  24383. if (rt.code == 60005 || rt.code == 60002 || rt.code == 60003 || rt.code == 60004) {
  24384. document.getElementById("mobile-ez-ptz-item").style = `background-image:linear-gradient(${direction === 0 ? 180 : (direction === 1 ? 0 : (direction === 2 ? 90 : 270))}deg, #f45656 0%, rgba(100,143,252,0.00) 30%)`;
  24385. }
  24386. }
  24387. });
  24388. }
  24389. }
  24390. var retcode$4 = 0;
  24391. var msg$4 = "成功";
  24392. var data$4 = {
  24393. header: {
  24394. color: "#FFFFFF",
  24395. backgroundColor: "#000000",
  24396. activeColor: "#FFFFFF",
  24397. btnList: [
  24398. {
  24399. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-0",
  24400. iconId: "deviceID",
  24401. part: "left",
  24402. defaultActive: 0,
  24403. isrender: 0,
  24404. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24405. },
  24406. {
  24407. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-1",
  24408. iconId: "deviceName",
  24409. part: "left",
  24410. defaultActive: 0,
  24411. isrender: 0,
  24412. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24413. },
  24414. {
  24415. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-2",
  24416. iconId: "cloudRec",
  24417. part: "right",
  24418. defaultActive: 0,
  24419. isrender: 0,
  24420. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24421. },
  24422. {
  24423. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-3",
  24424. iconId: "rec",
  24425. part: "right",
  24426. defaultActive: 0,
  24427. isrender: 0,
  24428. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24429. }
  24430. ]
  24431. },
  24432. footer: {
  24433. color: "#FFFFFF",
  24434. backgroundColor: "rgb(0 0 0 / 0%)",
  24435. activeColor: "#FFFFFF",
  24436. btnList: [
  24437. {
  24438. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-0",
  24439. iconId: "play",
  24440. part: "left",
  24441. defaultActive: 1,
  24442. isrender: 0,
  24443. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24444. },
  24445. {
  24446. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-1",
  24447. iconId: "capturePicture",
  24448. part: "left",
  24449. defaultActive: 0,
  24450. isrender: 0,
  24451. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24452. },
  24453. {
  24454. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-2",
  24455. iconId: "sound",
  24456. part: "left",
  24457. defaultActive: 0,
  24458. isrender: 0,
  24459. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24460. },
  24461. {
  24462. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-3",
  24463. iconId: "pantile",
  24464. part: "left",
  24465. defaultActive: 0,
  24466. isrender: 0,
  24467. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24468. },
  24469. {
  24470. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-4",
  24471. iconId: "recordvideo",
  24472. part: "left",
  24473. defaultActive: 0,
  24474. isrender: 0,
  24475. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24476. },
  24477. {
  24478. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-5",
  24479. iconId: "closevideo",
  24480. part: "left",
  24481. defaultActive: 0,
  24482. isrender: 1,
  24483. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24484. },
  24485. {
  24486. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-5",
  24487. iconId: "talk",
  24488. part: "left",
  24489. defaultActive: 0,
  24490. isrender: 0,
  24491. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24492. },
  24493. {
  24494. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-6",
  24495. iconId: "hd",
  24496. part: "right",
  24497. defaultActive: 0,
  24498. isrender: 0,
  24499. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24500. },
  24501. {
  24502. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-7",
  24503. iconId: "webExpend",
  24504. part: "right",
  24505. defaultActive: 0,
  24506. isrender: 0,
  24507. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24508. },
  24509. {
  24510. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-8",
  24511. iconId: "expend",
  24512. part: "right",
  24513. defaultActive: 0,
  24514. isrender: 0,
  24515. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24516. }
  24517. ]
  24518. }
  24519. };
  24520. var emptyData = {
  24521. retcode: retcode$4,
  24522. msg: msg$4,
  24523. data: data$4
  24524. };
  24525. var retcode$3 = 0;
  24526. var msg$3 = "成功";
  24527. var data$3 = {
  24528. header: {
  24529. color: "#FFFFFF",
  24530. backgroundColor: "#000000",
  24531. activeColor: "#FFFFFF",
  24532. btnList: [
  24533. {
  24534. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-header-0",
  24535. iconId: "deviceID",
  24536. part: "left",
  24537. defaultActive: 1,
  24538. isrender: 1,
  24539. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24540. },
  24541. {
  24542. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-header-1",
  24543. iconId: "deviceName",
  24544. part: "left",
  24545. defaultActive: 1,
  24546. isrender: 1,
  24547. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24548. }
  24549. ]
  24550. },
  24551. footer: {
  24552. color: "#FFFFFF",
  24553. backgroundColor: "rgb(0 0 0 / 0%)",
  24554. activeColor: "#FFFFFF",
  24555. btnList: [
  24556. {
  24557. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-0",
  24558. iconId: "play",
  24559. part: "left",
  24560. defaultActive: 1,
  24561. isrender: 1,
  24562. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24563. },
  24564. {
  24565. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-1",
  24566. iconId: "capturePicture",
  24567. part: "left",
  24568. defaultActive: 0,
  24569. isrender: 1,
  24570. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24571. },
  24572. {
  24573. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-2",
  24574. iconId: "sound",
  24575. part: "left",
  24576. defaultActive: 0,
  24577. isrender: 1,
  24578. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24579. },
  24580. {
  24581. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-3",
  24582. iconId: "pantile",
  24583. part: "left",
  24584. defaultActive: 0,
  24585. isrender: 1,
  24586. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24587. },
  24588. {
  24589. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-4",
  24590. iconId: "recordvideo",
  24591. part: "left",
  24592. defaultActive: 0,
  24593. isrender: 1,
  24594. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24595. },
  24596. {
  24597. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-5",
  24598. iconId: "closevideo",
  24599. part: "left",
  24600. defaultActive: 0,
  24601. isrender: 1,
  24602. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24603. },
  24604. {
  24605. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-5",
  24606. iconId: "talk",
  24607. part: "left",
  24608. defaultActive: 0,
  24609. isrender: 1,
  24610. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24611. },
  24612. {
  24613. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-6",
  24614. iconId: "hd",
  24615. part: "right",
  24616. defaultActive: 0,
  24617. isrender: 1,
  24618. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24619. },
  24620. {
  24621. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-7",
  24622. iconId: "webExpend",
  24623. part: "right",
  24624. defaultActive: 0,
  24625. isrender: 1,
  24626. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24627. },
  24628. {
  24629. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-8",
  24630. iconId: "expend",
  24631. part: "right",
  24632. defaultActive: 0,
  24633. isrender: 1,
  24634. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24635. }
  24636. ]
  24637. }
  24638. };
  24639. var pcLiveData = {
  24640. retcode: retcode$3,
  24641. msg: msg$3,
  24642. data: data$3
  24643. };
  24644. var retcode$2 = 0;
  24645. var msg$2 = "成功";
  24646. var data$2 = {
  24647. header: {
  24648. color: "#FFFFFF",
  24649. backgroundColor: "#000000",
  24650. activeColor: "#FFFFFF",
  24651. btnList: [
  24652. {
  24653. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-0",
  24654. iconId: "deviceID",
  24655. part: "left",
  24656. defaultActive: 0,
  24657. isrender: 1,
  24658. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24659. },
  24660. {
  24661. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-1",
  24662. iconId: "deviceName",
  24663. part: "left",
  24664. defaultActive: 0,
  24665. isrender: 1,
  24666. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24667. },
  24668. {
  24669. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-2",
  24670. iconId: "cloudRec",
  24671. part: "right",
  24672. defaultActive: 0,
  24673. isrender: 1,
  24674. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24675. },
  24676. {
  24677. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-header-3",
  24678. iconId: "rec",
  24679. part: "right",
  24680. defaultActive: 0,
  24681. isrender: 1,
  24682. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24683. }
  24684. ]
  24685. },
  24686. footer: {
  24687. color: "#FFFFFF",
  24688. backgroundColor: "rgba(0 0 0 / 0%)",
  24689. activeColor: "#FFFFFF",
  24690. btnList: [
  24691. {
  24692. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-0",
  24693. iconId: "play",
  24694. part: "left",
  24695. defaultActive: 1,
  24696. isrender: 1,
  24697. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24698. },
  24699. {
  24700. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-1",
  24701. iconId: "capturePicture",
  24702. part: "left",
  24703. defaultActive: 0,
  24704. isrender: 1,
  24705. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24706. },
  24707. {
  24708. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-2",
  24709. iconId: "sound",
  24710. part: "left",
  24711. defaultActive: 0,
  24712. isrender: 1,
  24713. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24714. },
  24715. {
  24716. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-4",
  24717. iconId: "recordvideo",
  24718. part: "left",
  24719. defaultActive: 0,
  24720. isrender: 1,
  24721. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24722. },
  24723. {
  24724. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-5",
  24725. iconId: "closevideo",
  24726. part: "left",
  24727. defaultActive: 0,
  24728. isrender: 1,
  24729. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24730. },
  24731. {
  24732. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-7",
  24733. iconId: "webExpend",
  24734. part: "right",
  24735. defaultActive: 0,
  24736. isrender: 1,
  24737. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24738. },
  24739. {
  24740. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f7896c8942c9476fb439370dd974f1c0-footer-8",
  24741. iconId: "expend",
  24742. part: "right",
  24743. defaultActive: 0,
  24744. isrender: 1,
  24745. themeId: "f7896c8942c9476fb439370dd974f1c0"
  24746. }
  24747. ]
  24748. }
  24749. };
  24750. var pcRecData = {
  24751. retcode: retcode$2,
  24752. msg: msg$2,
  24753. data: data$2
  24754. };
  24755. var retcode$1 = 0;
  24756. var msg$1 = "成功";
  24757. var data$1 = {
  24758. header: {
  24759. color: "#FFFFFF",
  24760. backgroundColor: "#000000",
  24761. activeColor: "#FFFFFF",
  24762. btnList: [
  24763. {
  24764. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-header-0",
  24765. iconId: "deviceID",
  24766. part: "left",
  24767. defaultActive: 1,
  24768. isrender: 1,
  24769. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24770. },
  24771. {
  24772. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-header-1",
  24773. iconId: "deviceName",
  24774. part: "left",
  24775. defaultActive: 1,
  24776. isrender: 1,
  24777. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24778. }
  24779. ]
  24780. },
  24781. footer: {
  24782. color: "#FFFFFF",
  24783. backgroundColor: "rgb(0 0 0 / 0%)",
  24784. activeColor: "#FFFFFF",
  24785. btnList: [
  24786. {
  24787. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-0",
  24788. iconId: "play",
  24789. part: "left",
  24790. defaultActive: 1,
  24791. isrender: 1,
  24792. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24793. },
  24794. {
  24795. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-2",
  24796. iconId: "sound",
  24797. part: "left",
  24798. defaultActive: 0,
  24799. isrender: 1,
  24800. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24801. },
  24802. {
  24803. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-3",
  24804. iconId: "pantile",
  24805. part: "left",
  24806. defaultActive: 0,
  24807. isrender: 1,
  24808. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24809. },
  24810. {
  24811. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-5",
  24812. iconId: "talk",
  24813. part: "left",
  24814. defaultActive: 0,
  24815. isrender: 1,
  24816. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24817. },
  24818. {
  24819. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-6",
  24820. iconId: "hd",
  24821. part: "right",
  24822. defaultActive: 0,
  24823. isrender: 1,
  24824. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24825. },
  24826. {
  24827. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-7",
  24828. iconId: "expend",
  24829. part: "right",
  24830. defaultActive: 0,
  24831. isrender: 1,
  24832. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24833. }
  24834. ]
  24835. }
  24836. };
  24837. var mobileLiveData = {
  24838. retcode: retcode$1,
  24839. msg: msg$1,
  24840. data: data$1
  24841. };
  24842. var retcode = 0;
  24843. var msg = "成功";
  24844. var data = {
  24845. header: {
  24846. color: "#FFFFFF",
  24847. backgroundColor: "#000000",
  24848. activeColor: "#FFFFFF",
  24849. btnList: [
  24850. {
  24851. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-header-0",
  24852. iconId: "deviceID",
  24853. part: "left",
  24854. defaultActive: 1,
  24855. isrender: 1,
  24856. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24857. },
  24858. {
  24859. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-header-1",
  24860. iconId: "deviceName",
  24861. part: "left",
  24862. defaultActive: 1,
  24863. isrender: 1,
  24864. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24865. }
  24866. ]
  24867. },
  24868. footer: {
  24869. color: "#FFFFFF",
  24870. backgroundColor: "rgb(0 0 0 / 0%)",
  24871. activeColor: "#FFFFFF",
  24872. btnList: [
  24873. {
  24874. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-0",
  24875. iconId: "play",
  24876. part: "left",
  24877. defaultActive: 1,
  24878. isrender: 1,
  24879. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24880. },
  24881. {
  24882. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-2",
  24883. iconId: "sound",
  24884. part: "left",
  24885. defaultActive: 0,
  24886. isrender: 1,
  24887. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24888. },
  24889. {
  24890. btnKey: "c1cbc1d4e86d49a0981f54beea95280a-f9a70c9a4fde425c9c7ec7815b9fec4b-footer-7",
  24891. iconId: "expend",
  24892. part: "right",
  24893. defaultActive: 0,
  24894. isrender: 1,
  24895. themeId: "f9a70c9a4fde425c9c7ec7815b9fec4b"
  24896. }
  24897. ]
  24898. }
  24899. };
  24900. var mobileRecData = {
  24901. retcode: retcode,
  24902. msg: msg,
  24903. data: data
  24904. };
  24905. const styleToString = (obj) => {
  24906. let styleString = "";
  24907. Object.keys(obj).map((item, index) => {
  24908. styleString += `${item}:${obj[item]}${index < Object.keys(obj).length - 1 ? ';' : ""}`;
  24909. });
  24910. return styleString;
  24911. };
  24912. class Theme {
  24913. constructor(jSPlugin) {
  24914. this.jSPlugin = jSPlugin;
  24915. this.isNeedRenderHeader = false;
  24916. this.isNeedRenderFooter = false;
  24917. this.decoderState = {
  24918. state: {
  24919. isEditing: false,
  24920. play: true,
  24921. sound: true,
  24922. recordvideo: false,
  24923. closevideo: false,
  24924. recordTimer: null,
  24925. recordCount: "00:00",
  24926. talk: false,
  24927. pantile: false,
  24928. hd: false,
  24929. expend: false,
  24930. webExpend: false,
  24931. cloudRec: matchEzopenUrl(jSPlugin.url).type === 'cloud.rec',
  24932. rec: matchEzopenUrl(jSPlugin.url).type === 'rec',
  24933. type: matchEzopenUrl(jSPlugin.url).type
  24934. }
  24935. };
  24936. this.inited = false;
  24937. this.isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
  24938. // 默认主题 - 按钮全部展示
  24939. this.themeData = emptyData.data;
  24940. // 自适应主题数据
  24941. /*
  24942. 移动端 & 直播 =》 mobileLive
  24943. 移动端 & 回放地址 => mobileRec
  24944. PC端 & 直播 =》 pcLive
  24945. PC端 & 回放地址 => pcRec
  24946. */
  24947. if (this.jSPlugin.themeId) {
  24948. switch (this.jSPlugin.themeId) {
  24949. case 'pcLive':
  24950. this.themeData = pcLiveData.data;
  24951. this.initThemeData();
  24952. this.renderThemeData();
  24953. break;
  24954. case 'pcRec':
  24955. this.themeData = pcRecData.data;
  24956. this.initThemeData();
  24957. this.renderThemeData();
  24958. break;
  24959. case 'mobileLive':
  24960. this.themeData = mobileLiveData.data;
  24961. this.initThemeData();
  24962. this.renderThemeData();
  24963. break;
  24964. case 'mobileRec':
  24965. this.themeData = mobileRecData.data;
  24966. this.initThemeData();
  24967. this.renderThemeData();
  24968. break;
  24969. case 'themeData':
  24970. this.themeData = this.jSPlugin.params.themeData;
  24971. this.initThemeData();
  24972. this.renderThemeData();
  24973. break;
  24974. default:
  24975. this.fetchThemeData(this.jSPlugin.themeId);
  24976. break;
  24977. }
  24978. }
  24979. if (!this.jSPlugin.Talk) {
  24980. this.jSPlugin.Talk = new Talk(this.jSPlugin);
  24981. }
  24982. }
  24983. fetchThemeData(themeId) {
  24984. const url = `${this.jSPlugin.env.domain}/jssdk/ezopen/template/getDetail?accessToken=${this.jSPlugin.accessToken}&id=${themeId}`;
  24985. fetch(url, {
  24986. method: 'GET'
  24987. })
  24988. .then(response => response.json())
  24989. .then(data => {
  24990. console.log("get theme data", data);
  24991. if (data.meta.code === 0 && data.data) {
  24992. if (data.data.header) {
  24993. this.themeData.header = data.data.header;
  24994. }
  24995. if (data.data.footer) {
  24996. this.themeData.footer = data.data.footer;
  24997. }
  24998. // // 判断是否自动隐藏控件
  24999. // if (themeData[0].autoFocus > 0) {
  25000. // autoFocus = parseInt(themeData[0].autoFocus);
  25001. // }
  25002. this.initThemeData();
  25003. this.renderThemeData();
  25004. }
  25005. })
  25006. .catch(error => {
  25007. this.renderThemeData();
  25008. });
  25009. }
  25010. changeTheme(options) {
  25011. if(typeof options === 'string') {
  25012. this.jSPlugin.themeId = options;
  25013. switch (this.jSPlugin.themeId) {
  25014. case 'pcLive':
  25015. this.themeData = pcLiveData.data;
  25016. this.initThemeData();
  25017. this.renderThemeData();
  25018. break;
  25019. case 'pcRec':
  25020. this.themeData = pcRecData.data;
  25021. this.initThemeData();
  25022. this.renderThemeData();
  25023. break;
  25024. case 'mobileLive':
  25025. this.themeData = mobileLiveData.data;
  25026. this.initThemeData();
  25027. this.renderThemeData();
  25028. break;
  25029. case 'mobileRec':
  25030. this.themeData = mobileRecData.data;
  25031. this.initThemeData();
  25032. this.renderThemeData();
  25033. break;
  25034. case 'themeData':
  25035. this.themeData = this.jSPlugin.params.themeData;
  25036. this.initThemeData();
  25037. this.renderThemeData();
  25038. break;
  25039. default:
  25040. this.fetchThemeData(options);
  25041. break;
  25042. }
  25043. } else if (typeof options === 'object') {
  25044. this.themeData = options;
  25045. this.initThemeData();
  25046. this.renderThemeData();
  25047. }
  25048. }
  25049. renderThemeData() {
  25050. const { header, footer } = this.themeData;
  25051. if (this.isNeedRenderHeader && header) {
  25052. // document.getElementById(`${this.jSPlugin.id}-headControl`).style.background = header.backgroundColor.replace("-diy", "");
  25053. // document.getElementById(`${this.jSPlugin.id}-headControl`).style.color = header.color.replace("-diy", "");
  25054. header.btnList.map((item, index) => {
  25055. if (item.isrender) {
  25056. this.setDecoderState({ [item.iconId]: this.decoderState[item.iconId] });
  25057. }
  25058. });
  25059. }
  25060. if (this.isNeedRenderFooter && footer) {
  25061. document.getElementById(`${this.jSPlugin.id}-audioControls`).style.background = footer.backgroundColor.replace("-diy", "");
  25062. document.getElementById(`${this.jSPlugin.id}-audioControls`).style.color = footer.color.replace("-diy", "");
  25063. footer.btnList.map((item, index) => {
  25064. if (item.isrender) {
  25065. this.setDecoderState({ [item.iconId]: this.decoderState[item.iconId] });
  25066. }
  25067. });
  25068. }
  25069. }
  25070. setDecoderState(options) {
  25071. const { header, footer } = this.themeData;
  25072. Object.keys(options).map((item, index) => {
  25073. var color = "#FFFFFF";
  25074. var activeColor = "#FFFFFF";
  25075. var _index = header.btnList.findIndex((i) => {
  25076. return i.iconId === item;
  25077. });
  25078. if (_index === -1) {
  25079. color = footer.color.replace("-diy", "");
  25080. activeColor = footer.activeColor.replace("-diy", "");
  25081. } else {
  25082. color = header.color.replace("-diy", "");
  25083. activeColor = header.activeColor.replace("-diy", "");
  25084. }
  25085. switch (item) {
  25086. case 'play':
  25087. if (options[item]) {
  25088. if (document.getElementById(`${this.jSPlugin.id}-play`)) {
  25089. document.getElementById(`${this.jSPlugin.id}-play-content`).children[0].children[0].style = "display:inline-block";
  25090. document.getElementById(`${this.jSPlugin.id}-play-content`).children[0].children[1].style = "display:none";
  25091. document.getElementById(`${this.jSPlugin.id}-play`).className = options[item] ? 'active' : '';
  25092. document.getElementById(`${this.jSPlugin.id}-play-content`).childNodes[0].children[0].style.fill = options[item] ? activeColor : color;
  25093. }
  25094. } else {
  25095. if (document.getElementById(`${this.jSPlugin.id}-play`)) {
  25096. document.getElementById(`${this.jSPlugin.id}-play-content`).children[0].children[1].style = "display:inline-block";
  25097. document.getElementById(`${this.jSPlugin.id}-play-content`).children[0].children[0].style = "display:none";
  25098. document.getElementById(`${this.jSPlugin.id}-play`).className = options[item] ? 'active' : '';
  25099. document.getElementById(`${this.jSPlugin.id}-play-content`).childNodes[0].children[1].style.fill = options[item] ? activeColor : color;
  25100. }
  25101. }
  25102. break;
  25103. case 'sound':
  25104. if (document.getElementById(`${this.jSPlugin.id}-sound`)) {
  25105. if (options[item]) {
  25106. document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[1].style = "display:inline-block";
  25107. document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[0].style = "display:none";
  25108. document.getElementById(`${this.jSPlugin.id}-sound`).className = options[item] ? 'active' : '';
  25109. document.getElementById(`${this.jSPlugin.id}-sound-content`).childNodes[0].children[1].style.fill = options[item] ? activeColor : color;
  25110. } else {
  25111. document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[0].style = "display:inline-block";
  25112. document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[1].style = "display:none";
  25113. document.getElementById(`${this.jSPlugin.id}-sound`).className = options[item] ? 'active' : '';
  25114. document.getElementById(`${this.jSPlugin.id}-sound-content`).childNodes[0].children[0].style.fill = options[item] ? activeColor : color;
  25115. }
  25116. }
  25117. break;
  25118. case 'recordvideo':
  25119. if (document.getElementById(`${this.jSPlugin.id}-recordvideo`)) {
  25120. document.getElementById(`${this.jSPlugin.id}-recordvideo`).className = options[item] ? 'active' : '';
  25121. document.getElementById(`${this.jSPlugin.id}-recordvideo-content`).childNodes[0].style.fill = options[item] ? activeColor : color;
  25122. }
  25123. break;
  25124. case 'closevideo':
  25125. if (document.getElementById(`${this.jSPlugin.id}-closevideo`)) {
  25126. document.getElementById(`${this.jSPlugin.id}-closevideo`).className = options[item] ? 'active' : '';
  25127. document.getElementById(`${this.jSPlugin.id}-closevideo-content`).childNodes[0].style.fill = options[item] ? activeColor : color;
  25128. }
  25129. break;
  25130. case 'talk':
  25131. if (document.getElementById(`${this.jSPlugin.id}-talk`)) {
  25132. document.getElementById(`${this.jSPlugin.id}-talk`).className = options[item] ? 'active' : '';
  25133. document.getElementById(`${this.jSPlugin.id}-talk-content`).childNodes[1].style.fill = options[item] ? activeColor : color;
  25134. }
  25135. break;
  25136. case 'pantile':
  25137. if (document.getElementById(`${this.jSPlugin.id}-pantile`)) {
  25138. document.getElementById(`${this.jSPlugin.id}-pantile`).className = options[item] ? 'active' : '';
  25139. document.getElementById(`${this.jSPlugin.id}-pantile-content`).childNodes[0].style.fill = options[item] ? activeColor : color;
  25140. }
  25141. break;
  25142. case 'webExpend':
  25143. if (options[item]) {
  25144. if (document.getElementById(`${this.jSPlugin.id}-webExpend`)) {
  25145. document.getElementById(`${this.jSPlugin.id}-webExpend-content`).children[0].children[1].style = "display:inline-block";
  25146. document.getElementById(`${this.jSPlugin.id}-webExpend-content`).children[0].children[0].style = "display:none";
  25147. }
  25148. // 全屏置灰
  25149. if (document.getElementById(`${this.jSPlugin.id}-expend`)) {
  25150. document.getElementById(`${this.jSPlugin.id}-expend`).className = "disabled";
  25151. }
  25152. } else {
  25153. if (document.getElementById(`${this.jSPlugin.id}-webExpend`)) {
  25154. document.getElementById(`${this.jSPlugin.id}-webExpend-content`).children[0].children[0].style = "display:inline-block";
  25155. document.getElementById(`${this.jSPlugin.id}-webExpend-content`).children[0].children[1].style = "display:none";
  25156. }
  25157. // 全屏置灰
  25158. if (document.getElementById(`${this.jSPlugin.id}-expend`)) {
  25159. document.getElementById(`${this.jSPlugin.id}-expend`).className = "";
  25160. }
  25161. }
  25162. if (document.getElementById(`${this.jSPlugin.id}-webExpend`)) {
  25163. document.getElementById(`${this.jSPlugin.id}-webExpend`).className = options[item] ? 'active' : '';
  25164. document.getElementById(`${this.jSPlugin.id}-webExpend-content`).childNodes[0].childNodes[0].style.fill = options[item] ? activeColor : color;
  25165. document.getElementById(`${this.jSPlugin.id}-webExpend-content`).childNodes[0].childNodes[1].style.fill = options[item] ? activeColor : color;
  25166. }
  25167. break;
  25168. case 'capturePicture':
  25169. if (document.getElementById(`${this.jSPlugin.id}-capturePicture`)) {
  25170. document.getElementById(`${this.jSPlugin.id}-capturePicture`).className = options[item] ? 'active' : '';
  25171. document.getElementById(`${this.jSPlugin.id}-capturePicture-content`).childNodes[0].style.fill = options[item] ? activeColor : color;
  25172. }
  25173. break;
  25174. case 'expend':
  25175. if (options[item]) {
  25176. if (document.getElementById(`${this.jSPlugin.id}-expend`)) {
  25177. document.getElementById(`${this.jSPlugin.id}-expend-content`).children[0].children[1].style = "display:inline-block";
  25178. document.getElementById(`${this.jSPlugin.id}-expend-content`).children[0].children[0].style = "display:none";
  25179. }
  25180. // 网站全屏置灰
  25181. if (document.getElementById(`${this.jSPlugin.id}-webExpend`)) {
  25182. document.getElementById(`${this.jSPlugin.id}-webExpend`).className = "disabled";
  25183. }
  25184. } else {
  25185. if (document.getElementById(`${this.jSPlugin.id}-expend`)) {
  25186. document.getElementById(`${this.jSPlugin.id}-expend-content`).children[0].children[0].style = "display:inline-block";
  25187. document.getElementById(`${this.jSPlugin.id}-expend-content`).children[0].children[1].style = "display:none";
  25188. }
  25189. // 网站全屏置灰
  25190. if (document.getElementById(`${this.jSPlugin.id}-webExpend`)) {
  25191. document.getElementById(`${this.jSPlugin.id}-webExpend`).className = "";
  25192. }
  25193. }
  25194. if (document.getElementById(`${this.jSPlugin.id}-expend`)) {
  25195. document.getElementById(`${this.jSPlugin.id}-expend`).className = options[item] ? 'active' : '';
  25196. document.getElementById(`${this.jSPlugin.id}-expend-content`).childNodes[0].childNodes[0].style.fill = options[item] ? activeColor : color;
  25197. document.getElementById(`${this.jSPlugin.id}-expend-content`).childNodes[0].childNodes[1].style.fill = options[item] ? activeColor : color;
  25198. }
  25199. break;
  25200. case 'hd':
  25201. if (options[item]) {
  25202. if(document.getElementById(`${this.jSPlugin.id}-hd`)) {
  25203. document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[0].style = "display:block";
  25204. document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[1].style = "display:none";
  25205. }
  25206. } else {
  25207. if(document.getElementById(`${this.jSPlugin.id}-hd`)) {
  25208. document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[1].style = "display:block";
  25209. document.getElementById(`${this.jSPlugin.id}-hd-content`).children[1].children[0].style = "display:none";
  25210. }
  25211. }
  25212. break;
  25213. case 'cloudRec':
  25214. if (document.getElementById(`${this.jSPlugin.id}-cloudRec`)) {
  25215. document.getElementById(`${this.jSPlugin.id}-cloudRec`).className = options[item] ? 'active' : '';
  25216. document.getElementById(`${this.jSPlugin.id}-cloudRec-content`).children[0].children[0].style.fill = options[item] ? activeColor : color;
  25217. }
  25218. if (document.getElementById(`${this.jSPlugin.id}-rec`)) {
  25219. document.getElementById(`${this.jSPlugin.id}-rec`).className = options[item] ? 'active' : '';
  25220. document.getElementById(`${this.jSPlugin.id}-rec-content`).children[0].children[0].style.fill = options[item] ? color : activeColor;
  25221. }
  25222. break;
  25223. case 'rec':
  25224. if (document.getElementById(`${this.jSPlugin.id}-cloudRec`)) {
  25225. document.getElementById(`${this.jSPlugin.id}-cloudRec`).className = options[item] ? 'active' : '';
  25226. document.getElementById(`${this.jSPlugin.id}-cloudRec-content`).children[0].children[0].style.fill = options[item] ? color : activeColor;
  25227. }
  25228. if (document.getElementById(`${this.jSPlugin.id}-rec`)) {
  25229. document.getElementById(`${this.jSPlugin.id}-rec`).className = options[item] ? 'active' : '';
  25230. document.getElementById(`${this.jSPlugin.id}-rec-content`).children[0].children[0].style.fill = options[item] ? activeColor : color;
  25231. }
  25232. break;
  25233. }
  25234. this.decoderState.state = Object.assign(this.decoderState.state, options);
  25235. });
  25236. }
  25237. toString() {
  25238. return `${this.coreX}-${this.coreY}`;
  25239. }
  25240. renderFooter(id, part) {
  25241. // 播放停止
  25242. var objItem = this.matchBtn(id);
  25243. var objDOM = document.createElement('div');
  25244. objDOM.innerHTML = `${`<span id="${this.jSPlugin.id}-${objItem.id}" style="position:relative;${objItem.part === 'left' ? 'margin-right: 12px;' : 'margin-left: 12px;'}">`
  25245. + `<span id="${this.jSPlugin.id}-${objItem.id}-content" title="${objItem.title}" style="display:inline-block;min-height:48px;max-height:96px;">`}${objItem.domString
  25246. }</span>`
  25247. + `<span id="${objItem.id}-remove" title="移除" style="position: absolute;top: -10px;left: 38px;display: none;">`
  25248. + '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 15 15">'
  25249. + '<circle style="fill-rule:evenodd;clip-rule:evenodd;fill-opacity:0.8011;" cx="7.5" cy="7.6" r="7" />'
  25250. + '<rect x="3.9" y="3.5" class="st1" style="fill:none;" width="8.1" height="8.1" />'
  25251. + '<line style="fill:none;stroke:#ffffff;stroke-width:0.5833;stroke-linecap:round;" x1="4.9" y1="5" x2="10" y2="10.1" />'
  25252. + '<line style="fill:none;stroke:#ffffff;stroke-width:0.5833;stroke-linecap:round;" x1="4.9" y1="10.1" x2="10" y2="5" />'
  25253. + '</svg>'
  25254. + '</span>'
  25255. + '</span>';
  25256. objDOM.onclick = objItem.onclick;
  25257. if (part === 'left') {
  25258. document.getElementById(`${this.jSPlugin.id}-audioControls`).childNodes[0].appendChild(objDOM);
  25259. } else {
  25260. document.getElementById(`${this.jSPlugin.id}-audioControls`).childNodes[1].appendChild(objDOM);
  25261. }
  25262. // 截图
  25263. }
  25264. renderHeader(id, part) {
  25265. // 播放停止
  25266. var objItem = this.matchBtn(id);
  25267. var objDOM = document.createElement('div');
  25268. objDOM.innerHTML = `${`<span id="${this.jSPlugin.id}-${objItem.id}" style="position:relative;${objItem.part === 'left' ? 'margin-right: 12px;' : 'margin-left: 12px;'}">`
  25269. + `<span id="${this.jSPlugin.id}-${objItem.id}-content" title="${objItem.title}" style="display:inline-block;height:48px;">`}${objItem.domString
  25270. }</span>`
  25271. + `<span id="${this.jSPlugin.id}-${objItem.id}-remove" title="移除" style="position: absolute;top: -10px;left: 38px;display: none;">`
  25272. + '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 15 15">'
  25273. + '<circle style="fill-rule:evenodd;clip-rule:evenodd;fill-opacity:0.8011;" cx="7.5" cy="7.6" r="7" />'
  25274. + '<rect x="3.9" y="3.5" class="st1" style="fill:none;" width="8.1" height="8.1" />'
  25275. + '<line style="fill:none;stroke:#ffffff;stroke-width:0.5833;stroke-linecap:round;" x1="4.9" y1="5" x2="10" y2="10.1" />'
  25276. + '<line style="fill:none;stroke:#ffffff;stroke-width:0.5833;stroke-linecap:round;" x1="4.9" y1="10.1" x2="10" y2="5" />'
  25277. + '</svg>'
  25278. + '</span>'
  25279. + '</span>';
  25280. objDOM.onclick = objItem.onclick;
  25281. if (part === 'left') {
  25282. document.getElementById(`${this.jSPlugin.id}-headControl`).childNodes[0].appendChild(objDOM);
  25283. } else {
  25284. document.getElementById(`${this.jSPlugin.id}-headControl`).childNodes[1].appendChild(objDOM);
  25285. }
  25286. }
  25287. matchBtn(btnId) {
  25288. const { header, footer } = this.themeData;
  25289. const btnItem = {
  25290. title: "",
  25291. id: "",
  25292. domString: "",
  25293. color: "#FFFFFF",
  25294. activeColor: "#FFFFFF",
  25295. onclick: () => { },
  25296. onmoveleft: () => { },
  25297. onmoveright: () => { },
  25298. onremove: () => { }
  25299. };
  25300. var _index = header.btnList.findIndex((item) => {
  25301. return item.iconId === btnId;
  25302. });
  25303. if (_index === -1) {
  25304. btnItem.color = footer.color;
  25305. btnItem.backgroundColor = footer.backgroundColor;
  25306. btnItem.activeColor = footer.activeColor;
  25307. } else {
  25308. btnItem.color = header.color;
  25309. btnItem.backgroundColor = header.backgroundColor;
  25310. btnItem.activeColor = header.activeColor;
  25311. }
  25312. switch (btnId) {
  25313. case 'play':
  25314. btnItem.title = "播放/结束播放";
  25315. btnItem.id = btnId;
  25316. btnItem.domString = (
  25317. '<span>'
  25318. + `<svg style="display:none" width="48" height="48" fill="${btnItem.color}" viewBox="-6 -6 32 32">
  25319. <path id="Stroke-1" class="st1" d="M10.5,1.7c-4.9,0-8.8,4-8.8,8.8s4,8.8,8.8,8.8s8.8-4,8.8-8.8S15.4,1.7,10.5,1.7z M10.5,2.7
  25320. c4.3,0,7.8,3.5,7.8,7.8s-3.5,7.8-7.8,7.8s-7.8-3.5-7.8-7.8S6.2,2.7,10.5,2.7z"/>
  25321. <path class="st2" d="M8.7,8C9,8,9.3,8.3,9.3,8.6v3.8C9.3,12.7,9,13,8.7,13C8.3,13,8,12.7,8,12.4V8.6C8,8.3,8.3,8,8.7,8z"/>
  25322. <path id="Rectangle-Copy-10" class="st2" d="M12.8,8c0.3,0,0.6,0.3,0.6,0.6v3.8c0,0.3-0.3,0.6-0.6,0.6c-0.3,0-0.6-0.3-0.6-0.6V8.6
  25323. C12.2,8.3,12.5,8,12.8,8z"/>
  25324. </svg>`
  25325. + `<svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25326. + '<path d="M13,9.8L10.1,8C9.9,7.9,9.7,7.9,9.5,7.9c-0.6,0-1,0.4-1,1v3.7c0,0.2,0.1,0.4,0.2,0.5c0.3,0.5,0.9,0.6,1.4,0.3 l2.9-1.8c0.1-0.1,0.2-0.2,0.3-0.3C13.6,10.7,13.4,10.1,13,9.8z" />'
  25327. + '<path d="M10.5,1.9c-4.9,0-8.8,4-8.8,8.8c0,4.9,4,8.8,8.8,8.8s8.8-4,8.8-8.8C19.4,5.8,15.4,1.9,10.5,1.9z M10.5,18.5 c-4.3,0-7.8-3.5-7.8-7.8s3.5-7.8,7.8-7.8c4.3,0,7.8,3.5,7.8,7.8S14.9,18.5,10.5,18.5z" />'
  25328. + '</svg>'
  25329. + '</span>'
  25330. );
  25331. btnItem.onclick = () => {
  25332. const { play } = this.decoderState.state;
  25333. if (play) {
  25334. this.jSPlugin.stop();
  25335. } else {
  25336. this.jSPlugin.play();
  25337. }
  25338. this.setDecoderState({ play: !play });
  25339. };
  25340. return btnItem;
  25341. case 'sound':
  25342. btnItem.title = "声音";
  25343. btnItem.id = btnId;
  25344. btnItem.domString = (
  25345. '<span>'
  25346. + `<svg style="display:none" fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">
  25347. <path d="M8.5,4.2c0.8-0.7,2.1-0.2,2.2,0.9l0,0.1v10c0,1.1-1.2,1.7-2.1,1.1l-0.1-0.1l-3.3-2.8C5,13.2,5,12.9,5.1,12.7 c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.3,2.8c0.2,0.2,0.5,0.1,0.5-0.2l0-0.1v-10c0-0.3-0.3-0.4-0.5-0.3L9.2,5L5.9,7.8 C5.6,7.9,5.3,7.9,5.1,7.7C5,7.5,5,7.3,5.1,7.1L5.2,7L8.5,4.2z"/>
  25348. <path d="M5.5,6.9C5.8,6.9,6,7.1,6,7.4c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2C3.4,7.9,3.3,8,3.2,8.2l0,0.1v4 c0,0.2,0.1,0.3,0.3,0.3l0.1,0h2C5.8,12.5,6,12.7,6,13c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2c-0.7,0-1.3-0.5-1.3-1.2l0-0.1v-4 c0-0.7,0.5-1.3,1.2-1.3l0.1,0H5.5z"/>
  25349. <path d="M17.4,7.9c0.2-0.2,0.5-0.2,0.7,0c0.2,0.2,0.2,0.4,0.1,0.6l-0.1,0.1l-3.8,3.8c-0.2,0.2-0.5,0.2-0.7,0 c-0.2-0.2-0.2-0.4-0.1-0.6l0.1-0.1L17.4,7.9z"/>
  25350. <path d="M13.7,7.9c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.8,3.8c0.2,0.2,0.2,0.5,0,0.7c-0.2,0.2-0.4,0.2-0.6,0.1l-0.1-0.1 l-3.7-3.8C13.5,8.4,13.5,8.1,13.7,7.9z"/>
  25351. </svg>`
  25352. + `<svg style="display:inline-block" width="48" height="48" fill="${btnItem.color}" viewBox="-6 -6 32 32">
  25353. <path d="M13.2,7.1c0.1-0.2,0.5-0.3,0.7-0.2c1.1,0.7,1.9,2.2,1.9,3.7c0,1.6-0.7,3-1.9,3.7
  25354. c-0.2,0.1-0.5,0.1-0.7-0.2c-0.1-0.2-0.1-0.5,0.2-0.7c0.8-0.5,1.4-1.6,1.4-2.9c0-1.3-0.6-2.4-1.4-2.9C13.1,7.6,13,7.3,13.2,7.1z"/>
  25355. <path d="M15.7,4.5c0.2-0.2,0.5-0.2,0.7-0.1C18,5.8,19,8.2,19,10.7c0,2.5-1,4.8-2.7,6.3
  25356. c-0.2,0.2-0.5,0.2-0.7-0.1c-0.2-0.2-0.2-0.5,0.1-0.7c1.4-1.2,2.3-3.3,2.3-5.5c0-2.2-0.9-4.3-2.3-5.5C15.5,5,15.5,4.7,15.7,4.5z"/>
  25357. <path id="Stroke-5" class="st1" d="M8.5,4.7c0.8-0.7,2.1-0.2,2.2,0.9l0,0.1v10c0,1.1-1.2,1.7-2.1,1.1l-0.1-0.1l-3.3-2.8
  25358. C5,13.7,5,13.4,5.1,13.2c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.3,2.8c0.2,0.2,0.5,0.1,0.5-0.2l0-0.1v-10c0-0.3-0.3-0.4-0.5-0.3l-0.1,0
  25359. L5.9,8.3C5.6,8.4,5.3,8.4,5.1,8.2C5,8,5,7.7,5.1,7.6l0.1-0.1L8.5,4.7z"/>
  25360. <path d="M5.5,7.4C5.8,7.4,6,7.6,6,7.9c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2c-0.2,0-0.3,0.1-0.3,0.3l0,0.1v4
  25361. c0,0.2,0.1,0.3,0.3,0.3l0.1,0h2C5.8,13,6,13.2,6,13.5c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-2c-0.7,0-1.3-0.5-1.3-1.2l0-0.1v-4
  25362. c0-0.7,0.5-1.3,1.2-1.3l0.1,0H5.5z"/>
  25363. </svg>`
  25364. + '</span>'
  25365. );
  25366. btnItem.onclick = () => {
  25367. const { play, sound } = this.decoderState.state;
  25368. if (play) {
  25369. if (sound) {
  25370. this.jSPlugin.closeSound();
  25371. this.setDecoderState({ sound: false });
  25372. } else {
  25373. this.jSPlugin.openSound();
  25374. this.setDecoderState({ sound: true });
  25375. }
  25376. }
  25377. };
  25378. return btnItem;
  25379. case 'recordvideo':
  25380. btnItem.title = "录屏";
  25381. btnItem.id = btnId;
  25382. btnItem.domString = (
  25383. `<svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25384. + '<path d="M11.6,5.3H4.7c-1.4,0-2.5,1.1-2.5,2.5v5.9c0,1.4,1.1,2.5,2.5,2.5h6.9c1.4,0,2.5-1.1,2.5-2.5V7.7 C14.1,6.4,13,5.3,11.6,5.3z M4.7,6.3h6.9c0.8,0,1.5,0.7,1.5,1.5v5.9c0,0.8-0.7,1.5-1.5,1.5H4.7c-0.8,0-1.5-0.7-1.5-1.5V7.7 C3.3,6.9,3.9,6.3,4.7,6.3z" />'
  25385. + '<path d="M16.6,6.7c0.9-0.8,2.3-0.1,2.4,1l0,0.1v5.7c0,1.2-1.3,1.9-2.3,1.2l-0.1-0.1L13.3,12 c-0.2-0.2-0.2-0.5-0.1-0.7c0.2-0.2,0.4-0.2,0.6-0.1l0.1,0.1l3.3,2.7c0.3,0.2,0.7,0.1,0.8-0.3l0-0.1V7.8c0-0.4-0.4-0.6-0.7-0.4 l-0.1,0l-3.3,2.7c-0.2,0.2-0.5,0.1-0.7-0.1c-0.2-0.2-0.1-0.5,0-0.6l0.1-0.1L16.6,6.7z" />'
  25386. + '</svg>'
  25387. );
  25388. btnItem.onclick = () => {
  25389. const { play, recordvideo } = this.decoderState.state;
  25390. if (play) {
  25391. if (recordvideo) {
  25392. this.jSPlugin.stopSave();
  25393. this.setDecoderState({ recordvideo: false });
  25394. } else {
  25395. this.jSPlugin.startSave(`${new Date().getTime()}`);
  25396. this.setDecoderState({ recordvideo: true });
  25397. }
  25398. }
  25399. };
  25400. return btnItem;
  25401. case 'closevideo':
  25402. btnItem.title = "关闭";
  25403. btnItem.id = btnId;
  25404. btnItem.domString = (
  25405. `<div class="flex align-center" style="min-height: 48px;max-height: 96px;">
  25406. <i class="el-icon-switch-button" style="font-size:24px;"></i>
  25407. </div>`
  25408. );
  25409. btnItem.onclick = () => {
  25410. const { play, closevideo } = this.decoderState.state;
  25411. if (play) {
  25412. _handleClose();
  25413. }
  25414. };
  25415. return btnItem;
  25416. case 'capturePicture':
  25417. btnItem.title = "截图";
  25418. btnItem.id = btnId;
  25419. btnItem.domString = (
  25420. `<svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25421. + '<path d="M10.8,7.7c-2,0-3.7,1.6-3.7,3.7S8.7,15,10.8,15c2,0,3.7-1.6,3.7-3.7S12.8,7.7,10.8,7.7z M10.8,8.7c1.5,0,2.7,1.2,2.7,2.7S12.2,14,10.8,14c-1.5,0-2.7-1.2-2.7-2.7S9.3,8.7,10.8,8.7z" />'
  25422. + '<path d="M8.6,3.7l-0.1,0C8,3.7,7.7,4,7.5,4.3l-1,1.7l-1.3,0C4,6.1,3.1,7,3.1,8.2v7.1 c0,1.2,0.9,2.1,2.1,2.1h11.1c1.2,0,2.1-0.9,2.1-2.1V8.2l0-0.1c-0.1-1.1-1-1.9-2.1-1.9l-1.3,0l-1.1-1.8c-0.2-0.4-0.7-0.6-1.1-0.6H8.6 z M8.6,4.7h4.2c0.1,0,0.2,0.1,0.3,0.1l1.2,2c0.1,0.2,0.3,0.2,0.4,0.2h1.6c0.6,0,1.1,0.5,1.1,1.1v7.1c0,0.6-0.5,1.1-1.1,1.1H5.1 c-0.6,0-1.1-0.5-1.1-1.1V8.2c0-0.6,0.5-1.1,1.1-1.1h1.6c0.2,0,0.3-0.1,0.4-0.2l1.2-2C8.4,4.7,8.5,4.7,8.6,4.7z" />'
  25423. + '</svg>'
  25424. );
  25425. btnItem.onclick = () => {
  25426. const { play } = this.decoderState.state;
  25427. if (play) {
  25428. this.jSPlugin.capturePicture(`${new Date().getTime()}`);
  25429. } else {
  25430. console.log("视频未播放,无法截图");
  25431. }
  25432. };
  25433. return btnItem;
  25434. case 'talk':
  25435. btnItem.title = "对讲";
  25436. btnItem.id = btnId;
  25437. btnItem.domString = (
  25438. '<div></div>'
  25439. + `<svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25440. + '<path d="M10.1,2.7C8.5,2.7,7.2,4,7.2,5.6v5.2c0,1.6,1.3,2.9,2.9,2.9l0.2,0c1.5-0.1,2.7-1.4,2.7-2.9V5.6 C13,4,11.7,2.7,10.1,2.7z M10.1,3.7c1.1,0,1.9,0.9,1.9,1.9v5.2c0,1-0.8,1.8-1.8,1.9l-0.1,0c-1,0-1.9-0.9-1.9-1.9V5.6 C8.2,4.5,9,3.7,10.1,3.7z" />'
  25441. + '<path d="M15.1,8.5c0.2,0,0.4,0.2,0.5,0.4l0,0.1v1.7c0,3-2.5,5.5-5.5,5.5c-3,0-5.4-2.3-5.5-5.3l0-0.2V9 c0-0.3,0.2-0.5,0.5-0.5c0.2,0,0.4,0.2,0.5,0.4l0,0.1v1.7c0,2.5,2,4.5,4.5,4.5c2.4,0,4.4-1.9,4.5-4.3l0-0.2V9 C14.6,8.7,14.8,8.5,15.1,8.5z" />'
  25442. + '<path d="M13.5,17.7c0.3,0,0.5,0.2,0.5,0.5c0,0.2-0.2,0.4-0.4,0.5l-0.1,0h-7c-0.3,0-0.5-0.2-0.5-0.5 c0-0.2,0.2-0.4,0.4-0.5l0.1,0H13.5z" />'
  25443. + '<path d="M10.1,15.2c0.2,0,0.4,0.2,0.5,0.4l0,0.1v2.5c0,0.3-0.2,0.5-0.5,0.5c-0.2,0-0.4-0.2-0.5-0.4l0-0.1 v-2.5C9.6,15.4,9.8,15.2,10.1,15.2z" />'
  25444. + '</svg>'
  25445. );
  25446. btnItem.onclick = () => {
  25447. const { talk, sound } = this.decoderState.state;
  25448. if (talk) {
  25449. console.log('结束对讲');
  25450. this.setDecoderState({ talk: false });
  25451. this.jSPlugin.Talk.stopTalk();
  25452. } else {
  25453. console.log('开始对讲');
  25454. this.setDecoderState({ talk: true });
  25455. if (sound) {
  25456. this.jSPlugin.closeSound();
  25457. this.setDecoderState({ sound: false });
  25458. }
  25459. this.jSPlugin.Talk.startTalk();
  25460. }
  25461. };
  25462. return btnItem;
  25463. case 'pantile':
  25464. btnItem.title = "云台控制";
  25465. btnItem.id = btnId;
  25466. btnItem.domString = (
  25467. `<svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25468. + '<path d="M10.2,7.8c1.6,0,2.9,1.3,2.9,2.9s-1.3,2.9-2.9,2.9s-2.9-1.3-2.9-2.9S8.5,7.8,10.2,7.8z M10.2,8.8c-1.1,0-1.9,0.9-1.9,1.9s0.9,1.9,1.9,1.9s1.9-0.9,1.9-1.9S11.2,8.8,10.2,8.8z" />'
  25469. + '<path d="M8.8,3.5c0.7-0.6,1.8-0.6,2.5-0.1l0.1,0.1l1.4,1.1c0.2,0.2,0.3,0.5,0.1,0.7 c-0.2,0.2-0.4,0.2-0.6,0.1l-0.1,0l-1.4-1.1C10.5,3.9,10,3.9,9.6,4.2L9.4,4.3L8,5.4C7.8,5.5,7.5,5.5,7.3,5.3c-0.2-0.2-0.1-0.5,0-0.6 l0.1-0.1L8.8,3.5z" />'
  25470. + '<path d="M2.5,12.3c-0.6-0.7-0.6-1.8-0.1-2.5l0.1-0.1l1.1-1.4c0.2-0.2,0.5-0.3,0.7-0.1 c0.2,0.2,0.2,0.4,0.1,0.6l0,0.1l-1.1,1.4C3,10.6,3,11.1,3.2,11.5l0.1,0.1L4.4,13c0.2,0.2,0.1,0.5-0.1,0.7c-0.2,0.2-0.5,0.1-0.6,0 l-0.1-0.1L2.5,12.3z" />'
  25471. + '<path d="M17.7,12.3c0.6-0.7,0.6-1.8,0.1-2.5l-0.1-0.1l-1.1-1.4c-0.2-0.2-0.5-0.3-0.7-0.1 c-0.2,0.2-0.2,0.4-0.1,0.6l0,0.1l1.1,1.4c0.3,0.4,0.3,0.9,0.1,1.3l-0.1,0.1L15.8,13c-0.2,0.2-0.1,0.5,0.1,0.7c0.2,0.2,0.5,0.1,0.6,0 l0.1-0.1L17.7,12.3z" />'
  25472. + '<path d="M8.8,18.2c0.7,0.6,1.8,0.6,2.5,0.1l0.1-0.1l1.4-1.1c0.2-0.2,0.3-0.5,0.1-0.7 c-0.2-0.2-0.4-0.2-0.6-0.1l-0.1,0l-1.4,1.1c-0.4,0.3-0.9,0.3-1.3,0.1l-0.1-0.1L8,16.3c-0.2-0.2-0.5-0.1-0.7,0.1 c-0.2,0.2-0.1,0.5,0,0.6l0.1,0.1L8.8,18.2z" />'
  25473. + '</svg>'
  25474. );
  25475. btnItem.onclick = () => {
  25476. const { pantile } = this.decoderState.state;
  25477. if (!pantile) {
  25478. console.log('显示云台');
  25479. this.Ptz.show();
  25480. this.setDecoderState({ pantile: true });
  25481. } else {
  25482. console.log('隐藏云台');
  25483. this.Ptz.hide();
  25484. this.setDecoderState({ pantile: false });
  25485. }
  25486. };
  25487. return btnItem;
  25488. case 'expend':
  25489. btnItem.title = "全局全屏";
  25490. btnItem.id = btnId;
  25491. btnItem.domString = (
  25492. `<span><svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25493. + '<path d="M3.4,7.6c-0.3,0-0.5-0.2-0.5-0.5V5.3c0-1.2,1-2.3,2.2-2.3h1.8c0.3,0,0.5,0.2,0.5,0.5S7.2,4.1,6.9,4.1H5.2 c-0.7,0-1.2,0.6-1.2,1.3v1.8C3.9,7.4,3.7,7.6,3.4,7.6z" />'
  25494. + '<path d="M6.9,18.1H5.2c-1.2,0-2.2-1-2.2-2.2v-1.8c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v1.8c0,0.7,0.6,1.2,1.2,1.2 h1.8c0.3,0,0.5,0.2,0.5,0.5S7.2,18.1,6.9,18.1z" />'
  25495. + '<path d="M15.7,18.1h-1.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h1.8c0.7,0,1.2-0.6,1.2-1.2v-1.8 c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v1.8C17.9,17.1,16.9,18.1,15.7,18.1z" />'
  25496. + '<path d="M17.4,7.6c-0.3,0-0.5-0.2-0.5-0.5V5.3c0-0.7-0.6-1.3-1.2-1.3h-1.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h1.8 c1.2,0,2.2,1,2.2,2.3v1.8C17.9,7.4,17.7,7.6,17.4,7.6z" />'
  25497. + '</svg>'
  25498. + `<svg style="display:none" width="48" height="48" fill="${btnItem.color}" viewBox="-6 -6 32 32">
  25499. <path class="st1" d="M5.7,8.1H3.9c-0.3,0-0.6-0.2-0.6-0.6S3.6,7,3.9,7h1.9c0.7,0,1.3-0.6,1.3-1.3V3.8c0-0.3,0.2-0.6,0.6-0.6
  25500. s0.6,0.2,0.6,0.6v1.9C8.2,7,7.1,8.1,5.7,8.1z"/>
  25501. <path class="st1" d="M7.6,17.7c-0.3,0-0.6-0.2-0.6-0.6v-1.9c0-0.7-0.6-1.3-1.3-1.3H3.9c-0.3,0-0.6-0.2-0.6-0.6s0.2-0.6,0.6-0.6h1.9
  25502. c1.3,0,2.4,1.1,2.4,2.4v1.9C8.2,17.5,7.9,17.7,7.6,17.7z"/>
  25503. <path class="st1" d="M13.4,17.7c-0.3,0-0.6-0.2-0.6-0.6v-1.9c0-1.3,1.1-2.4,2.4-2.4h1.9c0.3,0,0.6,0.2,0.6,0.6S17.5,14,17.2,14
  25504. h-1.9c-0.7,0-1.3,0.6-1.3,1.3v1.9C14,17.5,13.8,17.7,13.4,17.7z"/>
  25505. <path class="st1" d="M17.2,8.1h-1.9c-1.3,0-2.4-1.1-2.4-2.4V3.8c0-0.3,0.2-0.6,0.6-0.6S14,3.5,14,3.8v1.9C14,6.4,14.6,7,15.3,7h1.9
  25506. c0.3,0,0.6,0.2,0.6,0.6S17.5,8.1,17.2,8.1z"/>
  25507. </svg>
  25508. </span>`
  25509. );
  25510. btnItem.onclick = () => {
  25511. const { webExpend, expend, play } = this.decoderState.state;
  25512. if (!play) {
  25513. return false;
  25514. }
  25515. if (webExpend) {
  25516. console.log("正在网站全屏");
  25517. return false;
  25518. }
  25519. if (!expend) {
  25520. console.log("执行全局全屏");
  25521. if (this.isMobile) {
  25522. var heightIntercept = parseInt(getComputedStyle(document.getElementById(`${this.jSPlugin.id}-wrap`)).height, 10) - parseInt(getComputedStyle(document.getElementById(this.jSPlugin.id)).height, 10);
  25523. requestMobileFullScreen(document.getElementById(`${this.jSPlugin.id}-wrap`));
  25524. setTimeout(() => {
  25525. var width = document.documentElement.clientWidth;
  25526. var height = document.documentElement.clientHeight;
  25527. this.jSPlugin.jSPlugin.JS_Resize(height, width - heightIntercept);
  25528. }, 100);
  25529. } else {
  25530. var promise = requestFullScreenPromise(document.getElementById(`${this.jSPlugin.id}`));
  25531. promise.then((data) => {
  25532. console.log("全屏promise", window.screen.availWidth);
  25533. this.jSPlugin.jSPlugin.JS_Resize(window.screen.availWidth, window.screen.availHeight);
  25534. })
  25535. .catch(err => {
  25536. console.log(err);
  25537. });
  25538. }
  25539. } else {
  25540. if (this.isMobile) {
  25541. var heightIntercept = parseInt(getComputedStyle(document.getElementById(`${this.jSPlugin.id}-wrap`)).height, 10) - parseInt(getComputedStyle(document.getElementById(this.jSPlugin.id)).height, 10);
  25542. cancelMobileFullScreen(document.getElementById(`${this.jSPlugin.id}-wrap`), this.jSPlugin.width, this.jSPlugin.height + heightIntercept);
  25543. this.jSPlugin.jSPlugin.JS_Resize(this.jSPlugin.width, this.jSPlugin.height);
  25544. } else {
  25545. console.log("取消全局全屏");
  25546. var cancelPromise = cancelFullScreenPromise();
  25547. cancelPromise.then((data) => {
  25548. console.log("取消全屏", data, this.jSPlugin);
  25549. this.jSPlugin.jSPlugin.JS_Resize(this.jSPlugin.width, this.jSPlugin.height);
  25550. });
  25551. }
  25552. }
  25553. this.setDecoderState({
  25554. expend: !expend
  25555. });
  25556. };
  25557. return btnItem;
  25558. case 'webExpend':
  25559. btnItem.title = "网页全屏";
  25560. btnItem.id = btnId;
  25561. btnItem.domString = (
  25562. `<span><svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25563. + '<path d="M3.1,7.6c-0.3,0-0.5-0.2-0.5-0.5V5.3c0-1.2,1-2.3,2.2-2.3h1.8c0.3,0,0.5,0.2,0.5,0.5S6.8,4.1,6.6,4.1H4.8 c-0.7,0-1.2,0.6-1.2,1.3v1.8C3.6,7.4,3.3,7.6,3.1,7.6z" />'
  25564. + '<path d="M15.3,18.1h-1.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h1.8c0.7,0,1.2-0.6,1.2-1.2v-1.8 c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v1.8C17.6,17.1,16.6,18.1,15.3,18.1z" />'
  25565. + '<circle class="st2" cx="10.2" cy="10.4" r="1.1"/>'
  25566. + '</svg>'
  25567. + `<svg fill="${btnItem.color}" style="display:none;" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">
  25568. <path class="st1" d="M5.4,8.1H3.5C3.2,8.1,3,7.9,3,7.6s0.2-0.5,0.5-0.5h1.9c0.8,0,1.4-0.6,1.4-1.4V3.8c0-0.3,0.2-0.5,0.5-0.5
  25569. s0.5,0.2,0.5,0.5v1.9C7.7,7,6.7,8.1,5.4,8.1z"/>
  25570. <path class="st1" d="M13.1,17.7c-0.3,0-0.5-0.2-0.5-0.5v-1.9c0-1.3,1.1-2.4,2.4-2.4h1.9c0.3,0,0.5,0.2,0.5,0.5s-0.2,0.5-0.5,0.5H15
  25571. c-0.8,0-1.4,0.6-1.4,1.4v1.9C13.6,17.4,13.4,17.7,13.1,17.7z"/>
  25572. <circle class="st2" cx="10.2" cy="10.4" r="1.1"/>
  25573. `
  25574. + '</svg></span>'
  25575. );
  25576. btnItem.onclick = () => {
  25577. const { webExpend, expend, play } = this.decoderState.state;
  25578. if (!play) {
  25579. return false;
  25580. }
  25581. if (expend) {
  25582. console.log("正在全局全屏");
  25583. return false;
  25584. }
  25585. if (!webExpend) {
  25586. console.log("执行网页全屏");
  25587. var footerDOMHeight = 0;
  25588. var headerDOMHeight = 0;
  25589. // ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item) => {
  25590. // window.addEventListener(item, (data) => fullscreenchange("fullscreenchange", data));
  25591. // });
  25592. // // 监听全屏事件触发
  25593. // function fullscreenchange() {
  25594. // let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  25595. // return isFullScreen;
  25596. // }
  25597. var promise = requestFullScreenPromise(document.getElementById(`${this.jSPlugin.id}-wrap`));
  25598. promise.then((data) => {
  25599. console.log("全屏promise", window.screen.availWidth);
  25600. if (document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`)) {
  25601. footerDOMHeight = parseInt(window.getComputedStyle(document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`)).height, 10);
  25602. }
  25603. if (document.getElementById(`${this.jSPlugin.id}-headControl`)) {
  25604. headerDOMHeight = parseInt(window.getComputedStyle(document.getElementById(`${this.jSPlugin.id}-headControl`)).height, 10);
  25605. }
  25606. console.log("this.jSPlugin.JS_Resiz", footerDOMHeight, headerDOMHeight, document.body.clientWidth);
  25607. this.jSPlugin.jSPlugin.JS_Resize(window.screen.availWidth, window.screen.availHeight - footerDOMHeight - headerDOMHeight);
  25608. })
  25609. .catch(err => {
  25610. console.log(err);
  25611. });
  25612. } else {
  25613. console.log("取消网页全屏");
  25614. var cancelPromise = cancelFullScreenPromise();
  25615. cancelPromise.then((data) => {
  25616. this.jSPlugin.jSPlugin.JS_Resize(this.jSPlugin.width, this.jSPlugin.height);
  25617. });
  25618. }
  25619. this.setDecoderState({
  25620. webExpend: !webExpend
  25621. });
  25622. };
  25623. return btnItem;
  25624. case 'hd':
  25625. btnItem.title = "画面清晰度";
  25626. btnItem.id = btnId;
  25627. btnItem.domString = (
  25628. `<ul id="${this.jSPlugin.id}-hdSelect" class="select" style="display:none;width: 60px;background: #fff;box-shadow: 0 3px 20px 0 rgb(0 0 0 / 10%);border-radius: 2px;padding: 6px 0;position: absolute;top: -120px;">`
  25629. + `<li class="selectOption" style="width: 60px;height: 32px;text-align: center;line-height: 32px;list-style: none;cursor: pointer;font-size: 13px;color: rgba(0, 0, 0, .85);" name="option" id="${this.jSPlugin.id}-select-hd">高清</li>`
  25630. + `<li class="selectOption" style="width: 60px;height: 32px;text-align: center;line-height: 32px;list-style: none;cursor: pointer;font-size: 13px;color: rgba(0, 0, 0, .85);" name="option" id="${this.jSPlugin.id}-select-sd">标清</li>`
  25631. + '</ul>'
  25632. + `<span><svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -6 32 32">`
  25633. + '<path d="M17.4,16.5H3.1c-0.8,0-1.4-0.6-1.4-1.4V5.4c0-0.9,0.7-1.6,1.6-1.6h14.1c0.8,0,1.4,0.6,1.4,1.4v9.8 C18.8,15.9,18.2,16.5,17.4,16.5z M3.3,5C3.1,5,2.9,5.2,2.9,5.4v9.7c0,0.2,0.1,0.3,0.3,0.3h14.3c0.2,0,0.3-0.1,0.3-0.3V5.3 c0-0.2-0.1-0.3-0.3-0.3H3.3z" />'
  25634. + '<path d="M13.3,13.6h-1.6c-0.4,0-0.7-0.3-0.7-0.7V7.4c0-0.4,0.3-0.7,0.7-0.7h1.6c1.2,0,2.2,1,2.2,2.2v2.4 C15.6,12.6,14.6,13.6,13.3,13.6z M12.2,12.5h1.1c0.6,0,1.1-0.5,1.1-1.1V9c0-0.6-0.5-1.1-1.1-1.1h-1.1V12.5z" />'
  25635. + '<path d="M5.5,13.6c-0.3,0-0.6-0.2-0.6-0.6V7.3C5,7,5.2,6.8,5.5,6.8S6.1,7,6.1,7.3v5.7C6.1,13.4,5.8,13.6,5.5,13.6z" />'
  25636. + '<path d="M9.2,13.6c-0.3,0-0.6-0.2-0.6-0.6V7.3c0-0.3,0.2-0.6,0.6-0.6S9.8,7,9.8,7.3v5.7C9.8,13.4,9.5,13.6,9.2,13.6z" />'
  25637. + '<rect x="5.6" y="9.6" width="3.6" height="1.1" />'
  25638. + '</svg>'
  25639. + `<svg style="display:none" fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="-6 -8 40 44">
  25640. <path d="M24.1,23.8h-20c-1.1,0-1.9-0.9-1.9-1.9V8.4c0-1.2,1-2.2,2.1-2.2h19.7c1.1,0,1.9,0.9,1.9,1.9v13.8
  25641. C26,23,25.1,23.8,24.1,23.8z M4.3,7.7C4,7.7,3.7,8,3.7,8.4v13.5c0,0.2,0.2,0.4,0.4,0.4h20c0.2,0,0.4-0.2,0.4-0.4V8.2
  25642. c0-0.2-0.2-0.4-0.4-0.4H4.3z"/>
  25643. <path d="M18.4,19.8h-2.2c-0.5,0-0.9-0.4-0.9-0.9v-7.8c0-0.5,0.4-0.9,0.9-0.9h2.2c1.7,0,3.1,1.4,3.1,3.1v3.3
  25644. C21.5,18.4,20.1,19.8,18.4,19.8z M16.7,18.3h1.6c0.9,0,1.6-0.7,1.6-1.6v-3.3c0-0.9-0.7-1.6-1.6-1.6h-1.6V18.3z"/>
  25645. <path d="M10.5,19.8c1.2,0,2.1-0.3,2.7-0.9c0.6-0.6,0.9-1.3,0.9-2.1c0-0.8-0.3-1.4-0.9-1.8c-0.4-0.2-1.1-0.5-2.2-0.8
  25646. l0,0l-1-0.2c-0.4-0.1-0.8-0.2-1-0.4c-0.4-0.2-0.6-0.5-0.6-0.9c0-0.4,0.1-0.6,0.4-0.9s0.7-0.3,1.3-0.3c0.8,0,1.4,0.2,1.8,0.6
  25647. c0.2,0.3,0.3,0.6,0.4,0.9l0,0h1.4c0-0.6-0.2-1.1-0.5-1.6c-0.6-0.8-1.6-1.2-2.9-1.2c-1,0-1.8,0.3-2.4,0.8c-0.6,0.5-0.9,1.2-0.9,2
  25648. c0,0.7,0.3,1.3,1,1.7c0.4,0.2,0.9,0.4,1.7,0.6l0,0l1.2,0.3c0.6,0.2,1.1,0.3,1.3,0.4c0.3,0.2,0.5,0.5,0.5,0.9c0,0.5-0.2,0.9-0.6,1.1
  25649. s-0.9,0.4-1.5,0.4c-0.9,0-1.6-0.2-2-0.7c-0.2-0.3-0.3-0.6-0.4-1.1l0,0H6.8c0,0.9,0.3,1.6,0.9,2.2C8.2,19.5,9.2,19.8,10.5,19.8z"/>
  25650. <defs>
  25651. <filter id="Adobe_OpacityMaskFilter" filterUnits="userSpaceOnUse" x="15.2" y="10.3" width="6.2" height="9.5">
  25652. <feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
  25653. </filter>
  25654. </defs>
  25655. <mask maskUnits="userSpaceOnUse" x="15.2" y="10.3" width="6.2" height="9.5" id="mask-2_2_">
  25656. <g class="st2">
  25657. <path id="path-1_2_" class="st3" d="M24.1,23.1h-20c-0.6,0-1.2-0.5-1.2-1.2V8.2C2.9,7.5,3.5,7,4.1,7h19.7c0.8,0,1.4,0.6,1.4,1.4
  25658. v13.5C25.2,22.6,24.7,23.1,24.1,23.1z"/>
  25659. </g>
  25660. </mask>
  25661. <defs>
  25662. <filter id="Adobe_OpacityMaskFilter_1_" filterUnits="userSpaceOnUse" x="6.8" y="10.3" width="7.3" height="9.5">
  25663. <feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
  25664. </filter>
  25665. </defs>
  25666. <mask maskUnits="userSpaceOnUse" x="6.8" y="10.3" width="7.3" height="9.5" id="mask-2_3_">
  25667. <g class="st5">
  25668. <path id="path-1_3_" class="st3" d="M24.1,23.1h-20c-0.6,0-1.2-0.5-1.2-1.2V8.2C2.9,7.5,3.5,7,4.1,7h19.7c0.8,0,1.4,0.6,1.4,1.4
  25669. v13.5C25.2,22.6,24.7,23.1,24.1,23.1z"/>
  25670. </g>
  25671. </mask>
  25672. </svg>
  25673. `
  25674. + '</span>'
  25675. );
  25676. btnItem.onclick = (e) => {
  25677. const { hd } = this.decoderState.state;
  25678. // 选择清晰度选项时才触发事件
  25679. if (hd && e.target.id === `${this.jSPlugin.id}-select-sd`) {
  25680. //decoder.changePlayUrl({ hd: false });
  25681. console.log("切换到标清");
  25682. this.jSPlugin.changePlayUrl({ hd: false });
  25683. this.setDecoderState({
  25684. hd: false
  25685. });
  25686. } else if (!hd && e.target.id === `${this.jSPlugin.id}-select-hd`) {
  25687. this.jSPlugin.changePlayUrl({ hd: true });
  25688. this.setDecoderState({
  25689. hd: true
  25690. });
  25691. }
  25692. if (document.getElementById(`${this.jSPlugin.id}-hdSelect`)) {
  25693. document.getElementById(`${this.jSPlugin.id}-hdSelect`).style.display = document.getElementById(`${this.jSPlugin.id}-hdSelect`).style.display === 'none' ? 'block' : 'none';
  25694. }
  25695. };
  25696. return btnItem;
  25697. case 'deviceName':
  25698. btnItem.title = "设备名称";
  25699. btnItem.id = btnId;
  25700. btnItem.domString = (
  25701. '<span>设备名称</span>'
  25702. );
  25703. btnItem.onclick = () => {
  25704. };
  25705. return btnItem;
  25706. case 'deviceID':
  25707. btnItem.title = "设备序列号";
  25708. btnItem.id = btnId;
  25709. btnItem.domString = (
  25710. '<span>设备序列号</span>'
  25711. );
  25712. btnItem.onclick = () => {
  25713. };
  25714. return btnItem;
  25715. case 'cloudRec':
  25716. btnItem.title = "云存储回放";
  25717. btnItem.id = btnId;
  25718. btnItem.domString = (
  25719. `
  25720. <span>
  25721. <svg fill="${btnItem.color}" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="2 0 20 20">
  25722. <path d="M9.5,13.1c-0.3,0-0.5-0.2-0.5-0.5V8.8c0-0.3,0.2-0.5,0.5-0.5S10,8.5,10,8.8v3.8C10,12.8,9.8,13.1,9.5,13.1z"/>
  25723. <path d="M7.6,10.6c-0.1,0-0.3-0.1-0.4-0.2C7,10.2,7,9.9,7.3,9.7l1.9-1.7c0.2-0.2,0.5-0.2,0.7,0l1.8,1.7
  25724. c0.2,0.2,0.2,0.5,0,0.7c-0.2,0.2-0.5,0.2-0.7,0L9.5,9.1l-1.6,1.4C7.8,10.6,7.7,10.6,7.6,10.6z"/>
  25725. <path d="M13.2,15.7H5.6c-2.1-0.1-3.8-1.8-3.8-3.9c0-1.8,1.3-3.4,3-3.8c0.4-2.2,2.3-3.9,4.6-3.9c2.3,0,4.2,1.7,4.6,3.8
  25726. c1.8,0.4,3.1,1.9,3.1,3.8C17.1,13.9,15.4,15.7,13.2,15.7z M5.6,14.7h7.6c1.6,0,2.9-1.3,2.9-2.9c0-1.5-1.1-2.7-2.6-2.9l-0.4,0l0-0.4
  25727. c-0.2-1.9-1.7-3.3-3.6-3.3C7.5,5.1,6,6.6,5.8,8.5l0,0.4l-0.4,0c-1.4,0.2-2.5,1.4-2.5,2.9C2.8,13.3,4.1,14.6,5.6,14.7z"/>
  25728. </svg>
  25729. </span>
  25730. `
  25731. );
  25732. btnItem.onclick = () => {
  25733. console.log("点击云回放");
  25734. this.setDecoderState({
  25735. type: 'cloud.rec',
  25736. cloudRec: true,
  25737. rec: false
  25738. });
  25739. this.jSPlugin.changePlayUrl({
  25740. type: 'cloud.rec'
  25741. });
  25742. console.log(this.jSPlugin);
  25743. var initDate = getQueryString("begin", this.jSPlugin.url) || new Date().Format('yyyyMMdd');
  25744. this.Rec.renderRec(`${initDate.slice(0, 4)}-${initDate.slice(4, 6)}-${initDate.slice(6, 8)}`);
  25745. };
  25746. return btnItem;
  25747. case 'rec':
  25748. btnItem.title = "本地存储";
  25749. btnItem.id = btnId;
  25750. btnItem.domString = (
  25751. `
  25752. <span>
  25753. <svg fill=${btnItem.color} version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="2 0 20 20">
  25754. <path d="M13,16.3H5.5c-1.1,0-2-0.9-2-2V3.8c0-1.1,0.9-2,2-2h5.4c0.5,0,1,0.2,1.4,0.6l2.1,2.1C14.8,4.8,15,5.3,15,5.9
  25755. v8.4C15,15.4,14.1,16.3,13,16.3z M5.5,2.8c-0.6,0-1,0.4-1,1v10.5c0,0.6,0.4,1,1,1H13c0.6,0,1-0.4,1-1V5.9c0-0.3-0.1-0.5-0.3-0.7
  25756. L11.6,3c-0.2-0.2-0.4-0.3-0.7-0.3H5.5z"/>
  25757. <path d="M6.3,7.3C6,7.3,5.8,7,5.8,6.8V4.5C5.8,4.2,6,4,6.3,4s0.5,0.2,0.5,0.5v2.2C6.8,7,6.6,7.3,6.3,7.3z"/>
  25758. <path d="M8.5,7.3C8.3,7.3,8,7,8,6.8V4.5C8,4.2,8.3,4,8.5,4S9,4.2,9,4.5v2.2C9,7,8.8,7.3,8.5,7.3z"/>
  25759. <path d="M10.8,7.3c-0.3,0-0.5-0.2-0.5-0.5V4.5c0-0.3,0.2-0.5,0.5-0.5s0.5,0.2,0.5,0.5v2.2C11.3,7,11.1,7.3,10.8,7.3z"
  25760. />
  25761. </svg>
  25762. </span>
  25763. `
  25764. );
  25765. btnItem.onclick = () => {
  25766. console.log("点击本地回放");
  25767. this.setDecoderState({
  25768. type: 'rec',
  25769. cloudRec: false,
  25770. rec: true
  25771. });
  25772. this.jSPlugin.changePlayUrl({
  25773. type: 'rec'
  25774. });
  25775. console.log(this.jSPlugin);
  25776. var initDate = getQueryString("begin", this.jSPlugin.url) || new Date().Format('yyyyMMdd');
  25777. this.Rec.renderRec(`${initDate.slice(0, 4)}-${initDate.slice(4, 6)}-${initDate.slice(6, 8)}`);
  25778. };
  25779. return btnItem;
  25780. default:
  25781. btnItem.title = "关闭";
  25782. btnItem.id = btnId;
  25783. btnItem.domString = (
  25784. `<span>关闭设备</span>`);
  25785. return btnItem;
  25786. }
  25787. }
  25788. initThemeData() {
  25789. const { header, footer } = this.themeData;
  25790. const videoId = this.jSPlugin.id;
  25791. this.header = defaultTheme.header;
  25792. this.footer = defaultTheme.footer;
  25793. this.isNeedRenderHeader = lodash.findIndex(header.btnList, (v)=>{
  25794. return v.isrender > 0;
  25795. }) >= 0;
  25796. this.isNeedRenderFooter = lodash.findIndex(footer.btnList, (v)=>{
  25797. return v.isrender > 0;
  25798. }) >= 0;
  25799. ["date-switch-container-wrap","rec-type-container-wrap","mobile-rec-wrap","mobile-ez-ptz-container"].forEach((item,index)=> {
  25800. if(document.getElementById(item)) {
  25801. document.getElementById(item).parentElement.removeChild(document.getElementById(item));
  25802. }
  25803. });
  25804. // if (this.isNeedRenderHeader) {
  25805. // if (!document.getElementById(`${this.jSPlugin.id}-headControl`)) {
  25806. // const headerContainer = document.createElement('div');
  25807. // headerContainer.setAttribute('id', `${this.jSPlugin.id}-headControl`);
  25808. // headerContainer.setAttribute('class', 'head-message');
  25809. // headerContainer.innerHTML = `<div id='${this.jSPlugin.id}}-headControl-left' style='display:flex'></div><div id='${this.jSPlugin.id}}-headControl-right' style='display:flex'></div>`;
  25810. // var headerStyle = {
  25811. // height: "48px",
  25812. // "line-height": "48px",
  25813. // display: "flex",
  25814. // "justify-content": "space-between",
  25815. // top: 0,
  25816. // "z-index": 1,
  25817. // background: "#000000",
  25818. // color: "#FFFFFF",
  25819. // width: "100%"
  25820. // };
  25821. // headerContainer.style = styleToString(headerStyle);
  25822. // document.getElementById(`${videoId}-wrap`).insertBefore(headerContainer, document.getElementById(videoId));
  25823. // } else {
  25824. // document.getElementById(`${this.jSPlugin.id}-headControl`).innerHTML = `<div id='${this.jSPlugin.id}}-headControl-left' style='display:flex'></div><div id='${this.jSPlugin.id}}-headControl-right' style='display:flex'></div>`;
  25825. // }
  25826. // } else {
  25827. // if (document.getElementById(`${this.jSPlugin.id}-headControl`)) {
  25828. // document.getElementById(`${this.jSPlugin.id}-headControl`).parentElement.removeChild(document.getElementById(`${this.jSPlugin.id}-headControl`));
  25829. // }
  25830. // }
  25831. if (this.isNeedRenderFooter) {
  25832. if (!document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`)) {
  25833. const footerContainer = document.createElement('div');
  25834. footerContainer.setAttribute('id', `${this.jSPlugin.id}-ez-iframe-footer-container`);
  25835. footerContainer.setAttribute('class', 'ez-iframe-footer-container');
  25836. var footerStyle = {
  25837. "min-height": "48px",
  25838. "max-height": "96px",
  25839. "position": "relative",
  25840. "margin-top": "-48px",
  25841. display: "flex",
  25842. "flex-wrap": "wrap",
  25843. "justify-content": "space-between",
  25844. top: 0,
  25845. "z-index": 1,
  25846. color: "#FFFFFF",
  25847. width: "100%"
  25848. };
  25849. footerContainer.style = styleToString(footerStyle);
  25850. footerContainer.innerHTML = `<div id="${this.jSPlugin.id}-audioControls" style='display:flex;justify-content: space-between;height: 48px;width:100%;'><div id='${this.jSPlugin.id}-audioControls-left' style='display:flex'></div><div id='${this.jSPlugin.id}-audioControls-right' style='display:flex'></div></div>`;
  25851. insertAfter$1(footerContainer, document.getElementById(videoId));
  25852. } else {
  25853. if (document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`)) {
  25854. document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`).innerHTML =`<div id="${this.jSPlugin.id}-audioControls" style='display:flex;justify-content: space-between;height: 48px;width:100%;'><div id='${this.jSPlugin.id}-audioControls-left' style='display:flex'></div><div id='${this.jSPlugin.id}-audioControls-right' style='display:flex'></div></div>`;
  25855. }
  25856. }
  25857. } else {
  25858. if (document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`)) {
  25859. document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`).parentElement.removeChild(document.getElementById(`${this.jSPlugin.id}-ez-iframe-footer-container`));
  25860. }
  25861. }
  25862. if (this.isNeedRenderHeader && document.getElementById(`${this.jSPlugin.id}-headControl`)) {
  25863. document.getElementById(`${this.jSPlugin.id}-headControl`).style.background = header.backgroundColor;
  25864. document.getElementById(`${this.jSPlugin.id}-headControl`).style.color = header.color;
  25865. header.btnList.map((item, index) => {
  25866. if (item.isrender) {
  25867. // this.renderHeader(item.iconId, item.part);
  25868. }
  25869. });
  25870. }
  25871. if (this.isNeedRenderFooter && document.getElementById(`${this.jSPlugin.id}-audioControls`)) {
  25872. document.getElementById(`${this.jSPlugin.id}-audioControls`).style.background = footer.backgroundColor;
  25873. document.getElementById(`${this.jSPlugin.id}-audioControls`).style.color = footer.color;
  25874. footer.btnList.map((item, index) => {
  25875. if (item.isrender) {
  25876. this.renderFooter(item.iconId, item.part);
  25877. }
  25878. });
  25879. }
  25880. var isNeedRenderTimeLine = (lodash.findIndex(this.themeData.header.btnList, (v)=>{
  25881. return (v.iconId === 'cloudRec' && v.isrender === 1) || (v.iconId === 'rec' && v.isrender === 1) ;
  25882. }) >= 0 || (this.isMobile && matchEzopenUrl(this.jSPlugin.url).type.indexOf('rec') !== -1)) && !this.jSPlugin.disabledTimeLine;
  25883. if (isNeedRenderTimeLine) {
  25884. if (this.isMobile) {
  25885. this.Rec = new MobileRec(this.jSPlugin);
  25886. } else {
  25887. this.Rec = new Rec(this.jSPlugin);
  25888. }
  25889. }
  25890. var isNeedRenderPTZ = (lodash.findIndex(this.themeData.header.btnList, (v)=>{
  25891. return (v.iconId === 'pantile' && v.isrender === 1);
  25892. }) >= 0 || (this.isMobile && matchEzopenUrl(this.jSPlugin.url).type.indexOf('live') !== -1)) && !this.jSPlugin.disabledPTZ;
  25893. if (isNeedRenderPTZ) {
  25894. this.MobilePtz = new MobilePtz(this.jSPlugin);
  25895. this.Ptz = new Ptz(this.jSPlugin);
  25896. } else {
  25897. this.Ptz = new Ptz(this.jSPlugin);
  25898. }
  25899. // 监听全屏事件触发
  25900. const fullscreenchange = () => {
  25901. const { expend, webExpend } = this.decoderState.state;
  25902. let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  25903. if (!isFullScreen) {
  25904. this.jSPlugin.jSPlugin.JS_Resize(this.jSPlugin.width, this.jSPlugin.height);
  25905. if (expend) {
  25906. this.setDecoderState({ expend: false });
  25907. }
  25908. if (webExpend) {
  25909. this.setDecoderState({ webExpend: false });
  25910. }
  25911. }
  25912. };
  25913. ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item) => {
  25914. window.addEventListener(item, (data) => fullscreenchange());
  25915. });
  25916. this.inited = true;
  25917. //设备信息
  25918. this.getDeviceInfo();
  25919. }
  25920. getDeviceInfo() {
  25921. const deviceAPISuccess = (data) => {
  25922. if (data.code == 200 && data.data) {
  25923. // 设备序列号
  25924. if (document.getElementById(`${this.jSPlugin.id}-deviceName-content`)) {
  25925. document.getElementById(`${this.jSPlugin.id}-deviceName-content`).innerHTML = data.data.deviceName;
  25926. }
  25927. // 设备序列号
  25928. if (document.getElementById(`${this.jSPlugin.id}-deviceID-content`)) {
  25929. document.getElementById(`${this.jSPlugin.id}-deviceID-content`).innerHTML = matchEzopenUrl(this.jSPlugin.url).deviceSerial;
  25930. }
  25931. }
  25932. };
  25933. request(this.jSPlugin.env.domain + '/api/lapp/device/info',
  25934. 'POST',
  25935. {
  25936. accessToken: this.jSPlugin.accessToken,
  25937. deviceSerial: matchEzopenUrl(this.jSPlugin.url).deviceSerial
  25938. }, '', deviceAPISuccess);
  25939. }
  25940. }
  25941. class Monitor {
  25942. constructor(params) {
  25943. this.params = params;
  25944. this.state = {
  25945. };
  25946. }
  25947. dclog(dclogObj) {
  25948. const { params } = this;
  25949. var url = "https://log.ys7.com/statistics.do?";
  25950. if(params.env) {
  25951. switch(params.env){
  25952. case 'test12':
  25953. url = "https://test12dclog.ys7.com/statistics.do?";
  25954. break;
  25955. case 'online':
  25956. break;
  25957. default:
  25958. url = params.env;
  25959. break;
  25960. }
  25961. }
  25962. var obj = Object.assign({}, { systemName: "open_website_monitor" }, { bn: "ezuikit-js" }, dclogObj, {un:dclogObj.url}, { st: new Date().getTime(), h: window.location.pathname }); // usr_name 更改为un,兼容旧
  25963. Object.keys(obj).forEach(function(item, index){
  25964. var value = obj[item];
  25965. if (typeof (obj[item]) === 'string') {
  25966. value = obj[item].replace('%', '%25'); // decodeURIComponent 无法解析%
  25967. }
  25968. if (typeof (obj[item]) === 'undefined') {
  25969. return;
  25970. }
  25971. url += "".concat(index === 0 ? '' : '&').concat(item, "=").concat(encodeURIComponent(value));
  25972. });
  25973. var img = new Image();
  25974. img.src = url;
  25975. }
  25976. }
  25977. /**
  25978. * EZUIKitPlayer for npm
  25979. */
  25980. (function (global, factory) {
  25981. if (typeof module === "object" && typeof module.exports === "object") {
  25982. module.exports = global.document ? factory(global, true) : function (w) {
  25983. if (!w.document) {
  25984. throw new Error("EZUIPlayer requires a window with a document");
  25985. }
  25986. return factory(w);
  25987. };
  25988. } else {
  25989. factory(global);
  25990. } // Pass this if window is not defined yet
  25991. })(typeof window !== "undefined" ? window : void 0, function (window, noGlobal) {
  25992. // 加载js
  25993. function addJs(filepath, callback) {
  25994. var headerScript = document.getElementsByTagName('head')[0].getElementsByTagName("script");
  25995. var isReady = false;
  25996. for (var i = 0; i < headerScript.length; i++) {
  25997. if (headerScript[i].getAttribute("src") == filepath) {
  25998. isReady = true;
  25999. callback();
  26000. }
  26001. }
  26002. if (!isReady) {
  26003. var oJs = document.createElement("script");
  26004. oJs.setAttribute("src", filepath);
  26005. oJs.onload = callback;
  26006. document.getElementsByTagName("head")[0].appendChild(oJs);
  26007. }
  26008. } // 加载css
  26009. function addCss(filepath, callback) {
  26010. var headerLink = document.getElementsByTagName('head')[0].getElementsByTagName("link");
  26011. var isReady = false;
  26012. for (var i = 0; i < headerLink.length; i++) {
  26013. if (headerLink[i].getAttribute("href") == filepath) {
  26014. isReady = true;
  26015. callback();
  26016. }
  26017. }
  26018. if (!isReady) {
  26019. var oJs = document.createElement('link');
  26020. oJs.rel = 'stylesheet';
  26021. oJs.type = 'text/css';
  26022. oJs.href = filepath;
  26023. oJs.onload = callback;
  26024. document.getElementsByTagName("head")[0].appendChild(oJs);
  26025. }
  26026. } // 通用请求方法
  26027. function request(url, method, params, header, success, error) {
  26028. var _url = url;
  26029. var http_request = new XMLHttpRequest();
  26030. http_request.onreadystatechange = function () {
  26031. if (http_request.readyState == 4) {
  26032. if (http_request.status == 200) {
  26033. var _data = JSON.parse(http_request.responseText);
  26034. success(_data);
  26035. }
  26036. }
  26037. };
  26038. http_request.open(method, _url, true); // http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  26039. var data = new FormData();
  26040. for (var i in params) {
  26041. data.append(i, params[i]);
  26042. }
  26043. http_request.send(data);
  26044. }
  26045. var EZUIKit = {
  26046. EZUIKitPlayer: undefined,
  26047. EZUIKitTalk: undefined,
  26048. opt: {
  26049. apiDomain: 'https://open.ys7.com/api/lapp/live/talk/url',
  26050. filePath: 'https://open.ys7.com/assets/ezuikit_v2.6.4',
  26051. accessToken: '',
  26052. url: '',
  26053. deviceSerial: '',
  26054. channelNo: '',
  26055. id: '',
  26056. talkLink: '',
  26057. rtcUrl: '',
  26058. ttsUrl: '',
  26059. stream: '',
  26060. // 对讲插件依赖
  26061. isReliesReady: false,
  26062. template: 'simple',
  26063. plugin: [],
  26064. // 加载插件,talk-对讲
  26065. audio: 1,
  26066. // 声音id 0-不开启 1-开启
  26067. autoplay: 1,
  26068. videoLoading: false,
  26069. },
  26070. state: {
  26071. countTimer: undefined,
  26072. // countTime 计时器
  26073. recodeTime: 0,
  26074. // 录音时间
  26075. recodeTimer: undefined,
  26076. //录音时长 计时器
  26077. recodeTime: 0,
  26078. fetchDefaultList: false,
  26079. // 是否拉取默认语音-当用户语音为空
  26080. page: 0,
  26081. // 语音当前页
  26082. pageSize: 5
  26083. },
  26084. handleTalkSuccess: function(){},
  26085. handleTalkError: function(){},
  26086. };
  26087. /**
  26088. * 视频播放器-开始
  26089. */
  26090. var domain = "https://open.ys7.com";
  26091. var filePathDomain = domain;
  26092. var EZUIKitPlayer = function EZUIKitPlayer(params) {
  26093. var _this = this;
  26094. this.opt = {
  26095. id: params.id,
  26096. apiDomain: domain + '/api/lapp/live/talk/url',
  26097. filePath: filePathDomain + '/assets/ezuikit_v2.6.4',
  26098. decoderVersion: '',
  26099. accessToken: '',
  26100. url: '',
  26101. deviceSerial: '',
  26102. channelNo: '',
  26103. talkLink: '',
  26104. rtcUrl: '',
  26105. ttsUrl: '',
  26106. stream: '',
  26107. // 对讲插件依赖
  26108. isReliesReady: false,
  26109. template: 'simple',
  26110. plugin: [],
  26111. // 加载插件,talk-对讲
  26112. audio: 1,
  26113. // 声音id 0-不开启 1-开启
  26114. autoplay: 1,
  26115. fullScreenStatus: 0,
  26116. bSupporDoubleClickFull: true,
  26117. videoLoading: false,
  26118. };
  26119. this.params = params;
  26120. if (params.id) {
  26121. this.opt.id = params.id;
  26122. }
  26123. if (params.accessToken) {
  26124. this.opt.accessToken = params.accessToken;
  26125. }
  26126. if (typeof params.audio !== 'undefined') {
  26127. this.opt.audio = params.audio;
  26128. }
  26129. if (typeof params.decoderVersion !== 'undefined') {
  26130. this.opt.decoderVersion = params.decoderVersion;
  26131. }
  26132. if (typeof params.env !== 'undefined') {
  26133. if(typeof params.env.domain !== 'undefined'){
  26134. domain = params.env.domain;
  26135. this.opt.apiDomain = domain + '/api/lapp/live/talk/url';
  26136. }
  26137. if(typeof params.env.filePathDomain !== 'undefined'){
  26138. filePathDomain = params.env.filePathDomain;
  26139. this.opt.filePathDomain = params.env.filePathDomain;
  26140. }
  26141. }
  26142. // if(typeof params.domain !== 'undefined'){
  26143. // this.opt.apiDomain = params.domain + '/api/lapp/live/talk/url';
  26144. // }
  26145. if (params.url) {
  26146. this.opt.url = params.url;
  26147. this.opt.deviceSerial = params.url.split("/")[3];
  26148. this.opt.channelNo = params.url.split("/")[4].split(".")[0];
  26149. }
  26150. if (typeof params.template !== 'undefined') {
  26151. this.opt.template = params.template;
  26152. }
  26153. if (params.plugin) {
  26154. this.opt.plugin = params.plugin;
  26155. }
  26156. if (typeof params.autoplay !== 'undefined') {
  26157. this.opt.autoplay = params.autoplay ? 1 : 0;
  26158. }
  26159. if (typeof params.bSupporDoubleClickFull !== 'undefined') {
  26160. this.opt.bSupporDoubleClickFull = params.bSupporDoubleClickFull;
  26161. }
  26162. if (typeof params.handleTalkSuccess !== 'undefined') {
  26163. window.EZUIKit.handleTalkSuccess = params.handleTalkSuccess;
  26164. }
  26165. if (typeof params.handleTalkError !== 'undefined') {
  26166. window.EZUIKit.handleTalkError = params.handleTalkError;
  26167. }
  26168. var id = this.opt.id;
  26169. var domElement = document.getElementById(id); // 间隙
  26170. domElement.style.fontSize = 0;
  26171. domElement.style.overflowY = 'auto';
  26172. domElement.style.position = 'relative';
  26173. /**
  26174. * 渲染iframe视频框
  26175. */
  26176. var iframe = document.createElement('iframe');
  26177. function matchIframeUrl() {
  26178. switch (_this.opt.template) {
  26179. case 'simple':
  26180. var iframeUrl = domain + "/ezopen/h5/iframe?bSupporDoubleClickFull=0&url=" + _this.opt.url.replace("?","&") + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0" + "&id=" + id + "&decoderVersion=" + _this.opt.decoderVersion;
  26181. var controlsValue = "";
  26182. if(typeof params.controls !== 'undefined' && params.controls){
  26183. console.log("typeof" ,typeof params.controls);
  26184. controlsValue = "play,voice,hd,fullScreen";
  26185. if(params.controls.length > 0){
  26186. controlsValue = params.controls.join(",");
  26187. iframeUrl += ('&controls=' + controlsValue);
  26188. }
  26189. }
  26190. if (params.websocketParams) {
  26191. iframeUrl += ('&websocketParams=' + JSON.stringify(params.websocketParams));
  26192. }
  26193. return iframeUrl;
  26194. case 'standard':
  26195. return domain + "/ezopen/h5/iframe?bSupporDoubleClickFull=0&url=" + _this.opt.url.replace("?","&") + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=1" + "&id=" + id + "&decoderVersion=" + _this.opt.decoderVersion;
  26196. case 'security':
  26197. return domain + "/ezopen/h5/iframe_se?bSupporDoubleClickFull=0&url=" + _this.opt.url.replace("?","&") + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0" + "&id=" + id + "&decoderVersion=" + _this.opt.decoderVersion;
  26198. case 'theme':
  26199. iframeUrl = domain +`/jssdk/theme.html?url=${params.url}&accessToken=${params.accessToken}&id=${id}&isMobile=${params.isMobile}`;
  26200. if(typeof params.isMobile !== 'undefined') {
  26201. iframeUrl += '&isMobile=' + params.isMobile;
  26202. }
  26203. if(typeof params.autoplay !== 'undefined') {
  26204. iframeUrl += '&autoplay=' + params.autoplay;
  26205. }
  26206. if(typeof params.domain !== 'undefined') {
  26207. if(params.domain == 'https://test12open.ys7.com')
  26208. iframeUrl += '&env=' + 'test12';
  26209. }
  26210. if (typeof params.env !== 'undefined') {
  26211. if(typeof params.env.domain !== 'undefined'){
  26212. if(params.env.domain == 'https://test12open.ys7.com'){
  26213. iframeUrl += '&env=' + 'test12';
  26214. }
  26215. }
  26216. }
  26217. if(typeof params.header !== 'undefined') {
  26218. iframeUrl += '&header=' + params.header;
  26219. }
  26220. return iframeUrl;
  26221. default:
  26222. return domain + "/ezopen/h5/iframe?bSupporDoubleClickFull=0&url=" + _this.opt.url.replace("?","&") + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0" + "&id=" + id + "&decoderVersion=" + _this.opt.decoderVersion;
  26223. }
  26224. }
  26225. iframe.src = matchIframeUrl(); // 默认取容器宽高
  26226. var iframeHeight = document.getElementById(id).offsetHeight;
  26227. var iframeWidth = document.getElementById(id).offsetWidth;
  26228. if (params.height) {
  26229. iframeHeight = parseInt(params.height);
  26230. if(/\%$/.test(params.height)) {
  26231. iframeWidth = document.getElementById(id).offsetWidth * (parseInt(params.height) /100);
  26232. }
  26233. }
  26234. if (params.width) {
  26235. iframeWidth = parseInt(params.width);
  26236. if(/\%$/.test(params.width)) {
  26237. iframeWidth = document.getElementById(id).offsetWidth * (parseInt(params.width) /100);
  26238. }
  26239. }
  26240. iframe.width = iframeWidth;
  26241. iframe.height = iframeHeight;
  26242. iframe.id = 'EZUIKitPlayer-' + id; // 部分iframe属性
  26243. iframe.setAttribute("allowfullscreen", true);
  26244. iframe.setAttribute("allow", "autoplay");
  26245. iframe.setAttribute("frameborder", 0);
  26246. domElement.appendChild(iframe);
  26247. var jqueryJS = _this.opt.filePath + '/js/jquery.js';
  26248. var layerJs = 'https://open.ys7.com/assets/layer/layer.js';
  26249. addJs(jqueryJS, function () {
  26250. addJs(layerJs, function () {
  26251. // });
  26252. // });
  26253. /**
  26254. * 渲染header
  26255. */
  26256. if (matchHeaderOpt().headerContainer) {
  26257. // if (params.header && params.header instanceof Array) {
  26258. var headerContainer = document.createElement('div');
  26259. headerContainer.setAttribute('class', 'panel-top');
  26260. var controsDOM = document.createElement('div');
  26261. controsDOM.setAttribute('class', 'contros');
  26262. headerContainer.appendChild(controsDOM);
  26263. domElement.insertBefore(headerContainer, iframe);
  26264. if (matchHeaderOpt().capturePictureModule) {
  26265. // 截图
  26266. var capturePictureDOM = document.createElement('span');
  26267. capturePictureDOM.innerHTML = '<span title="截图">' + '<svg id="capturePicture" title="截图" t="1578882764585" class="icon" viewBox="0 0 1024 1024" version="1.1"' + ' xmlns="http://www.w3.org/2000/svg" p-id="5958" width="24" height="24">' + ' <path' + ' d="M887.296 315.904h-153.6c-51.2 0-68.096-102.4-119.296-102.4H392.704c-34.304 0-51.2 102.4-102.4 102.4h-153.6c-29.696 0-51.2 21.504-51.2 51.2v439.296c0 25.6 21.504 47.104 51.2 47.104h751.104c29.696 0 51.2-21.504 51.2-51.2v-435.2c-0.512-30.208-21.504-51.2-51.712-51.2zM512 768c-115.2 0-204.8-89.6-204.8-200.704s89.6-200.704 204.8-200.704 204.8 89.6 204.8 200.704-93.696 200.704-204.8 200.704z m247.296-354.304c-12.8 0-25.6-12.8-25.6-25.6s12.8-25.6 25.6-25.6 25.6 12.8 25.6 25.6c0 17.408-12.8 25.6-25.6 25.6zM256 264.704c0-8.704-8.704-16.896-16.896-16.896h-51.2c-8.704 0-16.896 8.704-16.896 16.896V281.6H256v-16.896z m256 148.992c-85.504 0-153.6 68.096-153.6 153.6s68.096 153.6 153.6 153.6 153.6-68.096 153.6-153.6-68.096-153.6-153.6-153.6z"' + ' fill="#ffffff" p-id="5959"></path>' + '</svg>' + '</span>';
  26268. capturePictureDOM.onclick = function () {
  26269. _this.capturePicture();
  26270. };
  26271. controsDOM.appendChild(capturePictureDOM);
  26272. }
  26273. console.log("matchHeaderOpt().saveModule", matchHeaderOpt().saveModule);
  26274. if (matchHeaderOpt().saveModule) {
  26275. var startSaveDOM = document.createElement('span');
  26276. startSaveDOM.innerHTML = '<span title="开始录像">' + ' <svg id="startSave" t="1578882716693" class="icon" viewBox="0 0 1024 1024" version="1.1"' + ' xmlns="http://www.w3.org/2000/svg" p-id="3782" width="24" height="24">' + ' <path' + ' d="M915.2 729.6l-128-76.8c-25.6-12.8-44.8-32-44.8-51.2V435.2c0-25.6 19.2-38.4 44.8-51.2l128-76.8c25.6-12.8 44.8 0 44.8 19.2V704c0 32-19.2 38.4-44.8 25.6z m-332.8 89.6H96c-51.2 0-89.6-38.4-89.6-89.6V332.8c0-51.2 38.4-89.6 89.6-89.6h486.4c51.2 0 89.6 38.4 89.6 89.6v396.8c0 51.2-38.4 89.6-89.6 89.6zM192 364.8c-32 6.4-57.6 32-64 64-12.8 57.6 38.4 115.2 96 102.4 32-6.4 57.6-32 64-70.4 12.8-57.6-38.4-108.8-96-96z m0 0"' + ' p-id="3783" fill="#ffffff"></path>' + ' </svg>' + '</span>';
  26277. startSaveDOM.onclick = function () {
  26278. _this.startSave();
  26279. document.getElementById('startSave').setAttribute('class', 'icon hide');
  26280. document.getElementById('stopSave').setAttribute('class', 'icon');
  26281. };
  26282. controsDOM.appendChild(startSaveDOM);
  26283. var stopSaveDOM = document.createElement('span');
  26284. stopSaveDOM.innerHTML = '<span title="结束录像">' + ' <svg id="stopSave" t="1578882716693" class="icon hide" viewBox="0 0 1024 1024" version="1.1"' + ' xmlns="http://www.w3.org/2000/svg" p-id="3782" width="24" height="24">' + ' <path' + ' d="M915.2 729.6l-128-76.8c-25.6-12.8-44.8-32-44.8-51.2V435.2c0-25.6 19.2-38.4 44.8-51.2l128-76.8c25.6-12.8 44.8 0 44.8 19.2V704c0 32-19.2 38.4-44.8 25.6z m-332.8 89.6H96c-51.2 0-89.6-38.4-89.6-89.6V332.8c0-51.2 38.4-89.6 89.6-89.6h486.4c51.2 0 89.6 38.4 89.6 89.6v396.8c0 51.2-38.4 89.6-89.6 89.6zM192 364.8c-32 6.4-57.6 32-64 64-12.8 57.6 38.4 115.2 96 102.4 32-6.4 57.6-32 64-70.4 12.8-57.6-38.4-108.8-96-96z m0 0"' + ' p-id="3783" fill="red"></path>' + ' </svg>' + ' </span>';
  26285. stopSaveDOM.onclick = function () {
  26286. _this.stopSave();
  26287. document.getElementById('stopSave').setAttribute('class', 'icon hide');
  26288. document.getElementById('startSave').setAttribute('class', 'icon');
  26289. };
  26290. controsDOM.appendChild(stopSaveDOM);
  26291. }
  26292. if (matchHeaderOpt().zoomModule) {
  26293. var enableZoomDOM = document.createElement('span');
  26294. enableZoomDOM.innerHTML = '<span title="开启电子放大">' + ' <svg id="enableZoom" t="1578882639834" class="icon" viewBox="0 0 1000 1000" version="1.1"' + ' xmlns="http://www.w3.org/2000/svg" p-id="2227" width="24" height="24">' + ' <path' + ' d="M830.6119 441.1089c0-193.7756-157.0939-350.8641-350.8775-350.8641S128.8559 247.3333 128.8559 441.1089 285.9508 791.972 479.7344 791.972 830.6119 634.8845 830.6119 441.1089zM483.2821 710.4863c-146.7975 0-265.8187-118.9953-265.8187-265.8088S336.4847 178.8697 483.2821 178.8697s265.8197 118.9953 265.8197 265.8078S630.0796 710.4863 483.2821 710.4863zM770.6031 653.5739l-72.6417 75.9485 141.6917 160.1814 82.0737-90.0739L770.6031 653.5739zM527.5849 267.4727h-88.60655762279428v132.90489048425167H306.0690340253259v88.60292721534799h132.90933675248866v132.9038911617923h88.60655762279428V488.9794719180395h132.90933675248866v-88.60292721534799H527.5849284006089V267.4726535408993z"' + ' p-id="2228" fill="#ffffff"></path>' + ' </svg>' + '</span>';
  26295. enableZoomDOM.onclick = function () {
  26296. _this.enableZoom();
  26297. document.getElementById('enableZoom').setAttribute('class', 'icon hide');
  26298. document.getElementById('closeZoom').setAttribute('class', 'icon');
  26299. };
  26300. controsDOM.appendChild(enableZoomDOM);
  26301. var closeZoomDOM = document.createElement('span');
  26302. closeZoomDOM.innerHTML = '<span title="关闭电子放大">' + ' <svg id="closeZoom" t="1578882639834" class="icon hide" viewBox="0 0 1000 1000" version="1.1"' + ' xmlns="http://www.w3.org/2000/svg" p-id="2227" width="24" height="24">' + ' <path' + ' d="M830.6119 441.1089c0-193.7756-157.0939-350.8641-350.8775-350.8641S128.8559 247.3333 128.8559 441.1089 285.9508 791.972 479.7344 791.972 830.6119 634.8845 830.6119 441.1089zM483.2821 710.4863c-146.7975 0-265.8187-118.9953-265.8187-265.8088S336.4847 178.8697 483.2821 178.8697s265.8197 118.9953 265.8197 265.8078S630.0796 710.4863 483.2821 710.4863zM770.6031 653.5739l-72.6417 75.9485 141.6917 160.1814 82.0737-90.0739L770.6031 653.5739zM527.5849 267.4727h-88.60655762279428v132.90489048425167H306.0690340253259v88.60292721534799h132.90933675248866v132.9038911617923h88.60655762279428V488.9794719180395h132.90933675248866v-88.60292721534799H527.5849284006089V267.4726535408993z"' + ' p-id="2228" fill="red"></path>' + ' </svg>' + '</span>';
  26303. closeZoomDOM.onclick = function () {
  26304. _this.closeZoom();
  26305. document.getElementById('closeZoom').setAttribute('class', 'icon hide');
  26306. document.getElementById('enableZoom').setAttribute('class', 'icon');
  26307. };
  26308. controsDOM.appendChild(closeZoomDOM);
  26309. }
  26310. }
  26311. /**
  26312. * 渲染footer
  26313. */
  26314. /** 根据配置匹配底部渲染 */
  26315. function matchFooterOpt() {
  26316. var result = {
  26317. footerContainer: false,
  26318. talkModule: false,
  26319. broadcastModule: false,
  26320. hdModule: false,
  26321. fullScreenModule: false
  26322. };
  26323. var template = _this.opt.template;
  26324. switch (template) {
  26325. case 'simple':
  26326. if (params.footer && params.footer instanceof Array) {
  26327. var footer = params.footer;
  26328. result = {
  26329. footerContainer: true,
  26330. talkModule: footer.indexOf('talk') !== -1,
  26331. broadcastModule: footer.indexOf('broadcast') !== -1,
  26332. hdModule: footer.indexOf('hd') !== -1,
  26333. fullScreenModule: footer.indexOf('fullScreen') !== -1
  26334. };
  26335. }
  26336. break;
  26337. case 'standard':
  26338. if (params.footer && params.footer instanceof Array) {
  26339. var footer = params.footer;
  26340. result = {
  26341. footerContainer: true,
  26342. talkModule: footer.indexOf('talk') !== -1,
  26343. broadcastModule: footer.indexOf('broadcast') !== -1,
  26344. hdModule: footer.indexOf('hd') !== -1,
  26345. fullScreenModule: footer.indexOf('fullScreen') !== -1
  26346. };
  26347. }
  26348. break;
  26349. case 'security':
  26350. break;
  26351. case 'voice':
  26352. result = {
  26353. footerContainer: true,
  26354. talkModule: true,
  26355. broadcastModule: true,
  26356. hdModule: true,
  26357. fullScreenModule: true
  26358. };
  26359. break;
  26360. }
  26361. return result;
  26362. }
  26363. /** 根据配置匹配底部渲染 */
  26364. function matchHeaderOpt() {
  26365. var result = {
  26366. headerContainer: false,
  26367. capturePictureModule: false,
  26368. saveModule: false,
  26369. zoomModule: false
  26370. };
  26371. var template = _this.opt.template;
  26372. switch (template) {
  26373. case 'simple':
  26374. if (params.header && params.header instanceof Array) {
  26375. var header = params.header;
  26376. result = {
  26377. headerContainer: true,
  26378. capturePictureModule: header.indexOf('capturePicture') !== -1,
  26379. saveModule: header.indexOf('save') !== -1,
  26380. zoomModule: header.indexOf('zoom') !== -1
  26381. };
  26382. }
  26383. break;
  26384. case 'standard':
  26385. break;
  26386. case 'security':
  26387. break;
  26388. case 'voice':
  26389. result = {
  26390. headerContainer: true,
  26391. capturePictureModule: true,
  26392. saveModule: true,
  26393. zoomModule: true
  26394. };
  26395. break;
  26396. }
  26397. return result;
  26398. }
  26399. if (matchFooterOpt().footerContainer || _this.opt.plugin.indexOf('talk') !== -1) {
  26400. var recoderCSS = _this.opt.filePath + '/npm/css/recoder.css';
  26401. var recoderJs = _this.opt.filePath + '/npm/js/recoder.js';
  26402. var recorderJs = _this.opt.filePath + '/recorder.js'; // addCss()
  26403. addCss(recoderCSS, function () { });
  26404. addJs(recoderJs, function () {
  26405. addJs(recorderJs, function () { });
  26406. }); // 对讲模块
  26407. if (_this.opt.plugin.indexOf('talk') !== -1 || matchFooterOpt().talkModule) {
  26408. function apiSuccess(data) {
  26409. console.log("data", data);
  26410. if (data.code == 200) {
  26411. var apiResult = data.data;
  26412. if (apiResult) {
  26413. // 临时将https转换为websocket
  26414. var rtcTrunk = apiResult.rtcUrl;
  26415. if (rtcTrunk.indexOf("ws") === -1) {
  26416. rtcTrunk = rtcTrunk.replace("https", "wss").replace("rtcgw", "rtcgw-ws");
  26417. }
  26418. _this.opt.rtcUrl = rtcTrunk;
  26419. _this.opt.ttsUrl = "tts://" + apiResult.ttsUrl;
  26420. var talk = "talk://" + _this.opt.deviceSerial + ":0:" + _this.opt.channelNo + ":cas.ys7.com:6500";
  26421. _this.opt.talkLink = _this.opt.ttsUrl + "/" + talk;
  26422. _this.opt.stream = apiResult.stream;
  26423. console.log("_this.opt", _this.opt); // 加载依赖
  26424. if (!_this.opt.isReliesReady) {
  26425. var adapeterJS = _this.opt.filePath + '/npm/js/adapeter.js';
  26426. var janusJS = _this.opt.filePath + '/npm/js/janus.js';
  26427. var ttsJS = _this.opt.filePath + '/npm/js/tts.js';
  26428. console.log("加载jquery.js");
  26429. addJs(adapeterJS, function () {
  26430. console.log("加载adapeter.js");
  26431. addJs(janusJS, function () {
  26432. console.log("加载janus.js");
  26433. addJs(ttsJS, function () {
  26434. console.log("加载tts.js"); // 文件加载完毕;
  26435. _this.opt.isReliesReady = true;
  26436. });
  26437. });
  26438. },()=>{
  26439. return !!window.adapter;
  26440. });
  26441. } // 创建DOM
  26442. if (!document.getElementById("audioleft")) {
  26443. var audioleft = document.createElement('div');
  26444. audioleft.style.display = 'none';
  26445. audioleft.id = 'audioleft';
  26446. document.body.appendChild(audioleft);
  26447. }
  26448. if (!document.getElementById("audioright")) {
  26449. var audioright = document.createElement('div');
  26450. audioright.style.display = 'none';
  26451. audioright.id = 'audioright';
  26452. document.body.appendChild(audioright);
  26453. }
  26454. }
  26455. }
  26456. EZUIKit.opt = _this.opt;
  26457. if(window.EZUIKit) {
  26458. window.EZUIKit.opt = _this.opt;
  26459. }
  26460. }
  26461. request(_this.opt.apiDomain, 'POST', {
  26462. accessToken: _this.opt.accessToken,
  26463. deviceSerial: _this.opt.deviceSerial,
  26464. channelNo: _this.opt.channelNo
  26465. }, '', apiSuccess);
  26466. }
  26467. if (matchFooterOpt().footerContainer) {
  26468. // 底部容器
  26469. var footerContainer = document.createElement('div');
  26470. footerContainer.setAttribute("class", 'audio-controls');
  26471. domElement.appendChild(footerContainer);
  26472. if (matchFooterOpt().hdModule || matchFooterOpt().fullScreenModule) {
  26473. // 底部右侧元素
  26474. var rightContros = document.createElement('div');
  26475. rightContros.setAttribute('class', 'contros');
  26476. footerContainer.appendChild(rightContros);
  26477. if (matchFooterOpt().hdModule) {
  26478. // 高清-标清切换
  26479. var hdDom = document.createElement('span');
  26480. hdDom.setAttribute('id', 'video-hd');
  26481. hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
  26482. hdDom.onclick = function () {
  26483. // 停止
  26484. if(_this.opt.videoLoading){
  26485. layer.msg("视频加载中,请稍后");
  26486. return false;
  26487. }else {
  26488. var stopPromise = _this.stop();
  26489. _this.opt.videoLoading = true;
  26490. stopPromise.then((data)=>{
  26491. _this.opt.videoLoading = false;
  26492. if (_this.opt.url.indexOf('.hd') === -1) {
  26493. _this.opt.url = _this.opt.url.replace('.live', '.hd.live');
  26494. hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
  26495. } else {
  26496. _this.opt.url = _this.opt.url.replace('.hd.live', '.live');
  26497. hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
  26498. }
  26499. _this.play(_this.opt.url);
  26500. })
  26501. .catch((error)=>{
  26502. console.log("error",error);
  26503. });
  26504. }
  26505. //iframe.src = domain +"/ezopen/h5/iframe?url=" + _this.opt.url.replace('.hd.live', '.live') + "&autoplay=1&audio=" + _this.opt.audio + "&accessToken=" + _this.opt.accessToken + "&templete=" + 0;
  26506. };
  26507. rightContros.appendChild(hdDom);
  26508. }
  26509. if (matchFooterOpt().fullScreenModule) {
  26510. // 声音控制
  26511. var openSoundDOM = document.createElement('span');
  26512. openSoundDOM.setAttribute('class', 'hide');
  26513. openSoundDOM.setAttribute('id', 'ezuikit-open-sound');
  26514. openSoundDOM.setAttribute('title', '打开声音');
  26515. openSoundDOM.setAttribute('style', 'vertical-align: top;');
  26516. openSoundDOM.innerHTML = '<svg t="1590476263239" class="icon" viewBox="0 0 1178 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2273" width="16" height="16"><path d="M665.6 51.2 665.6 51.2c-10.24-30.72-40.96-51.2-71.68-51.2-5.12 0-15.36 0-20.48 5.12l0 0L358.4 153.6 51.2 209.92l0 0C20.48 220.16 0 250.88 0 281.6 0 286.72 0 291.84 0 307.2l0 0 0 409.6 0 0c0 15.36 0 20.48 0 25.6 0 30.72 20.48 61.44 51.2 71.68l0 0L358.4 870.4l97.28 71.68 107.52 76.8 0 0c5.12 5.12 15.36 5.12 25.6 5.12 40.96 0 76.8-35.84 76.8-76.8 0-10.24 0-10.24 0-25.6l0 0L665.6 51.2zM563.2 870.4l-153.6-102.4-307.2-51.2L102.4 307.2l307.2-51.2 153.6-102.4L563.2 870.4z" p-id="2274" fill="#FF0000"></path><path d="M1049.6 537.6l112.64-112.64c20.48-20.48 20.48-56.32 0-76.8-20.48-20.48-56.32-20.48-76.8 0L972.8 460.8l-112.64-112.64c0 0 0 0 0 0-20.48-20.48-56.32-20.48-76.8 0 0 0 0 0 0 0-20.48 20.48-20.48 56.32 0 76.8l112.64 112.64-112.64 112.64c-20.48 20.48-20.48 56.32 0 76.8 20.48 20.48 56.32 20.48 76.8 0L972.8 614.4l112.64 112.64c20.48 20.48 56.32 20.48 76.8 0s20.48-56.32 0-76.8L1049.6 537.6z" p-id="2275" fill="#FF0000"></path></svg>';
  26517. openSoundDOM.onclick = function () {
  26518. _this.openSound(0);
  26519. openSoundDOM.setAttribute('class', 'hide');
  26520. closeSoundDOM.setAttribute('class', '');
  26521. }; // 声音控制
  26522. var closeSoundDOM = document.createElement('span');
  26523. openSoundDOM.setAttribute('id', 'ezuikit-close-sound');
  26524. closeSoundDOM.setAttribute('class', 'hide');
  26525. closeSoundDOM.setAttribute('title', '关闭声音');
  26526. closeSoundDOM.setAttribute('style', 'vertical-align: top;');
  26527. closeSoundDOM.innerHTML = '<svg t="1590414410633" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="20545" width="16" height="16"><path d="M840.533333 98.133333c-17.066667-17.066667-42.666667-17.066667-59.733333 0-17.066667 17.066667-17.066667 42.666667 0 59.733334C883.2 256 938.666667 392.533333 938.666667 533.333333c0 140.8-55.466667 277.333333-157.866667 375.466667-17.066667 17.066667-17.066667 42.666667 0 59.733333 8.533333 8.533333 21.333333 12.8 29.866667 12.8 8.533333 0 21.333333-4.266667 29.866666-12.8 115.2-110.933333 183.466667-268.8 183.466667-435.2 0-166.4-68.266667-324.266667-183.466667-435.2zM571.733333 12.8c-17.066667-8.533333-34.133333-4.266667-46.933333 8.533333L281.6 256H42.666667c-25.6 0-42.666667 17.066667-42.666667 42.666667v426.666666c0 25.6 17.066667 42.666667 42.666667 42.666667h238.933333l243.2 234.666667c8.533333 8.533333 17.066667 12.8 29.866667 12.8 4.266667 0 12.8 0 17.066666-4.266667 17.066667-8.533333 25.6-21.333333 25.6-38.4V51.2c0-17.066667-8.533333-34.133333-25.6-38.4zM512 870.4l-183.466667-179.2c-8.533333-4.266667-17.066667-8.533333-29.866666-8.533333H85.333333V341.333333h213.333334c12.8 0 21.333333-4.266667 29.866666-12.8L512 153.6v716.8z" p-id="20546" fill="#ffffff"></path><path d="M759.466667 349.866667c-12.8-21.333333-38.4-25.6-59.733334-8.533334-21.333333 12.8-25.6 38.4-8.533333 59.733334 21.333333 29.866667 34.133333 76.8 34.133333 123.733333 0 46.933333-12.8 93.866667-34.133333 123.733333-12.8 21.333333-8.533333 46.933333 8.533333 59.733334 8.533333 4.266667 17.066667 8.533333 25.6 8.533333 12.8 0 25.6-4.266667 34.133334-17.066667 34.133333-46.933333 51.2-106.666667 51.2-174.933333 0-68.266667-17.066667-128-51.2-174.933333z" p-id="20547" fill="#ffffff"></path></svg>';
  26528. closeSoundDOM.onclick = function () {
  26529. _this.closeSound(0);
  26530. openSoundDOM.setAttribute('class', '');
  26531. closeSoundDOM.setAttribute('class', 'hide');
  26532. };
  26533. rightContros.appendChild(openSoundDOM);
  26534. rightContros.appendChild(closeSoundDOM);
  26535. } // 根据当前音频配置展示
  26536. if (_this.opt.audio == 1) {
  26537. closeSoundDOM.setAttribute('class', '');
  26538. } else {
  26539. openSoundDOM.setAttribute('class', '');
  26540. _this.closeSound(0);
  26541. }
  26542. if (matchFooterOpt().fullScreenModule) {
  26543. // 全屏控制
  26544. var fullScreenDOM = document.createElement('span');
  26545. fullScreenDOM.setAttribute('title', '全屏');
  26546. fullScreenDOM.setAttribute('style', 'vertical-align: top;');
  26547. fullScreenDOM.innerHTML = '<svg id="fullScreen" t="1578020167938" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5035" width="16" height="16"> <path d="M348.373333 625.706667l-128 128-64 64v-128a33.28 33.28 0 0 0-35.413333-35.413334A33.493333 33.493333 0 0 0 85.333333 689.706667v213.333333A33.706667 33.706667 0 0 0 120.96 938.666667h213.333333a35.626667 35.626667 0 0 0 0-71.04h-128l64-64 128-128a35.2 35.2 0 0 0-49.92-49.92zM206.293333 156.373333h128a33.28 33.28 0 0 0 35.413334-35.413333A33.493333 33.493333 0 0 0 334.293333 85.333333H113.706667c-7.04 0-14.08 7.04-21.333334 14.293334a26.026667 26.026667 0 0 0-7.04 21.333333v213.333333a33.493333 33.493333 0 0 0 35.626667 35.413334 33.28 33.28 0 0 0 35.413333-35.413334v-128l192 192a35.2 35.2 0 0 0 49.92-49.92zM903.04 85.333333h-213.333333a33.493333 33.493333 0 0 0-35.413334 35.626667 33.28 33.28 0 0 0 35.413334 35.413333h128l-64 64-128 128a35.2 35.2 0 0 0 49.92 49.92l128-128 64-64v128a35.626667 35.626667 0 0 0 71.04 0v-213.333333A33.706667 33.706667 0 0 0 903.04 85.333333zM903.04 654.293333a33.28 33.28 0 0 0-35.413333 35.413334v128l-64-64-128-128a35.2 35.2 0 0 0-49.92 49.92l128 128 64 64h-128a35.626667 35.626667 0 0 0 0 71.04h213.333333A33.706667 33.706667 0 0 0 938.666667 903.04v-213.333333a33.493333 33.493333 0 0 0-35.626667-35.413334z" p-id="5036" fill="#ffffff"></path></svg>';
  26548. fullScreenDOM.onclick = function () {
  26549. _this.fullScreen();
  26550. };
  26551. rightContros.appendChild(fullScreenDOM);
  26552. }
  26553. }
  26554. if (matchFooterOpt().talkModule) {
  26555. // 对讲
  26556. var startTalkDOM = document.createElement('div');
  26557. var stopTalkDOM = document.createElement('div');
  26558. startTalkDOM.setAttribute("class", "ptp-talk off");
  26559. startTalkDOM.innerHTML = '<span title="对讲">' + '<svg t="1581930496966" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"' + ' p-id="1641" width="16" height="16">' + ' <path' + ' d="M715.648 647.872c-30.208-22.336-61.568 39.36-100.992 77.44-39.36 38.08-34.112 31.488-123.392-17.088S311.488 540.224 280 491.648C248.448 443.072 265.472 424.704 265.472 424.704s78.72-62.976 97.152-81.344c18.368-18.368 13.12-30.208 13.12-30.208l-128.64-190.144c-23.616-5.184-64.32 5.12-128.576 57.6C54.208 233.088 30.592 353.856 151.296 575.68c120.768 221.824 347.84 330.752 485.568 374.08 137.856 43.328 228.416-61.696 249.408-103.68 21.056-41.984 13.12-85.312 13.12-85.312S745.856 670.208 715.648 647.872z"' + ' p-id="1642" fill="#ffffff"></path>' + ' <path' + ' d="M715.328 64C580.992 64 472.192 172.864 472.192 307.2s108.8 243.2 243.136 243.2 243.2-108.864 243.2-243.2S849.6 64 715.328 64zM715.328 461.056c-84.992 0-153.856-68.864-153.856-153.856s68.864-153.856 153.856-153.856 153.856 68.928 153.856 153.856S800.32 461.056 715.328 461.056z"' + ' p-id="1643" fill="#ffffff"></path>' + ' <path' + ' d="M777.472 277.376c-18.176 0-32.96-14.784-32.96-33.024 0-8.448 3.136-16.064 8.32-21.888-11.52-5.12-24.128-8-37.568-8-51.2 0-92.672 41.472-92.672 92.736s41.472 92.736 92.672 92.736S808.064 358.4 808.064 307.2c0-13.696-3.072-26.688-8.384-38.4C793.728 274.112 786.048 277.376 777.472 277.376zM715.328 340.928c-18.624 0-33.664-15.104-33.664-33.728 0-18.624 15.04-33.728 33.664-33.728 18.688 0 33.728 15.104 33.728 33.728C749.056 325.824 734.016 340.928 715.328 340.928z"' + ' p-id="1644" fill="#ffffff"></path>' + ' </svg>' + ' </span>' + ' <span>开启对讲</span>';
  26560. startTalkDOM.onclick = function () {
  26561. console.log("EZUIKit.state.countTimer", EZUIKit.state.countTimer);
  26562. if (EZUIKit.state.countTimer) {
  26563. window.layer.msg("语音设备正忙,请稍后重试");
  26564. return false;
  26565. }
  26566. countTime('add', 0);
  26567. console.log("开始对讲,关闭声音");
  26568. _this.closeSound(0);
  26569. console.log(_this.opt);
  26570. _this.startTalk();
  26571. this.setAttribute("class", "ptp-talk off hide");
  26572. stopTalkDOM.setAttribute("class", "ptp-talk on");
  26573. };
  26574. stopTalkDOM.setAttribute("class", "ptp-talk on hide");
  26575. stopTalkDOM.innerHTML = '<span title="对讲">' + ' <svg t="1581930496966" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"' + ' p-id="1641" width="16" height="16">' + ' <path' + ' d="M715.648 647.872c-30.208-22.336-61.568 39.36-100.992 77.44-39.36 38.08-34.112 31.488-123.392-17.088S311.488 540.224 280 491.648C248.448 443.072 265.472 424.704 265.472 424.704s78.72-62.976 97.152-81.344c18.368-18.368 13.12-30.208 13.12-30.208l-128.64-190.144c-23.616-5.184-64.32 5.12-128.576 57.6C54.208 233.088 30.592 353.856 151.296 575.68c120.768 221.824 347.84 330.752 485.568 374.08 137.856 43.328 228.416-61.696 249.408-103.68 21.056-41.984 13.12-85.312 13.12-85.312S745.856 670.208 715.648 647.872z"' + ' p-id="1642" fill="#ff0000"></path>' + ' <path' + ' d="M715.328 64C580.992 64 472.192 172.864 472.192 307.2s108.8 243.2 243.136 243.2 243.2-108.864 243.2-243.2S849.6 64 715.328 64zM715.328 461.056c-84.992 0-153.856-68.864-153.856-153.856s68.864-153.856 153.856-153.856 153.856 68.928 153.856 153.856S800.32 461.056 715.328 461.056z"' + ' p-id="1643" fill="#ff0000"></path>' + ' <path' + ' d="M777.472 277.376c-18.176 0-32.96-14.784-32.96-33.024 0-8.448 3.136-16.064 8.32-21.888-11.52-5.12-24.128-8-37.568-8-51.2 0-92.672 41.472-92.672 92.736s41.472 92.736 92.672 92.736S808.064 358.4 808.064 307.2c0-13.696-3.072-26.688-8.384-38.4C793.728 274.112 786.048 277.376 777.472 277.376zM715.328 340.928c-18.624 0-33.664-15.104-33.664-33.728 0-18.624 15.04-33.728 33.664-33.728 18.688 0 33.728 15.104 33.728 33.728C749.056 325.824 734.016 340.928 715.328 340.928z"' + ' p-id="1644" fill="#ff0000"></path>' + ' </svg>' + ' </span>' + '<span>关闭对讲</span>';
  26576. stopTalkDOM.onclick = function () {
  26577. console.log(_this.opt);
  26578. _this.stopTalk();
  26579. countTime('destory', 0);
  26580. _this.openSound(0);
  26581. this.setAttribute("class", "ptp-talk on hide");
  26582. startTalkDOM.setAttribute("class", "ptp-talk off");
  26583. };
  26584. footerContainer.appendChild(startTalkDOM);
  26585. footerContainer.appendChild(stopTalkDOM);
  26586. }
  26587. if (matchFooterOpt().broadcastModule) {
  26588. var startBroadcastDOM = document.createElement('div');
  26589. var stopBroadcastDOM = document.createElement('div');
  26590. startBroadcastDOM.setAttribute("class", 'broadcast off');
  26591. stopBroadcastDOM.setAttribute("class", "broadcast on hide");
  26592. startBroadcastDOM.innerHTML = ' <span title="语音播报">' + ' <svg t="1583561695846" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"' + ' p-id="1126" width="16" height="16">' + ' <path' + ' d="M513.82044445 964.38044445c-8.192 0-15.47377778-2.73066667-21.84533334-8.192 0 0-46.42133333-41.87022222-99.21422222-86.47111112-89.20177778-73.728-117.41866667-88.29155555-123.79022222-90.112H35.04355555c-14.56355555 0-26.39644445-11.83288889-26.39644444-27.30666666V271.70133333c0-14.56355555 11.83288889-27.30666667 26.39644444-27.30666666H246.21511111c7.28177778-2.73066667 37.31911111-15.47377778 137.44355556-91.02222222 58.25422222-43.69066667 111.04711111-86.47111111 111.04711111-86.47111112 5.46133333-4.55111111 12.74311111-7.28177778 20.02488889-7.28177778 4.55111111 0 10.01244445 0.91022222 14.56355555 3.6408889 10.92266667 5.46133333 18.20444445 17.29422222 18.20444445 30.03733333v837.40444444c0 12.74311111-7.28177778 25.48622222-19.11466667 30.94755556-5.46133333 1.82044445-10.01244445 2.73066667-14.56355555 2.73066667zM270.79111111 724.992c19.11466667 0 48.24177778 8.192 167.48088889 106.496 16.384 13.65333333 33.67822222 28.21688889 51.88266667 43.69066667l5.46133333 4.55111111V139.71911111l-5.46133333 3.64088889c-22.75555555 17.29422222-44.60088889 34.58844445-65.536 50.06222222C293.54666667 291.72622222 264.41955555 299.008 245.30488889 299.008H82.37511111c-20.02488889 0-21.84533333 12.74311111-21.84533333 26.39644445V694.04444445c0 23.66577778 6.37155555 30.03733333 28.21688889 30.03733333h180.224l1.82044444 0.91022222z m520.64711111 162.01955555c-14.56355555 0-26.39644445-11.83288889-26.39644444-27.30666666 0-11.83288889 8.192-20.02488889 16.384-24.576 112.86755555-67.35644445 182.04444445-191.14666667 182.04444444-324.03911111 0-132.89244445-70.08711111-256.68266667-182.04444444-324.03911111-10.01244445-5.46133333-15.47377778-14.56355555-15.47377778-24.576 0-14.56355555 11.83288889-27.30666667 26.39644445-27.30666667 5.46133333 0 10.01244445 1.82044445 16.384 5.46133333 128.34133333 76.45866667 207.53066667 218.45333333 207.53066666 369.55022222 0 152.00711111-80.09955555 293.09155555-208.44088889 369.55022223-6.37155555 5.46133333-10.92266667 7.28177778-16.384 7.28177777z m-90.112-152.91733333c-14.56355555 0-26.39644445-11.83288889-26.39644444-27.30666667 0-10.01244445 4.55111111-18.20444445 12.74311111-23.66577777 61.89511111-34.58844445 100.12444445-100.12444445 100.12444444-171.12177778 0-70.08711111-37.31911111-134.71288889-96.48355555-170.21155555-8.192-4.55111111-12.74311111-13.65333333-12.74311111-23.66577778 0-14.56355555 11.83288889-27.30666667 26.39644444-27.30666667 4.55111111 0 11.83288889 2.73066667 15.47377778 4.55111111 74.63822222 44.60088889 121.96977778 127.43111111 121.96977778 215.72266667 0 90.112-48.24177778 173.85244445-125.61066667 218.45333333-1.82044445 0-9.10222222 4.55111111-15.47377778 4.55111111z"' + ' fill="#ffffff" p-id="1127"></path>' + ' </svg>' + '</span>' + '<span>语音播报</span>';
  26593. startBroadcastDOM.onclick = function () {
  26594. this.setAttribute("class", "broadcast off hide");
  26595. stopBroadcastDOM.setAttribute("class", "broadcast on");
  26596. };
  26597. stopBroadcastDOM.innerHTML = '<div class="pop-hover">' + ' <div class="pop-hover-content">' + ' <div class="vioce-list" id="voice-list">' + ' <ul class="voice-list-ul">' + ' </ul>' + ' <div id="voice-list-end"></div>' + ' </div>' + ' <div id="voice-custom" style="text-align: center;">自定义语音</div>' + ' </div>' + '</div>' + '<span title="语音播报">' + ' <svg t="1583561695846" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"' + ' p-id="1126" width="16" height="16">' + ' <path' + ' d="M513.82044445 964.38044445c-8.192 0-15.47377778-2.73066667-21.84533334-8.192 0 0-46.42133333-41.87022222-99.21422222-86.47111112-89.20177778-73.728-117.41866667-88.29155555-123.79022222-90.112H35.04355555c-14.56355555 0-26.39644445-11.83288889-26.39644444-27.30666666V271.70133333c0-14.56355555 11.83288889-27.30666667 26.39644444-27.30666666H246.21511111c7.28177778-2.73066667 37.31911111-15.47377778 137.44355556-91.02222222 58.25422222-43.69066667 111.04711111-86.47111111 111.04711111-86.47111112 5.46133333-4.55111111 12.74311111-7.28177778 20.02488889-7.28177778 4.55111111 0 10.01244445 0.91022222 14.56355555 3.6408889 10.92266667 5.46133333 18.20444445 17.29422222 18.20444445 30.03733333v837.40444444c0 12.74311111-7.28177778 25.48622222-19.11466667 30.94755556-5.46133333 1.82044445-10.01244445 2.73066667-14.56355555 2.73066667zM270.79111111 724.992c19.11466667 0 48.24177778 8.192 167.48088889 106.496 16.384 13.65333333 33.67822222 28.21688889 51.88266667 43.69066667l5.46133333 4.55111111V139.71911111l-5.46133333 3.64088889c-22.75555555 17.29422222-44.60088889 34.58844445-65.536 50.06222222C293.54666667 291.72622222 264.41955555 299.008 245.30488889 299.008H82.37511111c-20.02488889 0-21.84533333 12.74311111-21.84533333 26.39644445V694.04444445c0 23.66577778 6.37155555 30.03733333 28.21688889 30.03733333h180.224l1.82044444 0.91022222z m520.64711111 162.01955555c-14.56355555 0-26.39644445-11.83288889-26.39644444-27.30666666 0-11.83288889 8.192-20.02488889 16.384-24.576 112.86755555-67.35644445 182.04444445-191.14666667 182.04444444-324.03911111 0-132.89244445-70.08711111-256.68266667-182.04444444-324.03911111-10.01244445-5.46133333-15.47377778-14.56355555-15.47377778-24.576 0-14.56355555 11.83288889-27.30666667 26.39644445-27.30666667 5.46133333 0 10.01244445 1.82044445 16.384 5.46133333 128.34133333 76.45866667 207.53066667 218.45333333 207.53066666 369.55022222 0 152.00711111-80.09955555 293.09155555-208.44088889 369.55022223-6.37155555 5.46133333-10.92266667 7.28177778-16.384 7.28177777z m-90.112-152.91733333c-14.56355555 0-26.39644445-11.83288889-26.39644444-27.30666667 0-10.01244445 4.55111111-18.20444445 12.74311111-23.66577777 61.89511111-34.58844445 100.12444445-100.12444445 100.12444444-171.12177778 0-70.08711111-37.31911111-134.71288889-96.48355555-170.21155555-8.192-4.55111111-12.74311111-13.65333333-12.74311111-23.66577778 0-14.56355555 11.83288889-27.30666667 26.39644444-27.30666667 4.55111111 0 11.83288889 2.73066667 15.47377778 4.55111111 74.63822222 44.60088889 121.96977778 127.43111111 121.96977778 215.72266667 0 90.112-48.24177778 173.85244445-125.61066667 218.45333333-1.82044445 0-9.10222222 4.55111111-15.47377778 4.55111111z"' + ' fill="#ff0000" p-id="1127"></path>' + ' </svg>' + '</span>' + '<span>语音播报</span>'; // //自定义语音唤起
  26598. // document.getElementById("voice-custom").onclick = function(){
  26599. // console.log("显示自定义语音");
  26600. // }
  26601. stopBroadcastDOM.onclick = function () {
  26602. this.setAttribute("class", "broadcast on hide");
  26603. startBroadcastDOM.setAttribute("class", "broadcast off");
  26604. };
  26605. footerContainer.appendChild(startBroadcastDOM);
  26606. footerContainer.appendChild(stopBroadcastDOM); // 召唤自定义语言
  26607. document.getElementById("voice-custom").onclick = function () {
  26608. console.log("显示自定义语音");
  26609. startSpeakDOM.setAttribute('class', 'speak off');
  26610. }; // 获取语音列表
  26611. fetchVoiceList(0);
  26612. function fetchVoiceList(page) {
  26613. function apiSuccess(data) {
  26614. console.log("data", data);
  26615. if (data.code == 200) {
  26616. randerVoliceList(data.data);
  26617. EZUIKit.state.page = data.page.page; // 如果用户语音列表为空
  26618. if (page == 0 && data.data.length == 0 && !EZUIKit.state.fetchDefaultList) {
  26619. // 获取用户语音为空
  26620. EZUIKit.state.fetchDefaultList = true;
  26621. fetchVoiceList(0);
  26622. }
  26623. }
  26624. }
  26625. request( domain + '/api/lapp/voice/query', 'POST', {
  26626. accessToken: _this.opt.accessToken,
  26627. pageStart: page,
  26628. pageSize: EZUIKit.state.pageSize,
  26629. default: EZUIKit.state.fetchDefaultList ? 'true' : 'false'
  26630. }, '', apiSuccess);
  26631. }
  26632. function randerVoliceList(data) {
  26633. console.log("renderVoliceList", data);
  26634. if (data && data.length > 0) {
  26635. for (var i = 0; i < data.length; i++) {
  26636. var voiceItem = document.createElement('li');
  26637. voiceItem.innerHTML = "<li class='voice-item' id='voice-item-" + i + "' data-time=" + (data[i]["duration"] || 20) + " data-url=" + data[i]["fileUrl"] + ">" + (data[i]["voiceName"].length > 10 ? data[i]["voiceName"].substr(0, 10) + "..." : data[i]["voiceName"]) + "</li>";
  26638. document.getElementsByClassName('voice-list-ul')[0].append(voiceItem); // "<li class='voice-item' id='voice-item-" + i + "' data-time=" + (data[i]["duration"] || 20) + " data-url=" + data[i]["fileUrl"] + ">" + (data[i]["voiceName"].length > 10 ? (data[i]["voiceName"].substr(0, 10) + "...") : data[i]["voiceName"]) + "</li>";
  26639. // $("#voice-list ul").append("<li class='voice-item' id='voice-item-" + i + "' data-time=" + (data[i]["duration"] || 20) + " data-url=" + data[i]["fileUrl"] + ">" + (data[i]["voiceName"].length > 10 ? (data[i]["voiceName"].substr(0, 10) + "...") : data[i]["voiceName"]) + "</li>");
  26640. voiceItem.onclick = function (e) {
  26641. console.log("点击元素", e.target, e.target.dataset.url);
  26642. var voiceUrl = e.target.dataset.url;
  26643. var time = e.target.dataset.time;
  26644. playListOfVoice(voiceUrl, time);
  26645. };
  26646. }
  26647. if (data.length === EZUIKit.state.pageSize) {
  26648. document.getElementById('voice-list-end').innerHTML = "向下滚动加载更多";
  26649. } else {
  26650. document.getElementById('voice-list-end').innerHTML = "没有更多数据了";
  26651. }
  26652. }
  26653. }
  26654. function playListOfVoice(voiceUrl, time) {
  26655. console.log("播放语音", voiceUrl, time); // decoder && decoder.closeSound(0);
  26656. function apiSuccess(data) {
  26657. console.log("data.data", data.data);
  26658. if (data.code == 200) {
  26659. // $("#startBroadcast").show();
  26660. // $("#stopBroadcast").hide();
  26661. countTime('sub', parseInt(time));
  26662. } else if (data.code == "10001") {
  26663. window.layer.msg("未找到当前语音");
  26664. } else {
  26665. window.layer.msg(data.msg || '发送失败,请稍后再试');
  26666. } // padding = false;
  26667. }
  26668. request( domain + '/api/lapp/voice/send', 'POST', {
  26669. accessToken: _this.opt.accessToken,
  26670. deviceSerial: _this.opt.deviceSerial,
  26671. channelNo: _this.opt.channelNo,
  26672. fileUrl: voiceUrl
  26673. }, '', apiSuccess);
  26674. } // 自定义语音
  26675. // 对讲
  26676. var startSpeakDOM = document.createElement('div');
  26677. var stopSpeakDOM = document.createElement('div');
  26678. startSpeakDOM.setAttribute('class', 'speak off hide');
  26679. stopSpeakDOM.setAttribute('class', 'speak on hide');
  26680. startSpeakDOM.setAttribute('id', 'startSpeak');
  26681. stopSpeakDOM.setAttribute('id', 'stopSpeak');
  26682. startSpeakDOM.innerHTML = '<span title="按住说话">' + ' <svg t="1581994757678" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"' + ' p-id="1639" width="16" height="16">' + ' <path' + ' d="M757.059829 393.846154v-52.512821h262.564103v52.512821H757.059829z m-420.102564 481.367521v96.273504h175.042735a8.752137 8.752137 0 0 1 8.752137 8.752137v35.008547a8.752137 8.752137 0 0 1-8.752137 8.752137H109.401709a8.752137 8.752137 0 0 1-8.752136-8.752137v-35.008547a8.752137 8.752137 0 0 1 8.752136-8.752137h175.042735v-96.273504C129.767932 875.213675 4.376068 749.821812 4.376068 595.145299V463.863248a26.25641 26.25641 0 1 1 52.512821 0v113.777778c0 140.174222 113.637744 253.811966 253.811966 253.811965s253.811966-113.637744 253.811966-253.811965V463.863248a26.25641 26.25641 0 1 1 52.51282 0v131.282051c0 154.676513-125.391863 280.068376-280.068376 280.068376z m-26.25641-96.273504c-111.178393 0-201.299145-90.120752-201.299146-201.299145V201.299145C109.401709 90.120752 199.522462 0 310.700855 0s201.299145 90.120752 201.299145 201.299145v376.341881c0 111.178393-90.120752 201.299145-201.299145 201.299145z m691.418803-280.068376H757.059829v-52.512821h245.059829v52.512821z m-17.504273 105.025641H757.059829v-52.512821h227.555556v52.512821z m-17.504274 105.025641H757.059829v-52.512821h210.051282v52.512821z m-8.752137 105.025641H757.059829v-52.512821h201.299145v52.512821z m-17.504273 105.025641H757.059829v-52.512821h183.794872v52.512821z m-26.25641 105.025641H757.059829v-52.512821h157.538462v52.512821z"' + ' p-id="1640" fill="#ffffff"></path>' + ' </svg>' + '</span>' + '<span>按住说话</span>';
  26683. stopSpeakDOM.innerHTML = '<span title="按住说话">' + '<svg t="1581994757678" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"' + ' p-id="1639" width="16" height="16">' + ' <path' + ' d="M757.059829 393.846154v-52.512821h262.564103v52.512821H757.059829z m-420.102564 481.367521v96.273504h175.042735a8.752137 8.752137 0 0 1 8.752137 8.752137v35.008547a8.752137 8.752137 0 0 1-8.752137 8.752137H109.401709a8.752137 8.752137 0 0 1-8.752136-8.752137v-35.008547a8.752137 8.752137 0 0 1 8.752136-8.752137h175.042735v-96.273504C129.767932 875.213675 4.376068 749.821812 4.376068 595.145299V463.863248a26.25641 26.25641 0 1 1 52.512821 0v113.777778c0 140.174222 113.637744 253.811966 253.811966 253.811965s253.811966-113.637744 253.811966-253.811965V463.863248a26.25641 26.25641 0 1 1 52.51282 0v131.282051c0 154.676513-125.391863 280.068376-280.068376 280.068376z m-26.25641-96.273504c-111.178393 0-201.299145-90.120752-201.299146-201.299145V201.299145C109.401709 90.120752 199.522462 0 310.700855 0s201.299145 90.120752 201.299145 201.299145v376.341881c0 111.178393-90.120752 201.299145-201.299145 201.299145z m691.418803-280.068376H757.059829v-52.512821h245.059829v52.512821z m-17.504273 105.025641H757.059829v-52.512821h227.555556v52.512821z m-17.504274 105.025641H757.059829v-52.512821h210.051282v52.512821z m-8.752137 105.025641H757.059829v-52.512821h201.299145v52.512821z m-17.504273 105.025641H757.059829v-52.512821h183.794872v52.512821z m-26.25641 105.025641H757.059829v-52.512821h157.538462v52.512821z"' + ' p-id="1640" fill="#ff0000"></path>' + '</svg>' + '</span>' + '<span>松开发送</span>';
  26684. footerContainer.appendChild(startSpeakDOM);
  26685. footerContainer.appendChild(stopSpeakDOM);
  26686. document.getElementById("voice-list").onscroll = function (e) {
  26687. var sum = this.scrollHeight;
  26688. console.log("sum", sum, this.scrollTop, document.getElementById("voice-list").clientHeight);
  26689. if (sum <= this.scrollTop + this.clientHeight) {
  26690. console.log("拖动到底,执行加载", EZUIKit.state.page);
  26691. fetchVoiceList(++EZUIKit.state.page);
  26692. }
  26693. }; // $("#voice-list").unbind("scroll").bind("scroll", function (e) {
  26694. // // console.log("e",e,this.scrollHeight, $(this).scrollTop() + $(this).height())
  26695. // var sum = this.scrollHeight;
  26696. // if (sum <= $(this).scrollTop() + $(this).height()) {
  26697. // console.log("拖动到底,执行加载", page);
  26698. // fetchVoiceList(++page);
  26699. // }
  26700. // loading = false;
  26701. // });
  26702. // time-area
  26703. var timeAreaDOM = document.createElement('div');
  26704. timeAreaDOM.setAttribute('class', 'time-area');
  26705. timeAreaDOM.setAttribute('id', 'time-area');
  26706. timeAreaDOM.innerHTML = '00:00';
  26707. footerContainer.appendChild(timeAreaDOM); // 按住说话
  26708. var recorder;
  26709. document.getElementById('startSpeak').onmousedown = function () {
  26710. if (EZUIKit.state.countTimer) {
  26711. window.layer.msg("语音设备正忙,请稍后重试");
  26712. return false;
  26713. }
  26714. console.log("按住说话");
  26715. startSpeakDOM.setAttribute('class', 'speak off hide');
  26716. stopSpeakDOM.setAttribute('class', 'speak on'); // console.log("startRecording",startRecording);
  26717. // startRecording();
  26718. voiceInit();
  26719. countTime('add', 0);
  26720. setTimeout(function () {
  26721. EZUIKit.state.recodeTime = 0;
  26722. startRecording();
  26723. }, 1000);
  26724. if (EZUIKit.state.recodeTimer) {
  26725. // 先清空计数器
  26726. clearInterval(EZUIKit.state.recodeTimer);
  26727. }
  26728. EZUIKit.state.recodeTimer = setInterval(function () {
  26729. if (EZUIKit.state.recodeTime >= 59) {
  26730. _this.stopTalk();
  26731. countTime('destory', 0);
  26732. this.setAttribute("class", "ptp-talk on hide");
  26733. startTalkDOM.setAttribute("class", "ptp-talk off");
  26734. window.layer.msg("不超过1分钟");
  26735. } else {
  26736. EZUIKit.state.recodeTime = EZUIKit.state.recodeTime + 1;
  26737. }
  26738. }, 1000);
  26739. /** 录音控制 */
  26740. var audio_context;
  26741. function startUserMedia(stream) {
  26742. var input = audio_context.createMediaStreamSource(stream);
  26743. recorder = new window.Recorder(input);
  26744. }
  26745. function startRecording() {
  26746. recorder && recorder.record();
  26747. }
  26748. function voiceInit() {
  26749. console.log("run init");
  26750. try {
  26751. // webkit shim
  26752. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  26753. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
  26754. window.URL = window.URL || window.webkitURL;
  26755. audio_context = new AudioContext();
  26756. console.log('Audio context set up.');
  26757. console.log('navigator.getUserMedia ' + (navigator.getUserMedia ? 'available.' : 'not present!'));
  26758. } catch (e) {
  26759. console.log("err", e);
  26760. window.layer.msg('No web audio support in this browser!');
  26761. }
  26762. navigator.getUserMedia({
  26763. audio: true
  26764. }, startUserMedia, function (e) {
  26765. console.log('No live audio input: ' + e);
  26766. });
  26767. }
  26768. }; // 松开发送
  26769. document.getElementById('stopSpeak').onmouseup = function () {
  26770. console.log("松开发送");
  26771. stopSpeakDOM.setAttribute('class', 'speak on hide');
  26772. stopSpeakFun();
  26773. function stopSpeakFun() {
  26774. countTime('destory', 0);
  26775. if (EZUIKit.state.recodeTime < 1) {
  26776. window.layer.msg("说话时间过短");
  26777. clearInterval(EZUIKit.state.recodeTimer);
  26778. return false;
  26779. }
  26780. clearInterval(EZUIKit.state.recodeTimer);
  26781. wavUpload();
  26782. }
  26783. function wavUpload() {
  26784. try {
  26785. recorder && recorder.stop(); // createAudioDom();
  26786. recorder && recorder.exportWAV(function (wav_file) {
  26787. console.log("wav_file", wav_file);
  26788. if (wav_file.size < 1000) {
  26789. window.layer.msg("录音失败,请重试"); // recodeTime = 0;
  26790. EZUIKit.state.recodeTime = 0;
  26791. return false;
  26792. } // 测试
  26793. countTime('sub', EZUIKit.state.recodeTime + 2); // 延时
  26794. var formdata = new FormData(); // form 表单 {key:value}
  26795. formdata.append("voiceFile", wav_file); // form input type="file"
  26796. formdata.append("accessToken", _this.opt.accessToken);
  26797. formdata.append("deviceSerial", _this.opt.deviceSerial);
  26798. formdata.append("channelNo", _this.opt.channelNo); // padding = true;
  26799. function apiSuccess(data) {
  26800. console.log("data.data", data.data);
  26801. if (data.code == 200) {
  26802. // $("#startBroadcast").show();
  26803. // $("#stopBroadcast").hide();
  26804. countTime('sub', EZUIKit.state.recodeTime + 2);
  26805. } else if (data.code == "10001") {
  26806. window.layer.msg("未找到当前语音");
  26807. } else {
  26808. window.layer.msg(data.msg || '发送失败,请稍后再试');
  26809. } // padding = false;
  26810. }
  26811. function apiError(err) {
  26812. console.log("err", err);
  26813. }
  26814. request(domain + '/api/lapp/voice/sendonce', 'POST', {
  26815. voiceFile: wav_file,
  26816. accessToken: _this.opt.accessToken,
  26817. deviceSerial: _this.opt.deviceSerial,
  26818. channelNo: _this.opt.channelNo
  26819. }, '', apiSuccess, apiError);
  26820. });
  26821. recorder && recorder.clear();
  26822. } catch (err) {
  26823. console.log(err);
  26824. }
  26825. }
  26826. };
  26827. }
  26828. /* 时间计数 */
  26829. function countTime(type, start) {
  26830. clearInterval(EZUIKit.state.countTimer);
  26831. if (type === 'add') {
  26832. var i = start;
  26833. EZUIKit.state.countTimer = setInterval(function () {
  26834. ++i;
  26835. document.getElementById("time-area").innerHTML = formatSeconds(i);
  26836. }, 1000);
  26837. } else if (type === 'sub') {
  26838. var i = start;
  26839. EZUIKit.state.countTimer = setInterval(function () {
  26840. if (i > 0) {
  26841. i--;
  26842. document.getElementById("time-area").innerHTML = formatSeconds(i);
  26843. } else {
  26844. clearInterval(EZUIKit.state.countTimer);
  26845. EZUIKit.state.countTimer = undefined;
  26846. console.log("倒计时结束,开启声音"); // decoder.openSound(0);
  26847. }
  26848. }, 1000);
  26849. } else if (type === 'destory') {
  26850. clearInterval(EZUIKit.state.countTimer);
  26851. EZUIKit.state.countTimer = undefined;
  26852. document.getElementById("time-area").innerHTML = '00:00';
  26853. } //将秒数转换为时分秒格式
  26854. function formatSeconds(value) {
  26855. var theTime = parseInt(value); // 秒
  26856. var middle = 0; // 分
  26857. var hour = 0; // 小时
  26858. var secondV = '00';
  26859. var minV = '00';
  26860. var hourV = '00';
  26861. if (theTime > 59) {
  26862. middle = parseInt(theTime / 60);
  26863. theTime = parseInt(theTime % 60);
  26864. if (middle > 59) {
  26865. hour = parseInt(middle / 60);
  26866. middle = parseInt(middle % 60);
  26867. }
  26868. }
  26869. secondV = parseInt(theTime) > 9 ? parseInt(theTime) : '0' + parseInt(theTime);
  26870. minV = parseInt(middle) > 9 ? parseInt(middle) : '0' + parseInt(middle);
  26871. hourV = parseInt(hour) > 9 ? parseInt(hour) : '0' + parseInt(hour);
  26872. if (hour > 0) {
  26873. return hourV + ':' + minV + ':' + secondV;
  26874. } else if (middle > 0) {
  26875. return minV + ':' + secondV;
  26876. } else {
  26877. return '00:' + secondV;
  26878. }
  26879. }
  26880. }
  26881. }
  26882. }
  26883. });
  26884. });
  26885. // iframe 传递数据
  26886. var _this = this;
  26887. window.addEventListener("message", function (event) {
  26888. event.origin;
  26889. var id = _this.opt.id;
  26890. if (event.data.type) {
  26891. switch (event.data.type) {
  26892. case 'openSound':
  26893. if (id == event.data.id && params.openSoundCallBack) {
  26894. params.openSoundCallBack(event.data);
  26895. }
  26896. break;
  26897. case 'closeSound':
  26898. if (id == event.data.id && params.closeSoundCallBack) {
  26899. params.closeSoundCallBack(event.data);
  26900. }
  26901. break;
  26902. case 'capturePicture':
  26903. if (id == event.data.id && params.capturePictureCallBack) {
  26904. params.capturePictureCallBack(event.data);
  26905. }
  26906. break;
  26907. case 'startSave':
  26908. if (id == event.data.id && params.startSaveCallBack) {
  26909. params.startSaveCallBack(event.data);
  26910. }
  26911. break;
  26912. case 'stopSave':
  26913. if (id == event.data.id && params.stopSaveCallBack) {
  26914. params.stopSaveCallBack(event.data);
  26915. }
  26916. break;
  26917. case 'fullScreen':
  26918. if (id == event.data.id && params.fullScreenCallBack) {
  26919. params.fullScreenCallBack(event.data);
  26920. }
  26921. break;
  26922. case 'getOSDTime':
  26923. if (id == event.data.id && params.getOSDTimeCallBack) {
  26924. params.getOSDTimeCallBack(event.data);
  26925. }
  26926. break;
  26927. case 'handleSuccess':
  26928. if (id == event.data.id && params.handleSuccess) {
  26929. params.handleSuccess(event.data);
  26930. }
  26931. break;
  26932. case 'handleError':
  26933. if (id == event.data.id && params.handleError) {
  26934. params.handleError(event.data);
  26935. }
  26936. break;
  26937. case 'dblclick':
  26938. if (id == event.data.id && _this.opt.bSupporDoubleClickFull) {
  26939. if(_this.opt.fullScreenStatus === 0){
  26940. _this.fullScreen();
  26941. } else {
  26942. _this.cancelFullScreen();
  26943. }
  26944. }
  26945. break;
  26946. case 'startTalk':
  26947. _this.startTalk();
  26948. // params.startTalk();
  26949. _this.closeSound();
  26950. break;
  26951. case 'stopTalk':
  26952. // window.stopTalk()
  26953. _this.stopTalk();
  26954. _this.openSound();
  26955. break;
  26956. case 'clickEventHandle':
  26957. console.log("event.data",event.data);
  26958. if(params.clickEventHandle) {
  26959. params.clickEventHandle(event.data);
  26960. }
  26961. break;
  26962. case 'removeEventHandle':
  26963. if(params.removeEventHandle) {
  26964. params.removeEventHandle(event.data);
  26965. }
  26966. break;
  26967. case 'esc':
  26968. if(params.clickEventHandle) {
  26969. params.clickEventHandle(event.data);
  26970. }
  26971. break;
  26972. }
  26973. }
  26974. });
  26975. // 全屏变化回调
  26976. function fullscreenchange(data) {
  26977. _this.opt.fullScreenStatus = data ? 1 : 0;
  26978. if (params.fullScreenChangeCallBack) {
  26979. params.fullScreenChangeCallBack({data:data,id: _this.opt.id});
  26980. }
  26981. }
  26982. if (typeof document.fullScreen !== "undefined") {
  26983. document.addEventListener("fullscreenchange", function() {
  26984. var e = document.fullscreen || false;
  26985. fullscreenchange(e);
  26986. });
  26987. } else if (typeof document.webkitIsFullScreen !== "undefined") {
  26988. document.addEventListener("webkitfullscreenchange", function() {
  26989. var e = document.webkitIsFullScreen || false;
  26990. fullscreenchange(e);
  26991. });
  26992. } else if (typeof document.mozFullScreen !== "undefined") {
  26993. document.addEventListener("mozfullscreenchange", function() {
  26994. var e = document.mozFullScreen || false;
  26995. fullscreenchange(e);
  26996. });
  26997. }
  26998. }; // 播放相关API
  26999. EZUIKitPlayer.prototype.play = function (data) {
  27000. var id = 'EZUIKitPlayer-' + this.opt.id;
  27001. var player = document.getElementById(id).contentWindow;
  27002. if (typeof data === 'object' && data.url) {
  27003. this.opt.url = data.url;
  27004. }
  27005. if (typeof data === 'object' && data.accessToken) {
  27006. this.opt.accessToken = data.accessToken;
  27007. }
  27008. if (typeof data === 'string') {
  27009. this.opt.url = data;
  27010. }
  27011. player.postMessage({
  27012. action: "play",
  27013. accessToken: this.opt.accessToken,
  27014. url: this.opt.url
  27015. }, domain + "/ezopen/h5/iframe");
  27016. var _this = this;
  27017. this.opt.videoLoading = true;
  27018. var promise = new Promise(function(resolve,reject) {
  27019. window.addEventListener("message", function (event) {
  27020. var playId = _this.opt.id;
  27021. if (playId == event.data.id && event.data.type === 'handleSuccess') {
  27022. setTimeout(()=>{
  27023. _this.opt.videoLoading = false;
  27024. },1000);
  27025. resolve(event.data);
  27026. }
  27027. });
  27028. });
  27029. return promise;
  27030. };
  27031. EZUIKitPlayer.prototype.stop = function () {
  27032. var id = 'EZUIKitPlayer-' + this.opt.id;
  27033. var player = document.getElementById(id).contentWindow;
  27034. player.postMessage("stop", domain + "/ezopen/h5/iframe");
  27035. var _this = this;
  27036. var promise = new Promise(function(resolve,reject) {
  27037. window.addEventListener("message", function (event) {
  27038. var playId = _this.opt.id;
  27039. if (playId == event.data.id && event.data.type === 'stop') {
  27040. resolve(event.data);
  27041. }
  27042. });
  27043. });
  27044. return promise;
  27045. };
  27046. EZUIKitPlayer.prototype.openSound = function () {
  27047. var id = 'EZUIKitPlayer-' + this.opt.id;
  27048. var player = document.getElementById(id).contentWindow;
  27049. player.postMessage("openSound", domain + "/ezopen/h5/iframe");
  27050. var _this = this;
  27051. var promise = new Promise(function(resolve,reject) {
  27052. window.addEventListener("message", function (event) {
  27053. var playId = _this.opt.id;
  27054. if (playId == event.data.id && event.data.type === 'openSound') {
  27055. resolve(event.data);
  27056. }
  27057. });
  27058. });
  27059. return promise;
  27060. };
  27061. EZUIKitPlayer.prototype.closeSound = function () {
  27062. var id = 'EZUIKitPlayer-' + this.opt.id;
  27063. var player = document.getElementById(id).contentWindow;
  27064. player.postMessage("closeSound", domain + "/ezopen/h5/iframe");
  27065. var _this = this;
  27066. var promise = new Promise(function(resolve,reject) {
  27067. window.addEventListener("message", function (event) {
  27068. var playId = _this.opt.id;
  27069. if (playId == event.data.id && event.data.type === 'closeSound') {
  27070. resolve(event.data);
  27071. }
  27072. });
  27073. });
  27074. return promise;
  27075. };
  27076. EZUIKitPlayer.prototype.startSave = function (fileName) {
  27077. var id = 'EZUIKitPlayer-' + this.opt.id;
  27078. var player = document.getElementById(id).contentWindow;
  27079. player.postMessage({
  27080. action: "startSave",
  27081. fileName: fileName || 'default'
  27082. }, domain + "/ezopen/h5/iframe");
  27083. var _this = this;
  27084. var promise = new Promise(function(resolve,reject) {
  27085. window.addEventListener("message", function (event) {
  27086. var playId = _this.opt.id;
  27087. if (playId == event.data.id && event.data.type === 'startSave') {
  27088. resolve(event.data);
  27089. }
  27090. });
  27091. });
  27092. return promise;
  27093. };
  27094. EZUIKitPlayer.prototype.stopSave = function () {
  27095. var id = 'EZUIKitPlayer-' + this.opt.id;
  27096. var player = document.getElementById(id).contentWindow;
  27097. player.postMessage("stopSave", domain + "/ezopen/h5/iframe");
  27098. var _this = this;
  27099. var promise = new Promise(function(resolve,reject) {
  27100. window.addEventListener("message", function (event) {
  27101. var playId = _this.opt.id;
  27102. if (playId == event.data.id && event.data.type === 'stopSave') {
  27103. resolve(event.data);
  27104. }
  27105. });
  27106. });
  27107. return promise;
  27108. };
  27109. EZUIKitPlayer.prototype.fullScreen = function () {
  27110. if(this.opt.fullScreenStatus === 1){
  27111. return false
  27112. }
  27113. var id = 'EZUIKitPlayer-' + this.opt.id;
  27114. var player = document.getElementById(id).contentWindow;
  27115. if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  27116. // console.log('移动端全屏');
  27117. var width = document.documentElement.clientWidth;
  27118. var height = document.documentElement.clientHeight;
  27119. // wrapper = document.getElementById("test"),
  27120. var wrapper = document.body;//document.body 属性返回 <body> 元素, document.documentElement 属性返回 <html> 元素。
  27121. wrapper =document.getElementById(id);
  27122. var style = "";
  27123. style += "width:" + height + "px;";// 注意旋转后的宽高切换
  27124. style += "height:" + width + "px;";
  27125. style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
  27126. // 注意旋转中点的处理
  27127. style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  27128. style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
  27129. style += 'position: fixed;top: 0;left: 0;z-index:10';
  27130. wrapper.style.cssText = style;
  27131. // var cancelFullDOM = document.createElement('div');
  27132. // cancelFullDOM.id = id + "cancel-full-screen"
  27133. // var cancelFullDOMStyle="width:30px;height:"+height+"px;z-index:1000;position:fixed;top:0px;right:0px;";
  27134. // cancelFullDOMStyle += "background-image: url(https://resource.ys7cloud.com/group1/M00/00/7E/CtwQE1-01qeAH2wAAAABOliqQ5g167.png);"
  27135. // cancelFullDOMStyle += "background-size: contain;background-repeat:no-repeat;background-color:rgba(0,0,0,0.2)"
  27136. // cancelFullDOM.style = cancelFullDOMStyle;
  27137. // cancelFullDOM.onclick = function(){
  27138. // _this.cancelFullScreen();
  27139. // }
  27140. // document.body.appendChild(cancelFullDOM);
  27141. setTimeout(function () {
  27142. player.postMessage('autoResize', domain + "/ezopen/h5/iframe");
  27143. }, 500);
  27144. } else {
  27145. // console.log('pc端全屏');
  27146. var requestFullScreen = function (element) {
  27147. var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
  27148. if (requestMethod) {
  27149. requestMethod.call(element);
  27150. } else if (typeof window.ActiveXObject !== "undefined") {
  27151. var wscript = new ActiveXObject("WScript.Shell");
  27152. if (wscript !== null) {
  27153. wscript.SendKeys("{F11}");
  27154. }
  27155. }
  27156. };
  27157. requestFullScreen(document.getElementById(id));
  27158. }
  27159. if (this.params.fullScreenCallBack) {
  27160. this.params.fullScreenCallBack(this.opt.id);
  27161. }
  27162. this.opt.fullScreenStatus = 1;
  27163. };
  27164. EZUIKitPlayer.prototype.cancelFullScreen = function () {
  27165. if(this.opt.fullScreenStatus === 0){
  27166. return false
  27167. }
  27168. var id = 'EZUIKitPlayer-' + this.opt.id;
  27169. var player = document.getElementById(id).contentWindow;
  27170. if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  27171. var width = document.getElementById(id).width;
  27172. var height = document.getElementById(id).height;
  27173. // wrapper = document.getElementById("test"),
  27174. var wrapper = document.body;//document.body 属性返回 <body> 元素, document.documentElement 属性返回 <html> 元素。
  27175. wrapper =document.getElementById(id);
  27176. var style = "";
  27177. style += "width:" + width + "px;";
  27178. style += "height:" + height + "px;";
  27179. style += "-webkit-transform: rotate(0); transform: rotate(0);";
  27180. style += "-webkit-transform-origin: 0 0;";
  27181. style += "transform-origin: 0 0;";
  27182. wrapper.style.cssText = style;
  27183. setTimeout(function () {
  27184. player.postMessage("autoResize", domain + "/ezopen/h5/iframe");
  27185. }, 500);
  27186. var cancelFullDOMId = id + "cancel-full-screen";
  27187. var cancelFullDOM = document.getElementById(cancelFullDOMId);
  27188. if(cancelFullDOM){
  27189. document.body.removeChild(cancelFullDOM);
  27190. }
  27191. } else {
  27192. if (document.exitFullscreen) {
  27193. document.exitFullscreen();
  27194. } else if (document.webkitCancelFullScreen) {
  27195. document.webkitCancelFullScreen();
  27196. } else if (document.mozCancelFullScreen) {
  27197. document.mozCancelFullScreen();
  27198. }
  27199. }
  27200. if (this.params.cancelFullScreenCallBack) {
  27201. this.params.cancelFullScreenCallBack(this.opt.id);
  27202. }
  27203. this.opt.fullScreenStatus = 0;
  27204. };
  27205. EZUIKitPlayer.prototype.capturePicture = function (fileName,isUndownload) {
  27206. var id = 'EZUIKitPlayer-' + this.opt.id;
  27207. var player = document.getElementById(id).contentWindow;
  27208. player.postMessage({
  27209. action: "capturePicture",
  27210. fileName: fileName || 'default',
  27211. isUndownload: isUndownload,
  27212. }, domain + "/ezopen/h5/iframe");
  27213. var _this = this;
  27214. var promise = new Promise(function(resolve,reject) {
  27215. window.addEventListener("message", function (event) {
  27216. var playId = _this.opt.id;
  27217. if (playId == event.data.id && event.data.type === 'capturePicture') {
  27218. resolve(event.data);
  27219. }
  27220. });
  27221. });
  27222. return promise;
  27223. };
  27224. EZUIKitPlayer.prototype.enableZoom = function () {
  27225. var id = 'EZUIKitPlayer-' + this.opt.id;
  27226. var player = document.getElementById(id).contentWindow;
  27227. player.postMessage("enableZoom", domain + "/ezopen/h5/iframe");
  27228. };
  27229. EZUIKitPlayer.prototype.closeZoom = function () {
  27230. var id = 'EZUIKitPlayer-' + this.opt.id;
  27231. var player = document.getElementById(id).contentWindow;
  27232. player.postMessage("closeZoom", domain + "/ezopen/h5/iframe");
  27233. };
  27234. EZUIKitPlayer.prototype.getOSDTime = function () {
  27235. var id = 'EZUIKitPlayer-' + this.opt.id;
  27236. var player = document.getElementById(id).contentWindow;
  27237. player.postMessage("getOSDTime", domain + "/ezopen/h5/iframe");
  27238. var _this = this;
  27239. var promise = new Promise(function(resolve,reject) {
  27240. window.addEventListener("message", function (event) {
  27241. var playId = _this.opt.id;
  27242. if (playId == event.data.id && event.data.type === 'getOSDTime') {
  27243. resolve(event.data);
  27244. }
  27245. });
  27246. });
  27247. return promise;
  27248. };
  27249. EZUIKitPlayer.prototype.autoResize = function () {
  27250. var id = 'EZUIKitPlayer-' + this.opt.id;
  27251. var player = document.getElementById(id).contentWindow;
  27252. player.postMessage("autoResize", domain + "/ezopen/h5/iframe");
  27253. };
  27254. EZUIKitPlayer.prototype.reSize = function (width,height) {
  27255. var id = 'EZUIKitPlayer-' + this.opt.id;
  27256. var player = document.getElementById(id).contentWindow;
  27257. var containerDOM = document.getElementById(this.opt.id);
  27258. containerDOM.style.width = width + 'px';
  27259. containerDOM.style.height = height + 'px';
  27260. document.getElementById(this.opt.id).style.width = width + 'px';
  27261. document.getElementById(this.opt.id).style.height = height + 'px';
  27262. var playDOM = document.getElementById(id);
  27263. playDOM.setAttribute("width",width);
  27264. playDOM.setAttribute("height",height);
  27265. playDOM.style.width = width + 'px';
  27266. playDOM.style.height = height + 'px';
  27267. setTimeout(function(){
  27268. player.postMessage({
  27269. action: 'autoResize',
  27270. }, domain + "/ezopen/h5/iframe");
  27271. },500);
  27272. };
  27273. EZUIKitPlayer.prototype.startTalk = function () {
  27274. console.log("执行开始对讲");
  27275. console.log(this.opt);
  27276. var _this = this;
  27277. EZUIKit.opt = this.opt;
  27278. if(window.EZUIKit) {
  27279. window.EZUIKit.opt = this.opt;
  27280. }
  27281. var apiSuccess = function(data) {
  27282. if (data.code == 200) {
  27283. var apiResult = data.data;
  27284. if (apiResult) {
  27285. // 临时将https转换为websocket
  27286. var rtcTrunk = apiResult.rtcUrl;
  27287. if (rtcTrunk.indexOf("ws") === -1) {
  27288. rtcTrunk = rtcTrunk.replace("https", "wss").replace("rtcgw", "rtcgw-ws");
  27289. }
  27290. _this.opt.rtcUrl = rtcTrunk;
  27291. _this.opt.ttsUrl = "tts://" + apiResult.ttsUrl;
  27292. var talk = "talk://" + _this.opt.deviceSerial + ":0:" + _this.opt.channelNo + ":cas.ys7.com:6500";
  27293. _this.opt.talkLink = _this.opt.ttsUrl + "/" + talk;
  27294. _this.opt.stream = apiResult.stream;
  27295. window.startTalk();
  27296. }
  27297. }
  27298. };
  27299. request(_this.opt.apiDomain, 'POST', {
  27300. accessToken: _this.opt.accessToken,
  27301. deviceSerial: _this.opt.deviceSerial,
  27302. channelNo: _this.opt.channelNo
  27303. }, '', apiSuccess);
  27304. };
  27305. EZUIKitPlayer.prototype.stopTalk = function () {
  27306. console.log("执行结束对讲");
  27307. window.stopTalk();
  27308. };
  27309. EZUIKitPlayer.prototype.edit = function () {
  27310. var id = 'EZUIKitPlayer-' + this.opt.id;
  27311. var player = document.getElementById(id).contentWindow;
  27312. player.postMessage("edit", domain + "/ezopen/h5/iframe");
  27313. };
  27314. EZUIKitPlayer.prototype.btnReRender = function (data) {
  27315. var id = 'EZUIKitPlayer-' + this.opt.id;
  27316. var player = document.getElementById(id).contentWindow;
  27317. player.postMessage({action: "btnReRender",data: data}, domain + "/ezopen/h5/iframe");
  27318. };
  27319. EZUIKitPlayer.prototype.changePlayUrl = function (data) {
  27320. var id = 'EZUIKitPlayer-' + this.opt.id;
  27321. var player = document.getElementById(id).contentWindow;
  27322. player.postMessage({action: "changePlayUrl",data: data}, domain + "/ezopen/h5/iframe");
  27323. };
  27324. EZUIKitPlayer.prototype.fetchThemeData = function () {
  27325. var id = 'EZUIKitPlayer-' + this.opt.id;
  27326. var player = document.getElementById(id).contentWindow;
  27327. player.postMessage({action: "fetchThemeData"}, domain + "/ezopen/h5/iframe");
  27328. };
  27329. EZUIKitPlayer.prototype.setThemeData = function (accessToken, header, footer) {
  27330. var id = 'EZUIKitPlayer-' + this.opt.id;
  27331. var player = document.getElementById(id).contentWindow;
  27332. player.postMessage({action: "setThemeData",data:{accessToken, header, footer}}, domain + "/ezopen/h5/iframe");
  27333. };
  27334. /**
  27335. * 视频播放器-结束
  27336. */
  27337. EZUIKit.EZUIKitPlayer = EZUIKitPlayer;
  27338. window.EZUIKitV3 = EZUIKit;
  27339. const EZUIKitV3 = EZUIKit;
  27340. return EZUIKitV3;
  27341. });
  27342. var EZUIKitV3$1 = EZUIKitV3;
  27343. /**
  27344. * Created by wangweijie5 on 2016/12/16.
  27345. */
  27346. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  27347. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27348. var __instance = function () {
  27349. var instance = void 0;
  27350. return function (newInstance) {
  27351. if (newInstance) instance = newInstance;
  27352. return instance;
  27353. };
  27354. }();
  27355. (function () {
  27356. function AudioRenderer() {
  27357. _classCallCheck(this, AudioRenderer);
  27358. if (__instance()) return __instance();
  27359. // 确保只有单例
  27360. if (AudioRenderer.unique !== undefined) {
  27361. return AudioRenderer.unique;
  27362. }
  27363. AudioRenderer.unique = this;
  27364. this.oAudioContext = null;
  27365. this.currentVolume = 0.8; // 初始音量
  27366. this.bSetVolume = false;
  27367. this.gainNode = null;
  27368. this.iWndNum = -1; // 窗口号
  27369. this.mVolumes = new Map(); // 用于存储所有音量
  27370. // Init AudioContext
  27371. var AudioContext = window.AudioContext || window.webkitAudioContext;
  27372. this.oAudioContext = new AudioContext();
  27373. this.writeString = function (view, offset, string) {
  27374. for (var i = 0; i < string.length; i++) {
  27375. view.setUint8(offset + i, string.charCodeAt(i));
  27376. }
  27377. };
  27378. this.setBufferToDataview = function (output, offset, input) {
  27379. for (var i = 0; i < input.length; i++, offset++) {
  27380. output.setUint8(offset, input[i]);
  27381. }
  27382. };
  27383. __instance(this);
  27384. }
  27385. /**
  27386. * @synopsis 音频播放
  27387. *
  27388. * @param dataBuf [IN] 音频缓存
  27389. * @param dataLen [IN] 缓存长度
  27390. * @param audioInfo [IN] 音频参数
  27391. *
  27392. * @returns 状态码
  27393. */
  27394. _createClass(AudioRenderer, [{
  27395. key: 'Play',
  27396. value: function Play(dataBuf, dataLen, audioInfo) {
  27397. var bufferData = new ArrayBuffer(44 + dataLen);
  27398. var viewTalk = new DataView(bufferData);
  27399. var sampleRates = audioInfo.samplesPerSec;
  27400. var channels = audioInfo.channels;
  27401. var bitsPerSample = audioInfo.bitsPerSample;
  27402. //console.log("audiorender sampleRates"+sampleRates+"channels:"+channels+"bitsPerSample:"+bitsPerSample);
  27403. /* RIFF identifier */
  27404. this.writeString(viewTalk, 0, 'RIFF');
  27405. /* file length */
  27406. viewTalk.setUint32(4, 32 + dataLen * 2, true);
  27407. /* RIFF type */
  27408. this.writeString(viewTalk, 8, 'WAVE');
  27409. /* format chunk identifier */
  27410. this.writeString(viewTalk, 12, 'fmt ');
  27411. /* format chunk length */
  27412. viewTalk.setUint32(16, 16, true);
  27413. /* sample format (raw) */
  27414. viewTalk.setUint16(20, 1, true);
  27415. /* channel count */
  27416. viewTalk.setUint16(22, channels, true);
  27417. /* sample rate */
  27418. viewTalk.setUint32(24, sampleRates, true);
  27419. /* byte rate (sample rate * block align) */
  27420. viewTalk.setUint32(28, sampleRates * 2, true);
  27421. /* block align (channel count * bytes per sample)/8 */
  27422. viewTalk.setUint16(32, channels * bitsPerSample / 8, true);
  27423. /* bits per sample */
  27424. viewTalk.setUint16(34, bitsPerSample, true);
  27425. /* data chunk identifier */
  27426. this.writeString(viewTalk, 36, 'data');
  27427. /* data chunk length */
  27428. viewTalk.setUint32(40, dataLen, true);
  27429. this.setBufferToDataview(viewTalk, 44, dataBuf);
  27430. var self = this;
  27431. this.oAudioContext.decodeAudioData(viewTalk.buffer, function (buffer) {
  27432. var bufferSource = self.oAudioContext.createBufferSource();
  27433. if (bufferSource == null) {
  27434. return -1;
  27435. }
  27436. bufferSource.buffer = buffer;
  27437. bufferSource.start(0);
  27438. if (self.gainNode == null || self.bSetVolume) {
  27439. self.gainNode = self.oAudioContext.createGain();
  27440. // self.gainNode.gain.value = self.currentVolume;
  27441. // // self.currentVolume = self.gainNode.gain.value;
  27442. // self.gainNode.connect(self.oAudioContext.destination);
  27443. self.bSetVolume = false;
  27444. }
  27445. self.gainNode.gain.value = self.currentVolume;
  27446. // self.currentVolume = self.gainNode.gain.value;
  27447. self.gainNode.connect(self.oAudioContext.destination);
  27448. bufferSource.connect(self.gainNode);
  27449. }, function (e) {
  27450. console.log("decode error");
  27451. return -1;
  27452. });
  27453. return 0;
  27454. }
  27455. /**
  27456. * @synopsis 停止播放
  27457. *
  27458. * @returns 返回音量
  27459. */
  27460. }, {
  27461. key: 'Stop',
  27462. value: function Stop() {
  27463. if (this.gainNode != null) {
  27464. this.gainNode.disconnect();
  27465. this.gainNode = null;
  27466. }
  27467. // this.oAudioContext.close();
  27468. // AudioRenderer.unique = undefined;
  27469. // __instance() = null;
  27470. return true;
  27471. }
  27472. /**
  27473. * @synopsis 设置音量
  27474. *
  27475. * @param iVolume [IN] 音量
  27476. *
  27477. * @returns 状态码
  27478. */
  27479. }, {
  27480. key: 'SetVolume',
  27481. value: function SetVolume(iVolume) {
  27482. this.bSetVolume = true;
  27483. this.currentVolume = iVolume;
  27484. // 储存当前窗口设置音量值
  27485. this.mVolumes.set(this.iWndNum, iVolume);
  27486. return true;
  27487. }
  27488. /**
  27489. * @synopsis 设置窗口号
  27490. *
  27491. * @param iWndNum [IN] 窗口号
  27492. *
  27493. * @returns 状态码
  27494. */
  27495. }, {
  27496. key: 'SetWndNum',
  27497. value: function SetWndNum(iWndNum) {
  27498. this.iWndNum = iWndNum;
  27499. // 获取当前窗口设置音量值
  27500. var iVolume = this.mVolumes.get(iWndNum);
  27501. if (iVolume == undefined) {
  27502. iVolume = 0.8; // 默认音量
  27503. }
  27504. this.currentVolume = iVolume;
  27505. return true;
  27506. }
  27507. /**
  27508. * @synopsis 获取音量
  27509. *
  27510. * @returns 返回音量
  27511. */
  27512. }, {
  27513. key: 'GetVolume',
  27514. value: function GetVolume() {
  27515. // 获取当前窗口设置音量值
  27516. var iVolume = this.mVolumes.get(this.iWndNum);
  27517. if (iVolume == undefined) {
  27518. iVolume = 0.8; // 默认音量
  27519. }
  27520. return iVolume;
  27521. }
  27522. }]);
  27523. window.AudioRenderer = AudioRenderer;
  27524. return AudioRenderer;
  27525. })();
  27526. //顶点着色器
  27527. //attribute修饰符用于声明由浏览器(javascript)传输给顶点着色器的变量值;
  27528. // vertexPos即我们定义的顶点坐标;
  27529. // gl_Position是一个内建的传出变量。
  27530. var vertexYUVShader = [
  27531. 'attribute vec4 vertexPos;',
  27532. 'attribute vec2 texturePos;',
  27533. 'varying vec2 textureCoord;',
  27534. 'void main()',
  27535. '{',
  27536. 'gl_Position = vertexPos;',
  27537. 'textureCoord = texturePos;',
  27538. '}'
  27539. ].join('\n');
  27540. //像素着色器(yuv->rgb)
  27541. var fragmentYUVShader = [
  27542. 'precision highp float;',
  27543. 'varying highp vec2 textureCoord;',
  27544. 'uniform sampler2D ySampler;',
  27545. 'uniform sampler2D uSampler;',
  27546. 'uniform sampler2D vSampler;',
  27547. 'const mat4 YUV2RGB = mat4',
  27548. '(',
  27549. '1.1643828125, 0, 1.59602734375, -.87078515625,',
  27550. '1.1643828125, -.39176171875, -.81296875, .52959375,',
  27551. '1.1643828125, 2.017234375, 0, -1.081390625,',
  27552. '0, 0, 0, 1',
  27553. ');',
  27554. 'void main(void) {',
  27555. 'highp float y = texture2D(ySampler, textureCoord).r;',
  27556. 'highp float u = texture2D(uSampler, textureCoord).r;',
  27557. 'highp float v = texture2D(vSampler, textureCoord).r;',
  27558. 'gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',
  27559. '}'
  27560. ].join('\n');
  27561. (function (root, factory) {
  27562. // root.SuperRender = factory();
  27563. window.SuperRender = factory();
  27564. }(undefined, function () {
  27565. function RenderManager(canvas) {
  27566. this.canvasElement = document.getElementById(canvas);
  27567. this.initContextGL();
  27568. if(this.contextGL) {
  27569. this.YUVProgram = this.initProgram(vertexYUVShader, fragmentYUVShader);
  27570. this.initBuffers();
  27571. this.initTextures();
  27572. }
  27573. }
  27574. /**
  27575. * 初始化WebGL上下文
  27576. */
  27577. RenderManager.prototype.initContextGL = function() {
  27578. var canvas = this.canvasElement;
  27579. var gl = null;
  27580. try {
  27581. gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
  27582. } catch (e) {
  27583. gl = null;
  27584. }
  27585. if(!gl || typeof gl.getParameter !== "function") {
  27586. gl = null;
  27587. }
  27588. this.contextGL = gl;
  27589. // console.log("WebGL1.0");
  27590. };
  27591. /**
  27592. * 初始化着色器程序
  27593. * @param vertexShaderScript 顶点着色器脚本
  27594. * @param fragmentShaderScript 片段着色器脚本
  27595. */
  27596. RenderManager.prototype.initProgram = function(vertexShaderScript, fragmentShaderScript) {
  27597. var gl = this.contextGL;
  27598. var vertexShader = gl.createShader(gl.VERTEX_SHADER); //创建定点着色器
  27599. gl.shaderSource(vertexShader, vertexShaderScript);
  27600. gl.compileShader(vertexShader);
  27601. if(!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
  27602. console.log('Vertex shader failed to compile: ' + gl.getShaderInfoLog(vertexShader));
  27603. }
  27604. var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
  27605. gl.shaderSource(fragmentShader, fragmentShaderScript);
  27606. gl.compileShader(fragmentShader);
  27607. if(!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
  27608. console.log('Fragment shader failed to compile: ' + gl.getShaderInfoLog(fragmentShader));
  27609. }
  27610. var program = gl.createProgram();
  27611. gl.attachShader(program, vertexShader);
  27612. gl.attachShader(program, fragmentShader);
  27613. gl.linkProgram(program);
  27614. if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  27615. console.log('Program failed to compile: ' + gl.getProgramInfoLog(program));
  27616. }
  27617. gl.deleteShader(vertexShader);
  27618. gl.deleteShader(fragmentShader);
  27619. return program;
  27620. };
  27621. /**
  27622. * 初始化数据缓存
  27623. */
  27624. RenderManager.prototype.initBuffers = function() {
  27625. var gl = this.contextGL;
  27626. var vertexPosBuffer = gl.createBuffer();
  27627. gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
  27628. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), gl.STATIC_DRAW);
  27629. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  27630. var texturePosBuffer = gl.createBuffer();
  27631. gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
  27632. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.DYNAMIC_DRAW);
  27633. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  27634. this.vertexPosBuffer = vertexPosBuffer;
  27635. this.texturePosBuffer = texturePosBuffer;
  27636. };
  27637. /**
  27638. * 创建纹理
  27639. */
  27640. RenderManager.prototype.initTexture = function() {
  27641. var gl = this.contextGL;
  27642. var textureRef = gl.createTexture();
  27643. gl.bindTexture(gl.TEXTURE_2D, textureRef);
  27644. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  27645. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  27646. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  27647. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  27648. gl.bindTexture(gl.TEXTURE_2D, null);
  27649. return textureRef;
  27650. };
  27651. /**
  27652. * 初始化YUV纹理
  27653. */
  27654. RenderManager.prototype.initTextures = function() {
  27655. var gl = this.contextGL;
  27656. var program = this.YUVProgram;
  27657. gl.useProgram(program);
  27658. var yTextureRef = this.initTexture();
  27659. var ySamplerRef = gl.getUniformLocation(program, 'ySampler');
  27660. gl.uniform1i(ySamplerRef, 0);
  27661. this.yTextureRef = yTextureRef;
  27662. var uTextureRef = this.initTexture();
  27663. var uSamplerRef = gl.getUniformLocation(program, 'uSampler');
  27664. gl.uniform1i(uSamplerRef, 1);
  27665. this.uTextureRef = uTextureRef;
  27666. var vTextureRef = this.initTexture();
  27667. var vSamplerRef = gl.getUniformLocation(program, 'vSampler');
  27668. gl.uniform1i(vSamplerRef, 2);
  27669. this.vTextureRef = vTextureRef;
  27670. gl.useProgram(null);
  27671. };
  27672. /**
  27673. * 显示帧数据
  27674. * @param nWidth 宽度
  27675. * @param nHeight 高度
  27676. * @param nHeight 帧数据
  27677. */
  27678. RenderManager.prototype.SR_DisplayFrameData = function(nWidth, nHeight, pData,dWidth,dHeight) {
  27679. if(nWidth <= 0 || nHeight <= 0)
  27680. {
  27681. return;
  27682. }
  27683. var gl = this.contextGL;
  27684. if(null == pData)
  27685. {
  27686. gl.clearColor(0.0, 0.0, 0.0, 0.0);
  27687. gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  27688. return;
  27689. }
  27690. var canvas = this.canvasElement;
  27691. this.nWindowWidth = canvas.width;
  27692. this.nWindowHeight = canvas.height;
  27693. var nWindowWidth = this.nWindowWidth;
  27694. var nWindowHeight = this.nWindowHeight;
  27695. gl.clearColor(0.8, 0.8, 1.0, 1.0);
  27696. gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  27697. gl.viewport(0, 0, nWindowWidth, nWindowHeight);
  27698. this.updateFrameData(nWidth, nHeight, pData,dWidth,dHeight);
  27699. var program = this.YUVProgram;
  27700. gl.useProgram(program);
  27701. var vertexPosBuffer = this.vertexPosBuffer;
  27702. gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
  27703. var vertexPosRef = gl.getAttribLocation(program, 'vertexPos');
  27704. gl.enableVertexAttribArray(vertexPosRef);
  27705. gl.vertexAttribPointer(vertexPosRef, 2, gl.FLOAT, false, 0, 0);
  27706. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  27707. var texturePosBuffer = this.texturePosBuffer;
  27708. gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
  27709. var texturePosRef = gl.getAttribLocation(program, 'texturePos');
  27710. gl.enableVertexAttribArray(texturePosRef);
  27711. gl.vertexAttribPointer(texturePosRef, 2, gl.FLOAT, false, 0, 0);
  27712. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  27713. gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
  27714. gl.disableVertexAttribArray(vertexPosRef);
  27715. gl.disableVertexAttribArray(texturePosRef);
  27716. gl.useProgram(null);
  27717. };
  27718. /**
  27719. * 上传YUV数据到纹理
  27720. * @param nWidth 宽度
  27721. * @param nHeight 高度
  27722. * @param nHeight 帧数据
  27723. */
  27724. RenderManager.prototype.updateFrameData = function(width, height, data,dWidth,dHeight) {
  27725. var gl = this.contextGL;
  27726. var yTextureRef = this.yTextureRef;
  27727. var uTextureRef = this.uTextureRef;
  27728. var vTextureRef = this.vTextureRef;
  27729. var i420Data = data;
  27730. // debugger;
  27731. if(width == dWidth && height == dHeight)
  27732. {
  27733. var yDataLength = width * height;
  27734. var yData = i420Data.subarray(0, yDataLength);
  27735. gl.activeTexture(gl.TEXTURE0);
  27736. gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
  27737. gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width, height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
  27738. var cbDataLength = width/2 * height/2;
  27739. var cbData = i420Data.subarray(width*height, width*height + cbDataLength);
  27740. gl.activeTexture(gl.TEXTURE1);
  27741. gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
  27742. gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
  27743. var crDataLength = cbDataLength;
  27744. var crData = i420Data.subarray(width*height + width*height/4, width*height + width*height/4 + crDataLength);
  27745. gl.activeTexture(gl.TEXTURE2);
  27746. gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
  27747. gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
  27748. }
  27749. else
  27750. {
  27751. // //裁剪宽
  27752. var yDataLength = dWidth * dHeight;
  27753. var yData=new Uint8Array(yDataLength) ;
  27754. for(var i=0;i<dHeight;i++)
  27755. {
  27756. //var ySonData=new Uint8Array(dWidth) ;
  27757. var ySonData = i420Data.subarray(i*width, i*width+dWidth);
  27758. for (var j = 0; j < dWidth; j++) {
  27759. yData[i*dWidth + j] = ySonData[j];
  27760. }
  27761. }
  27762. gl.activeTexture(gl.TEXTURE0);
  27763. gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
  27764. gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth, dHeight, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
  27765. yData=null;
  27766. ySonData=null;
  27767. var cbDataLength = dWidth/2 * dHeight/2;
  27768. var cbData =new Uint8Array(cbDataLength);
  27769. //var cbSonData=new Uint8Array(dWidth/2) ;
  27770. for(var i=0;i<dHeight/2;i++)
  27771. {
  27772. var cbSonData = i420Data.subarray(width*height+i*width/2, width*height+i*width/2+dWidth/2);
  27773. for (var j = 0; j < dWidth/2; j++) {
  27774. cbData[i*dWidth/2 + j] = cbSonData[j];
  27775. }
  27776. }
  27777. gl.activeTexture(gl.TEXTURE1);
  27778. gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
  27779. gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
  27780. cbData=null;
  27781. cbSonData=null;
  27782. var crDataLength = cbDataLength;
  27783. var crData = new Uint8Array(crDataLength);
  27784. for(var i=0;i<dHeight/2;i++)
  27785. {
  27786. var crSonData = i420Data.subarray(width*height*5/4+i*width/2, width*height*5/4+i*width/2+dWidth/2);
  27787. for (var j = 0; j < dWidth/2; j++) {
  27788. crData[i*dWidth/2 + j] = crSonData[j];
  27789. }
  27790. }
  27791. gl.activeTexture(gl.TEXTURE2);
  27792. gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
  27793. gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
  27794. crData=null;
  27795. crSonData=null;
  27796. }
  27797. };
  27798. /**
  27799. * 设置显示区域
  27800. * @param stDisplayRect 显示区域
  27801. */
  27802. RenderManager.prototype.SR_SetDisplayRect = function(stDisplayRect) {
  27803. var gl = this.contextGL;
  27804. var nWindowWidth = this.nWindowWidth;
  27805. var nWindowHeight = this.nWindowHeight;
  27806. var texturePosValues = null;
  27807. if(stDisplayRect && nWindowWidth > 0 && nWindowHeight > 0) {
  27808. var fLeft = stDisplayRect.left / nWindowWidth;
  27809. var fTop = stDisplayRect.top / nWindowHeight;
  27810. var fRight = stDisplayRect.right / nWindowWidth;
  27811. var fBottom = stDisplayRect.bottom / nWindowHeight;
  27812. texturePosValues = new Float32Array([fRight, fTop, fLeft, fTop, fRight, fBottom, fLeft, fBottom]);
  27813. }
  27814. else {
  27815. texturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]);
  27816. }
  27817. var texturePosBuffer = this.texturePosBuffer;
  27818. gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
  27819. gl.bufferSubData(gl.ARRAY_BUFFER, 0, texturePosValues);
  27820. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  27821. };
  27822. /**
  27823. * 释放显示资源
  27824. */
  27825. RenderManager.prototype.SR_Destroy = function() {
  27826. var gl = this.contextGL;
  27827. var YUVProgram = this.YUVProgram;
  27828. gl.deleteProgram(YUVProgram);
  27829. var vertexPosBuffer = this.vertexPosBuffer;
  27830. var texturePosBuffer = this.texturePosBuffer;
  27831. gl.deleteBuffer(vertexPosBuffer);
  27832. gl.deleteBuffer(texturePosBuffer);
  27833. var yTextureRef = this.yTextureRef;
  27834. var uTextureRef = this.uTextureRef;
  27835. var vTextureRef = this.vTextureRef;
  27836. gl.deleteTexture(yTextureRef);
  27837. gl.deleteTexture(uTextureRef);
  27838. gl.deleteTexture(vTextureRef);
  27839. };
  27840. return RenderManager;
  27841. }));
  27842. /* eslint-disable valid-jsdoc */
  27843. // import './jsPlugin-4.0.2.min.js';
  27844. // iframe模板 - 兼容旧版本
  27845. const matchTemplate = (templateName, params) => {
  27846. const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'voice', 'theme'];
  27847. const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData', ''];
  27848. if (typeof templateName === 'undefined') {
  27849. if (params.themeData) {
  27850. return {
  27851. templateType: 'themeData',
  27852. templateId: 'themeData'
  27853. }
  27854. }
  27855. return {
  27856. templateType: 'local',
  27857. templateId: ''
  27858. }
  27859. } if (typeof templateName === 'string') {
  27860. if (templateName.length === 32) {
  27861. return {
  27862. templateType: 'remote',
  27863. templateId: templateName
  27864. }
  27865. } else if (IFRAMETEMPLATE.indexOf(templateName) !== -1) {
  27866. // 精简版且不使用头部,底部,仅播放视频,建议使用按需加载避免iframe内存额外消耗
  27867. if (templateName === 'simple' && typeof params.header === 'undefined' && typeof params.footer === 'undefined') {
  27868. return {
  27869. templateType: 'local',
  27870. templateId: ''
  27871. }
  27872. }
  27873. return {
  27874. templateType: 'iframe',
  27875. templateId: templateName
  27876. }
  27877. } else if (LOCALTEMPLATE.indexOf(templateName) !== -1) {
  27878. return {
  27879. templateType: 'local',
  27880. templateId: templateName
  27881. }
  27882. }
  27883. }
  27884. };
  27885. var _handleClose = null;
  27886. class EZUIKitPlayer {
  27887. constructor(params) {
  27888. const { autoplay = true } = params;
  27889. this.params = params;
  27890. window.EZUIKit[params.id] = {
  27891. state: {
  27892. EZUIKitPlayer: {
  27893. init: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.init || false,
  27894. themeInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit || false,
  27895. talkInit: window.EZUIKit[params.id] && window.EZUIKit[params.id].state && window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit || false
  27896. }
  27897. }
  27898. };
  27899. if (matchTemplate(this.params.template, params).templateType !== 'iframe') {
  27900. this.Monitor = new Monitor({
  27901. env: !(typeof params.disableMonitor !== 'undefined' && params.disableMonitor) ? 'online' : 'test12',
  27902. });
  27903. this.id = params.id;
  27904. this.width = params.width;
  27905. this.height = params.height;
  27906. this.url = params.url;
  27907. this.accessToken = params.accessToken;
  27908. this.themeId = matchTemplate(params.template, params).templateId;
  27909. this.id = params.id;
  27910. this.audio = false;
  27911. this.poster = params.poster;
  27912. this.speed = 1;
  27913. this.disabledTimeLine = false;
  27914. _handleClose = params.handleClose;
  27915. this.env = {
  27916. domain: "https://open.ys7.com"
  27917. };
  27918. // this.staticPath = "http://121.37.6.200/Zgcy";
  27919. this.staticPath = params.decoderPath;
  27920. if (typeof params.staticPath === 'string') {
  27921. this.staticPath = params.staticPath;
  27922. }
  27923. if (typeof params.audio !== 'undefined') {
  27924. this.audio = params.audio;
  27925. }
  27926. if (typeof params.disabledTimeLine !== 'undefined') {
  27927. this.disabledTimeLine = params.disabledTimeLine;
  27928. }
  27929. addJs(`${this.staticPath}/js/jsPlugin-4.0.2.min.js`, () => {
  27930. if (autoplay) {
  27931. this.initTime = new Date().getTime();
  27932. this.Monitor.dclog({
  27933. url: this.url,
  27934. action: 0,
  27935. text: 'startInit',
  27936. });
  27937. var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
  27938. var getRealUrlPromise = this._getRealUrlPromise(params.accessToken, params.url);
  27939. Promise.all([initEZUIKitPlayerPromise, getRealUrlPromise]).then(values => {
  27940. if (values[1]) {
  27941. this._pluginPlay(values[1],
  27942. () => {
  27943. // console.log("自动播放成功");
  27944. this.Monitor.dclog({
  27945. url: this.url,
  27946. action: 202,
  27947. d: new Date().getTime() - this.initTime,
  27948. text: 'autoPlaySuccess'
  27949. });
  27950. },
  27951. () => {
  27952. console.log("自动播放失败");
  27953. this.Monitor.dclog({
  27954. url: this.url,
  27955. action: 402,
  27956. d: new Date().getTime() - this.initTime,
  27957. text: 'autoPlayError'
  27958. });
  27959. },
  27960. );
  27961. }
  27962. window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
  27963. if (document.getElementById(`${params.id}canvas_draw0`)) {
  27964. document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
  27965. }
  27966. });
  27967. } else {
  27968. this.initTime = new Date().getTime();
  27969. this.Monitor.dclog({
  27970. url: this.url,
  27971. action: 0,
  27972. text: 'startInit',
  27973. });
  27974. var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
  27975. initEZUIKitPlayerPromise.then((data) => {
  27976. console.log("初始化成功", data);
  27977. window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
  27978. if (document.getElementById(`${params.id}canvas_draw0`)) {
  27979. document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
  27980. }
  27981. this.Monitor.dclog({
  27982. url: this.url,
  27983. action: 201,
  27984. d: new Date().getTime() - this.initTime,
  27985. text: 'initSuccess',
  27986. });
  27987. });
  27988. }
  27989. },()=>{
  27990. return !!window.JSPlugin;
  27991. });
  27992. if ((params.plugin && params.plugin.indexOf("talk") !== -1)) {
  27993. this.Talk = new Talk(this);
  27994. window.EZUIKit[params.id].state.EZUIKitPlayer.talkInit = true;
  27995. }
  27996. } else {
  27997. return new EZUIKitV3$1.EZUIKitPlayer(params);
  27998. }
  27999. }
  28000. initEZUIKitPlayer(params) {
  28001. const { id, width = 600, height = 400 } = params;
  28002. if (!document.getElementById(`${id}-wrap`)) {
  28003. document.getElementById(id).style = `display:inline-block;width:${width}px;height:${height}px;`;
  28004. var wapDom = document.createElement("div");
  28005. wapDom.id = `${id}-wrap`;
  28006. wapDom.style = `display:inline-block;width:${width}px;position:relative;`;
  28007. document.getElementById(id).parentNode.insertBefore(wapDom, document.getElementById(id));
  28008. wapDom.appendChild(document.getElementById(id));
  28009. document.getElementById(id).style.verticalAlign = "top";
  28010. }
  28011. const initDecoder = (resolve, reject) => {
  28012. var jSPlugin = new window.JSPlugin({
  28013. szId: id,
  28014. iType: 2,
  28015. iWidth: width,
  28016. iHeight: height,
  28017. iMaxSplit: 1,
  28018. iCurrentSplit: 1,
  28019. szBasePath: "",
  28020. staticPath: params.staticPath,
  28021. oStyle: {
  28022. border: "none",
  28023. background: "#000000"
  28024. }
  28025. });
  28026. jSPlugin.EventCallback = {
  28027. loadEventHandler: function () {
  28028. },
  28029. zoomEventResponse: function (/*iMode, aPoint*/) { //电子放大回调
  28030. },
  28031. windowEventSelect: function (iWndIndex) { //插件选中窗口回调
  28032. },
  28033. pluginErrorHandler: (iWndIndex, iErrorCode, oError) => { //插件错误回调
  28034. console.log(iWndIndex, iErrorCode, oError);
  28035. if (iErrorCode === 1003) {
  28036. console.log("断流");
  28037. this.pluginStatus.loadingSetText({
  28038. text: "连接断开,请重试",
  28039. color: 'red'
  28040. });
  28041. if (typeof this.params.handleError === 'function') {
  28042. this.params.handleError({
  28043. msg: "连接断开,请重试",
  28044. retcode: 1003,
  28045. id: this.params.id,
  28046. type: "handleError"
  28047. });
  28048. }
  28049. }
  28050. },
  28051. windowEventOver: function (iWndIndex) {
  28052. },
  28053. windowEventOut: function (iWndIndex) {
  28054. },
  28055. windowEventUp: function (iWndIndex) {
  28056. },
  28057. windowFullCcreenChange: function (bFull) {
  28058. },
  28059. firstFrameDisplay: (iWndIndex, iWidth, iHeight) => {
  28060. // console.log(iWidth, iHeight);
  28061. jSPlugin.JS_SetCanFullScreen(false);
  28062. this.pluginStatus.loadingClear();
  28063. },
  28064. performanceLack: function () {
  28065. },
  28066. mouseEvent: function (iMouseEventType, iMouseX, iMouseY) {
  28067. }
  28068. };
  28069. // 增加视频容器
  28070. var pluginStatus = new Status(this, id);
  28071. pluginStatus.loadingStart(id);
  28072. pluginStatus.loadingSetText({ text: '初始化播放器完成' });
  28073. this.env = {
  28074. domain: "https://open.ys7.com"
  28075. };
  28076. if (typeof params.env !== 'undefined') {
  28077. this.env = Object.assign(this.env, params.env);
  28078. }
  28079. this.errorHander = new Code();
  28080. this.jSPlugin = jSPlugin;
  28081. if (this.themeId && !window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit) {
  28082. this.Theme = new Theme(this, id);
  28083. window.EZUIKit[params.id].state.EZUIKitPlayer.themeInit = true;
  28084. }
  28085. this.pluginStatus = pluginStatus;
  28086. // 待需要改造plugin,异步判断;
  28087. resolve({
  28088. meta: {
  28089. retcode: 200,
  28090. msg: "初始化成功"
  28091. }
  28092. });
  28093. };
  28094. var initDecoderPromise = new Promise(initDecoder);
  28095. return initDecoderPromise;
  28096. }
  28097. _getRealUrlPromise(accessToken, url) {
  28098. var apiDomain = this.env.domain;
  28099. if (this.env) {
  28100. apiDomain = this.env.domain;
  28101. }
  28102. var getRealUrlPromise = (resolve, reject) => {
  28103. var realUrl = '';
  28104. var apiUrl = apiDomain + "/api/lapp/live/url/ezopen";
  28105. var data = new FormData();
  28106. data.append("ezopen", url);
  28107. data.append("isFlv", false);
  28108. data.append("userAgent", window.navigator.userAgent);
  28109. data.append("isHttp", false);
  28110. data.append("accessToken", accessToken);
  28111. fetch(apiUrl, {
  28112. method: "POST",
  28113. // headers: {
  28114. // 'Content-Type': 'application/json'
  28115. // },
  28116. body: data
  28117. })
  28118. .then(response => response.json())
  28119. .then((data) => {
  28120. if (data.code == 200 || data.retcode == 0) {
  28121. var playUrl = "";
  28122. var stream = "";
  28123. if (data.ext && data.ext.token) {
  28124. realUrl += data.data;
  28125. stream = data.ext.token;
  28126. playUrl = data.data;
  28127. } else if (data.data && data.data.token) {
  28128. realUrl += data.data.url;
  28129. stream = data.data.token;
  28130. playUrl = data.data.url;
  28131. }
  28132. var type = url.indexOf('live') !== -1 ? 'live' : 'playback';
  28133. if (type === 'live') {
  28134. realUrl = realUrl + '&ssn=' + stream + '&auth=1&biz=4&cln=100';
  28135. } else {
  28136. realUrl = realUrl + '&ssn=' + stream + '&auth=1&cln=100';
  28137. }
  28138. // console.log(realUrl);
  28139. // 设置秘钥 - 如果地址中包含秘钥参数,播放前配置到JSPlugin对应实例中
  28140. var validateCode = getQueryString('checkCode', realUrl);
  28141. if (validateCode) {
  28142. this.jSPlugin.JS_SetSecretKey(0, validateCode);
  28143. }
  28144. // 回放处理
  28145. if (realUrl.indexOf('playback') !== -1) {
  28146. var wsBegin = getQueryString('begin', playUrl) || getQueryString('begin', url);
  28147. var wsEnd = getQueryString('end', playUrl) || getQueryString('end', url);
  28148. // 兼容各种时间格式
  28149. if (!wsBegin) {
  28150. var defaultDate = new Date();
  28151. realUrl = realUrl + '&begin=' + defaultDate.Format('yyyyMMdd') + 'T000000Z';
  28152. } else {
  28153. realUrl = realUrl.replace('&begin=' + getQueryString('begin', playUrl), '&begin=' + formatRecTime(wsBegin, '000000'));
  28154. if (!getQueryString('begin', realUrl)) {
  28155. realUrl += '&begin=' + formatRecTime(wsBegin, '000000');
  28156. }
  28157. }
  28158. if (!wsEnd) {
  28159. realUrl = realUrl + '&end=' + formatRecTime(getQueryString('begin', realUrl).substr(0, 8), '235959');
  28160. } else {
  28161. realUrl = realUrl.replace('&end=' + getQueryString('end', playUrl), '&end=' + formatRecTime(wsEnd, '235959'));
  28162. if (!getQueryString('end', realUrl)) {
  28163. realUrl += '&end=' + formatRecTime(wsEnd, '235959');
  28164. }
  28165. }
  28166. // api错误处理
  28167. if (!getQueryString('stream', playUrl)) {
  28168. realUrl = realUrl.replace('stream', '&stream');
  28169. }
  28170. if (url.indexOf('.cloud') !== -1) { //云存储回放
  28171. // 调用回放API接口获取回放片段 - start
  28172. var recBegin = reRormatRecTime(getQueryString('begin', realUrl));
  28173. var recEnd = reRormatRecTime(getQueryString('end', realUrl));
  28174. var deviceSerial = getQueryString('serial', realUrl);
  28175. var channelNo = getQueryString('chn', realUrl);
  28176. var recSliceUrl = apiDomain + "/api/lapp/video/by/time";
  28177. var recSliceParams = {
  28178. accessToken: this.accessToken,
  28179. recType: 1,
  28180. deviceSerial: deviceSerial,
  28181. channelNo: channelNo,
  28182. startTime: recBegin,
  28183. endTime: recEnd,
  28184. version: '2.0'
  28185. };
  28186. function recAPISuccess(data) {
  28187. if (data.code == 200) {
  28188. var recSliceArr = [];
  28189. if (data.data && data.data.files && data.data.files.length > 0) {
  28190. var dataArr = data.data.files;
  28191. var nextFileTime = new Date().getTime();
  28192. var isAll = data.data.isAll;
  28193. // mock
  28194. // var number = 0;
  28195. //isAll = false;
  28196. if (isAll) {
  28197. recSliceArr = recSliceArrFun(dataArr);
  28198. var recSliceArrJSON = JSON.stringify(recSliceArr).replace('\\', '');
  28199. realUrl += ('&recSlice=' + recSliceArrJSON.replace('\\', '')) + '&r=' + Math.random();
  28200. resolve(realUrl);
  28201. } else {
  28202. recTransaction();
  28203. // 云存储回调事务
  28204. function recTransaction() {
  28205. function recAPIV2Success(data) {
  28206. if (data.data && data.data.files && data.data.files.length > 0) {
  28207. //if(number < 2 ) {
  28208. if (data.data.isAll == false) {
  28209. if (data.data.files) {
  28210. dataArr = dataArr.concat(data.data.files);
  28211. }
  28212. nextFileTime = data.data.nextFileTime > 0 ? data.data.nextFileTime : new Date().getTime();
  28213. recTransaction();
  28214. } else {
  28215. recSliceArr = recSliceArrFun(dataArr);
  28216. var recSliceArrJSON = JSON.stringify(recSliceArr).replace('\\', '');
  28217. realUrl += ('&recSlice=' + recSliceArrJSON.replace('\\', '')) + '&r=' + Math.random();
  28218. resolve(realUrl);
  28219. }
  28220. // mock
  28221. //number = number + 1;
  28222. } else {
  28223. recSliceArr = recSliceArrFun(dataArr);
  28224. var recSliceArrJSON = JSON.stringify(recSliceArr).replace('\\', '');
  28225. realUrl += ('&recSlice=' + recSliceArrJSON.replace('\\', '')) + '&r=' + Math.random();
  28226. resolve(realUrl);
  28227. }
  28228. }
  28229. recSliceParams.startTime = nextFileTime;
  28230. request(recSliceUrl, 'POST', recSliceParams, '', recAPIV2Success);
  28231. }
  28232. }
  28233. } else {
  28234. reject({
  28235. retcode: -1,
  28236. msg: "未找到录像片段"
  28237. });
  28238. }
  28239. } else {
  28240. reject({
  28241. retcode: -1,
  28242. msg: "未找到录像片段"
  28243. });
  28244. }
  28245. function recSliceArrFun(data) {
  28246. var downloadPathArr = [];
  28247. data.forEach(function (item, index) {
  28248. if (downloadPathArr.length == 0 || (item.downloadPath !== downloadPathArr[downloadPathArr.length - 1].downloadPath)) {
  28249. downloadPathArr.push({
  28250. downloadPath: item.downloadPath,
  28251. ownerId: item.ownerId,
  28252. iStorageVersion: item.iStorageVersion,
  28253. videoType: item.videoType,
  28254. iPlaySpeed: 0,
  28255. startTime: item.startTime,
  28256. endTime: item.endTime
  28257. });
  28258. } else {
  28259. downloadPathArr[downloadPathArr.length - 1].endTime = item.endTime;
  28260. }
  28261. });
  28262. return downloadPathArr;
  28263. }
  28264. }
  28265. request(recSliceUrl, 'POST', recSliceParams, '', recAPISuccess);
  28266. } else { // 本地回放
  28267. //alarm rec - start
  28268. if (url.indexOf('alarmId') !== -1) {
  28269. console.log("进入alarmId回放");
  28270. // 调用回放API接口获取回放片段 - start
  28271. var alarmId = getQueryString('alarmId', realUrl);
  28272. var recBegin = reRormatRecTime(getQueryString('begin', realUrl));
  28273. var recEnd = reRormatRecTime(getQueryString('end', realUrl));
  28274. var deviceSerial = getQueryString('serial', realUrl);
  28275. var channelNo = getQueryString('chn', realUrl);
  28276. var recSliceUrl = apiDomain + "/api/lapp/video/by/id";
  28277. var recSliceParams = {
  28278. accessToken: this.accessToken,
  28279. // recType: 1,
  28280. deviceSerial: deviceSerial,
  28281. channelNo: channelNo,
  28282. alarmId: alarmId
  28283. // startTime:recBegin,
  28284. // endTime:recEnd
  28285. };
  28286. function recAPISuccess(data) {
  28287. if (data.code == 200) {
  28288. var recSliceArr = [];
  28289. if (data.data) {
  28290. recSliceArr = recSliceArrFun([data.data]);
  28291. var recSliceArrJSON = JSON.stringify(recSliceArr).replace('\\', '');
  28292. realUrl += ('&recSlice=' + recSliceArrJSON.replace('\\', ''));
  28293. console.log("realUrl", realUrl, data.data.recType);
  28294. if (data.data.recType == 1) {
  28295. realUrl = realUrl.replace('/playback', '/cloudplayback');
  28296. } else {
  28297. realUrl = realUrl.replace('/cloudplayback', '/playback');
  28298. }
  28299. // _this.opt.sources[0] = realUrl;
  28300. resolve(realUrl);
  28301. // request(nodeUrl, 'GET', '', '', nodeSuccess, nodeError);
  28302. }
  28303. }
  28304. function recSliceArrFun(data) {
  28305. var downloadPathArr = [];
  28306. data.forEach(function (item, index) {
  28307. if (downloadPathArr.length == 0 || (item.downloadPath !== downloadPathArr[downloadPathArr.length - 1].downloadPath)) {
  28308. downloadPathArr.push({
  28309. downloadPath: item.downloadPath,
  28310. ownerId: item.ownerId,
  28311. iStorageVersion: item.iStorageVersion,
  28312. videoType: item.videoType,
  28313. iPlaySpeed: 0,
  28314. startTime: item.startTime,
  28315. endTime: item.endTime
  28316. });
  28317. } else {
  28318. downloadPathArr[downloadPathArr.length - 1].endTime = item.endTime;
  28319. }
  28320. });
  28321. console.log("downloadPathArr", downloadPathArr);
  28322. return downloadPathArr;
  28323. }
  28324. }
  28325. request(recSliceUrl, 'POST', recSliceParams, '', recAPISuccess);
  28326. } else {
  28327. // arlar rec - end
  28328. // request(nodeUrl, 'GET', '', '', nodeSuccess, nodeError);
  28329. resolve(realUrl);
  28330. }
  28331. }
  28332. } else {
  28333. resolve(realUrl);
  28334. }
  28335. } else {
  28336. this.pluginStatus.loadingSetText({
  28337. text: data.msg,
  28338. color: 'red'
  28339. });
  28340. if (typeof this.params.handleError === 'function') {
  28341. this.params.handleError({
  28342. retcode: data.code,
  28343. msg: data.msg,
  28344. id: this.params.id,
  28345. type: "handleError"
  28346. });
  28347. }
  28348. resolve(realUrl);
  28349. }
  28350. // fetch real url end
  28351. });
  28352. };
  28353. return new Promise(function (resolve, reject) {
  28354. return getRealUrlPromise(resolve, reject);
  28355. });
  28356. // 格式化回放时间
  28357. function formatRecTime(time, defaultTime) {
  28358. // 用户格式 无需更改 => 20182626T000000Z
  28359. // return time
  28360. // 用户格式需要更改
  28361. //用户时间长度为 14 20181226000000 =》 20181226000000
  28362. // 用户长度为12 201812260000 =》 201812260000 + defaultTime后面2位
  28363. // 用户长度为10 2018122600 =》 201812260000 + defaultTime后面4位
  28364. // 用户长度为8 20181226 =》 201812260000 + defaultTime后面6位
  28365. // 结果 20181226000000 14位
  28366. // 插入 TZ
  28367. var reg = /^[0-9]{8}T[0-9]{6}Z$/;
  28368. if (reg.test(time)) { // 用户格式 无需更改 => 20182626T000000Z
  28369. return time;
  28370. } else if (/[0-9]{8,14}/.test(time)) {
  28371. var start = 6 - (14 - time.length);
  28372. var end = defaultTime.length;
  28373. var standardTime = time + defaultTime.substring(start, end);
  28374. return standardTime.slice(0, 8) + 'T' + standardTime.slice(8) + 'Z';
  28375. }
  28376. throw new Error('回放时间格式有误,请确认');
  28377. }
  28378. function reRormatRecTime(time) {
  28379. var year = time.slice(0, 4);
  28380. var month = time.slice(4, 6);
  28381. var day = time.slice(6, 8);
  28382. var hour = time.slice(9, 11);
  28383. var minute = time.slice(11, 13);
  28384. var second = time.slice(13, 15);
  28385. var date = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
  28386. // if (_this.opt.domain !== 'open') {
  28387. // return new Date(date.replace(/-/g, '/')).getTime() + (8 * 60 * 60 * 1000);
  28388. // }
  28389. return new Date(date.replace(/-/g, '/')).getTime();
  28390. }
  28391. }
  28392. _pluginPlay(data, successCallback, errorCallback) {
  28393. // console.log("get real url result ===", data);
  28394. function getPlayParams(url) {
  28395. var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
  28396. var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
  28397. if (websocketStreamingParam.indexOf('/playback') !== -1) {
  28398. websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
  28399. }
  28400. // 本地回放仅支持主码流
  28401. return {
  28402. websocketConnectUrl: websocketConnectUrl,
  28403. websocketStreamingParam: websocketStreamingParam
  28404. };
  28405. }
  28406. var wsUrl = getPlayParams(data).websocketConnectUrl;
  28407. if (this.env && this.env.wsUrl) {
  28408. wsUrl = this.env.wsUrl;
  28409. }
  28410. var wsParams = {
  28411. playURL: getPlayParams(data).websocketStreamingParam
  28412. };
  28413. this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
  28414. // console.log("播放成功");
  28415. this.pluginStatus.loadingClear();
  28416. this.pluginStatus.setPlayStatus({play: true, loading: false});
  28417. if (this.Theme) {
  28418. this.Theme.setDecoderState({ play: true });
  28419. }
  28420. if (this.audio) {
  28421. setTimeout(() => {
  28422. this.openSound();
  28423. }, 500);
  28424. }
  28425. if (typeof this.params.handleSuccess === 'function') {
  28426. this.params.handleSuccess({
  28427. retcode: 0,
  28428. id: this.params.id,
  28429. type: "handleSuccess"
  28430. });
  28431. }
  28432. successCallback();
  28433. this.Monitor.dclog({
  28434. url: this.url,
  28435. action: 211,
  28436. d: new Date().getTime() - this.playStartTime,
  28437. text: 'startPlaySuccess'
  28438. });
  28439. }, (err) => {
  28440. var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
  28441. var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
  28442. this.pluginStatus.loadingSetText({
  28443. text: msg,
  28444. color: 'red'
  28445. });
  28446. if (typeof this.params.handleError === 'function') {
  28447. this.params.handleError({
  28448. retcode: err.oError.errorCode,
  28449. msg: msg,
  28450. id: this.params.id,
  28451. type: "handleError"
  28452. });
  28453. }
  28454. errorCallback();
  28455. this.Monitor.dclog({
  28456. url: this.url,
  28457. action: 411,
  28458. d: new Date().getTime() - this.playStartTime,
  28459. text: 'startPlayError'
  28460. });
  28461. });
  28462. }
  28463. play(options) {
  28464. this.pluginStatus.setPlayStatus({play: false, loading: true});
  28465. this.playStartTime = new Date().getTime();
  28466. this.Monitor.dclog({
  28467. url: this.url,
  28468. action: 1,
  28469. d: new Date().getTime() - this.initTime,
  28470. text: 'startPlay'
  28471. });
  28472. if (options) {
  28473. if (typeof options.url === 'string') {
  28474. this.url = options.url;
  28475. }
  28476. if (typeof options.accessToken === 'string') {
  28477. this.accessToken = options.accessToken;
  28478. }
  28479. if (this.Theme && (typeof options.url === 'string' || typeof options.accessToken === 'string')) {
  28480. this.Theme.getDeviceInfo();
  28481. }
  28482. }
  28483. const promise = new Promise((resolve, reject) => {
  28484. this._getRealUrlPromise(this.accessToken, this.url)
  28485. .then((data) => {
  28486. this._pluginPlay(data, () => resolve(true), () => reject(false));
  28487. })
  28488. .catch((err) => {
  28489. var msg = err.msg ? err.msg : '播放失败,请检查设备及客户端网络';
  28490. this.pluginStatus.loadingSetText({
  28491. text: msg,
  28492. color: 'red'
  28493. });
  28494. if (typeof this.params.handleError === 'function') {
  28495. this.params.handleError({
  28496. retcode: err.oError.errorCode,
  28497. msg: msg,
  28498. id: this.params.id,
  28499. type: "handleError"
  28500. });
  28501. }
  28502. reject(false);
  28503. });
  28504. });
  28505. return promise;
  28506. }
  28507. stop() {
  28508. this.pluginStatus.setPlayStatus({loading: true});
  28509. return this.jSPlugin.JS_Stop(0).then(() => {
  28510. console.log("停止成功");
  28511. this.pluginStatus.setPlayStatus({play: false,loading: false});
  28512. if (this.Theme) {
  28513. this.Theme.setDecoderState({ play: false });
  28514. }
  28515. });
  28516. }
  28517. changePlayUrl(options) {
  28518. var initUrl = this.url;
  28519. var url = matchUrl(initUrl, options);
  28520. // console.log("changePlayUrl", url);
  28521. this.url = url;
  28522. const promise = new Promise((resolve, reject) => {
  28523. this.stop()
  28524. .then(() => {
  28525. if (options.accessToken) {
  28526. this.accessToken = options.accessToken;
  28527. return this.play({
  28528. accessToken: options.accessToken,
  28529. url: url
  28530. }).then(() => {
  28531. resolve(url);
  28532. }).catch((err) => {
  28533. reject(url);
  28534. });
  28535. }
  28536. this.play(url)
  28537. .then(() => {
  28538. resolve(url);
  28539. })
  28540. .catch((err) => {
  28541. reject(url);
  28542. });
  28543. })
  28544. .catch((err) => {
  28545. _handleClose(0);
  28546. console.log("切换过程停止失败", err);
  28547. // if (options.accessToken) {
  28548. // this.accessToken = options.accessToken;
  28549. // return this.play({
  28550. // accessToken: options.accessToken,
  28551. // url: url
  28552. // }).then(() => {
  28553. // resolve(url);
  28554. // }).catch((err) => {
  28555. // reject(url);
  28556. // });
  28557. // }
  28558. // this.play(url)
  28559. // .then(() => {
  28560. // resolve(url);
  28561. // }).catch((err) => {
  28562. // reject(url);
  28563. // });
  28564. });
  28565. });
  28566. /**
  28567. * 匹配播放地址 用户播放地址切换
  28568. * options
  28569. * type | string | live,rec
  28570. * hd | boolean | true,false
  28571. * deviceSerial
  28572. * channelNO
  28573. * begin
  28574. * end
  28575. */
  28576. function matchUrl(matchInitUrl, matchOptions) {
  28577. if (matchOptions.url) {
  28578. return matchOptions.url;
  28579. }
  28580. var type = matchInitUrl.split("/")[4].split(".")[matchInitUrl.split("/")[4].split(".").length - 1].split("?")[0];
  28581. if (type === 'rec' && matchInitUrl.indexOf(".cloud.rec") !== -1) {
  28582. type = 'cloud.rec';
  28583. }
  28584. if (matchOptions.type) {
  28585. type = matchOptions.type;
  28586. }
  28587. var deviceSerial = matchInitUrl.split("/")[3];
  28588. if (matchOptions.deviceSerial) {
  28589. deviceSerial = matchOptions.deviceSerial;
  28590. }
  28591. var channelNo = matchInitUrl.split("/")[4].split(".")[0];
  28592. if (matchOptions.channelNo) {
  28593. channelNo = matchOptions.channelNo;
  28594. }
  28595. // 如果切换设备,之前设备有验证码,新设备无验证码,建议传空验证码,清理验证码(降低解码消耗)
  28596. var validCode = matchInitUrl.split("/")[2].split("@").length === 2 ? matchInitUrl.split("/")[2].split("@")[0] : "";
  28597. if (typeof matchOptions.validCode !== 'undefined') {
  28598. validCode = matchOptions.validCode;
  28599. }
  28600. var hd = typeof matchOptions.hd === 'undefined' ? matchInitUrl.indexOf('.hd') !== -1 : matchOptions.hd;
  28601. let result = `ezopen://${validCode ? `${validCode}@` : ""}open.ys7.com/${deviceSerial}/${channelNo}${hd ? '.hd' : ''}.${type}`;
  28602. if (type === 'live') {
  28603. return result;
  28604. }
  28605. result = `ezopen://${validCode ? `${validCode}@` : ""}open.ys7.com/${deviceSerial}/${channelNo}.${type}`;
  28606. if (matchOptions.begin && matchOptions.end) {
  28607. result += `?begin=${matchOptions.begin}&end=${matchOptions.end}`;
  28608. } else if (matchOptions.begin) {
  28609. result += `?begin=${matchOptions.begin}`;
  28610. } else if (getQueryString("begin", matchInitUrl)) {
  28611. result += `?begin=${getQueryString("begin", matchInitUrl)}`;
  28612. }
  28613. return result;
  28614. }
  28615. return promise;
  28616. }
  28617. getOSDTime() {
  28618. var promise = new Promise((resolve, reject) => {
  28619. this.jSPlugin.JS_GetOSDTime(0)
  28620. .then((data) => {
  28621. resolve({
  28622. code: 0,
  28623. retcode: 0,
  28624. data: data
  28625. });
  28626. // 兼容旧版本callback
  28627. if (typeof this.params.getOSDTimeCallBack === 'function') {
  28628. this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: 0, data: data });
  28629. }
  28630. })
  28631. .catch(err => {
  28632. reject({
  28633. code: -1,
  28634. retcode: -1,
  28635. data: err
  28636. });
  28637. // 兼容旧版本callback
  28638. if (typeof this.params.getOSDTimeCallBack === 'function') {
  28639. this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: -1, data: -1 });
  28640. }
  28641. });
  28642. });
  28643. return promise;
  28644. }
  28645. capturePicture(name, callback = false) {
  28646. var capturePictureRT = this.jSPlugin.JS_CapturePicture(0, name, "JPEG", callback, !!callback);
  28647. if (isPromise(capturePictureRT)) {
  28648. // 兼容旧版本callback
  28649. if (typeof this.params.capturePictureCallBack === 'function') {
  28650. capturePictureRT.then(() => {
  28651. this.params.capturePictureCallBack({ id: this.id, type: 'capturePicture', code: 0 });
  28652. })
  28653. .catch(() => {
  28654. this.params.capturePictureCallBack({ id: this.id, type: 'capturePicture', code: -1 });
  28655. });
  28656. }
  28657. return capturePictureRT;
  28658. }
  28659. return new Promise(function (resolve) {
  28660. resolve(capturePictureRT);
  28661. });
  28662. }
  28663. startSave(name) {
  28664. var startSaveRT = this.jSPlugin.JS_StartSave(0, name);
  28665. if (isPromise(startSaveRT)) {
  28666. // 兼容旧版本callback
  28667. if (typeof this.params.startSaveCallBack === 'function') {
  28668. startSaveRT.then(() => {
  28669. this.params.startSaveCallBack({ id: this.id, type: 'startSave', code: 0 });
  28670. })
  28671. .catch(() => {
  28672. this.params.startSaveCallBack({ id: this.id, type: 'startSave', code: -1 });
  28673. });
  28674. }
  28675. return startSaveRT;
  28676. }
  28677. if (this.Theme) {
  28678. this.Theme.setDecoderState({ recordvideo: true });
  28679. }
  28680. return new Promise(function (resolve) {
  28681. resolve(startSaveRT);
  28682. });
  28683. }
  28684. stopSave() {
  28685. var stopSaveRT = this.jSPlugin.JS_StopSave(0);
  28686. if (isPromise(stopSaveRT)) {
  28687. // 兼容旧版本callback
  28688. if (typeof this.params.startSaveCallBack === 'function') {
  28689. stopSaveRT.then(() => {
  28690. this.params.stopSaveCallBack({ id: this.id, type: 'stopSave', code: 0 });
  28691. })
  28692. .catch(() => {
  28693. this.params.stopSaveCallBack({ id: this.id, type: 'stopSave', code: -1 });
  28694. });
  28695. }
  28696. return stopSaveRT;
  28697. }
  28698. if (this.Theme) {
  28699. this.Theme.setDecoderState({ recordvideo: false });
  28700. }
  28701. return new Promise(function (resolve) {
  28702. resolve(stopSaveRT);
  28703. });
  28704. }
  28705. openSound() {
  28706. var openSoundRT = this.jSPlugin.JS_OpenSound(0);
  28707. console.log("打开声音", openSoundRT);
  28708. if (isPromise(openSoundRT)) {
  28709. return openSoundRT;
  28710. }
  28711. if (this.Theme) {
  28712. this.Theme.setDecoderState({ sound: true });
  28713. }
  28714. // 兼容旧版本callback
  28715. if (typeof this.params.openSoundCallBack === 'function') {
  28716. this.params.openSoundCallBack({ id: this.id, type: 'openSound', code: openSoundRT });
  28717. }
  28718. return new Promise(function (resolve) {
  28719. resolve(openSoundRT);
  28720. });
  28721. }
  28722. closeSound() {
  28723. var closeSoundRT = this.jSPlugin.JS_CloseSound(0);
  28724. if (isPromise(closeSoundRT)) {
  28725. return closeSoundRT;
  28726. }
  28727. if (this.Theme) {
  28728. this.Theme.setDecoderState({ sound: false });
  28729. }
  28730. // 兼容旧版本callback
  28731. if (typeof this.params.closeSoundCallBack === 'function') {
  28732. this.params.closeSoundCallBack({ id: this.id, type: 'closeSound', code: closeSoundRT });
  28733. }
  28734. return new Promise(function (resolve) {
  28735. resolve(closeSoundRT);
  28736. });
  28737. }
  28738. enableZoom() {
  28739. var enableZoomRT = this.jSPlugin.JS_EnableZoom(0);
  28740. if (isPromise(enableZoomRT)) {
  28741. return enableZoomRT;
  28742. }
  28743. return new Promise(function (resolve) {
  28744. resolve(enableZoomRT);
  28745. });
  28746. }
  28747. closeZoom() {
  28748. var closeZoomRT = this.jSPlugin.JS_DisableZoom(0);
  28749. if (isPromise(closeZoomRT)) {
  28750. return closeZoomRT;
  28751. }
  28752. return new Promise(function (resolve) {
  28753. resolve(closeZoomRT);
  28754. });
  28755. }
  28756. setPoster(url) {
  28757. this.pluginStatus.setPoster(url);
  28758. }
  28759. reSize(width, height) {
  28760. this.width = width;
  28761. this.height = height;
  28762. document.getElementById(`${this.id}-wrap`).style = `width:${width}px;position:relative;`;
  28763. this.jSPlugin.JS_Resize(width, height);
  28764. }
  28765. fast() {
  28766. var speed = this.speed;
  28767. if (speed === 1) {
  28768. speed = 2;
  28769. } else if (speed === 2) {
  28770. speed = 4;
  28771. } else {
  28772. if (typeof this.params.handleError === 'function') {
  28773. this.params.handleError({
  28774. msg: "播放速度最大为4倍速度",
  28775. retcode: 1003,
  28776. id: this.id,
  28777. type: "handleError"
  28778. });
  28779. }
  28780. }
  28781. var fastRT = this.jSPlugin.JS_Fast(0);
  28782. if (isPromise(fastRT)) {
  28783. this.speed = speed;
  28784. return fastRT;
  28785. }
  28786. return new Promise(function (resolve) {
  28787. this.speed = speed;
  28788. resolve(fastRT);
  28789. });
  28790. }
  28791. slow() {
  28792. var speed = this.speed;
  28793. if (speed === 4) {
  28794. speed = 2;
  28795. } else if (speed === 2) {
  28796. speed = 1;
  28797. } else {
  28798. if (typeof this.params.handleError === 'function') {
  28799. this.params.handleError({
  28800. msg: "播放速度最小为1倍速度",
  28801. retcode: 1003,
  28802. id: this.id,
  28803. type: "handleError"
  28804. });
  28805. }
  28806. }
  28807. var slowRT = this.jSPlugin.JS_Slow(0);
  28808. console.log("slowRT", slowRT);
  28809. if (isPromise(slowRT)) {
  28810. this.speed = speed;
  28811. return slowRT;
  28812. }
  28813. return new Promise(function (resolve) {
  28814. this.speed = speed;
  28815. resolve(slowRT);
  28816. });
  28817. }
  28818. seek(startTime, endTime) {
  28819. var url = this.url;
  28820. var currentDay = (getQueryString(url, 'begin') || new Date().Format('yyyyMMdd')).substr(0, 8);
  28821. endTime = formatRecTime(currentDay, '235959');
  28822. if (startTime.length === 6) {
  28823. startTime = formatRecTime(currentDay, startTime);
  28824. } else if (startTime.length === 16) {
  28825. if (startTime.substr(0, 8) !== currentDay) {
  28826. this.params.handleError({
  28827. msg: "seek时间不能跨日期",
  28828. retcode: -1,
  28829. id: this.id,
  28830. type: "handleError"
  28831. });
  28832. return false;
  28833. }
  28834. } else {
  28835. this.params.handleError({
  28836. msg: "seek时间格式错误",
  28837. retcode: -1,
  28838. id: this.id,
  28839. type: "handleError"
  28840. });
  28841. return false;
  28842. }
  28843. // 格式化回放时间
  28844. function formatRecTime(time, defaultTime) {
  28845. // 用户格式 无需更改 => 20182626T000000Z
  28846. // return time
  28847. // 用户格式需要更改
  28848. //用户时间长度为 14 20181226000000 =》 20181226000000
  28849. // 用户长度为12 201812260000 =》 201812260000 + defaultTime后面2位
  28850. // 用户长度为10 2018122600 =》 201812260000 + defaultTime后面4位
  28851. // 用户长度为8 20181226 =》 201812260000 + defaultTime后面6位
  28852. // 结果 20181226000000 14位
  28853. // 插入 TZ
  28854. var reg = /^[0-9]{8}T[0-9]{6}Z$/;
  28855. if (reg.test(time)) { // 用户格式 无需更改 => 20182626T000000Z
  28856. return time;
  28857. } else if (/[0-9]{8,14}/.test(time)) {
  28858. var start = 6 - (14 - time.length);
  28859. var end = defaultTime.length;
  28860. var standardTime = time + defaultTime.substring(start, end);
  28861. return standardTime.slice(0, 8) + 'T' + standardTime.slice(8) + 'Z';
  28862. } else {
  28863. throw new Error('回放时间格式有误,请确认');
  28864. }
  28865. }
  28866. var seekRT = this.jSPlugin.JS_Seek(0, startTime, endTime);
  28867. console.log("seekRT", seekRT);
  28868. if (isPromise(seekRT)) {
  28869. return seekRT;
  28870. }
  28871. return new Promise(function (resolve) {
  28872. resolve(seekRT);
  28873. });
  28874. }
  28875. fullScreen() {
  28876. var promise = requestFullScreenPromise(document.getElementById(`${this.id}`));
  28877. promise.then((data) => {
  28878. console.log("全屏promise", window.screen.availWidth);
  28879. this.jSPlugin.JS_Resize(window.screen.availWidth, window.screen.availHeight);
  28880. // 兼容旧版本callback
  28881. if (typeof this.params.fullScreenCallBack === 'function') {
  28882. this.params.fullScreenCallBack({ id: this.id, type: 'fullScreen', code: 0 });
  28883. }
  28884. });
  28885. // 监听全屏事件触发
  28886. const fullscreenchange = () => {
  28887. let isFullScreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  28888. if (!isFullScreen) {
  28889. this.jSPlugin.JS_Resize(this.width, this.height);
  28890. }
  28891. // 兼容旧版本callback
  28892. if (typeof this.params.fullScreenChangeCallBack === 'function') {
  28893. this.params.fullScreenChangeCallBack({ id: this.id, type: 'fullScreen', code: isFullScreen });
  28894. }
  28895. };
  28896. ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange'].forEach((item) => {
  28897. window.addEventListener(item, (data) => fullscreenchange());
  28898. });
  28899. }
  28900. cancelFullScreen() {
  28901. var cancelPromise = cancelFullScreenPromise();
  28902. cancelPromise.then((data) => {
  28903. console.log("取消全屏", data, this.jSPlugin);
  28904. this.jSPlugin.JS_Resize(this.width, this.height);
  28905. });
  28906. }
  28907. startTalk() {
  28908. this.Talk.startTalk();
  28909. }
  28910. stopTalk() {
  28911. this.Talk.stopTalk();
  28912. }
  28913. destroy() {
  28914. var destroyRT = this.jSPlugin.JS_DestroyWorker(0);
  28915. if (this.Theme) {
  28916. this.Theme = null;
  28917. window.EZUIKit[this.params.id].state.EZUIKitPlayer.themeInit = false;
  28918. }
  28919. if (isPromise(destroyRT)) {
  28920. return destroyRT;
  28921. }
  28922. return new Promise(function (resolve) {
  28923. resolve(destroyRT);
  28924. });
  28925. }
  28926. }
  28927. (function (global, factory) {
  28928. if (typeof module === "object" && typeof module.exports === "object") {
  28929. module.exports = global.document ?
  28930. factory(global, true) :
  28931. function (w) {
  28932. if (!w.document) {
  28933. throw new Error("EZUIPlayer requires a window with a document");
  28934. }
  28935. return factory(w);
  28936. };
  28937. } else {
  28938. factory(global);
  28939. }
  28940. // Pass this if window is not defined yet
  28941. })(typeof window !== "undefined" ? window : undefined, function (window, noGlobal) {
  28942. const EZUIKit = {
  28943. Core,
  28944. HLS,
  28945. FLV,
  28946. EZUIKitPlayer
  28947. };
  28948. window.EZUIKit = EZUIKit;
  28949. return EZUIKit;
  28950. });