plyr.polyfilled.mjs 498 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754
  1. typeof navigator === "object" && // Polyfill for creating CustomEvents on IE9/10/11
  2. // code pulled from:
  3. // https://github.com/d4tocchini/customevent-polyfill
  4. // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
  5. (function () {
  6. if (typeof window === 'undefined') {
  7. return;
  8. }
  9. try {
  10. var ce = new window.CustomEvent('test', {
  11. cancelable: true
  12. });
  13. ce.preventDefault();
  14. if (ce.defaultPrevented !== true) {
  15. // IE has problems with .preventDefault() on custom events
  16. // http://stackoverflow.com/questions/23349191
  17. throw new Error('Could not prevent default');
  18. }
  19. } catch (e) {
  20. var CustomEvent = function CustomEvent(event, params) {
  21. var evt, origPrevent;
  22. params = params || {};
  23. params.bubbles = !!params.bubbles;
  24. params.cancelable = !!params.cancelable;
  25. evt = document.createEvent('CustomEvent');
  26. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  27. origPrevent = evt.preventDefault;
  28. evt.preventDefault = function () {
  29. origPrevent.call(this);
  30. try {
  31. Object.defineProperty(this, 'defaultPrevented', {
  32. get: function get() {
  33. return true;
  34. }
  35. });
  36. } catch (e) {
  37. this.defaultPrevented = true;
  38. }
  39. };
  40. return evt;
  41. };
  42. CustomEvent.prototype = window.Event.prototype;
  43. window.CustomEvent = CustomEvent; // expose definition to window
  44. }
  45. })();
  46. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  47. function createCommonjsModule(fn, module) {
  48. return module = { exports: {} }, fn(module, module.exports), module.exports;
  49. }
  50. var check = function (it) {
  51. return it && it.Math == Math && it;
  52. };
  53. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  54. var global_1 =
  55. // eslint-disable-next-line no-undef
  56. check(typeof globalThis == 'object' && globalThis) ||
  57. check(typeof window == 'object' && window) ||
  58. check(typeof self == 'object' && self) ||
  59. check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
  60. // eslint-disable-next-line no-new-func
  61. Function('return this')();
  62. var fails = function (exec) {
  63. try {
  64. return !!exec();
  65. } catch (error) {
  66. return true;
  67. }
  68. };
  69. // Thank's IE8 for his funny defineProperty
  70. var descriptors = !fails(function () {
  71. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  72. });
  73. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  74. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  75. // Nashorn ~ JDK8 bug
  76. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  77. // `Object.prototype.propertyIsEnumerable` method implementation
  78. // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
  79. var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  80. var descriptor = getOwnPropertyDescriptor(this, V);
  81. return !!descriptor && descriptor.enumerable;
  82. } : nativePropertyIsEnumerable;
  83. var objectPropertyIsEnumerable = {
  84. f: f
  85. };
  86. var createPropertyDescriptor = function (bitmap, value) {
  87. return {
  88. enumerable: !(bitmap & 1),
  89. configurable: !(bitmap & 2),
  90. writable: !(bitmap & 4),
  91. value: value
  92. };
  93. };
  94. var toString = {}.toString;
  95. var classofRaw = function (it) {
  96. return toString.call(it).slice(8, -1);
  97. };
  98. var split = ''.split;
  99. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  100. var indexedObject = fails(function () {
  101. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  102. // eslint-disable-next-line no-prototype-builtins
  103. return !Object('z').propertyIsEnumerable(0);
  104. }) ? function (it) {
  105. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  106. } : Object;
  107. // `RequireObjectCoercible` abstract operation
  108. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  109. var requireObjectCoercible = function (it) {
  110. if (it == undefined) throw TypeError("Can't call method on " + it);
  111. return it;
  112. };
  113. // toObject with fallback for non-array-like ES3 strings
  114. var toIndexedObject = function (it) {
  115. return indexedObject(requireObjectCoercible(it));
  116. };
  117. var isObject = function (it) {
  118. return typeof it === 'object' ? it !== null : typeof it === 'function';
  119. };
  120. // `ToPrimitive` abstract operation
  121. // https://tc39.github.io/ecma262/#sec-toprimitive
  122. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  123. // and the second argument - flag - preferred type is a string
  124. var toPrimitive = function (input, PREFERRED_STRING) {
  125. if (!isObject(input)) return input;
  126. var fn, val;
  127. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  128. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
  129. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  130. throw TypeError("Can't convert object to primitive value");
  131. };
  132. var hasOwnProperty = {}.hasOwnProperty;
  133. var has = function (it, key) {
  134. return hasOwnProperty.call(it, key);
  135. };
  136. var document$1 = global_1.document;
  137. // typeof document.createElement is 'object' in old IE
  138. var EXISTS = isObject(document$1) && isObject(document$1.createElement);
  139. var documentCreateElement = function (it) {
  140. return EXISTS ? document$1.createElement(it) : {};
  141. };
  142. // Thank's IE8 for his funny defineProperty
  143. var ie8DomDefine = !descriptors && !fails(function () {
  144. return Object.defineProperty(documentCreateElement('div'), 'a', {
  145. get: function () { return 7; }
  146. }).a != 7;
  147. });
  148. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  149. // `Object.getOwnPropertyDescriptor` method
  150. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  151. var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  152. O = toIndexedObject(O);
  153. P = toPrimitive(P, true);
  154. if (ie8DomDefine) try {
  155. return nativeGetOwnPropertyDescriptor(O, P);
  156. } catch (error) { /* empty */ }
  157. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  158. };
  159. var objectGetOwnPropertyDescriptor = {
  160. f: f$1
  161. };
  162. var anObject = function (it) {
  163. if (!isObject(it)) {
  164. throw TypeError(String(it) + ' is not an object');
  165. } return it;
  166. };
  167. var nativeDefineProperty = Object.defineProperty;
  168. // `Object.defineProperty` method
  169. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  170. var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  171. anObject(O);
  172. P = toPrimitive(P, true);
  173. anObject(Attributes);
  174. if (ie8DomDefine) try {
  175. return nativeDefineProperty(O, P, Attributes);
  176. } catch (error) { /* empty */ }
  177. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  178. if ('value' in Attributes) O[P] = Attributes.value;
  179. return O;
  180. };
  181. var objectDefineProperty = {
  182. f: f$2
  183. };
  184. var createNonEnumerableProperty = descriptors ? function (object, key, value) {
  185. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  186. } : function (object, key, value) {
  187. object[key] = value;
  188. return object;
  189. };
  190. var setGlobal = function (key, value) {
  191. try {
  192. createNonEnumerableProperty(global_1, key, value);
  193. } catch (error) {
  194. global_1[key] = value;
  195. } return value;
  196. };
  197. var SHARED = '__core-js_shared__';
  198. var store = global_1[SHARED] || setGlobal(SHARED, {});
  199. var sharedStore = store;
  200. var functionToString = Function.toString;
  201. // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
  202. if (typeof sharedStore.inspectSource != 'function') {
  203. sharedStore.inspectSource = function (it) {
  204. return functionToString.call(it);
  205. };
  206. }
  207. var inspectSource = sharedStore.inspectSource;
  208. var WeakMap$1 = global_1.WeakMap;
  209. var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(inspectSource(WeakMap$1));
  210. var isPure = false;
  211. var shared = createCommonjsModule(function (module) {
  212. (module.exports = function (key, value) {
  213. return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
  214. })('versions', []).push({
  215. version: '3.6.5',
  216. mode: 'global',
  217. copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
  218. });
  219. });
  220. var id = 0;
  221. var postfix = Math.random();
  222. var uid = function (key) {
  223. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  224. };
  225. var keys = shared('keys');
  226. var sharedKey = function (key) {
  227. return keys[key] || (keys[key] = uid(key));
  228. };
  229. var hiddenKeys = {};
  230. var WeakMap$2 = global_1.WeakMap;
  231. var set, get, has$1;
  232. var enforce = function (it) {
  233. return has$1(it) ? get(it) : set(it, {});
  234. };
  235. var getterFor = function (TYPE) {
  236. return function (it) {
  237. var state;
  238. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  239. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  240. } return state;
  241. };
  242. };
  243. if (nativeWeakMap) {
  244. var store$1 = new WeakMap$2();
  245. var wmget = store$1.get;
  246. var wmhas = store$1.has;
  247. var wmset = store$1.set;
  248. set = function (it, metadata) {
  249. wmset.call(store$1, it, metadata);
  250. return metadata;
  251. };
  252. get = function (it) {
  253. return wmget.call(store$1, it) || {};
  254. };
  255. has$1 = function (it) {
  256. return wmhas.call(store$1, it);
  257. };
  258. } else {
  259. var STATE = sharedKey('state');
  260. hiddenKeys[STATE] = true;
  261. set = function (it, metadata) {
  262. createNonEnumerableProperty(it, STATE, metadata);
  263. return metadata;
  264. };
  265. get = function (it) {
  266. return has(it, STATE) ? it[STATE] : {};
  267. };
  268. has$1 = function (it) {
  269. return has(it, STATE);
  270. };
  271. }
  272. var internalState = {
  273. set: set,
  274. get: get,
  275. has: has$1,
  276. enforce: enforce,
  277. getterFor: getterFor
  278. };
  279. var redefine = createCommonjsModule(function (module) {
  280. var getInternalState = internalState.get;
  281. var enforceInternalState = internalState.enforce;
  282. var TEMPLATE = String(String).split('String');
  283. (module.exports = function (O, key, value, options) {
  284. var unsafe = options ? !!options.unsafe : false;
  285. var simple = options ? !!options.enumerable : false;
  286. var noTargetGet = options ? !!options.noTargetGet : false;
  287. if (typeof value == 'function') {
  288. if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
  289. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  290. }
  291. if (O === global_1) {
  292. if (simple) O[key] = value;
  293. else setGlobal(key, value);
  294. return;
  295. } else if (!unsafe) {
  296. delete O[key];
  297. } else if (!noTargetGet && O[key]) {
  298. simple = true;
  299. }
  300. if (simple) O[key] = value;
  301. else createNonEnumerableProperty(O, key, value);
  302. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  303. })(Function.prototype, 'toString', function toString() {
  304. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  305. });
  306. });
  307. var path = global_1;
  308. var aFunction = function (variable) {
  309. return typeof variable == 'function' ? variable : undefined;
  310. };
  311. var getBuiltIn = function (namespace, method) {
  312. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
  313. : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
  314. };
  315. var ceil = Math.ceil;
  316. var floor = Math.floor;
  317. // `ToInteger` abstract operation
  318. // https://tc39.github.io/ecma262/#sec-tointeger
  319. var toInteger = function (argument) {
  320. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  321. };
  322. var min = Math.min;
  323. // `ToLength` abstract operation
  324. // https://tc39.github.io/ecma262/#sec-tolength
  325. var toLength = function (argument) {
  326. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  327. };
  328. var max = Math.max;
  329. var min$1 = Math.min;
  330. // Helper for a popular repeating case of the spec:
  331. // Let integer be ? ToInteger(index).
  332. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  333. var toAbsoluteIndex = function (index, length) {
  334. var integer = toInteger(index);
  335. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  336. };
  337. // `Array.prototype.{ indexOf, includes }` methods implementation
  338. var createMethod = function (IS_INCLUDES) {
  339. return function ($this, el, fromIndex) {
  340. var O = toIndexedObject($this);
  341. var length = toLength(O.length);
  342. var index = toAbsoluteIndex(fromIndex, length);
  343. var value;
  344. // Array#includes uses SameValueZero equality algorithm
  345. // eslint-disable-next-line no-self-compare
  346. if (IS_INCLUDES && el != el) while (length > index) {
  347. value = O[index++];
  348. // eslint-disable-next-line no-self-compare
  349. if (value != value) return true;
  350. // Array#indexOf ignores holes, Array#includes - not
  351. } else for (;length > index; index++) {
  352. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  353. } return !IS_INCLUDES && -1;
  354. };
  355. };
  356. var arrayIncludes = {
  357. // `Array.prototype.includes` method
  358. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  359. includes: createMethod(true),
  360. // `Array.prototype.indexOf` method
  361. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  362. indexOf: createMethod(false)
  363. };
  364. var indexOf = arrayIncludes.indexOf;
  365. var objectKeysInternal = function (object, names) {
  366. var O = toIndexedObject(object);
  367. var i = 0;
  368. var result = [];
  369. var key;
  370. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  371. // Don't enum bug & hidden keys
  372. while (names.length > i) if (has(O, key = names[i++])) {
  373. ~indexOf(result, key) || result.push(key);
  374. }
  375. return result;
  376. };
  377. // IE8- don't enum bug keys
  378. var enumBugKeys = [
  379. 'constructor',
  380. 'hasOwnProperty',
  381. 'isPrototypeOf',
  382. 'propertyIsEnumerable',
  383. 'toLocaleString',
  384. 'toString',
  385. 'valueOf'
  386. ];
  387. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  388. // `Object.getOwnPropertyNames` method
  389. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  390. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  391. return objectKeysInternal(O, hiddenKeys$1);
  392. };
  393. var objectGetOwnPropertyNames = {
  394. f: f$3
  395. };
  396. var f$4 = Object.getOwnPropertySymbols;
  397. var objectGetOwnPropertySymbols = {
  398. f: f$4
  399. };
  400. // all object keys, includes non-enumerable and symbols
  401. var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  402. var keys = objectGetOwnPropertyNames.f(anObject(it));
  403. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  404. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  405. };
  406. var copyConstructorProperties = function (target, source) {
  407. var keys = ownKeys(source);
  408. var defineProperty = objectDefineProperty.f;
  409. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  410. for (var i = 0; i < keys.length; i++) {
  411. var key = keys[i];
  412. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  413. }
  414. };
  415. var replacement = /#|\.prototype\./;
  416. var isForced = function (feature, detection) {
  417. var value = data[normalize(feature)];
  418. return value == POLYFILL ? true
  419. : value == NATIVE ? false
  420. : typeof detection == 'function' ? fails(detection)
  421. : !!detection;
  422. };
  423. var normalize = isForced.normalize = function (string) {
  424. return String(string).replace(replacement, '.').toLowerCase();
  425. };
  426. var data = isForced.data = {};
  427. var NATIVE = isForced.NATIVE = 'N';
  428. var POLYFILL = isForced.POLYFILL = 'P';
  429. var isForced_1 = isForced;
  430. var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  431. /*
  432. options.target - name of the target object
  433. options.global - target is the global object
  434. options.stat - export as static methods of target
  435. options.proto - export as prototype methods of target
  436. options.real - real prototype method for the `pure` version
  437. options.forced - export even if the native feature is available
  438. options.bind - bind methods to the target, required for the `pure` version
  439. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  440. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  441. options.sham - add a flag to not completely full polyfills
  442. options.enumerable - export as enumerable property
  443. options.noTargetGet - prevent calling a getter on target
  444. */
  445. var _export = function (options, source) {
  446. var TARGET = options.target;
  447. var GLOBAL = options.global;
  448. var STATIC = options.stat;
  449. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  450. if (GLOBAL) {
  451. target = global_1;
  452. } else if (STATIC) {
  453. target = global_1[TARGET] || setGlobal(TARGET, {});
  454. } else {
  455. target = (global_1[TARGET] || {}).prototype;
  456. }
  457. if (target) for (key in source) {
  458. sourceProperty = source[key];
  459. if (options.noTargetGet) {
  460. descriptor = getOwnPropertyDescriptor$1(target, key);
  461. targetProperty = descriptor && descriptor.value;
  462. } else targetProperty = target[key];
  463. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  464. // contained in target
  465. if (!FORCED && targetProperty !== undefined) {
  466. if (typeof sourceProperty === typeof targetProperty) continue;
  467. copyConstructorProperties(sourceProperty, targetProperty);
  468. }
  469. // add a flag to not completely full polyfills
  470. if (options.sham || (targetProperty && targetProperty.sham)) {
  471. createNonEnumerableProperty(sourceProperty, 'sham', true);
  472. }
  473. // extend global
  474. redefine(target, key, sourceProperty, options);
  475. }
  476. };
  477. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
  478. // Chrome 38 Symbol has incorrect toString conversion
  479. // eslint-disable-next-line no-undef
  480. return !String(Symbol());
  481. });
  482. var useSymbolAsUid = nativeSymbol
  483. // eslint-disable-next-line no-undef
  484. && !Symbol.sham
  485. // eslint-disable-next-line no-undef
  486. && typeof Symbol.iterator == 'symbol';
  487. // `IsArray` abstract operation
  488. // https://tc39.github.io/ecma262/#sec-isarray
  489. var isArray = Array.isArray || function isArray(arg) {
  490. return classofRaw(arg) == 'Array';
  491. };
  492. // `ToObject` abstract operation
  493. // https://tc39.github.io/ecma262/#sec-toobject
  494. var toObject = function (argument) {
  495. return Object(requireObjectCoercible(argument));
  496. };
  497. // `Object.keys` method
  498. // https://tc39.github.io/ecma262/#sec-object.keys
  499. var objectKeys = Object.keys || function keys(O) {
  500. return objectKeysInternal(O, enumBugKeys);
  501. };
  502. // `Object.defineProperties` method
  503. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  504. var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  505. anObject(O);
  506. var keys = objectKeys(Properties);
  507. var length = keys.length;
  508. var index = 0;
  509. var key;
  510. while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
  511. return O;
  512. };
  513. var html = getBuiltIn('document', 'documentElement');
  514. var GT = '>';
  515. var LT = '<';
  516. var PROTOTYPE = 'prototype';
  517. var SCRIPT = 'script';
  518. var IE_PROTO = sharedKey('IE_PROTO');
  519. var EmptyConstructor = function () { /* empty */ };
  520. var scriptTag = function (content) {
  521. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  522. };
  523. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  524. var NullProtoObjectViaActiveX = function (activeXDocument) {
  525. activeXDocument.write(scriptTag(''));
  526. activeXDocument.close();
  527. var temp = activeXDocument.parentWindow.Object;
  528. activeXDocument = null; // avoid memory leak
  529. return temp;
  530. };
  531. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  532. var NullProtoObjectViaIFrame = function () {
  533. // Thrash, waste and sodomy: IE GC bug
  534. var iframe = documentCreateElement('iframe');
  535. var JS = 'java' + SCRIPT + ':';
  536. var iframeDocument;
  537. iframe.style.display = 'none';
  538. html.appendChild(iframe);
  539. // https://github.com/zloirock/core-js/issues/475
  540. iframe.src = String(JS);
  541. iframeDocument = iframe.contentWindow.document;
  542. iframeDocument.open();
  543. iframeDocument.write(scriptTag('document.F=Object'));
  544. iframeDocument.close();
  545. return iframeDocument.F;
  546. };
  547. // Check for document.domain and active x support
  548. // No need to use active x approach when document.domain is not set
  549. // see https://github.com/es-shims/es5-shim/issues/150
  550. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  551. // avoid IE GC bug
  552. var activeXDocument;
  553. var NullProtoObject = function () {
  554. try {
  555. /* global ActiveXObject */
  556. activeXDocument = document.domain && new ActiveXObject('htmlfile');
  557. } catch (error) { /* ignore */ }
  558. NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
  559. var length = enumBugKeys.length;
  560. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  561. return NullProtoObject();
  562. };
  563. hiddenKeys[IE_PROTO] = true;
  564. // `Object.create` method
  565. // https://tc39.github.io/ecma262/#sec-object.create
  566. var objectCreate = Object.create || function create(O, Properties) {
  567. var result;
  568. if (O !== null) {
  569. EmptyConstructor[PROTOTYPE] = anObject(O);
  570. result = new EmptyConstructor();
  571. EmptyConstructor[PROTOTYPE] = null;
  572. // add "__proto__" for Object.getPrototypeOf polyfill
  573. result[IE_PROTO] = O;
  574. } else result = NullProtoObject();
  575. return Properties === undefined ? result : objectDefineProperties(result, Properties);
  576. };
  577. var nativeGetOwnPropertyNames = objectGetOwnPropertyNames.f;
  578. var toString$1 = {}.toString;
  579. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  580. ? Object.getOwnPropertyNames(window) : [];
  581. var getWindowNames = function (it) {
  582. try {
  583. return nativeGetOwnPropertyNames(it);
  584. } catch (error) {
  585. return windowNames.slice();
  586. }
  587. };
  588. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  589. var f$5 = function getOwnPropertyNames(it) {
  590. return windowNames && toString$1.call(it) == '[object Window]'
  591. ? getWindowNames(it)
  592. : nativeGetOwnPropertyNames(toIndexedObject(it));
  593. };
  594. var objectGetOwnPropertyNamesExternal = {
  595. f: f$5
  596. };
  597. var WellKnownSymbolsStore = shared('wks');
  598. var Symbol$1 = global_1.Symbol;
  599. var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
  600. var wellKnownSymbol = function (name) {
  601. if (!has(WellKnownSymbolsStore, name)) {
  602. if (nativeSymbol && has(Symbol$1, name)) WellKnownSymbolsStore[name] = Symbol$1[name];
  603. else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  604. } return WellKnownSymbolsStore[name];
  605. };
  606. var f$6 = wellKnownSymbol;
  607. var wellKnownSymbolWrapped = {
  608. f: f$6
  609. };
  610. var defineProperty = objectDefineProperty.f;
  611. var defineWellKnownSymbol = function (NAME) {
  612. var Symbol = path.Symbol || (path.Symbol = {});
  613. if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
  614. value: wellKnownSymbolWrapped.f(NAME)
  615. });
  616. };
  617. var defineProperty$1 = objectDefineProperty.f;
  618. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  619. var setToStringTag = function (it, TAG, STATIC) {
  620. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  621. defineProperty$1(it, TO_STRING_TAG, { configurable: true, value: TAG });
  622. }
  623. };
  624. var aFunction$1 = function (it) {
  625. if (typeof it != 'function') {
  626. throw TypeError(String(it) + ' is not a function');
  627. } return it;
  628. };
  629. // optional / simple context binding
  630. var functionBindContext = function (fn, that, length) {
  631. aFunction$1(fn);
  632. if (that === undefined) return fn;
  633. switch (length) {
  634. case 0: return function () {
  635. return fn.call(that);
  636. };
  637. case 1: return function (a) {
  638. return fn.call(that, a);
  639. };
  640. case 2: return function (a, b) {
  641. return fn.call(that, a, b);
  642. };
  643. case 3: return function (a, b, c) {
  644. return fn.call(that, a, b, c);
  645. };
  646. }
  647. return function (/* ...args */) {
  648. return fn.apply(that, arguments);
  649. };
  650. };
  651. var SPECIES = wellKnownSymbol('species');
  652. // `ArraySpeciesCreate` abstract operation
  653. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  654. var arraySpeciesCreate = function (originalArray, length) {
  655. var C;
  656. if (isArray(originalArray)) {
  657. C = originalArray.constructor;
  658. // cross-realm fallback
  659. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  660. else if (isObject(C)) {
  661. C = C[SPECIES];
  662. if (C === null) C = undefined;
  663. }
  664. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  665. };
  666. var push = [].push;
  667. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  668. var createMethod$1 = function (TYPE) {
  669. var IS_MAP = TYPE == 1;
  670. var IS_FILTER = TYPE == 2;
  671. var IS_SOME = TYPE == 3;
  672. var IS_EVERY = TYPE == 4;
  673. var IS_FIND_INDEX = TYPE == 6;
  674. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  675. return function ($this, callbackfn, that, specificCreate) {
  676. var O = toObject($this);
  677. var self = indexedObject(O);
  678. var boundFunction = functionBindContext(callbackfn, that, 3);
  679. var length = toLength(self.length);
  680. var index = 0;
  681. var create = specificCreate || arraySpeciesCreate;
  682. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  683. var value, result;
  684. for (;length > index; index++) if (NO_HOLES || index in self) {
  685. value = self[index];
  686. result = boundFunction(value, index, O);
  687. if (TYPE) {
  688. if (IS_MAP) target[index] = result; // map
  689. else if (result) switch (TYPE) {
  690. case 3: return true; // some
  691. case 5: return value; // find
  692. case 6: return index; // findIndex
  693. case 2: push.call(target, value); // filter
  694. } else if (IS_EVERY) return false; // every
  695. }
  696. }
  697. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  698. };
  699. };
  700. var arrayIteration = {
  701. // `Array.prototype.forEach` method
  702. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  703. forEach: createMethod$1(0),
  704. // `Array.prototype.map` method
  705. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  706. map: createMethod$1(1),
  707. // `Array.prototype.filter` method
  708. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  709. filter: createMethod$1(2),
  710. // `Array.prototype.some` method
  711. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  712. some: createMethod$1(3),
  713. // `Array.prototype.every` method
  714. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  715. every: createMethod$1(4),
  716. // `Array.prototype.find` method
  717. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  718. find: createMethod$1(5),
  719. // `Array.prototype.findIndex` method
  720. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  721. findIndex: createMethod$1(6)
  722. };
  723. var $forEach = arrayIteration.forEach;
  724. var HIDDEN = sharedKey('hidden');
  725. var SYMBOL = 'Symbol';
  726. var PROTOTYPE$1 = 'prototype';
  727. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  728. var setInternalState = internalState.set;
  729. var getInternalState = internalState.getterFor(SYMBOL);
  730. var ObjectPrototype = Object[PROTOTYPE$1];
  731. var $Symbol = global_1.Symbol;
  732. var $stringify = getBuiltIn('JSON', 'stringify');
  733. var nativeGetOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  734. var nativeDefineProperty$1 = objectDefineProperty.f;
  735. var nativeGetOwnPropertyNames$1 = objectGetOwnPropertyNamesExternal.f;
  736. var nativePropertyIsEnumerable$1 = objectPropertyIsEnumerable.f;
  737. var AllSymbols = shared('symbols');
  738. var ObjectPrototypeSymbols = shared('op-symbols');
  739. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  740. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  741. var WellKnownSymbolsStore$1 = shared('wks');
  742. var QObject = global_1.QObject;
  743. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  744. var USE_SETTER = !QObject || !QObject[PROTOTYPE$1] || !QObject[PROTOTYPE$1].findChild;
  745. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  746. var setSymbolDescriptor = descriptors && fails(function () {
  747. return objectCreate(nativeDefineProperty$1({}, 'a', {
  748. get: function () { return nativeDefineProperty$1(this, 'a', { value: 7 }).a; }
  749. })).a != 7;
  750. }) ? function (O, P, Attributes) {
  751. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$1(ObjectPrototype, P);
  752. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  753. nativeDefineProperty$1(O, P, Attributes);
  754. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  755. nativeDefineProperty$1(ObjectPrototype, P, ObjectPrototypeDescriptor);
  756. }
  757. } : nativeDefineProperty$1;
  758. var wrap = function (tag, description) {
  759. var symbol = AllSymbols[tag] = objectCreate($Symbol[PROTOTYPE$1]);
  760. setInternalState(symbol, {
  761. type: SYMBOL,
  762. tag: tag,
  763. description: description
  764. });
  765. if (!descriptors) symbol.description = description;
  766. return symbol;
  767. };
  768. var isSymbol = useSymbolAsUid ? function (it) {
  769. return typeof it == 'symbol';
  770. } : function (it) {
  771. return Object(it) instanceof $Symbol;
  772. };
  773. var $defineProperty = function defineProperty(O, P, Attributes) {
  774. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  775. anObject(O);
  776. var key = toPrimitive(P, true);
  777. anObject(Attributes);
  778. if (has(AllSymbols, key)) {
  779. if (!Attributes.enumerable) {
  780. if (!has(O, HIDDEN)) nativeDefineProperty$1(O, HIDDEN, createPropertyDescriptor(1, {}));
  781. O[HIDDEN][key] = true;
  782. } else {
  783. if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  784. Attributes = objectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  785. } return setSymbolDescriptor(O, key, Attributes);
  786. } return nativeDefineProperty$1(O, key, Attributes);
  787. };
  788. var $defineProperties = function defineProperties(O, Properties) {
  789. anObject(O);
  790. var properties = toIndexedObject(Properties);
  791. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  792. $forEach(keys, function (key) {
  793. if (!descriptors || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
  794. });
  795. return O;
  796. };
  797. var $create = function create(O, Properties) {
  798. return Properties === undefined ? objectCreate(O) : $defineProperties(objectCreate(O), Properties);
  799. };
  800. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  801. var P = toPrimitive(V, true);
  802. var enumerable = nativePropertyIsEnumerable$1.call(this, P);
  803. if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;
  804. return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
  805. };
  806. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  807. var it = toIndexedObject(O);
  808. var key = toPrimitive(P, true);
  809. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
  810. var descriptor = nativeGetOwnPropertyDescriptor$1(it, key);
  811. if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
  812. descriptor.enumerable = true;
  813. }
  814. return descriptor;
  815. };
  816. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  817. var names = nativeGetOwnPropertyNames$1(toIndexedObject(O));
  818. var result = [];
  819. $forEach(names, function (key) {
  820. if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);
  821. });
  822. return result;
  823. };
  824. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  825. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  826. var names = nativeGetOwnPropertyNames$1(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  827. var result = [];
  828. $forEach(names, function (key) {
  829. if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
  830. result.push(AllSymbols[key]);
  831. }
  832. });
  833. return result;
  834. };
  835. // `Symbol` constructor
  836. // https://tc39.github.io/ecma262/#sec-symbol-constructor
  837. if (!nativeSymbol) {
  838. $Symbol = function Symbol() {
  839. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
  840. var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
  841. var tag = uid(description);
  842. var setter = function (value) {
  843. if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
  844. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  845. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  846. };
  847. if (descriptors && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  848. return wrap(tag, description);
  849. };
  850. redefine($Symbol[PROTOTYPE$1], 'toString', function toString() {
  851. return getInternalState(this).tag;
  852. });
  853. redefine($Symbol, 'withoutSetter', function (description) {
  854. return wrap(uid(description), description);
  855. });
  856. objectPropertyIsEnumerable.f = $propertyIsEnumerable;
  857. objectDefineProperty.f = $defineProperty;
  858. objectGetOwnPropertyDescriptor.f = $getOwnPropertyDescriptor;
  859. objectGetOwnPropertyNames.f = objectGetOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  860. objectGetOwnPropertySymbols.f = $getOwnPropertySymbols;
  861. wellKnownSymbolWrapped.f = function (name) {
  862. return wrap(wellKnownSymbol(name), name);
  863. };
  864. if (descriptors) {
  865. // https://github.com/tc39/proposal-Symbol-description
  866. nativeDefineProperty$1($Symbol[PROTOTYPE$1], 'description', {
  867. configurable: true,
  868. get: function description() {
  869. return getInternalState(this).description;
  870. }
  871. });
  872. {
  873. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  874. }
  875. }
  876. }
  877. _export({ global: true, wrap: true, forced: !nativeSymbol, sham: !nativeSymbol }, {
  878. Symbol: $Symbol
  879. });
  880. $forEach(objectKeys(WellKnownSymbolsStore$1), function (name) {
  881. defineWellKnownSymbol(name);
  882. });
  883. _export({ target: SYMBOL, stat: true, forced: !nativeSymbol }, {
  884. // `Symbol.for` method
  885. // https://tc39.github.io/ecma262/#sec-symbol.for
  886. 'for': function (key) {
  887. var string = String(key);
  888. if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  889. var symbol = $Symbol(string);
  890. StringToSymbolRegistry[string] = symbol;
  891. SymbolToStringRegistry[symbol] = string;
  892. return symbol;
  893. },
  894. // `Symbol.keyFor` method
  895. // https://tc39.github.io/ecma262/#sec-symbol.keyfor
  896. keyFor: function keyFor(sym) {
  897. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
  898. if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  899. },
  900. useSetter: function () { USE_SETTER = true; },
  901. useSimple: function () { USE_SETTER = false; }
  902. });
  903. _export({ target: 'Object', stat: true, forced: !nativeSymbol, sham: !descriptors }, {
  904. // `Object.create` method
  905. // https://tc39.github.io/ecma262/#sec-object.create
  906. create: $create,
  907. // `Object.defineProperty` method
  908. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  909. defineProperty: $defineProperty,
  910. // `Object.defineProperties` method
  911. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  912. defineProperties: $defineProperties,
  913. // `Object.getOwnPropertyDescriptor` method
  914. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  915. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  916. });
  917. _export({ target: 'Object', stat: true, forced: !nativeSymbol }, {
  918. // `Object.getOwnPropertyNames` method
  919. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  920. getOwnPropertyNames: $getOwnPropertyNames,
  921. // `Object.getOwnPropertySymbols` method
  922. // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
  923. getOwnPropertySymbols: $getOwnPropertySymbols
  924. });
  925. // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  926. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  927. _export({ target: 'Object', stat: true, forced: fails(function () { objectGetOwnPropertySymbols.f(1); }) }, {
  928. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  929. return objectGetOwnPropertySymbols.f(toObject(it));
  930. }
  931. });
  932. // `JSON.stringify` method behavior with symbols
  933. // https://tc39.github.io/ecma262/#sec-json.stringify
  934. if ($stringify) {
  935. var FORCED_JSON_STRINGIFY = !nativeSymbol || fails(function () {
  936. var symbol = $Symbol();
  937. // MS Edge converts symbol values to JSON as {}
  938. return $stringify([symbol]) != '[null]'
  939. // WebKit converts symbol values to JSON as null
  940. || $stringify({ a: symbol }) != '{}'
  941. // V8 throws on boxed symbols
  942. || $stringify(Object(symbol)) != '{}';
  943. });
  944. _export({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
  945. // eslint-disable-next-line no-unused-vars
  946. stringify: function stringify(it, replacer, space) {
  947. var args = [it];
  948. var index = 1;
  949. var $replacer;
  950. while (arguments.length > index) args.push(arguments[index++]);
  951. $replacer = replacer;
  952. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  953. if (!isArray(replacer)) replacer = function (key, value) {
  954. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  955. if (!isSymbol(value)) return value;
  956. };
  957. args[1] = replacer;
  958. return $stringify.apply(null, args);
  959. }
  960. });
  961. }
  962. // `Symbol.prototype[@@toPrimitive]` method
  963. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
  964. if (!$Symbol[PROTOTYPE$1][TO_PRIMITIVE]) {
  965. createNonEnumerableProperty($Symbol[PROTOTYPE$1], TO_PRIMITIVE, $Symbol[PROTOTYPE$1].valueOf);
  966. }
  967. // `Symbol.prototype[@@toStringTag]` property
  968. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
  969. setToStringTag($Symbol, SYMBOL);
  970. hiddenKeys[HIDDEN] = true;
  971. var defineProperty$2 = objectDefineProperty.f;
  972. var NativeSymbol = global_1.Symbol;
  973. if (descriptors && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
  974. // Safari 12 bug
  975. NativeSymbol().description !== undefined
  976. )) {
  977. var EmptyStringDescriptionStore = {};
  978. // wrap Symbol constructor for correct work with undefined description
  979. var SymbolWrapper = function Symbol() {
  980. var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
  981. var result = this instanceof SymbolWrapper
  982. ? new NativeSymbol(description)
  983. // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
  984. : description === undefined ? NativeSymbol() : NativeSymbol(description);
  985. if (description === '') EmptyStringDescriptionStore[result] = true;
  986. return result;
  987. };
  988. copyConstructorProperties(SymbolWrapper, NativeSymbol);
  989. var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
  990. symbolPrototype.constructor = SymbolWrapper;
  991. var symbolToString = symbolPrototype.toString;
  992. var native = String(NativeSymbol('test')) == 'Symbol(test)';
  993. var regexp = /^Symbol\((.*)\)[^)]+$/;
  994. defineProperty$2(symbolPrototype, 'description', {
  995. configurable: true,
  996. get: function description() {
  997. var symbol = isObject(this) ? this.valueOf() : this;
  998. var string = symbolToString.call(symbol);
  999. if (has(EmptyStringDescriptionStore, symbol)) return '';
  1000. var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
  1001. return desc === '' ? undefined : desc;
  1002. }
  1003. });
  1004. _export({ global: true, forced: true }, {
  1005. Symbol: SymbolWrapper
  1006. });
  1007. }
  1008. // `Symbol.iterator` well-known symbol
  1009. // https://tc39.github.io/ecma262/#sec-symbol.iterator
  1010. defineWellKnownSymbol('iterator');
  1011. var arrayMethodIsStrict = function (METHOD_NAME, argument) {
  1012. var method = [][METHOD_NAME];
  1013. return !!method && fails(function () {
  1014. // eslint-disable-next-line no-useless-call,no-throw-literal
  1015. method.call(null, argument || function () { throw 1; }, 1);
  1016. });
  1017. };
  1018. var defineProperty$3 = Object.defineProperty;
  1019. var cache = {};
  1020. var thrower = function (it) { throw it; };
  1021. var arrayMethodUsesToLength = function (METHOD_NAME, options) {
  1022. if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
  1023. if (!options) options = {};
  1024. var method = [][METHOD_NAME];
  1025. var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
  1026. var argument0 = has(options, 0) ? options[0] : thrower;
  1027. var argument1 = has(options, 1) ? options[1] : undefined;
  1028. return cache[METHOD_NAME] = !!method && !fails(function () {
  1029. if (ACCESSORS && !descriptors) return true;
  1030. var O = { length: -1 };
  1031. if (ACCESSORS) defineProperty$3(O, 1, { enumerable: true, get: thrower });
  1032. else O[1] = 1;
  1033. method.call(O, argument0, argument1);
  1034. });
  1035. };
  1036. var $forEach$1 = arrayIteration.forEach;
  1037. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  1038. var USES_TO_LENGTH = arrayMethodUsesToLength('forEach');
  1039. // `Array.prototype.forEach` method implementation
  1040. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  1041. var arrayForEach = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) {
  1042. return $forEach$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  1043. } : [].forEach;
  1044. // `Array.prototype.forEach` method
  1045. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  1046. _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, {
  1047. forEach: arrayForEach
  1048. });
  1049. var $indexOf = arrayIncludes.indexOf;
  1050. var nativeIndexOf = [].indexOf;
  1051. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
  1052. var STRICT_METHOD$1 = arrayMethodIsStrict('indexOf');
  1053. var USES_TO_LENGTH$1 = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  1054. // `Array.prototype.indexOf` method
  1055. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  1056. _export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD$1 || !USES_TO_LENGTH$1 }, {
  1057. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  1058. return NEGATIVE_ZERO
  1059. // convert -0 to +0
  1060. ? nativeIndexOf.apply(this, arguments) || 0
  1061. : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
  1062. }
  1063. });
  1064. var UNSCOPABLES = wellKnownSymbol('unscopables');
  1065. var ArrayPrototype = Array.prototype;
  1066. // Array.prototype[@@unscopables]
  1067. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  1068. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  1069. objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, {
  1070. configurable: true,
  1071. value: objectCreate(null)
  1072. });
  1073. }
  1074. // add a key to Array.prototype[@@unscopables]
  1075. var addToUnscopables = function (key) {
  1076. ArrayPrototype[UNSCOPABLES][key] = true;
  1077. };
  1078. var iterators = {};
  1079. var correctPrototypeGetter = !fails(function () {
  1080. function F() { /* empty */ }
  1081. F.prototype.constructor = null;
  1082. return Object.getPrototypeOf(new F()) !== F.prototype;
  1083. });
  1084. var IE_PROTO$1 = sharedKey('IE_PROTO');
  1085. var ObjectPrototype$1 = Object.prototype;
  1086. // `Object.getPrototypeOf` method
  1087. // https://tc39.github.io/ecma262/#sec-object.getprototypeof
  1088. var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
  1089. O = toObject(O);
  1090. if (has(O, IE_PROTO$1)) return O[IE_PROTO$1];
  1091. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1092. return O.constructor.prototype;
  1093. } return O instanceof Object ? ObjectPrototype$1 : null;
  1094. };
  1095. var ITERATOR = wellKnownSymbol('iterator');
  1096. var BUGGY_SAFARI_ITERATORS = false;
  1097. var returnThis = function () { return this; };
  1098. // `%IteratorPrototype%` object
  1099. // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
  1100. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  1101. if ([].keys) {
  1102. arrayIterator = [].keys();
  1103. // Safari 8 has buggy iterators w/o `next`
  1104. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  1105. else {
  1106. PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
  1107. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  1108. }
  1109. }
  1110. if (IteratorPrototype == undefined) IteratorPrototype = {};
  1111. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  1112. if ( !has(IteratorPrototype, ITERATOR)) {
  1113. createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
  1114. }
  1115. var iteratorsCore = {
  1116. IteratorPrototype: IteratorPrototype,
  1117. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  1118. };
  1119. var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
  1120. var returnThis$1 = function () { return this; };
  1121. var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
  1122. var TO_STRING_TAG = NAME + ' Iterator';
  1123. IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
  1124. setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
  1125. iterators[TO_STRING_TAG] = returnThis$1;
  1126. return IteratorConstructor;
  1127. };
  1128. var aPossiblePrototype = function (it) {
  1129. if (!isObject(it) && it !== null) {
  1130. throw TypeError("Can't set " + String(it) + ' as a prototype');
  1131. } return it;
  1132. };
  1133. // `Object.setPrototypeOf` method
  1134. // https://tc39.github.io/ecma262/#sec-object.setprototypeof
  1135. // Works with __proto__ only. Old v8 can't work with null proto objects.
  1136. /* eslint-disable no-proto */
  1137. var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  1138. var CORRECT_SETTER = false;
  1139. var test = {};
  1140. var setter;
  1141. try {
  1142. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  1143. setter.call(test, []);
  1144. CORRECT_SETTER = test instanceof Array;
  1145. } catch (error) { /* empty */ }
  1146. return function setPrototypeOf(O, proto) {
  1147. anObject(O);
  1148. aPossiblePrototype(proto);
  1149. if (CORRECT_SETTER) setter.call(O, proto);
  1150. else O.__proto__ = proto;
  1151. return O;
  1152. };
  1153. }() : undefined);
  1154. var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
  1155. var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
  1156. var ITERATOR$1 = wellKnownSymbol('iterator');
  1157. var KEYS = 'keys';
  1158. var VALUES = 'values';
  1159. var ENTRIES = 'entries';
  1160. var returnThis$2 = function () { return this; };
  1161. var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  1162. createIteratorConstructor(IteratorConstructor, NAME, next);
  1163. var getIterationMethod = function (KIND) {
  1164. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  1165. if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
  1166. switch (KIND) {
  1167. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  1168. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  1169. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  1170. } return function () { return new IteratorConstructor(this); };
  1171. };
  1172. var TO_STRING_TAG = NAME + ' Iterator';
  1173. var INCORRECT_VALUES_NAME = false;
  1174. var IterablePrototype = Iterable.prototype;
  1175. var nativeIterator = IterablePrototype[ITERATOR$1]
  1176. || IterablePrototype['@@iterator']
  1177. || DEFAULT && IterablePrototype[DEFAULT];
  1178. var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
  1179. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  1180. var CurrentIteratorPrototype, methods, KEY;
  1181. // fix native
  1182. if (anyNativeIterator) {
  1183. CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
  1184. if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
  1185. if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) {
  1186. if (objectSetPrototypeOf) {
  1187. objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
  1188. } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') {
  1189. createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR$1, returnThis$2);
  1190. }
  1191. }
  1192. // Set @@toStringTag to native iterators
  1193. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
  1194. }
  1195. }
  1196. // fix Array#{values, @@iterator}.name in V8 / FF
  1197. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  1198. INCORRECT_VALUES_NAME = true;
  1199. defaultIterator = function values() { return nativeIterator.call(this); };
  1200. }
  1201. // define iterator
  1202. if ( IterablePrototype[ITERATOR$1] !== defaultIterator) {
  1203. createNonEnumerableProperty(IterablePrototype, ITERATOR$1, defaultIterator);
  1204. }
  1205. iterators[NAME] = defaultIterator;
  1206. // export additional methods
  1207. if (DEFAULT) {
  1208. methods = {
  1209. values: getIterationMethod(VALUES),
  1210. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  1211. entries: getIterationMethod(ENTRIES)
  1212. };
  1213. if (FORCED) for (KEY in methods) {
  1214. if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  1215. redefine(IterablePrototype, KEY, methods[KEY]);
  1216. }
  1217. } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
  1218. }
  1219. return methods;
  1220. };
  1221. var ARRAY_ITERATOR = 'Array Iterator';
  1222. var setInternalState$1 = internalState.set;
  1223. var getInternalState$1 = internalState.getterFor(ARRAY_ITERATOR);
  1224. // `Array.prototype.entries` method
  1225. // https://tc39.github.io/ecma262/#sec-array.prototype.entries
  1226. // `Array.prototype.keys` method
  1227. // https://tc39.github.io/ecma262/#sec-array.prototype.keys
  1228. // `Array.prototype.values` method
  1229. // https://tc39.github.io/ecma262/#sec-array.prototype.values
  1230. // `Array.prototype[@@iterator]` method
  1231. // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
  1232. // `CreateArrayIterator` internal method
  1233. // https://tc39.github.io/ecma262/#sec-createarrayiterator
  1234. var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
  1235. setInternalState$1(this, {
  1236. type: ARRAY_ITERATOR,
  1237. target: toIndexedObject(iterated), // target
  1238. index: 0, // next index
  1239. kind: kind // kind
  1240. });
  1241. // `%ArrayIteratorPrototype%.next` method
  1242. // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
  1243. }, function () {
  1244. var state = getInternalState$1(this);
  1245. var target = state.target;
  1246. var kind = state.kind;
  1247. var index = state.index++;
  1248. if (!target || index >= target.length) {
  1249. state.target = undefined;
  1250. return { value: undefined, done: true };
  1251. }
  1252. if (kind == 'keys') return { value: index, done: false };
  1253. if (kind == 'values') return { value: target[index], done: false };
  1254. return { value: [index, target[index]], done: false };
  1255. }, 'values');
  1256. // argumentsList[@@iterator] is %ArrayProto_values%
  1257. // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
  1258. // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
  1259. iterators.Arguments = iterators.Array;
  1260. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  1261. addToUnscopables('keys');
  1262. addToUnscopables('values');
  1263. addToUnscopables('entries');
  1264. var nativeJoin = [].join;
  1265. var ES3_STRINGS = indexedObject != Object;
  1266. var STRICT_METHOD$2 = arrayMethodIsStrict('join', ',');
  1267. // `Array.prototype.join` method
  1268. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  1269. _export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$2 }, {
  1270. join: function join(separator) {
  1271. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  1272. }
  1273. });
  1274. var createProperty = function (object, key, value) {
  1275. var propertyKey = toPrimitive(key);
  1276. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  1277. else object[propertyKey] = value;
  1278. };
  1279. var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
  1280. var process = global_1.process;
  1281. var versions = process && process.versions;
  1282. var v8 = versions && versions.v8;
  1283. var match, version;
  1284. if (v8) {
  1285. match = v8.split('.');
  1286. version = match[0] + match[1];
  1287. } else if (engineUserAgent) {
  1288. match = engineUserAgent.match(/Edge\/(\d+)/);
  1289. if (!match || match[1] >= 74) {
  1290. match = engineUserAgent.match(/Chrome\/(\d+)/);
  1291. if (match) version = match[1];
  1292. }
  1293. }
  1294. var engineV8Version = version && +version;
  1295. var SPECIES$1 = wellKnownSymbol('species');
  1296. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  1297. // We can't use this feature detection in V8 since it causes
  1298. // deoptimization and serious performance degradation
  1299. // https://github.com/zloirock/core-js/issues/677
  1300. return engineV8Version >= 51 || !fails(function () {
  1301. var array = [];
  1302. var constructor = array.constructor = {};
  1303. constructor[SPECIES$1] = function () {
  1304. return { foo: 1 };
  1305. };
  1306. return array[METHOD_NAME](Boolean).foo !== 1;
  1307. });
  1308. };
  1309. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  1310. var USES_TO_LENGTH$2 = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 });
  1311. var SPECIES$2 = wellKnownSymbol('species');
  1312. var nativeSlice = [].slice;
  1313. var max$1 = Math.max;
  1314. // `Array.prototype.slice` method
  1315. // https://tc39.github.io/ecma262/#sec-array.prototype.slice
  1316. // fallback for not array-like ES3 strings and DOM objects
  1317. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH$2 }, {
  1318. slice: function slice(start, end) {
  1319. var O = toIndexedObject(this);
  1320. var length = toLength(O.length);
  1321. var k = toAbsoluteIndex(start, length);
  1322. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  1323. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  1324. var Constructor, result, n;
  1325. if (isArray(O)) {
  1326. Constructor = O.constructor;
  1327. // cross-realm fallback
  1328. if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
  1329. Constructor = undefined;
  1330. } else if (isObject(Constructor)) {
  1331. Constructor = Constructor[SPECIES$2];
  1332. if (Constructor === null) Constructor = undefined;
  1333. }
  1334. if (Constructor === Array || Constructor === undefined) {
  1335. return nativeSlice.call(O, k, fin);
  1336. }
  1337. }
  1338. result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
  1339. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  1340. result.length = n;
  1341. return result;
  1342. }
  1343. });
  1344. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  1345. var test = {};
  1346. test[TO_STRING_TAG$1] = 'z';
  1347. var toStringTagSupport = String(test) === '[object z]';
  1348. var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
  1349. // ES3 wrong here
  1350. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  1351. // fallback for IE11 Script Access Denied error
  1352. var tryGet = function (it, key) {
  1353. try {
  1354. return it[key];
  1355. } catch (error) { /* empty */ }
  1356. };
  1357. // getting tag from ES6+ `Object.prototype.toString`
  1358. var classof = toStringTagSupport ? classofRaw : function (it) {
  1359. var O, tag, result;
  1360. return it === undefined ? 'Undefined' : it === null ? 'Null'
  1361. // @@toStringTag case
  1362. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$2)) == 'string' ? tag
  1363. // builtinTag case
  1364. : CORRECT_ARGUMENTS ? classofRaw(O)
  1365. // ES3 arguments fallback
  1366. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  1367. };
  1368. // `Object.prototype.toString` method implementation
  1369. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  1370. var objectToString = toStringTagSupport ? {}.toString : function toString() {
  1371. return '[object ' + classof(this) + ']';
  1372. };
  1373. // `Object.prototype.toString` method
  1374. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  1375. if (!toStringTagSupport) {
  1376. redefine(Object.prototype, 'toString', objectToString, { unsafe: true });
  1377. }
  1378. // `RegExp.prototype.flags` getter implementation
  1379. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  1380. var regexpFlags = function () {
  1381. var that = anObject(this);
  1382. var result = '';
  1383. if (that.global) result += 'g';
  1384. if (that.ignoreCase) result += 'i';
  1385. if (that.multiline) result += 'm';
  1386. if (that.dotAll) result += 's';
  1387. if (that.unicode) result += 'u';
  1388. if (that.sticky) result += 'y';
  1389. return result;
  1390. };
  1391. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
  1392. // so we use an intermediate function.
  1393. function RE(s, f) {
  1394. return RegExp(s, f);
  1395. }
  1396. var UNSUPPORTED_Y = fails(function () {
  1397. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  1398. var re = RE('a', 'y');
  1399. re.lastIndex = 2;
  1400. return re.exec('abcd') != null;
  1401. });
  1402. var BROKEN_CARET = fails(function () {
  1403. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  1404. var re = RE('^r', 'gy');
  1405. re.lastIndex = 2;
  1406. return re.exec('str') != null;
  1407. });
  1408. var regexpStickyHelpers = {
  1409. UNSUPPORTED_Y: UNSUPPORTED_Y,
  1410. BROKEN_CARET: BROKEN_CARET
  1411. };
  1412. var nativeExec = RegExp.prototype.exec;
  1413. // This always refers to the native implementation, because the
  1414. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  1415. // which loads this file before patching the method.
  1416. var nativeReplace = String.prototype.replace;
  1417. var patchedExec = nativeExec;
  1418. var UPDATES_LAST_INDEX_WRONG = (function () {
  1419. var re1 = /a/;
  1420. var re2 = /b*/g;
  1421. nativeExec.call(re1, 'a');
  1422. nativeExec.call(re2, 'a');
  1423. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  1424. })();
  1425. var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y || regexpStickyHelpers.BROKEN_CARET;
  1426. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  1427. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  1428. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1;
  1429. if (PATCH) {
  1430. patchedExec = function exec(str) {
  1431. var re = this;
  1432. var lastIndex, reCopy, match, i;
  1433. var sticky = UNSUPPORTED_Y$1 && re.sticky;
  1434. var flags = regexpFlags.call(re);
  1435. var source = re.source;
  1436. var charsAdded = 0;
  1437. var strCopy = str;
  1438. if (sticky) {
  1439. flags = flags.replace('y', '');
  1440. if (flags.indexOf('g') === -1) {
  1441. flags += 'g';
  1442. }
  1443. strCopy = String(str).slice(re.lastIndex);
  1444. // Support anchored sticky behavior.
  1445. if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\n')) {
  1446. source = '(?: ' + source + ')';
  1447. strCopy = ' ' + strCopy;
  1448. charsAdded++;
  1449. }
  1450. // ^(? + rx + ) is needed, in combination with some str slicing, to
  1451. // simulate the 'y' flag.
  1452. reCopy = new RegExp('^(?:' + source + ')', flags);
  1453. }
  1454. if (NPCG_INCLUDED) {
  1455. reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
  1456. }
  1457. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  1458. match = nativeExec.call(sticky ? reCopy : re, strCopy);
  1459. if (sticky) {
  1460. if (match) {
  1461. match.input = match.input.slice(charsAdded);
  1462. match[0] = match[0].slice(charsAdded);
  1463. match.index = re.lastIndex;
  1464. re.lastIndex += match[0].length;
  1465. } else re.lastIndex = 0;
  1466. } else if (UPDATES_LAST_INDEX_WRONG && match) {
  1467. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  1468. }
  1469. if (NPCG_INCLUDED && match && match.length > 1) {
  1470. // Fix browsers whose `exec` methods don't consistently return `undefined`
  1471. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  1472. nativeReplace.call(match[0], reCopy, function () {
  1473. for (i = 1; i < arguments.length - 2; i++) {
  1474. if (arguments[i] === undefined) match[i] = undefined;
  1475. }
  1476. });
  1477. }
  1478. return match;
  1479. };
  1480. }
  1481. var regexpExec = patchedExec;
  1482. _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
  1483. exec: regexpExec
  1484. });
  1485. var TO_STRING = 'toString';
  1486. var RegExpPrototype = RegExp.prototype;
  1487. var nativeToString = RegExpPrototype[TO_STRING];
  1488. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
  1489. // FF44- RegExp#toString has a wrong name
  1490. var INCORRECT_NAME = nativeToString.name != TO_STRING;
  1491. // `RegExp.prototype.toString` method
  1492. // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
  1493. if (NOT_GENERIC || INCORRECT_NAME) {
  1494. redefine(RegExp.prototype, TO_STRING, function toString() {
  1495. var R = anObject(this);
  1496. var p = String(R.source);
  1497. var rf = R.flags;
  1498. var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? regexpFlags.call(R) : rf);
  1499. return '/' + p + '/' + f;
  1500. }, { unsafe: true });
  1501. }
  1502. // `String.prototype.{ codePointAt, at }` methods implementation
  1503. var createMethod$2 = function (CONVERT_TO_STRING) {
  1504. return function ($this, pos) {
  1505. var S = String(requireObjectCoercible($this));
  1506. var position = toInteger(pos);
  1507. var size = S.length;
  1508. var first, second;
  1509. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  1510. first = S.charCodeAt(position);
  1511. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  1512. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  1513. ? CONVERT_TO_STRING ? S.charAt(position) : first
  1514. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  1515. };
  1516. };
  1517. var stringMultibyte = {
  1518. // `String.prototype.codePointAt` method
  1519. // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
  1520. codeAt: createMethod$2(false),
  1521. // `String.prototype.at` method
  1522. // https://github.com/mathiasbynens/String.prototype.at
  1523. charAt: createMethod$2(true)
  1524. };
  1525. var charAt = stringMultibyte.charAt;
  1526. var STRING_ITERATOR = 'String Iterator';
  1527. var setInternalState$2 = internalState.set;
  1528. var getInternalState$2 = internalState.getterFor(STRING_ITERATOR);
  1529. // `String.prototype[@@iterator]` method
  1530. // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
  1531. defineIterator(String, 'String', function (iterated) {
  1532. setInternalState$2(this, {
  1533. type: STRING_ITERATOR,
  1534. string: String(iterated),
  1535. index: 0
  1536. });
  1537. // `%StringIteratorPrototype%.next` method
  1538. // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
  1539. }, function next() {
  1540. var state = getInternalState$2(this);
  1541. var string = state.string;
  1542. var index = state.index;
  1543. var point;
  1544. if (index >= string.length) return { value: undefined, done: true };
  1545. point = charAt(string, index);
  1546. state.index += point.length;
  1547. return { value: point, done: false };
  1548. });
  1549. // TODO: Remove from `core-js@4` since it's moved to entry points
  1550. var SPECIES$3 = wellKnownSymbol('species');
  1551. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  1552. // #replace needs built-in support for named groups.
  1553. // #match works fine because it just return the exec results, even if it has
  1554. // a "grops" property.
  1555. var re = /./;
  1556. re.exec = function () {
  1557. var result = [];
  1558. result.groups = { a: '7' };
  1559. return result;
  1560. };
  1561. return ''.replace(re, '$<a>') !== '7';
  1562. });
  1563. // IE <= 11 replaces $0 with the whole match, as if it was $&
  1564. // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
  1565. var REPLACE_KEEPS_$0 = (function () {
  1566. return 'a'.replace(/./, '$0') === '$0';
  1567. })();
  1568. var REPLACE = wellKnownSymbol('replace');
  1569. // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
  1570. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
  1571. if (/./[REPLACE]) {
  1572. return /./[REPLACE]('a', '$0') === '';
  1573. }
  1574. return false;
  1575. })();
  1576. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  1577. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  1578. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  1579. var re = /(?:)/;
  1580. var originalExec = re.exec;
  1581. re.exec = function () { return originalExec.apply(this, arguments); };
  1582. var result = 'ab'.split(re);
  1583. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  1584. });
  1585. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  1586. var SYMBOL = wellKnownSymbol(KEY);
  1587. var DELEGATES_TO_SYMBOL = !fails(function () {
  1588. // String methods call symbol-named RegEp methods
  1589. var O = {};
  1590. O[SYMBOL] = function () { return 7; };
  1591. return ''[KEY](O) != 7;
  1592. });
  1593. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  1594. // Symbol-named RegExp methods call .exec
  1595. var execCalled = false;
  1596. var re = /a/;
  1597. if (KEY === 'split') {
  1598. // We can't use real regex here since it causes deoptimization
  1599. // and serious performance degradation in V8
  1600. // https://github.com/zloirock/core-js/issues/306
  1601. re = {};
  1602. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  1603. // a new one. We need to return the patched regex when creating the new one.
  1604. re.constructor = {};
  1605. re.constructor[SPECIES$3] = function () { return re; };
  1606. re.flags = '';
  1607. re[SYMBOL] = /./[SYMBOL];
  1608. }
  1609. re.exec = function () { execCalled = true; return null; };
  1610. re[SYMBOL]('');
  1611. return !execCalled;
  1612. });
  1613. if (
  1614. !DELEGATES_TO_SYMBOL ||
  1615. !DELEGATES_TO_EXEC ||
  1616. (KEY === 'replace' && !(
  1617. REPLACE_SUPPORTS_NAMED_GROUPS &&
  1618. REPLACE_KEEPS_$0 &&
  1619. !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
  1620. )) ||
  1621. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  1622. ) {
  1623. var nativeRegExpMethod = /./[SYMBOL];
  1624. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  1625. if (regexp.exec === regexpExec) {
  1626. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  1627. // The native String method already delegates to @@method (this
  1628. // polyfilled function), leasing to infinite recursion.
  1629. // We avoid it by directly calling the native @@method method.
  1630. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  1631. }
  1632. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  1633. }
  1634. return { done: false };
  1635. }, {
  1636. REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,
  1637. REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
  1638. });
  1639. var stringMethod = methods[0];
  1640. var regexMethod = methods[1];
  1641. redefine(String.prototype, KEY, stringMethod);
  1642. redefine(RegExp.prototype, SYMBOL, length == 2
  1643. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  1644. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  1645. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  1646. // 21.2.5.6 RegExp.prototype[@@match](string)
  1647. // 21.2.5.9 RegExp.prototype[@@search](string)
  1648. : function (string) { return regexMethod.call(string, this); }
  1649. );
  1650. }
  1651. if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);
  1652. };
  1653. var charAt$1 = stringMultibyte.charAt;
  1654. // `AdvanceStringIndex` abstract operation
  1655. // https://tc39.github.io/ecma262/#sec-advancestringindex
  1656. var advanceStringIndex = function (S, index, unicode) {
  1657. return index + (unicode ? charAt$1(S, index).length : 1);
  1658. };
  1659. // `RegExpExec` abstract operation
  1660. // https://tc39.github.io/ecma262/#sec-regexpexec
  1661. var regexpExecAbstract = function (R, S) {
  1662. var exec = R.exec;
  1663. if (typeof exec === 'function') {
  1664. var result = exec.call(R, S);
  1665. if (typeof result !== 'object') {
  1666. throw TypeError('RegExp exec method returned something other than an Object or null');
  1667. }
  1668. return result;
  1669. }
  1670. if (classofRaw(R) !== 'RegExp') {
  1671. throw TypeError('RegExp#exec called on incompatible receiver');
  1672. }
  1673. return regexpExec.call(R, S);
  1674. };
  1675. var max$2 = Math.max;
  1676. var min$2 = Math.min;
  1677. var floor$1 = Math.floor;
  1678. var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g;
  1679. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g;
  1680. var maybeToString = function (it) {
  1681. return it === undefined ? it : String(it);
  1682. };
  1683. // @@replace logic
  1684. fixRegexpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) {
  1685. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;
  1686. var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;
  1687. var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
  1688. return [
  1689. // `String.prototype.replace` method
  1690. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  1691. function replace(searchValue, replaceValue) {
  1692. var O = requireObjectCoercible(this);
  1693. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  1694. return replacer !== undefined
  1695. ? replacer.call(searchValue, O, replaceValue)
  1696. : nativeReplace.call(String(O), searchValue, replaceValue);
  1697. },
  1698. // `RegExp.prototype[@@replace]` method
  1699. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  1700. function (regexp, replaceValue) {
  1701. if (
  1702. (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) ||
  1703. (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1)
  1704. ) {
  1705. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  1706. if (res.done) return res.value;
  1707. }
  1708. var rx = anObject(regexp);
  1709. var S = String(this);
  1710. var functionalReplace = typeof replaceValue === 'function';
  1711. if (!functionalReplace) replaceValue = String(replaceValue);
  1712. var global = rx.global;
  1713. if (global) {
  1714. var fullUnicode = rx.unicode;
  1715. rx.lastIndex = 0;
  1716. }
  1717. var results = [];
  1718. while (true) {
  1719. var result = regexpExecAbstract(rx, S);
  1720. if (result === null) break;
  1721. results.push(result);
  1722. if (!global) break;
  1723. var matchStr = String(result[0]);
  1724. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1725. }
  1726. var accumulatedResult = '';
  1727. var nextSourcePosition = 0;
  1728. for (var i = 0; i < results.length; i++) {
  1729. result = results[i];
  1730. var matched = String(result[0]);
  1731. var position = max$2(min$2(toInteger(result.index), S.length), 0);
  1732. var captures = [];
  1733. // NOTE: This is equivalent to
  1734. // captures = result.slice(1).map(maybeToString)
  1735. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  1736. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  1737. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  1738. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  1739. var namedCaptures = result.groups;
  1740. if (functionalReplace) {
  1741. var replacerArgs = [matched].concat(captures, position, S);
  1742. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  1743. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  1744. } else {
  1745. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  1746. }
  1747. if (position >= nextSourcePosition) {
  1748. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  1749. nextSourcePosition = position + matched.length;
  1750. }
  1751. }
  1752. return accumulatedResult + S.slice(nextSourcePosition);
  1753. }
  1754. ];
  1755. // https://tc39.github.io/ecma262/#sec-getsubstitution
  1756. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  1757. var tailPos = position + matched.length;
  1758. var m = captures.length;
  1759. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  1760. if (namedCaptures !== undefined) {
  1761. namedCaptures = toObject(namedCaptures);
  1762. symbols = SUBSTITUTION_SYMBOLS;
  1763. }
  1764. return nativeReplace.call(replacement, symbols, function (match, ch) {
  1765. var capture;
  1766. switch (ch.charAt(0)) {
  1767. case '$': return '$';
  1768. case '&': return matched;
  1769. case '`': return str.slice(0, position);
  1770. case "'": return str.slice(tailPos);
  1771. case '<':
  1772. capture = namedCaptures[ch.slice(1, -1)];
  1773. break;
  1774. default: // \d\d?
  1775. var n = +ch;
  1776. if (n === 0) return match;
  1777. if (n > m) {
  1778. var f = floor$1(n / 10);
  1779. if (f === 0) return match;
  1780. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  1781. return match;
  1782. }
  1783. capture = captures[n - 1];
  1784. }
  1785. return capture === undefined ? '' : capture;
  1786. });
  1787. }
  1788. });
  1789. // `SameValue` abstract operation
  1790. // https://tc39.github.io/ecma262/#sec-samevalue
  1791. var sameValue = Object.is || function is(x, y) {
  1792. // eslint-disable-next-line no-self-compare
  1793. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  1794. };
  1795. // @@search logic
  1796. fixRegexpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) {
  1797. return [
  1798. // `String.prototype.search` method
  1799. // https://tc39.github.io/ecma262/#sec-string.prototype.search
  1800. function search(regexp) {
  1801. var O = requireObjectCoercible(this);
  1802. var searcher = regexp == undefined ? undefined : regexp[SEARCH];
  1803. return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  1804. },
  1805. // `RegExp.prototype[@@search]` method
  1806. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
  1807. function (regexp) {
  1808. var res = maybeCallNative(nativeSearch, regexp, this);
  1809. if (res.done) return res.value;
  1810. var rx = anObject(regexp);
  1811. var S = String(this);
  1812. var previousLastIndex = rx.lastIndex;
  1813. if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
  1814. var result = regexpExecAbstract(rx, S);
  1815. if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
  1816. return result === null ? -1 : result.index;
  1817. }
  1818. ];
  1819. });
  1820. var MATCH = wellKnownSymbol('match');
  1821. // `IsRegExp` abstract operation
  1822. // https://tc39.github.io/ecma262/#sec-isregexp
  1823. var isRegexp = function (it) {
  1824. var isRegExp;
  1825. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
  1826. };
  1827. var SPECIES$4 = wellKnownSymbol('species');
  1828. // `SpeciesConstructor` abstract operation
  1829. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  1830. var speciesConstructor = function (O, defaultConstructor) {
  1831. var C = anObject(O).constructor;
  1832. var S;
  1833. return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aFunction$1(S);
  1834. };
  1835. var arrayPush = [].push;
  1836. var min$3 = Math.min;
  1837. var MAX_UINT32 = 0xFFFFFFFF;
  1838. // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
  1839. var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
  1840. // @@split logic
  1841. fixRegexpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {
  1842. var internalSplit;
  1843. if (
  1844. 'abbc'.split(/(b)*/)[1] == 'c' ||
  1845. 'test'.split(/(?:)/, -1).length != 4 ||
  1846. 'ab'.split(/(?:ab)*/).length != 2 ||
  1847. '.'.split(/(.?)(.?)/).length != 4 ||
  1848. '.'.split(/()()/).length > 1 ||
  1849. ''.split(/.?/).length
  1850. ) {
  1851. // based on es5-shim implementation, need to rework it
  1852. internalSplit = function (separator, limit) {
  1853. var string = String(requireObjectCoercible(this));
  1854. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1855. if (lim === 0) return [];
  1856. if (separator === undefined) return [string];
  1857. // If `separator` is not a regex, use native split
  1858. if (!isRegexp(separator)) {
  1859. return nativeSplit.call(string, separator, lim);
  1860. }
  1861. var output = [];
  1862. var flags = (separator.ignoreCase ? 'i' : '') +
  1863. (separator.multiline ? 'm' : '') +
  1864. (separator.unicode ? 'u' : '') +
  1865. (separator.sticky ? 'y' : '');
  1866. var lastLastIndex = 0;
  1867. // Make `global` and avoid `lastIndex` issues by working with a copy
  1868. var separatorCopy = new RegExp(separator.source, flags + 'g');
  1869. var match, lastIndex, lastLength;
  1870. while (match = regexpExec.call(separatorCopy, string)) {
  1871. lastIndex = separatorCopy.lastIndex;
  1872. if (lastIndex > lastLastIndex) {
  1873. output.push(string.slice(lastLastIndex, match.index));
  1874. if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
  1875. lastLength = match[0].length;
  1876. lastLastIndex = lastIndex;
  1877. if (output.length >= lim) break;
  1878. }
  1879. if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
  1880. }
  1881. if (lastLastIndex === string.length) {
  1882. if (lastLength || !separatorCopy.test('')) output.push('');
  1883. } else output.push(string.slice(lastLastIndex));
  1884. return output.length > lim ? output.slice(0, lim) : output;
  1885. };
  1886. // Chakra, V8
  1887. } else if ('0'.split(undefined, 0).length) {
  1888. internalSplit = function (separator, limit) {
  1889. return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
  1890. };
  1891. } else internalSplit = nativeSplit;
  1892. return [
  1893. // `String.prototype.split` method
  1894. // https://tc39.github.io/ecma262/#sec-string.prototype.split
  1895. function split(separator, limit) {
  1896. var O = requireObjectCoercible(this);
  1897. var splitter = separator == undefined ? undefined : separator[SPLIT];
  1898. return splitter !== undefined
  1899. ? splitter.call(separator, O, limit)
  1900. : internalSplit.call(String(O), separator, limit);
  1901. },
  1902. // `RegExp.prototype[@@split]` method
  1903. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
  1904. //
  1905. // NOTE: This cannot be properly polyfilled in engines that don't support
  1906. // the 'y' flag.
  1907. function (regexp, limit) {
  1908. var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
  1909. if (res.done) return res.value;
  1910. var rx = anObject(regexp);
  1911. var S = String(this);
  1912. var C = speciesConstructor(rx, RegExp);
  1913. var unicodeMatching = rx.unicode;
  1914. var flags = (rx.ignoreCase ? 'i' : '') +
  1915. (rx.multiline ? 'm' : '') +
  1916. (rx.unicode ? 'u' : '') +
  1917. (SUPPORTS_Y ? 'y' : 'g');
  1918. // ^(? + rx + ) is needed, in combination with some S slicing, to
  1919. // simulate the 'y' flag.
  1920. var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
  1921. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1922. if (lim === 0) return [];
  1923. if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
  1924. var p = 0;
  1925. var q = 0;
  1926. var A = [];
  1927. while (q < S.length) {
  1928. splitter.lastIndex = SUPPORTS_Y ? q : 0;
  1929. var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
  1930. var e;
  1931. if (
  1932. z === null ||
  1933. (e = min$3(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
  1934. ) {
  1935. q = advanceStringIndex(S, q, unicodeMatching);
  1936. } else {
  1937. A.push(S.slice(p, q));
  1938. if (A.length === lim) return A;
  1939. for (var i = 1; i <= z.length - 1; i++) {
  1940. A.push(z[i]);
  1941. if (A.length === lim) return A;
  1942. }
  1943. q = p = e;
  1944. }
  1945. }
  1946. A.push(S.slice(p));
  1947. return A;
  1948. }
  1949. ];
  1950. }, !SUPPORTS_Y);
  1951. // iterable DOM collections
  1952. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  1953. var domIterables = {
  1954. CSSRuleList: 0,
  1955. CSSStyleDeclaration: 0,
  1956. CSSValueList: 0,
  1957. ClientRectList: 0,
  1958. DOMRectList: 0,
  1959. DOMStringList: 0,
  1960. DOMTokenList: 1,
  1961. DataTransferItemList: 0,
  1962. FileList: 0,
  1963. HTMLAllCollection: 0,
  1964. HTMLCollection: 0,
  1965. HTMLFormElement: 0,
  1966. HTMLSelectElement: 0,
  1967. MediaList: 0,
  1968. MimeTypeArray: 0,
  1969. NamedNodeMap: 0,
  1970. NodeList: 1,
  1971. PaintRequestList: 0,
  1972. Plugin: 0,
  1973. PluginArray: 0,
  1974. SVGLengthList: 0,
  1975. SVGNumberList: 0,
  1976. SVGPathSegList: 0,
  1977. SVGPointList: 0,
  1978. SVGStringList: 0,
  1979. SVGTransformList: 0,
  1980. SourceBufferList: 0,
  1981. StyleSheetList: 0,
  1982. TextTrackCueList: 0,
  1983. TextTrackList: 0,
  1984. TouchList: 0
  1985. };
  1986. for (var COLLECTION_NAME in domIterables) {
  1987. var Collection = global_1[COLLECTION_NAME];
  1988. var CollectionPrototype = Collection && Collection.prototype;
  1989. // some Chrome versions have non-configurable methods on DOMTokenList
  1990. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  1991. createNonEnumerableProperty(CollectionPrototype, 'forEach', arrayForEach);
  1992. } catch (error) {
  1993. CollectionPrototype.forEach = arrayForEach;
  1994. }
  1995. }
  1996. var ITERATOR$2 = wellKnownSymbol('iterator');
  1997. var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
  1998. var ArrayValues = es_array_iterator.values;
  1999. for (var COLLECTION_NAME$1 in domIterables) {
  2000. var Collection$1 = global_1[COLLECTION_NAME$1];
  2001. var CollectionPrototype$1 = Collection$1 && Collection$1.prototype;
  2002. if (CollectionPrototype$1) {
  2003. // some Chrome versions have non-configurable methods on DOMTokenList
  2004. if (CollectionPrototype$1[ITERATOR$2] !== ArrayValues) try {
  2005. createNonEnumerableProperty(CollectionPrototype$1, ITERATOR$2, ArrayValues);
  2006. } catch (error) {
  2007. CollectionPrototype$1[ITERATOR$2] = ArrayValues;
  2008. }
  2009. if (!CollectionPrototype$1[TO_STRING_TAG$3]) {
  2010. createNonEnumerableProperty(CollectionPrototype$1, TO_STRING_TAG$3, COLLECTION_NAME$1);
  2011. }
  2012. if (domIterables[COLLECTION_NAME$1]) for (var METHOD_NAME in es_array_iterator) {
  2013. // some Chrome versions have non-configurable methods on DOMTokenList
  2014. if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try {
  2015. createNonEnumerableProperty(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]);
  2016. } catch (error) {
  2017. CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME];
  2018. }
  2019. }
  2020. }
  2021. }
  2022. var ITERATOR$3 = wellKnownSymbol('iterator');
  2023. var nativeUrl = !fails(function () {
  2024. var url = new URL('b?a=1&b=2&c=3', 'http://a');
  2025. var searchParams = url.searchParams;
  2026. var result = '';
  2027. url.pathname = 'c%20d';
  2028. searchParams.forEach(function (value, key) {
  2029. searchParams['delete']('b');
  2030. result += key + value;
  2031. });
  2032. return (isPure && !url.toJSON)
  2033. || !searchParams.sort
  2034. || url.href !== 'http://a/c%20d?a=1&c=3'
  2035. || searchParams.get('c') !== '3'
  2036. || String(new URLSearchParams('?a=1')) !== 'a=1'
  2037. || !searchParams[ITERATOR$3]
  2038. // throws in Edge
  2039. || new URL('https://a@b').username !== 'a'
  2040. || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
  2041. // not punycoded in Edge
  2042. || new URL('http://тест').host !== 'xn--e1aybc'
  2043. // not escaped in Chrome 62-
  2044. || new URL('http://a#б').hash !== '#%D0%B1'
  2045. // fails in Chrome 66-
  2046. || result !== 'a1c3'
  2047. // throws in Safari
  2048. || new URL('http://x', undefined).host !== 'x';
  2049. });
  2050. var anInstance = function (it, Constructor, name) {
  2051. if (!(it instanceof Constructor)) {
  2052. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  2053. } return it;
  2054. };
  2055. var nativeAssign = Object.assign;
  2056. var defineProperty$4 = Object.defineProperty;
  2057. // `Object.assign` method
  2058. // https://tc39.github.io/ecma262/#sec-object.assign
  2059. var objectAssign = !nativeAssign || fails(function () {
  2060. // should have correct order of operations (Edge bug)
  2061. if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty$4({}, 'a', {
  2062. enumerable: true,
  2063. get: function () {
  2064. defineProperty$4(this, 'b', {
  2065. value: 3,
  2066. enumerable: false
  2067. });
  2068. }
  2069. }), { b: 2 })).b !== 1) return true;
  2070. // should work with symbols and should have deterministic property order (V8 bug)
  2071. var A = {};
  2072. var B = {};
  2073. // eslint-disable-next-line no-undef
  2074. var symbol = Symbol();
  2075. var alphabet = 'abcdefghijklmnopqrst';
  2076. A[symbol] = 7;
  2077. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  2078. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  2079. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  2080. var T = toObject(target);
  2081. var argumentsLength = arguments.length;
  2082. var index = 1;
  2083. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  2084. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  2085. while (argumentsLength > index) {
  2086. var S = indexedObject(arguments[index++]);
  2087. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  2088. var length = keys.length;
  2089. var j = 0;
  2090. var key;
  2091. while (length > j) {
  2092. key = keys[j++];
  2093. if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
  2094. }
  2095. } return T;
  2096. } : nativeAssign;
  2097. // call something on iterator step with safe closing on error
  2098. var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
  2099. try {
  2100. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  2101. // 7.4.6 IteratorClose(iterator, completion)
  2102. } catch (error) {
  2103. var returnMethod = iterator['return'];
  2104. if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
  2105. throw error;
  2106. }
  2107. };
  2108. var ITERATOR$4 = wellKnownSymbol('iterator');
  2109. var ArrayPrototype$1 = Array.prototype;
  2110. // check on default Array iterator
  2111. var isArrayIteratorMethod = function (it) {
  2112. return it !== undefined && (iterators.Array === it || ArrayPrototype$1[ITERATOR$4] === it);
  2113. };
  2114. var ITERATOR$5 = wellKnownSymbol('iterator');
  2115. var getIteratorMethod = function (it) {
  2116. if (it != undefined) return it[ITERATOR$5]
  2117. || it['@@iterator']
  2118. || iterators[classof(it)];
  2119. };
  2120. // `Array.from` method implementation
  2121. // https://tc39.github.io/ecma262/#sec-array.from
  2122. var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  2123. var O = toObject(arrayLike);
  2124. var C = typeof this == 'function' ? this : Array;
  2125. var argumentsLength = arguments.length;
  2126. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  2127. var mapping = mapfn !== undefined;
  2128. var iteratorMethod = getIteratorMethod(O);
  2129. var index = 0;
  2130. var length, result, step, iterator, next, value;
  2131. if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  2132. // if the target is not iterable or it's an array with the default iterator - use a simple case
  2133. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  2134. iterator = iteratorMethod.call(O);
  2135. next = iterator.next;
  2136. result = new C();
  2137. for (;!(step = next.call(iterator)).done; index++) {
  2138. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  2139. createProperty(result, index, value);
  2140. }
  2141. } else {
  2142. length = toLength(O.length);
  2143. result = new C(length);
  2144. for (;length > index; index++) {
  2145. value = mapping ? mapfn(O[index], index) : O[index];
  2146. createProperty(result, index, value);
  2147. }
  2148. }
  2149. result.length = index;
  2150. return result;
  2151. };
  2152. // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
  2153. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  2154. var base = 36;
  2155. var tMin = 1;
  2156. var tMax = 26;
  2157. var skew = 38;
  2158. var damp = 700;
  2159. var initialBias = 72;
  2160. var initialN = 128; // 0x80
  2161. var delimiter = '-'; // '\x2D'
  2162. var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
  2163. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  2164. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  2165. var baseMinusTMin = base - tMin;
  2166. var floor$2 = Math.floor;
  2167. var stringFromCharCode = String.fromCharCode;
  2168. /**
  2169. * Creates an array containing the numeric code points of each Unicode
  2170. * character in the string. While JavaScript uses UCS-2 internally,
  2171. * this function will convert a pair of surrogate halves (each of which
  2172. * UCS-2 exposes as separate characters) into a single code point,
  2173. * matching UTF-16.
  2174. */
  2175. var ucs2decode = function (string) {
  2176. var output = [];
  2177. var counter = 0;
  2178. var length = string.length;
  2179. while (counter < length) {
  2180. var value = string.charCodeAt(counter++);
  2181. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  2182. // It's a high surrogate, and there is a next character.
  2183. var extra = string.charCodeAt(counter++);
  2184. if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
  2185. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  2186. } else {
  2187. // It's an unmatched surrogate; only append this code unit, in case the
  2188. // next code unit is the high surrogate of a surrogate pair.
  2189. output.push(value);
  2190. counter--;
  2191. }
  2192. } else {
  2193. output.push(value);
  2194. }
  2195. }
  2196. return output;
  2197. };
  2198. /**
  2199. * Converts a digit/integer into a basic code point.
  2200. */
  2201. var digitToBasic = function (digit) {
  2202. // 0..25 map to ASCII a..z or A..Z
  2203. // 26..35 map to ASCII 0..9
  2204. return digit + 22 + 75 * (digit < 26);
  2205. };
  2206. /**
  2207. * Bias adaptation function as per section 3.4 of RFC 3492.
  2208. * https://tools.ietf.org/html/rfc3492#section-3.4
  2209. */
  2210. var adapt = function (delta, numPoints, firstTime) {
  2211. var k = 0;
  2212. delta = firstTime ? floor$2(delta / damp) : delta >> 1;
  2213. delta += floor$2(delta / numPoints);
  2214. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  2215. delta = floor$2(delta / baseMinusTMin);
  2216. }
  2217. return floor$2(k + (baseMinusTMin + 1) * delta / (delta + skew));
  2218. };
  2219. /**
  2220. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  2221. * Punycode string of ASCII-only symbols.
  2222. */
  2223. // eslint-disable-next-line max-statements
  2224. var encode = function (input) {
  2225. var output = [];
  2226. // Convert the input in UCS-2 to an array of Unicode code points.
  2227. input = ucs2decode(input);
  2228. // Cache the length.
  2229. var inputLength = input.length;
  2230. // Initialize the state.
  2231. var n = initialN;
  2232. var delta = 0;
  2233. var bias = initialBias;
  2234. var i, currentValue;
  2235. // Handle the basic code points.
  2236. for (i = 0; i < input.length; i++) {
  2237. currentValue = input[i];
  2238. if (currentValue < 0x80) {
  2239. output.push(stringFromCharCode(currentValue));
  2240. }
  2241. }
  2242. var basicLength = output.length; // number of basic code points.
  2243. var handledCPCount = basicLength; // number of code points that have been handled;
  2244. // Finish the basic string with a delimiter unless it's empty.
  2245. if (basicLength) {
  2246. output.push(delimiter);
  2247. }
  2248. // Main encoding loop:
  2249. while (handledCPCount < inputLength) {
  2250. // All non-basic code points < n have been handled already. Find the next larger one:
  2251. var m = maxInt;
  2252. for (i = 0; i < input.length; i++) {
  2253. currentValue = input[i];
  2254. if (currentValue >= n && currentValue < m) {
  2255. m = currentValue;
  2256. }
  2257. }
  2258. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
  2259. var handledCPCountPlusOne = handledCPCount + 1;
  2260. if (m - n > floor$2((maxInt - delta) / handledCPCountPlusOne)) {
  2261. throw RangeError(OVERFLOW_ERROR);
  2262. }
  2263. delta += (m - n) * handledCPCountPlusOne;
  2264. n = m;
  2265. for (i = 0; i < input.length; i++) {
  2266. currentValue = input[i];
  2267. if (currentValue < n && ++delta > maxInt) {
  2268. throw RangeError(OVERFLOW_ERROR);
  2269. }
  2270. if (currentValue == n) {
  2271. // Represent delta as a generalized variable-length integer.
  2272. var q = delta;
  2273. for (var k = base; /* no condition */; k += base) {
  2274. var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  2275. if (q < t) break;
  2276. var qMinusT = q - t;
  2277. var baseMinusT = base - t;
  2278. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
  2279. q = floor$2(qMinusT / baseMinusT);
  2280. }
  2281. output.push(stringFromCharCode(digitToBasic(q)));
  2282. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  2283. delta = 0;
  2284. ++handledCPCount;
  2285. }
  2286. }
  2287. ++delta;
  2288. ++n;
  2289. }
  2290. return output.join('');
  2291. };
  2292. var stringPunycodeToAscii = function (input) {
  2293. var encoded = [];
  2294. var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.');
  2295. var i, label;
  2296. for (i = 0; i < labels.length; i++) {
  2297. label = labels[i];
  2298. encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);
  2299. }
  2300. return encoded.join('.');
  2301. };
  2302. var redefineAll = function (target, src, options) {
  2303. for (var key in src) redefine(target, key, src[key], options);
  2304. return target;
  2305. };
  2306. var getIterator = function (it) {
  2307. var iteratorMethod = getIteratorMethod(it);
  2308. if (typeof iteratorMethod != 'function') {
  2309. throw TypeError(String(it) + ' is not iterable');
  2310. } return anObject(iteratorMethod.call(it));
  2311. };
  2312. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  2313. var $fetch = getBuiltIn('fetch');
  2314. var Headers = getBuiltIn('Headers');
  2315. var ITERATOR$6 = wellKnownSymbol('iterator');
  2316. var URL_SEARCH_PARAMS = 'URLSearchParams';
  2317. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  2318. var setInternalState$3 = internalState.set;
  2319. var getInternalParamsState = internalState.getterFor(URL_SEARCH_PARAMS);
  2320. var getInternalIteratorState = internalState.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  2321. var plus = /\+/g;
  2322. var sequences = Array(4);
  2323. var percentSequence = function (bytes) {
  2324. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  2325. };
  2326. var percentDecode = function (sequence) {
  2327. try {
  2328. return decodeURIComponent(sequence);
  2329. } catch (error) {
  2330. return sequence;
  2331. }
  2332. };
  2333. var deserialize = function (it) {
  2334. var result = it.replace(plus, ' ');
  2335. var bytes = 4;
  2336. try {
  2337. return decodeURIComponent(result);
  2338. } catch (error) {
  2339. while (bytes) {
  2340. result = result.replace(percentSequence(bytes--), percentDecode);
  2341. }
  2342. return result;
  2343. }
  2344. };
  2345. var find = /[!'()~]|%20/g;
  2346. var replace = {
  2347. '!': '%21',
  2348. "'": '%27',
  2349. '(': '%28',
  2350. ')': '%29',
  2351. '~': '%7E',
  2352. '%20': '+'
  2353. };
  2354. var replacer = function (match) {
  2355. return replace[match];
  2356. };
  2357. var serialize = function (it) {
  2358. return encodeURIComponent(it).replace(find, replacer);
  2359. };
  2360. var parseSearchParams = function (result, query) {
  2361. if (query) {
  2362. var attributes = query.split('&');
  2363. var index = 0;
  2364. var attribute, entry;
  2365. while (index < attributes.length) {
  2366. attribute = attributes[index++];
  2367. if (attribute.length) {
  2368. entry = attribute.split('=');
  2369. result.push({
  2370. key: deserialize(entry.shift()),
  2371. value: deserialize(entry.join('='))
  2372. });
  2373. }
  2374. }
  2375. }
  2376. };
  2377. var updateSearchParams = function (query) {
  2378. this.entries.length = 0;
  2379. parseSearchParams(this.entries, query);
  2380. };
  2381. var validateArgumentsLength = function (passed, required) {
  2382. if (passed < required) throw TypeError('Not enough arguments');
  2383. };
  2384. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  2385. setInternalState$3(this, {
  2386. type: URL_SEARCH_PARAMS_ITERATOR,
  2387. iterator: getIterator(getInternalParamsState(params).entries),
  2388. kind: kind
  2389. });
  2390. }, 'Iterator', function next() {
  2391. var state = getInternalIteratorState(this);
  2392. var kind = state.kind;
  2393. var step = state.iterator.next();
  2394. var entry = step.value;
  2395. if (!step.done) {
  2396. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
  2397. } return step;
  2398. });
  2399. // `URLSearchParams` constructor
  2400. // https://url.spec.whatwg.org/#interface-urlsearchparams
  2401. var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
  2402. anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  2403. var init = arguments.length > 0 ? arguments[0] : undefined;
  2404. var that = this;
  2405. var entries = [];
  2406. var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;
  2407. setInternalState$3(that, {
  2408. type: URL_SEARCH_PARAMS,
  2409. entries: entries,
  2410. updateURL: function () { /* empty */ },
  2411. updateSearchParams: updateSearchParams
  2412. });
  2413. if (init !== undefined) {
  2414. if (isObject(init)) {
  2415. iteratorMethod = getIteratorMethod(init);
  2416. if (typeof iteratorMethod === 'function') {
  2417. iterator = iteratorMethod.call(init);
  2418. next = iterator.next;
  2419. while (!(step = next.call(iterator)).done) {
  2420. entryIterator = getIterator(anObject(step.value));
  2421. entryNext = entryIterator.next;
  2422. if (
  2423. (first = entryNext.call(entryIterator)).done ||
  2424. (second = entryNext.call(entryIterator)).done ||
  2425. !entryNext.call(entryIterator).done
  2426. ) throw TypeError('Expected sequence with length 2');
  2427. entries.push({ key: first.value + '', value: second.value + '' });
  2428. }
  2429. } else for (key in init) if (has(init, key)) entries.push({ key: key, value: init[key] + '' });
  2430. } else {
  2431. parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');
  2432. }
  2433. }
  2434. };
  2435. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  2436. redefineAll(URLSearchParamsPrototype, {
  2437. // `URLSearchParams.prototype.appent` method
  2438. // https://url.spec.whatwg.org/#dom-urlsearchparams-append
  2439. append: function append(name, value) {
  2440. validateArgumentsLength(arguments.length, 2);
  2441. var state = getInternalParamsState(this);
  2442. state.entries.push({ key: name + '', value: value + '' });
  2443. state.updateURL();
  2444. },
  2445. // `URLSearchParams.prototype.delete` method
  2446. // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
  2447. 'delete': function (name) {
  2448. validateArgumentsLength(arguments.length, 1);
  2449. var state = getInternalParamsState(this);
  2450. var entries = state.entries;
  2451. var key = name + '';
  2452. var index = 0;
  2453. while (index < entries.length) {
  2454. if (entries[index].key === key) entries.splice(index, 1);
  2455. else index++;
  2456. }
  2457. state.updateURL();
  2458. },
  2459. // `URLSearchParams.prototype.get` method
  2460. // https://url.spec.whatwg.org/#dom-urlsearchparams-get
  2461. get: function get(name) {
  2462. validateArgumentsLength(arguments.length, 1);
  2463. var entries = getInternalParamsState(this).entries;
  2464. var key = name + '';
  2465. var index = 0;
  2466. for (; index < entries.length; index++) {
  2467. if (entries[index].key === key) return entries[index].value;
  2468. }
  2469. return null;
  2470. },
  2471. // `URLSearchParams.prototype.getAll` method
  2472. // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
  2473. getAll: function getAll(name) {
  2474. validateArgumentsLength(arguments.length, 1);
  2475. var entries = getInternalParamsState(this).entries;
  2476. var key = name + '';
  2477. var result = [];
  2478. var index = 0;
  2479. for (; index < entries.length; index++) {
  2480. if (entries[index].key === key) result.push(entries[index].value);
  2481. }
  2482. return result;
  2483. },
  2484. // `URLSearchParams.prototype.has` method
  2485. // https://url.spec.whatwg.org/#dom-urlsearchparams-has
  2486. has: function has(name) {
  2487. validateArgumentsLength(arguments.length, 1);
  2488. var entries = getInternalParamsState(this).entries;
  2489. var key = name + '';
  2490. var index = 0;
  2491. while (index < entries.length) {
  2492. if (entries[index++].key === key) return true;
  2493. }
  2494. return false;
  2495. },
  2496. // `URLSearchParams.prototype.set` method
  2497. // https://url.spec.whatwg.org/#dom-urlsearchparams-set
  2498. set: function set(name, value) {
  2499. validateArgumentsLength(arguments.length, 1);
  2500. var state = getInternalParamsState(this);
  2501. var entries = state.entries;
  2502. var found = false;
  2503. var key = name + '';
  2504. var val = value + '';
  2505. var index = 0;
  2506. var entry;
  2507. for (; index < entries.length; index++) {
  2508. entry = entries[index];
  2509. if (entry.key === key) {
  2510. if (found) entries.splice(index--, 1);
  2511. else {
  2512. found = true;
  2513. entry.value = val;
  2514. }
  2515. }
  2516. }
  2517. if (!found) entries.push({ key: key, value: val });
  2518. state.updateURL();
  2519. },
  2520. // `URLSearchParams.prototype.sort` method
  2521. // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
  2522. sort: function sort() {
  2523. var state = getInternalParamsState(this);
  2524. var entries = state.entries;
  2525. // Array#sort is not stable in some engines
  2526. var slice = entries.slice();
  2527. var entry, entriesIndex, sliceIndex;
  2528. entries.length = 0;
  2529. for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {
  2530. entry = slice[sliceIndex];
  2531. for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {
  2532. if (entries[entriesIndex].key > entry.key) {
  2533. entries.splice(entriesIndex, 0, entry);
  2534. break;
  2535. }
  2536. }
  2537. if (entriesIndex === sliceIndex) entries.push(entry);
  2538. }
  2539. state.updateURL();
  2540. },
  2541. // `URLSearchParams.prototype.forEach` method
  2542. forEach: function forEach(callback /* , thisArg */) {
  2543. var entries = getInternalParamsState(this).entries;
  2544. var boundFunction = functionBindContext(callback, arguments.length > 1 ? arguments[1] : undefined, 3);
  2545. var index = 0;
  2546. var entry;
  2547. while (index < entries.length) {
  2548. entry = entries[index++];
  2549. boundFunction(entry.value, entry.key, this);
  2550. }
  2551. },
  2552. // `URLSearchParams.prototype.keys` method
  2553. keys: function keys() {
  2554. return new URLSearchParamsIterator(this, 'keys');
  2555. },
  2556. // `URLSearchParams.prototype.values` method
  2557. values: function values() {
  2558. return new URLSearchParamsIterator(this, 'values');
  2559. },
  2560. // `URLSearchParams.prototype.entries` method
  2561. entries: function entries() {
  2562. return new URLSearchParamsIterator(this, 'entries');
  2563. }
  2564. }, { enumerable: true });
  2565. // `URLSearchParams.prototype[@@iterator]` method
  2566. redefine(URLSearchParamsPrototype, ITERATOR$6, URLSearchParamsPrototype.entries);
  2567. // `URLSearchParams.prototype.toString` method
  2568. // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
  2569. redefine(URLSearchParamsPrototype, 'toString', function toString() {
  2570. var entries = getInternalParamsState(this).entries;
  2571. var result = [];
  2572. var index = 0;
  2573. var entry;
  2574. while (index < entries.length) {
  2575. entry = entries[index++];
  2576. result.push(serialize(entry.key) + '=' + serialize(entry.value));
  2577. } return result.join('&');
  2578. }, { enumerable: true });
  2579. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  2580. _export({ global: true, forced: !nativeUrl }, {
  2581. URLSearchParams: URLSearchParamsConstructor
  2582. });
  2583. // Wrap `fetch` for correct work with polyfilled `URLSearchParams`
  2584. // https://github.com/zloirock/core-js/issues/674
  2585. if (!nativeUrl && typeof $fetch == 'function' && typeof Headers == 'function') {
  2586. _export({ global: true, enumerable: true, forced: true }, {
  2587. fetch: function fetch(input /* , init */) {
  2588. var args = [input];
  2589. var init, body, headers;
  2590. if (arguments.length > 1) {
  2591. init = arguments[1];
  2592. if (isObject(init)) {
  2593. body = init.body;
  2594. if (classof(body) === URL_SEARCH_PARAMS) {
  2595. headers = init.headers ? new Headers(init.headers) : new Headers();
  2596. if (!headers.has('content-type')) {
  2597. headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  2598. }
  2599. init = objectCreate(init, {
  2600. body: createPropertyDescriptor(0, String(body)),
  2601. headers: createPropertyDescriptor(0, headers)
  2602. });
  2603. }
  2604. }
  2605. args.push(init);
  2606. } return $fetch.apply(this, args);
  2607. }
  2608. });
  2609. }
  2610. var web_urlSearchParams = {
  2611. URLSearchParams: URLSearchParamsConstructor,
  2612. getState: getInternalParamsState
  2613. };
  2614. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  2615. var codeAt = stringMultibyte.codeAt;
  2616. var NativeURL = global_1.URL;
  2617. var URLSearchParams$1 = web_urlSearchParams.URLSearchParams;
  2618. var getInternalSearchParamsState = web_urlSearchParams.getState;
  2619. var setInternalState$4 = internalState.set;
  2620. var getInternalURLState = internalState.getterFor('URL');
  2621. var floor$3 = Math.floor;
  2622. var pow = Math.pow;
  2623. var INVALID_AUTHORITY = 'Invalid authority';
  2624. var INVALID_SCHEME = 'Invalid scheme';
  2625. var INVALID_HOST = 'Invalid host';
  2626. var INVALID_PORT = 'Invalid port';
  2627. var ALPHA = /[A-Za-z]/;
  2628. var ALPHANUMERIC = /[\d+-.A-Za-z]/;
  2629. var DIGIT = /\d/;
  2630. var HEX_START = /^(0x|0X)/;
  2631. var OCT = /^[0-7]+$/;
  2632. var DEC = /^\d+$/;
  2633. var HEX = /^[\dA-Fa-f]+$/;
  2634. // eslint-disable-next-line no-control-regex
  2635. var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/;
  2636. // eslint-disable-next-line no-control-regex
  2637. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/;
  2638. // eslint-disable-next-line no-control-regex
  2639. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g;
  2640. // eslint-disable-next-line no-control-regex
  2641. var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g;
  2642. var EOF;
  2643. var parseHost = function (url, input) {
  2644. var result, codePoints, index;
  2645. if (input.charAt(0) == '[') {
  2646. if (input.charAt(input.length - 1) != ']') return INVALID_HOST;
  2647. result = parseIPv6(input.slice(1, -1));
  2648. if (!result) return INVALID_HOST;
  2649. url.host = result;
  2650. // opaque host
  2651. } else if (!isSpecial(url)) {
  2652. if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST;
  2653. result = '';
  2654. codePoints = arrayFrom(input);
  2655. for (index = 0; index < codePoints.length; index++) {
  2656. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  2657. }
  2658. url.host = result;
  2659. } else {
  2660. input = stringPunycodeToAscii(input);
  2661. if (FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST;
  2662. result = parseIPv4(input);
  2663. if (result === null) return INVALID_HOST;
  2664. url.host = result;
  2665. }
  2666. };
  2667. var parseIPv4 = function (input) {
  2668. var parts = input.split('.');
  2669. var partsLength, numbers, index, part, radix, number, ipv4;
  2670. if (parts.length && parts[parts.length - 1] == '') {
  2671. parts.pop();
  2672. }
  2673. partsLength = parts.length;
  2674. if (partsLength > 4) return input;
  2675. numbers = [];
  2676. for (index = 0; index < partsLength; index++) {
  2677. part = parts[index];
  2678. if (part == '') return input;
  2679. radix = 10;
  2680. if (part.length > 1 && part.charAt(0) == '0') {
  2681. radix = HEX_START.test(part) ? 16 : 8;
  2682. part = part.slice(radix == 8 ? 1 : 2);
  2683. }
  2684. if (part === '') {
  2685. number = 0;
  2686. } else {
  2687. if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part)) return input;
  2688. number = parseInt(part, radix);
  2689. }
  2690. numbers.push(number);
  2691. }
  2692. for (index = 0; index < partsLength; index++) {
  2693. number = numbers[index];
  2694. if (index == partsLength - 1) {
  2695. if (number >= pow(256, 5 - partsLength)) return null;
  2696. } else if (number > 255) return null;
  2697. }
  2698. ipv4 = numbers.pop();
  2699. for (index = 0; index < numbers.length; index++) {
  2700. ipv4 += numbers[index] * pow(256, 3 - index);
  2701. }
  2702. return ipv4;
  2703. };
  2704. // eslint-disable-next-line max-statements
  2705. var parseIPv6 = function (input) {
  2706. var address = [0, 0, 0, 0, 0, 0, 0, 0];
  2707. var pieceIndex = 0;
  2708. var compress = null;
  2709. var pointer = 0;
  2710. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  2711. var char = function () {
  2712. return input.charAt(pointer);
  2713. };
  2714. if (char() == ':') {
  2715. if (input.charAt(1) != ':') return;
  2716. pointer += 2;
  2717. pieceIndex++;
  2718. compress = pieceIndex;
  2719. }
  2720. while (char()) {
  2721. if (pieceIndex == 8) return;
  2722. if (char() == ':') {
  2723. if (compress !== null) return;
  2724. pointer++;
  2725. pieceIndex++;
  2726. compress = pieceIndex;
  2727. continue;
  2728. }
  2729. value = length = 0;
  2730. while (length < 4 && HEX.test(char())) {
  2731. value = value * 16 + parseInt(char(), 16);
  2732. pointer++;
  2733. length++;
  2734. }
  2735. if (char() == '.') {
  2736. if (length == 0) return;
  2737. pointer -= length;
  2738. if (pieceIndex > 6) return;
  2739. numbersSeen = 0;
  2740. while (char()) {
  2741. ipv4Piece = null;
  2742. if (numbersSeen > 0) {
  2743. if (char() == '.' && numbersSeen < 4) pointer++;
  2744. else return;
  2745. }
  2746. if (!DIGIT.test(char())) return;
  2747. while (DIGIT.test(char())) {
  2748. number = parseInt(char(), 10);
  2749. if (ipv4Piece === null) ipv4Piece = number;
  2750. else if (ipv4Piece == 0) return;
  2751. else ipv4Piece = ipv4Piece * 10 + number;
  2752. if (ipv4Piece > 255) return;
  2753. pointer++;
  2754. }
  2755. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  2756. numbersSeen++;
  2757. if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
  2758. }
  2759. if (numbersSeen != 4) return;
  2760. break;
  2761. } else if (char() == ':') {
  2762. pointer++;
  2763. if (!char()) return;
  2764. } else if (char()) return;
  2765. address[pieceIndex++] = value;
  2766. }
  2767. if (compress !== null) {
  2768. swaps = pieceIndex - compress;
  2769. pieceIndex = 7;
  2770. while (pieceIndex != 0 && swaps > 0) {
  2771. swap = address[pieceIndex];
  2772. address[pieceIndex--] = address[compress + swaps - 1];
  2773. address[compress + --swaps] = swap;
  2774. }
  2775. } else if (pieceIndex != 8) return;
  2776. return address;
  2777. };
  2778. var findLongestZeroSequence = function (ipv6) {
  2779. var maxIndex = null;
  2780. var maxLength = 1;
  2781. var currStart = null;
  2782. var currLength = 0;
  2783. var index = 0;
  2784. for (; index < 8; index++) {
  2785. if (ipv6[index] !== 0) {
  2786. if (currLength > maxLength) {
  2787. maxIndex = currStart;
  2788. maxLength = currLength;
  2789. }
  2790. currStart = null;
  2791. currLength = 0;
  2792. } else {
  2793. if (currStart === null) currStart = index;
  2794. ++currLength;
  2795. }
  2796. }
  2797. if (currLength > maxLength) {
  2798. maxIndex = currStart;
  2799. maxLength = currLength;
  2800. }
  2801. return maxIndex;
  2802. };
  2803. var serializeHost = function (host) {
  2804. var result, index, compress, ignore0;
  2805. // ipv4
  2806. if (typeof host == 'number') {
  2807. result = [];
  2808. for (index = 0; index < 4; index++) {
  2809. result.unshift(host % 256);
  2810. host = floor$3(host / 256);
  2811. } return result.join('.');
  2812. // ipv6
  2813. } else if (typeof host == 'object') {
  2814. result = '';
  2815. compress = findLongestZeroSequence(host);
  2816. for (index = 0; index < 8; index++) {
  2817. if (ignore0 && host[index] === 0) continue;
  2818. if (ignore0) ignore0 = false;
  2819. if (compress === index) {
  2820. result += index ? ':' : '::';
  2821. ignore0 = true;
  2822. } else {
  2823. result += host[index].toString(16);
  2824. if (index < 7) result += ':';
  2825. }
  2826. }
  2827. return '[' + result + ']';
  2828. } return host;
  2829. };
  2830. var C0ControlPercentEncodeSet = {};
  2831. var fragmentPercentEncodeSet = objectAssign({}, C0ControlPercentEncodeSet, {
  2832. ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
  2833. });
  2834. var pathPercentEncodeSet = objectAssign({}, fragmentPercentEncodeSet, {
  2835. '#': 1, '?': 1, '{': 1, '}': 1
  2836. });
  2837. var userinfoPercentEncodeSet = objectAssign({}, pathPercentEncodeSet, {
  2838. '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
  2839. });
  2840. var percentEncode = function (char, set) {
  2841. var code = codeAt(char, 0);
  2842. return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);
  2843. };
  2844. var specialSchemes = {
  2845. ftp: 21,
  2846. file: null,
  2847. http: 80,
  2848. https: 443,
  2849. ws: 80,
  2850. wss: 443
  2851. };
  2852. var isSpecial = function (url) {
  2853. return has(specialSchemes, url.scheme);
  2854. };
  2855. var includesCredentials = function (url) {
  2856. return url.username != '' || url.password != '';
  2857. };
  2858. var cannotHaveUsernamePasswordPort = function (url) {
  2859. return !url.host || url.cannotBeABaseURL || url.scheme == 'file';
  2860. };
  2861. var isWindowsDriveLetter = function (string, normalized) {
  2862. var second;
  2863. return string.length == 2 && ALPHA.test(string.charAt(0))
  2864. && ((second = string.charAt(1)) == ':' || (!normalized && second == '|'));
  2865. };
  2866. var startsWithWindowsDriveLetter = function (string) {
  2867. var third;
  2868. return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (
  2869. string.length == 2 ||
  2870. ((third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#')
  2871. );
  2872. };
  2873. var shortenURLsPath = function (url) {
  2874. var path = url.path;
  2875. var pathSize = path.length;
  2876. if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  2877. path.pop();
  2878. }
  2879. };
  2880. var isSingleDot = function (segment) {
  2881. return segment === '.' || segment.toLowerCase() === '%2e';
  2882. };
  2883. var isDoubleDot = function (segment) {
  2884. segment = segment.toLowerCase();
  2885. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  2886. };
  2887. // States:
  2888. var SCHEME_START = {};
  2889. var SCHEME = {};
  2890. var NO_SCHEME = {};
  2891. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  2892. var PATH_OR_AUTHORITY = {};
  2893. var RELATIVE = {};
  2894. var RELATIVE_SLASH = {};
  2895. var SPECIAL_AUTHORITY_SLASHES = {};
  2896. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  2897. var AUTHORITY = {};
  2898. var HOST = {};
  2899. var HOSTNAME = {};
  2900. var PORT = {};
  2901. var FILE = {};
  2902. var FILE_SLASH = {};
  2903. var FILE_HOST = {};
  2904. var PATH_START = {};
  2905. var PATH = {};
  2906. var CANNOT_BE_A_BASE_URL_PATH = {};
  2907. var QUERY = {};
  2908. var FRAGMENT = {};
  2909. // eslint-disable-next-line max-statements
  2910. var parseURL = function (url, input, stateOverride, base) {
  2911. var state = stateOverride || SCHEME_START;
  2912. var pointer = 0;
  2913. var buffer = '';
  2914. var seenAt = false;
  2915. var seenBracket = false;
  2916. var seenPasswordToken = false;
  2917. var codePoints, char, bufferCodePoints, failure;
  2918. if (!stateOverride) {
  2919. url.scheme = '';
  2920. url.username = '';
  2921. url.password = '';
  2922. url.host = null;
  2923. url.port = null;
  2924. url.path = [];
  2925. url.query = null;
  2926. url.fragment = null;
  2927. url.cannotBeABaseURL = false;
  2928. input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  2929. }
  2930. input = input.replace(TAB_AND_NEW_LINE, '');
  2931. codePoints = arrayFrom(input);
  2932. while (pointer <= codePoints.length) {
  2933. char = codePoints[pointer];
  2934. switch (state) {
  2935. case SCHEME_START:
  2936. if (char && ALPHA.test(char)) {
  2937. buffer += char.toLowerCase();
  2938. state = SCHEME;
  2939. } else if (!stateOverride) {
  2940. state = NO_SCHEME;
  2941. continue;
  2942. } else return INVALID_SCHEME;
  2943. break;
  2944. case SCHEME:
  2945. if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {
  2946. buffer += char.toLowerCase();
  2947. } else if (char == ':') {
  2948. if (stateOverride && (
  2949. (isSpecial(url) != has(specialSchemes, buffer)) ||
  2950. (buffer == 'file' && (includesCredentials(url) || url.port !== null)) ||
  2951. (url.scheme == 'file' && !url.host)
  2952. )) return;
  2953. url.scheme = buffer;
  2954. if (stateOverride) {
  2955. if (isSpecial(url) && specialSchemes[url.scheme] == url.port) url.port = null;
  2956. return;
  2957. }
  2958. buffer = '';
  2959. if (url.scheme == 'file') {
  2960. state = FILE;
  2961. } else if (isSpecial(url) && base && base.scheme == url.scheme) {
  2962. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  2963. } else if (isSpecial(url)) {
  2964. state = SPECIAL_AUTHORITY_SLASHES;
  2965. } else if (codePoints[pointer + 1] == '/') {
  2966. state = PATH_OR_AUTHORITY;
  2967. pointer++;
  2968. } else {
  2969. url.cannotBeABaseURL = true;
  2970. url.path.push('');
  2971. state = CANNOT_BE_A_BASE_URL_PATH;
  2972. }
  2973. } else if (!stateOverride) {
  2974. buffer = '';
  2975. state = NO_SCHEME;
  2976. pointer = 0;
  2977. continue;
  2978. } else return INVALID_SCHEME;
  2979. break;
  2980. case NO_SCHEME:
  2981. if (!base || (base.cannotBeABaseURL && char != '#')) return INVALID_SCHEME;
  2982. if (base.cannotBeABaseURL && char == '#') {
  2983. url.scheme = base.scheme;
  2984. url.path = base.path.slice();
  2985. url.query = base.query;
  2986. url.fragment = '';
  2987. url.cannotBeABaseURL = true;
  2988. state = FRAGMENT;
  2989. break;
  2990. }
  2991. state = base.scheme == 'file' ? FILE : RELATIVE;
  2992. continue;
  2993. case SPECIAL_RELATIVE_OR_AUTHORITY:
  2994. if (char == '/' && codePoints[pointer + 1] == '/') {
  2995. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  2996. pointer++;
  2997. } else {
  2998. state = RELATIVE;
  2999. continue;
  3000. } break;
  3001. case PATH_OR_AUTHORITY:
  3002. if (char == '/') {
  3003. state = AUTHORITY;
  3004. break;
  3005. } else {
  3006. state = PATH;
  3007. continue;
  3008. }
  3009. case RELATIVE:
  3010. url.scheme = base.scheme;
  3011. if (char == EOF) {
  3012. url.username = base.username;
  3013. url.password = base.password;
  3014. url.host = base.host;
  3015. url.port = base.port;
  3016. url.path = base.path.slice();
  3017. url.query = base.query;
  3018. } else if (char == '/' || (char == '\\' && isSpecial(url))) {
  3019. state = RELATIVE_SLASH;
  3020. } else if (char == '?') {
  3021. url.username = base.username;
  3022. url.password = base.password;
  3023. url.host = base.host;
  3024. url.port = base.port;
  3025. url.path = base.path.slice();
  3026. url.query = '';
  3027. state = QUERY;
  3028. } else if (char == '#') {
  3029. url.username = base.username;
  3030. url.password = base.password;
  3031. url.host = base.host;
  3032. url.port = base.port;
  3033. url.path = base.path.slice();
  3034. url.query = base.query;
  3035. url.fragment = '';
  3036. state = FRAGMENT;
  3037. } else {
  3038. url.username = base.username;
  3039. url.password = base.password;
  3040. url.host = base.host;
  3041. url.port = base.port;
  3042. url.path = base.path.slice();
  3043. url.path.pop();
  3044. state = PATH;
  3045. continue;
  3046. } break;
  3047. case RELATIVE_SLASH:
  3048. if (isSpecial(url) && (char == '/' || char == '\\')) {
  3049. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  3050. } else if (char == '/') {
  3051. state = AUTHORITY;
  3052. } else {
  3053. url.username = base.username;
  3054. url.password = base.password;
  3055. url.host = base.host;
  3056. url.port = base.port;
  3057. state = PATH;
  3058. continue;
  3059. } break;
  3060. case SPECIAL_AUTHORITY_SLASHES:
  3061. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  3062. if (char != '/' || buffer.charAt(pointer + 1) != '/') continue;
  3063. pointer++;
  3064. break;
  3065. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  3066. if (char != '/' && char != '\\') {
  3067. state = AUTHORITY;
  3068. continue;
  3069. } break;
  3070. case AUTHORITY:
  3071. if (char == '@') {
  3072. if (seenAt) buffer = '%40' + buffer;
  3073. seenAt = true;
  3074. bufferCodePoints = arrayFrom(buffer);
  3075. for (var i = 0; i < bufferCodePoints.length; i++) {
  3076. var codePoint = bufferCodePoints[i];
  3077. if (codePoint == ':' && !seenPasswordToken) {
  3078. seenPasswordToken = true;
  3079. continue;
  3080. }
  3081. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  3082. if (seenPasswordToken) url.password += encodedCodePoints;
  3083. else url.username += encodedCodePoints;
  3084. }
  3085. buffer = '';
  3086. } else if (
  3087. char == EOF || char == '/' || char == '?' || char == '#' ||
  3088. (char == '\\' && isSpecial(url))
  3089. ) {
  3090. if (seenAt && buffer == '') return INVALID_AUTHORITY;
  3091. pointer -= arrayFrom(buffer).length + 1;
  3092. buffer = '';
  3093. state = HOST;
  3094. } else buffer += char;
  3095. break;
  3096. case HOST:
  3097. case HOSTNAME:
  3098. if (stateOverride && url.scheme == 'file') {
  3099. state = FILE_HOST;
  3100. continue;
  3101. } else if (char == ':' && !seenBracket) {
  3102. if (buffer == '') return INVALID_HOST;
  3103. failure = parseHost(url, buffer);
  3104. if (failure) return failure;
  3105. buffer = '';
  3106. state = PORT;
  3107. if (stateOverride == HOSTNAME) return;
  3108. } else if (
  3109. char == EOF || char == '/' || char == '?' || char == '#' ||
  3110. (char == '\\' && isSpecial(url))
  3111. ) {
  3112. if (isSpecial(url) && buffer == '') return INVALID_HOST;
  3113. if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null)) return;
  3114. failure = parseHost(url, buffer);
  3115. if (failure) return failure;
  3116. buffer = '';
  3117. state = PATH_START;
  3118. if (stateOverride) return;
  3119. continue;
  3120. } else {
  3121. if (char == '[') seenBracket = true;
  3122. else if (char == ']') seenBracket = false;
  3123. buffer += char;
  3124. } break;
  3125. case PORT:
  3126. if (DIGIT.test(char)) {
  3127. buffer += char;
  3128. } else if (
  3129. char == EOF || char == '/' || char == '?' || char == '#' ||
  3130. (char == '\\' && isSpecial(url)) ||
  3131. stateOverride
  3132. ) {
  3133. if (buffer != '') {
  3134. var port = parseInt(buffer, 10);
  3135. if (port > 0xFFFF) return INVALID_PORT;
  3136. url.port = (isSpecial(url) && port === specialSchemes[url.scheme]) ? null : port;
  3137. buffer = '';
  3138. }
  3139. if (stateOverride) return;
  3140. state = PATH_START;
  3141. continue;
  3142. } else return INVALID_PORT;
  3143. break;
  3144. case FILE:
  3145. url.scheme = 'file';
  3146. if (char == '/' || char == '\\') state = FILE_SLASH;
  3147. else if (base && base.scheme == 'file') {
  3148. if (char == EOF) {
  3149. url.host = base.host;
  3150. url.path = base.path.slice();
  3151. url.query = base.query;
  3152. } else if (char == '?') {
  3153. url.host = base.host;
  3154. url.path = base.path.slice();
  3155. url.query = '';
  3156. state = QUERY;
  3157. } else if (char == '#') {
  3158. url.host = base.host;
  3159. url.path = base.path.slice();
  3160. url.query = base.query;
  3161. url.fragment = '';
  3162. state = FRAGMENT;
  3163. } else {
  3164. if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  3165. url.host = base.host;
  3166. url.path = base.path.slice();
  3167. shortenURLsPath(url);
  3168. }
  3169. state = PATH;
  3170. continue;
  3171. }
  3172. } else {
  3173. state = PATH;
  3174. continue;
  3175. } break;
  3176. case FILE_SLASH:
  3177. if (char == '/' || char == '\\') {
  3178. state = FILE_HOST;
  3179. break;
  3180. }
  3181. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  3182. if (isWindowsDriveLetter(base.path[0], true)) url.path.push(base.path[0]);
  3183. else url.host = base.host;
  3184. }
  3185. state = PATH;
  3186. continue;
  3187. case FILE_HOST:
  3188. if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') {
  3189. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  3190. state = PATH;
  3191. } else if (buffer == '') {
  3192. url.host = '';
  3193. if (stateOverride) return;
  3194. state = PATH_START;
  3195. } else {
  3196. failure = parseHost(url, buffer);
  3197. if (failure) return failure;
  3198. if (url.host == 'localhost') url.host = '';
  3199. if (stateOverride) return;
  3200. buffer = '';
  3201. state = PATH_START;
  3202. } continue;
  3203. } else buffer += char;
  3204. break;
  3205. case PATH_START:
  3206. if (isSpecial(url)) {
  3207. state = PATH;
  3208. if (char != '/' && char != '\\') continue;
  3209. } else if (!stateOverride && char == '?') {
  3210. url.query = '';
  3211. state = QUERY;
  3212. } else if (!stateOverride && char == '#') {
  3213. url.fragment = '';
  3214. state = FRAGMENT;
  3215. } else if (char != EOF) {
  3216. state = PATH;
  3217. if (char != '/') continue;
  3218. } break;
  3219. case PATH:
  3220. if (
  3221. char == EOF || char == '/' ||
  3222. (char == '\\' && isSpecial(url)) ||
  3223. (!stateOverride && (char == '?' || char == '#'))
  3224. ) {
  3225. if (isDoubleDot(buffer)) {
  3226. shortenURLsPath(url);
  3227. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  3228. url.path.push('');
  3229. }
  3230. } else if (isSingleDot(buffer)) {
  3231. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  3232. url.path.push('');
  3233. }
  3234. } else {
  3235. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  3236. if (url.host) url.host = '';
  3237. buffer = buffer.charAt(0) + ':'; // normalize windows drive letter
  3238. }
  3239. url.path.push(buffer);
  3240. }
  3241. buffer = '';
  3242. if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {
  3243. while (url.path.length > 1 && url.path[0] === '') {
  3244. url.path.shift();
  3245. }
  3246. }
  3247. if (char == '?') {
  3248. url.query = '';
  3249. state = QUERY;
  3250. } else if (char == '#') {
  3251. url.fragment = '';
  3252. state = FRAGMENT;
  3253. }
  3254. } else {
  3255. buffer += percentEncode(char, pathPercentEncodeSet);
  3256. } break;
  3257. case CANNOT_BE_A_BASE_URL_PATH:
  3258. if (char == '?') {
  3259. url.query = '';
  3260. state = QUERY;
  3261. } else if (char == '#') {
  3262. url.fragment = '';
  3263. state = FRAGMENT;
  3264. } else if (char != EOF) {
  3265. url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);
  3266. } break;
  3267. case QUERY:
  3268. if (!stateOverride && char == '#') {
  3269. url.fragment = '';
  3270. state = FRAGMENT;
  3271. } else if (char != EOF) {
  3272. if (char == "'" && isSpecial(url)) url.query += '%27';
  3273. else if (char == '#') url.query += '%23';
  3274. else url.query += percentEncode(char, C0ControlPercentEncodeSet);
  3275. } break;
  3276. case FRAGMENT:
  3277. if (char != EOF) url.fragment += percentEncode(char, fragmentPercentEncodeSet);
  3278. break;
  3279. }
  3280. pointer++;
  3281. }
  3282. };
  3283. // `URL` constructor
  3284. // https://url.spec.whatwg.org/#url-class
  3285. var URLConstructor = function URL(url /* , base */) {
  3286. var that = anInstance(this, URLConstructor, 'URL');
  3287. var base = arguments.length > 1 ? arguments[1] : undefined;
  3288. var urlString = String(url);
  3289. var state = setInternalState$4(that, { type: 'URL' });
  3290. var baseState, failure;
  3291. if (base !== undefined) {
  3292. if (base instanceof URLConstructor) baseState = getInternalURLState(base);
  3293. else {
  3294. failure = parseURL(baseState = {}, String(base));
  3295. if (failure) throw TypeError(failure);
  3296. }
  3297. }
  3298. failure = parseURL(state, urlString, null, baseState);
  3299. if (failure) throw TypeError(failure);
  3300. var searchParams = state.searchParams = new URLSearchParams$1();
  3301. var searchParamsState = getInternalSearchParamsState(searchParams);
  3302. searchParamsState.updateSearchParams(state.query);
  3303. searchParamsState.updateURL = function () {
  3304. state.query = String(searchParams) || null;
  3305. };
  3306. if (!descriptors) {
  3307. that.href = serializeURL.call(that);
  3308. that.origin = getOrigin.call(that);
  3309. that.protocol = getProtocol.call(that);
  3310. that.username = getUsername.call(that);
  3311. that.password = getPassword.call(that);
  3312. that.host = getHost.call(that);
  3313. that.hostname = getHostname.call(that);
  3314. that.port = getPort.call(that);
  3315. that.pathname = getPathname.call(that);
  3316. that.search = getSearch.call(that);
  3317. that.searchParams = getSearchParams.call(that);
  3318. that.hash = getHash.call(that);
  3319. }
  3320. };
  3321. var URLPrototype = URLConstructor.prototype;
  3322. var serializeURL = function () {
  3323. var url = getInternalURLState(this);
  3324. var scheme = url.scheme;
  3325. var username = url.username;
  3326. var password = url.password;
  3327. var host = url.host;
  3328. var port = url.port;
  3329. var path = url.path;
  3330. var query = url.query;
  3331. var fragment = url.fragment;
  3332. var output = scheme + ':';
  3333. if (host !== null) {
  3334. output += '//';
  3335. if (includesCredentials(url)) {
  3336. output += username + (password ? ':' + password : '') + '@';
  3337. }
  3338. output += serializeHost(host);
  3339. if (port !== null) output += ':' + port;
  3340. } else if (scheme == 'file') output += '//';
  3341. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  3342. if (query !== null) output += '?' + query;
  3343. if (fragment !== null) output += '#' + fragment;
  3344. return output;
  3345. };
  3346. var getOrigin = function () {
  3347. var url = getInternalURLState(this);
  3348. var scheme = url.scheme;
  3349. var port = url.port;
  3350. if (scheme == 'blob') try {
  3351. return new URL(scheme.path[0]).origin;
  3352. } catch (error) {
  3353. return 'null';
  3354. }
  3355. if (scheme == 'file' || !isSpecial(url)) return 'null';
  3356. return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');
  3357. };
  3358. var getProtocol = function () {
  3359. return getInternalURLState(this).scheme + ':';
  3360. };
  3361. var getUsername = function () {
  3362. return getInternalURLState(this).username;
  3363. };
  3364. var getPassword = function () {
  3365. return getInternalURLState(this).password;
  3366. };
  3367. var getHost = function () {
  3368. var url = getInternalURLState(this);
  3369. var host = url.host;
  3370. var port = url.port;
  3371. return host === null ? ''
  3372. : port === null ? serializeHost(host)
  3373. : serializeHost(host) + ':' + port;
  3374. };
  3375. var getHostname = function () {
  3376. var host = getInternalURLState(this).host;
  3377. return host === null ? '' : serializeHost(host);
  3378. };
  3379. var getPort = function () {
  3380. var port = getInternalURLState(this).port;
  3381. return port === null ? '' : String(port);
  3382. };
  3383. var getPathname = function () {
  3384. var url = getInternalURLState(this);
  3385. var path = url.path;
  3386. return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  3387. };
  3388. var getSearch = function () {
  3389. var query = getInternalURLState(this).query;
  3390. return query ? '?' + query : '';
  3391. };
  3392. var getSearchParams = function () {
  3393. return getInternalURLState(this).searchParams;
  3394. };
  3395. var getHash = function () {
  3396. var fragment = getInternalURLState(this).fragment;
  3397. return fragment ? '#' + fragment : '';
  3398. };
  3399. var accessorDescriptor = function (getter, setter) {
  3400. return { get: getter, set: setter, configurable: true, enumerable: true };
  3401. };
  3402. if (descriptors) {
  3403. objectDefineProperties(URLPrototype, {
  3404. // `URL.prototype.href` accessors pair
  3405. // https://url.spec.whatwg.org/#dom-url-href
  3406. href: accessorDescriptor(serializeURL, function (href) {
  3407. var url = getInternalURLState(this);
  3408. var urlString = String(href);
  3409. var failure = parseURL(url, urlString);
  3410. if (failure) throw TypeError(failure);
  3411. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  3412. }),
  3413. // `URL.prototype.origin` getter
  3414. // https://url.spec.whatwg.org/#dom-url-origin
  3415. origin: accessorDescriptor(getOrigin),
  3416. // `URL.prototype.protocol` accessors pair
  3417. // https://url.spec.whatwg.org/#dom-url-protocol
  3418. protocol: accessorDescriptor(getProtocol, function (protocol) {
  3419. var url = getInternalURLState(this);
  3420. parseURL(url, String(protocol) + ':', SCHEME_START);
  3421. }),
  3422. // `URL.prototype.username` accessors pair
  3423. // https://url.spec.whatwg.org/#dom-url-username
  3424. username: accessorDescriptor(getUsername, function (username) {
  3425. var url = getInternalURLState(this);
  3426. var codePoints = arrayFrom(String(username));
  3427. if (cannotHaveUsernamePasswordPort(url)) return;
  3428. url.username = '';
  3429. for (var i = 0; i < codePoints.length; i++) {
  3430. url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  3431. }
  3432. }),
  3433. // `URL.prototype.password` accessors pair
  3434. // https://url.spec.whatwg.org/#dom-url-password
  3435. password: accessorDescriptor(getPassword, function (password) {
  3436. var url = getInternalURLState(this);
  3437. var codePoints = arrayFrom(String(password));
  3438. if (cannotHaveUsernamePasswordPort(url)) return;
  3439. url.password = '';
  3440. for (var i = 0; i < codePoints.length; i++) {
  3441. url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  3442. }
  3443. }),
  3444. // `URL.prototype.host` accessors pair
  3445. // https://url.spec.whatwg.org/#dom-url-host
  3446. host: accessorDescriptor(getHost, function (host) {
  3447. var url = getInternalURLState(this);
  3448. if (url.cannotBeABaseURL) return;
  3449. parseURL(url, String(host), HOST);
  3450. }),
  3451. // `URL.prototype.hostname` accessors pair
  3452. // https://url.spec.whatwg.org/#dom-url-hostname
  3453. hostname: accessorDescriptor(getHostname, function (hostname) {
  3454. var url = getInternalURLState(this);
  3455. if (url.cannotBeABaseURL) return;
  3456. parseURL(url, String(hostname), HOSTNAME);
  3457. }),
  3458. // `URL.prototype.port` accessors pair
  3459. // https://url.spec.whatwg.org/#dom-url-port
  3460. port: accessorDescriptor(getPort, function (port) {
  3461. var url = getInternalURLState(this);
  3462. if (cannotHaveUsernamePasswordPort(url)) return;
  3463. port = String(port);
  3464. if (port == '') url.port = null;
  3465. else parseURL(url, port, PORT);
  3466. }),
  3467. // `URL.prototype.pathname` accessors pair
  3468. // https://url.spec.whatwg.org/#dom-url-pathname
  3469. pathname: accessorDescriptor(getPathname, function (pathname) {
  3470. var url = getInternalURLState(this);
  3471. if (url.cannotBeABaseURL) return;
  3472. url.path = [];
  3473. parseURL(url, pathname + '', PATH_START);
  3474. }),
  3475. // `URL.prototype.search` accessors pair
  3476. // https://url.spec.whatwg.org/#dom-url-search
  3477. search: accessorDescriptor(getSearch, function (search) {
  3478. var url = getInternalURLState(this);
  3479. search = String(search);
  3480. if (search == '') {
  3481. url.query = null;
  3482. } else {
  3483. if ('?' == search.charAt(0)) search = search.slice(1);
  3484. url.query = '';
  3485. parseURL(url, search, QUERY);
  3486. }
  3487. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  3488. }),
  3489. // `URL.prototype.searchParams` getter
  3490. // https://url.spec.whatwg.org/#dom-url-searchparams
  3491. searchParams: accessorDescriptor(getSearchParams),
  3492. // `URL.prototype.hash` accessors pair
  3493. // https://url.spec.whatwg.org/#dom-url-hash
  3494. hash: accessorDescriptor(getHash, function (hash) {
  3495. var url = getInternalURLState(this);
  3496. hash = String(hash);
  3497. if (hash == '') {
  3498. url.fragment = null;
  3499. return;
  3500. }
  3501. if ('#' == hash.charAt(0)) hash = hash.slice(1);
  3502. url.fragment = '';
  3503. parseURL(url, hash, FRAGMENT);
  3504. })
  3505. });
  3506. }
  3507. // `URL.prototype.toJSON` method
  3508. // https://url.spec.whatwg.org/#dom-url-tojson
  3509. redefine(URLPrototype, 'toJSON', function toJSON() {
  3510. return serializeURL.call(this);
  3511. }, { enumerable: true });
  3512. // `URL.prototype.toString` method
  3513. // https://url.spec.whatwg.org/#URL-stringification-behavior
  3514. redefine(URLPrototype, 'toString', function toString() {
  3515. return serializeURL.call(this);
  3516. }, { enumerable: true });
  3517. if (NativeURL) {
  3518. var nativeCreateObjectURL = NativeURL.createObjectURL;
  3519. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  3520. // `URL.createObjectURL` method
  3521. // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
  3522. // eslint-disable-next-line no-unused-vars
  3523. if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {
  3524. return nativeCreateObjectURL.apply(NativeURL, arguments);
  3525. });
  3526. // `URL.revokeObjectURL` method
  3527. // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
  3528. // eslint-disable-next-line no-unused-vars
  3529. if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {
  3530. return nativeRevokeObjectURL.apply(NativeURL, arguments);
  3531. });
  3532. }
  3533. setToStringTag(URLConstructor, 'URL');
  3534. _export({ global: true, forced: !nativeUrl, sham: !descriptors }, {
  3535. URL: URLConstructor
  3536. });
  3537. function _typeof(obj) {
  3538. "@babel/helpers - typeof";
  3539. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  3540. _typeof = function (obj) {
  3541. return typeof obj;
  3542. };
  3543. } else {
  3544. _typeof = function (obj) {
  3545. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  3546. };
  3547. }
  3548. return _typeof(obj);
  3549. }
  3550. function _classCallCheck(instance, Constructor) {
  3551. if (!(instance instanceof Constructor)) {
  3552. throw new TypeError("Cannot call a class as a function");
  3553. }
  3554. }
  3555. function _defineProperties(target, props) {
  3556. for (var i = 0; i < props.length; i++) {
  3557. var descriptor = props[i];
  3558. descriptor.enumerable = descriptor.enumerable || false;
  3559. descriptor.configurable = true;
  3560. if ("value" in descriptor) descriptor.writable = true;
  3561. Object.defineProperty(target, descriptor.key, descriptor);
  3562. }
  3563. }
  3564. function _createClass(Constructor, protoProps, staticProps) {
  3565. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  3566. if (staticProps) _defineProperties(Constructor, staticProps);
  3567. return Constructor;
  3568. }
  3569. function _defineProperty(obj, key, value) {
  3570. if (key in obj) {
  3571. Object.defineProperty(obj, key, {
  3572. value: value,
  3573. enumerable: true,
  3574. configurable: true,
  3575. writable: true
  3576. });
  3577. } else {
  3578. obj[key] = value;
  3579. }
  3580. return obj;
  3581. }
  3582. function ownKeys$1(object, enumerableOnly) {
  3583. var keys = Object.keys(object);
  3584. if (Object.getOwnPropertySymbols) {
  3585. var symbols = Object.getOwnPropertySymbols(object);
  3586. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  3587. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  3588. });
  3589. keys.push.apply(keys, symbols);
  3590. }
  3591. return keys;
  3592. }
  3593. function _objectSpread2(target) {
  3594. for (var i = 1; i < arguments.length; i++) {
  3595. var source = arguments[i] != null ? arguments[i] : {};
  3596. if (i % 2) {
  3597. ownKeys$1(Object(source), true).forEach(function (key) {
  3598. _defineProperty(target, key, source[key]);
  3599. });
  3600. } else if (Object.getOwnPropertyDescriptors) {
  3601. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  3602. } else {
  3603. ownKeys$1(Object(source)).forEach(function (key) {
  3604. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  3605. });
  3606. }
  3607. }
  3608. return target;
  3609. }
  3610. function _objectWithoutPropertiesLoose(source, excluded) {
  3611. if (source == null) return {};
  3612. var target = {};
  3613. var sourceKeys = Object.keys(source);
  3614. var key, i;
  3615. for (i = 0; i < sourceKeys.length; i++) {
  3616. key = sourceKeys[i];
  3617. if (excluded.indexOf(key) >= 0) continue;
  3618. target[key] = source[key];
  3619. }
  3620. return target;
  3621. }
  3622. function _objectWithoutProperties(source, excluded) {
  3623. if (source == null) return {};
  3624. var target = _objectWithoutPropertiesLoose(source, excluded);
  3625. var key, i;
  3626. if (Object.getOwnPropertySymbols) {
  3627. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  3628. for (i = 0; i < sourceSymbolKeys.length; i++) {
  3629. key = sourceSymbolKeys[i];
  3630. if (excluded.indexOf(key) >= 0) continue;
  3631. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  3632. target[key] = source[key];
  3633. }
  3634. }
  3635. return target;
  3636. }
  3637. function _slicedToArray(arr, i) {
  3638. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  3639. }
  3640. function _toConsumableArray(arr) {
  3641. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  3642. }
  3643. function _arrayWithoutHoles(arr) {
  3644. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  3645. }
  3646. function _arrayWithHoles(arr) {
  3647. if (Array.isArray(arr)) return arr;
  3648. }
  3649. function _iterableToArray(iter) {
  3650. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  3651. }
  3652. function _iterableToArrayLimit(arr, i) {
  3653. if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
  3654. var _arr = [];
  3655. var _n = true;
  3656. var _d = false;
  3657. var _e = undefined;
  3658. try {
  3659. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  3660. _arr.push(_s.value);
  3661. if (i && _arr.length === i) break;
  3662. }
  3663. } catch (err) {
  3664. _d = true;
  3665. _e = err;
  3666. } finally {
  3667. try {
  3668. if (!_n && _i["return"] != null) _i["return"]();
  3669. } finally {
  3670. if (_d) throw _e;
  3671. }
  3672. }
  3673. return _arr;
  3674. }
  3675. function _unsupportedIterableToArray(o, minLen) {
  3676. if (!o) return;
  3677. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3678. var n = Object.prototype.toString.call(o).slice(8, -1);
  3679. if (n === "Object" && o.constructor) n = o.constructor.name;
  3680. if (n === "Map" || n === "Set") return Array.from(o);
  3681. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3682. }
  3683. function _arrayLikeToArray(arr, len) {
  3684. if (len == null || len > arr.length) len = arr.length;
  3685. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3686. return arr2;
  3687. }
  3688. function _nonIterableSpread() {
  3689. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3690. }
  3691. function _nonIterableRest() {
  3692. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3693. }
  3694. (function (global) {
  3695. /**
  3696. * Polyfill URLSearchParams
  3697. *
  3698. * Inspired from : https://github.com/WebReflection/url-search-params/blob/master/src/url-search-params.js
  3699. */
  3700. var checkIfIteratorIsSupported = function checkIfIteratorIsSupported() {
  3701. try {
  3702. return !!Symbol.iterator;
  3703. } catch (error) {
  3704. return false;
  3705. }
  3706. };
  3707. var iteratorSupported = checkIfIteratorIsSupported();
  3708. var createIterator = function createIterator(items) {
  3709. var iterator = {
  3710. next: function next() {
  3711. var value = items.shift();
  3712. return {
  3713. done: value === void 0,
  3714. value: value
  3715. };
  3716. }
  3717. };
  3718. if (iteratorSupported) {
  3719. iterator[Symbol.iterator] = function () {
  3720. return iterator;
  3721. };
  3722. }
  3723. return iterator;
  3724. };
  3725. /**
  3726. * Search param name and values should be encoded according to https://url.spec.whatwg.org/#urlencoded-serializing
  3727. * encodeURIComponent() produces the same result except encoding spaces as `%20` instead of `+`.
  3728. */
  3729. var serializeParam = function serializeParam(value) {
  3730. return encodeURIComponent(value).replace(/%20/g, '+');
  3731. };
  3732. var deserializeParam = function deserializeParam(value) {
  3733. return decodeURIComponent(String(value).replace(/\+/g, ' '));
  3734. };
  3735. var polyfillURLSearchParams = function polyfillURLSearchParams() {
  3736. var URLSearchParams = function URLSearchParams(searchString) {
  3737. Object.defineProperty(this, '_entries', {
  3738. writable: true,
  3739. value: {}
  3740. });
  3741. var typeofSearchString = _typeof(searchString);
  3742. if (typeofSearchString === 'undefined') ; else if (typeofSearchString === 'string') {
  3743. if (searchString !== '') {
  3744. this._fromString(searchString);
  3745. }
  3746. } else if (searchString instanceof URLSearchParams) {
  3747. var _this = this;
  3748. searchString.forEach(function (value, name) {
  3749. _this.append(name, value);
  3750. });
  3751. } else if (searchString !== null && typeofSearchString === 'object') {
  3752. if (Object.prototype.toString.call(searchString) === '[object Array]') {
  3753. for (var i = 0; i < searchString.length; i++) {
  3754. var entry = searchString[i];
  3755. if (Object.prototype.toString.call(entry) === '[object Array]' || entry.length !== 2) {
  3756. this.append(entry[0], entry[1]);
  3757. } else {
  3758. throw new TypeError('Expected [string, any] as entry at index ' + i + ' of URLSearchParams\'s input');
  3759. }
  3760. }
  3761. } else {
  3762. for (var key in searchString) {
  3763. if (searchString.hasOwnProperty(key)) {
  3764. this.append(key, searchString[key]);
  3765. }
  3766. }
  3767. }
  3768. } else {
  3769. throw new TypeError('Unsupported input\'s type for URLSearchParams');
  3770. }
  3771. };
  3772. var proto = URLSearchParams.prototype;
  3773. proto.append = function (name, value) {
  3774. if (name in this._entries) {
  3775. this._entries[name].push(String(value));
  3776. } else {
  3777. this._entries[name] = [String(value)];
  3778. }
  3779. };
  3780. proto.delete = function (name) {
  3781. delete this._entries[name];
  3782. };
  3783. proto.get = function (name) {
  3784. return name in this._entries ? this._entries[name][0] : null;
  3785. };
  3786. proto.getAll = function (name) {
  3787. return name in this._entries ? this._entries[name].slice(0) : [];
  3788. };
  3789. proto.has = function (name) {
  3790. return name in this._entries;
  3791. };
  3792. proto.set = function (name, value) {
  3793. this._entries[name] = [String(value)];
  3794. };
  3795. proto.forEach = function (callback, thisArg) {
  3796. var entries;
  3797. for (var name in this._entries) {
  3798. if (this._entries.hasOwnProperty(name)) {
  3799. entries = this._entries[name];
  3800. for (var i = 0; i < entries.length; i++) {
  3801. callback.call(thisArg, entries[i], name, this);
  3802. }
  3803. }
  3804. }
  3805. };
  3806. proto.keys = function () {
  3807. var items = [];
  3808. this.forEach(function (value, name) {
  3809. items.push(name);
  3810. });
  3811. return createIterator(items);
  3812. };
  3813. proto.values = function () {
  3814. var items = [];
  3815. this.forEach(function (value) {
  3816. items.push(value);
  3817. });
  3818. return createIterator(items);
  3819. };
  3820. proto.entries = function () {
  3821. var items = [];
  3822. this.forEach(function (value, name) {
  3823. items.push([name, value]);
  3824. });
  3825. return createIterator(items);
  3826. };
  3827. if (iteratorSupported) {
  3828. proto[Symbol.iterator] = proto.entries;
  3829. }
  3830. proto.toString = function () {
  3831. var searchArray = [];
  3832. this.forEach(function (value, name) {
  3833. searchArray.push(serializeParam(name) + '=' + serializeParam(value));
  3834. });
  3835. return searchArray.join('&');
  3836. };
  3837. global.URLSearchParams = URLSearchParams;
  3838. };
  3839. var checkIfURLSearchParamsSupported = function checkIfURLSearchParamsSupported() {
  3840. try {
  3841. var URLSearchParams = global.URLSearchParams;
  3842. return new URLSearchParams('?a=1').toString() === 'a=1' && typeof URLSearchParams.prototype.set === 'function';
  3843. } catch (e) {
  3844. return false;
  3845. }
  3846. };
  3847. if (!checkIfURLSearchParamsSupported()) {
  3848. polyfillURLSearchParams();
  3849. }
  3850. var proto = global.URLSearchParams.prototype;
  3851. if (typeof proto.sort !== 'function') {
  3852. proto.sort = function () {
  3853. var _this = this;
  3854. var items = [];
  3855. this.forEach(function (value, name) {
  3856. items.push([name, value]);
  3857. if (!_this._entries) {
  3858. _this.delete(name);
  3859. }
  3860. });
  3861. items.sort(function (a, b) {
  3862. if (a[0] < b[0]) {
  3863. return -1;
  3864. } else if (a[0] > b[0]) {
  3865. return +1;
  3866. } else {
  3867. return 0;
  3868. }
  3869. });
  3870. if (_this._entries) {
  3871. // force reset because IE keeps keys index
  3872. _this._entries = {};
  3873. }
  3874. for (var i = 0; i < items.length; i++) {
  3875. this.append(items[i][0], items[i][1]);
  3876. }
  3877. };
  3878. }
  3879. if (typeof proto._fromString !== 'function') {
  3880. Object.defineProperty(proto, '_fromString', {
  3881. enumerable: false,
  3882. configurable: false,
  3883. writable: false,
  3884. value: function value(searchString) {
  3885. if (this._entries) {
  3886. this._entries = {};
  3887. } else {
  3888. var keys = [];
  3889. this.forEach(function (value, name) {
  3890. keys.push(name);
  3891. });
  3892. for (var i = 0; i < keys.length; i++) {
  3893. this.delete(keys[i]);
  3894. }
  3895. }
  3896. searchString = searchString.replace(/^\?/, '');
  3897. var attributes = searchString.split('&');
  3898. var attribute;
  3899. for (var i = 0; i < attributes.length; i++) {
  3900. attribute = attributes[i].split('=');
  3901. this.append(deserializeParam(attribute[0]), attribute.length > 1 ? deserializeParam(attribute[1]) : '');
  3902. }
  3903. }
  3904. });
  3905. } // HTMLAnchorElement
  3906. })(typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal);
  3907. (function (global) {
  3908. /**
  3909. * Polyfill URL
  3910. *
  3911. * Inspired from : https://github.com/arv/DOM-URL-Polyfill/blob/master/src/url.js
  3912. */
  3913. var checkIfURLIsSupported = function checkIfURLIsSupported() {
  3914. try {
  3915. var u = new global.URL('b', 'http://a');
  3916. u.pathname = 'c d';
  3917. return u.href === 'http://a/c%20d' && u.searchParams;
  3918. } catch (e) {
  3919. return false;
  3920. }
  3921. };
  3922. var polyfillURL = function polyfillURL() {
  3923. var _URL = global.URL;
  3924. var URL = function URL(url, base) {
  3925. if (typeof url !== 'string') url = String(url); // Only create another document if the base is different from current location.
  3926. var doc = document,
  3927. baseElement;
  3928. if (base && (global.location === void 0 || base !== global.location.href)) {
  3929. doc = document.implementation.createHTMLDocument('');
  3930. baseElement = doc.createElement('base');
  3931. baseElement.href = base;
  3932. doc.head.appendChild(baseElement);
  3933. try {
  3934. if (baseElement.href.indexOf(base) !== 0) throw new Error(baseElement.href);
  3935. } catch (err) {
  3936. throw new Error('URL unable to set base ' + base + ' due to ' + err);
  3937. }
  3938. }
  3939. var anchorElement = doc.createElement('a');
  3940. anchorElement.href = url;
  3941. if (baseElement) {
  3942. doc.body.appendChild(anchorElement);
  3943. anchorElement.href = anchorElement.href; // force href to refresh
  3944. }
  3945. var inputElement = doc.createElement('input');
  3946. inputElement.type = 'url';
  3947. inputElement.value = url;
  3948. if (anchorElement.protocol === ':' || !/:/.test(anchorElement.href) || !inputElement.checkValidity() && !base) {
  3949. throw new TypeError('Invalid URL');
  3950. }
  3951. Object.defineProperty(this, '_anchorElement', {
  3952. value: anchorElement
  3953. }); // create a linked searchParams which reflect its changes on URL
  3954. var searchParams = new global.URLSearchParams(this.search);
  3955. var enableSearchUpdate = true;
  3956. var enableSearchParamsUpdate = true;
  3957. var _this = this;
  3958. ['append', 'delete', 'set'].forEach(function (methodName) {
  3959. var method = searchParams[methodName];
  3960. searchParams[methodName] = function () {
  3961. method.apply(searchParams, arguments);
  3962. if (enableSearchUpdate) {
  3963. enableSearchParamsUpdate = false;
  3964. _this.search = searchParams.toString();
  3965. enableSearchParamsUpdate = true;
  3966. }
  3967. };
  3968. });
  3969. Object.defineProperty(this, 'searchParams', {
  3970. value: searchParams,
  3971. enumerable: true
  3972. });
  3973. var search = void 0;
  3974. Object.defineProperty(this, '_updateSearchParams', {
  3975. enumerable: false,
  3976. configurable: false,
  3977. writable: false,
  3978. value: function value() {
  3979. if (this.search !== search) {
  3980. search = this.search;
  3981. if (enableSearchParamsUpdate) {
  3982. enableSearchUpdate = false;
  3983. this.searchParams._fromString(this.search);
  3984. enableSearchUpdate = true;
  3985. }
  3986. }
  3987. }
  3988. });
  3989. };
  3990. var proto = URL.prototype;
  3991. var linkURLWithAnchorAttribute = function linkURLWithAnchorAttribute(attributeName) {
  3992. Object.defineProperty(proto, attributeName, {
  3993. get: function get() {
  3994. return this._anchorElement[attributeName];
  3995. },
  3996. set: function set(value) {
  3997. this._anchorElement[attributeName] = value;
  3998. },
  3999. enumerable: true
  4000. });
  4001. };
  4002. ['hash', 'host', 'hostname', 'port', 'protocol'].forEach(function (attributeName) {
  4003. linkURLWithAnchorAttribute(attributeName);
  4004. });
  4005. Object.defineProperty(proto, 'search', {
  4006. get: function get() {
  4007. return this._anchorElement['search'];
  4008. },
  4009. set: function set(value) {
  4010. this._anchorElement['search'] = value;
  4011. this._updateSearchParams();
  4012. },
  4013. enumerable: true
  4014. });
  4015. Object.defineProperties(proto, {
  4016. 'toString': {
  4017. get: function get() {
  4018. var _this = this;
  4019. return function () {
  4020. return _this.href;
  4021. };
  4022. }
  4023. },
  4024. 'href': {
  4025. get: function get() {
  4026. return this._anchorElement.href.replace(/\?$/, '');
  4027. },
  4028. set: function set(value) {
  4029. this._anchorElement.href = value;
  4030. this._updateSearchParams();
  4031. },
  4032. enumerable: true
  4033. },
  4034. 'pathname': {
  4035. get: function get() {
  4036. return this._anchorElement.pathname.replace(/(^\/?)/, '/');
  4037. },
  4038. set: function set(value) {
  4039. this._anchorElement.pathname = value;
  4040. },
  4041. enumerable: true
  4042. },
  4043. 'origin': {
  4044. get: function get() {
  4045. // get expected port from protocol
  4046. var expectedPort = {
  4047. 'http:': 80,
  4048. 'https:': 443,
  4049. 'ftp:': 21
  4050. }[this._anchorElement.protocol]; // add port to origin if, expected port is different than actual port
  4051. // and it is not empty f.e http://foo:8080
  4052. // 8080 != 80 && 8080 != ''
  4053. var addPortToOrigin = this._anchorElement.port != expectedPort && this._anchorElement.port !== '';
  4054. return this._anchorElement.protocol + '//' + this._anchorElement.hostname + (addPortToOrigin ? ':' + this._anchorElement.port : '');
  4055. },
  4056. enumerable: true
  4057. },
  4058. 'password': {
  4059. // TODO
  4060. get: function get() {
  4061. return '';
  4062. },
  4063. set: function set(value) {},
  4064. enumerable: true
  4065. },
  4066. 'username': {
  4067. // TODO
  4068. get: function get() {
  4069. return '';
  4070. },
  4071. set: function set(value) {},
  4072. enumerable: true
  4073. }
  4074. });
  4075. URL.createObjectURL = function (blob) {
  4076. return _URL.createObjectURL.apply(_URL, arguments);
  4077. };
  4078. URL.revokeObjectURL = function (url) {
  4079. return _URL.revokeObjectURL.apply(_URL, arguments);
  4080. };
  4081. global.URL = URL;
  4082. };
  4083. if (!checkIfURLIsSupported()) {
  4084. polyfillURL();
  4085. }
  4086. if (global.location !== void 0 && !('origin' in global.location)) {
  4087. var getOrigin = function getOrigin() {
  4088. return global.location.protocol + '//' + global.location.hostname + (global.location.port ? ':' + global.location.port : '');
  4089. };
  4090. try {
  4091. Object.defineProperty(global.location, 'origin', {
  4092. get: getOrigin,
  4093. enumerable: true
  4094. });
  4095. } catch (e) {
  4096. setInterval(function () {
  4097. global.location.origin = getOrigin();
  4098. }, 100);
  4099. }
  4100. }
  4101. })(typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal);
  4102. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  4103. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  4104. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  4105. // We can't use this feature detection in V8 since it causes
  4106. // deoptimization and serious performance degradation
  4107. // https://github.com/zloirock/core-js/issues/679
  4108. var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () {
  4109. var array = [];
  4110. array[IS_CONCAT_SPREADABLE] = false;
  4111. return array.concat()[0] !== array;
  4112. });
  4113. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  4114. var isConcatSpreadable = function (O) {
  4115. if (!isObject(O)) return false;
  4116. var spreadable = O[IS_CONCAT_SPREADABLE];
  4117. return spreadable !== undefined ? !!spreadable : isArray(O);
  4118. };
  4119. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  4120. // `Array.prototype.concat` method
  4121. // https://tc39.github.io/ecma262/#sec-array.prototype.concat
  4122. // with adding support of @@isConcatSpreadable and @@species
  4123. _export({ target: 'Array', proto: true, forced: FORCED }, {
  4124. concat: function concat(arg) { // eslint-disable-line no-unused-vars
  4125. var O = toObject(this);
  4126. var A = arraySpeciesCreate(O, 0);
  4127. var n = 0;
  4128. var i, k, length, len, E;
  4129. for (i = -1, length = arguments.length; i < length; i++) {
  4130. E = i === -1 ? O : arguments[i];
  4131. if (isConcatSpreadable(E)) {
  4132. len = toLength(E.length);
  4133. if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  4134. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  4135. } else {
  4136. if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  4137. createProperty(A, n++, E);
  4138. }
  4139. }
  4140. A.length = n;
  4141. return A;
  4142. }
  4143. });
  4144. var $filter = arrayIteration.filter;
  4145. var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('filter');
  4146. // Edge 14- issue
  4147. var USES_TO_LENGTH$3 = arrayMethodUsesToLength('filter');
  4148. // `Array.prototype.filter` method
  4149. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  4150. // with adding support of @@species
  4151. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 || !USES_TO_LENGTH$3 }, {
  4152. filter: function filter(callbackfn /* , thisArg */) {
  4153. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4154. }
  4155. });
  4156. var $find = arrayIteration.find;
  4157. var FIND = 'find';
  4158. var SKIPS_HOLES = true;
  4159. var USES_TO_LENGTH$4 = arrayMethodUsesToLength(FIND);
  4160. // Shouldn't skip holes
  4161. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  4162. // `Array.prototype.find` method
  4163. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  4164. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH$4 }, {
  4165. find: function find(callbackfn /* , that = undefined */) {
  4166. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4167. }
  4168. });
  4169. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  4170. addToUnscopables(FIND);
  4171. var ITERATOR$7 = wellKnownSymbol('iterator');
  4172. var SAFE_CLOSING = false;
  4173. try {
  4174. var called = 0;
  4175. var iteratorWithReturn = {
  4176. next: function () {
  4177. return { done: !!called++ };
  4178. },
  4179. 'return': function () {
  4180. SAFE_CLOSING = true;
  4181. }
  4182. };
  4183. iteratorWithReturn[ITERATOR$7] = function () {
  4184. return this;
  4185. };
  4186. // eslint-disable-next-line no-throw-literal
  4187. Array.from(iteratorWithReturn, function () { throw 2; });
  4188. } catch (error) { /* empty */ }
  4189. var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
  4190. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  4191. var ITERATION_SUPPORT = false;
  4192. try {
  4193. var object = {};
  4194. object[ITERATOR$7] = function () {
  4195. return {
  4196. next: function () {
  4197. return { done: ITERATION_SUPPORT = true };
  4198. }
  4199. };
  4200. };
  4201. exec(object);
  4202. } catch (error) { /* empty */ }
  4203. return ITERATION_SUPPORT;
  4204. };
  4205. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  4206. Array.from(iterable);
  4207. });
  4208. // `Array.from` method
  4209. // https://tc39.github.io/ecma262/#sec-array.from
  4210. _export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  4211. from: arrayFrom
  4212. });
  4213. var $includes = arrayIncludes.includes;
  4214. var USES_TO_LENGTH$5 = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  4215. // `Array.prototype.includes` method
  4216. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  4217. _export({ target: 'Array', proto: true, forced: !USES_TO_LENGTH$5 }, {
  4218. includes: function includes(el /* , fromIndex = 0 */) {
  4219. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  4220. }
  4221. });
  4222. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  4223. addToUnscopables('includes');
  4224. var $map = arrayIteration.map;
  4225. var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('map');
  4226. // FF49- issue
  4227. var USES_TO_LENGTH$6 = arrayMethodUsesToLength('map');
  4228. // `Array.prototype.map` method
  4229. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  4230. // with adding support of @@species
  4231. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 || !USES_TO_LENGTH$6 }, {
  4232. map: function map(callbackfn /* , thisArg */) {
  4233. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4234. }
  4235. });
  4236. // makes subclassing work correct for wrapped built-ins
  4237. var inheritIfRequired = function ($this, dummy, Wrapper) {
  4238. var NewTarget, NewTargetPrototype;
  4239. if (
  4240. // it can work only with native `setPrototypeOf`
  4241. objectSetPrototypeOf &&
  4242. // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
  4243. typeof (NewTarget = dummy.constructor) == 'function' &&
  4244. NewTarget !== Wrapper &&
  4245. isObject(NewTargetPrototype = NewTarget.prototype) &&
  4246. NewTargetPrototype !== Wrapper.prototype
  4247. ) objectSetPrototypeOf($this, NewTargetPrototype);
  4248. return $this;
  4249. };
  4250. // a string of all valid unicode whitespaces
  4251. // eslint-disable-next-line max-len
  4252. var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  4253. var whitespace = '[' + whitespaces + ']';
  4254. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  4255. var rtrim = RegExp(whitespace + whitespace + '*$');
  4256. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  4257. var createMethod$3 = function (TYPE) {
  4258. return function ($this) {
  4259. var string = String(requireObjectCoercible($this));
  4260. if (TYPE & 1) string = string.replace(ltrim, '');
  4261. if (TYPE & 2) string = string.replace(rtrim, '');
  4262. return string;
  4263. };
  4264. };
  4265. var stringTrim = {
  4266. // `String.prototype.{ trimLeft, trimStart }` methods
  4267. // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
  4268. start: createMethod$3(1),
  4269. // `String.prototype.{ trimRight, trimEnd }` methods
  4270. // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
  4271. end: createMethod$3(2),
  4272. // `String.prototype.trim` method
  4273. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  4274. trim: createMethod$3(3)
  4275. };
  4276. var getOwnPropertyNames = objectGetOwnPropertyNames.f;
  4277. var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
  4278. var defineProperty$5 = objectDefineProperty.f;
  4279. var trim = stringTrim.trim;
  4280. var NUMBER = 'Number';
  4281. var NativeNumber = global_1[NUMBER];
  4282. var NumberPrototype = NativeNumber.prototype;
  4283. // Opera ~12 has broken Object#toString
  4284. var BROKEN_CLASSOF = classofRaw(objectCreate(NumberPrototype)) == NUMBER;
  4285. // `ToNumber` abstract operation
  4286. // https://tc39.github.io/ecma262/#sec-tonumber
  4287. var toNumber = function (argument) {
  4288. var it = toPrimitive(argument, false);
  4289. var first, third, radix, maxCode, digits, length, index, code;
  4290. if (typeof it == 'string' && it.length > 2) {
  4291. it = trim(it);
  4292. first = it.charCodeAt(0);
  4293. if (first === 43 || first === 45) {
  4294. third = it.charCodeAt(2);
  4295. if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
  4296. } else if (first === 48) {
  4297. switch (it.charCodeAt(1)) {
  4298. case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
  4299. case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
  4300. default: return +it;
  4301. }
  4302. digits = it.slice(2);
  4303. length = digits.length;
  4304. for (index = 0; index < length; index++) {
  4305. code = digits.charCodeAt(index);
  4306. // parseInt parses a string to a first unavailable symbol
  4307. // but ToNumber should return NaN if a string contains unavailable symbols
  4308. if (code < 48 || code > maxCode) return NaN;
  4309. } return parseInt(digits, radix);
  4310. }
  4311. } return +it;
  4312. };
  4313. // `Number` constructor
  4314. // https://tc39.github.io/ecma262/#sec-number-constructor
  4315. if (isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
  4316. var NumberWrapper = function Number(value) {
  4317. var it = arguments.length < 1 ? 0 : value;
  4318. var dummy = this;
  4319. return dummy instanceof NumberWrapper
  4320. // check on 1..constructor(foo) case
  4321. && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classofRaw(dummy) != NUMBER)
  4322. ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);
  4323. };
  4324. for (var keys$1 = descriptors ? getOwnPropertyNames(NativeNumber) : (
  4325. // ES3:
  4326. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  4327. // ES2015 (in case, if modules with ES2015 Number statics required before):
  4328. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  4329. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  4330. ).split(','), j = 0, key; keys$1.length > j; j++) {
  4331. if (has(NativeNumber, key = keys$1[j]) && !has(NumberWrapper, key)) {
  4332. defineProperty$5(NumberWrapper, key, getOwnPropertyDescriptor$2(NativeNumber, key));
  4333. }
  4334. }
  4335. NumberWrapper.prototype = NumberPrototype;
  4336. NumberPrototype.constructor = NumberWrapper;
  4337. redefine(global_1, NUMBER, NumberWrapper);
  4338. }
  4339. var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
  4340. // `Object.keys` method
  4341. // https://tc39.github.io/ecma262/#sec-object.keys
  4342. _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  4343. keys: function keys(it) {
  4344. return objectKeys(toObject(it));
  4345. }
  4346. });
  4347. var notARegexp = function (it) {
  4348. if (isRegexp(it)) {
  4349. throw TypeError("The method doesn't accept regular expressions");
  4350. } return it;
  4351. };
  4352. var MATCH$1 = wellKnownSymbol('match');
  4353. var correctIsRegexpLogic = function (METHOD_NAME) {
  4354. var regexp = /./;
  4355. try {
  4356. '/./'[METHOD_NAME](regexp);
  4357. } catch (e) {
  4358. try {
  4359. regexp[MATCH$1] = false;
  4360. return '/./'[METHOD_NAME](regexp);
  4361. } catch (f) { /* empty */ }
  4362. } return false;
  4363. };
  4364. // `String.prototype.includes` method
  4365. // https://tc39.github.io/ecma262/#sec-string.prototype.includes
  4366. _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes') }, {
  4367. includes: function includes(searchString /* , position = 0 */) {
  4368. return !!~String(requireObjectCoercible(this))
  4369. .indexOf(notARegexp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  4370. }
  4371. });
  4372. var freezing = !fails(function () {
  4373. return Object.isExtensible(Object.preventExtensions({}));
  4374. });
  4375. var internalMetadata = createCommonjsModule(function (module) {
  4376. var defineProperty = objectDefineProperty.f;
  4377. var METADATA = uid('meta');
  4378. var id = 0;
  4379. var isExtensible = Object.isExtensible || function () {
  4380. return true;
  4381. };
  4382. var setMetadata = function (it) {
  4383. defineProperty(it, METADATA, { value: {
  4384. objectID: 'O' + ++id, // object ID
  4385. weakData: {} // weak collections IDs
  4386. } });
  4387. };
  4388. var fastKey = function (it, create) {
  4389. // return a primitive with prefix
  4390. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  4391. if (!has(it, METADATA)) {
  4392. // can't set metadata to uncaught frozen object
  4393. if (!isExtensible(it)) return 'F';
  4394. // not necessary to add metadata
  4395. if (!create) return 'E';
  4396. // add missing metadata
  4397. setMetadata(it);
  4398. // return object ID
  4399. } return it[METADATA].objectID;
  4400. };
  4401. var getWeakData = function (it, create) {
  4402. if (!has(it, METADATA)) {
  4403. // can't set metadata to uncaught frozen object
  4404. if (!isExtensible(it)) return true;
  4405. // not necessary to add metadata
  4406. if (!create) return false;
  4407. // add missing metadata
  4408. setMetadata(it);
  4409. // return the store of weak collections IDs
  4410. } return it[METADATA].weakData;
  4411. };
  4412. // add metadata on freeze-family methods calling
  4413. var onFreeze = function (it) {
  4414. if (freezing && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);
  4415. return it;
  4416. };
  4417. var meta = module.exports = {
  4418. REQUIRED: false,
  4419. fastKey: fastKey,
  4420. getWeakData: getWeakData,
  4421. onFreeze: onFreeze
  4422. };
  4423. hiddenKeys[METADATA] = true;
  4424. });
  4425. var internalMetadata_1 = internalMetadata.REQUIRED;
  4426. var internalMetadata_2 = internalMetadata.fastKey;
  4427. var internalMetadata_3 = internalMetadata.getWeakData;
  4428. var internalMetadata_4 = internalMetadata.onFreeze;
  4429. var iterate_1 = createCommonjsModule(function (module) {
  4430. var Result = function (stopped, result) {
  4431. this.stopped = stopped;
  4432. this.result = result;
  4433. };
  4434. var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
  4435. var boundFunction = functionBindContext(fn, that, AS_ENTRIES ? 2 : 1);
  4436. var iterator, iterFn, index, length, result, next, step;
  4437. if (IS_ITERATOR) {
  4438. iterator = iterable;
  4439. } else {
  4440. iterFn = getIteratorMethod(iterable);
  4441. if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
  4442. // optimisation for array iterators
  4443. if (isArrayIteratorMethod(iterFn)) {
  4444. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  4445. result = AS_ENTRIES
  4446. ? boundFunction(anObject(step = iterable[index])[0], step[1])
  4447. : boundFunction(iterable[index]);
  4448. if (result && result instanceof Result) return result;
  4449. } return new Result(false);
  4450. }
  4451. iterator = iterFn.call(iterable);
  4452. }
  4453. next = iterator.next;
  4454. while (!(step = next.call(iterator)).done) {
  4455. result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
  4456. if (typeof result == 'object' && result && result instanceof Result) return result;
  4457. } return new Result(false);
  4458. };
  4459. iterate.stop = function (result) {
  4460. return new Result(true, result);
  4461. };
  4462. });
  4463. var collection = function (CONSTRUCTOR_NAME, wrapper, common) {
  4464. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  4465. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  4466. var ADDER = IS_MAP ? 'set' : 'add';
  4467. var NativeConstructor = global_1[CONSTRUCTOR_NAME];
  4468. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  4469. var Constructor = NativeConstructor;
  4470. var exported = {};
  4471. var fixMethod = function (KEY) {
  4472. var nativeMethod = NativePrototype[KEY];
  4473. redefine(NativePrototype, KEY,
  4474. KEY == 'add' ? function add(value) {
  4475. nativeMethod.call(this, value === 0 ? 0 : value);
  4476. return this;
  4477. } : KEY == 'delete' ? function (key) {
  4478. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  4479. } : KEY == 'get' ? function get(key) {
  4480. return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);
  4481. } : KEY == 'has' ? function has(key) {
  4482. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  4483. } : function set(key, value) {
  4484. nativeMethod.call(this, key === 0 ? 0 : key, value);
  4485. return this;
  4486. }
  4487. );
  4488. };
  4489. // eslint-disable-next-line max-len
  4490. if (isForced_1(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
  4491. new NativeConstructor().entries().next();
  4492. })))) {
  4493. // create collection constructor
  4494. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  4495. internalMetadata.REQUIRED = true;
  4496. } else if (isForced_1(CONSTRUCTOR_NAME, true)) {
  4497. var instance = new Constructor();
  4498. // early implementations not supports chaining
  4499. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  4500. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  4501. var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
  4502. // most early implementations doesn't supports iterables, most modern - not close it correctly
  4503. // eslint-disable-next-line no-new
  4504. var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); });
  4505. // for early implementations -0 and +0 not the same
  4506. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  4507. // V8 ~ Chromium 42- fails only with 5+ elements
  4508. var $instance = new NativeConstructor();
  4509. var index = 5;
  4510. while (index--) $instance[ADDER](index, index);
  4511. return !$instance.has(-0);
  4512. });
  4513. if (!ACCEPT_ITERABLES) {
  4514. Constructor = wrapper(function (dummy, iterable) {
  4515. anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
  4516. var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
  4517. if (iterable != undefined) iterate_1(iterable, that[ADDER], that, IS_MAP);
  4518. return that;
  4519. });
  4520. Constructor.prototype = NativePrototype;
  4521. NativePrototype.constructor = Constructor;
  4522. }
  4523. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  4524. fixMethod('delete');
  4525. fixMethod('has');
  4526. IS_MAP && fixMethod('get');
  4527. }
  4528. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  4529. // weak collections should not contains .clear method
  4530. if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;
  4531. }
  4532. exported[CONSTRUCTOR_NAME] = Constructor;
  4533. _export({ global: true, forced: Constructor != NativeConstructor }, exported);
  4534. setToStringTag(Constructor, CONSTRUCTOR_NAME);
  4535. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  4536. return Constructor;
  4537. };
  4538. var getWeakData = internalMetadata.getWeakData;
  4539. var setInternalState$5 = internalState.set;
  4540. var internalStateGetterFor = internalState.getterFor;
  4541. var find$1 = arrayIteration.find;
  4542. var findIndex = arrayIteration.findIndex;
  4543. var id$1 = 0;
  4544. // fallback for uncaught frozen keys
  4545. var uncaughtFrozenStore = function (store) {
  4546. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  4547. };
  4548. var UncaughtFrozenStore = function () {
  4549. this.entries = [];
  4550. };
  4551. var findUncaughtFrozen = function (store, key) {
  4552. return find$1(store.entries, function (it) {
  4553. return it[0] === key;
  4554. });
  4555. };
  4556. UncaughtFrozenStore.prototype = {
  4557. get: function (key) {
  4558. var entry = findUncaughtFrozen(this, key);
  4559. if (entry) return entry[1];
  4560. },
  4561. has: function (key) {
  4562. return !!findUncaughtFrozen(this, key);
  4563. },
  4564. set: function (key, value) {
  4565. var entry = findUncaughtFrozen(this, key);
  4566. if (entry) entry[1] = value;
  4567. else this.entries.push([key, value]);
  4568. },
  4569. 'delete': function (key) {
  4570. var index = findIndex(this.entries, function (it) {
  4571. return it[0] === key;
  4572. });
  4573. if (~index) this.entries.splice(index, 1);
  4574. return !!~index;
  4575. }
  4576. };
  4577. var collectionWeak = {
  4578. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  4579. var C = wrapper(function (that, iterable) {
  4580. anInstance(that, C, CONSTRUCTOR_NAME);
  4581. setInternalState$5(that, {
  4582. type: CONSTRUCTOR_NAME,
  4583. id: id$1++,
  4584. frozen: undefined
  4585. });
  4586. if (iterable != undefined) iterate_1(iterable, that[ADDER], that, IS_MAP);
  4587. });
  4588. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  4589. var define = function (that, key, value) {
  4590. var state = getInternalState(that);
  4591. var data = getWeakData(anObject(key), true);
  4592. if (data === true) uncaughtFrozenStore(state).set(key, value);
  4593. else data[state.id] = value;
  4594. return that;
  4595. };
  4596. redefineAll(C.prototype, {
  4597. // 23.3.3.2 WeakMap.prototype.delete(key)
  4598. // 23.4.3.3 WeakSet.prototype.delete(value)
  4599. 'delete': function (key) {
  4600. var state = getInternalState(this);
  4601. if (!isObject(key)) return false;
  4602. var data = getWeakData(key);
  4603. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  4604. return data && has(data, state.id) && delete data[state.id];
  4605. },
  4606. // 23.3.3.4 WeakMap.prototype.has(key)
  4607. // 23.4.3.4 WeakSet.prototype.has(value)
  4608. has: function has$1(key) {
  4609. var state = getInternalState(this);
  4610. if (!isObject(key)) return false;
  4611. var data = getWeakData(key);
  4612. if (data === true) return uncaughtFrozenStore(state).has(key);
  4613. return data && has(data, state.id);
  4614. }
  4615. });
  4616. redefineAll(C.prototype, IS_MAP ? {
  4617. // 23.3.3.3 WeakMap.prototype.get(key)
  4618. get: function get(key) {
  4619. var state = getInternalState(this);
  4620. if (isObject(key)) {
  4621. var data = getWeakData(key);
  4622. if (data === true) return uncaughtFrozenStore(state).get(key);
  4623. return data ? data[state.id] : undefined;
  4624. }
  4625. },
  4626. // 23.3.3.5 WeakMap.prototype.set(key, value)
  4627. set: function set(key, value) {
  4628. return define(this, key, value);
  4629. }
  4630. } : {
  4631. // 23.4.3.1 WeakSet.prototype.add(value)
  4632. add: function add(value) {
  4633. return define(this, value, true);
  4634. }
  4635. });
  4636. return C;
  4637. }
  4638. };
  4639. var es_weakMap = createCommonjsModule(function (module) {
  4640. var enforceIternalState = internalState.enforce;
  4641. var IS_IE11 = !global_1.ActiveXObject && 'ActiveXObject' in global_1;
  4642. var isExtensible = Object.isExtensible;
  4643. var InternalWeakMap;
  4644. var wrapper = function (init) {
  4645. return function WeakMap() {
  4646. return init(this, arguments.length ? arguments[0] : undefined);
  4647. };
  4648. };
  4649. // `WeakMap` constructor
  4650. // https://tc39.github.io/ecma262/#sec-weakmap-constructor
  4651. var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);
  4652. // IE11 WeakMap frozen keys fix
  4653. // We can't use feature detection because it crash some old IE builds
  4654. // https://github.com/zloirock/core-js/issues/485
  4655. if (nativeWeakMap && IS_IE11) {
  4656. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  4657. internalMetadata.REQUIRED = true;
  4658. var WeakMapPrototype = $WeakMap.prototype;
  4659. var nativeDelete = WeakMapPrototype['delete'];
  4660. var nativeHas = WeakMapPrototype.has;
  4661. var nativeGet = WeakMapPrototype.get;
  4662. var nativeSet = WeakMapPrototype.set;
  4663. redefineAll(WeakMapPrototype, {
  4664. 'delete': function (key) {
  4665. if (isObject(key) && !isExtensible(key)) {
  4666. var state = enforceIternalState(this);
  4667. if (!state.frozen) state.frozen = new InternalWeakMap();
  4668. return nativeDelete.call(this, key) || state.frozen['delete'](key);
  4669. } return nativeDelete.call(this, key);
  4670. },
  4671. has: function has(key) {
  4672. if (isObject(key) && !isExtensible(key)) {
  4673. var state = enforceIternalState(this);
  4674. if (!state.frozen) state.frozen = new InternalWeakMap();
  4675. return nativeHas.call(this, key) || state.frozen.has(key);
  4676. } return nativeHas.call(this, key);
  4677. },
  4678. get: function get(key) {
  4679. if (isObject(key) && !isExtensible(key)) {
  4680. var state = enforceIternalState(this);
  4681. if (!state.frozen) state.frozen = new InternalWeakMap();
  4682. return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
  4683. } return nativeGet.call(this, key);
  4684. },
  4685. set: function set(key, value) {
  4686. if (isObject(key) && !isExtensible(key)) {
  4687. var state = enforceIternalState(this);
  4688. if (!state.frozen) state.frozen = new InternalWeakMap();
  4689. nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
  4690. } else nativeSet.call(this, key, value);
  4691. return this;
  4692. }
  4693. });
  4694. }
  4695. });
  4696. var $every = arrayIteration.every;
  4697. var STRICT_METHOD$3 = arrayMethodIsStrict('every');
  4698. var USES_TO_LENGTH$7 = arrayMethodUsesToLength('every');
  4699. // `Array.prototype.every` method
  4700. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  4701. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$3 || !USES_TO_LENGTH$7 }, {
  4702. every: function every(callbackfn /* , thisArg */) {
  4703. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4704. }
  4705. });
  4706. // `Object.assign` method
  4707. // https://tc39.github.io/ecma262/#sec-object.assign
  4708. _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, {
  4709. assign: objectAssign
  4710. });
  4711. var non = '\u200B\u0085\u180E';
  4712. // check that a method works with the correct list
  4713. // of whitespaces and has a correct name
  4714. var stringTrimForced = function (METHOD_NAME) {
  4715. return fails(function () {
  4716. return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
  4717. });
  4718. };
  4719. var $trim = stringTrim.trim;
  4720. // `String.prototype.trim` method
  4721. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  4722. _export({ target: 'String', proto: true, forced: stringTrimForced('trim') }, {
  4723. trim: function trim() {
  4724. return $trim(this);
  4725. }
  4726. });
  4727. var $some = arrayIteration.some;
  4728. var STRICT_METHOD$4 = arrayMethodIsStrict('some');
  4729. var USES_TO_LENGTH$8 = arrayMethodUsesToLength('some');
  4730. // `Array.prototype.some` method
  4731. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  4732. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$4 || !USES_TO_LENGTH$8 }, {
  4733. some: function some(callbackfn /* , thisArg */) {
  4734. return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4735. }
  4736. });
  4737. // `thisNumberValue` abstract operation
  4738. // https://tc39.github.io/ecma262/#sec-thisnumbervalue
  4739. var thisNumberValue = function (value) {
  4740. if (typeof value != 'number' && classofRaw(value) != 'Number') {
  4741. throw TypeError('Incorrect invocation');
  4742. }
  4743. return +value;
  4744. };
  4745. // `String.prototype.repeat` method implementation
  4746. // https://tc39.github.io/ecma262/#sec-string.prototype.repeat
  4747. var stringRepeat = ''.repeat || function repeat(count) {
  4748. var str = String(requireObjectCoercible(this));
  4749. var result = '';
  4750. var n = toInteger(count);
  4751. if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
  4752. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
  4753. return result;
  4754. };
  4755. var nativeToFixed = 1.0.toFixed;
  4756. var floor$4 = Math.floor;
  4757. var pow$1 = function (x, n, acc) {
  4758. return n === 0 ? acc : n % 2 === 1 ? pow$1(x, n - 1, acc * x) : pow$1(x * x, n / 2, acc);
  4759. };
  4760. var log = function (x) {
  4761. var n = 0;
  4762. var x2 = x;
  4763. while (x2 >= 4096) {
  4764. n += 12;
  4765. x2 /= 4096;
  4766. }
  4767. while (x2 >= 2) {
  4768. n += 1;
  4769. x2 /= 2;
  4770. } return n;
  4771. };
  4772. var FORCED$1 = nativeToFixed && (
  4773. 0.00008.toFixed(3) !== '0.000' ||
  4774. 0.9.toFixed(0) !== '1' ||
  4775. 1.255.toFixed(2) !== '1.25' ||
  4776. 1000000000000000128.0.toFixed(0) !== '1000000000000000128'
  4777. ) || !fails(function () {
  4778. // V8 ~ Android 4.3-
  4779. nativeToFixed.call({});
  4780. });
  4781. // `Number.prototype.toFixed` method
  4782. // https://tc39.github.io/ecma262/#sec-number.prototype.tofixed
  4783. _export({ target: 'Number', proto: true, forced: FORCED$1 }, {
  4784. // eslint-disable-next-line max-statements
  4785. toFixed: function toFixed(fractionDigits) {
  4786. var number = thisNumberValue(this);
  4787. var fractDigits = toInteger(fractionDigits);
  4788. var data = [0, 0, 0, 0, 0, 0];
  4789. var sign = '';
  4790. var result = '0';
  4791. var e, z, j, k;
  4792. var multiply = function (n, c) {
  4793. var index = -1;
  4794. var c2 = c;
  4795. while (++index < 6) {
  4796. c2 += n * data[index];
  4797. data[index] = c2 % 1e7;
  4798. c2 = floor$4(c2 / 1e7);
  4799. }
  4800. };
  4801. var divide = function (n) {
  4802. var index = 6;
  4803. var c = 0;
  4804. while (--index >= 0) {
  4805. c += data[index];
  4806. data[index] = floor$4(c / n);
  4807. c = (c % n) * 1e7;
  4808. }
  4809. };
  4810. var dataToString = function () {
  4811. var index = 6;
  4812. var s = '';
  4813. while (--index >= 0) {
  4814. if (s !== '' || index === 0 || data[index] !== 0) {
  4815. var t = String(data[index]);
  4816. s = s === '' ? t : s + stringRepeat.call('0', 7 - t.length) + t;
  4817. }
  4818. } return s;
  4819. };
  4820. if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits');
  4821. // eslint-disable-next-line no-self-compare
  4822. if (number != number) return 'NaN';
  4823. if (number <= -1e21 || number >= 1e21) return String(number);
  4824. if (number < 0) {
  4825. sign = '-';
  4826. number = -number;
  4827. }
  4828. if (number > 1e-21) {
  4829. e = log(number * pow$1(2, 69, 1)) - 69;
  4830. z = e < 0 ? number * pow$1(2, -e, 1) : number / pow$1(2, e, 1);
  4831. z *= 0x10000000000000;
  4832. e = 52 - e;
  4833. if (e > 0) {
  4834. multiply(0, z);
  4835. j = fractDigits;
  4836. while (j >= 7) {
  4837. multiply(1e7, 0);
  4838. j -= 7;
  4839. }
  4840. multiply(pow$1(10, j, 1), 0);
  4841. j = e - 1;
  4842. while (j >= 23) {
  4843. divide(1 << 23);
  4844. j -= 23;
  4845. }
  4846. divide(1 << j);
  4847. multiply(1, 1);
  4848. divide(2);
  4849. result = dataToString();
  4850. } else {
  4851. multiply(0, z);
  4852. multiply(1 << -e, 0);
  4853. result = dataToString() + stringRepeat.call('0', fractDigits);
  4854. }
  4855. }
  4856. if (fractDigits > 0) {
  4857. k = result.length;
  4858. result = sign + (k <= fractDigits
  4859. ? '0.' + stringRepeat.call('0', fractDigits - k) + result
  4860. : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits));
  4861. } else {
  4862. result = sign + result;
  4863. } return result;
  4864. }
  4865. });
  4866. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  4867. // `Object.{ entries, values }` methods implementation
  4868. var createMethod$4 = function (TO_ENTRIES) {
  4869. return function (it) {
  4870. var O = toIndexedObject(it);
  4871. var keys = objectKeys(O);
  4872. var length = keys.length;
  4873. var i = 0;
  4874. var result = [];
  4875. var key;
  4876. while (length > i) {
  4877. key = keys[i++];
  4878. if (!descriptors || propertyIsEnumerable.call(O, key)) {
  4879. result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
  4880. }
  4881. }
  4882. return result;
  4883. };
  4884. };
  4885. var objectToArray = {
  4886. // `Object.entries` method
  4887. // https://tc39.github.io/ecma262/#sec-object.entries
  4888. entries: createMethod$4(true),
  4889. // `Object.values` method
  4890. // https://tc39.github.io/ecma262/#sec-object.values
  4891. values: createMethod$4(false)
  4892. };
  4893. var $entries = objectToArray.entries;
  4894. // `Object.entries` method
  4895. // https://tc39.github.io/ecma262/#sec-object.entries
  4896. _export({ target: 'Object', stat: true }, {
  4897. entries: function entries(O) {
  4898. return $entries(O);
  4899. }
  4900. });
  4901. var $values = objectToArray.values;
  4902. // `Object.values` method
  4903. // https://tc39.github.io/ecma262/#sec-object.values
  4904. _export({ target: 'Object', stat: true }, {
  4905. values: function values(O) {
  4906. return $values(O);
  4907. }
  4908. });
  4909. // `Number.isNaN` method
  4910. // https://tc39.github.io/ecma262/#sec-number.isnan
  4911. _export({ target: 'Number', stat: true }, {
  4912. isNaN: function isNaN(number) {
  4913. // eslint-disable-next-line no-self-compare
  4914. return number != number;
  4915. }
  4916. });
  4917. var nativeGetOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
  4918. var FAILS_ON_PRIMITIVES$1 = fails(function () { nativeGetOwnPropertyDescriptor$2(1); });
  4919. var FORCED$2 = !descriptors || FAILS_ON_PRIMITIVES$1;
  4920. // `Object.getOwnPropertyDescriptor` method
  4921. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  4922. _export({ target: 'Object', stat: true, forced: FORCED$2, sham: !descriptors }, {
  4923. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  4924. return nativeGetOwnPropertyDescriptor$2(toIndexedObject(it), key);
  4925. }
  4926. });
  4927. // `Object.getOwnPropertyDescriptors` method
  4928. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  4929. _export({ target: 'Object', stat: true, sham: !descriptors }, {
  4930. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  4931. var O = toIndexedObject(object);
  4932. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  4933. var keys = ownKeys(O);
  4934. var result = {};
  4935. var index = 0;
  4936. var key, descriptor;
  4937. while (keys.length > index) {
  4938. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  4939. if (descriptor !== undefined) createProperty(result, key, descriptor);
  4940. }
  4941. return result;
  4942. }
  4943. });
  4944. // @@match logic
  4945. fixRegexpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
  4946. return [
  4947. // `String.prototype.match` method
  4948. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  4949. function match(regexp) {
  4950. var O = requireObjectCoercible(this);
  4951. var matcher = regexp == undefined ? undefined : regexp[MATCH];
  4952. return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  4953. },
  4954. // `RegExp.prototype[@@match]` method
  4955. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  4956. function (regexp) {
  4957. var res = maybeCallNative(nativeMatch, regexp, this);
  4958. if (res.done) return res.value;
  4959. var rx = anObject(regexp);
  4960. var S = String(this);
  4961. if (!rx.global) return regexpExecAbstract(rx, S);
  4962. var fullUnicode = rx.unicode;
  4963. rx.lastIndex = 0;
  4964. var A = [];
  4965. var n = 0;
  4966. var result;
  4967. while ((result = regexpExecAbstract(rx, S)) !== null) {
  4968. var matchStr = String(result[0]);
  4969. A[n] = matchStr;
  4970. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  4971. n++;
  4972. }
  4973. return n === 0 ? null : A;
  4974. }
  4975. ];
  4976. });
  4977. function _classCallCheck$1(e, t) {
  4978. if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
  4979. }
  4980. function _defineProperties$1(e, t) {
  4981. for (var n = 0; n < t.length; n++) {
  4982. var r = t[n];
  4983. r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
  4984. }
  4985. }
  4986. function _createClass$1(e, t, n) {
  4987. return t && _defineProperties$1(e.prototype, t), n && _defineProperties$1(e, n), e;
  4988. }
  4989. function _defineProperty$1(e, t, n) {
  4990. return t in e ? Object.defineProperty(e, t, {
  4991. value: n,
  4992. enumerable: !0,
  4993. configurable: !0,
  4994. writable: !0
  4995. }) : e[t] = n, e;
  4996. }
  4997. function ownKeys$2(e, t) {
  4998. var n = Object.keys(e);
  4999. if (Object.getOwnPropertySymbols) {
  5000. var r = Object.getOwnPropertySymbols(e);
  5001. t && (r = r.filter(function (t) {
  5002. return Object.getOwnPropertyDescriptor(e, t).enumerable;
  5003. })), n.push.apply(n, r);
  5004. }
  5005. return n;
  5006. }
  5007. function _objectSpread2$1(e) {
  5008. for (var t = 1; t < arguments.length; t++) {
  5009. var n = null != arguments[t] ? arguments[t] : {};
  5010. t % 2 ? ownKeys$2(Object(n), !0).forEach(function (t) {
  5011. _defineProperty$1(e, t, n[t]);
  5012. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : ownKeys$2(Object(n)).forEach(function (t) {
  5013. Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
  5014. });
  5015. }
  5016. return e;
  5017. }
  5018. var defaults = {
  5019. addCSS: !0,
  5020. thumbWidth: 15,
  5021. watch: !0
  5022. };
  5023. function matches(e, t) {
  5024. return function () {
  5025. return Array.from(document.querySelectorAll(t)).includes(this);
  5026. }.call(e, t);
  5027. }
  5028. function trigger(e, t) {
  5029. if (e && t) {
  5030. var n = new Event(t, {
  5031. bubbles: !0
  5032. });
  5033. e.dispatchEvent(n);
  5034. }
  5035. }
  5036. var getConstructor = function getConstructor(e) {
  5037. return null != e ? e.constructor : null;
  5038. },
  5039. instanceOf = function instanceOf(e, t) {
  5040. return !!(e && t && e instanceof t);
  5041. },
  5042. isNullOrUndefined = function isNullOrUndefined(e) {
  5043. return null == e;
  5044. },
  5045. isObject$1 = function isObject(e) {
  5046. return getConstructor(e) === Object;
  5047. },
  5048. isNumber = function isNumber(e) {
  5049. return getConstructor(e) === Number && !Number.isNaN(e);
  5050. },
  5051. isString = function isString(e) {
  5052. return getConstructor(e) === String;
  5053. },
  5054. isBoolean = function isBoolean(e) {
  5055. return getConstructor(e) === Boolean;
  5056. },
  5057. isFunction = function isFunction(e) {
  5058. return getConstructor(e) === Function;
  5059. },
  5060. isArray$1 = function isArray(e) {
  5061. return Array.isArray(e);
  5062. },
  5063. isNodeList = function isNodeList(e) {
  5064. return instanceOf(e, NodeList);
  5065. },
  5066. isElement = function isElement(e) {
  5067. return instanceOf(e, Element);
  5068. },
  5069. isEvent = function isEvent(e) {
  5070. return instanceOf(e, Event);
  5071. },
  5072. isEmpty = function isEmpty(e) {
  5073. return isNullOrUndefined(e) || (isString(e) || isArray$1(e) || isNodeList(e)) && !e.length || isObject$1(e) && !Object.keys(e).length;
  5074. },
  5075. is = {
  5076. nullOrUndefined: isNullOrUndefined,
  5077. object: isObject$1,
  5078. number: isNumber,
  5079. string: isString,
  5080. boolean: isBoolean,
  5081. function: isFunction,
  5082. array: isArray$1,
  5083. nodeList: isNodeList,
  5084. element: isElement,
  5085. event: isEvent,
  5086. empty: isEmpty
  5087. };
  5088. function getDecimalPlaces(e) {
  5089. var t = "".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  5090. return t ? Math.max(0, (t[1] ? t[1].length : 0) - (t[2] ? +t[2] : 0)) : 0;
  5091. }
  5092. function round(e, t) {
  5093. if (1 > t) {
  5094. var n = getDecimalPlaces(t);
  5095. return parseFloat(e.toFixed(n));
  5096. }
  5097. return Math.round(e / t) * t;
  5098. }
  5099. var RangeTouch = function () {
  5100. function e(t, n) {
  5101. _classCallCheck$1(this, e), is.element(t) ? this.element = t : is.string(t) && (this.element = document.querySelector(t)), is.element(this.element) && is.empty(this.element.rangeTouch) && (this.config = _objectSpread2$1({}, defaults, {}, n), this.init());
  5102. }
  5103. return _createClass$1(e, [{
  5104. key: "init",
  5105. value: function value() {
  5106. e.enabled && (this.config.addCSS && (this.element.style.userSelect = "none", this.element.style.webKitUserSelect = "none", this.element.style.touchAction = "manipulation"), this.listeners(!0), this.element.rangeTouch = this);
  5107. }
  5108. }, {
  5109. key: "destroy",
  5110. value: function value() {
  5111. e.enabled && (this.config.addCSS && (this.element.style.userSelect = "", this.element.style.webKitUserSelect = "", this.element.style.touchAction = ""), this.listeners(!1), this.element.rangeTouch = null);
  5112. }
  5113. }, {
  5114. key: "listeners",
  5115. value: function value(e) {
  5116. var t = this,
  5117. n = e ? "addEventListener" : "removeEventListener";
  5118. ["touchstart", "touchmove", "touchend"].forEach(function (e) {
  5119. t.element[n](e, function (e) {
  5120. return t.set(e);
  5121. }, !1);
  5122. });
  5123. }
  5124. }, {
  5125. key: "get",
  5126. value: function value(t) {
  5127. if (!e.enabled || !is.event(t)) return null;
  5128. var n,
  5129. r = t.target,
  5130. i = t.changedTouches[0],
  5131. o = parseFloat(r.getAttribute("min")) || 0,
  5132. s = parseFloat(r.getAttribute("max")) || 100,
  5133. u = parseFloat(r.getAttribute("step")) || 1,
  5134. c = r.getBoundingClientRect(),
  5135. a = 100 / c.width * (this.config.thumbWidth / 2) / 100;
  5136. return 0 > (n = 100 / c.width * (i.clientX - c.left)) ? n = 0 : 100 < n && (n = 100), 50 > n ? n -= (100 - 2 * n) * a : 50 < n && (n += 2 * (n - 50) * a), o + round(n / 100 * (s - o), u);
  5137. }
  5138. }, {
  5139. key: "set",
  5140. value: function value(t) {
  5141. e.enabled && is.event(t) && !t.target.disabled && (t.preventDefault(), t.target.value = this.get(t), trigger(t.target, "touchend" === t.type ? "change" : "input"));
  5142. }
  5143. }], [{
  5144. key: "setup",
  5145. value: function value(t) {
  5146. var n = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {},
  5147. r = null;
  5148. if (is.empty(t) || is.string(t) ? r = Array.from(document.querySelectorAll(is.string(t) ? t : 'input[type="range"]')) : is.element(t) ? r = [t] : is.nodeList(t) ? r = Array.from(t) : is.array(t) && (r = t.filter(is.element)), is.empty(r)) return null;
  5149. var i = _objectSpread2$1({}, defaults, {}, n);
  5150. if (is.string(t) && i.watch) {
  5151. var o = new MutationObserver(function (n) {
  5152. Array.from(n).forEach(function (n) {
  5153. Array.from(n.addedNodes).forEach(function (n) {
  5154. is.element(n) && matches(n, t) && new e(n, i);
  5155. });
  5156. });
  5157. });
  5158. o.observe(document.body, {
  5159. childList: !0,
  5160. subtree: !0
  5161. });
  5162. }
  5163. return r.map(function (t) {
  5164. return new e(t, n);
  5165. });
  5166. }
  5167. }, {
  5168. key: "enabled",
  5169. get: function get() {
  5170. return "ontouchstart" in document.documentElement;
  5171. }
  5172. }]), e;
  5173. }();
  5174. var nativePromiseConstructor = global_1.Promise;
  5175. var SPECIES$5 = wellKnownSymbol('species');
  5176. var setSpecies = function (CONSTRUCTOR_NAME) {
  5177. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  5178. var defineProperty = objectDefineProperty.f;
  5179. if (descriptors && Constructor && !Constructor[SPECIES$5]) {
  5180. defineProperty(Constructor, SPECIES$5, {
  5181. configurable: true,
  5182. get: function () { return this; }
  5183. });
  5184. }
  5185. };
  5186. var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(engineUserAgent);
  5187. var location = global_1.location;
  5188. var set$1 = global_1.setImmediate;
  5189. var clear = global_1.clearImmediate;
  5190. var process$1 = global_1.process;
  5191. var MessageChannel = global_1.MessageChannel;
  5192. var Dispatch = global_1.Dispatch;
  5193. var counter = 0;
  5194. var queue = {};
  5195. var ONREADYSTATECHANGE = 'onreadystatechange';
  5196. var defer, channel, port;
  5197. var run = function (id) {
  5198. // eslint-disable-next-line no-prototype-builtins
  5199. if (queue.hasOwnProperty(id)) {
  5200. var fn = queue[id];
  5201. delete queue[id];
  5202. fn();
  5203. }
  5204. };
  5205. var runner = function (id) {
  5206. return function () {
  5207. run(id);
  5208. };
  5209. };
  5210. var listener = function (event) {
  5211. run(event.data);
  5212. };
  5213. var post = function (id) {
  5214. // old engines have not location.origin
  5215. global_1.postMessage(id + '', location.protocol + '//' + location.host);
  5216. };
  5217. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  5218. if (!set$1 || !clear) {
  5219. set$1 = function setImmediate(fn) {
  5220. var args = [];
  5221. var i = 1;
  5222. while (arguments.length > i) args.push(arguments[i++]);
  5223. queue[++counter] = function () {
  5224. // eslint-disable-next-line no-new-func
  5225. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  5226. };
  5227. defer(counter);
  5228. return counter;
  5229. };
  5230. clear = function clearImmediate(id) {
  5231. delete queue[id];
  5232. };
  5233. // Node.js 0.8-
  5234. if (classofRaw(process$1) == 'process') {
  5235. defer = function (id) {
  5236. process$1.nextTick(runner(id));
  5237. };
  5238. // Sphere (JS game engine) Dispatch API
  5239. } else if (Dispatch && Dispatch.now) {
  5240. defer = function (id) {
  5241. Dispatch.now(runner(id));
  5242. };
  5243. // Browsers with MessageChannel, includes WebWorkers
  5244. // except iOS - https://github.com/zloirock/core-js/issues/624
  5245. } else if (MessageChannel && !engineIsIos) {
  5246. channel = new MessageChannel();
  5247. port = channel.port2;
  5248. channel.port1.onmessage = listener;
  5249. defer = functionBindContext(port.postMessage, port, 1);
  5250. // Browsers with postMessage, skip WebWorkers
  5251. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  5252. } else if (
  5253. global_1.addEventListener &&
  5254. typeof postMessage == 'function' &&
  5255. !global_1.importScripts &&
  5256. !fails(post) &&
  5257. location.protocol !== 'file:'
  5258. ) {
  5259. defer = post;
  5260. global_1.addEventListener('message', listener, false);
  5261. // IE8-
  5262. } else if (ONREADYSTATECHANGE in documentCreateElement('script')) {
  5263. defer = function (id) {
  5264. html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () {
  5265. html.removeChild(this);
  5266. run(id);
  5267. };
  5268. };
  5269. // Rest old browsers
  5270. } else {
  5271. defer = function (id) {
  5272. setTimeout(runner(id), 0);
  5273. };
  5274. }
  5275. }
  5276. var task = {
  5277. set: set$1,
  5278. clear: clear
  5279. };
  5280. var getOwnPropertyDescriptor$3 = objectGetOwnPropertyDescriptor.f;
  5281. var macrotask = task.set;
  5282. var MutationObserver$1 = global_1.MutationObserver || global_1.WebKitMutationObserver;
  5283. var process$2 = global_1.process;
  5284. var Promise$1 = global_1.Promise;
  5285. var IS_NODE = classofRaw(process$2) == 'process';
  5286. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  5287. var queueMicrotaskDescriptor = getOwnPropertyDescriptor$3(global_1, 'queueMicrotask');
  5288. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  5289. var flush, head, last, notify, toggle, node, promise, then;
  5290. // modern engines have queueMicrotask method
  5291. if (!queueMicrotask) {
  5292. flush = function () {
  5293. var parent, fn;
  5294. if (IS_NODE && (parent = process$2.domain)) parent.exit();
  5295. while (head) {
  5296. fn = head.fn;
  5297. head = head.next;
  5298. try {
  5299. fn();
  5300. } catch (error) {
  5301. if (head) notify();
  5302. else last = undefined;
  5303. throw error;
  5304. }
  5305. } last = undefined;
  5306. if (parent) parent.enter();
  5307. };
  5308. // Node.js
  5309. if (IS_NODE) {
  5310. notify = function () {
  5311. process$2.nextTick(flush);
  5312. };
  5313. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  5314. } else if (MutationObserver$1 && !engineIsIos) {
  5315. toggle = true;
  5316. node = document.createTextNode('');
  5317. new MutationObserver$1(flush).observe(node, { characterData: true });
  5318. notify = function () {
  5319. node.data = toggle = !toggle;
  5320. };
  5321. // environments with maybe non-completely correct, but existent Promise
  5322. } else if (Promise$1 && Promise$1.resolve) {
  5323. // Promise.resolve without an argument throws an error in LG WebOS 2
  5324. promise = Promise$1.resolve(undefined);
  5325. then = promise.then;
  5326. notify = function () {
  5327. then.call(promise, flush);
  5328. };
  5329. // for other environments - macrotask based on:
  5330. // - setImmediate
  5331. // - MessageChannel
  5332. // - window.postMessag
  5333. // - onreadystatechange
  5334. // - setTimeout
  5335. } else {
  5336. notify = function () {
  5337. // strange IE + webpack dev server bug - use .call(global)
  5338. macrotask.call(global_1, flush);
  5339. };
  5340. }
  5341. }
  5342. var microtask = queueMicrotask || function (fn) {
  5343. var task = { fn: fn, next: undefined };
  5344. if (last) last.next = task;
  5345. if (!head) {
  5346. head = task;
  5347. notify();
  5348. } last = task;
  5349. };
  5350. var PromiseCapability = function (C) {
  5351. var resolve, reject;
  5352. this.promise = new C(function ($$resolve, $$reject) {
  5353. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  5354. resolve = $$resolve;
  5355. reject = $$reject;
  5356. });
  5357. this.resolve = aFunction$1(resolve);
  5358. this.reject = aFunction$1(reject);
  5359. };
  5360. // 25.4.1.5 NewPromiseCapability(C)
  5361. var f$7 = function (C) {
  5362. return new PromiseCapability(C);
  5363. };
  5364. var newPromiseCapability = {
  5365. f: f$7
  5366. };
  5367. var promiseResolve = function (C, x) {
  5368. anObject(C);
  5369. if (isObject(x) && x.constructor === C) return x;
  5370. var promiseCapability = newPromiseCapability.f(C);
  5371. var resolve = promiseCapability.resolve;
  5372. resolve(x);
  5373. return promiseCapability.promise;
  5374. };
  5375. var hostReportErrors = function (a, b) {
  5376. var console = global_1.console;
  5377. if (console && console.error) {
  5378. arguments.length === 1 ? console.error(a) : console.error(a, b);
  5379. }
  5380. };
  5381. var perform = function (exec) {
  5382. try {
  5383. return { error: false, value: exec() };
  5384. } catch (error) {
  5385. return { error: true, value: error };
  5386. }
  5387. };
  5388. var task$1 = task.set;
  5389. var SPECIES$6 = wellKnownSymbol('species');
  5390. var PROMISE = 'Promise';
  5391. var getInternalState$3 = internalState.get;
  5392. var setInternalState$6 = internalState.set;
  5393. var getInternalPromiseState = internalState.getterFor(PROMISE);
  5394. var PromiseConstructor = nativePromiseConstructor;
  5395. var TypeError$1 = global_1.TypeError;
  5396. var document$2 = global_1.document;
  5397. var process$3 = global_1.process;
  5398. var $fetch$1 = getBuiltIn('fetch');
  5399. var newPromiseCapability$1 = newPromiseCapability.f;
  5400. var newGenericPromiseCapability = newPromiseCapability$1;
  5401. var IS_NODE$1 = classofRaw(process$3) == 'process';
  5402. var DISPATCH_EVENT = !!(document$2 && document$2.createEvent && global_1.dispatchEvent);
  5403. var UNHANDLED_REJECTION = 'unhandledrejection';
  5404. var REJECTION_HANDLED = 'rejectionhandled';
  5405. var PENDING = 0;
  5406. var FULFILLED = 1;
  5407. var REJECTED = 2;
  5408. var HANDLED = 1;
  5409. var UNHANDLED = 2;
  5410. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  5411. var FORCED$3 = isForced_1(PROMISE, function () {
  5412. var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
  5413. if (!GLOBAL_CORE_JS_PROMISE) {
  5414. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  5415. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  5416. // We can't detect it synchronously, so just check versions
  5417. if (engineV8Version === 66) return true;
  5418. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  5419. if (!IS_NODE$1 && typeof PromiseRejectionEvent != 'function') return true;
  5420. }
  5421. // We can't use @@species feature detection in V8 since it causes
  5422. // deoptimization and performance degradation
  5423. // https://github.com/zloirock/core-js/issues/679
  5424. if (engineV8Version >= 51 && /native code/.test(PromiseConstructor)) return false;
  5425. // Detect correctness of subclassing with @@species support
  5426. var promise = PromiseConstructor.resolve(1);
  5427. var FakePromise = function (exec) {
  5428. exec(function () { /* empty */ }, function () { /* empty */ });
  5429. };
  5430. var constructor = promise.constructor = {};
  5431. constructor[SPECIES$6] = FakePromise;
  5432. return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
  5433. });
  5434. var INCORRECT_ITERATION$1 = FORCED$3 || !checkCorrectnessOfIteration(function (iterable) {
  5435. PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
  5436. });
  5437. // helpers
  5438. var isThenable = function (it) {
  5439. var then;
  5440. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  5441. };
  5442. var notify$1 = function (promise, state, isReject) {
  5443. if (state.notified) return;
  5444. state.notified = true;
  5445. var chain = state.reactions;
  5446. microtask(function () {
  5447. var value = state.value;
  5448. var ok = state.state == FULFILLED;
  5449. var index = 0;
  5450. // variable length - can't use forEach
  5451. while (chain.length > index) {
  5452. var reaction = chain[index++];
  5453. var handler = ok ? reaction.ok : reaction.fail;
  5454. var resolve = reaction.resolve;
  5455. var reject = reaction.reject;
  5456. var domain = reaction.domain;
  5457. var result, then, exited;
  5458. try {
  5459. if (handler) {
  5460. if (!ok) {
  5461. if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
  5462. state.rejection = HANDLED;
  5463. }
  5464. if (handler === true) result = value;
  5465. else {
  5466. if (domain) domain.enter();
  5467. result = handler(value); // can throw
  5468. if (domain) {
  5469. domain.exit();
  5470. exited = true;
  5471. }
  5472. }
  5473. if (result === reaction.promise) {
  5474. reject(TypeError$1('Promise-chain cycle'));
  5475. } else if (then = isThenable(result)) {
  5476. then.call(result, resolve, reject);
  5477. } else resolve(result);
  5478. } else reject(value);
  5479. } catch (error) {
  5480. if (domain && !exited) domain.exit();
  5481. reject(error);
  5482. }
  5483. }
  5484. state.reactions = [];
  5485. state.notified = false;
  5486. if (isReject && !state.rejection) onUnhandled(promise, state);
  5487. });
  5488. };
  5489. var dispatchEvent = function (name, promise, reason) {
  5490. var event, handler;
  5491. if (DISPATCH_EVENT) {
  5492. event = document$2.createEvent('Event');
  5493. event.promise = promise;
  5494. event.reason = reason;
  5495. event.initEvent(name, false, true);
  5496. global_1.dispatchEvent(event);
  5497. } else event = { promise: promise, reason: reason };
  5498. if (handler = global_1['on' + name]) handler(event);
  5499. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  5500. };
  5501. var onUnhandled = function (promise, state) {
  5502. task$1.call(global_1, function () {
  5503. var value = state.value;
  5504. var IS_UNHANDLED = isUnhandled(state);
  5505. var result;
  5506. if (IS_UNHANDLED) {
  5507. result = perform(function () {
  5508. if (IS_NODE$1) {
  5509. process$3.emit('unhandledRejection', value, promise);
  5510. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  5511. });
  5512. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  5513. state.rejection = IS_NODE$1 || isUnhandled(state) ? UNHANDLED : HANDLED;
  5514. if (result.error) throw result.value;
  5515. }
  5516. });
  5517. };
  5518. var isUnhandled = function (state) {
  5519. return state.rejection !== HANDLED && !state.parent;
  5520. };
  5521. var onHandleUnhandled = function (promise, state) {
  5522. task$1.call(global_1, function () {
  5523. if (IS_NODE$1) {
  5524. process$3.emit('rejectionHandled', promise);
  5525. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  5526. });
  5527. };
  5528. var bind = function (fn, promise, state, unwrap) {
  5529. return function (value) {
  5530. fn(promise, state, value, unwrap);
  5531. };
  5532. };
  5533. var internalReject = function (promise, state, value, unwrap) {
  5534. if (state.done) return;
  5535. state.done = true;
  5536. if (unwrap) state = unwrap;
  5537. state.value = value;
  5538. state.state = REJECTED;
  5539. notify$1(promise, state, true);
  5540. };
  5541. var internalResolve = function (promise, state, value, unwrap) {
  5542. if (state.done) return;
  5543. state.done = true;
  5544. if (unwrap) state = unwrap;
  5545. try {
  5546. if (promise === value) throw TypeError$1("Promise can't be resolved itself");
  5547. var then = isThenable(value);
  5548. if (then) {
  5549. microtask(function () {
  5550. var wrapper = { done: false };
  5551. try {
  5552. then.call(value,
  5553. bind(internalResolve, promise, wrapper, state),
  5554. bind(internalReject, promise, wrapper, state)
  5555. );
  5556. } catch (error) {
  5557. internalReject(promise, wrapper, error, state);
  5558. }
  5559. });
  5560. } else {
  5561. state.value = value;
  5562. state.state = FULFILLED;
  5563. notify$1(promise, state, false);
  5564. }
  5565. } catch (error) {
  5566. internalReject(promise, { done: false }, error, state);
  5567. }
  5568. };
  5569. // constructor polyfill
  5570. if (FORCED$3) {
  5571. // 25.4.3.1 Promise(executor)
  5572. PromiseConstructor = function Promise(executor) {
  5573. anInstance(this, PromiseConstructor, PROMISE);
  5574. aFunction$1(executor);
  5575. Internal.call(this);
  5576. var state = getInternalState$3(this);
  5577. try {
  5578. executor(bind(internalResolve, this, state), bind(internalReject, this, state));
  5579. } catch (error) {
  5580. internalReject(this, state, error);
  5581. }
  5582. };
  5583. // eslint-disable-next-line no-unused-vars
  5584. Internal = function Promise(executor) {
  5585. setInternalState$6(this, {
  5586. type: PROMISE,
  5587. done: false,
  5588. notified: false,
  5589. parent: false,
  5590. reactions: [],
  5591. rejection: false,
  5592. state: PENDING,
  5593. value: undefined
  5594. });
  5595. };
  5596. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  5597. // `Promise.prototype.then` method
  5598. // https://tc39.github.io/ecma262/#sec-promise.prototype.then
  5599. then: function then(onFulfilled, onRejected) {
  5600. var state = getInternalPromiseState(this);
  5601. var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
  5602. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  5603. reaction.fail = typeof onRejected == 'function' && onRejected;
  5604. reaction.domain = IS_NODE$1 ? process$3.domain : undefined;
  5605. state.parent = true;
  5606. state.reactions.push(reaction);
  5607. if (state.state != PENDING) notify$1(this, state, false);
  5608. return reaction.promise;
  5609. },
  5610. // `Promise.prototype.catch` method
  5611. // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
  5612. 'catch': function (onRejected) {
  5613. return this.then(undefined, onRejected);
  5614. }
  5615. });
  5616. OwnPromiseCapability = function () {
  5617. var promise = new Internal();
  5618. var state = getInternalState$3(promise);
  5619. this.promise = promise;
  5620. this.resolve = bind(internalResolve, promise, state);
  5621. this.reject = bind(internalReject, promise, state);
  5622. };
  5623. newPromiseCapability.f = newPromiseCapability$1 = function (C) {
  5624. return C === PromiseConstructor || C === PromiseWrapper
  5625. ? new OwnPromiseCapability(C)
  5626. : newGenericPromiseCapability(C);
  5627. };
  5628. if ( typeof nativePromiseConstructor == 'function') {
  5629. nativeThen = nativePromiseConstructor.prototype.then;
  5630. // wrap native Promise#then for native async functions
  5631. redefine(nativePromiseConstructor.prototype, 'then', function then(onFulfilled, onRejected) {
  5632. var that = this;
  5633. return new PromiseConstructor(function (resolve, reject) {
  5634. nativeThen.call(that, resolve, reject);
  5635. }).then(onFulfilled, onRejected);
  5636. // https://github.com/zloirock/core-js/issues/640
  5637. }, { unsafe: true });
  5638. // wrap fetch result
  5639. if (typeof $fetch$1 == 'function') _export({ global: true, enumerable: true, forced: true }, {
  5640. // eslint-disable-next-line no-unused-vars
  5641. fetch: function fetch(input /* , init */) {
  5642. return promiseResolve(PromiseConstructor, $fetch$1.apply(global_1, arguments));
  5643. }
  5644. });
  5645. }
  5646. }
  5647. _export({ global: true, wrap: true, forced: FORCED$3 }, {
  5648. Promise: PromiseConstructor
  5649. });
  5650. setToStringTag(PromiseConstructor, PROMISE, false);
  5651. setSpecies(PROMISE);
  5652. PromiseWrapper = getBuiltIn(PROMISE);
  5653. // statics
  5654. _export({ target: PROMISE, stat: true, forced: FORCED$3 }, {
  5655. // `Promise.reject` method
  5656. // https://tc39.github.io/ecma262/#sec-promise.reject
  5657. reject: function reject(r) {
  5658. var capability = newPromiseCapability$1(this);
  5659. capability.reject.call(undefined, r);
  5660. return capability.promise;
  5661. }
  5662. });
  5663. _export({ target: PROMISE, stat: true, forced: FORCED$3 }, {
  5664. // `Promise.resolve` method
  5665. // https://tc39.github.io/ecma262/#sec-promise.resolve
  5666. resolve: function resolve(x) {
  5667. return promiseResolve( this, x);
  5668. }
  5669. });
  5670. _export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION$1 }, {
  5671. // `Promise.all` method
  5672. // https://tc39.github.io/ecma262/#sec-promise.all
  5673. all: function all(iterable) {
  5674. var C = this;
  5675. var capability = newPromiseCapability$1(C);
  5676. var resolve = capability.resolve;
  5677. var reject = capability.reject;
  5678. var result = perform(function () {
  5679. var $promiseResolve = aFunction$1(C.resolve);
  5680. var values = [];
  5681. var counter = 0;
  5682. var remaining = 1;
  5683. iterate_1(iterable, function (promise) {
  5684. var index = counter++;
  5685. var alreadyCalled = false;
  5686. values.push(undefined);
  5687. remaining++;
  5688. $promiseResolve.call(C, promise).then(function (value) {
  5689. if (alreadyCalled) return;
  5690. alreadyCalled = true;
  5691. values[index] = value;
  5692. --remaining || resolve(values);
  5693. }, reject);
  5694. });
  5695. --remaining || resolve(values);
  5696. });
  5697. if (result.error) reject(result.value);
  5698. return capability.promise;
  5699. },
  5700. // `Promise.race` method
  5701. // https://tc39.github.io/ecma262/#sec-promise.race
  5702. race: function race(iterable) {
  5703. var C = this;
  5704. var capability = newPromiseCapability$1(C);
  5705. var reject = capability.reject;
  5706. var result = perform(function () {
  5707. var $promiseResolve = aFunction$1(C.resolve);
  5708. iterate_1(iterable, function (promise) {
  5709. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  5710. });
  5711. });
  5712. if (result.error) reject(result.value);
  5713. return capability.promise;
  5714. }
  5715. });
  5716. var getOwnPropertyDescriptor$4 = objectGetOwnPropertyDescriptor.f;
  5717. var nativeStartsWith = ''.startsWith;
  5718. var min$4 = Math.min;
  5719. var CORRECT_IS_REGEXP_LOGIC = correctIsRegexpLogic('startsWith');
  5720. // https://github.com/zloirock/core-js/pull/702
  5721. var MDN_POLYFILL_BUG = !CORRECT_IS_REGEXP_LOGIC && !!function () {
  5722. var descriptor = getOwnPropertyDescriptor$4(String.prototype, 'startsWith');
  5723. return descriptor && !descriptor.writable;
  5724. }();
  5725. // `String.prototype.startsWith` method
  5726. // https://tc39.github.io/ecma262/#sec-string.prototype.startswith
  5727. _export({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  5728. startsWith: function startsWith(searchString /* , position = 0 */) {
  5729. var that = String(requireObjectCoercible(this));
  5730. notARegexp(searchString);
  5731. var index = toLength(min$4(arguments.length > 1 ? arguments[1] : undefined, that.length));
  5732. var search = String(searchString);
  5733. return nativeStartsWith
  5734. ? nativeStartsWith.call(that, search, index)
  5735. : that.slice(index, index + search.length) === search;
  5736. }
  5737. });
  5738. // ==========================================================================
  5739. // Type checking utils
  5740. // ==========================================================================
  5741. var getConstructor$1 = function getConstructor(input) {
  5742. return input !== null && typeof input !== 'undefined' ? input.constructor : null;
  5743. };
  5744. var instanceOf$1 = function instanceOf(input, constructor) {
  5745. return Boolean(input && constructor && input instanceof constructor);
  5746. };
  5747. var isNullOrUndefined$1 = function isNullOrUndefined(input) {
  5748. return input === null || typeof input === 'undefined';
  5749. };
  5750. var isObject$2 = function isObject(input) {
  5751. return getConstructor$1(input) === Object;
  5752. };
  5753. var isNumber$1 = function isNumber(input) {
  5754. return getConstructor$1(input) === Number && !Number.isNaN(input);
  5755. };
  5756. var isString$1 = function isString(input) {
  5757. return getConstructor$1(input) === String;
  5758. };
  5759. var isBoolean$1 = function isBoolean(input) {
  5760. return getConstructor$1(input) === Boolean;
  5761. };
  5762. var isFunction$1 = function isFunction(input) {
  5763. return getConstructor$1(input) === Function;
  5764. };
  5765. var isArray$2 = function isArray(input) {
  5766. return Array.isArray(input);
  5767. };
  5768. var isWeakMap = function isWeakMap(input) {
  5769. return instanceOf$1(input, WeakMap);
  5770. };
  5771. var isNodeList$1 = function isNodeList(input) {
  5772. return instanceOf$1(input, NodeList);
  5773. };
  5774. var isElement$1 = function isElement(input) {
  5775. return instanceOf$1(input, Element);
  5776. };
  5777. var isTextNode = function isTextNode(input) {
  5778. return getConstructor$1(input) === Text;
  5779. };
  5780. var isEvent$1 = function isEvent(input) {
  5781. return instanceOf$1(input, Event);
  5782. };
  5783. var isKeyboardEvent = function isKeyboardEvent(input) {
  5784. return instanceOf$1(input, KeyboardEvent);
  5785. };
  5786. var isCue = function isCue(input) {
  5787. return instanceOf$1(input, window.TextTrackCue) || instanceOf$1(input, window.VTTCue);
  5788. };
  5789. var isTrack = function isTrack(input) {
  5790. return instanceOf$1(input, TextTrack) || !isNullOrUndefined$1(input) && isString$1(input.kind);
  5791. };
  5792. var isPromise = function isPromise(input) {
  5793. return instanceOf$1(input, Promise) && isFunction$1(input.then);
  5794. };
  5795. var isEmpty$1 = function isEmpty(input) {
  5796. return isNullOrUndefined$1(input) || (isString$1(input) || isArray$2(input) || isNodeList$1(input)) && !input.length || isObject$2(input) && !Object.keys(input).length;
  5797. };
  5798. var isUrl = function isUrl(input) {
  5799. // Accept a URL object
  5800. if (instanceOf$1(input, window.URL)) {
  5801. return true;
  5802. } // Must be string from here
  5803. if (!isString$1(input)) {
  5804. return false;
  5805. } // Add the protocol if required
  5806. var string = input;
  5807. if (!input.startsWith('http://') || !input.startsWith('https://')) {
  5808. string = "http://".concat(input);
  5809. }
  5810. try {
  5811. return !isEmpty$1(new URL(string).hostname);
  5812. } catch (e) {
  5813. return false;
  5814. }
  5815. };
  5816. var is$1 = {
  5817. nullOrUndefined: isNullOrUndefined$1,
  5818. object: isObject$2,
  5819. number: isNumber$1,
  5820. string: isString$1,
  5821. boolean: isBoolean$1,
  5822. function: isFunction$1,
  5823. array: isArray$2,
  5824. weakMap: isWeakMap,
  5825. nodeList: isNodeList$1,
  5826. element: isElement$1,
  5827. textNode: isTextNode,
  5828. event: isEvent$1,
  5829. keyboardEvent: isKeyboardEvent,
  5830. cue: isCue,
  5831. track: isTrack,
  5832. promise: isPromise,
  5833. url: isUrl,
  5834. empty: isEmpty$1
  5835. };
  5836. var transitionEndEvent = function () {
  5837. var element = document.createElement('span');
  5838. var events = {
  5839. WebkitTransition: 'webkitTransitionEnd',
  5840. MozTransition: 'transitionend',
  5841. OTransition: 'oTransitionEnd otransitionend',
  5842. transition: 'transitionend'
  5843. };
  5844. var type = Object.keys(events).find(function (event) {
  5845. return element.style[event] !== undefined;
  5846. });
  5847. return is$1.string(type) ? events[type] : false;
  5848. }(); // Force repaint of element
  5849. function repaint(element, delay) {
  5850. setTimeout(function () {
  5851. try {
  5852. // eslint-disable-next-line no-param-reassign
  5853. element.hidden = true; // eslint-disable-next-line no-unused-expressions
  5854. element.offsetHeight; // eslint-disable-next-line no-param-reassign
  5855. element.hidden = false;
  5856. } catch (e) {// Do nothing
  5857. }
  5858. }, delay);
  5859. }
  5860. // ==========================================================================
  5861. // Browser sniffing
  5862. // Unfortunately, due to mixed support, UA sniffing is required
  5863. // ==========================================================================
  5864. var browser = {
  5865. isIE:
  5866. /* @cc_on!@ */
  5867. !!document.documentMode,
  5868. isEdge: window.navigator.userAgent.includes('Edge'),
  5869. isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),
  5870. isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
  5871. isIos: /(iPad|iPhone|iPod)/gi.test(navigator.platform)
  5872. };
  5873. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  5874. var createMethod$5 = function (IS_RIGHT) {
  5875. return function (that, callbackfn, argumentsLength, memo) {
  5876. aFunction$1(callbackfn);
  5877. var O = toObject(that);
  5878. var self = indexedObject(O);
  5879. var length = toLength(O.length);
  5880. var index = IS_RIGHT ? length - 1 : 0;
  5881. var i = IS_RIGHT ? -1 : 1;
  5882. if (argumentsLength < 2) while (true) {
  5883. if (index in self) {
  5884. memo = self[index];
  5885. index += i;
  5886. break;
  5887. }
  5888. index += i;
  5889. if (IS_RIGHT ? index < 0 : length <= index) {
  5890. throw TypeError('Reduce of empty array with no initial value');
  5891. }
  5892. }
  5893. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  5894. memo = callbackfn(memo, self[index], index, O);
  5895. }
  5896. return memo;
  5897. };
  5898. };
  5899. var arrayReduce = {
  5900. // `Array.prototype.reduce` method
  5901. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  5902. left: createMethod$5(false),
  5903. // `Array.prototype.reduceRight` method
  5904. // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
  5905. right: createMethod$5(true)
  5906. };
  5907. var $reduce = arrayReduce.left;
  5908. var STRICT_METHOD$5 = arrayMethodIsStrict('reduce');
  5909. var USES_TO_LENGTH$9 = arrayMethodUsesToLength('reduce', { 1: 0 });
  5910. // `Array.prototype.reduce` method
  5911. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  5912. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$5 || !USES_TO_LENGTH$9 }, {
  5913. reduce: function reduce(callbackfn /* , initialValue */) {
  5914. return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
  5915. }
  5916. });
  5917. function cloneDeep(object) {
  5918. return JSON.parse(JSON.stringify(object));
  5919. } // Get a nested value in an object
  5920. function getDeep(object, path) {
  5921. return path.split('.').reduce(function (obj, key) {
  5922. return obj && obj[key];
  5923. }, object);
  5924. } // Deep extend destination object with N more objects
  5925. function extend() {
  5926. var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5927. for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5928. sources[_key - 1] = arguments[_key];
  5929. }
  5930. if (!sources.length) {
  5931. return target;
  5932. }
  5933. var source = sources.shift();
  5934. if (!is$1.object(source)) {
  5935. return target;
  5936. }
  5937. Object.keys(source).forEach(function (key) {
  5938. if (is$1.object(source[key])) {
  5939. if (!Object.keys(target).includes(key)) {
  5940. Object.assign(target, _defineProperty({}, key, {}));
  5941. }
  5942. extend(target[key], source[key]);
  5943. } else {
  5944. Object.assign(target, _defineProperty({}, key, source[key]));
  5945. }
  5946. });
  5947. return extend.apply(void 0, [target].concat(sources));
  5948. }
  5949. function wrap$1(elements, wrapper) {
  5950. // Convert `elements` to an array, if necessary.
  5951. var targets = elements.length ? elements : [elements]; // Loops backwards to prevent having to clone the wrapper on the
  5952. // first element (see `child` below).
  5953. Array.from(targets).reverse().forEach(function (element, index) {
  5954. var child = index > 0 ? wrapper.cloneNode(true) : wrapper; // Cache the current parent and sibling.
  5955. var parent = element.parentNode;
  5956. var sibling = element.nextSibling; // Wrap the element (is automatically removed from its current
  5957. // parent).
  5958. child.appendChild(element); // If the element had a sibling, insert the wrapper before
  5959. // the sibling to maintain the HTML structure; otherwise, just
  5960. // append it to the parent.
  5961. if (sibling) {
  5962. parent.insertBefore(child, sibling);
  5963. } else {
  5964. parent.appendChild(child);
  5965. }
  5966. });
  5967. } // Set attributes
  5968. function setAttributes(element, attributes) {
  5969. if (!is$1.element(element) || is$1.empty(attributes)) {
  5970. return;
  5971. } // Assume null and undefined attributes should be left out,
  5972. // Setting them would otherwise convert them to "null" and "undefined"
  5973. Object.entries(attributes).filter(function (_ref) {
  5974. var _ref2 = _slicedToArray(_ref, 2),
  5975. value = _ref2[1];
  5976. return !is$1.nullOrUndefined(value);
  5977. }).forEach(function (_ref3) {
  5978. var _ref4 = _slicedToArray(_ref3, 2),
  5979. key = _ref4[0],
  5980. value = _ref4[1];
  5981. return element.setAttribute(key, value);
  5982. });
  5983. } // Create a DocumentFragment
  5984. function createElement(type, attributes, text) {
  5985. // Create a new <element>
  5986. var element = document.createElement(type); // Set all passed attributes
  5987. if (is$1.object(attributes)) {
  5988. setAttributes(element, attributes);
  5989. } // Add text node
  5990. if (is$1.string(text)) {
  5991. element.innerText = text;
  5992. } // Return built element
  5993. return element;
  5994. } // Inaert an element after another
  5995. function insertAfter(element, target) {
  5996. if (!is$1.element(element) || !is$1.element(target)) {
  5997. return;
  5998. }
  5999. target.parentNode.insertBefore(element, target.nextSibling);
  6000. } // Insert a DocumentFragment
  6001. function insertElement(type, parent, attributes, text) {
  6002. if (!is$1.element(parent)) {
  6003. return;
  6004. }
  6005. parent.appendChild(createElement(type, attributes, text));
  6006. } // Remove element(s)
  6007. function removeElement(element) {
  6008. if (is$1.nodeList(element) || is$1.array(element)) {
  6009. Array.from(element).forEach(removeElement);
  6010. return;
  6011. }
  6012. if (!is$1.element(element) || !is$1.element(element.parentNode)) {
  6013. return;
  6014. }
  6015. element.parentNode.removeChild(element);
  6016. } // Remove all child elements
  6017. function emptyElement(element) {
  6018. if (!is$1.element(element)) {
  6019. return;
  6020. }
  6021. var length = element.childNodes.length;
  6022. while (length > 0) {
  6023. element.removeChild(element.lastChild);
  6024. length -= 1;
  6025. }
  6026. } // Replace element
  6027. function replaceElement(newChild, oldChild) {
  6028. if (!is$1.element(oldChild) || !is$1.element(oldChild.parentNode) || !is$1.element(newChild)) {
  6029. return null;
  6030. }
  6031. oldChild.parentNode.replaceChild(newChild, oldChild);
  6032. return newChild;
  6033. } // Get an attribute object from a string selector
  6034. function getAttributesFromSelector(sel, existingAttributes) {
  6035. // For example:
  6036. // '.test' to { class: 'test' }
  6037. // '#test' to { id: 'test' }
  6038. // '[data-test="test"]' to { 'data-test': 'test' }
  6039. if (!is$1.string(sel) || is$1.empty(sel)) {
  6040. return {};
  6041. }
  6042. var attributes = {};
  6043. var existing = extend({}, existingAttributes);
  6044. sel.split(',').forEach(function (s) {
  6045. // Remove whitespace
  6046. var selector = s.trim();
  6047. var className = selector.replace('.', '');
  6048. var stripped = selector.replace(/[[\]]/g, ''); // Get the parts and value
  6049. var parts = stripped.split('=');
  6050. var _parts = _slicedToArray(parts, 1),
  6051. key = _parts[0];
  6052. var value = parts.length > 1 ? parts[1].replace(/["']/g, '') : ''; // Get the first character
  6053. var start = selector.charAt(0);
  6054. switch (start) {
  6055. case '.':
  6056. // Add to existing classname
  6057. if (is$1.string(existing.class)) {
  6058. attributes.class = "".concat(existing.class, " ").concat(className);
  6059. } else {
  6060. attributes.class = className;
  6061. }
  6062. break;
  6063. case '#':
  6064. // ID selector
  6065. attributes.id = selector.replace('#', '');
  6066. break;
  6067. case '[':
  6068. // Attribute selector
  6069. attributes[key] = value;
  6070. break;
  6071. }
  6072. });
  6073. return extend(existing, attributes);
  6074. } // Toggle hidden
  6075. function toggleHidden(element, hidden) {
  6076. if (!is$1.element(element)) {
  6077. return;
  6078. }
  6079. var hide = hidden;
  6080. if (!is$1.boolean(hide)) {
  6081. hide = !element.hidden;
  6082. } // eslint-disable-next-line no-param-reassign
  6083. element.hidden = hide;
  6084. } // Mirror Element.classList.toggle, with IE compatibility for "force" argument
  6085. function toggleClass(element, className, force) {
  6086. if (is$1.nodeList(element)) {
  6087. return Array.from(element).map(function (e) {
  6088. return toggleClass(e, className, force);
  6089. });
  6090. }
  6091. if (is$1.element(element)) {
  6092. var method = 'toggle';
  6093. if (typeof force !== 'undefined') {
  6094. method = force ? 'add' : 'remove';
  6095. }
  6096. element.classList[method](className);
  6097. return element.classList.contains(className);
  6098. }
  6099. return false;
  6100. } // Has class name
  6101. function hasClass(element, className) {
  6102. return is$1.element(element) && element.classList.contains(className);
  6103. } // Element matches selector
  6104. function matches$1(element, selector) {
  6105. var _Element = Element,
  6106. prototype = _Element.prototype;
  6107. function match() {
  6108. return Array.from(document.querySelectorAll(selector)).includes(this);
  6109. }
  6110. var method = prototype.matches || prototype.webkitMatchesSelector || prototype.mozMatchesSelector || prototype.msMatchesSelector || match;
  6111. return method.call(element, selector);
  6112. } // Closest ancestor element matching selector (also tests element itself)
  6113. function closest(element, selector) {
  6114. var _Element2 = Element,
  6115. prototype = _Element2.prototype; // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
  6116. function closestElement() {
  6117. var el = this;
  6118. do {
  6119. if (matches$1.matches(el, selector)) return el;
  6120. el = el.parentElement || el.parentNode;
  6121. } while (el !== null && el.nodeType === 1);
  6122. return null;
  6123. }
  6124. var method = prototype.closest || closestElement;
  6125. return method.call(element, selector);
  6126. } // Find all elements
  6127. function getElements(selector) {
  6128. return this.elements.container.querySelectorAll(selector);
  6129. } // Find a single element
  6130. function getElement(selector) {
  6131. return this.elements.container.querySelector(selector);
  6132. } // Set focus and tab focus class
  6133. function setFocus() {
  6134. var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6135. var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6136. if (!is$1.element(element)) {
  6137. return;
  6138. } // Set regular focus
  6139. element.focus({
  6140. preventScroll: true
  6141. }); // If we want to mimic keyboard focus via tab
  6142. if (tabFocus) {
  6143. toggleClass(element, this.config.classNames.tabFocus);
  6144. }
  6145. }
  6146. var defaultCodecs = {
  6147. 'audio/ogg': 'vorbis',
  6148. 'audio/wav': '1',
  6149. 'video/webm': 'vp8, vorbis',
  6150. 'video/mp4': 'avc1.42E01E, mp4a.40.2',
  6151. 'video/ogg': 'theora'
  6152. }; // Check for feature support
  6153. var support = {
  6154. // Basic support
  6155. audio: 'canPlayType' in document.createElement('audio'),
  6156. video: 'canPlayType' in document.createElement('video'),
  6157. // Check for support
  6158. // Basic functionality vs full UI
  6159. check: function check(type, provider, playsinline) {
  6160. var canPlayInline = browser.isIPhone && playsinline && support.playsinline;
  6161. var api = support[type] || provider !== 'html5';
  6162. var ui = api && support.rangeInput && (type !== 'video' || !browser.isIPhone || canPlayInline);
  6163. return {
  6164. api: api,
  6165. ui: ui
  6166. };
  6167. },
  6168. // Picture-in-picture support
  6169. // Safari & Chrome only currently
  6170. pip: function () {
  6171. if (browser.isIPhone) {
  6172. return false;
  6173. } // Safari
  6174. // https://developer.apple.com/documentation/webkitjs/adding_picture_in_picture_to_your_safari_media_controls
  6175. if (is$1.function(createElement('video').webkitSetPresentationMode)) {
  6176. return true;
  6177. } // Chrome
  6178. // https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture
  6179. if (document.pictureInPictureEnabled && !createElement('video').disablePictureInPicture) {
  6180. return true;
  6181. }
  6182. return false;
  6183. }(),
  6184. // Airplay support
  6185. // Safari only currently
  6186. airplay: is$1.function(window.WebKitPlaybackTargetAvailabilityEvent),
  6187. // Inline playback support
  6188. // https://webkit.org/blog/6784/new-video-policies-for-ios/
  6189. playsinline: 'playsInline' in document.createElement('video'),
  6190. // Check for mime type support against a player instance
  6191. // Credits: http://diveintohtml5.info/everything.html
  6192. // Related: http://www.leanbackplayer.com/test/h5mt.html
  6193. mime: function mime(input) {
  6194. if (is$1.empty(input)) {
  6195. return false;
  6196. }
  6197. var _input$split = input.split('/'),
  6198. _input$split2 = _slicedToArray(_input$split, 1),
  6199. mediaType = _input$split2[0];
  6200. var type = input; // Verify we're using HTML5 and there's no media type mismatch
  6201. if (!this.isHTML5 || mediaType !== this.type) {
  6202. return false;
  6203. } // Add codec if required
  6204. if (Object.keys(defaultCodecs).includes(type)) {
  6205. type += "; codecs=\"".concat(defaultCodecs[input], "\"");
  6206. }
  6207. try {
  6208. return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
  6209. } catch (e) {
  6210. return false;
  6211. }
  6212. },
  6213. // Check for textTracks support
  6214. textTracks: 'textTracks' in document.createElement('video'),
  6215. // <input type="range"> Sliders
  6216. rangeInput: function () {
  6217. var range = document.createElement('input');
  6218. range.type = 'range';
  6219. return range.type === 'range';
  6220. }(),
  6221. // Touch
  6222. // NOTE: Remember a device can be mouse + touch enabled so we check on first touch event
  6223. touch: 'ontouchstart' in document.documentElement,
  6224. // Detect transitions support
  6225. transitions: transitionEndEvent !== false,
  6226. // Reduced motion iOS & MacOS setting
  6227. // https://webkit.org/blog/7551/responsive-design-for-motion/
  6228. reducedMotion: 'matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches
  6229. };
  6230. // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
  6231. // https://www.youtube.com/watch?v=NPM6172J22g
  6232. var supportsPassiveListeners = function () {
  6233. // Test via a getter in the options object to see if the passive property is accessed
  6234. var supported = false;
  6235. try {
  6236. var options = Object.defineProperty({}, 'passive', {
  6237. get: function get() {
  6238. supported = true;
  6239. return null;
  6240. }
  6241. });
  6242. window.addEventListener('test', null, options);
  6243. window.removeEventListener('test', null, options);
  6244. } catch (e) {// Do nothing
  6245. }
  6246. return supported;
  6247. }(); // Toggle event listener
  6248. function toggleListener(element, event, callback) {
  6249. var _this = this;
  6250. var toggle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6251. var passive = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  6252. var capture = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
  6253. // Bail if no element, event, or callback
  6254. if (!element || !('addEventListener' in element) || is$1.empty(event) || !is$1.function(callback)) {
  6255. return;
  6256. } // Allow multiple events
  6257. var events = event.split(' '); // Build options
  6258. // Default to just the capture boolean for browsers with no passive listener support
  6259. var options = capture; // If passive events listeners are supported
  6260. if (supportsPassiveListeners) {
  6261. options = {
  6262. // Whether the listener can be passive (i.e. default never prevented)
  6263. passive: passive,
  6264. // Whether the listener is a capturing listener or not
  6265. capture: capture
  6266. };
  6267. } // If a single node is passed, bind the event listener
  6268. events.forEach(function (type) {
  6269. if (_this && _this.eventListeners && toggle) {
  6270. // Cache event listener
  6271. _this.eventListeners.push({
  6272. element: element,
  6273. type: type,
  6274. callback: callback,
  6275. options: options
  6276. });
  6277. }
  6278. element[toggle ? 'addEventListener' : 'removeEventListener'](type, callback, options);
  6279. });
  6280. } // Bind event handler
  6281. function on(element) {
  6282. var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6283. var callback = arguments.length > 2 ? arguments[2] : undefined;
  6284. var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6285. var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6286. toggleListener.call(this, element, events, callback, true, passive, capture);
  6287. } // Unbind event handler
  6288. function off(element) {
  6289. var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6290. var callback = arguments.length > 2 ? arguments[2] : undefined;
  6291. var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6292. var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6293. toggleListener.call(this, element, events, callback, false, passive, capture);
  6294. } // Bind once-only event handler
  6295. function once(element) {
  6296. var _this2 = this;
  6297. var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6298. var callback = arguments.length > 2 ? arguments[2] : undefined;
  6299. var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6300. var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6301. var onceCallback = function onceCallback() {
  6302. off(element, events, onceCallback, passive, capture);
  6303. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6304. args[_key] = arguments[_key];
  6305. }
  6306. callback.apply(_this2, args);
  6307. };
  6308. toggleListener.call(this, element, events, onceCallback, true, passive, capture);
  6309. } // Trigger event
  6310. function triggerEvent(element) {
  6311. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6312. var bubbles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6313. var detail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  6314. // Bail if no element
  6315. if (!is$1.element(element) || is$1.empty(type)) {
  6316. return;
  6317. } // Create and dispatch the event
  6318. var event = new CustomEvent(type, {
  6319. bubbles: bubbles,
  6320. detail: _objectSpread2(_objectSpread2({}, detail), {}, {
  6321. plyr: this
  6322. })
  6323. }); // Dispatch the event
  6324. element.dispatchEvent(event);
  6325. } // Unbind all cached event listeners
  6326. function unbindListeners() {
  6327. if (this && this.eventListeners) {
  6328. this.eventListeners.forEach(function (item) {
  6329. var element = item.element,
  6330. type = item.type,
  6331. callback = item.callback,
  6332. options = item.options;
  6333. element.removeEventListener(type, callback, options);
  6334. });
  6335. this.eventListeners = [];
  6336. }
  6337. } // Run method when / if player is ready
  6338. function ready() {
  6339. var _this3 = this;
  6340. return new Promise(function (resolve) {
  6341. return _this3.ready ? setTimeout(resolve, 0) : on.call(_this3, _this3.elements.container, 'ready', resolve);
  6342. }).then(function () {});
  6343. }
  6344. /**
  6345. * Silence a Promise-like object.
  6346. * This is useful for avoiding non-harmful, but potentially confusing "uncaught
  6347. * play promise" rejection error messages.
  6348. * @param {Object} value An object that may or may not be `Promise`-like.
  6349. */
  6350. function silencePromise(value) {
  6351. if (is$1.promise(value)) {
  6352. value.then(null, function () {});
  6353. }
  6354. }
  6355. function validateRatio(input) {
  6356. if (!is$1.array(input) && (!is$1.string(input) || !input.includes(':'))) {
  6357. return false;
  6358. }
  6359. var ratio = is$1.array(input) ? input : input.split(':');
  6360. return ratio.map(Number).every(is$1.number);
  6361. }
  6362. function reduceAspectRatio(ratio) {
  6363. if (!is$1.array(ratio) || !ratio.every(is$1.number)) {
  6364. return null;
  6365. }
  6366. var _ratio = _slicedToArray(ratio, 2),
  6367. width = _ratio[0],
  6368. height = _ratio[1];
  6369. var getDivider = function getDivider(w, h) {
  6370. return h === 0 ? w : getDivider(h, w % h);
  6371. };
  6372. var divider = getDivider(width, height);
  6373. return [width / divider, height / divider];
  6374. }
  6375. function getAspectRatio(input) {
  6376. var parse = function parse(ratio) {
  6377. return validateRatio(ratio) ? ratio.split(':').map(Number) : null;
  6378. }; // Try provided ratio
  6379. var ratio = parse(input); // Get from config
  6380. if (ratio === null) {
  6381. ratio = parse(this.config.ratio);
  6382. } // Get from embed
  6383. if (ratio === null && !is$1.empty(this.embed) && is$1.array(this.embed.ratio)) {
  6384. ratio = this.embed.ratio;
  6385. } // Get from HTML5 video
  6386. if (ratio === null && this.isHTML5) {
  6387. var _this$media = this.media,
  6388. videoWidth = _this$media.videoWidth,
  6389. videoHeight = _this$media.videoHeight;
  6390. ratio = reduceAspectRatio([videoWidth, videoHeight]);
  6391. }
  6392. return ratio;
  6393. } // Set aspect ratio for responsive container
  6394. function setAspectRatio(input) {
  6395. if (!this.isVideo) {
  6396. return {};
  6397. }
  6398. var wrapper = this.elements.wrapper;
  6399. var ratio = getAspectRatio.call(this, input);
  6400. var _ref = is$1.array(ratio) ? ratio : [0, 0],
  6401. _ref2 = _slicedToArray(_ref, 2),
  6402. w = _ref2[0],
  6403. h = _ref2[1];
  6404. var padding = 100 / w * h;
  6405. wrapper.style.paddingBottom = "".concat(padding, "%"); // For Vimeo we have an extra <div> to hide the standard controls and UI
  6406. if (this.isVimeo && !this.config.vimeo.premium && this.supported.ui) {
  6407. var height = 100 / this.media.offsetWidth * parseInt(window.getComputedStyle(this.media).paddingBottom, 10);
  6408. var offset = (height - padding) / (height / 50);
  6409. this.media.style.transform = "translateY(-".concat(offset, "%)");
  6410. } else if (this.isHTML5) {
  6411. wrapper.classList.toggle(this.config.classNames.videoFixedRatio, ratio !== null);
  6412. }
  6413. return {
  6414. padding: padding,
  6415. ratio: ratio
  6416. };
  6417. }
  6418. var html5 = {
  6419. getSources: function getSources() {
  6420. var _this = this;
  6421. if (!this.isHTML5) {
  6422. return [];
  6423. }
  6424. var sources = Array.from(this.media.querySelectorAll('source')); // Filter out unsupported sources (if type is specified)
  6425. return sources.filter(function (source) {
  6426. var type = source.getAttribute('type');
  6427. if (is$1.empty(type)) {
  6428. return true;
  6429. }
  6430. return support.mime.call(_this, type);
  6431. });
  6432. },
  6433. // Get quality levels
  6434. getQualityOptions: function getQualityOptions() {
  6435. // Whether we're forcing all options (e.g. for streaming)
  6436. if (this.config.quality.forced) {
  6437. return this.config.quality.options;
  6438. } // Get sizes from <source> elements
  6439. return html5.getSources.call(this).map(function (source) {
  6440. return Number(source.getAttribute('data-res'));
  6441. }).filter(Boolean);
  6442. },
  6443. setup: function setup() {
  6444. if (!this.isHTML5) {
  6445. return;
  6446. }
  6447. var player = this; // Set speed options from config
  6448. player.options.speed = player.config.speed.options; // Set aspect ratio if fixed
  6449. if (!is$1.empty(this.config.ratio)) {
  6450. setAspectRatio.call(player);
  6451. } // Quality
  6452. Object.defineProperty(player.media, 'quality', {
  6453. get: function get() {
  6454. // Get sources
  6455. var sources = html5.getSources.call(player);
  6456. var source = sources.find(function (s) {
  6457. return s.getAttribute('src') === player.source;
  6458. }); // Return size, if match is found
  6459. return source && Number(source.getAttribute('data-res'));
  6460. },
  6461. set: function set(input) {
  6462. if (player.quality === input) {
  6463. return;
  6464. } // If we're using an an external handler...
  6465. if (player.config.quality.forced && is$1.function(player.config.quality.onChange)) {
  6466. player.config.quality.onChange(input);
  6467. } else {
  6468. // Get sources
  6469. var sources = html5.getSources.call(player); // Get first match for requested size
  6470. var source = sources.find(function (s) {
  6471. return Number(s.getAttribute('data-res')) === input;
  6472. }); // No matching source found
  6473. if (!source) {
  6474. return;
  6475. } // Get current state
  6476. var _player$media = player.media,
  6477. currentTime = _player$media.currentTime,
  6478. paused = _player$media.paused,
  6479. preload = _player$media.preload,
  6480. readyState = _player$media.readyState,
  6481. playbackRate = _player$media.playbackRate; // Set new source
  6482. player.media.src = source.getAttribute('src'); // Prevent loading if preload="none" and the current source isn't loaded (#1044)
  6483. if (preload !== 'none' || readyState) {
  6484. // Restore time
  6485. player.once('loadedmetadata', function () {
  6486. player.speed = playbackRate;
  6487. player.currentTime = currentTime; // Resume playing
  6488. if (!paused) {
  6489. silencePromise(player.play());
  6490. }
  6491. }); // Load new source
  6492. player.media.load();
  6493. }
  6494. } // Trigger change event
  6495. triggerEvent.call(player, player.media, 'qualitychange', false, {
  6496. quality: input
  6497. });
  6498. }
  6499. });
  6500. },
  6501. // Cancel current network requests
  6502. // See https://github.com/sampotts/plyr/issues/174
  6503. cancelRequests: function cancelRequests() {
  6504. if (!this.isHTML5) {
  6505. return;
  6506. } // Remove child sources
  6507. removeElement(html5.getSources.call(this)); // Set blank video src attribute
  6508. // This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
  6509. // Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
  6510. this.media.setAttribute('src', this.config.blankVideo); // Load the new empty source
  6511. // This will cancel existing requests
  6512. // See https://github.com/sampotts/plyr/issues/174
  6513. this.media.load(); // Debugging
  6514. this.debug.log('Cancelled network requests');
  6515. }
  6516. };
  6517. function dedupe(array) {
  6518. if (!is$1.array(array)) {
  6519. return array;
  6520. }
  6521. return array.filter(function (item, index) {
  6522. return array.indexOf(item) === index;
  6523. });
  6524. } // Get the closest value in an array
  6525. function closest$1(array, value) {
  6526. if (!is$1.array(array) || !array.length) {
  6527. return null;
  6528. }
  6529. return array.reduce(function (prev, curr) {
  6530. return Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev;
  6531. });
  6532. }
  6533. var defineProperty$6 = objectDefineProperty.f;
  6534. var getOwnPropertyNames$1 = objectGetOwnPropertyNames.f;
  6535. var setInternalState$7 = internalState.set;
  6536. var MATCH$2 = wellKnownSymbol('match');
  6537. var NativeRegExp = global_1.RegExp;
  6538. var RegExpPrototype$1 = NativeRegExp.prototype;
  6539. var re1 = /a/g;
  6540. var re2 = /a/g;
  6541. // "new" should create a new object, old webkit bug
  6542. var CORRECT_NEW = new NativeRegExp(re1) !== re1;
  6543. var UNSUPPORTED_Y$2 = regexpStickyHelpers.UNSUPPORTED_Y;
  6544. var FORCED$4 = descriptors && isForced_1('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y$2 || fails(function () {
  6545. re2[MATCH$2] = false;
  6546. // RegExp constructor can alter flags and IsRegExp works correct with @@match
  6547. return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
  6548. })));
  6549. // `RegExp` constructor
  6550. // https://tc39.github.io/ecma262/#sec-regexp-constructor
  6551. if (FORCED$4) {
  6552. var RegExpWrapper = function RegExp(pattern, flags) {
  6553. var thisIsRegExp = this instanceof RegExpWrapper;
  6554. var patternIsRegExp = isRegexp(pattern);
  6555. var flagsAreUndefined = flags === undefined;
  6556. var sticky;
  6557. if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
  6558. return pattern;
  6559. }
  6560. if (CORRECT_NEW) {
  6561. if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;
  6562. } else if (pattern instanceof RegExpWrapper) {
  6563. if (flagsAreUndefined) flags = regexpFlags.call(pattern);
  6564. pattern = pattern.source;
  6565. }
  6566. if (UNSUPPORTED_Y$2) {
  6567. sticky = !!flags && flags.indexOf('y') > -1;
  6568. if (sticky) flags = flags.replace(/y/g, '');
  6569. }
  6570. var result = inheritIfRequired(
  6571. CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),
  6572. thisIsRegExp ? this : RegExpPrototype$1,
  6573. RegExpWrapper
  6574. );
  6575. if (UNSUPPORTED_Y$2 && sticky) setInternalState$7(result, { sticky: sticky });
  6576. return result;
  6577. };
  6578. var proxy = function (key) {
  6579. key in RegExpWrapper || defineProperty$6(RegExpWrapper, key, {
  6580. configurable: true,
  6581. get: function () { return NativeRegExp[key]; },
  6582. set: function (it) { NativeRegExp[key] = it; }
  6583. });
  6584. };
  6585. var keys$2 = getOwnPropertyNames$1(NativeRegExp);
  6586. var index = 0;
  6587. while (keys$2.length > index) proxy(keys$2[index++]);
  6588. RegExpPrototype$1.constructor = RegExpWrapper;
  6589. RegExpWrapper.prototype = RegExpPrototype$1;
  6590. redefine(global_1, 'RegExp', RegExpWrapper);
  6591. }
  6592. // https://tc39.github.io/ecma262/#sec-get-regexp-@@species
  6593. setSpecies('RegExp');
  6594. function generateId(prefix) {
  6595. return "".concat(prefix, "-").concat(Math.floor(Math.random() * 10000));
  6596. } // Format string
  6597. function format(input) {
  6598. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6599. args[_key - 1] = arguments[_key];
  6600. }
  6601. if (is$1.empty(input)) {
  6602. return input;
  6603. }
  6604. return input.toString().replace(/{(\d+)}/g, function (match, i) {
  6605. return args[i].toString();
  6606. });
  6607. } // Get percentage
  6608. function getPercentage(current, max) {
  6609. if (current === 0 || max === 0 || Number.isNaN(current) || Number.isNaN(max)) {
  6610. return 0;
  6611. }
  6612. return (current / max * 100).toFixed(2);
  6613. } // Replace all occurances of a string in a string
  6614. var replaceAll = function replaceAll() {
  6615. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6616. var find = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6617. var replace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  6618. return input.replace(new RegExp(find.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'), 'g'), replace.toString());
  6619. }; // Convert to title case
  6620. var toTitleCase = function toTitleCase() {
  6621. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6622. return input.toString().replace(/\w\S*/g, function (text) {
  6623. return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
  6624. });
  6625. }; // Convert string to pascalCase
  6626. function toPascalCase() {
  6627. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6628. var string = input.toString(); // Convert kebab case
  6629. string = replaceAll(string, '-', ' '); // Convert snake case
  6630. string = replaceAll(string, '_', ' '); // Convert to title case
  6631. string = toTitleCase(string); // Convert to pascal case
  6632. return replaceAll(string, ' ', '');
  6633. } // Convert string to pascalCase
  6634. function toCamelCase() {
  6635. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6636. var string = input.toString(); // Convert to pascal case
  6637. string = toPascalCase(string); // Convert first character to lowercase
  6638. return string.charAt(0).toLowerCase() + string.slice(1);
  6639. } // Remove HTML from a string
  6640. function stripHTML(source) {
  6641. var fragment = document.createDocumentFragment();
  6642. var element = document.createElement('div');
  6643. fragment.appendChild(element);
  6644. element.innerHTML = source;
  6645. return fragment.firstChild.innerText;
  6646. } // Like outerHTML, but also works for DocumentFragment
  6647. function getHTML(element) {
  6648. var wrapper = document.createElement('div');
  6649. wrapper.appendChild(element);
  6650. return wrapper.innerHTML;
  6651. }
  6652. var resources = {
  6653. pip: 'PIP',
  6654. airplay: 'AirPlay',
  6655. html5: 'HTML5',
  6656. vimeo: 'Vimeo',
  6657. youtube: 'YouTube'
  6658. };
  6659. var i18n = {
  6660. get: function get() {
  6661. var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6662. var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6663. if (is$1.empty(key) || is$1.empty(config)) {
  6664. return '';
  6665. }
  6666. var string = getDeep(config.i18n, key);
  6667. if (is$1.empty(string)) {
  6668. if (Object.keys(resources).includes(key)) {
  6669. return resources[key];
  6670. }
  6671. return '';
  6672. }
  6673. var replace = {
  6674. '{seektime}': config.seekTime,
  6675. '{title}': config.title
  6676. };
  6677. Object.entries(replace).forEach(function (_ref) {
  6678. var _ref2 = _slicedToArray(_ref, 2),
  6679. k = _ref2[0],
  6680. v = _ref2[1];
  6681. string = replaceAll(string, k, v);
  6682. });
  6683. return string;
  6684. }
  6685. };
  6686. var Storage = /*#__PURE__*/function () {
  6687. function Storage(player) {
  6688. _classCallCheck(this, Storage);
  6689. this.enabled = player.config.storage.enabled;
  6690. this.key = player.config.storage.key;
  6691. } // Check for actual support (see if we can use it)
  6692. _createClass(Storage, [{
  6693. key: "get",
  6694. value: function get(key) {
  6695. if (!Storage.supported || !this.enabled) {
  6696. return null;
  6697. }
  6698. var store = window.localStorage.getItem(this.key);
  6699. if (is$1.empty(store)) {
  6700. return null;
  6701. }
  6702. var json = JSON.parse(store);
  6703. return is$1.string(key) && key.length ? json[key] : json;
  6704. }
  6705. }, {
  6706. key: "set",
  6707. value: function set(object) {
  6708. // Bail if we don't have localStorage support or it's disabled
  6709. if (!Storage.supported || !this.enabled) {
  6710. return;
  6711. } // Can only store objectst
  6712. if (!is$1.object(object)) {
  6713. return;
  6714. } // Get current storage
  6715. var storage = this.get(); // Default to empty object
  6716. if (is$1.empty(storage)) {
  6717. storage = {};
  6718. } // Update the working copy of the values
  6719. extend(storage, object); // Update storage
  6720. window.localStorage.setItem(this.key, JSON.stringify(storage));
  6721. }
  6722. }], [{
  6723. key: "supported",
  6724. get: function get() {
  6725. try {
  6726. if (!('localStorage' in window)) {
  6727. return false;
  6728. }
  6729. var test = '___test'; // Try to use it (it might be disabled, e.g. user is in private mode)
  6730. // see: https://github.com/sampotts/plyr/issues/131
  6731. window.localStorage.setItem(test, test);
  6732. window.localStorage.removeItem(test);
  6733. return true;
  6734. } catch (e) {
  6735. return false;
  6736. }
  6737. }
  6738. }]);
  6739. return Storage;
  6740. }();
  6741. // ==========================================================================
  6742. // Fetch wrapper
  6743. // Using XHR to avoid issues with older browsers
  6744. // ==========================================================================
  6745. function fetch(url) {
  6746. var responseType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'text';
  6747. return new Promise(function (resolve, reject) {
  6748. try {
  6749. var request = new XMLHttpRequest(); // Check for CORS support
  6750. if (!('withCredentials' in request)) {
  6751. return;
  6752. }
  6753. request.addEventListener('load', function () {
  6754. if (responseType === 'text') {
  6755. try {
  6756. resolve(JSON.parse(request.responseText));
  6757. } catch (e) {
  6758. resolve(request.responseText);
  6759. }
  6760. } else {
  6761. resolve(request.response);
  6762. }
  6763. });
  6764. request.addEventListener('error', function () {
  6765. throw new Error(request.status);
  6766. });
  6767. request.open('GET', url, true); // Set the required response type
  6768. request.responseType = responseType;
  6769. request.send();
  6770. } catch (e) {
  6771. reject(e);
  6772. }
  6773. });
  6774. }
  6775. // ==========================================================================
  6776. function loadSprite(url, id) {
  6777. if (!is$1.string(url)) {
  6778. return;
  6779. }
  6780. var prefix = 'cache';
  6781. var hasId = is$1.string(id);
  6782. var isCached = false;
  6783. var exists = function exists() {
  6784. return document.getElementById(id) !== null;
  6785. };
  6786. var update = function update(container, data) {
  6787. // eslint-disable-next-line no-param-reassign
  6788. container.innerHTML = data; // Check again incase of race condition
  6789. if (hasId && exists()) {
  6790. return;
  6791. } // Inject the SVG to the body
  6792. document.body.insertAdjacentElement('afterbegin', container);
  6793. }; // Only load once if ID set
  6794. if (!hasId || !exists()) {
  6795. var useStorage = Storage.supported; // Create container
  6796. var container = document.createElement('div');
  6797. container.setAttribute('hidden', '');
  6798. if (hasId) {
  6799. container.setAttribute('id', id);
  6800. } // Check in cache
  6801. if (useStorage) {
  6802. var cached = window.localStorage.getItem("".concat(prefix, "-").concat(id));
  6803. isCached = cached !== null;
  6804. if (isCached) {
  6805. var data = JSON.parse(cached);
  6806. update(container, data.content);
  6807. }
  6808. } // Get the sprite
  6809. fetch(url).then(function (result) {
  6810. if (is$1.empty(result)) {
  6811. return;
  6812. }
  6813. if (useStorage) {
  6814. window.localStorage.setItem("".concat(prefix, "-").concat(id), JSON.stringify({
  6815. content: result
  6816. }));
  6817. }
  6818. update(container, result);
  6819. }).catch(function () {});
  6820. }
  6821. }
  6822. var ceil$1 = Math.ceil;
  6823. var floor$5 = Math.floor;
  6824. // `Math.trunc` method
  6825. // https://tc39.github.io/ecma262/#sec-math.trunc
  6826. _export({ target: 'Math', stat: true }, {
  6827. trunc: function trunc(it) {
  6828. return (it > 0 ? floor$5 : ceil$1)(it);
  6829. }
  6830. });
  6831. var getHours = function getHours(value) {
  6832. return Math.trunc(value / 60 / 60 % 60, 10);
  6833. };
  6834. var getMinutes = function getMinutes(value) {
  6835. return Math.trunc(value / 60 % 60, 10);
  6836. };
  6837. var getSeconds = function getSeconds(value) {
  6838. return Math.trunc(value % 60, 10);
  6839. }; // Format time to UI friendly string
  6840. function formatTime() {
  6841. var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  6842. var displayHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6843. var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6844. // Bail if the value isn't a number
  6845. if (!is$1.number(time)) {
  6846. return formatTime(undefined, displayHours, inverted);
  6847. } // Format time component to add leading zero
  6848. var format = function format(value) {
  6849. return "0".concat(value).slice(-2);
  6850. }; // Breakdown to hours, mins, secs
  6851. var hours = getHours(time);
  6852. var mins = getMinutes(time);
  6853. var secs = getSeconds(time); // Do we need to display hours?
  6854. if (displayHours || hours > 0) {
  6855. hours = "".concat(hours, ":");
  6856. } else {
  6857. hours = '';
  6858. } // Render
  6859. return "".concat(inverted && time > 0 ? '-' : '').concat(hours).concat(format(mins), ":").concat(format(secs));
  6860. }
  6861. var controls = {
  6862. // Get icon URL
  6863. getIconUrl: function getIconUrl() {
  6864. var url = new URL(this.config.iconUrl, window.location);
  6865. var cors = url.host !== window.location.host || browser.isIE && !window.svg4everybody;
  6866. return {
  6867. url: this.config.iconUrl,
  6868. cors: cors
  6869. };
  6870. },
  6871. // Find the UI controls
  6872. findElements: function findElements() {
  6873. try {
  6874. this.elements.controls = getElement.call(this, this.config.selectors.controls.wrapper); // Buttons
  6875. this.elements.buttons = {
  6876. play: getElements.call(this, this.config.selectors.buttons.play),
  6877. pause: getElement.call(this, this.config.selectors.buttons.pause),
  6878. restart: getElement.call(this, this.config.selectors.buttons.restart),
  6879. rewind: getElement.call(this, this.config.selectors.buttons.rewind),
  6880. fastForward: getElement.call(this, this.config.selectors.buttons.fastForward),
  6881. mute: getElement.call(this, this.config.selectors.buttons.mute),
  6882. pip: getElement.call(this, this.config.selectors.buttons.pip),
  6883. airplay: getElement.call(this, this.config.selectors.buttons.airplay),
  6884. settings: getElement.call(this, this.config.selectors.buttons.settings),
  6885. captions: getElement.call(this, this.config.selectors.buttons.captions),
  6886. fullscreen: getElement.call(this, this.config.selectors.buttons.fullscreen)
  6887. }; // Progress
  6888. this.elements.progress = getElement.call(this, this.config.selectors.progress); // Inputs
  6889. this.elements.inputs = {
  6890. seek: getElement.call(this, this.config.selectors.inputs.seek),
  6891. volume: getElement.call(this, this.config.selectors.inputs.volume)
  6892. }; // Display
  6893. this.elements.display = {
  6894. buffer: getElement.call(this, this.config.selectors.display.buffer),
  6895. currentTime: getElement.call(this, this.config.selectors.display.currentTime),
  6896. duration: getElement.call(this, this.config.selectors.display.duration)
  6897. }; // Seek tooltip
  6898. if (is$1.element(this.elements.progress)) {
  6899. this.elements.display.seekTooltip = this.elements.progress.querySelector(".".concat(this.config.classNames.tooltip));
  6900. }
  6901. return true;
  6902. } catch (error) {
  6903. // Log it
  6904. this.debug.warn('It looks like there is a problem with your custom controls HTML', error); // Restore native video controls
  6905. this.toggleNativeControls(true);
  6906. return false;
  6907. }
  6908. },
  6909. // Create <svg> icon
  6910. createIcon: function createIcon(type, attributes) {
  6911. var namespace = 'http://www.w3.org/2000/svg';
  6912. var iconUrl = controls.getIconUrl.call(this);
  6913. var iconPath = "".concat(!iconUrl.cors ? iconUrl.url : '', "#").concat(this.config.iconPrefix); // Create <svg>
  6914. var icon = document.createElementNS(namespace, 'svg');
  6915. setAttributes(icon, extend(attributes, {
  6916. 'aria-hidden': 'true',
  6917. focusable: 'false'
  6918. })); // Create the <use> to reference sprite
  6919. var use = document.createElementNS(namespace, 'use');
  6920. var path = "".concat(iconPath, "-").concat(type); // Set `href` attributes
  6921. // https://github.com/sampotts/plyr/issues/460
  6922. // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href
  6923. if ('href' in use) {
  6924. use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', path);
  6925. } // Always set the older attribute even though it's "deprecated" (it'll be around for ages)
  6926. use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', path); // Add <use> to <svg>
  6927. icon.appendChild(use);
  6928. return icon;
  6929. },
  6930. // Create hidden text label
  6931. createLabel: function createLabel(key) {
  6932. var attr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6933. var text = i18n.get(key, this.config);
  6934. var attributes = _objectSpread2(_objectSpread2({}, attr), {}, {
  6935. class: [attr.class, this.config.classNames.hidden].filter(Boolean).join(' ')
  6936. });
  6937. return createElement('span', attributes, text);
  6938. },
  6939. // Create a badge
  6940. createBadge: function createBadge(text) {
  6941. if (is$1.empty(text)) {
  6942. return null;
  6943. }
  6944. var badge = createElement('span', {
  6945. class: this.config.classNames.menu.value
  6946. });
  6947. badge.appendChild(createElement('span', {
  6948. class: this.config.classNames.menu.badge
  6949. }, text));
  6950. return badge;
  6951. },
  6952. // Create a <button>
  6953. createButton: function createButton(buttonType, attr) {
  6954. var _this = this;
  6955. var attributes = extend({}, attr);
  6956. var type = toCamelCase(buttonType);
  6957. var props = {
  6958. element: 'button',
  6959. toggle: false,
  6960. label: null,
  6961. icon: null,
  6962. labelPressed: null,
  6963. iconPressed: null
  6964. };
  6965. ['element', 'icon', 'label'].forEach(function (key) {
  6966. if (Object.keys(attributes).includes(key)) {
  6967. props[key] = attributes[key];
  6968. delete attributes[key];
  6969. }
  6970. }); // Default to 'button' type to prevent form submission
  6971. if (props.element === 'button' && !Object.keys(attributes).includes('type')) {
  6972. attributes.type = 'button';
  6973. } // Set class name
  6974. if (Object.keys(attributes).includes('class')) {
  6975. if (!attributes.class.split(' ').some(function (c) {
  6976. return c === _this.config.classNames.control;
  6977. })) {
  6978. extend(attributes, {
  6979. class: "".concat(attributes.class, " ").concat(this.config.classNames.control)
  6980. });
  6981. }
  6982. } else {
  6983. attributes.class = this.config.classNames.control;
  6984. } // Large play button
  6985. switch (buttonType) {
  6986. case 'play':
  6987. props.toggle = true;
  6988. props.label = 'play';
  6989. props.labelPressed = 'pause';
  6990. props.icon = 'play';
  6991. props.iconPressed = 'pause';
  6992. break;
  6993. case 'mute':
  6994. props.toggle = true;
  6995. props.label = 'mute';
  6996. props.labelPressed = 'unmute';
  6997. props.icon = 'volume';
  6998. props.iconPressed = 'muted';
  6999. break;
  7000. case 'captions':
  7001. props.toggle = true;
  7002. props.label = 'enableCaptions';
  7003. props.labelPressed = 'disableCaptions';
  7004. props.icon = 'captions-off';
  7005. props.iconPressed = 'captions-on';
  7006. break;
  7007. case 'fullscreen':
  7008. props.toggle = true;
  7009. props.label = 'enterFullscreen';
  7010. props.labelPressed = 'exitFullscreen';
  7011. props.icon = 'enter-fullscreen';
  7012. props.iconPressed = 'exit-fullscreen';
  7013. break;
  7014. case 'play-large':
  7015. attributes.class += " ".concat(this.config.classNames.control, "--overlaid");
  7016. type = 'play';
  7017. props.label = 'play';
  7018. props.icon = 'play';
  7019. break;
  7020. default:
  7021. if (is$1.empty(props.label)) {
  7022. props.label = type;
  7023. }
  7024. if (is$1.empty(props.icon)) {
  7025. props.icon = buttonType;
  7026. }
  7027. }
  7028. var button = createElement(props.element); // Setup toggle icon and labels
  7029. if (props.toggle) {
  7030. // Icon
  7031. button.appendChild(controls.createIcon.call(this, props.iconPressed, {
  7032. class: 'icon--pressed'
  7033. }));
  7034. button.appendChild(controls.createIcon.call(this, props.icon, {
  7035. class: 'icon--not-pressed'
  7036. })); // Label/Tooltip
  7037. button.appendChild(controls.createLabel.call(this, props.labelPressed, {
  7038. class: 'label--pressed'
  7039. }));
  7040. button.appendChild(controls.createLabel.call(this, props.label, {
  7041. class: 'label--not-pressed'
  7042. }));
  7043. } else {
  7044. button.appendChild(controls.createIcon.call(this, props.icon));
  7045. button.appendChild(controls.createLabel.call(this, props.label));
  7046. } // Merge and set attributes
  7047. extend(attributes, getAttributesFromSelector(this.config.selectors.buttons[type], attributes));
  7048. setAttributes(button, attributes); // We have multiple play buttons
  7049. if (type === 'play') {
  7050. if (!is$1.array(this.elements.buttons[type])) {
  7051. this.elements.buttons[type] = [];
  7052. }
  7053. this.elements.buttons[type].push(button);
  7054. } else {
  7055. this.elements.buttons[type] = button;
  7056. }
  7057. return button;
  7058. },
  7059. // Create an <input type='range'>
  7060. createRange: function createRange(type, attributes) {
  7061. // Seek input
  7062. var input = createElement('input', extend(getAttributesFromSelector(this.config.selectors.inputs[type]), {
  7063. type: 'range',
  7064. min: 0,
  7065. max: 100,
  7066. step: 0.01,
  7067. value: 0,
  7068. autocomplete: 'off',
  7069. // A11y fixes for https://github.com/sampotts/plyr/issues/905
  7070. role: 'slider',
  7071. 'aria-label': i18n.get(type, this.config),
  7072. 'aria-valuemin': 0,
  7073. 'aria-valuemax': 100,
  7074. 'aria-valuenow': 0
  7075. }, attributes));
  7076. this.elements.inputs[type] = input; // Set the fill for webkit now
  7077. controls.updateRangeFill.call(this, input); // Improve support on touch devices
  7078. RangeTouch.setup(input);
  7079. return input;
  7080. },
  7081. // Create a <progress>
  7082. createProgress: function createProgress(type, attributes) {
  7083. var progress = createElement('progress', extend(getAttributesFromSelector(this.config.selectors.display[type]), {
  7084. min: 0,
  7085. max: 100,
  7086. value: 0,
  7087. role: 'progressbar',
  7088. 'aria-hidden': true
  7089. }, attributes)); // Create the label inside
  7090. if (type !== 'volume') {
  7091. progress.appendChild(createElement('span', null, '0'));
  7092. var suffixKey = {
  7093. played: 'played',
  7094. buffer: 'buffered'
  7095. }[type];
  7096. var suffix = suffixKey ? i18n.get(suffixKey, this.config) : '';
  7097. progress.innerText = "% ".concat(suffix.toLowerCase());
  7098. }
  7099. this.elements.display[type] = progress;
  7100. return progress;
  7101. },
  7102. // Create time display
  7103. createTime: function createTime(type, attrs) {
  7104. var attributes = getAttributesFromSelector(this.config.selectors.display[type], attrs);
  7105. var container = createElement('div', extend(attributes, {
  7106. class: "".concat(attributes.class ? attributes.class : '', " ").concat(this.config.classNames.display.time, " ").trim(),
  7107. 'aria-label': i18n.get(type, this.config)
  7108. }), '00:00'); // Reference for updates
  7109. this.elements.display[type] = container;
  7110. return container;
  7111. },
  7112. // Bind keyboard shortcuts for a menu item
  7113. // We have to bind to keyup otherwise Firefox triggers a click when a keydown event handler shifts focus
  7114. // https://bugzilla.mozilla.org/show_bug.cgi?id=1220143
  7115. bindMenuItemShortcuts: function bindMenuItemShortcuts(menuItem, type) {
  7116. var _this2 = this;
  7117. // Navigate through menus via arrow keys and space
  7118. on.call(this, menuItem, 'keydown keyup', function (event) {
  7119. // We only care about space and ⬆️ ⬇️️ ➡️
  7120. if (![32, 38, 39, 40].includes(event.which)) {
  7121. return;
  7122. } // Prevent play / seek
  7123. event.preventDefault();
  7124. event.stopPropagation(); // We're just here to prevent the keydown bubbling
  7125. if (event.type === 'keydown') {
  7126. return;
  7127. }
  7128. var isRadioButton = matches$1(menuItem, '[role="menuitemradio"]'); // Show the respective menu
  7129. if (!isRadioButton && [32, 39].includes(event.which)) {
  7130. controls.showMenuPanel.call(_this2, type, true);
  7131. } else {
  7132. var target;
  7133. if (event.which !== 32) {
  7134. if (event.which === 40 || isRadioButton && event.which === 39) {
  7135. target = menuItem.nextElementSibling;
  7136. if (!is$1.element(target)) {
  7137. target = menuItem.parentNode.firstElementChild;
  7138. }
  7139. } else {
  7140. target = menuItem.previousElementSibling;
  7141. if (!is$1.element(target)) {
  7142. target = menuItem.parentNode.lastElementChild;
  7143. }
  7144. }
  7145. setFocus.call(_this2, target, true);
  7146. }
  7147. }
  7148. }, false); // Enter will fire a `click` event but we still need to manage focus
  7149. // So we bind to keyup which fires after and set focus here
  7150. on.call(this, menuItem, 'keyup', function (event) {
  7151. if (event.which !== 13) {
  7152. return;
  7153. }
  7154. controls.focusFirstMenuItem.call(_this2, null, true);
  7155. });
  7156. },
  7157. // Create a settings menu item
  7158. createMenuItem: function createMenuItem(_ref) {
  7159. var _this3 = this;
  7160. var value = _ref.value,
  7161. list = _ref.list,
  7162. type = _ref.type,
  7163. title = _ref.title,
  7164. _ref$badge = _ref.badge,
  7165. badge = _ref$badge === void 0 ? null : _ref$badge,
  7166. _ref$checked = _ref.checked,
  7167. checked = _ref$checked === void 0 ? false : _ref$checked;
  7168. var attributes = getAttributesFromSelector(this.config.selectors.inputs[type]);
  7169. var menuItem = createElement('button', extend(attributes, {
  7170. type: 'button',
  7171. role: 'menuitemradio',
  7172. class: "".concat(this.config.classNames.control, " ").concat(attributes.class ? attributes.class : '').trim(),
  7173. 'aria-checked': checked,
  7174. value: value
  7175. }));
  7176. var flex = createElement('span'); // We have to set as HTML incase of special characters
  7177. flex.innerHTML = title;
  7178. if (is$1.element(badge)) {
  7179. flex.appendChild(badge);
  7180. }
  7181. menuItem.appendChild(flex); // Replicate radio button behaviour
  7182. Object.defineProperty(menuItem, 'checked', {
  7183. enumerable: true,
  7184. get: function get() {
  7185. return menuItem.getAttribute('aria-checked') === 'true';
  7186. },
  7187. set: function set(check) {
  7188. // Ensure exclusivity
  7189. if (check) {
  7190. Array.from(menuItem.parentNode.children).filter(function (node) {
  7191. return matches$1(node, '[role="menuitemradio"]');
  7192. }).forEach(function (node) {
  7193. return node.setAttribute('aria-checked', 'false');
  7194. });
  7195. }
  7196. menuItem.setAttribute('aria-checked', check ? 'true' : 'false');
  7197. }
  7198. });
  7199. this.listeners.bind(menuItem, 'click keyup', function (event) {
  7200. if (is$1.keyboardEvent(event) && event.which !== 32) {
  7201. return;
  7202. }
  7203. event.preventDefault();
  7204. event.stopPropagation();
  7205. menuItem.checked = true;
  7206. switch (type) {
  7207. case 'language':
  7208. _this3.currentTrack = Number(value);
  7209. break;
  7210. case 'quality':
  7211. _this3.quality = value;
  7212. break;
  7213. case 'speed':
  7214. _this3.speed = parseFloat(value);
  7215. break;
  7216. }
  7217. controls.showMenuPanel.call(_this3, 'home', is$1.keyboardEvent(event));
  7218. }, type, false);
  7219. controls.bindMenuItemShortcuts.call(this, menuItem, type);
  7220. list.appendChild(menuItem);
  7221. },
  7222. // Format a time for display
  7223. formatTime: function formatTime$1() {
  7224. var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7225. var inverted = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7226. // Bail if the value isn't a number
  7227. if (!is$1.number(time)) {
  7228. return time;
  7229. } // Always display hours if duration is over an hour
  7230. var forceHours = getHours(this.duration) > 0;
  7231. return formatTime(time, forceHours, inverted);
  7232. },
  7233. // Update the displayed time
  7234. updateTimeDisplay: function updateTimeDisplay() {
  7235. var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7236. var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  7237. var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7238. // Bail if there's no element to display or the value isn't a number
  7239. if (!is$1.element(target) || !is$1.number(time)) {
  7240. return;
  7241. } // eslint-disable-next-line no-param-reassign
  7242. target.innerText = controls.formatTime(time, inverted);
  7243. },
  7244. // Update volume UI and storage
  7245. updateVolume: function updateVolume() {
  7246. if (!this.supported.ui) {
  7247. return;
  7248. } // Update range
  7249. if (is$1.element(this.elements.inputs.volume)) {
  7250. controls.setRange.call(this, this.elements.inputs.volume, this.muted ? 0 : this.volume);
  7251. } // Update mute state
  7252. if (is$1.element(this.elements.buttons.mute)) {
  7253. this.elements.buttons.mute.pressed = this.muted || this.volume === 0;
  7254. }
  7255. },
  7256. // Update seek value and lower fill
  7257. setRange: function setRange(target) {
  7258. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  7259. if (!is$1.element(target)) {
  7260. return;
  7261. } // eslint-disable-next-line
  7262. target.value = value; // Webkit range fill
  7263. controls.updateRangeFill.call(this, target);
  7264. },
  7265. // Update <progress> elements
  7266. updateProgress: function updateProgress(event) {
  7267. var _this4 = this;
  7268. if (!this.supported.ui || !is$1.event(event)) {
  7269. return;
  7270. }
  7271. var value = 0;
  7272. var setProgress = function setProgress(target, input) {
  7273. var val = is$1.number(input) ? input : 0;
  7274. var progress = is$1.element(target) ? target : _this4.elements.display.buffer; // Update value and label
  7275. if (is$1.element(progress)) {
  7276. progress.value = val; // Update text label inside
  7277. var label = progress.getElementsByTagName('span')[0];
  7278. if (is$1.element(label)) {
  7279. label.childNodes[0].nodeValue = val;
  7280. }
  7281. }
  7282. };
  7283. if (event) {
  7284. switch (event.type) {
  7285. // Video playing
  7286. case 'timeupdate':
  7287. case 'seeking':
  7288. case 'seeked':
  7289. value = getPercentage(this.currentTime, this.duration); // Set seek range value only if it's a 'natural' time event
  7290. if (event.type === 'timeupdate') {
  7291. controls.setRange.call(this, this.elements.inputs.seek, value);
  7292. }
  7293. break;
  7294. // Check buffer status
  7295. case 'playing':
  7296. case 'progress':
  7297. setProgress(this.elements.display.buffer, this.buffered * 100);
  7298. break;
  7299. }
  7300. }
  7301. },
  7302. // Webkit polyfill for lower fill range
  7303. updateRangeFill: function updateRangeFill(target) {
  7304. // Get range from event if event passed
  7305. var range = is$1.event(target) ? target.target : target; // Needs to be a valid <input type='range'>
  7306. if (!is$1.element(range) || range.getAttribute('type') !== 'range') {
  7307. return;
  7308. } // Set aria values for https://github.com/sampotts/plyr/issues/905
  7309. if (matches$1(range, this.config.selectors.inputs.seek)) {
  7310. range.setAttribute('aria-valuenow', this.currentTime);
  7311. var currentTime = controls.formatTime(this.currentTime);
  7312. var duration = controls.formatTime(this.duration);
  7313. var format = i18n.get('seekLabel', this.config);
  7314. range.setAttribute('aria-valuetext', format.replace('{currentTime}', currentTime).replace('{duration}', duration));
  7315. } else if (matches$1(range, this.config.selectors.inputs.volume)) {
  7316. var percent = range.value * 100;
  7317. range.setAttribute('aria-valuenow', percent);
  7318. range.setAttribute('aria-valuetext', "".concat(percent.toFixed(1), "%"));
  7319. } else {
  7320. range.setAttribute('aria-valuenow', range.value);
  7321. } // WebKit only
  7322. if (!browser.isWebkit) {
  7323. return;
  7324. } // Set CSS custom property
  7325. range.style.setProperty('--value', "".concat(range.value / range.max * 100, "%"));
  7326. },
  7327. // Update hover tooltip for seeking
  7328. updateSeekTooltip: function updateSeekTooltip(event) {
  7329. var _this5 = this;
  7330. // Bail if setting not true
  7331. if (!this.config.tooltips.seek || !is$1.element(this.elements.inputs.seek) || !is$1.element(this.elements.display.seekTooltip) || this.duration === 0) {
  7332. return;
  7333. }
  7334. var visible = "".concat(this.config.classNames.tooltip, "--visible");
  7335. var toggle = function toggle(show) {
  7336. return toggleClass(_this5.elements.display.seekTooltip, visible, show);
  7337. }; // Hide on touch
  7338. if (this.touch) {
  7339. toggle(false);
  7340. return;
  7341. } // Determine percentage, if already visible
  7342. var percent = 0;
  7343. var clientRect = this.elements.progress.getBoundingClientRect();
  7344. if (is$1.event(event)) {
  7345. percent = 100 / clientRect.width * (event.pageX - clientRect.left);
  7346. } else if (hasClass(this.elements.display.seekTooltip, visible)) {
  7347. percent = parseFloat(this.elements.display.seekTooltip.style.left, 10);
  7348. } else {
  7349. return;
  7350. } // Set bounds
  7351. if (percent < 0) {
  7352. percent = 0;
  7353. } else if (percent > 100) {
  7354. percent = 100;
  7355. } // Display the time a click would seek to
  7356. controls.updateTimeDisplay.call(this, this.elements.display.seekTooltip, this.duration / 100 * percent); // Set position
  7357. this.elements.display.seekTooltip.style.left = "".concat(percent, "%"); // Show/hide the tooltip
  7358. // If the event is a moues in/out and percentage is inside bounds
  7359. if (is$1.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
  7360. toggle(event.type === 'mouseenter');
  7361. }
  7362. },
  7363. // Handle time change event
  7364. timeUpdate: function timeUpdate(event) {
  7365. // Only invert if only one time element is displayed and used for both duration and currentTime
  7366. var invert = !is$1.element(this.elements.display.duration) && this.config.invertTime; // Duration
  7367. controls.updateTimeDisplay.call(this, this.elements.display.currentTime, invert ? this.duration - this.currentTime : this.currentTime, invert); // Ignore updates while seeking
  7368. if (event && event.type === 'timeupdate' && this.media.seeking) {
  7369. return;
  7370. } // Playing progress
  7371. controls.updateProgress.call(this, event);
  7372. },
  7373. // Show the duration on metadataloaded or durationchange events
  7374. durationUpdate: function durationUpdate() {
  7375. // Bail if no UI or durationchange event triggered after playing/seek when invertTime is false
  7376. if (!this.supported.ui || !this.config.invertTime && this.currentTime) {
  7377. return;
  7378. } // If duration is the 2**32 (shaka), Infinity (HLS), DASH-IF (Number.MAX_SAFE_INTEGER || Number.MAX_VALUE) indicating live we hide the currentTime and progressbar.
  7379. // https://github.com/video-dev/hls.js/blob/5820d29d3c4c8a46e8b75f1e3afa3e68c1a9a2db/src/controller/buffer-controller.js#L415
  7380. // https://github.com/google/shaka-player/blob/4d889054631f4e1cf0fbd80ddd2b71887c02e232/lib/media/streaming_engine.js#L1062
  7381. // https://github.com/Dash-Industry-Forum/dash.js/blob/69859f51b969645b234666800d4cb596d89c602d/src/dash/models/DashManifestModel.js#L338
  7382. if (this.duration >= Math.pow(2, 32)) {
  7383. toggleHidden(this.elements.display.currentTime, true);
  7384. toggleHidden(this.elements.progress, true);
  7385. return;
  7386. } // Update ARIA values
  7387. if (is$1.element(this.elements.inputs.seek)) {
  7388. this.elements.inputs.seek.setAttribute('aria-valuemax', this.duration);
  7389. } // If there's a spot to display duration
  7390. var hasDuration = is$1.element(this.elements.display.duration); // If there's only one time display, display duration there
  7391. if (!hasDuration && this.config.displayDuration && this.paused) {
  7392. controls.updateTimeDisplay.call(this, this.elements.display.currentTime, this.duration);
  7393. } // If there's a duration element, update content
  7394. if (hasDuration) {
  7395. controls.updateTimeDisplay.call(this, this.elements.display.duration, this.duration);
  7396. } // Update the tooltip (if visible)
  7397. controls.updateSeekTooltip.call(this);
  7398. },
  7399. // Hide/show a tab
  7400. toggleMenuButton: function toggleMenuButton(setting, toggle) {
  7401. toggleHidden(this.elements.settings.buttons[setting], !toggle);
  7402. },
  7403. // Update the selected setting
  7404. updateSetting: function updateSetting(setting, container, input) {
  7405. var pane = this.elements.settings.panels[setting];
  7406. var value = null;
  7407. var list = container;
  7408. if (setting === 'captions') {
  7409. value = this.currentTrack;
  7410. } else {
  7411. value = !is$1.empty(input) ? input : this[setting]; // Get default
  7412. if (is$1.empty(value)) {
  7413. value = this.config[setting].default;
  7414. } // Unsupported value
  7415. if (!is$1.empty(this.options[setting]) && !this.options[setting].includes(value)) {
  7416. this.debug.warn("Unsupported value of '".concat(value, "' for ").concat(setting));
  7417. return;
  7418. } // Disabled value
  7419. if (!this.config[setting].options.includes(value)) {
  7420. this.debug.warn("Disabled value of '".concat(value, "' for ").concat(setting));
  7421. return;
  7422. }
  7423. } // Get the list if we need to
  7424. if (!is$1.element(list)) {
  7425. list = pane && pane.querySelector('[role="menu"]');
  7426. } // If there's no list it means it's not been rendered...
  7427. if (!is$1.element(list)) {
  7428. return;
  7429. } // Update the label
  7430. var label = this.elements.settings.buttons[setting].querySelector(".".concat(this.config.classNames.menu.value));
  7431. label.innerHTML = controls.getLabel.call(this, setting, value); // Find the radio option and check it
  7432. var target = list && list.querySelector("[value=\"".concat(value, "\"]"));
  7433. if (is$1.element(target)) {
  7434. target.checked = true;
  7435. }
  7436. },
  7437. // Translate a value into a nice label
  7438. getLabel: function getLabel(setting, value) {
  7439. switch (setting) {
  7440. case 'speed':
  7441. return value === 1 ? i18n.get('normal', this.config) : "".concat(value, "&times;");
  7442. case 'quality':
  7443. if (is$1.number(value)) {
  7444. var label = i18n.get("qualityLabel.".concat(value), this.config);
  7445. if (!label.length) {
  7446. return "".concat(value, "p");
  7447. }
  7448. return label;
  7449. }
  7450. return toTitleCase(value);
  7451. case 'captions':
  7452. return captions.getLabel.call(this);
  7453. default:
  7454. return null;
  7455. }
  7456. },
  7457. // Set the quality menu
  7458. setQualityMenu: function setQualityMenu(options) {
  7459. var _this6 = this;
  7460. // Menu required
  7461. if (!is$1.element(this.elements.settings.panels.quality)) {
  7462. return;
  7463. }
  7464. var type = 'quality';
  7465. var list = this.elements.settings.panels.quality.querySelector('[role="menu"]'); // Set options if passed and filter based on uniqueness and config
  7466. if (is$1.array(options)) {
  7467. this.options.quality = dedupe(options).filter(function (quality) {
  7468. return _this6.config.quality.options.includes(quality);
  7469. });
  7470. } // Toggle the pane and tab
  7471. var toggle = !is$1.empty(this.options.quality) && this.options.quality.length > 1;
  7472. controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
  7473. emptyElement(list); // Check if we need to toggle the parent
  7474. controls.checkMenu.call(this); // If we're hiding, nothing more to do
  7475. if (!toggle) {
  7476. return;
  7477. } // Get the badge HTML for HD, 4K etc
  7478. var getBadge = function getBadge(quality) {
  7479. var label = i18n.get("qualityBadge.".concat(quality), _this6.config);
  7480. if (!label.length) {
  7481. return null;
  7482. }
  7483. return controls.createBadge.call(_this6, label);
  7484. }; // Sort options by the config and then render options
  7485. this.options.quality.sort(function (a, b) {
  7486. var sorting = _this6.config.quality.options;
  7487. return sorting.indexOf(a) > sorting.indexOf(b) ? 1 : -1;
  7488. }).forEach(function (quality) {
  7489. controls.createMenuItem.call(_this6, {
  7490. value: quality,
  7491. list: list,
  7492. type: type,
  7493. title: controls.getLabel.call(_this6, 'quality', quality),
  7494. badge: getBadge(quality)
  7495. });
  7496. });
  7497. controls.updateSetting.call(this, type, list);
  7498. },
  7499. // Set the looping options
  7500. /* setLoopMenu() {
  7501. // Menu required
  7502. if (!is.element(this.elements.settings.panels.loop)) {
  7503. return;
  7504. }
  7505. const options = ['start', 'end', 'all', 'reset'];
  7506. const list = this.elements.settings.panels.loop.querySelector('[role="menu"]');
  7507. // Show the pane and tab
  7508. toggleHidden(this.elements.settings.buttons.loop, false);
  7509. toggleHidden(this.elements.settings.panels.loop, false);
  7510. // Toggle the pane and tab
  7511. const toggle = !is.empty(this.loop.options);
  7512. controls.toggleMenuButton.call(this, 'loop', toggle);
  7513. // Empty the menu
  7514. emptyElement(list);
  7515. options.forEach(option => {
  7516. const item = createElement('li');
  7517. const button = createElement(
  7518. 'button',
  7519. extend(getAttributesFromSelector(this.config.selectors.buttons.loop), {
  7520. type: 'button',
  7521. class: this.config.classNames.control,
  7522. 'data-plyr-loop-action': option,
  7523. }),
  7524. i18n.get(option, this.config)
  7525. );
  7526. if (['start', 'end'].includes(option)) {
  7527. const badge = controls.createBadge.call(this, '00:00');
  7528. button.appendChild(badge);
  7529. }
  7530. item.appendChild(button);
  7531. list.appendChild(item);
  7532. });
  7533. }, */
  7534. // Get current selected caption language
  7535. // TODO: rework this to user the getter in the API?
  7536. // Set a list of available captions languages
  7537. setCaptionsMenu: function setCaptionsMenu() {
  7538. var _this7 = this;
  7539. // Menu required
  7540. if (!is$1.element(this.elements.settings.panels.captions)) {
  7541. return;
  7542. } // TODO: Captions or language? Currently it's mixed
  7543. var type = 'captions';
  7544. var list = this.elements.settings.panels.captions.querySelector('[role="menucaptions"]');
  7545. var tracks = captions.getTracks.call(this);
  7546. var toggle = Boolean(tracks.length); // Toggle the pane and tab
  7547. controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
  7548. emptyElement(list); // Check if we need to toggle the parent
  7549. controls.checkMenu.call(this); // If there's no captions, bail
  7550. if (!toggle) {
  7551. return;
  7552. } // Generate options data
  7553. var options = tracks.map(function (track, value) {
  7554. return {
  7555. value: value,
  7556. checked: _this7.captions.toggled && _this7.currentTrack === value,
  7557. title: captions.getLabel.call(_this7, track),
  7558. badge: track.language && controls.createBadge.call(_this7, track.language.toUpperCase()),
  7559. list: list,
  7560. type: 'language'
  7561. };
  7562. }); // Add the "Disabled" option to turn off captions
  7563. options.unshift({
  7564. value: -1,
  7565. checked: !this.captions.toggled,
  7566. title: i18n.get('disabled', this.config),
  7567. list: list,
  7568. type: 'language'
  7569. }); // Generate options
  7570. options.forEach(controls.createMenuItem.bind(this));
  7571. controls.updateSetting.call(this, type, list);
  7572. },
  7573. // Set a list of available captions languages
  7574. setSpeedMenu: function setSpeedMenu() {
  7575. var _this8 = this;
  7576. // Menu required
  7577. if (!is$1.element(this.elements.settings.panels.speed)) {
  7578. return;
  7579. }
  7580. var type = 'speed';
  7581. var list = this.elements.settings.panels.speed.querySelector('[role="menu"]'); // Filter out invalid speeds
  7582. this.options.speed = this.options.speed.filter(function (o) {
  7583. return o >= _this8.minimumSpeed && o <= _this8.maximumSpeed;
  7584. }); // Toggle the pane and tab
  7585. var toggle = !is$1.empty(this.options.speed) && this.options.speed.length > 1;
  7586. controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
  7587. emptyElement(list); // Check if we need to toggle the parent
  7588. controls.checkMenu.call(this); // If we're hiding, nothing more to do
  7589. if (!toggle) {
  7590. return;
  7591. } // Create items
  7592. this.options.speed.forEach(function (speed) {
  7593. controls.createMenuItem.call(_this8, {
  7594. value: speed,
  7595. list: list,
  7596. type: type,
  7597. title: controls.getLabel.call(_this8, 'speed', speed)
  7598. });
  7599. });
  7600. controls.updateSetting.call(this, type, list);
  7601. },
  7602. // Check if we need to hide/show the settings menu
  7603. checkMenu: function checkMenu() {
  7604. var buttons = this.elements.settings.buttons;
  7605. var visible = !is$1.empty(buttons) && Object.values(buttons).some(function (button) {
  7606. return !button.hidden;
  7607. });
  7608. toggleHidden(this.elements.settings.menu, !visible);
  7609. },
  7610. // Focus the first menu item in a given (or visible) menu
  7611. focusFirstMenuItem: function focusFirstMenuItem(pane) {
  7612. var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7613. if (this.elements.settings.popup.hidden) {
  7614. return;
  7615. }
  7616. var target = pane;
  7617. if (!is$1.element(target)) {
  7618. target = Object.values(this.elements.settings.panels).find(function (p) {
  7619. return !p.hidden;
  7620. });
  7621. }
  7622. var firstItem = target.querySelector('[role^="menuitem"]');
  7623. setFocus.call(this, firstItem, tabFocus);
  7624. },
  7625. // Show/hide menu
  7626. toggleMenu: function toggleMenu(input) {
  7627. var popup = this.elements.settings.popup;
  7628. var button = this.elements.buttons.settings; // Menu and button are required
  7629. if (!is$1.element(popup) || !is$1.element(button)) {
  7630. return;
  7631. } // True toggle by default
  7632. var hidden = popup.hidden;
  7633. var show = hidden;
  7634. if (is$1.boolean(input)) {
  7635. show = input;
  7636. } else if (is$1.keyboardEvent(input) && input.which === 27) {
  7637. show = false;
  7638. } else if (is$1.event(input)) {
  7639. // If Plyr is in a shadowDOM, the event target is set to the component, instead of the
  7640. // Element in the shadowDOM. The path, if available, is complete.
  7641. var target = is$1.function(input.composedPath) ? input.composedPath()[0] : input.target;
  7642. var isMenuItem = popup.contains(target); // If the click was inside the menu or if the click
  7643. // wasn't the button or menu item and we're trying to
  7644. // show the menu (a doc click shouldn't show the menu)
  7645. if (isMenuItem || !isMenuItem && input.target !== button && show) {
  7646. return;
  7647. }
  7648. } // Set button attributes
  7649. button.setAttribute('aria-expanded', show); // Show the actual popup
  7650. toggleHidden(popup, !show); // Add class hook
  7651. toggleClass(this.elements.container, this.config.classNames.menu.open, show); // Focus the first item if key interaction
  7652. if (show && is$1.keyboardEvent(input)) {
  7653. controls.focusFirstMenuItem.call(this, null, true);
  7654. } else if (!show && !hidden) {
  7655. // If closing, re-focus the button
  7656. setFocus.call(this, button, is$1.keyboardEvent(input));
  7657. }
  7658. },
  7659. // Get the natural size of a menu panel
  7660. getMenuSize: function getMenuSize(tab) {
  7661. var clone = tab.cloneNode(true);
  7662. clone.style.position = 'absolute';
  7663. clone.style.opacity = 0;
  7664. clone.removeAttribute('hidden'); // Append to parent so we get the "real" size
  7665. tab.parentNode.appendChild(clone); // Get the sizes before we remove
  7666. var width = clone.scrollWidth;
  7667. var height = clone.scrollHeight; // Remove from the DOM
  7668. removeElement(clone);
  7669. return {
  7670. width: width,
  7671. height: height
  7672. };
  7673. },
  7674. // Show a panel in the menu
  7675. showMenuPanel: function showMenuPanel() {
  7676. var _this9 = this;
  7677. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  7678. var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7679. var target = this.elements.container.querySelector("#plyr-settings-".concat(this.id, "-").concat(type)); // Nothing to show, bail
  7680. if (!is$1.element(target)) {
  7681. return;
  7682. } // Hide all other panels
  7683. var container = target.parentNode;
  7684. var current = Array.from(container.children).find(function (node) {
  7685. return !node.hidden;
  7686. }); // If we can do fancy animations, we'll animate the height/width
  7687. if (support.transitions && !support.reducedMotion) {
  7688. // Set the current width as a base
  7689. container.style.width = "".concat(current.scrollWidth, "px");
  7690. container.style.height = "".concat(current.scrollHeight, "px"); // Get potential sizes
  7691. var size = controls.getMenuSize.call(this, target); // Restore auto height/width
  7692. var restore = function restore(event) {
  7693. // We're only bothered about height and width on the container
  7694. if (event.target !== container || !['width', 'height'].includes(event.propertyName)) {
  7695. return;
  7696. } // Revert back to auto
  7697. container.style.width = '';
  7698. container.style.height = ''; // Only listen once
  7699. off.call(_this9, container, transitionEndEvent, restore);
  7700. }; // Listen for the transition finishing and restore auto height/width
  7701. on.call(this, container, transitionEndEvent, restore); // Set dimensions to target
  7702. container.style.width = "".concat(size.width, "px");
  7703. container.style.height = "".concat(size.height, "px");
  7704. } // Set attributes on current tab
  7705. toggleHidden(current, true); // Set attributes on target
  7706. toggleHidden(target, false); // Focus the first item
  7707. controls.focusFirstMenuItem.call(this, target, tabFocus);
  7708. },
  7709. // Set the download URL
  7710. setDownloadUrl: function setDownloadUrl() {
  7711. var button = this.elements.buttons.download; // Bail if no button
  7712. if (!is$1.element(button)) {
  7713. return;
  7714. } // Set attribute
  7715. button.setAttribute('href', this.download);
  7716. },
  7717. // Build the default HTML
  7718. create: function create(data) {
  7719. var _this10 = this;
  7720. var bindMenuItemShortcuts = controls.bindMenuItemShortcuts,
  7721. createButton = controls.createButton,
  7722. createProgress = controls.createProgress,
  7723. createRange = controls.createRange,
  7724. createTime = controls.createTime,
  7725. setQualityMenu = controls.setQualityMenu,
  7726. setSpeedMenu = controls.setSpeedMenu,
  7727. showMenuPanel = controls.showMenuPanel;
  7728. this.elements.controls = null; // Larger overlaid play button
  7729. if (is$1.array(this.config.controls) && this.config.controls.includes('play-large')) {
  7730. this.elements.container.appendChild(createButton.call(this, 'play-large'));
  7731. } // Create the container
  7732. var container = createElement('div', getAttributesFromSelector(this.config.selectors.controls.wrapper));
  7733. this.elements.controls = container; // Default item attributes
  7734. var defaultAttributes = {
  7735. class: 'plyr__controls__item'
  7736. }; // Loop through controls in order
  7737. dedupe(is$1.array(this.config.controls) ? this.config.controls : []).forEach(function (control) {
  7738. // Restart button
  7739. if (control === 'restart') {
  7740. container.appendChild(createButton.call(_this10, 'restart', defaultAttributes));
  7741. } // Rewind button
  7742. if (control === 'rewind') {
  7743. container.appendChild(createButton.call(_this10, 'rewind', defaultAttributes));
  7744. } // Play/Pause button
  7745. if (control === 'play') {
  7746. container.appendChild(createButton.call(_this10, 'play', defaultAttributes));
  7747. } // Fast forward button
  7748. if (control === 'fast-forward') {
  7749. container.appendChild(createButton.call(_this10, 'fast-forward', defaultAttributes));
  7750. } // Progress
  7751. if (control === 'progress') {
  7752. var progressContainer = createElement('div', {
  7753. class: "".concat(defaultAttributes.class, " plyr__progress__container")
  7754. });
  7755. var progress = createElement('div', getAttributesFromSelector(_this10.config.selectors.progress)); // Seek range slider
  7756. progress.appendChild(createRange.call(_this10, 'seek', {
  7757. id: "plyr-seek-".concat(data.id)
  7758. })); // Buffer progress
  7759. progress.appendChild(createProgress.call(_this10, 'buffer')); // TODO: Add loop display indicator
  7760. // Seek tooltip
  7761. if (_this10.config.tooltips.seek) {
  7762. var tooltip = createElement('span', {
  7763. class: _this10.config.classNames.tooltip
  7764. }, '00:00');
  7765. progress.appendChild(tooltip);
  7766. _this10.elements.display.seekTooltip = tooltip;
  7767. }
  7768. _this10.elements.progress = progress;
  7769. progressContainer.appendChild(_this10.elements.progress);
  7770. container.appendChild(progressContainer);
  7771. } // Media current time display
  7772. if (control === 'current-time') {
  7773. container.appendChild(createTime.call(_this10, 'currentTime', defaultAttributes));
  7774. } // Media duration display
  7775. if (control === 'duration') {
  7776. container.appendChild(createTime.call(_this10, 'duration', defaultAttributes));
  7777. } // Volume controls
  7778. if (control === 'mute' || control === 'volume') {
  7779. var volume = _this10.elements.volume; // Create the volume container if needed
  7780. if (!is$1.element(volume) || !container.contains(volume)) {
  7781. volume = createElement('div', extend({}, defaultAttributes, {
  7782. class: "".concat(defaultAttributes.class, " plyr__volume").trim()
  7783. }));
  7784. _this10.elements.volume = volume;
  7785. container.appendChild(volume);
  7786. } // Toggle mute button
  7787. if (control === 'mute') {
  7788. volume.appendChild(createButton.call(_this10, 'mute'));
  7789. } // Volume range control
  7790. // Ignored on iOS as it's handled globally
  7791. // https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
  7792. if (control === 'volume' && !browser.isIos) {
  7793. // Set the attributes
  7794. var attributes = {
  7795. max: 1,
  7796. step: 0.05,
  7797. value: _this10.config.volume
  7798. }; // Create the volume range slider
  7799. volume.appendChild(createRange.call(_this10, 'volume', extend(attributes, {
  7800. id: "plyr-volume-".concat(data.id)
  7801. })));
  7802. }
  7803. } // Toggle captions button
  7804. if (control === 'captions') {
  7805. container.appendChild(createButton.call(_this10, 'captions', defaultAttributes));
  7806. } // Settings button / menu
  7807. if (control === 'settings' && !is$1.empty(_this10.config.settings)) {
  7808. var wrapper = createElement('div', extend({}, defaultAttributes, {
  7809. class: "".concat(defaultAttributes.class, " plyr__menu").trim(),
  7810. hidden: ''
  7811. }));
  7812. wrapper.appendChild(createButton.call(_this10, 'settings', {
  7813. 'aria-haspopup': true,
  7814. 'aria-controls': "plyr-settings-".concat(data.id),
  7815. 'aria-expanded': false
  7816. }));
  7817. var popup = createElement('div', {
  7818. class: 'plyr__menu__container',
  7819. id: "plyr-settings-".concat(data.id),
  7820. hidden: ''
  7821. });
  7822. var inner = createElement('div');
  7823. var home = createElement('div', {
  7824. id: "plyr-settings-".concat(data.id, "-home")
  7825. }); // Create the menu
  7826. var menu = createElement('div', {
  7827. role: 'menu'
  7828. });
  7829. home.appendChild(menu);
  7830. inner.appendChild(home);
  7831. _this10.elements.settings.panels.home = home; // Build the menu items
  7832. _this10.config.settings.forEach(function (type) {
  7833. // TODO: bundle this with the createMenuItem helper and bindings
  7834. var menuItem = createElement('button', extend(getAttributesFromSelector(_this10.config.selectors.buttons.settings), {
  7835. type: 'button',
  7836. class: "".concat(_this10.config.classNames.control, " ").concat(_this10.config.classNames.control, "--forward"),
  7837. role: 'menuitem',
  7838. 'aria-haspopup': true,
  7839. hidden: ''
  7840. })); // Bind menu shortcuts for keyboard users
  7841. bindMenuItemShortcuts.call(_this10, menuItem, type); // Show menu on click
  7842. on.call(_this10, menuItem, 'click', function () {
  7843. showMenuPanel.call(_this10, type, false);
  7844. });
  7845. var flex = createElement('span', null, i18n.get(type, _this10.config));
  7846. var value = createElement('span', {
  7847. class: _this10.config.classNames.menu.value
  7848. }); // Speed contains HTML entities
  7849. value.innerHTML = data[type];
  7850. flex.appendChild(value);
  7851. menuItem.appendChild(flex);
  7852. menu.appendChild(menuItem); // Build the panes
  7853. var pane = createElement('div', {
  7854. id: "plyr-settings-".concat(data.id, "-").concat(type),
  7855. hidden: ''
  7856. }); // Back button
  7857. var backButton = createElement('button', {
  7858. type: 'button',
  7859. class: "".concat(_this10.config.classNames.control, " ").concat(_this10.config.classNames.control, "--back")
  7860. }); // Visible label
  7861. backButton.appendChild(createElement('span', {
  7862. 'aria-hidden': true
  7863. }, i18n.get(type, _this10.config))); // Screen reader label
  7864. backButton.appendChild(createElement('span', {
  7865. class: _this10.config.classNames.hidden
  7866. }, i18n.get('menuBack', _this10.config))); // Go back via keyboard
  7867. on.call(_this10, pane, 'keydown', function (event) {
  7868. // We only care about <-
  7869. if (event.which !== 37) {
  7870. return;
  7871. } // Prevent seek
  7872. event.preventDefault();
  7873. event.stopPropagation(); // Show the respective menu
  7874. showMenuPanel.call(_this10, 'home', true);
  7875. }, false); // Go back via button click
  7876. on.call(_this10, backButton, 'click', function () {
  7877. showMenuPanel.call(_this10, 'home', false);
  7878. }); // Add to pane
  7879. pane.appendChild(backButton); // Menu
  7880. pane.appendChild(createElement('div', {
  7881. role: 'menu'
  7882. })); // Menu Captions
  7883. pane.appendChild(createElement('div', {
  7884. role: 'menucaptions'
  7885. }));
  7886. inner.appendChild(pane);
  7887. _this10.elements.settings.buttons[type] = menuItem;
  7888. _this10.elements.settings.panels[type] = pane;
  7889. });
  7890. popup.appendChild(inner);
  7891. wrapper.appendChild(popup);
  7892. container.appendChild(wrapper);
  7893. _this10.elements.settings.popup = popup;
  7894. _this10.elements.settings.menu = wrapper;
  7895. } // Picture in picture button
  7896. if (control === 'pip' && support.pip) {
  7897. container.appendChild(createButton.call(_this10, 'pip', defaultAttributes));
  7898. } // Airplay button
  7899. if (control === 'airplay' && support.airplay) {
  7900. container.appendChild(createButton.call(_this10, 'airplay', defaultAttributes));
  7901. } // Download button
  7902. if (control === 'download') {
  7903. var _attributes = extend({}, defaultAttributes, {
  7904. element: 'a',
  7905. href: _this10.download,
  7906. target: '_blank'
  7907. }); // Set download attribute for HTML5 only
  7908. if (_this10.isHTML5) {
  7909. _attributes.download = '';
  7910. }
  7911. var download = _this10.config.urls.download;
  7912. if (!is$1.url(download) && _this10.isEmbed) {
  7913. extend(_attributes, {
  7914. icon: "logo-".concat(_this10.provider),
  7915. label: _this10.provider
  7916. });
  7917. }
  7918. container.appendChild(createButton.call(_this10, 'download', _attributes));
  7919. } // Toggle fullscreen button
  7920. if (control === 'fullscreen') {
  7921. container.appendChild(createButton.call(_this10, 'fullscreen', defaultAttributes));
  7922. }
  7923. }); // Set available quality levels
  7924. if (this.isHTML5) {
  7925. setQualityMenu.call(this, html5.getQualityOptions.call(this));
  7926. }
  7927. setSpeedMenu.call(this);
  7928. return container;
  7929. },
  7930. // Insert controls
  7931. inject: function inject() {
  7932. var _this11 = this;
  7933. // Sprite
  7934. if (this.config.loadSprite) {
  7935. var icon = controls.getIconUrl.call(this); // Only load external sprite using AJAX
  7936. if (icon.cors) {
  7937. loadSprite(icon.url, 'sprite-plyr');
  7938. }
  7939. } // Create a unique ID
  7940. this.id = Math.floor(Math.random() * 10000); // Null by default
  7941. var container = null;
  7942. this.elements.controls = null; // Set template properties
  7943. var props = {
  7944. id: this.id,
  7945. seektime: this.config.seekTime,
  7946. title: this.config.title
  7947. };
  7948. var update = true; // If function, run it and use output
  7949. if (is$1.function(this.config.controls)) {
  7950. this.config.controls = this.config.controls.call(this, props);
  7951. } // Convert falsy controls to empty array (primarily for empty strings)
  7952. if (!this.config.controls) {
  7953. this.config.controls = [];
  7954. }
  7955. if (is$1.element(this.config.controls) || is$1.string(this.config.controls)) {
  7956. // HTMLElement or Non-empty string passed as the option
  7957. container = this.config.controls;
  7958. } else {
  7959. // Create controls
  7960. container = controls.create.call(this, {
  7961. id: this.id,
  7962. seektime: this.config.seekTime,
  7963. speed: this.speed,
  7964. quality: this.quality,
  7965. captions: captions.getLabel.call(this) // TODO: Looping
  7966. // loop: 'None',
  7967. });
  7968. update = false;
  7969. } // Replace props with their value
  7970. var replace = function replace(input) {
  7971. var result = input;
  7972. Object.entries(props).forEach(function (_ref2) {
  7973. var _ref3 = _slicedToArray(_ref2, 2),
  7974. key = _ref3[0],
  7975. value = _ref3[1];
  7976. result = replaceAll(result, "{".concat(key, "}"), value);
  7977. });
  7978. return result;
  7979. }; // Update markup
  7980. if (update) {
  7981. if (is$1.string(this.config.controls)) {
  7982. container = replace(container);
  7983. }
  7984. } // Controls container
  7985. var target; // Inject to custom location
  7986. if (is$1.string(this.config.selectors.controls.container)) {
  7987. target = document.querySelector(this.config.selectors.controls.container);
  7988. } // Inject into the container by default
  7989. if (!is$1.element(target)) {
  7990. target = this.elements.container;
  7991. } // Inject controls HTML (needs to be before captions, hence "afterbegin")
  7992. var insertMethod = is$1.element(container) ? 'insertAdjacentElement' : 'insertAdjacentHTML';
  7993. target[insertMethod]('afterbegin', container); // Find the elements if need be
  7994. if (!is$1.element(this.elements.controls)) {
  7995. controls.findElements.call(this);
  7996. } // Add pressed property to buttons
  7997. if (!is$1.empty(this.elements.buttons)) {
  7998. var addProperty = function addProperty(button) {
  7999. var className = _this11.config.classNames.controlPressed;
  8000. Object.defineProperty(button, 'pressed', {
  8001. enumerable: true,
  8002. get: function get() {
  8003. return hasClass(button, className);
  8004. },
  8005. set: function set() {
  8006. var pressed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8007. toggleClass(button, className, pressed);
  8008. }
  8009. });
  8010. }; // Toggle classname when pressed property is set
  8011. Object.values(this.elements.buttons).filter(Boolean).forEach(function (button) {
  8012. if (is$1.array(button) || is$1.nodeList(button)) {
  8013. Array.from(button).filter(Boolean).forEach(addProperty);
  8014. } else {
  8015. addProperty(button);
  8016. }
  8017. });
  8018. } // Edge sometimes doesn't finish the paint so force a repaint
  8019. if (browser.isEdge) {
  8020. repaint(target);
  8021. } // Setup tooltips
  8022. if (this.config.tooltips.controls) {
  8023. var _this$config = this.config,
  8024. classNames = _this$config.classNames,
  8025. selectors = _this$config.selectors;
  8026. var selector = "".concat(selectors.controls.wrapper, " ").concat(selectors.labels, " .").concat(classNames.hidden);
  8027. var labels = getElements.call(this, selector);
  8028. Array.from(labels).forEach(function (label) {
  8029. toggleClass(label, _this11.config.classNames.hidden, false);
  8030. toggleClass(label, _this11.config.classNames.tooltip, true);
  8031. });
  8032. }
  8033. }
  8034. };
  8035. /**
  8036. * Parse a string to a URL object
  8037. * @param {String} input - the URL to be parsed
  8038. * @param {Boolean} safe - failsafe parsing
  8039. */
  8040. function parseUrl(input) {
  8041. var safe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8042. var url = input;
  8043. if (safe) {
  8044. var parser = document.createElement('a');
  8045. parser.href = url;
  8046. url = parser.href;
  8047. }
  8048. try {
  8049. return new URL(url);
  8050. } catch (e) {
  8051. return null;
  8052. }
  8053. } // Convert object to URLSearchParams
  8054. function buildUrlParams(input) {
  8055. var params = new URLSearchParams();
  8056. if (is$1.object(input)) {
  8057. Object.entries(input).forEach(function (_ref) {
  8058. var _ref2 = _slicedToArray(_ref, 2),
  8059. key = _ref2[0],
  8060. value = _ref2[1];
  8061. params.set(key, value);
  8062. });
  8063. }
  8064. return params;
  8065. }
  8066. var captions = {
  8067. // Setup captions
  8068. setup: function setup() {
  8069. // Requires UI support
  8070. if (!this.supported.ui) {
  8071. return;
  8072. } // Only Vimeo and HTML5 video supported at this point
  8073. if (!this.isVideo || this.isYouTube || this.isHTML5 && !support.textTracks) {
  8074. // Clear menu and hide
  8075. if (is$1.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
  8076. controls.setCaptionsMenu.call(this);
  8077. }
  8078. return;
  8079. } // Inject the container
  8080. if (!is$1.element(this.elements.captions)) {
  8081. this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
  8082. insertAfter(this.elements.captions, this.elements.wrapper);
  8083. } // Fix IE captions if CORS is used
  8084. // Fetch captions and inject as blobs instead (data URIs not supported!)
  8085. if (browser.isIE && window.URL) {
  8086. var elements = this.media.querySelectorAll('track');
  8087. Array.from(elements).forEach(function (track) {
  8088. var src = track.getAttribute('src');
  8089. var url = parseUrl(src);
  8090. if (url !== null && url.hostname !== window.location.href.hostname && ['http:', 'https:'].includes(url.protocol)) {
  8091. fetch(src, 'blob').then(function (blob) {
  8092. track.setAttribute('src', window.URL.createObjectURL(blob));
  8093. }).catch(function () {
  8094. removeElement(track);
  8095. });
  8096. }
  8097. });
  8098. } // Get and set initial data
  8099. // The "preferred" options are not realized unless / until the wanted language has a match
  8100. // * languages: Array of user's browser languages.
  8101. // * language: The language preferred by user settings or config
  8102. // * active: The state preferred by user settings or config
  8103. // * toggled: The real captions state
  8104. var browserLanguages = navigator.languages || [navigator.language || navigator.userLanguage || 'en'];
  8105. var languages = dedupe(browserLanguages.map(function (language) {
  8106. return language.split('-')[0];
  8107. }));
  8108. var language = (this.storage.get('language') || this.config.captions.language || 'auto').toLowerCase(); // Use first browser language when language is 'auto'
  8109. if (language === 'auto') {
  8110. var _languages = _slicedToArray(languages, 1);
  8111. language = _languages[0];
  8112. }
  8113. var active = this.storage.get('captions');
  8114. if (!is$1.boolean(active)) {
  8115. active = this.config.captions.active;
  8116. }
  8117. Object.assign(this.captions, {
  8118. toggled: false,
  8119. active: active,
  8120. language: language,
  8121. languages: languages
  8122. }); // Watch changes to textTracks and update captions menu
  8123. if (this.isHTML5) {
  8124. var trackEvents = this.config.captions.update ? 'addtrack removetrack' : 'removetrack';
  8125. on.call(this, this.media.textTracks, trackEvents, captions.update.bind(this));
  8126. } // Update available languages in list next tick (the event must not be triggered before the listeners)
  8127. setTimeout(captions.update.bind(this), 0);
  8128. },
  8129. // Update available language options in settings based on tracks
  8130. update: function update() {
  8131. var _this = this;
  8132. var tracks = captions.getTracks.call(this, true); // Get the wanted language
  8133. var _this$captions = this.captions,
  8134. active = _this$captions.active,
  8135. language = _this$captions.language,
  8136. meta = _this$captions.meta,
  8137. currentTrackNode = _this$captions.currentTrackNode;
  8138. var languageExists = Boolean(tracks.find(function (track) {
  8139. return track.language === language;
  8140. })); // Handle tracks (add event listener and "pseudo"-default)
  8141. if (this.isHTML5 && this.isVideo) {
  8142. tracks.filter(function (track) {
  8143. return !meta.get(track);
  8144. }).forEach(function (track) {
  8145. _this.debug.log('Track added', track); // Attempt to store if the original dom element was "default"
  8146. meta.set(track, {
  8147. default: track.mode === 'showing'
  8148. }); // Turn off native caption rendering to avoid double captions
  8149. // Note: mode='hidden' forces a track to download. To ensure every track
  8150. // isn't downloaded at once, only 'showing' tracks should be reassigned
  8151. // eslint-disable-next-line no-param-reassign
  8152. if (track.mode === 'showing') {
  8153. // eslint-disable-next-line no-param-reassign
  8154. track.mode = 'hidden';
  8155. } // Add event listener for cue changes
  8156. on.call(_this, track, 'cuechange', function () {
  8157. return captions.updateCues.call(_this);
  8158. });
  8159. });
  8160. } // Update language first time it matches, or if the previous matching track was removed
  8161. if (languageExists && this.language !== language || !tracks.includes(currentTrackNode)) {
  8162. captions.setLanguage.call(this, language);
  8163. captions.toggle.call(this, active && languageExists);
  8164. } // Enable or disable captions based on track length
  8165. toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is$1.empty(tracks)); // Update available languages in list
  8166. if (is$1.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
  8167. controls.setCaptionsMenu.call(this);
  8168. }
  8169. },
  8170. // Toggle captions display
  8171. // Used internally for the toggleCaptions method, with the passive option forced to false
  8172. toggle: function toggle(input) {
  8173. var _this2 = this;
  8174. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8175. // If there's no full support
  8176. if (!this.supported.ui) {
  8177. return;
  8178. }
  8179. var toggled = this.captions.toggled; // Current state
  8180. var activeClass = this.config.classNames.captions.active; // Get the next state
  8181. // If the method is called without parameter, toggle based on current value
  8182. var active = is$1.nullOrUndefined(input) ? !toggled : input; // Update state and trigger event
  8183. if (active !== toggled) {
  8184. // When passive, don't override user preferences
  8185. if (!passive) {
  8186. this.captions.active = active;
  8187. this.storage.set({
  8188. captions: active
  8189. });
  8190. } // Force language if the call isn't passive and there is no matching language to toggle to
  8191. if (!this.language && active && !passive) {
  8192. var tracks = captions.getTracks.call(this);
  8193. var track = captions.findTrack.call(this, [this.captions.language].concat(_toConsumableArray(this.captions.languages)), true); // Override user preferences to avoid switching languages if a matching track is added
  8194. this.captions.language = track.language; // Set caption, but don't store in localStorage as user preference
  8195. captions.set.call(this, tracks.indexOf(track));
  8196. return;
  8197. } // Toggle button if it's enabled
  8198. if (this.elements.buttons.captions) {
  8199. this.elements.buttons.captions.pressed = active;
  8200. } // Add class hook
  8201. toggleClass(this.elements.container, activeClass, active);
  8202. this.captions.toggled = active; // Update settings menu
  8203. controls.updateSetting.call(this, 'captions'); // Trigger event (not used internally)
  8204. triggerEvent.call(this, this.media, active ? 'captionsenabled' : 'captionsdisabled');
  8205. } // Wait for the call stack to clear before setting mode='hidden'
  8206. // on the active track - forcing the browser to download it
  8207. setTimeout(function () {
  8208. if (active && _this2.captions.toggled) {
  8209. _this2.captions.currentTrackNode.mode = 'hidden';
  8210. }
  8211. });
  8212. },
  8213. // Set captions by track index
  8214. // Used internally for the currentTrack setter with the passive option forced to false
  8215. set: function set(index) {
  8216. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8217. var tracks = captions.getTracks.call(this); // Disable captions if setting to -1
  8218. if (index === -1) {
  8219. captions.toggle.call(this, false, passive);
  8220. return;
  8221. }
  8222. if (!is$1.number(index)) {
  8223. this.debug.warn('Invalid caption argument', index);
  8224. return;
  8225. }
  8226. if (!(index in tracks)) {
  8227. this.debug.warn('Track not found', index);
  8228. return;
  8229. }
  8230. if (this.captions.currentTrack !== index) {
  8231. this.captions.currentTrack = index;
  8232. var track = tracks[index];
  8233. var _ref = track || {},
  8234. language = _ref.language; // Store reference to node for invalidation on remove
  8235. this.captions.currentTrackNode = track; // Update settings menu
  8236. controls.updateSetting.call(this, 'captions'); // When passive, don't override user preferences
  8237. if (!passive) {
  8238. this.captions.language = language;
  8239. this.storage.set({
  8240. language: language
  8241. });
  8242. } // Handle Vimeo captions
  8243. if (this.isVimeo) {
  8244. this.embed.enableTextTrack(language);
  8245. } // Trigger event
  8246. triggerEvent.call(this, this.media, 'languagechange');
  8247. } // Show captions
  8248. captions.toggle.call(this, true, passive);
  8249. if (this.isHTML5 && this.isVideo) {
  8250. // If we change the active track while a cue is already displayed we need to update it
  8251. captions.updateCues.call(this);
  8252. }
  8253. },
  8254. // Set captions by language
  8255. // Used internally for the language setter with the passive option forced to false
  8256. setLanguage: function setLanguage(input) {
  8257. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8258. if (!is$1.string(input)) {
  8259. this.debug.warn('Invalid language argument', input);
  8260. return;
  8261. } // Normalize
  8262. var language = input.toLowerCase();
  8263. this.captions.language = language; // Set currentTrack
  8264. var tracks = captions.getTracks.call(this);
  8265. var track = captions.findTrack.call(this, [language]);
  8266. captions.set.call(this, tracks.indexOf(track), passive);
  8267. },
  8268. // Get current valid caption tracks
  8269. // If update is false it will also ignore tracks without metadata
  8270. // This is used to "freeze" the language options when captions.update is false
  8271. getTracks: function getTracks() {
  8272. var _this3 = this;
  8273. var update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8274. // Handle media or textTracks missing or null
  8275. var tracks = Array.from((this.media || {}).textTracks || []); // For HTML5, use cache instead of current tracks when it exists (if captions.update is false)
  8276. // Filter out removed tracks and tracks that aren't captions/subtitles (for example metadata)
  8277. return tracks.filter(function (track) {
  8278. return !_this3.isHTML5 || update || _this3.captions.meta.has(track);
  8279. }).filter(function (track) {
  8280. return ['captions', 'subtitles'].includes(track.kind);
  8281. });
  8282. },
  8283. // Match tracks based on languages and get the first
  8284. findTrack: function findTrack(languages) {
  8285. var _this4 = this;
  8286. var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8287. var tracks = captions.getTracks.call(this);
  8288. var sortIsDefault = function sortIsDefault(track) {
  8289. return Number((_this4.captions.meta.get(track) || {}).default);
  8290. };
  8291. var sorted = Array.from(tracks).sort(function (a, b) {
  8292. return sortIsDefault(b) - sortIsDefault(a);
  8293. });
  8294. var track;
  8295. languages.every(function (language) {
  8296. track = sorted.find(function (t) {
  8297. return t.language === language;
  8298. });
  8299. return !track; // Break iteration if there is a match
  8300. }); // If no match is found but is required, get first
  8301. return track || (force ? sorted[0] : undefined);
  8302. },
  8303. // Get the current track
  8304. getCurrentTrack: function getCurrentTrack() {
  8305. return captions.getTracks.call(this)[this.currentTrack];
  8306. },
  8307. // Get UI label for track
  8308. getLabel: function getLabel(track) {
  8309. var currentTrack = track;
  8310. if (!is$1.track(currentTrack) && support.textTracks && this.captions.toggled) {
  8311. currentTrack = captions.getCurrentTrack.call(this);
  8312. }
  8313. if (is$1.track(currentTrack)) {
  8314. if (!is$1.empty(currentTrack.label)) {
  8315. return currentTrack.label;
  8316. }
  8317. if (!is$1.empty(currentTrack.language)) {
  8318. return track.language.toUpperCase();
  8319. }
  8320. return i18n.get('enabled', this.config);
  8321. }
  8322. return i18n.get('disabled', this.config);
  8323. },
  8324. // Update captions using current track's active cues
  8325. // Also optional array argument in case there isn't any track (ex: vimeo)
  8326. updateCues: function updateCues(input) {
  8327. // Requires UI
  8328. if (!this.supported.ui) {
  8329. return;
  8330. }
  8331. if (!is$1.element(this.elements.captions)) {
  8332. this.debug.warn('No captions element to render to');
  8333. return;
  8334. } // Only accept array or empty input
  8335. if (!is$1.nullOrUndefined(input) && !Array.isArray(input)) {
  8336. this.debug.warn('updateCues: Invalid input', input);
  8337. return;
  8338. }
  8339. var cues = input; // Get cues from track
  8340. if (!cues) {
  8341. var track = captions.getCurrentTrack.call(this);
  8342. cues = Array.from((track || {}).activeCues || []).map(function (cue) {
  8343. return cue.getCueAsHTML();
  8344. }).map(getHTML);
  8345. } // Set new caption text
  8346. var content = cues.map(function (cueText) {
  8347. return cueText.trim();
  8348. }).join('\n');
  8349. var changed = content !== this.elements.captions.innerHTML;
  8350. if (changed) {
  8351. // Empty the container and create a new child element
  8352. emptyElement(this.elements.captions);
  8353. var caption = createElement('span', getAttributesFromSelector(this.config.selectors.caption));
  8354. caption.innerHTML = content;
  8355. this.elements.captions.appendChild(caption); // Trigger event
  8356. triggerEvent.call(this, this.media, 'cuechange');
  8357. }
  8358. }
  8359. };
  8360. // ==========================================================================
  8361. // Plyr default config
  8362. // ==========================================================================
  8363. var defaults$1 = {
  8364. // Disable
  8365. enabled: true,
  8366. // Custom media title
  8367. title: '',
  8368. // Logging to console
  8369. debug: false,
  8370. // Auto play (if supported)
  8371. autoplay: false,
  8372. // Only allow one media playing at once (vimeo only)
  8373. autopause: true,
  8374. // Allow inline playback on iOS (this effects YouTube/Vimeo - HTML5 requires the attribute present)
  8375. // TODO: Remove iosNative fullscreen option in favour of this (logic needs work)
  8376. playsinline: true,
  8377. // Default time to skip when rewind/fast forward
  8378. seekTime: 10,
  8379. // Default volume
  8380. volume: 1,
  8381. muted: false,
  8382. // Pass a custom duration
  8383. duration: null,
  8384. // Display the media duration on load in the current time position
  8385. // If you have opted to display both duration and currentTime, this is ignored
  8386. displayDuration: true,
  8387. // Invert the current time to be a countdown
  8388. invertTime: true,
  8389. // Clicking the currentTime inverts it's value to show time left rather than elapsed
  8390. toggleInvert: true,
  8391. // Force an aspect ratio
  8392. // The format must be `'w:h'` (e.g. `'16:9'`)
  8393. ratio: null,
  8394. // Click video container to play/pause
  8395. clickToPlay: true,
  8396. // Auto hide the controls
  8397. hideControls: true,
  8398. // Reset to start when playback ended
  8399. resetOnEnd: false,
  8400. // Disable the standard context menu
  8401. disableContextMenu: true,
  8402. // Sprite (for icons)
  8403. loadSprite: true,
  8404. iconPrefix: 'plyr',
  8405. iconUrl: '/theme/modules/plyr/plyr.svg',
  8406. // Blank video (used to prevent errors on source change)
  8407. blankVideo: '/theme/modules/plyr/blank.webm',
  8408. // Quality default
  8409. quality: {
  8410. default: 576,
  8411. // The options to display in the UI, if available for the source media
  8412. options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240],
  8413. forced: false,
  8414. onChange: null
  8415. },
  8416. // Set loops
  8417. loop: {
  8418. active: false // start: null,
  8419. // end: null,
  8420. },
  8421. // Speed default and options to display
  8422. speed: {
  8423. selected: 1,
  8424. // The options to display in the UI, if available for the source media (e.g. Vimeo and YouTube only support 0.5x-4x)
  8425. options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4]
  8426. },
  8427. // Keyboard shortcut settings
  8428. keyboard: {
  8429. focused: true,
  8430. global: false
  8431. },
  8432. // Display tooltips
  8433. tooltips: {
  8434. controls: false,
  8435. seek: true
  8436. },
  8437. // Captions settings
  8438. captions: {
  8439. active: false,
  8440. language: 'auto',
  8441. // Listen to new tracks added after Plyr is initialized.
  8442. // This is needed for streaming captions, but may result in unselectable options
  8443. update: false
  8444. },
  8445. // Fullscreen settings
  8446. fullscreen: {
  8447. enabled: true,
  8448. // Allow fullscreen?
  8449. fallback: true,
  8450. // Fallback using full viewport/window
  8451. iosNative: false // Use the native fullscreen in iOS (disables custom controls)
  8452. // Selector for the fullscreen container so contextual / non-player content can remain visible in fullscreen mode
  8453. // Non-ancestors of the player element will be ignored
  8454. // container: null, // defaults to the player element
  8455. },
  8456. // Local storage
  8457. storage: {
  8458. enabled: true,
  8459. key: 'plyr'
  8460. },
  8461. // Default controls
  8462. controls: ['play-large', // 'restart',
  8463. // 'rewind',
  8464. 'play', // 'fast-forward',
  8465. 'progress', 'current-time', // 'duration',
  8466. 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', // 'download',
  8467. 'fullscreen'],
  8468. settings: ['captions', 'quality', 'speed'],
  8469. // Localisation
  8470. i18n: {
  8471. restart: 'Restart',
  8472. rewind: 'Rewind {seektime}s',
  8473. play: 'Play',
  8474. pause: 'Pause',
  8475. fastForward: 'Forward {seektime}s',
  8476. seek: 'Seek',
  8477. seekLabel: '{currentTime} of {duration}',
  8478. played: 'Played',
  8479. buffered: 'Buffered',
  8480. currentTime: 'Current time',
  8481. duration: 'Duration',
  8482. volume: 'Volume',
  8483. mute: 'Mute',
  8484. unmute: 'Unmute',
  8485. enableCaptions: 'Enable captions',
  8486. disableCaptions: 'Disable captions',
  8487. download: 'Download',
  8488. enterFullscreen: 'Enter fullscreen',
  8489. exitFullscreen: 'Exit fullscreen',
  8490. frameTitle: 'Player for {title}',
  8491. captions: 'Captions',
  8492. settings: 'Settings',
  8493. pip: 'PIP',
  8494. menuBack: 'Go back to previous menu',
  8495. speed: 'Speed',
  8496. normal: 'Normal',
  8497. quality: 'Quality',
  8498. loop: 'Loop',
  8499. start: 'Start',
  8500. end: 'End',
  8501. all: 'All',
  8502. reset: 'Reset',
  8503. disabled: 'Disabled',
  8504. enabled: 'Enabled',
  8505. advertisement: 'Ad',
  8506. qualityBadge: {
  8507. 2160: '4K',
  8508. 1440: 'HD',
  8509. 1080: 'HD',
  8510. 720: 'HD',
  8511. 576: 'SD',
  8512. 480: 'SD'
  8513. }
  8514. },
  8515. // URLs
  8516. urls: {
  8517. download: null,
  8518. vimeo: {
  8519. sdk: 'https://player.vimeo.com/api/player.js',
  8520. iframe: 'https://player.vimeo.com/video/{0}?{1}',
  8521. api: 'https://vimeo.com/api/v2/video/{0}.json'
  8522. },
  8523. youtube: {
  8524. sdk: 'https://www.youtube.com/iframe_api',
  8525. api: 'https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}'
  8526. },
  8527. googleIMA: {
  8528. sdk: 'https://imasdk.googleapis.com/js/sdkloader/ima3.js'
  8529. }
  8530. },
  8531. // Custom control listeners
  8532. listeners: {
  8533. seek: null,
  8534. play: null,
  8535. pause: null,
  8536. restart: null,
  8537. rewind: null,
  8538. fastForward: null,
  8539. mute: null,
  8540. volume: null,
  8541. captions: null,
  8542. download: null,
  8543. fullscreen: null,
  8544. pip: null,
  8545. airplay: null,
  8546. speed: null,
  8547. quality: null,
  8548. loop: null,
  8549. language: null
  8550. },
  8551. // Events to watch and bubble
  8552. events: [// Events to watch on HTML5 media elements and bubble
  8553. // https://developer.mozilla.org/en/docs/Web/Guide/Events/Media_events
  8554. 'ended', 'progress', 'stalled', 'playing', 'waiting', 'canplay', 'canplaythrough', 'loadstart', 'loadeddata', 'loadedmetadata', 'timeupdate', 'volumechange', 'play', 'pause', 'error', 'seeking', 'seeked', 'emptied', 'ratechange', 'cuechange', // Custom events
  8555. 'download', 'enterfullscreen', 'exitfullscreen', 'captionsenabled', 'captionsdisabled', 'languagechange', 'controlshidden', 'controlsshown', 'ready', // YouTube
  8556. 'statechange', // Quality
  8557. 'qualitychange', // Ads
  8558. 'adsloaded', 'adscontentpause', 'adscontentresume', 'adstarted', 'adsmidpoint', 'adscomplete', 'adsallcomplete', 'adsimpression', 'adsclick'],
  8559. // Selectors
  8560. // Change these to match your template if using custom HTML
  8561. selectors: {
  8562. editable: 'input, textarea, select, [contenteditable]',
  8563. container: '.plyr',
  8564. controls: {
  8565. container: null,
  8566. wrapper: '.plyr__controls'
  8567. },
  8568. labels: '[data-plyr]',
  8569. buttons: {
  8570. play: '[data-plyr="play"]',
  8571. pause: '[data-plyr="pause"]',
  8572. restart: '[data-plyr="restart"]',
  8573. rewind: '[data-plyr="rewind"]',
  8574. fastForward: '[data-plyr="fast-forward"]',
  8575. mute: '[data-plyr="mute"]',
  8576. captions: '[data-plyr="captions"]',
  8577. download: '[data-plyr="download"]',
  8578. fullscreen: '[data-plyr="fullscreen"]',
  8579. pip: '[data-plyr="pip"]',
  8580. airplay: '[data-plyr="airplay"]',
  8581. settings: '[data-plyr="settings"]',
  8582. loop: '[data-plyr="loop"]'
  8583. },
  8584. inputs: {
  8585. seek: '[data-plyr="seek"]',
  8586. volume: '[data-plyr="volume"]',
  8587. speed: '[data-plyr="speed"]',
  8588. language: '[data-plyr="language"]',
  8589. quality: '[data-plyr="quality"]'
  8590. },
  8591. display: {
  8592. currentTime: '.plyr__time--current',
  8593. duration: '.plyr__time--duration',
  8594. buffer: '.plyr__progress__buffer',
  8595. loop: '.plyr__progress__loop',
  8596. // Used later
  8597. volume: '.plyr__volume--display'
  8598. },
  8599. progress: '.plyr__progress',
  8600. captions: '.plyr__captions',
  8601. caption: '.plyr__caption'
  8602. },
  8603. // Class hooks added to the player in different states
  8604. classNames: {
  8605. type: 'plyr--{0}',
  8606. provider: 'plyr--{0}',
  8607. video: 'plyr__video-wrapper',
  8608. embed: 'plyr__video-embed',
  8609. videoFixedRatio: 'plyr__video-wrapper--fixed-ratio',
  8610. embedContainer: 'plyr__video-embed__container',
  8611. poster: 'plyr__poster',
  8612. posterEnabled: 'plyr__poster-enabled',
  8613. ads: 'plyr__ads',
  8614. control: 'plyr__control',
  8615. controlPressed: 'plyr__control--pressed',
  8616. playing: 'plyr--playing',
  8617. paused: 'plyr--paused',
  8618. stopped: 'plyr--stopped',
  8619. loading: 'plyr--loading',
  8620. hover: 'plyr--hover',
  8621. tooltip: 'plyr__tooltip',
  8622. cues: 'plyr__cues',
  8623. hidden: 'plyr__sr-only',
  8624. hideControls: 'plyr--hide-controls',
  8625. isIos: 'plyr--is-ios',
  8626. isTouch: 'plyr--is-touch',
  8627. uiSupported: 'plyr--full-ui',
  8628. noTransition: 'plyr--no-transition',
  8629. display: {
  8630. time: 'plyr__time'
  8631. },
  8632. menu: {
  8633. value: 'plyr__menu__value',
  8634. badge: 'plyr__badge',
  8635. open: 'plyr--menu-open'
  8636. },
  8637. captions: {
  8638. enabled: 'plyr--captions-enabled',
  8639. active: 'plyr--captions-active'
  8640. },
  8641. fullscreen: {
  8642. enabled: 'plyr--fullscreen-enabled',
  8643. fallback: 'plyr--fullscreen-fallback'
  8644. },
  8645. pip: {
  8646. supported: 'plyr--pip-supported',
  8647. active: 'plyr--pip-active'
  8648. },
  8649. airplay: {
  8650. supported: 'plyr--airplay-supported',
  8651. active: 'plyr--airplay-active'
  8652. },
  8653. tabFocus: 'plyr__tab-focus',
  8654. previewThumbnails: {
  8655. // Tooltip thumbs
  8656. thumbContainer: 'plyr__preview-thumb',
  8657. thumbContainerShown: 'plyr__preview-thumb--is-shown',
  8658. imageContainer: 'plyr__preview-thumb__image-container',
  8659. timeContainer: 'plyr__preview-thumb__time-container',
  8660. // Scrubbing
  8661. scrubbingContainer: 'plyr__preview-scrubbing',
  8662. scrubbingContainerShown: 'plyr__preview-scrubbing--is-shown'
  8663. }
  8664. },
  8665. // Embed attributes
  8666. attributes: {
  8667. embed: {
  8668. provider: 'data-plyr-provider',
  8669. id: 'data-plyr-embed-id'
  8670. }
  8671. },
  8672. // Advertisements plugin
  8673. // Register for an account here: http://vi.ai/publisher-video-monetization/?aid=plyrio
  8674. ads: {
  8675. enabled: false,
  8676. publisherId: '',
  8677. tagUrl: ''
  8678. },
  8679. // Preview Thumbnails plugin
  8680. previewThumbnails: {
  8681. enabled: false,
  8682. src: ''
  8683. },
  8684. // Vimeo plugin
  8685. vimeo: {
  8686. byline: false,
  8687. portrait: false,
  8688. title: false,
  8689. speed: true,
  8690. transparent: false,
  8691. // Whether the owner of the video has a Pro or Business account
  8692. // (which allows us to properly hide controls without CSS hacks, etc)
  8693. premium: false,
  8694. // Custom settings from Plyr
  8695. referrerPolicy: null // https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
  8696. },
  8697. // YouTube plugin
  8698. youtube: {
  8699. noCookie: true,
  8700. // Whether to use an alternative version of YouTube without cookies
  8701. rel: 0,
  8702. // No related vids
  8703. showinfo: 0,
  8704. // Hide info
  8705. iv_load_policy: 3,
  8706. // Hide annotations
  8707. modestbranding: 1 // Hide logos as much as possible (they still show one in the corner when paused)
  8708. }
  8709. };
  8710. // ==========================================================================
  8711. // Plyr states
  8712. // ==========================================================================
  8713. var pip = {
  8714. active: 'picture-in-picture',
  8715. inactive: 'inline'
  8716. };
  8717. // ==========================================================================
  8718. // Plyr supported types and providers
  8719. // ==========================================================================
  8720. var providers = {
  8721. html5: 'html5',
  8722. youtube: 'youtube',
  8723. vimeo: 'vimeo'
  8724. };
  8725. var types = {
  8726. audio: 'audio',
  8727. video: 'video'
  8728. };
  8729. /**
  8730. * Get provider by URL
  8731. * @param {String} url
  8732. */
  8733. function getProviderByUrl(url) {
  8734. // YouTube
  8735. if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(url)) {
  8736. return providers.youtube;
  8737. } // Vimeo
  8738. if (/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(url)) {
  8739. return providers.vimeo;
  8740. }
  8741. return null;
  8742. }
  8743. // ==========================================================================
  8744. // Console wrapper
  8745. // ==========================================================================
  8746. var noop = function noop() {};
  8747. var Console = /*#__PURE__*/function () {
  8748. function Console() {
  8749. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8750. _classCallCheck(this, Console);
  8751. this.enabled = window.console && enabled;
  8752. if (this.enabled) {
  8753. this.log('Debugging enabled');
  8754. }
  8755. }
  8756. _createClass(Console, [{
  8757. key: "log",
  8758. get: function get() {
  8759. // eslint-disable-next-line no-console
  8760. return this.enabled ? Function.prototype.bind.call(console.log, console) : noop;
  8761. }
  8762. }, {
  8763. key: "warn",
  8764. get: function get() {
  8765. // eslint-disable-next-line no-console
  8766. return this.enabled ? Function.prototype.bind.call(console.warn, console) : noop;
  8767. }
  8768. }, {
  8769. key: "error",
  8770. get: function get() {
  8771. // eslint-disable-next-line no-console
  8772. return this.enabled ? Function.prototype.bind.call(console.error, console) : noop;
  8773. }
  8774. }]);
  8775. return Console;
  8776. }();
  8777. var Fullscreen = /*#__PURE__*/function () {
  8778. function Fullscreen(player) {
  8779. var _this = this;
  8780. _classCallCheck(this, Fullscreen);
  8781. // Keep reference to parent
  8782. this.player = player; // Get prefix
  8783. this.prefix = Fullscreen.prefix;
  8784. this.property = Fullscreen.property; // Scroll position
  8785. this.scrollPosition = {
  8786. x: 0,
  8787. y: 0
  8788. }; // Force the use of 'full window/browser' rather than fullscreen
  8789. this.forceFallback = player.config.fullscreen.fallback === 'force'; // Get the fullscreen element
  8790. // Checks container is an ancestor, defaults to null
  8791. this.player.elements.fullscreen = player.config.fullscreen.container && closest(this.player.elements.container, player.config.fullscreen.container); // Register event listeners
  8792. // Handle event (incase user presses escape etc)
  8793. on.call(this.player, document, this.prefix === 'ms' ? 'MSFullscreenChange' : "".concat(this.prefix, "fullscreenchange"), function () {
  8794. // TODO: Filter for target??
  8795. _this.onChange();
  8796. }); // Fullscreen toggle on double click
  8797. on.call(this.player, this.player.elements.container, 'dblclick', function (event) {
  8798. // Ignore double click in controls
  8799. if (is$1.element(_this.player.elements.controls) && _this.player.elements.controls.contains(event.target)) {
  8800. return;
  8801. }
  8802. _this.toggle();
  8803. }); // Tap focus when in fullscreen
  8804. on.call(this, this.player.elements.container, 'keydown', function (event) {
  8805. return _this.trapFocus(event);
  8806. }); // Update the UI
  8807. this.update();
  8808. } // Determine if native supported
  8809. _createClass(Fullscreen, [{
  8810. key: "onChange",
  8811. value: function onChange() {
  8812. if (!this.enabled) {
  8813. return;
  8814. } // Update toggle button
  8815. var button = this.player.elements.buttons.fullscreen;
  8816. if (is$1.element(button)) {
  8817. button.pressed = this.active;
  8818. } // Trigger an event
  8819. triggerEvent.call(this.player, this.target, this.active ? 'enterfullscreen' : 'exitfullscreen', true);
  8820. }
  8821. }, {
  8822. key: "toggleFallback",
  8823. value: function toggleFallback() {
  8824. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8825. // Store or restore scroll position
  8826. if (toggle) {
  8827. this.scrollPosition = {
  8828. x: window.scrollX || 0,
  8829. y: window.scrollY || 0
  8830. };
  8831. } else {
  8832. window.scrollTo(this.scrollPosition.x, this.scrollPosition.y);
  8833. } // Toggle scroll
  8834. document.body.style.overflow = toggle ? 'hidden' : ''; // Toggle class hook
  8835. toggleClass(this.target, this.player.config.classNames.fullscreen.fallback, toggle); // Force full viewport on iPhone X+
  8836. if (browser.isIos) {
  8837. var viewport = document.head.querySelector('meta[name="viewport"]');
  8838. var property = 'viewport-fit=cover'; // Inject the viewport meta if required
  8839. if (!viewport) {
  8840. viewport = document.createElement('meta');
  8841. viewport.setAttribute('name', 'viewport');
  8842. } // Check if the property already exists
  8843. var hasProperty = is$1.string(viewport.content) && viewport.content.includes(property);
  8844. if (toggle) {
  8845. this.cleanupViewport = !hasProperty;
  8846. if (!hasProperty) {
  8847. viewport.content += ",".concat(property);
  8848. }
  8849. } else if (this.cleanupViewport) {
  8850. viewport.content = viewport.content.split(',').filter(function (part) {
  8851. return part.trim() !== property;
  8852. }).join(',');
  8853. }
  8854. } // Toggle button and fire events
  8855. this.onChange();
  8856. } // Trap focus inside container
  8857. }, {
  8858. key: "trapFocus",
  8859. value: function trapFocus(event) {
  8860. // Bail if iOS, not active, not the tab key
  8861. if (browser.isIos || !this.active || event.key !== 'Tab' || event.keyCode !== 9) {
  8862. return;
  8863. } // Get the current focused element
  8864. var focused = document.activeElement;
  8865. var focusable = getElements.call(this.player, 'a[href], button:not(:disabled), input:not(:disabled), [tabindex]');
  8866. var _focusable = _slicedToArray(focusable, 1),
  8867. first = _focusable[0];
  8868. var last = focusable[focusable.length - 1];
  8869. if (focused === last && !event.shiftKey) {
  8870. // Move focus to first element that can be tabbed if Shift isn't used
  8871. first.focus();
  8872. event.preventDefault();
  8873. } else if (focused === first && event.shiftKey) {
  8874. // Move focus to last element that can be tabbed if Shift is used
  8875. last.focus();
  8876. event.preventDefault();
  8877. }
  8878. } // Update UI
  8879. }, {
  8880. key: "update",
  8881. value: function update() {
  8882. if (this.enabled) {
  8883. var mode;
  8884. if (this.forceFallback) {
  8885. mode = 'Fallback (forced)';
  8886. } else if (Fullscreen.native) {
  8887. mode = 'Native';
  8888. } else {
  8889. mode = 'Fallback';
  8890. }
  8891. this.player.debug.log("".concat(mode, " fullscreen enabled"));
  8892. } else {
  8893. this.player.debug.log('Fullscreen not supported and fallback disabled');
  8894. } // Add styling hook to show button
  8895. toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.enabled);
  8896. } // Make an element fullscreen
  8897. }, {
  8898. key: "enter",
  8899. value: function enter() {
  8900. if (!this.enabled) {
  8901. return;
  8902. } // iOS native fullscreen doesn't need the request step
  8903. if (browser.isIos && this.player.config.fullscreen.iosNative) {
  8904. this.target.webkitEnterFullscreen();
  8905. } else if (!Fullscreen.native || this.forceFallback) {
  8906. this.toggleFallback(true);
  8907. } else if (!this.prefix) {
  8908. this.target.requestFullscreen({
  8909. navigationUI: 'hide'
  8910. });
  8911. } else if (!is$1.empty(this.prefix)) {
  8912. this.target["".concat(this.prefix, "Request").concat(this.property)]();
  8913. }
  8914. } // Bail from fullscreen
  8915. }, {
  8916. key: "exit",
  8917. value: function exit() {
  8918. if (!this.enabled) {
  8919. return;
  8920. } // iOS native fullscreen
  8921. if (browser.isIos && this.player.config.fullscreen.iosNative) {
  8922. this.target.webkitExitFullscreen();
  8923. silencePromise(this.player.play());
  8924. } else if (!Fullscreen.native || this.forceFallback) {
  8925. this.toggleFallback(false);
  8926. } else if (!this.prefix) {
  8927. (document.cancelFullScreen || document.exitFullscreen).call(document);
  8928. } else if (!is$1.empty(this.prefix)) {
  8929. var action = this.prefix === 'moz' ? 'Cancel' : 'Exit';
  8930. document["".concat(this.prefix).concat(action).concat(this.property)]();
  8931. }
  8932. } // Toggle state
  8933. }, {
  8934. key: "toggle",
  8935. value: function toggle() {
  8936. if (!this.active) {
  8937. this.enter();
  8938. } else {
  8939. this.exit();
  8940. }
  8941. }
  8942. }, {
  8943. key: "usingNative",
  8944. // If we're actually using native
  8945. get: function get() {
  8946. return Fullscreen.native && !this.forceFallback;
  8947. } // Get the prefix for handlers
  8948. }, {
  8949. key: "enabled",
  8950. // Determine if fullscreen is enabled
  8951. get: function get() {
  8952. return (Fullscreen.native || this.player.config.fullscreen.fallback) && this.player.config.fullscreen.enabled && this.player.supported.ui && this.player.isVideo;
  8953. } // Get active state
  8954. }, {
  8955. key: "active",
  8956. get: function get() {
  8957. if (!this.enabled) {
  8958. return false;
  8959. } // Fallback using classname
  8960. if (!Fullscreen.native || this.forceFallback) {
  8961. return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
  8962. }
  8963. var element = !this.prefix ? document.fullscreenElement : document["".concat(this.prefix).concat(this.property, "Element")];
  8964. return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
  8965. } // Get target element
  8966. }, {
  8967. key: "target",
  8968. get: function get() {
  8969. return browser.isIos && this.player.config.fullscreen.iosNative ? this.player.media : this.player.elements.fullscreen || this.player.elements.container;
  8970. }
  8971. }], [{
  8972. key: "native",
  8973. get: function get() {
  8974. return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled);
  8975. }
  8976. }, {
  8977. key: "prefix",
  8978. get: function get() {
  8979. // No prefix
  8980. if (is$1.function(document.exitFullscreen)) {
  8981. return '';
  8982. } // Check for fullscreen support by vendor prefix
  8983. var value = '';
  8984. var prefixes = ['webkit', 'moz', 'ms'];
  8985. prefixes.some(function (pre) {
  8986. if (is$1.function(document["".concat(pre, "ExitFullscreen")]) || is$1.function(document["".concat(pre, "CancelFullScreen")])) {
  8987. value = pre;
  8988. return true;
  8989. }
  8990. return false;
  8991. });
  8992. return value;
  8993. }
  8994. }, {
  8995. key: "property",
  8996. get: function get() {
  8997. return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen';
  8998. }
  8999. }]);
  9000. return Fullscreen;
  9001. }();
  9002. // `Math.sign` method implementation
  9003. // https://tc39.github.io/ecma262/#sec-math.sign
  9004. var mathSign = Math.sign || function sign(x) {
  9005. // eslint-disable-next-line no-self-compare
  9006. return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
  9007. };
  9008. // `Math.sign` method
  9009. // https://tc39.github.io/ecma262/#sec-math.sign
  9010. _export({ target: 'Math', stat: true }, {
  9011. sign: mathSign
  9012. });
  9013. // ==========================================================================
  9014. // Load image avoiding xhr/fetch CORS issues
  9015. // Server status can't be obtained this way unfortunately, so this uses "naturalWidth" to determine if the image has loaded
  9016. // By default it checks if it is at least 1px, but you can add a second argument to change this
  9017. // ==========================================================================
  9018. function loadImage(src) {
  9019. var minWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  9020. return new Promise(function (resolve, reject) {
  9021. var image = new Image();
  9022. var handler = function handler() {
  9023. delete image.onload;
  9024. delete image.onerror;
  9025. (image.naturalWidth >= minWidth ? resolve : reject)(image);
  9026. };
  9027. Object.assign(image, {
  9028. onload: handler,
  9029. onerror: handler,
  9030. src: src
  9031. });
  9032. });
  9033. }
  9034. var ui = {
  9035. addStyleHook: function addStyleHook() {
  9036. toggleClass(this.elements.container, this.config.selectors.container.replace('.', ''), true);
  9037. toggleClass(this.elements.container, this.config.classNames.uiSupported, this.supported.ui);
  9038. },
  9039. // Toggle native HTML5 media controls
  9040. toggleNativeControls: function toggleNativeControls() {
  9041. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9042. if (toggle && this.isHTML5) {
  9043. this.media.setAttribute('controls', '');
  9044. } else {
  9045. this.media.removeAttribute('controls');
  9046. }
  9047. },
  9048. // Setup the UI
  9049. build: function build() {
  9050. var _this = this;
  9051. // Re-attach media element listeners
  9052. // TODO: Use event bubbling?
  9053. this.listeners.media(); // Don't setup interface if no support
  9054. if (!this.supported.ui) {
  9055. this.debug.warn("Basic support only for ".concat(this.provider, " ").concat(this.type)); // Restore native controls
  9056. ui.toggleNativeControls.call(this, true); // Bail
  9057. return;
  9058. } // Inject custom controls if not present
  9059. if (!is$1.element(this.elements.controls)) {
  9060. // Inject custom controls
  9061. controls.inject.call(this); // Re-attach control listeners
  9062. this.listeners.controls();
  9063. } // Remove native controls
  9064. ui.toggleNativeControls.call(this); // Setup captions for HTML5
  9065. if (this.isHTML5) {
  9066. captions.setup.call(this);
  9067. } // Reset volume
  9068. this.volume = null; // Reset mute state
  9069. this.muted = null; // Reset loop state
  9070. this.loop = null; // Reset quality setting
  9071. this.quality = null; // Reset speed
  9072. this.speed = null; // Reset volume display
  9073. controls.updateVolume.call(this); // Reset time display
  9074. controls.timeUpdate.call(this); // Update the UI
  9075. ui.checkPlaying.call(this); // Check for picture-in-picture support
  9076. toggleClass(this.elements.container, this.config.classNames.pip.supported, support.pip && this.isHTML5 && this.isVideo); // Check for airplay support
  9077. toggleClass(this.elements.container, this.config.classNames.airplay.supported, support.airplay && this.isHTML5); // Add iOS class
  9078. toggleClass(this.elements.container, this.config.classNames.isIos, browser.isIos); // Add touch class
  9079. toggleClass(this.elements.container, this.config.classNames.isTouch, this.touch); // Ready for API calls
  9080. this.ready = true; // Ready event at end of execution stack
  9081. setTimeout(function () {
  9082. triggerEvent.call(_this, _this.media, 'ready');
  9083. }, 0); // Set the title
  9084. ui.setTitle.call(this); // Assure the poster image is set, if the property was added before the element was created
  9085. if (this.poster) {
  9086. ui.setPoster.call(this, this.poster, false).catch(function () {});
  9087. } // Manually set the duration if user has overridden it.
  9088. // The event listeners for it doesn't get called if preload is disabled (#701)
  9089. if (this.config.duration) {
  9090. controls.durationUpdate.call(this);
  9091. }
  9092. },
  9093. // Setup aria attribute for play and iframe title
  9094. setTitle: function setTitle() {
  9095. // Find the current text
  9096. var label = i18n.get('play', this.config); // If there's a media title set, use that for the label
  9097. if (is$1.string(this.config.title) && !is$1.empty(this.config.title)) {
  9098. label += ", ".concat(this.config.title);
  9099. } // If there's a play button, set label
  9100. Array.from(this.elements.buttons.play || []).forEach(function (button) {
  9101. button.setAttribute('aria-label', label);
  9102. }); // Set iframe title
  9103. // https://github.com/sampotts/plyr/issues/124
  9104. if (this.isEmbed) {
  9105. var iframe = getElement.call(this, 'iframe');
  9106. if (!is$1.element(iframe)) {
  9107. return;
  9108. } // Default to media type
  9109. var title = !is$1.empty(this.config.title) ? this.config.title : 'video';
  9110. var format = i18n.get('frameTitle', this.config);
  9111. iframe.setAttribute('title', format.replace('{title}', title));
  9112. }
  9113. },
  9114. // Toggle poster
  9115. togglePoster: function togglePoster(enable) {
  9116. toggleClass(this.elements.container, this.config.classNames.posterEnabled, enable);
  9117. },
  9118. // Set the poster image (async)
  9119. // Used internally for the poster setter, with the passive option forced to false
  9120. setPoster: function setPoster(poster) {
  9121. var _this2 = this;
  9122. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  9123. // Don't override if call is passive
  9124. if (passive && this.poster) {
  9125. return Promise.reject(new Error('Poster already set'));
  9126. } // Set property synchronously to respect the call order
  9127. this.media.setAttribute('data-poster', poster); // Wait until ui is ready
  9128. return ready.call(this) // Load image
  9129. .then(function () {
  9130. return loadImage(poster);
  9131. }).catch(function (err) {
  9132. // Hide poster on error unless it's been set by another call
  9133. if (poster === _this2.poster) {
  9134. ui.togglePoster.call(_this2, false);
  9135. } // Rethrow
  9136. throw err;
  9137. }).then(function () {
  9138. // Prevent race conditions
  9139. if (poster !== _this2.poster) {
  9140. throw new Error('setPoster cancelled by later call to setPoster');
  9141. }
  9142. }).then(function () {
  9143. Object.assign(_this2.elements.poster.style, {
  9144. backgroundImage: "url('".concat(poster, "')"),
  9145. // Reset backgroundSize as well (since it can be set to "cover" for padded thumbnails for youtube)
  9146. backgroundSize: ''
  9147. });
  9148. ui.togglePoster.call(_this2, true);
  9149. return poster;
  9150. });
  9151. },
  9152. // Check playing state
  9153. checkPlaying: function checkPlaying(event) {
  9154. var _this3 = this;
  9155. // Class hooks
  9156. toggleClass(this.elements.container, this.config.classNames.playing, this.playing);
  9157. toggleClass(this.elements.container, this.config.classNames.paused, this.paused);
  9158. toggleClass(this.elements.container, this.config.classNames.stopped, this.stopped); // Set state
  9159. Array.from(this.elements.buttons.play || []).forEach(function (target) {
  9160. Object.assign(target, {
  9161. pressed: _this3.playing
  9162. });
  9163. target.setAttribute('aria-label', i18n.get(_this3.playing ? 'pause' : 'play', _this3.config));
  9164. }); // Only update controls on non timeupdate events
  9165. if (is$1.event(event) && event.type === 'timeupdate') {
  9166. return;
  9167. } // Toggle controls
  9168. ui.toggleControls.call(this);
  9169. },
  9170. // Check if media is loading
  9171. checkLoading: function checkLoading(event) {
  9172. var _this4 = this;
  9173. this.loading = ['stalled', 'waiting'].includes(event.type); // Clear timer
  9174. clearTimeout(this.timers.loading); // Timer to prevent flicker when seeking
  9175. this.timers.loading = setTimeout(function () {
  9176. // Update progress bar loading class state
  9177. toggleClass(_this4.elements.container, _this4.config.classNames.loading, _this4.loading); // Update controls visibility
  9178. ui.toggleControls.call(_this4);
  9179. }, this.loading ? 250 : 0);
  9180. },
  9181. // Toggle controls based on state and `force` argument
  9182. toggleControls: function toggleControls(force) {
  9183. var controlsElement = this.elements.controls;
  9184. if (controlsElement && this.config.hideControls) {
  9185. // Don't hide controls if a touch-device user recently seeked. (Must be limited to touch devices, or it occasionally prevents desktop controls from hiding.)
  9186. var recentTouchSeek = this.touch && this.lastSeekTime + 2000 > Date.now(); // Show controls if force, loading, paused, button interaction, or recent seek, otherwise hide
  9187. this.toggleControls(Boolean(force || this.loading || this.paused || controlsElement.pressed || controlsElement.hover || recentTouchSeek));
  9188. }
  9189. },
  9190. // Migrate any custom properties from the media to the parent
  9191. migrateStyles: function migrateStyles() {
  9192. var _this5 = this;
  9193. // Loop through values (as they are the keys when the object is spread 🤔)
  9194. Object.values(_objectSpread2({}, this.media.style)) // We're only fussed about Plyr specific properties
  9195. .filter(function (key) {
  9196. return !is$1.empty(key) && key.startsWith('--plyr');
  9197. }).forEach(function (key) {
  9198. // Set on the container
  9199. _this5.elements.container.style.setProperty(key, _this5.media.style.getPropertyValue(key)); // Clean up from media element
  9200. _this5.media.style.removeProperty(key);
  9201. }); // Remove attribute if empty
  9202. if (is$1.empty(this.media.style)) {
  9203. this.media.removeAttribute('style');
  9204. }
  9205. }
  9206. };
  9207. var Listeners = /*#__PURE__*/function () {
  9208. function Listeners(player) {
  9209. _classCallCheck(this, Listeners);
  9210. this.player = player;
  9211. this.lastKey = null;
  9212. this.focusTimer = null;
  9213. this.lastKeyDown = null;
  9214. this.handleKey = this.handleKey.bind(this);
  9215. this.toggleMenu = this.toggleMenu.bind(this);
  9216. this.setTabFocus = this.setTabFocus.bind(this);
  9217. this.firstTouch = this.firstTouch.bind(this);
  9218. } // Handle key presses
  9219. _createClass(Listeners, [{
  9220. key: "handleKey",
  9221. value: function handleKey(event) {
  9222. var player = this.player;
  9223. var elements = player.elements;
  9224. var code = event.keyCode ? event.keyCode : event.which;
  9225. var pressed = event.type === 'keydown';
  9226. var repeat = pressed && code === this.lastKey; // Bail if a modifier key is set
  9227. if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
  9228. return;
  9229. } // If the event is bubbled from the media element
  9230. // Firefox doesn't get the keycode for whatever reason
  9231. if (!is$1.number(code)) {
  9232. return;
  9233. } // Seek by the number keys
  9234. var seekByKey = function seekByKey() {
  9235. // Divide the max duration into 10th's and times by the number value
  9236. player.currentTime = player.duration / 10 * (code - 48);
  9237. }; // Handle the key on keydown
  9238. // Reset on keyup
  9239. if (pressed) {
  9240. // Check focused element
  9241. // and if the focused element is not editable (e.g. text input)
  9242. // and any that accept key input http://webaim.org/techniques/keyboard/
  9243. var focused = document.activeElement;
  9244. if (is$1.element(focused)) {
  9245. var editable = player.config.selectors.editable;
  9246. var seek = elements.inputs.seek;
  9247. if (focused !== seek && matches$1(focused, editable)) {
  9248. return;
  9249. }
  9250. if (event.which === 32 && matches$1(focused, 'button, [role^="menuitem"]')) {
  9251. return;
  9252. }
  9253. } // Which keycodes should we prevent default
  9254. var preventDefault = [32, 37, 38, 39, 40, 48, 49, 50, 51, 52, 53, 54, 56, 57, 67, 70, 73, 75, 76, 77, 79]; // If the code is found prevent default (e.g. prevent scrolling for arrows)
  9255. if (preventDefault.includes(code)) {
  9256. event.preventDefault();
  9257. event.stopPropagation();
  9258. }
  9259. switch (code) {
  9260. case 48:
  9261. case 49:
  9262. case 50:
  9263. case 51:
  9264. case 52:
  9265. case 53:
  9266. case 54:
  9267. case 55:
  9268. case 56:
  9269. case 57:
  9270. // 0-9
  9271. if (!repeat) {
  9272. seekByKey();
  9273. }
  9274. break;
  9275. case 32:
  9276. case 75:
  9277. // Space and K key
  9278. if (!repeat) {
  9279. silencePromise(player.togglePlay());
  9280. }
  9281. break;
  9282. case 38:
  9283. // Arrow up
  9284. player.increaseVolume(0.1);
  9285. break;
  9286. case 40:
  9287. // Arrow down
  9288. player.decreaseVolume(0.1);
  9289. break;
  9290. case 77:
  9291. // M key
  9292. if (!repeat) {
  9293. player.muted = !player.muted;
  9294. }
  9295. break;
  9296. case 39:
  9297. // Arrow forward
  9298. player.forward();
  9299. break;
  9300. case 37:
  9301. // Arrow back
  9302. player.rewind();
  9303. break;
  9304. case 70:
  9305. // F key
  9306. player.fullscreen.toggle();
  9307. break;
  9308. case 67:
  9309. // C key
  9310. if (!repeat) {
  9311. player.toggleCaptions();
  9312. }
  9313. break;
  9314. case 76:
  9315. // L key
  9316. player.loop = !player.loop;
  9317. break;
  9318. } // Escape is handle natively when in full screen
  9319. // So we only need to worry about non native
  9320. if (code === 27 && !player.fullscreen.usingNative && player.fullscreen.active) {
  9321. player.fullscreen.toggle();
  9322. } // Store last code for next cycle
  9323. this.lastKey = code;
  9324. } else {
  9325. this.lastKey = null;
  9326. }
  9327. } // Toggle menu
  9328. }, {
  9329. key: "toggleMenu",
  9330. value: function toggleMenu(event) {
  9331. controls.toggleMenu.call(this.player, event);
  9332. } // Device is touch enabled
  9333. }, {
  9334. key: "firstTouch",
  9335. value: function firstTouch() {
  9336. var player = this.player;
  9337. var elements = player.elements;
  9338. player.touch = true; // Add touch class
  9339. toggleClass(elements.container, player.config.classNames.isTouch, true);
  9340. }
  9341. }, {
  9342. key: "setTabFocus",
  9343. value: function setTabFocus(event) {
  9344. var player = this.player;
  9345. var elements = player.elements;
  9346. clearTimeout(this.focusTimer); // Ignore any key other than tab
  9347. if (event.type === 'keydown' && event.which !== 9) {
  9348. return;
  9349. } // Store reference to event timeStamp
  9350. if (event.type === 'keydown') {
  9351. this.lastKeyDown = event.timeStamp;
  9352. } // Remove current classes
  9353. var removeCurrent = function removeCurrent() {
  9354. var className = player.config.classNames.tabFocus;
  9355. var current = getElements.call(player, ".".concat(className));
  9356. toggleClass(current, className, false);
  9357. }; // Determine if a key was pressed to trigger this event
  9358. var wasKeyDown = event.timeStamp - this.lastKeyDown <= 20; // Ignore focus events if a key was pressed prior
  9359. if (event.type === 'focus' && !wasKeyDown) {
  9360. return;
  9361. } // Remove all current
  9362. removeCurrent(); // Delay the adding of classname until the focus has changed
  9363. // This event fires before the focusin event
  9364. if (event.type !== 'focusout') {
  9365. this.focusTimer = setTimeout(function () {
  9366. var focused = document.activeElement; // Ignore if current focus element isn't inside the player
  9367. if (!elements.container.contains(focused)) {
  9368. return;
  9369. }
  9370. toggleClass(document.activeElement, player.config.classNames.tabFocus, true);
  9371. }, 10);
  9372. }
  9373. } // Global window & document listeners
  9374. }, {
  9375. key: "global",
  9376. value: function global() {
  9377. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  9378. var player = this.player; // Keyboard shortcuts
  9379. if (player.config.keyboard.global) {
  9380. toggleListener.call(player, window, 'keydown keyup', this.handleKey, toggle, false);
  9381. } // Click anywhere closes menu
  9382. toggleListener.call(player, document.body, 'click', this.toggleMenu, toggle); // Detect touch by events
  9383. once.call(player, document.body, 'touchstart', this.firstTouch); // Tab focus detection
  9384. toggleListener.call(player, document.body, 'keydown focus blur focusout', this.setTabFocus, toggle, false, true);
  9385. } // Container listeners
  9386. }, {
  9387. key: "container",
  9388. value: function container() {
  9389. var player = this.player;
  9390. var config = player.config,
  9391. elements = player.elements,
  9392. timers = player.timers; // Keyboard shortcuts
  9393. if (!config.keyboard.global && config.keyboard.focused) {
  9394. on.call(player, elements.container, 'keydown keyup', this.handleKey, false);
  9395. } // Toggle controls on mouse events and entering fullscreen
  9396. on.call(player, elements.container, 'mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen', function (event) {
  9397. var controlsElement = elements.controls; // Remove button states for fullscreen
  9398. if (controlsElement && event.type === 'enterfullscreen') {
  9399. controlsElement.pressed = false;
  9400. controlsElement.hover = false;
  9401. } // Show, then hide after a timeout unless another control event occurs
  9402. var show = ['touchstart', 'touchmove', 'mousemove'].includes(event.type);
  9403. var delay = 0;
  9404. if (show) {
  9405. ui.toggleControls.call(player, true); // Use longer timeout for touch devices
  9406. delay = player.touch ? 3000 : 2000;
  9407. } // Clear timer
  9408. clearTimeout(timers.controls); // Set new timer to prevent flicker when seeking
  9409. timers.controls = setTimeout(function () {
  9410. return ui.toggleControls.call(player, false);
  9411. }, delay);
  9412. }); // Set a gutter for Vimeo
  9413. var setGutter = function setGutter(ratio, padding, toggle) {
  9414. if (!player.isVimeo || player.config.vimeo.premium) {
  9415. return;
  9416. }
  9417. var target = player.elements.wrapper.firstChild;
  9418. var _ratio = _slicedToArray(ratio, 2),
  9419. y = _ratio[1];
  9420. var _getAspectRatio$call = getAspectRatio.call(player),
  9421. _getAspectRatio$call2 = _slicedToArray(_getAspectRatio$call, 2),
  9422. videoX = _getAspectRatio$call2[0],
  9423. videoY = _getAspectRatio$call2[1];
  9424. target.style.maxWidth = toggle ? "".concat(y / videoY * videoX, "px") : null;
  9425. target.style.margin = toggle ? '0 auto' : null;
  9426. }; // Resize on fullscreen change
  9427. var setPlayerSize = function setPlayerSize(measure) {
  9428. // If we don't need to measure the viewport
  9429. if (!measure) {
  9430. return setAspectRatio.call(player);
  9431. }
  9432. var rect = elements.container.getBoundingClientRect();
  9433. var width = rect.width,
  9434. height = rect.height;
  9435. return setAspectRatio.call(player, "".concat(width, ":").concat(height));
  9436. };
  9437. var resized = function resized() {
  9438. clearTimeout(timers.resized);
  9439. timers.resized = setTimeout(setPlayerSize, 50);
  9440. };
  9441. on.call(player, elements.container, 'enterfullscreen exitfullscreen', function (event) {
  9442. var _player$fullscreen = player.fullscreen,
  9443. target = _player$fullscreen.target,
  9444. usingNative = _player$fullscreen.usingNative; // Ignore events not from target
  9445. if (target !== elements.container) {
  9446. return;
  9447. } // If it's not an embed and no ratio specified
  9448. if (!player.isEmbed && is$1.empty(player.config.ratio)) {
  9449. return;
  9450. }
  9451. var isEnter = event.type === 'enterfullscreen'; // Set the player size when entering fullscreen to viewport size
  9452. var _setPlayerSize = setPlayerSize(isEnter),
  9453. padding = _setPlayerSize.padding,
  9454. ratio = _setPlayerSize.ratio; // Set Vimeo gutter
  9455. setGutter(ratio, padding, isEnter); // If not using native browser fullscreen API, we need to check for resizes of viewport
  9456. if (!usingNative) {
  9457. if (isEnter) {
  9458. on.call(player, window, 'resize', resized);
  9459. } else {
  9460. off.call(player, window, 'resize', resized);
  9461. }
  9462. }
  9463. });
  9464. } // Listen for media events
  9465. }, {
  9466. key: "media",
  9467. value: function media() {
  9468. var _this = this;
  9469. var player = this.player;
  9470. var elements = player.elements; // Time change on media
  9471. on.call(player, player.media, 'timeupdate seeking seeked', function (event) {
  9472. return controls.timeUpdate.call(player, event);
  9473. }); // Display duration
  9474. on.call(player, player.media, 'durationchange loadeddata loadedmetadata', function (event) {
  9475. return controls.durationUpdate.call(player, event);
  9476. }); // Handle the media finishing
  9477. on.call(player, player.media, 'ended', function () {
  9478. // Show poster on end
  9479. if (player.isHTML5 && player.isVideo && player.config.resetOnEnd) {
  9480. // Restart
  9481. player.restart(); // Call pause otherwise IE11 will start playing the video again
  9482. player.pause();
  9483. }
  9484. }); // Check for buffer progress
  9485. on.call(player, player.media, 'progress playing seeking seeked', function (event) {
  9486. return controls.updateProgress.call(player, event);
  9487. }); // Handle volume changes
  9488. on.call(player, player.media, 'volumechange', function (event) {
  9489. return controls.updateVolume.call(player, event);
  9490. }); // Handle play/pause
  9491. on.call(player, player.media, 'playing play pause ended emptied timeupdate', function (event) {
  9492. return ui.checkPlaying.call(player, event);
  9493. }); // Loading state
  9494. on.call(player, player.media, 'waiting canplay seeked playing', function (event) {
  9495. return ui.checkLoading.call(player, event);
  9496. }); // Click video
  9497. if (player.supported.ui && player.config.clickToPlay && !player.isAudio) {
  9498. // Re-fetch the wrapper
  9499. var wrapper = getElement.call(player, ".".concat(player.config.classNames.video)); // Bail if there's no wrapper (this should never happen)
  9500. if (!is$1.element(wrapper)) {
  9501. return;
  9502. } // On click play, pause or restart
  9503. on.call(player, elements.container, 'click', function (event) {
  9504. var targets = [elements.container, wrapper]; // Ignore if click if not container or in video wrapper
  9505. if (!targets.includes(event.target) && !wrapper.contains(event.target)) {
  9506. return;
  9507. } // Touch devices will just show controls (if hidden)
  9508. if (player.touch && player.config.hideControls) {
  9509. return;
  9510. }
  9511. if (player.ended) {
  9512. _this.proxy(event, player.restart, 'restart');
  9513. _this.proxy(event, function () {
  9514. silencePromise(player.play());
  9515. }, 'play');
  9516. } else {
  9517. _this.proxy(event, function () {
  9518. silencePromise(player.togglePlay());
  9519. }, 'play');
  9520. }
  9521. });
  9522. } // Disable right click
  9523. if (player.supported.ui && player.config.disableContextMenu) {
  9524. on.call(player, elements.wrapper, 'contextmenu', function (event) {
  9525. event.preventDefault();
  9526. }, false);
  9527. } // Volume change
  9528. on.call(player, player.media, 'volumechange', function () {
  9529. // Save to storage
  9530. player.storage.set({
  9531. volume: player.volume,
  9532. muted: player.muted
  9533. });
  9534. }); // Speed change
  9535. on.call(player, player.media, 'ratechange', function () {
  9536. // Update UI
  9537. controls.updateSetting.call(player, 'speed'); // Save to storage
  9538. player.storage.set({
  9539. speed: player.speed
  9540. });
  9541. }); // Quality change
  9542. on.call(player, player.media, 'qualitychange', function (event) {
  9543. // Update UI
  9544. controls.updateSetting.call(player, 'quality', null, event.detail.quality);
  9545. }); // Update download link when ready and if quality changes
  9546. on.call(player, player.media, 'ready qualitychange', function () {
  9547. controls.setDownloadUrl.call(player);
  9548. }); // Proxy events to container
  9549. // Bubble up key events for Edge
  9550. var proxyEvents = player.config.events.concat(['keyup', 'keydown']).join(' ');
  9551. on.call(player, player.media, proxyEvents, function (event) {
  9552. var _event$detail = event.detail,
  9553. detail = _event$detail === void 0 ? {} : _event$detail; // Get error details from media
  9554. if (event.type === 'error') {
  9555. detail = player.media.error;
  9556. }
  9557. triggerEvent.call(player, elements.container, event.type, true, detail);
  9558. });
  9559. } // Run default and custom handlers
  9560. }, {
  9561. key: "proxy",
  9562. value: function proxy(event, defaultHandler, customHandlerKey) {
  9563. var player = this.player;
  9564. var customHandler = player.config.listeners[customHandlerKey];
  9565. var hasCustomHandler = is$1.function(customHandler);
  9566. var returned = true; // Execute custom handler
  9567. if (hasCustomHandler) {
  9568. returned = customHandler.call(player, event);
  9569. } // Only call default handler if not prevented in custom handler
  9570. if (returned !== false && is$1.function(defaultHandler)) {
  9571. defaultHandler.call(player, event);
  9572. }
  9573. } // Trigger custom and default handlers
  9574. }, {
  9575. key: "bind",
  9576. value: function bind(element, type, defaultHandler, customHandlerKey) {
  9577. var _this2 = this;
  9578. var passive = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  9579. var player = this.player;
  9580. var customHandler = player.config.listeners[customHandlerKey];
  9581. var hasCustomHandler = is$1.function(customHandler);
  9582. on.call(player, element, type, function (event) {
  9583. return _this2.proxy(event, defaultHandler, customHandlerKey);
  9584. }, passive && !hasCustomHandler);
  9585. } // Listen for control events
  9586. }, {
  9587. key: "controls",
  9588. value: function controls$1() {
  9589. var _this3 = this;
  9590. var player = this.player;
  9591. var elements = player.elements; // IE doesn't support input event, so we fallback to change
  9592. var inputEvent = browser.isIE ? 'change' : 'input'; // Play/pause toggle
  9593. if (elements.buttons.play) {
  9594. Array.from(elements.buttons.play).forEach(function (button) {
  9595. _this3.bind(button, 'click', function () {
  9596. silencePromise(player.togglePlay());
  9597. }, 'play');
  9598. });
  9599. } // Pause
  9600. this.bind(elements.buttons.restart, 'click', player.restart, 'restart'); // Rewind
  9601. this.bind(elements.buttons.rewind, 'click', player.rewind, 'rewind'); // Rewind
  9602. this.bind(elements.buttons.fastForward, 'click', player.forward, 'fastForward'); // Mute toggle
  9603. this.bind(elements.buttons.mute, 'click', function () {
  9604. player.muted = !player.muted;
  9605. }, 'mute'); // Captions toggle
  9606. this.bind(elements.buttons.captions, 'click', function () {
  9607. return player.toggleCaptions();
  9608. }); // Download
  9609. this.bind(elements.buttons.download, 'click', function () {
  9610. triggerEvent.call(player, player.media, 'download');
  9611. }, 'download'); // Fullscreen toggle
  9612. this.bind(elements.buttons.fullscreen, 'click', function () {
  9613. player.fullscreen.toggle();
  9614. }, 'fullscreen'); // Picture-in-Picture
  9615. this.bind(elements.buttons.pip, 'click', function () {
  9616. player.pip = 'toggle';
  9617. }, 'pip'); // Airplay
  9618. this.bind(elements.buttons.airplay, 'click', player.airplay, 'airplay'); // Settings menu - click toggle
  9619. this.bind(elements.buttons.settings, 'click', function (event) {
  9620. // Prevent the document click listener closing the menu
  9621. event.stopPropagation();
  9622. event.preventDefault();
  9623. controls.toggleMenu.call(player, event);
  9624. }, null, false); // Can't be passive as we're preventing default
  9625. // Settings menu - keyboard toggle
  9626. // We have to bind to keyup otherwise Firefox triggers a click when a keydown event handler shifts focus
  9627. // https://bugzilla.mozilla.org/show_bug.cgi?id=1220143
  9628. this.bind(elements.buttons.settings, 'keyup', function (event) {
  9629. var code = event.which; // We only care about space and return
  9630. if (![13, 32].includes(code)) {
  9631. return;
  9632. } // Because return triggers a click anyway, all we need to do is set focus
  9633. if (code === 13) {
  9634. controls.focusFirstMenuItem.call(player, null, true);
  9635. return;
  9636. } // Prevent scroll
  9637. event.preventDefault(); // Prevent playing video (Firefox)
  9638. event.stopPropagation(); // Toggle menu
  9639. controls.toggleMenu.call(player, event);
  9640. }, null, false // Can't be passive as we're preventing default
  9641. ); // Escape closes menu
  9642. this.bind(elements.settings.menu, 'keydown', function (event) {
  9643. if (event.which === 27) {
  9644. controls.toggleMenu.call(player, event);
  9645. }
  9646. }); // Set range input alternative "value", which matches the tooltip time (#954)
  9647. this.bind(elements.inputs.seek, 'mousedown mousemove', function (event) {
  9648. var rect = elements.progress.getBoundingClientRect();
  9649. var percent = 100 / rect.width * (event.pageX - rect.left);
  9650. event.currentTarget.setAttribute('seek-value', percent);
  9651. }); // Pause while seeking
  9652. this.bind(elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', function (event) {
  9653. var seek = event.currentTarget;
  9654. var code = event.keyCode ? event.keyCode : event.which;
  9655. var attribute = 'play-on-seeked';
  9656. if (is$1.keyboardEvent(event) && code !== 39 && code !== 37) {
  9657. return;
  9658. } // Record seek time so we can prevent hiding controls for a few seconds after seek
  9659. player.lastSeekTime = Date.now(); // Was playing before?
  9660. var play = seek.hasAttribute(attribute); // Done seeking
  9661. var done = ['mouseup', 'touchend', 'keyup'].includes(event.type); // If we're done seeking and it was playing, resume playback
  9662. if (play && done) {
  9663. seek.removeAttribute(attribute);
  9664. silencePromise(player.play());
  9665. } else if (!done && player.playing) {
  9666. seek.setAttribute(attribute, '');
  9667. player.pause();
  9668. }
  9669. }); // Fix range inputs on iOS
  9670. // Super weird iOS bug where after you interact with an <input type="range">,
  9671. // it takes over further interactions on the page. This is a hack
  9672. if (browser.isIos) {
  9673. var inputs = getElements.call(player, 'input[type="range"]');
  9674. Array.from(inputs).forEach(function (input) {
  9675. return _this3.bind(input, inputEvent, function (event) {
  9676. return repaint(event.target);
  9677. });
  9678. });
  9679. } // Seek
  9680. this.bind(elements.inputs.seek, inputEvent, function (event) {
  9681. var seek = event.currentTarget; // If it exists, use seek-value instead of "value" for consistency with tooltip time (#954)
  9682. var seekTo = seek.getAttribute('seek-value');
  9683. if (is$1.empty(seekTo)) {
  9684. seekTo = seek.value;
  9685. }
  9686. seek.removeAttribute('seek-value');
  9687. player.currentTime = seekTo / seek.max * player.duration;
  9688. }, 'seek'); // Seek tooltip
  9689. this.bind(elements.progress, 'mouseenter mouseleave mousemove', function (event) {
  9690. return controls.updateSeekTooltip.call(player, event);
  9691. }); // Preview thumbnails plugin
  9692. // TODO: Really need to work on some sort of plug-in wide event bus or pub-sub for this
  9693. this.bind(elements.progress, 'mousemove touchmove', function (event) {
  9694. var previewThumbnails = player.previewThumbnails;
  9695. if (previewThumbnails && previewThumbnails.loaded) {
  9696. previewThumbnails.startMove(event);
  9697. }
  9698. }); // Hide thumbnail preview - on mouse click, mouse leave, and video play/seek. All four are required, e.g., for buffering
  9699. this.bind(elements.progress, 'mouseleave touchend click', function () {
  9700. var previewThumbnails = player.previewThumbnails;
  9701. if (previewThumbnails && previewThumbnails.loaded) {
  9702. previewThumbnails.endMove(false, true);
  9703. }
  9704. }); // Show scrubbing preview
  9705. this.bind(elements.progress, 'mousedown touchstart', function (event) {
  9706. var previewThumbnails = player.previewThumbnails;
  9707. if (previewThumbnails && previewThumbnails.loaded) {
  9708. previewThumbnails.startScrubbing(event);
  9709. }
  9710. });
  9711. this.bind(elements.progress, 'mouseup touchend', function (event) {
  9712. var previewThumbnails = player.previewThumbnails;
  9713. if (previewThumbnails && previewThumbnails.loaded) {
  9714. previewThumbnails.endScrubbing(event);
  9715. }
  9716. }); // Polyfill for lower fill in <input type="range"> for webkit
  9717. if (browser.isWebkit) {
  9718. Array.from(getElements.call(player, 'input[type="range"]')).forEach(function (element) {
  9719. _this3.bind(element, 'input', function (event) {
  9720. return controls.updateRangeFill.call(player, event.target);
  9721. });
  9722. });
  9723. } // Current time invert
  9724. // Only if one time element is used for both currentTime and duration
  9725. if (player.config.toggleInvert && !is$1.element(elements.display.duration)) {
  9726. this.bind(elements.display.currentTime, 'click', function () {
  9727. // Do nothing if we're at the start
  9728. if (player.currentTime === 0) {
  9729. return;
  9730. }
  9731. player.config.invertTime = !player.config.invertTime;
  9732. controls.timeUpdate.call(player);
  9733. });
  9734. } // Volume
  9735. this.bind(elements.inputs.volume, inputEvent, function (event) {
  9736. player.volume = event.target.value;
  9737. }, 'volume'); // Update controls.hover state (used for ui.toggleControls to avoid hiding when interacting)
  9738. this.bind(elements.controls, 'mouseenter mouseleave', function (event) {
  9739. elements.controls.hover = !player.touch && event.type === 'mouseenter';
  9740. }); // Also update controls.hover state for any non-player children of fullscreen element (as above)
  9741. if (elements.fullscreen) {
  9742. Array.from(elements.fullscreen.children).filter(function (c) {
  9743. return !c.contains(elements.container);
  9744. }).forEach(function (child) {
  9745. _this3.bind(child, 'mouseenter mouseleave', function (event) {
  9746. elements.controls.hover = !player.touch && event.type === 'mouseenter';
  9747. });
  9748. });
  9749. } // Update controls.pressed state (used for ui.toggleControls to avoid hiding when interacting)
  9750. this.bind(elements.controls, 'mousedown mouseup touchstart touchend touchcancel', function (event) {
  9751. elements.controls.pressed = ['mousedown', 'touchstart'].includes(event.type);
  9752. }); // Show controls when they receive focus (e.g., when using keyboard tab key)
  9753. this.bind(elements.controls, 'focusin', function () {
  9754. var config = player.config,
  9755. timers = player.timers; // Skip transition to prevent focus from scrolling the parent element
  9756. toggleClass(elements.controls, config.classNames.noTransition, true); // Toggle
  9757. ui.toggleControls.call(player, true); // Restore transition
  9758. setTimeout(function () {
  9759. toggleClass(elements.controls, config.classNames.noTransition, false);
  9760. }, 0); // Delay a little more for mouse users
  9761. var delay = _this3.touch ? 3000 : 4000; // Clear timer
  9762. clearTimeout(timers.controls); // Hide again after delay
  9763. timers.controls = setTimeout(function () {
  9764. return ui.toggleControls.call(player, false);
  9765. }, delay);
  9766. }); // Mouse wheel for volume
  9767. this.bind(elements.inputs.volume, 'wheel', function (event) {
  9768. // Detect "natural" scroll - suppored on OS X Safari only
  9769. // Other browsers on OS X will be inverted until support improves
  9770. var inverted = event.webkitDirectionInvertedFromDevice; // Get delta from event. Invert if `inverted` is true
  9771. var _map = [event.deltaX, -event.deltaY].map(function (value) {
  9772. return inverted ? -value : value;
  9773. }),
  9774. _map2 = _slicedToArray(_map, 2),
  9775. x = _map2[0],
  9776. y = _map2[1]; // Using the biggest delta, normalize to 1 or -1 (or 0 if no delta)
  9777. var direction = Math.sign(Math.abs(x) > Math.abs(y) ? x : y); // Change the volume by 2%
  9778. player.increaseVolume(direction / 50); // Don't break page scrolling at max and min
  9779. var volume = player.media.volume;
  9780. if (direction === 1 && volume < 1 || direction === -1 && volume > 0) {
  9781. event.preventDefault();
  9782. }
  9783. }, 'volume', false);
  9784. }
  9785. }]);
  9786. return Listeners;
  9787. }();
  9788. var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('splice');
  9789. var USES_TO_LENGTH$a = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 });
  9790. var max$3 = Math.max;
  9791. var min$5 = Math.min;
  9792. var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF;
  9793. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  9794. // `Array.prototype.splice` method
  9795. // https://tc39.github.io/ecma262/#sec-array.prototype.splice
  9796. // with adding support of @@species
  9797. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 || !USES_TO_LENGTH$a }, {
  9798. splice: function splice(start, deleteCount /* , ...items */) {
  9799. var O = toObject(this);
  9800. var len = toLength(O.length);
  9801. var actualStart = toAbsoluteIndex(start, len);
  9802. var argumentsLength = arguments.length;
  9803. var insertCount, actualDeleteCount, A, k, from, to;
  9804. if (argumentsLength === 0) {
  9805. insertCount = actualDeleteCount = 0;
  9806. } else if (argumentsLength === 1) {
  9807. insertCount = 0;
  9808. actualDeleteCount = len - actualStart;
  9809. } else {
  9810. insertCount = argumentsLength - 2;
  9811. actualDeleteCount = min$5(max$3(toInteger(deleteCount), 0), len - actualStart);
  9812. }
  9813. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$1) {
  9814. throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  9815. }
  9816. A = arraySpeciesCreate(O, actualDeleteCount);
  9817. for (k = 0; k < actualDeleteCount; k++) {
  9818. from = actualStart + k;
  9819. if (from in O) createProperty(A, k, O[from]);
  9820. }
  9821. A.length = actualDeleteCount;
  9822. if (insertCount < actualDeleteCount) {
  9823. for (k = actualStart; k < len - actualDeleteCount; k++) {
  9824. from = k + actualDeleteCount;
  9825. to = k + insertCount;
  9826. if (from in O) O[to] = O[from];
  9827. else delete O[to];
  9828. }
  9829. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  9830. } else if (insertCount > actualDeleteCount) {
  9831. for (k = len - actualDeleteCount; k > actualStart; k--) {
  9832. from = k + actualDeleteCount - 1;
  9833. to = k + insertCount - 1;
  9834. if (from in O) O[to] = O[from];
  9835. else delete O[to];
  9836. }
  9837. }
  9838. for (k = 0; k < insertCount; k++) {
  9839. O[k + actualStart] = arguments[k + 2];
  9840. }
  9841. O.length = len - actualDeleteCount + insertCount;
  9842. return A;
  9843. }
  9844. });
  9845. var loadjs_umd = createCommonjsModule(function (module, exports) {
  9846. (function (root, factory) {
  9847. {
  9848. module.exports = factory();
  9849. }
  9850. })(commonjsGlobal, function () {
  9851. /**
  9852. * Global dependencies.
  9853. * @global {Object} document - DOM
  9854. */
  9855. var devnull = function devnull() {},
  9856. bundleIdCache = {},
  9857. bundleResultCache = {},
  9858. bundleCallbackQueue = {};
  9859. /**
  9860. * Subscribe to bundle load event.
  9861. * @param {string[]} bundleIds - Bundle ids
  9862. * @param {Function} callbackFn - The callback function
  9863. */
  9864. function subscribe(bundleIds, callbackFn) {
  9865. // listify
  9866. bundleIds = bundleIds.push ? bundleIds : [bundleIds];
  9867. var depsNotFound = [],
  9868. i = bundleIds.length,
  9869. numWaiting = i,
  9870. fn,
  9871. bundleId,
  9872. r,
  9873. q; // define callback function
  9874. fn = function fn(bundleId, pathsNotFound) {
  9875. if (pathsNotFound.length) depsNotFound.push(bundleId);
  9876. numWaiting--;
  9877. if (!numWaiting) callbackFn(depsNotFound);
  9878. }; // register callback
  9879. while (i--) {
  9880. bundleId = bundleIds[i]; // execute callback if in result cache
  9881. r = bundleResultCache[bundleId];
  9882. if (r) {
  9883. fn(bundleId, r);
  9884. continue;
  9885. } // add to callback queue
  9886. q = bundleCallbackQueue[bundleId] = bundleCallbackQueue[bundleId] || [];
  9887. q.push(fn);
  9888. }
  9889. }
  9890. /**
  9891. * Publish bundle load event.
  9892. * @param {string} bundleId - Bundle id
  9893. * @param {string[]} pathsNotFound - List of files not found
  9894. */
  9895. function publish(bundleId, pathsNotFound) {
  9896. // exit if id isn't defined
  9897. if (!bundleId) return;
  9898. var q = bundleCallbackQueue[bundleId]; // cache result
  9899. bundleResultCache[bundleId] = pathsNotFound; // exit if queue is empty
  9900. if (!q) return; // empty callback queue
  9901. while (q.length) {
  9902. q[0](bundleId, pathsNotFound);
  9903. q.splice(0, 1);
  9904. }
  9905. }
  9906. /**
  9907. * Execute callbacks.
  9908. * @param {Object or Function} args - The callback args
  9909. * @param {string[]} depsNotFound - List of dependencies not found
  9910. */
  9911. function executeCallbacks(args, depsNotFound) {
  9912. // accept function as argument
  9913. if (args.call) args = {
  9914. success: args
  9915. }; // success and error callbacks
  9916. if (depsNotFound.length) (args.error || devnull)(depsNotFound);else (args.success || devnull)(args);
  9917. }
  9918. /**
  9919. * Load individual file.
  9920. * @param {string} path - The file path
  9921. * @param {Function} callbackFn - The callback function
  9922. */
  9923. function loadFile(path, callbackFn, args, numTries) {
  9924. var doc = document,
  9925. async = args.async,
  9926. maxTries = (args.numRetries || 0) + 1,
  9927. beforeCallbackFn = args.before || devnull,
  9928. pathname = path.replace(/[\?|#].*$/, ''),
  9929. pathStripped = path.replace(/^(css|img)!/, ''),
  9930. isLegacyIECss,
  9931. e;
  9932. numTries = numTries || 0;
  9933. if (/(^css!|\.css$)/.test(pathname)) {
  9934. // css
  9935. e = doc.createElement('link');
  9936. e.rel = 'stylesheet';
  9937. e.href = pathStripped; // tag IE9+
  9938. isLegacyIECss = 'hideFocus' in e; // use preload in IE Edge (to detect load errors)
  9939. if (isLegacyIECss && e.relList) {
  9940. isLegacyIECss = 0;
  9941. e.rel = 'preload';
  9942. e.as = 'style';
  9943. }
  9944. } else if (/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(pathname)) {
  9945. // image
  9946. e = doc.createElement('img');
  9947. e.src = pathStripped;
  9948. } else {
  9949. // javascript
  9950. e = doc.createElement('script');
  9951. e.src = path;
  9952. e.async = async === undefined ? true : async;
  9953. }
  9954. e.onload = e.onerror = e.onbeforeload = function (ev) {
  9955. var result = ev.type[0]; // treat empty stylesheets as failures to get around lack of onerror
  9956. // support in IE9-11
  9957. if (isLegacyIECss) {
  9958. try {
  9959. if (!e.sheet.cssText.length) result = 'e';
  9960. } catch (x) {
  9961. // sheets objects created from load errors don't allow access to
  9962. // `cssText` (unless error is Code:18 SecurityError)
  9963. if (x.code != 18) result = 'e';
  9964. }
  9965. } // handle retries in case of load failure
  9966. if (result == 'e') {
  9967. // increment counter
  9968. numTries += 1; // exit function and try again
  9969. if (numTries < maxTries) {
  9970. return loadFile(path, callbackFn, args, numTries);
  9971. }
  9972. } else if (e.rel == 'preload' && e.as == 'style') {
  9973. // activate preloaded stylesheets
  9974. return e.rel = 'stylesheet'; // jshint ignore:line
  9975. } // execute callback
  9976. callbackFn(path, result, ev.defaultPrevented);
  9977. }; // add to document (unless callback returns `false`)
  9978. if (beforeCallbackFn(path, e) !== false) doc.head.appendChild(e);
  9979. }
  9980. /**
  9981. * Load multiple files.
  9982. * @param {string[]} paths - The file paths
  9983. * @param {Function} callbackFn - The callback function
  9984. */
  9985. function loadFiles(paths, callbackFn, args) {
  9986. // listify paths
  9987. paths = paths.push ? paths : [paths];
  9988. var numWaiting = paths.length,
  9989. x = numWaiting,
  9990. pathsNotFound = [],
  9991. fn,
  9992. i; // define callback function
  9993. fn = function fn(path, result, defaultPrevented) {
  9994. // handle error
  9995. if (result == 'e') pathsNotFound.push(path); // handle beforeload event. If defaultPrevented then that means the load
  9996. // will be blocked (ex. Ghostery/ABP on Safari)
  9997. if (result == 'b') {
  9998. if (defaultPrevented) pathsNotFound.push(path);else return;
  9999. }
  10000. numWaiting--;
  10001. if (!numWaiting) callbackFn(pathsNotFound);
  10002. }; // load scripts
  10003. for (i = 0; i < x; i++) {
  10004. loadFile(paths[i], fn, args);
  10005. }
  10006. }
  10007. /**
  10008. * Initiate script load and register bundle.
  10009. * @param {(string|string[])} paths - The file paths
  10010. * @param {(string|Function|Object)} [arg1] - The (1) bundleId or (2) success
  10011. * callback or (3) object literal with success/error arguments, numRetries,
  10012. * etc.
  10013. * @param {(Function|Object)} [arg2] - The (1) success callback or (2) object
  10014. * literal with success/error arguments, numRetries, etc.
  10015. */
  10016. function loadjs(paths, arg1, arg2) {
  10017. var bundleId, args; // bundleId (if string)
  10018. if (arg1 && arg1.trim) bundleId = arg1; // args (default is {})
  10019. args = (bundleId ? arg2 : arg1) || {}; // throw error if bundle is already defined
  10020. if (bundleId) {
  10021. if (bundleId in bundleIdCache) {
  10022. throw "LoadJS";
  10023. } else {
  10024. bundleIdCache[bundleId] = true;
  10025. }
  10026. }
  10027. function loadFn(resolve, reject) {
  10028. loadFiles(paths, function (pathsNotFound) {
  10029. // execute callbacks
  10030. executeCallbacks(args, pathsNotFound); // resolve Promise
  10031. if (resolve) {
  10032. executeCallbacks({
  10033. success: resolve,
  10034. error: reject
  10035. }, pathsNotFound);
  10036. } // publish bundle load event
  10037. publish(bundleId, pathsNotFound);
  10038. }, args);
  10039. }
  10040. if (args.returnPromise) return new Promise(loadFn);else loadFn();
  10041. }
  10042. /**
  10043. * Execute callbacks when dependencies have been satisfied.
  10044. * @param {(string|string[])} deps - List of bundle ids
  10045. * @param {Object} args - success/error arguments
  10046. */
  10047. loadjs.ready = function ready(deps, args) {
  10048. // subscribe to bundle load event
  10049. subscribe(deps, function (depsNotFound) {
  10050. // execute callbacks
  10051. executeCallbacks(args, depsNotFound);
  10052. });
  10053. return loadjs;
  10054. };
  10055. /**
  10056. * Manually satisfy bundle dependencies.
  10057. * @param {string} bundleId - The bundle id
  10058. */
  10059. loadjs.done = function done(bundleId) {
  10060. publish(bundleId, []);
  10061. };
  10062. /**
  10063. * Reset loadjs dependencies statuses
  10064. */
  10065. loadjs.reset = function reset() {
  10066. bundleIdCache = {};
  10067. bundleResultCache = {};
  10068. bundleCallbackQueue = {};
  10069. };
  10070. /**
  10071. * Determine if bundle has already been defined
  10072. * @param String} bundleId - The bundle id
  10073. */
  10074. loadjs.isDefined = function isDefined(bundleId) {
  10075. return bundleId in bundleIdCache;
  10076. }; // export
  10077. return loadjs;
  10078. });
  10079. });
  10080. function loadScript(url) {
  10081. return new Promise(function (resolve, reject) {
  10082. loadjs_umd(url, {
  10083. success: resolve,
  10084. error: reject
  10085. });
  10086. });
  10087. }
  10088. function parseId(url) {
  10089. if (is$1.empty(url)) {
  10090. return null;
  10091. }
  10092. if (is$1.number(Number(url))) {
  10093. return url;
  10094. }
  10095. var regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
  10096. return url.match(regex) ? RegExp.$2 : url;
  10097. } // Set playback state and trigger change (only on actual change)
  10098. function assurePlaybackState(play) {
  10099. if (play && !this.embed.hasPlayed) {
  10100. this.embed.hasPlayed = true;
  10101. }
  10102. if (this.media.paused === play) {
  10103. this.media.paused = !play;
  10104. triggerEvent.call(this, this.media, play ? 'play' : 'pause');
  10105. }
  10106. }
  10107. var vimeo = {
  10108. setup: function setup() {
  10109. var player = this; // Add embed class for responsive
  10110. toggleClass(player.elements.wrapper, player.config.classNames.embed, true); // Set speed options from config
  10111. player.options.speed = player.config.speed.options; // Set intial ratio
  10112. setAspectRatio.call(player); // Load the SDK if not already
  10113. if (!is$1.object(window.Vimeo)) {
  10114. loadScript(player.config.urls.vimeo.sdk).then(function () {
  10115. vimeo.ready.call(player);
  10116. }).catch(function (error) {
  10117. player.debug.warn('Vimeo SDK (player.js) failed to load', error);
  10118. });
  10119. } else {
  10120. vimeo.ready.call(player);
  10121. }
  10122. },
  10123. // API Ready
  10124. ready: function ready() {
  10125. var _this = this;
  10126. var player = this;
  10127. var config = player.config.vimeo;
  10128. var premium = config.premium,
  10129. referrerPolicy = config.referrerPolicy,
  10130. frameParams = _objectWithoutProperties(config, ["premium", "referrerPolicy"]); // If the owner has a pro or premium account then we can hide controls etc
  10131. if (premium) {
  10132. Object.assign(frameParams, {
  10133. controls: false,
  10134. sidedock: false
  10135. });
  10136. } // Get Vimeo params for the iframe
  10137. var params = buildUrlParams(_objectSpread2({
  10138. loop: player.config.loop.active,
  10139. autoplay: player.autoplay,
  10140. muted: player.muted,
  10141. gesture: 'media',
  10142. playsinline: !this.config.fullscreen.iosNative
  10143. }, frameParams)); // Get the source URL or ID
  10144. var source = player.media.getAttribute('src'); // Get from <div> if needed
  10145. if (is$1.empty(source)) {
  10146. source = player.media.getAttribute(player.config.attributes.embed.id);
  10147. }
  10148. var id = parseId(source); // Build an iframe
  10149. var iframe = createElement('iframe');
  10150. var src = format(player.config.urls.vimeo.iframe, id, params);
  10151. iframe.setAttribute('src', src);
  10152. iframe.setAttribute('allowfullscreen', '');
  10153. iframe.setAttribute('allow', 'autoplay,fullscreen,picture-in-picture'); // Set the referrer policy if required
  10154. if (!is$1.empty(referrerPolicy)) {
  10155. iframe.setAttribute('referrerPolicy', referrerPolicy);
  10156. } // Inject the package
  10157. var poster = player.poster;
  10158. if (premium) {
  10159. iframe.setAttribute('data-poster', poster);
  10160. player.media = replaceElement(iframe, player.media);
  10161. } else {
  10162. var wrapper = createElement('div', {
  10163. class: player.config.classNames.embedContainer,
  10164. 'data-poster': poster
  10165. });
  10166. wrapper.appendChild(iframe);
  10167. player.media = replaceElement(wrapper, player.media);
  10168. } // Get poster image
  10169. fetch(format(player.config.urls.vimeo.api, id), 'json').then(function (response) {
  10170. if (is$1.empty(response)) {
  10171. return;
  10172. } // Get the URL for thumbnail
  10173. var url = new URL(response[0].thumbnail_large); // Get original image
  10174. url.pathname = "".concat(url.pathname.split('_')[0], ".jpg"); // Set and show poster
  10175. ui.setPoster.call(player, url.href).catch(function () {});
  10176. }); // Setup instance
  10177. // https://github.com/vimeo/player.js
  10178. player.embed = new window.Vimeo.Player(iframe, {
  10179. autopause: player.config.autopause,
  10180. muted: player.muted
  10181. });
  10182. player.media.paused = true;
  10183. player.media.currentTime = 0; // Disable native text track rendering
  10184. if (player.supported.ui) {
  10185. player.embed.disableTextTrack();
  10186. } // Create a faux HTML5 API using the Vimeo API
  10187. player.media.play = function () {
  10188. assurePlaybackState.call(player, true);
  10189. return player.embed.play();
  10190. };
  10191. player.media.pause = function () {
  10192. assurePlaybackState.call(player, false);
  10193. return player.embed.pause();
  10194. };
  10195. player.media.stop = function () {
  10196. player.pause();
  10197. player.currentTime = 0;
  10198. }; // Seeking
  10199. var currentTime = player.media.currentTime;
  10200. Object.defineProperty(player.media, 'currentTime', {
  10201. get: function get() {
  10202. return currentTime;
  10203. },
  10204. set: function set(time) {
  10205. // Vimeo will automatically play on seek if the video hasn't been played before
  10206. // Get current paused state and volume etc
  10207. var embed = player.embed,
  10208. media = player.media,
  10209. paused = player.paused,
  10210. volume = player.volume;
  10211. var restorePause = paused && !embed.hasPlayed; // Set seeking state and trigger event
  10212. media.seeking = true;
  10213. triggerEvent.call(player, media, 'seeking'); // If paused, mute until seek is complete
  10214. Promise.resolve(restorePause && embed.setVolume(0)) // Seek
  10215. .then(function () {
  10216. return embed.setCurrentTime(time);
  10217. }) // Restore paused
  10218. .then(function () {
  10219. return restorePause && embed.pause();
  10220. }) // Restore volume
  10221. .then(function () {
  10222. return restorePause && embed.setVolume(volume);
  10223. }).catch(function () {// Do nothing
  10224. });
  10225. }
  10226. }); // Playback speed
  10227. var speed = player.config.speed.selected;
  10228. Object.defineProperty(player.media, 'playbackRate', {
  10229. get: function get() {
  10230. return speed;
  10231. },
  10232. set: function set(input) {
  10233. player.embed.setPlaybackRate(input).then(function () {
  10234. speed = input;
  10235. triggerEvent.call(player, player.media, 'ratechange');
  10236. }).catch(function () {
  10237. // Cannot set Playback Rate, Video is probably not on Pro account
  10238. player.options.speed = [1];
  10239. });
  10240. }
  10241. }); // Volume
  10242. var volume = player.config.volume;
  10243. Object.defineProperty(player.media, 'volume', {
  10244. get: function get() {
  10245. return volume;
  10246. },
  10247. set: function set(input) {
  10248. player.embed.setVolume(input).then(function () {
  10249. volume = input;
  10250. triggerEvent.call(player, player.media, 'volumechange');
  10251. });
  10252. }
  10253. }); // Muted
  10254. var muted = player.config.muted;
  10255. Object.defineProperty(player.media, 'muted', {
  10256. get: function get() {
  10257. return muted;
  10258. },
  10259. set: function set(input) {
  10260. var toggle = is$1.boolean(input) ? input : false;
  10261. player.embed.setVolume(toggle ? 0 : player.config.volume).then(function () {
  10262. muted = toggle;
  10263. triggerEvent.call(player, player.media, 'volumechange');
  10264. });
  10265. }
  10266. }); // Loop
  10267. var loop = player.config.loop;
  10268. Object.defineProperty(player.media, 'loop', {
  10269. get: function get() {
  10270. return loop;
  10271. },
  10272. set: function set(input) {
  10273. var toggle = is$1.boolean(input) ? input : player.config.loop.active;
  10274. player.embed.setLoop(toggle).then(function () {
  10275. loop = toggle;
  10276. });
  10277. }
  10278. }); // Source
  10279. var currentSrc;
  10280. player.embed.getVideoUrl().then(function (value) {
  10281. currentSrc = value;
  10282. controls.setDownloadUrl.call(player);
  10283. }).catch(function (error) {
  10284. _this.debug.warn(error);
  10285. });
  10286. Object.defineProperty(player.media, 'currentSrc', {
  10287. get: function get() {
  10288. return currentSrc;
  10289. }
  10290. }); // Ended
  10291. Object.defineProperty(player.media, 'ended', {
  10292. get: function get() {
  10293. return player.currentTime === player.duration;
  10294. }
  10295. }); // Set aspect ratio based on video size
  10296. Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then(function (dimensions) {
  10297. var _dimensions = _slicedToArray(dimensions, 2),
  10298. width = _dimensions[0],
  10299. height = _dimensions[1];
  10300. player.embed.ratio = [width, height];
  10301. setAspectRatio.call(_this);
  10302. }); // Set autopause
  10303. player.embed.setAutopause(player.config.autopause).then(function (state) {
  10304. player.config.autopause = state;
  10305. }); // Get title
  10306. player.embed.getVideoTitle().then(function (title) {
  10307. player.config.title = title;
  10308. ui.setTitle.call(_this);
  10309. }); // Get current time
  10310. player.embed.getCurrentTime().then(function (value) {
  10311. currentTime = value;
  10312. triggerEvent.call(player, player.media, 'timeupdate');
  10313. }); // Get duration
  10314. player.embed.getDuration().then(function (value) {
  10315. player.media.duration = value;
  10316. triggerEvent.call(player, player.media, 'durationchange');
  10317. }); // Get captions
  10318. player.embed.getTextTracks().then(function (tracks) {
  10319. player.media.textTracks = tracks;
  10320. captions.setup.call(player);
  10321. });
  10322. player.embed.on('cuechange', function (_ref) {
  10323. var _ref$cues = _ref.cues,
  10324. cues = _ref$cues === void 0 ? [] : _ref$cues;
  10325. var strippedCues = cues.map(function (cue) {
  10326. return stripHTML(cue.text);
  10327. });
  10328. captions.updateCues.call(player, strippedCues);
  10329. });
  10330. player.embed.on('loaded', function () {
  10331. // Assure state and events are updated on autoplay
  10332. player.embed.getPaused().then(function (paused) {
  10333. assurePlaybackState.call(player, !paused);
  10334. if (!paused) {
  10335. triggerEvent.call(player, player.media, 'playing');
  10336. }
  10337. });
  10338. if (is$1.element(player.embed.element) && player.supported.ui) {
  10339. var frame = player.embed.element; // Fix keyboard focus issues
  10340. // https://github.com/sampotts/plyr/issues/317
  10341. frame.setAttribute('tabindex', -1);
  10342. }
  10343. });
  10344. player.embed.on('bufferstart', function () {
  10345. triggerEvent.call(player, player.media, 'waiting');
  10346. });
  10347. player.embed.on('bufferend', function () {
  10348. triggerEvent.call(player, player.media, 'playing');
  10349. });
  10350. player.embed.on('play', function () {
  10351. assurePlaybackState.call(player, true);
  10352. triggerEvent.call(player, player.media, 'playing');
  10353. });
  10354. player.embed.on('pause', function () {
  10355. assurePlaybackState.call(player, false);
  10356. });
  10357. player.embed.on('timeupdate', function (data) {
  10358. player.media.seeking = false;
  10359. currentTime = data.seconds;
  10360. triggerEvent.call(player, player.media, 'timeupdate');
  10361. });
  10362. player.embed.on('progress', function (data) {
  10363. player.media.buffered = data.percent;
  10364. triggerEvent.call(player, player.media, 'progress'); // Check all loaded
  10365. if (parseInt(data.percent, 10) === 1) {
  10366. triggerEvent.call(player, player.media, 'canplaythrough');
  10367. } // Get duration as if we do it before load, it gives an incorrect value
  10368. // https://github.com/sampotts/plyr/issues/891
  10369. player.embed.getDuration().then(function (value) {
  10370. if (value !== player.media.duration) {
  10371. player.media.duration = value;
  10372. triggerEvent.call(player, player.media, 'durationchange');
  10373. }
  10374. });
  10375. });
  10376. player.embed.on('seeked', function () {
  10377. player.media.seeking = false;
  10378. triggerEvent.call(player, player.media, 'seeked');
  10379. });
  10380. player.embed.on('ended', function () {
  10381. player.media.paused = true;
  10382. triggerEvent.call(player, player.media, 'ended');
  10383. });
  10384. player.embed.on('error', function (detail) {
  10385. player.media.error = detail;
  10386. triggerEvent.call(player, player.media, 'error');
  10387. }); // Rebuild UI
  10388. setTimeout(function () {
  10389. return ui.build.call(player);
  10390. }, 0);
  10391. }
  10392. };
  10393. function parseId$1(url) {
  10394. if (is$1.empty(url)) {
  10395. return null;
  10396. }
  10397. var regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
  10398. return url.match(regex) ? RegExp.$2 : url;
  10399. } // Set playback state and trigger change (only on actual change)
  10400. function assurePlaybackState$1(play) {
  10401. if (play && !this.embed.hasPlayed) {
  10402. this.embed.hasPlayed = true;
  10403. }
  10404. if (this.media.paused === play) {
  10405. this.media.paused = !play;
  10406. triggerEvent.call(this, this.media, play ? 'play' : 'pause');
  10407. }
  10408. }
  10409. function getHost$1(config) {
  10410. if (config.noCookie) {
  10411. return 'https://www.youtube-nocookie.com';
  10412. }
  10413. if (window.location.protocol === 'http:') {
  10414. return 'http://www.youtube.com';
  10415. } // Use YouTube's default
  10416. return undefined;
  10417. }
  10418. var youtube = {
  10419. setup: function setup() {
  10420. var _this = this;
  10421. // Add embed class for responsive
  10422. toggleClass(this.elements.wrapper, this.config.classNames.embed, true); // Setup API
  10423. if (is$1.object(window.YT) && is$1.function(window.YT.Player)) {
  10424. youtube.ready.call(this);
  10425. } else {
  10426. // Reference current global callback
  10427. var callback = window.onYouTubeIframeAPIReady; // Set callback to process queue
  10428. window.onYouTubeIframeAPIReady = function () {
  10429. // Call global callback if set
  10430. if (is$1.function(callback)) {
  10431. callback();
  10432. }
  10433. youtube.ready.call(_this);
  10434. }; // Load the SDK
  10435. loadScript(this.config.urls.youtube.sdk).catch(function (error) {
  10436. _this.debug.warn('YouTube API failed to load', error);
  10437. });
  10438. }
  10439. },
  10440. // Get the media title
  10441. getTitle: function getTitle(videoId) {
  10442. var _this2 = this;
  10443. var url = format(this.config.urls.youtube.api, videoId);
  10444. fetch(url).then(function (data) {
  10445. if (is$1.object(data)) {
  10446. var title = data.title,
  10447. height = data.height,
  10448. width = data.width; // Set title
  10449. _this2.config.title = title;
  10450. ui.setTitle.call(_this2); // Set aspect ratio
  10451. _this2.embed.ratio = [width, height];
  10452. }
  10453. setAspectRatio.call(_this2);
  10454. }).catch(function () {
  10455. // Set aspect ratio
  10456. setAspectRatio.call(_this2);
  10457. });
  10458. },
  10459. // API ready
  10460. ready: function ready() {
  10461. var player = this; // Ignore already setup (race condition)
  10462. var currentId = player.media && player.media.getAttribute('id');
  10463. if (!is$1.empty(currentId) && currentId.startsWith('youtube-')) {
  10464. return;
  10465. } // Get the source URL or ID
  10466. var source = player.media.getAttribute('src'); // Get from <div> if needed
  10467. if (is$1.empty(source)) {
  10468. source = player.media.getAttribute(this.config.attributes.embed.id);
  10469. } // Replace the <iframe> with a <div> due to YouTube API issues
  10470. var videoId = parseId$1(source);
  10471. var id = generateId(player.provider); // Get poster, if already set
  10472. var poster = player.poster; // Replace media element
  10473. var container = createElement('div', {
  10474. id: id,
  10475. 'data-poster': poster
  10476. });
  10477. player.media = replaceElement(container, player.media); // Id to poster wrapper
  10478. var posterSrc = function posterSrc(s) {
  10479. return "https://i.ytimg.com/vi/".concat(videoId, "/").concat(s, "default.jpg");
  10480. }; // Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide)
  10481. loadImage(posterSrc('maxres'), 121) // Higest quality and unpadded
  10482. .catch(function () {
  10483. return loadImage(posterSrc('sd'), 121);
  10484. }) // 480p padded 4:3
  10485. .catch(function () {
  10486. return loadImage(posterSrc('hq'));
  10487. }) // 360p padded 4:3. Always exists
  10488. .then(function (image) {
  10489. return ui.setPoster.call(player, image.src);
  10490. }).then(function (src) {
  10491. // If the image is padded, use background-size "cover" instead (like youtube does too with their posters)
  10492. if (!src.includes('maxres')) {
  10493. player.elements.poster.style.backgroundSize = 'cover';
  10494. }
  10495. }).catch(function () {});
  10496. var config = player.config.youtube; // Setup instance
  10497. // https://developers.google.com/youtube/iframe_api_reference
  10498. player.embed = new window.YT.Player(id, {
  10499. videoId: videoId,
  10500. host: getHost$1(config),
  10501. playerVars: extend({}, {
  10502. autoplay: player.config.autoplay ? 1 : 0,
  10503. // Autoplay
  10504. hl: player.config.hl,
  10505. // iframe interface language
  10506. controls: player.supported.ui ? 0 : 1,
  10507. // Only show controls if not fully supported
  10508. disablekb: 1,
  10509. // Disable keyboard as we handle it
  10510. playsinline: !player.config.fullscreen.iosNative ? 1 : 0,
  10511. // Allow iOS inline playback
  10512. // Captions are flaky on YouTube
  10513. cc_load_policy: player.captions.active ? 1 : 0,
  10514. cc_lang_pref: player.config.captions.language,
  10515. // Tracking for stats
  10516. widget_referrer: window ? window.location.href : null
  10517. }, config),
  10518. events: {
  10519. onError: function onError(event) {
  10520. // YouTube may fire onError twice, so only handle it once
  10521. if (!player.media.error) {
  10522. var code = event.data; // Messages copied from https://developers.google.com/youtube/iframe_api_reference#onError
  10523. var message = {
  10524. 2: 'The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.',
  10525. 5: 'The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.',
  10526. 100: 'The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.',
  10527. 101: 'The owner of the requested video does not allow it to be played in embedded players.',
  10528. 150: 'The owner of the requested video does not allow it to be played in embedded players.'
  10529. }[code] || 'An unknown error occured';
  10530. player.media.error = {
  10531. code: code,
  10532. message: message
  10533. };
  10534. triggerEvent.call(player, player.media, 'error');
  10535. }
  10536. },
  10537. onPlaybackRateChange: function onPlaybackRateChange(event) {
  10538. // Get the instance
  10539. var instance = event.target; // Get current speed
  10540. player.media.playbackRate = instance.getPlaybackRate();
  10541. triggerEvent.call(player, player.media, 'ratechange');
  10542. },
  10543. onReady: function onReady(event) {
  10544. // Bail if onReady has already been called. See issue #1108
  10545. if (is$1.function(player.media.play)) {
  10546. return;
  10547. } // Get the instance
  10548. var instance = event.target; // Get the title
  10549. youtube.getTitle.call(player, videoId); // Create a faux HTML5 API using the YouTube API
  10550. player.media.play = function () {
  10551. assurePlaybackState$1.call(player, true);
  10552. instance.playVideo();
  10553. };
  10554. player.media.pause = function () {
  10555. assurePlaybackState$1.call(player, false);
  10556. instance.pauseVideo();
  10557. };
  10558. player.media.stop = function () {
  10559. instance.stopVideo();
  10560. };
  10561. player.media.duration = instance.getDuration();
  10562. player.media.paused = true; // Seeking
  10563. player.media.currentTime = 0;
  10564. Object.defineProperty(player.media, 'currentTime', {
  10565. get: function get() {
  10566. return Number(instance.getCurrentTime());
  10567. },
  10568. set: function set(time) {
  10569. // If paused and never played, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
  10570. if (player.paused && !player.embed.hasPlayed) {
  10571. player.embed.mute();
  10572. } // Set seeking state and trigger event
  10573. player.media.seeking = true;
  10574. triggerEvent.call(player, player.media, 'seeking'); // Seek after events sent
  10575. instance.seekTo(time);
  10576. }
  10577. }); // Playback speed
  10578. Object.defineProperty(player.media, 'playbackRate', {
  10579. get: function get() {
  10580. return instance.getPlaybackRate();
  10581. },
  10582. set: function set(input) {
  10583. instance.setPlaybackRate(input);
  10584. }
  10585. }); // Volume
  10586. var volume = player.config.volume;
  10587. Object.defineProperty(player.media, 'volume', {
  10588. get: function get() {
  10589. return volume;
  10590. },
  10591. set: function set(input) {
  10592. volume = input;
  10593. instance.setVolume(volume * 100);
  10594. triggerEvent.call(player, player.media, 'volumechange');
  10595. }
  10596. }); // Muted
  10597. var muted = player.config.muted;
  10598. Object.defineProperty(player.media, 'muted', {
  10599. get: function get() {
  10600. return muted;
  10601. },
  10602. set: function set(input) {
  10603. var toggle = is$1.boolean(input) ? input : muted;
  10604. muted = toggle;
  10605. instance[toggle ? 'mute' : 'unMute']();
  10606. triggerEvent.call(player, player.media, 'volumechange');
  10607. }
  10608. }); // Source
  10609. Object.defineProperty(player.media, 'currentSrc', {
  10610. get: function get() {
  10611. return instance.getVideoUrl();
  10612. }
  10613. }); // Ended
  10614. Object.defineProperty(player.media, 'ended', {
  10615. get: function get() {
  10616. return player.currentTime === player.duration;
  10617. }
  10618. }); // Get available speeds
  10619. var speeds = instance.getAvailablePlaybackRates(); // Filter based on config
  10620. player.options.speed = speeds.filter(function (s) {
  10621. return player.config.speed.options.includes(s);
  10622. }); // Set the tabindex to avoid focus entering iframe
  10623. if (player.supported.ui) {
  10624. player.media.setAttribute('tabindex', -1);
  10625. }
  10626. triggerEvent.call(player, player.media, 'timeupdate');
  10627. triggerEvent.call(player, player.media, 'durationchange'); // Reset timer
  10628. clearInterval(player.timers.buffering); // Setup buffering
  10629. player.timers.buffering = setInterval(function () {
  10630. // Get loaded % from YouTube
  10631. player.media.buffered = instance.getVideoLoadedFraction(); // Trigger progress only when we actually buffer something
  10632. if (player.media.lastBuffered === null || player.media.lastBuffered < player.media.buffered) {
  10633. triggerEvent.call(player, player.media, 'progress');
  10634. } // Set last buffer point
  10635. player.media.lastBuffered = player.media.buffered; // Bail if we're at 100%
  10636. if (player.media.buffered === 1) {
  10637. clearInterval(player.timers.buffering); // Trigger event
  10638. triggerEvent.call(player, player.media, 'canplaythrough');
  10639. }
  10640. }, 200); // Rebuild UI
  10641. setTimeout(function () {
  10642. return ui.build.call(player);
  10643. }, 50);
  10644. },
  10645. onStateChange: function onStateChange(event) {
  10646. // Get the instance
  10647. var instance = event.target; // Reset timer
  10648. clearInterval(player.timers.playing);
  10649. var seeked = player.media.seeking && [1, 2].includes(event.data);
  10650. if (seeked) {
  10651. // Unset seeking and fire seeked event
  10652. player.media.seeking = false;
  10653. triggerEvent.call(player, player.media, 'seeked');
  10654. } // Handle events
  10655. // -1 Unstarted
  10656. // 0 Ended
  10657. // 1 Playing
  10658. // 2 Paused
  10659. // 3 Buffering
  10660. // 5 Video cued
  10661. switch (event.data) {
  10662. case -1:
  10663. // Update scrubber
  10664. triggerEvent.call(player, player.media, 'timeupdate'); // Get loaded % from YouTube
  10665. player.media.buffered = instance.getVideoLoadedFraction();
  10666. triggerEvent.call(player, player.media, 'progress');
  10667. break;
  10668. case 0:
  10669. assurePlaybackState$1.call(player, false); // YouTube doesn't support loop for a single video, so mimick it.
  10670. if (player.media.loop) {
  10671. // YouTube needs a call to `stopVideo` before playing again
  10672. instance.stopVideo();
  10673. instance.playVideo();
  10674. } else {
  10675. triggerEvent.call(player, player.media, 'ended');
  10676. }
  10677. break;
  10678. case 1:
  10679. // Restore paused state (YouTube starts playing on seek if the video hasn't been played yet)
  10680. if (!player.config.autoplay && player.media.paused && !player.embed.hasPlayed) {
  10681. player.media.pause();
  10682. } else {
  10683. assurePlaybackState$1.call(player, true);
  10684. triggerEvent.call(player, player.media, 'playing'); // Poll to get playback progress
  10685. player.timers.playing = setInterval(function () {
  10686. triggerEvent.call(player, player.media, 'timeupdate');
  10687. }, 50); // Check duration again due to YouTube bug
  10688. // https://github.com/sampotts/plyr/issues/374
  10689. // https://code.google.com/p/gdata-issues/issues/detail?id=8690
  10690. if (player.media.duration !== instance.getDuration()) {
  10691. player.media.duration = instance.getDuration();
  10692. triggerEvent.call(player, player.media, 'durationchange');
  10693. }
  10694. }
  10695. break;
  10696. case 2:
  10697. // Restore audio (YouTube starts playing on seek if the video hasn't been played yet)
  10698. if (!player.muted) {
  10699. player.embed.unMute();
  10700. }
  10701. assurePlaybackState$1.call(player, false);
  10702. break;
  10703. case 3:
  10704. // Trigger waiting event to add loading classes to container as the video buffers.
  10705. triggerEvent.call(player, player.media, 'waiting');
  10706. break;
  10707. }
  10708. triggerEvent.call(player, player.elements.container, 'statechange', false, {
  10709. code: event.data
  10710. });
  10711. }
  10712. }
  10713. });
  10714. }
  10715. };
  10716. var media = {
  10717. // Setup media
  10718. setup: function setup() {
  10719. // If there's no media, bail
  10720. if (!this.media) {
  10721. this.debug.warn('No media element found!');
  10722. return;
  10723. } // Add type class
  10724. toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', this.type), true); // Add provider class
  10725. toggleClass(this.elements.container, this.config.classNames.provider.replace('{0}', this.provider), true); // Add video class for embeds
  10726. // This will require changes if audio embeds are added
  10727. if (this.isEmbed) {
  10728. toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', 'video'), true);
  10729. } // Inject the player wrapper
  10730. if (this.isVideo) {
  10731. // Create the wrapper div
  10732. this.elements.wrapper = createElement('div', {
  10733. class: this.config.classNames.video
  10734. }); // Wrap the video in a container
  10735. wrap$1(this.media, this.elements.wrapper); // Poster image container
  10736. this.elements.poster = createElement('div', {
  10737. class: this.config.classNames.poster
  10738. });
  10739. this.elements.wrapper.appendChild(this.elements.poster);
  10740. }
  10741. if (this.isHTML5) {
  10742. html5.setup.call(this);
  10743. } else if (this.isYouTube) {
  10744. youtube.setup.call(this);
  10745. } else if (this.isVimeo) {
  10746. vimeo.setup.call(this);
  10747. }
  10748. }
  10749. };
  10750. var destroy = function destroy(instance) {
  10751. // Destroy our adsManager
  10752. if (instance.manager) {
  10753. instance.manager.destroy();
  10754. } // Destroy our adsManager
  10755. if (instance.elements.displayContainer) {
  10756. instance.elements.displayContainer.destroy();
  10757. }
  10758. instance.elements.container.remove();
  10759. };
  10760. var Ads = /*#__PURE__*/function () {
  10761. /**
  10762. * Ads constructor.
  10763. * @param {Object} player
  10764. * @return {Ads}
  10765. */
  10766. function Ads(player) {
  10767. var _this = this;
  10768. _classCallCheck(this, Ads);
  10769. this.player = player;
  10770. this.config = player.config.ads;
  10771. this.playing = false;
  10772. this.initialized = false;
  10773. this.elements = {
  10774. container: null,
  10775. displayContainer: null
  10776. };
  10777. this.manager = null;
  10778. this.loader = null;
  10779. this.cuePoints = null;
  10780. this.events = {};
  10781. this.safetyTimer = null;
  10782. this.countdownTimer = null; // Setup a promise to resolve when the IMA manager is ready
  10783. this.managerPromise = new Promise(function (resolve, reject) {
  10784. // The ad is loaded and ready
  10785. _this.on('loaded', resolve); // Ads failed
  10786. _this.on('error', reject);
  10787. });
  10788. this.load();
  10789. }
  10790. _createClass(Ads, [{
  10791. key: "load",
  10792. /**
  10793. * Load the IMA SDK
  10794. */
  10795. value: function load() {
  10796. var _this2 = this;
  10797. if (!this.enabled) {
  10798. return;
  10799. } // Check if the Google IMA3 SDK is loaded or load it ourselves
  10800. if (!is$1.object(window.google) || !is$1.object(window.google.ima)) {
  10801. loadScript(this.player.config.urls.googleIMA.sdk).then(function () {
  10802. _this2.ready();
  10803. }).catch(function () {
  10804. // Script failed to load or is blocked
  10805. _this2.trigger('error', new Error('Google IMA SDK failed to load'));
  10806. });
  10807. } else {
  10808. this.ready();
  10809. }
  10810. }
  10811. /**
  10812. * Get the ads instance ready
  10813. */
  10814. }, {
  10815. key: "ready",
  10816. value: function ready() {
  10817. var _this3 = this;
  10818. // Double check we're enabled
  10819. if (!this.enabled) {
  10820. destroy(this);
  10821. } // Start ticking our safety timer. If the whole advertisement
  10822. // thing doesn't resolve within our set time; we bail
  10823. this.startSafetyTimer(12000, 'ready()'); // Clear the safety timer
  10824. this.managerPromise.then(function () {
  10825. _this3.clearSafetyTimer('onAdsManagerLoaded()');
  10826. }); // Set listeners on the Plyr instance
  10827. this.listeners(); // Setup the IMA SDK
  10828. this.setupIMA();
  10829. } // Build the tag URL
  10830. }, {
  10831. key: "setupIMA",
  10832. /**
  10833. * In order for the SDK to display ads for our video, we need to tell it where to put them,
  10834. * so here we define our ad container. This div is set up to render on top of the video player.
  10835. * Using the code below, we tell the SDK to render ads within that div. We also provide a
  10836. * handle to the content video player - the SDK will poll the current time of our player to
  10837. * properly place mid-rolls. After we create the ad display container, we initialize it. On
  10838. * mobile devices, this initialization is done as the result of a user action.
  10839. */
  10840. value: function setupIMA() {
  10841. var _this4 = this;
  10842. // Create the container for our advertisements
  10843. this.elements.container = createElement('div', {
  10844. class: this.player.config.classNames.ads
  10845. });
  10846. this.player.elements.container.appendChild(this.elements.container); // So we can run VPAID2
  10847. google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED); // Set language
  10848. google.ima.settings.setLocale(this.player.config.ads.language); // Set playback for iOS10+
  10849. google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline); // We assume the adContainer is the video container of the plyr element that will house the ads
  10850. this.elements.displayContainer = new google.ima.AdDisplayContainer(this.elements.container, this.player.media); // Create ads loader
  10851. this.loader = new google.ima.AdsLoader(this.elements.displayContainer); // Listen and respond to ads loaded and error events
  10852. this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, function (event) {
  10853. return _this4.onAdsManagerLoaded(event);
  10854. }, false);
  10855. this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, function (error) {
  10856. return _this4.onAdError(error);
  10857. }, false); // Request video ads to be pre-loaded
  10858. this.requestAds();
  10859. }
  10860. /**
  10861. * Request advertisements
  10862. */
  10863. }, {
  10864. key: "requestAds",
  10865. value: function requestAds() {
  10866. var container = this.player.elements.container;
  10867. try {
  10868. // Request video ads
  10869. var request = new google.ima.AdsRequest();
  10870. request.adTagUrl = this.tagUrl; // Specify the linear and nonlinear slot sizes. This helps the SDK
  10871. // to select the correct creative if multiple are returned
  10872. request.linearAdSlotWidth = container.offsetWidth;
  10873. request.linearAdSlotHeight = container.offsetHeight;
  10874. request.nonLinearAdSlotWidth = container.offsetWidth;
  10875. request.nonLinearAdSlotHeight = container.offsetHeight; // We only overlay ads as we only support video.
  10876. request.forceNonLinearFullSlot = false; // Mute based on current state
  10877. request.setAdWillPlayMuted(!this.player.muted);
  10878. this.loader.requestAds(request);
  10879. } catch (e) {
  10880. this.onAdError(e);
  10881. }
  10882. }
  10883. /**
  10884. * Update the ad countdown
  10885. * @param {Boolean} start
  10886. */
  10887. }, {
  10888. key: "pollCountdown",
  10889. value: function pollCountdown() {
  10890. var _this5 = this;
  10891. var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10892. if (!start) {
  10893. clearInterval(this.countdownTimer);
  10894. this.elements.container.removeAttribute('data-badge-text');
  10895. return;
  10896. }
  10897. var update = function update() {
  10898. var time = formatTime(Math.max(_this5.manager.getRemainingTime(), 0));
  10899. var label = "".concat(i18n.get('advertisement', _this5.player.config), " - ").concat(time);
  10900. _this5.elements.container.setAttribute('data-badge-text', label);
  10901. };
  10902. this.countdownTimer = setInterval(update, 100);
  10903. }
  10904. /**
  10905. * This method is called whenever the ads are ready inside the AdDisplayContainer
  10906. * @param {Event} adsManagerLoadedEvent
  10907. */
  10908. }, {
  10909. key: "onAdsManagerLoaded",
  10910. value: function onAdsManagerLoaded(event) {
  10911. var _this6 = this;
  10912. // Load could occur after a source change (race condition)
  10913. if (!this.enabled) {
  10914. return;
  10915. } // Get the ads manager
  10916. var settings = new google.ima.AdsRenderingSettings(); // Tell the SDK to save and restore content video state on our behalf
  10917. settings.restoreCustomPlaybackStateOnAdBreakComplete = true;
  10918. settings.enablePreloading = true; // The SDK is polling currentTime on the contentPlayback. And needs a duration
  10919. // so it can determine when to start the mid- and post-roll
  10920. this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
  10921. this.cuePoints = this.manager.getCuePoints(); // Add listeners to the required events
  10922. // Advertisement error events
  10923. this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, function (error) {
  10924. return _this6.onAdError(error);
  10925. }); // Advertisement regular events
  10926. Object.keys(google.ima.AdEvent.Type).forEach(function (type) {
  10927. _this6.manager.addEventListener(google.ima.AdEvent.Type[type], function (e) {
  10928. return _this6.onAdEvent(e);
  10929. });
  10930. }); // Resolve our adsManager
  10931. this.trigger('loaded');
  10932. }
  10933. }, {
  10934. key: "addCuePoints",
  10935. value: function addCuePoints() {
  10936. var _this7 = this;
  10937. // Add advertisement cue's within the time line if available
  10938. if (!is$1.empty(this.cuePoints)) {
  10939. this.cuePoints.forEach(function (cuePoint) {
  10940. if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
  10941. var seekElement = _this7.player.elements.progress;
  10942. if (is$1.element(seekElement)) {
  10943. var cuePercentage = 100 / _this7.player.duration * cuePoint;
  10944. var cue = createElement('span', {
  10945. class: _this7.player.config.classNames.cues
  10946. });
  10947. cue.style.left = "".concat(cuePercentage.toString(), "%");
  10948. seekElement.appendChild(cue);
  10949. }
  10950. }
  10951. });
  10952. }
  10953. }
  10954. /**
  10955. * This is where all the event handling takes place. Retrieve the ad from the event. Some
  10956. * events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
  10957. * https://developers.google.com/interactive-media-ads/docs/sdks/html5/v3/apis#ima.AdEvent.Type
  10958. * @param {Event} event
  10959. */
  10960. }, {
  10961. key: "onAdEvent",
  10962. value: function onAdEvent(event) {
  10963. var _this8 = this;
  10964. var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
  10965. // don't have ad object associated
  10966. var ad = event.getAd();
  10967. var adData = event.getAdData(); // Proxy event
  10968. var dispatchEvent = function dispatchEvent(type) {
  10969. triggerEvent.call(_this8.player, _this8.player.media, "ads".concat(type.replace(/_/g, '').toLowerCase()));
  10970. }; // Bubble the event
  10971. dispatchEvent(event.type);
  10972. switch (event.type) {
  10973. case google.ima.AdEvent.Type.LOADED:
  10974. // This is the first event sent for an ad - it is possible to determine whether the
  10975. // ad is a video ad or an overlay
  10976. this.trigger('loaded'); // Start countdown
  10977. this.pollCountdown(true);
  10978. if (!ad.isLinear()) {
  10979. // Position AdDisplayContainer correctly for overlay
  10980. ad.width = container.offsetWidth;
  10981. ad.height = container.offsetHeight;
  10982. } // console.info('Ad type: ' + event.getAd().getAdPodInfo().getPodIndex());
  10983. // console.info('Ad time: ' + event.getAd().getAdPodInfo().getTimeOffset());
  10984. break;
  10985. case google.ima.AdEvent.Type.STARTED:
  10986. // Set volume to match player
  10987. this.manager.setVolume(this.player.volume);
  10988. break;
  10989. case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:
  10990. // All ads for the current videos are done. We can now request new advertisements
  10991. // in case the video is re-played
  10992. // TODO: Example for what happens when a next video in a playlist would be loaded.
  10993. // So here we load a new video when all ads are done.
  10994. // Then we load new ads within a new adsManager. When the video
  10995. // Is started - after - the ads are loaded, then we get ads.
  10996. // You can also easily test cancelling and reloading by running
  10997. // player.ads.cancel() and player.ads.play from the console I guess.
  10998. // this.player.source = {
  10999. // type: 'video',
  11000. // title: 'View From A Blue Moon',
  11001. // sources: [{
  11002. // src:
  11003. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4', type:
  11004. // 'video/mp4', }], poster:
  11005. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg', tracks:
  11006. // [ { kind: 'captions', label: 'English', srclang: 'en', src:
  11007. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
  11008. // default: true, }, { kind: 'captions', label: 'French', srclang: 'fr', src:
  11009. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt', }, ],
  11010. // };
  11011. // TODO: So there is still this thing where a video should only be allowed to start
  11012. // playing when the IMA SDK is ready or has failed
  11013. if (this.player.ended) {
  11014. this.loadAds();
  11015. } else {
  11016. // The SDK won't allow new ads to be called without receiving a contentComplete()
  11017. this.loader.contentComplete();
  11018. }
  11019. break;
  11020. case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:
  11021. // This event indicates the ad has started - the video player can adjust the UI,
  11022. // for example display a pause button and remaining time. Fired when content should
  11023. // be paused. This usually happens right before an ad is about to cover the content
  11024. this.pauseContent();
  11025. break;
  11026. case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:
  11027. // This event indicates the ad has finished - the video player can perform
  11028. // appropriate UI actions, such as removing the timer for remaining time detection.
  11029. // Fired when content should be resumed. This usually happens when an ad finishes
  11030. // or collapses
  11031. this.pollCountdown();
  11032. this.resumeContent();
  11033. break;
  11034. case google.ima.AdEvent.Type.LOG:
  11035. if (adData.adError) {
  11036. this.player.debug.warn("Non-fatal ad error: ".concat(adData.adError.getMessage()));
  11037. }
  11038. break;
  11039. }
  11040. }
  11041. /**
  11042. * Any ad error handling comes through here
  11043. * @param {Event} event
  11044. */
  11045. }, {
  11046. key: "onAdError",
  11047. value: function onAdError(event) {
  11048. this.cancel();
  11049. this.player.debug.warn('Ads error', event);
  11050. }
  11051. /**
  11052. * Setup hooks for Plyr and window events. This ensures
  11053. * the mid- and post-roll launch at the correct time. And
  11054. * resize the advertisement when the player resizes
  11055. */
  11056. }, {
  11057. key: "listeners",
  11058. value: function listeners() {
  11059. var _this9 = this;
  11060. var container = this.player.elements.container;
  11061. var time;
  11062. this.player.on('canplay', function () {
  11063. _this9.addCuePoints();
  11064. });
  11065. this.player.on('ended', function () {
  11066. _this9.loader.contentComplete();
  11067. });
  11068. this.player.on('timeupdate', function () {
  11069. time = _this9.player.currentTime;
  11070. });
  11071. this.player.on('seeked', function () {
  11072. var seekedTime = _this9.player.currentTime;
  11073. if (is$1.empty(_this9.cuePoints)) {
  11074. return;
  11075. }
  11076. _this9.cuePoints.forEach(function (cuePoint, index) {
  11077. if (time < cuePoint && cuePoint < seekedTime) {
  11078. _this9.manager.discardAdBreak();
  11079. _this9.cuePoints.splice(index, 1);
  11080. }
  11081. });
  11082. }); // Listen to the resizing of the window. And resize ad accordingly
  11083. // TODO: eventually implement ResizeObserver
  11084. window.addEventListener('resize', function () {
  11085. if (_this9.manager) {
  11086. _this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
  11087. }
  11088. });
  11089. }
  11090. /**
  11091. * Initialize the adsManager and start playing advertisements
  11092. */
  11093. }, {
  11094. key: "play",
  11095. value: function play() {
  11096. var _this10 = this;
  11097. var container = this.player.elements.container;
  11098. if (!this.managerPromise) {
  11099. this.resumeContent();
  11100. } // Play the requested advertisement whenever the adsManager is ready
  11101. this.managerPromise.then(function () {
  11102. // Set volume to match player
  11103. _this10.manager.setVolume(_this10.player.volume); // Initialize the container. Must be done via a user action on mobile devices
  11104. _this10.elements.displayContainer.initialize();
  11105. try {
  11106. if (!_this10.initialized) {
  11107. // Initialize the ads manager. Ad rules playlist will start at this time
  11108. _this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
  11109. // start at this time; the call will be ignored for ad rules
  11110. _this10.manager.start();
  11111. }
  11112. _this10.initialized = true;
  11113. } catch (adError) {
  11114. // An error may be thrown if there was a problem with the
  11115. // VAST response
  11116. _this10.onAdError(adError);
  11117. }
  11118. }).catch(function () {});
  11119. }
  11120. /**
  11121. * Resume our video
  11122. */
  11123. }, {
  11124. key: "resumeContent",
  11125. value: function resumeContent() {
  11126. // Hide the advertisement container
  11127. this.elements.container.style.zIndex = ''; // Ad is stopped
  11128. this.playing = false; // Play video
  11129. silencePromise(this.player.media.play());
  11130. }
  11131. /**
  11132. * Pause our video
  11133. */
  11134. }, {
  11135. key: "pauseContent",
  11136. value: function pauseContent() {
  11137. // Show the advertisement container
  11138. this.elements.container.style.zIndex = 3; // Ad is playing
  11139. this.playing = true; // Pause our video.
  11140. this.player.media.pause();
  11141. }
  11142. /**
  11143. * Destroy the adsManager so we can grab new ads after this. If we don't then we're not
  11144. * allowed to call new ads based on google policies, as they interpret this as an accidental
  11145. * video requests. https://developers.google.com/interactive-
  11146. * media-ads/docs/sdks/android/faq#8
  11147. */
  11148. }, {
  11149. key: "cancel",
  11150. value: function cancel() {
  11151. // Pause our video
  11152. if (this.initialized) {
  11153. this.resumeContent();
  11154. } // Tell our instance that we're done for now
  11155. this.trigger('error'); // Re-create our adsManager
  11156. this.loadAds();
  11157. }
  11158. /**
  11159. * Re-create our adsManager
  11160. */
  11161. }, {
  11162. key: "loadAds",
  11163. value: function loadAds() {
  11164. var _this11 = this;
  11165. // Tell our adsManager to go bye bye
  11166. this.managerPromise.then(function () {
  11167. // Destroy our adsManager
  11168. if (_this11.manager) {
  11169. _this11.manager.destroy();
  11170. } // Re-set our adsManager promises
  11171. _this11.managerPromise = new Promise(function (resolve) {
  11172. _this11.on('loaded', resolve);
  11173. _this11.player.debug.log(_this11.manager);
  11174. }); // Now that the manager has been destroyed set it to also be un-initialized
  11175. _this11.initialized = false; // Now request some new advertisements
  11176. _this11.requestAds();
  11177. }).catch(function () {});
  11178. }
  11179. /**
  11180. * Handles callbacks after an ad event was invoked
  11181. * @param {String} event - Event type
  11182. */
  11183. }, {
  11184. key: "trigger",
  11185. value: function trigger(event) {
  11186. var _this12 = this;
  11187. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  11188. args[_key - 1] = arguments[_key];
  11189. }
  11190. var handlers = this.events[event];
  11191. if (is$1.array(handlers)) {
  11192. handlers.forEach(function (handler) {
  11193. if (is$1.function(handler)) {
  11194. handler.apply(_this12, args);
  11195. }
  11196. });
  11197. }
  11198. }
  11199. /**
  11200. * Add event listeners
  11201. * @param {String} event - Event type
  11202. * @param {Function} callback - Callback for when event occurs
  11203. * @return {Ads}
  11204. */
  11205. }, {
  11206. key: "on",
  11207. value: function on(event, callback) {
  11208. if (!is$1.array(this.events[event])) {
  11209. this.events[event] = [];
  11210. }
  11211. this.events[event].push(callback);
  11212. return this;
  11213. }
  11214. /**
  11215. * Setup a safety timer for when the ad network doesn't respond for whatever reason.
  11216. * The advertisement has 12 seconds to get its things together. We stop this timer when the
  11217. * advertisement is playing, or when a user action is required to start, then we clear the
  11218. * timer on ad ready
  11219. * @param {Number} time
  11220. * @param {String} from
  11221. */
  11222. }, {
  11223. key: "startSafetyTimer",
  11224. value: function startSafetyTimer(time, from) {
  11225. var _this13 = this;
  11226. this.player.debug.log("Safety timer invoked from: ".concat(from));
  11227. this.safetyTimer = setTimeout(function () {
  11228. _this13.cancel();
  11229. _this13.clearSafetyTimer('startSafetyTimer()');
  11230. }, time);
  11231. }
  11232. /**
  11233. * Clear our safety timer(s)
  11234. * @param {String} from
  11235. */
  11236. }, {
  11237. key: "clearSafetyTimer",
  11238. value: function clearSafetyTimer(from) {
  11239. if (!is$1.nullOrUndefined(this.safetyTimer)) {
  11240. this.player.debug.log("Safety timer cleared from: ".concat(from));
  11241. clearTimeout(this.safetyTimer);
  11242. this.safetyTimer = null;
  11243. }
  11244. }
  11245. }, {
  11246. key: "enabled",
  11247. get: function get() {
  11248. var config = this.config;
  11249. return this.player.isHTML5 && this.player.isVideo && config.enabled && (!is$1.empty(config.publisherId) || is$1.url(config.tagUrl));
  11250. }
  11251. }, {
  11252. key: "tagUrl",
  11253. get: function get() {
  11254. var config = this.config;
  11255. if (is$1.url(config.tagUrl)) {
  11256. return config.tagUrl;
  11257. }
  11258. var params = {
  11259. AV_PUBLISHERID: '58c25bb0073ef448b1087ad6',
  11260. AV_CHANNELID: '5a0458dc28a06145e4519d21',
  11261. AV_URL: window.location.hostname,
  11262. cb: Date.now(),
  11263. AV_WIDTH: 640,
  11264. AV_HEIGHT: 480,
  11265. AV_CDIM2: config.publisherId
  11266. };
  11267. var base = 'https://go.aniview.com/api/adserver6/vast/';
  11268. return "".concat(base, "?").concat(buildUrlParams(params));
  11269. }
  11270. }]);
  11271. return Ads;
  11272. }();
  11273. var $findIndex = arrayIteration.findIndex;
  11274. var FIND_INDEX = 'findIndex';
  11275. var SKIPS_HOLES$1 = true;
  11276. var USES_TO_LENGTH$b = arrayMethodUsesToLength(FIND_INDEX);
  11277. // Shouldn't skip holes
  11278. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES$1 = false; });
  11279. // `Array.prototype.findIndex` method
  11280. // https://tc39.github.io/ecma262/#sec-array.prototype.findindex
  11281. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES$1 || !USES_TO_LENGTH$b }, {
  11282. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  11283. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  11284. }
  11285. });
  11286. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  11287. addToUnscopables(FIND_INDEX);
  11288. var min$6 = Math.min;
  11289. var nativeLastIndexOf = [].lastIndexOf;
  11290. var NEGATIVE_ZERO$1 = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
  11291. var STRICT_METHOD$6 = arrayMethodIsStrict('lastIndexOf');
  11292. // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
  11293. var USES_TO_LENGTH$c = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  11294. var FORCED$5 = NEGATIVE_ZERO$1 || !STRICT_METHOD$6 || !USES_TO_LENGTH$c;
  11295. // `Array.prototype.lastIndexOf` method implementation
  11296. // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
  11297. var arrayLastIndexOf = FORCED$5 ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
  11298. // convert -0 to +0
  11299. if (NEGATIVE_ZERO$1) return nativeLastIndexOf.apply(this, arguments) || 0;
  11300. var O = toIndexedObject(this);
  11301. var length = toLength(O.length);
  11302. var index = length - 1;
  11303. if (arguments.length > 1) index = min$6(index, toInteger(arguments[1]));
  11304. if (index < 0) index = length + index;
  11305. for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
  11306. return -1;
  11307. } : nativeLastIndexOf;
  11308. // `Array.prototype.lastIndexOf` method
  11309. // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
  11310. _export({ target: 'Array', proto: true, forced: arrayLastIndexOf !== [].lastIndexOf }, {
  11311. lastIndexOf: arrayLastIndexOf
  11312. });
  11313. var parseVtt = function parseVtt(vttDataString) {
  11314. var processedList = [];
  11315. var frames = vttDataString.split(/\r\n\r\n|\n\n|\r\r/);
  11316. frames.forEach(function (frame) {
  11317. var result = {};
  11318. var lines = frame.split(/\r\n|\n|\r/);
  11319. lines.forEach(function (line) {
  11320. if (!is$1.number(result.startTime)) {
  11321. // The line with start and end times on it is the first line of interest
  11322. var matchTimes = line.match(/([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/); // Note that this currently ignores caption formatting directives that are optionally on the end of this line - fine for non-captions VTT
  11323. if (matchTimes) {
  11324. result.startTime = Number(matchTimes[1] || 0) * 60 * 60 + Number(matchTimes[2]) * 60 + Number(matchTimes[3]) + Number("0.".concat(matchTimes[4]));
  11325. result.endTime = Number(matchTimes[6] || 0) * 60 * 60 + Number(matchTimes[7]) * 60 + Number(matchTimes[8]) + Number("0.".concat(matchTimes[9]));
  11326. }
  11327. } else if (!is$1.empty(line.trim()) && is$1.empty(result.text)) {
  11328. // If we already have the startTime, then we're definitely up to the text line(s)
  11329. var lineSplit = line.trim().split('#xywh=');
  11330. var _lineSplit = _slicedToArray(lineSplit, 1);
  11331. result.text = _lineSplit[0];
  11332. // If there's content in lineSplit[1], then we have sprites. If not, then it's just one frame per image
  11333. if (lineSplit[1]) {
  11334. var _lineSplit$1$split = lineSplit[1].split(',');
  11335. var _lineSplit$1$split2 = _slicedToArray(_lineSplit$1$split, 4);
  11336. result.x = _lineSplit$1$split2[0];
  11337. result.y = _lineSplit$1$split2[1];
  11338. result.w = _lineSplit$1$split2[2];
  11339. result.h = _lineSplit$1$split2[3];
  11340. }
  11341. }
  11342. });
  11343. if (result.text) {
  11344. processedList.push(result);
  11345. }
  11346. });
  11347. return processedList;
  11348. };
  11349. /**
  11350. * Preview thumbnails for seek hover and scrubbing
  11351. * Seeking: Hover over the seek bar (desktop only): shows a small preview container above the seek bar
  11352. * Scrubbing: Click and drag the seek bar (desktop and mobile): shows the preview image over the entire video, as if the video is scrubbing at very high speed
  11353. *
  11354. * Notes:
  11355. * - Thumbs are set via JS settings on Plyr init, not HTML5 'track' property. Using the track property would be a bit gross, because it doesn't support custom 'kinds'. kind=metadata might be used for something else, and we want to allow multiple thumbnails tracks. Tracks must have a unique combination of 'kind' and 'label'. We would have to do something like kind=metadata,label=thumbnails1 / kind=metadata,label=thumbnails2. Square peg, round hole
  11356. * - VTT info: the image URL is relative to the VTT, not the current document. But if the url starts with a slash, it will naturally be relative to the current domain. https://support.jwplayer.com/articles/how-to-add-preview-thumbnails
  11357. * - This implementation uses multiple separate img elements. Other implementations use background-image on one element. This would be nice and simple, but Firefox and Safari have flickering issues with replacing backgrounds of larger images. It seems that YouTube perhaps only avoids this because they don't have the option for high-res previews (even the fullscreen ones, when mousedown/seeking). Images appear over the top of each other, and previous ones are discarded once the new ones have been rendered
  11358. */
  11359. var fitRatio = function fitRatio(ratio, outer) {
  11360. var targetRatio = outer.width / outer.height;
  11361. var result = {};
  11362. if (ratio > targetRatio) {
  11363. result.width = outer.width;
  11364. result.height = 1 / ratio * outer.width;
  11365. } else {
  11366. result.height = outer.height;
  11367. result.width = ratio * outer.height;
  11368. }
  11369. return result;
  11370. };
  11371. var PreviewThumbnails = /*#__PURE__*/function () {
  11372. /**
  11373. * PreviewThumbnails constructor.
  11374. * @param {Plyr} player
  11375. * @return {PreviewThumbnails}
  11376. */
  11377. function PreviewThumbnails(player) {
  11378. _classCallCheck(this, PreviewThumbnails);
  11379. this.player = player;
  11380. this.thumbnails = [];
  11381. this.loaded = false;
  11382. this.lastMouseMoveTime = Date.now();
  11383. this.mouseDown = false;
  11384. this.loadedImages = [];
  11385. this.elements = {
  11386. thumb: {},
  11387. scrubbing: {}
  11388. };
  11389. this.load();
  11390. }
  11391. _createClass(PreviewThumbnails, [{
  11392. key: "load",
  11393. value: function load() {
  11394. var _this = this;
  11395. // Toggle the regular seek tooltip
  11396. if (this.player.elements.display.seekTooltip) {
  11397. this.player.elements.display.seekTooltip.hidden = this.enabled;
  11398. }
  11399. if (!this.enabled) {
  11400. return;
  11401. }
  11402. this.getThumbnails().then(function () {
  11403. if (!_this.enabled) {
  11404. return;
  11405. } // Render DOM elements
  11406. _this.render(); // Check to see if thumb container size was specified manually in CSS
  11407. _this.determineContainerAutoSizing();
  11408. _this.loaded = true;
  11409. });
  11410. } // Download VTT files and parse them
  11411. }, {
  11412. key: "getThumbnails",
  11413. value: function getThumbnails() {
  11414. var _this2 = this;
  11415. return new Promise(function (resolve) {
  11416. var src = _this2.player.config.previewThumbnails.src;
  11417. if (is$1.empty(src)) {
  11418. throw new Error('Missing previewThumbnails.src config attribute');
  11419. } // Resolve promise
  11420. var sortAndResolve = function sortAndResolve() {
  11421. // Sort smallest to biggest (e.g., [120p, 480p, 1080p])
  11422. _this2.thumbnails.sort(function (x, y) {
  11423. return x.height - y.height;
  11424. });
  11425. _this2.player.debug.log('Preview thumbnails', _this2.thumbnails);
  11426. resolve();
  11427. }; // Via callback()
  11428. if (is$1.function(src)) {
  11429. src(function (thumbnails) {
  11430. _this2.thumbnails = thumbnails;
  11431. sortAndResolve();
  11432. });
  11433. } // VTT urls
  11434. else {
  11435. // If string, convert into single-element list
  11436. var urls = is$1.string(src) ? [src] : src; // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails
  11437. var promises = urls.map(function (u) {
  11438. return _this2.getThumbnail(u);
  11439. }); // Resolve
  11440. Promise.all(promises).then(sortAndResolve);
  11441. }
  11442. });
  11443. } // Process individual VTT file
  11444. }, {
  11445. key: "getThumbnail",
  11446. value: function getThumbnail(url) {
  11447. var _this3 = this;
  11448. return new Promise(function (resolve) {
  11449. fetch(url).then(function (response) {
  11450. var thumbnail = {
  11451. frames: parseVtt(response),
  11452. height: null,
  11453. urlPrefix: ''
  11454. }; // If the URLs don't start with '/', then we need to set their relative path to be the location of the VTT file
  11455. // If the URLs do start with '/', then they obviously don't need a prefix, so it will remain blank
  11456. // If the thumbnail URLs start with with none of '/', 'http://' or 'https://', then we need to set their relative path to be the location of the VTT file
  11457. if (!thumbnail.frames[0].text.startsWith('/') && !thumbnail.frames[0].text.startsWith('http://') && !thumbnail.frames[0].text.startsWith('https://')) {
  11458. thumbnail.urlPrefix = url.substring(0, url.lastIndexOf('/') + 1);
  11459. } // Download the first frame, so that we can determine/set the height of this thumbnailsDef
  11460. var tempImage = new Image();
  11461. tempImage.onload = function () {
  11462. thumbnail.height = tempImage.naturalHeight;
  11463. thumbnail.width = tempImage.naturalWidth;
  11464. _this3.thumbnails.push(thumbnail);
  11465. resolve();
  11466. };
  11467. tempImage.src = thumbnail.urlPrefix + thumbnail.frames[0].text;
  11468. });
  11469. });
  11470. }
  11471. }, {
  11472. key: "startMove",
  11473. value: function startMove(event) {
  11474. if (!this.loaded) {
  11475. return;
  11476. }
  11477. if (!is$1.event(event) || !['touchmove', 'mousemove'].includes(event.type)) {
  11478. return;
  11479. } // Wait until media has a duration
  11480. if (!this.player.media.duration) {
  11481. return;
  11482. }
  11483. if (event.type === 'touchmove') {
  11484. // Calculate seek hover position as approx video seconds
  11485. this.seekTime = this.player.media.duration * (this.player.elements.inputs.seek.value / 100);
  11486. } else {
  11487. // Calculate seek hover position as approx video seconds
  11488. var clientRect = this.player.elements.progress.getBoundingClientRect();
  11489. var percentage = 100 / clientRect.width * (event.pageX - clientRect.left);
  11490. this.seekTime = this.player.media.duration * (percentage / 100);
  11491. if (this.seekTime < 0) {
  11492. // The mousemove fires for 10+px out to the left
  11493. this.seekTime = 0;
  11494. }
  11495. if (this.seekTime > this.player.media.duration - 1) {
  11496. // Took 1 second off the duration for safety, because different players can disagree on the real duration of a video
  11497. this.seekTime = this.player.media.duration - 1;
  11498. }
  11499. this.mousePosX = event.pageX; // Set time text inside image container
  11500. this.elements.thumb.time.innerText = formatTime(this.seekTime);
  11501. } // Download and show image
  11502. this.showImageAtCurrentTime();
  11503. }
  11504. }, {
  11505. key: "endMove",
  11506. value: function endMove() {
  11507. this.toggleThumbContainer(false, true);
  11508. }
  11509. }, {
  11510. key: "startScrubbing",
  11511. value: function startScrubbing(event) {
  11512. // Only act on left mouse button (0), or touch device (event.button does not exist or is false)
  11513. if (is$1.nullOrUndefined(event.button) || event.button === false || event.button === 0) {
  11514. this.mouseDown = true; // Wait until media has a duration
  11515. if (this.player.media.duration) {
  11516. this.toggleScrubbingContainer(true);
  11517. this.toggleThumbContainer(false, true); // Download and show image
  11518. this.showImageAtCurrentTime();
  11519. }
  11520. }
  11521. }
  11522. }, {
  11523. key: "endScrubbing",
  11524. value: function endScrubbing() {
  11525. var _this4 = this;
  11526. this.mouseDown = false; // Hide scrubbing preview. But wait until the video has successfully seeked before hiding the scrubbing preview
  11527. if (Math.ceil(this.lastTime) === Math.ceil(this.player.media.currentTime)) {
  11528. // The video was already seeked/loaded at the chosen time - hide immediately
  11529. this.toggleScrubbingContainer(false);
  11530. } else {
  11531. // The video hasn't seeked yet. Wait for that
  11532. once.call(this.player, this.player.media, 'timeupdate', function () {
  11533. // Re-check mousedown - we might have already started scrubbing again
  11534. if (!_this4.mouseDown) {
  11535. _this4.toggleScrubbingContainer(false);
  11536. }
  11537. });
  11538. }
  11539. }
  11540. /**
  11541. * Setup hooks for Plyr and window events
  11542. */
  11543. }, {
  11544. key: "listeners",
  11545. value: function listeners() {
  11546. var _this5 = this;
  11547. // Hide thumbnail preview - on mouse click, mouse leave (in listeners.js for now), and video play/seek. All four are required, e.g., for buffering
  11548. this.player.on('play', function () {
  11549. _this5.toggleThumbContainer(false, true);
  11550. });
  11551. this.player.on('seeked', function () {
  11552. _this5.toggleThumbContainer(false);
  11553. });
  11554. this.player.on('timeupdate', function () {
  11555. _this5.lastTime = _this5.player.media.currentTime;
  11556. });
  11557. }
  11558. /**
  11559. * Create HTML elements for image containers
  11560. */
  11561. }, {
  11562. key: "render",
  11563. value: function render() {
  11564. // Create HTML element: plyr__preview-thumbnail-container
  11565. this.elements.thumb.container = createElement('div', {
  11566. class: this.player.config.classNames.previewThumbnails.thumbContainer
  11567. }); // Wrapper for the image for styling
  11568. this.elements.thumb.imageContainer = createElement('div', {
  11569. class: this.player.config.classNames.previewThumbnails.imageContainer
  11570. });
  11571. this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer); // Create HTML element, parent+span: time text (e.g., 01:32:00)
  11572. var timeContainer = createElement('div', {
  11573. class: this.player.config.classNames.previewThumbnails.timeContainer
  11574. });
  11575. this.elements.thumb.time = createElement('span', {}, '00:00');
  11576. timeContainer.appendChild(this.elements.thumb.time);
  11577. this.elements.thumb.container.appendChild(timeContainer); // Inject the whole thumb
  11578. if (is$1.element(this.player.elements.progress)) {
  11579. this.player.elements.progress.appendChild(this.elements.thumb.container);
  11580. } // Create HTML element: plyr__preview-scrubbing-container
  11581. this.elements.scrubbing.container = createElement('div', {
  11582. class: this.player.config.classNames.previewThumbnails.scrubbingContainer
  11583. });
  11584. this.player.elements.wrapper.appendChild(this.elements.scrubbing.container);
  11585. }
  11586. }, {
  11587. key: "destroy",
  11588. value: function destroy() {
  11589. if (this.elements.thumb.container) {
  11590. this.elements.thumb.container.remove();
  11591. }
  11592. if (this.elements.scrubbing.container) {
  11593. this.elements.scrubbing.container.remove();
  11594. }
  11595. }
  11596. }, {
  11597. key: "showImageAtCurrentTime",
  11598. value: function showImageAtCurrentTime() {
  11599. var _this6 = this;
  11600. if (this.mouseDown) {
  11601. this.setScrubbingContainerSize();
  11602. } else {
  11603. this.setThumbContainerSizeAndPos();
  11604. } // Find the desired thumbnail index
  11605. // TODO: Handle a video longer than the thumbs where thumbNum is null
  11606. var thumbNum = this.thumbnails[0].frames.findIndex(function (frame) {
  11607. return _this6.seekTime >= frame.startTime && _this6.seekTime <= frame.endTime;
  11608. });
  11609. var hasThumb = thumbNum >= 0;
  11610. var qualityIndex = 0; // Show the thumb container if we're not scrubbing
  11611. if (!this.mouseDown) {
  11612. this.toggleThumbContainer(hasThumb);
  11613. } // No matching thumb found
  11614. if (!hasThumb) {
  11615. return;
  11616. } // Check to see if we've already downloaded higher quality versions of this image
  11617. this.thumbnails.forEach(function (thumbnail, index) {
  11618. if (_this6.loadedImages.includes(thumbnail.frames[thumbNum].text)) {
  11619. qualityIndex = index;
  11620. }
  11621. }); // Only proceed if either thumbnum or thumbfilename has changed
  11622. if (thumbNum !== this.showingThumb) {
  11623. this.showingThumb = thumbNum;
  11624. this.loadImage(qualityIndex);
  11625. }
  11626. } // Show the image that's currently specified in this.showingThumb
  11627. }, {
  11628. key: "loadImage",
  11629. value: function loadImage() {
  11630. var _this7 = this;
  11631. var qualityIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11632. var thumbNum = this.showingThumb;
  11633. var thumbnail = this.thumbnails[qualityIndex];
  11634. var urlPrefix = thumbnail.urlPrefix;
  11635. var frame = thumbnail.frames[thumbNum];
  11636. var thumbFilename = thumbnail.frames[thumbNum].text;
  11637. var thumbUrl = urlPrefix + thumbFilename;
  11638. if (!this.currentImageElement || this.currentImageElement.dataset.filename !== thumbFilename) {
  11639. // If we're already loading a previous image, remove its onload handler - we don't want it to load after this one
  11640. // Only do this if not using sprites. Without sprites we really want to show as many images as possible, as a best-effort
  11641. if (this.loadingImage && this.usingSprites) {
  11642. this.loadingImage.onload = null;
  11643. } // We're building and adding a new image. In other implementations of similar functionality (YouTube), background image
  11644. // is instead used. But this causes issues with larger images in Firefox and Safari - switching between background
  11645. // images causes a flicker. Putting a new image over the top does not
  11646. var previewImage = new Image();
  11647. previewImage.src = thumbUrl;
  11648. previewImage.dataset.index = thumbNum;
  11649. previewImage.dataset.filename = thumbFilename;
  11650. this.showingThumbFilename = thumbFilename;
  11651. this.player.debug.log("Loading image: ".concat(thumbUrl)); // For some reason, passing the named function directly causes it to execute immediately. So I've wrapped it in an anonymous function...
  11652. previewImage.onload = function () {
  11653. return _this7.showImage(previewImage, frame, qualityIndex, thumbNum, thumbFilename, true);
  11654. };
  11655. this.loadingImage = previewImage;
  11656. this.removeOldImages(previewImage);
  11657. } else {
  11658. // Update the existing image
  11659. this.showImage(this.currentImageElement, frame, qualityIndex, thumbNum, thumbFilename, false);
  11660. this.currentImageElement.dataset.index = thumbNum;
  11661. this.removeOldImages(this.currentImageElement);
  11662. }
  11663. }
  11664. }, {
  11665. key: "showImage",
  11666. value: function showImage(previewImage, frame, qualityIndex, thumbNum, thumbFilename) {
  11667. var newImage = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
  11668. this.player.debug.log("Showing thumb: ".concat(thumbFilename, ". num: ").concat(thumbNum, ". qual: ").concat(qualityIndex, ". newimg: ").concat(newImage));
  11669. this.setImageSizeAndOffset(previewImage, frame);
  11670. if (newImage) {
  11671. this.currentImageContainer.appendChild(previewImage);
  11672. this.currentImageElement = previewImage;
  11673. if (!this.loadedImages.includes(thumbFilename)) {
  11674. this.loadedImages.push(thumbFilename);
  11675. }
  11676. } // Preload images before and after the current one
  11677. // Show higher quality of the same frame
  11678. // Each step here has a short time delay, and only continues if still hovering/seeking the same spot. This is to protect slow connections from overloading
  11679. this.preloadNearby(thumbNum, true).then(this.preloadNearby(thumbNum, false)).then(this.getHigherQuality(qualityIndex, previewImage, frame, thumbFilename));
  11680. } // Remove all preview images that aren't the designated current image
  11681. }, {
  11682. key: "removeOldImages",
  11683. value: function removeOldImages(currentImage) {
  11684. var _this8 = this;
  11685. // Get a list of all images, convert it from a DOM list to an array
  11686. Array.from(this.currentImageContainer.children).forEach(function (image) {
  11687. if (image.tagName.toLowerCase() !== 'img') {
  11688. return;
  11689. }
  11690. var removeDelay = _this8.usingSprites ? 500 : 1000;
  11691. if (image.dataset.index !== currentImage.dataset.index && !image.dataset.deleting) {
  11692. // Wait 200ms, as the new image can take some time to show on certain browsers (even though it was downloaded before showing). This will prevent flicker, and show some generosity towards slower clients
  11693. // First set attribute 'deleting' to prevent multi-handling of this on repeat firing of this function
  11694. // eslint-disable-next-line no-param-reassign
  11695. image.dataset.deleting = true; // This has to be set before the timeout - to prevent issues switching between hover and scrub
  11696. var currentImageContainer = _this8.currentImageContainer;
  11697. setTimeout(function () {
  11698. currentImageContainer.removeChild(image);
  11699. _this8.player.debug.log("Removing thumb: ".concat(image.dataset.filename));
  11700. }, removeDelay);
  11701. }
  11702. });
  11703. } // Preload images before and after the current one. Only if the user is still hovering/seeking the same frame
  11704. // This will only preload the lowest quality
  11705. }, {
  11706. key: "preloadNearby",
  11707. value: function preloadNearby(thumbNum) {
  11708. var _this9 = this;
  11709. var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  11710. return new Promise(function (resolve) {
  11711. setTimeout(function () {
  11712. var oldThumbFilename = _this9.thumbnails[0].frames[thumbNum].text;
  11713. if (_this9.showingThumbFilename === oldThumbFilename) {
  11714. // Find the nearest thumbs with different filenames. Sometimes it'll be the next index, but in the case of sprites, it might be 100+ away
  11715. var thumbnailsClone;
  11716. if (forward) {
  11717. thumbnailsClone = _this9.thumbnails[0].frames.slice(thumbNum);
  11718. } else {
  11719. thumbnailsClone = _this9.thumbnails[0].frames.slice(0, thumbNum).reverse();
  11720. }
  11721. var foundOne = false;
  11722. thumbnailsClone.forEach(function (frame) {
  11723. var newThumbFilename = frame.text;
  11724. if (newThumbFilename !== oldThumbFilename) {
  11725. // Found one with a different filename. Make sure it hasn't already been loaded on this page visit
  11726. if (!_this9.loadedImages.includes(newThumbFilename)) {
  11727. foundOne = true;
  11728. _this9.player.debug.log("Preloading thumb filename: ".concat(newThumbFilename));
  11729. var urlPrefix = _this9.thumbnails[0].urlPrefix;
  11730. var thumbURL = urlPrefix + newThumbFilename;
  11731. var previewImage = new Image();
  11732. previewImage.src = thumbURL;
  11733. previewImage.onload = function () {
  11734. _this9.player.debug.log("Preloaded thumb filename: ".concat(newThumbFilename));
  11735. if (!_this9.loadedImages.includes(newThumbFilename)) _this9.loadedImages.push(newThumbFilename); // We don't resolve until the thumb is loaded
  11736. resolve();
  11737. };
  11738. }
  11739. }
  11740. }); // If there are none to preload then we want to resolve immediately
  11741. if (!foundOne) {
  11742. resolve();
  11743. }
  11744. }
  11745. }, 300);
  11746. });
  11747. } // If user has been hovering current image for half a second, look for a higher quality one
  11748. }, {
  11749. key: "getHigherQuality",
  11750. value: function getHigherQuality(currentQualityIndex, previewImage, frame, thumbFilename) {
  11751. var _this10 = this;
  11752. if (currentQualityIndex < this.thumbnails.length - 1) {
  11753. // Only use the higher quality version if it's going to look any better - if the current thumb is of a lower pixel density than the thumbnail container
  11754. var previewImageHeight = previewImage.naturalHeight;
  11755. if (this.usingSprites) {
  11756. previewImageHeight = frame.h;
  11757. }
  11758. if (previewImageHeight < this.thumbContainerHeight) {
  11759. // Recurse back to the loadImage function - show a higher quality one, but only if the viewer is on this frame for a while
  11760. setTimeout(function () {
  11761. // Make sure the mouse hasn't already moved on and started hovering at another image
  11762. if (_this10.showingThumbFilename === thumbFilename) {
  11763. _this10.player.debug.log("Showing higher quality thumb for: ".concat(thumbFilename));
  11764. _this10.loadImage(currentQualityIndex + 1);
  11765. }
  11766. }, 300);
  11767. }
  11768. }
  11769. }
  11770. }, {
  11771. key: "toggleThumbContainer",
  11772. value: function toggleThumbContainer() {
  11773. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11774. var clearShowing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11775. var className = this.player.config.classNames.previewThumbnails.thumbContainerShown;
  11776. this.elements.thumb.container.classList.toggle(className, toggle);
  11777. if (!toggle && clearShowing) {
  11778. this.showingThumb = null;
  11779. this.showingThumbFilename = null;
  11780. }
  11781. }
  11782. }, {
  11783. key: "toggleScrubbingContainer",
  11784. value: function toggleScrubbingContainer() {
  11785. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11786. var className = this.player.config.classNames.previewThumbnails.scrubbingContainerShown;
  11787. this.elements.scrubbing.container.classList.toggle(className, toggle);
  11788. if (!toggle) {
  11789. this.showingThumb = null;
  11790. this.showingThumbFilename = null;
  11791. }
  11792. }
  11793. }, {
  11794. key: "determineContainerAutoSizing",
  11795. value: function determineContainerAutoSizing() {
  11796. if (this.elements.thumb.imageContainer.clientHeight > 20 || this.elements.thumb.imageContainer.clientWidth > 20) {
  11797. // This will prevent auto sizing in this.setThumbContainerSizeAndPos()
  11798. this.sizeSpecifiedInCSS = true;
  11799. }
  11800. } // Set the size to be about a quarter of the size of video. Unless option dynamicSize === false, in which case it needs to be set in CSS
  11801. }, {
  11802. key: "setThumbContainerSizeAndPos",
  11803. value: function setThumbContainerSizeAndPos() {
  11804. if (!this.sizeSpecifiedInCSS) {
  11805. var thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
  11806. this.elements.thumb.imageContainer.style.height = "".concat(this.thumbContainerHeight, "px");
  11807. this.elements.thumb.imageContainer.style.width = "".concat(thumbWidth, "px");
  11808. } else if (this.elements.thumb.imageContainer.clientHeight > 20 && this.elements.thumb.imageContainer.clientWidth < 20) {
  11809. var _thumbWidth = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio);
  11810. this.elements.thumb.imageContainer.style.width = "".concat(_thumbWidth, "px");
  11811. } else if (this.elements.thumb.imageContainer.clientHeight < 20 && this.elements.thumb.imageContainer.clientWidth > 20) {
  11812. var thumbHeight = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio);
  11813. this.elements.thumb.imageContainer.style.height = "".concat(thumbHeight, "px");
  11814. }
  11815. this.setThumbContainerPos();
  11816. }
  11817. }, {
  11818. key: "setThumbContainerPos",
  11819. value: function setThumbContainerPos() {
  11820. var seekbarRect = this.player.elements.progress.getBoundingClientRect();
  11821. var plyrRect = this.player.elements.container.getBoundingClientRect();
  11822. var container = this.elements.thumb.container; // Find the lowest and highest desired left-position, so we don't slide out the side of the video container
  11823. var minVal = plyrRect.left - seekbarRect.left + 10;
  11824. var maxVal = plyrRect.right - seekbarRect.left - container.clientWidth - 10; // Set preview container position to: mousepos, minus seekbar.left, minus half of previewContainer.clientWidth
  11825. var previewPos = this.mousePosX - seekbarRect.left - container.clientWidth / 2;
  11826. if (previewPos < minVal) {
  11827. previewPos = minVal;
  11828. }
  11829. if (previewPos > maxVal) {
  11830. previewPos = maxVal;
  11831. }
  11832. container.style.left = "".concat(previewPos, "px");
  11833. } // Can't use 100% width, in case the video is a different aspect ratio to the video container
  11834. }, {
  11835. key: "setScrubbingContainerSize",
  11836. value: function setScrubbingContainerSize() {
  11837. var _fitRatio = fitRatio(this.thumbAspectRatio, {
  11838. width: this.player.media.clientWidth,
  11839. height: this.player.media.clientHeight
  11840. }),
  11841. width = _fitRatio.width,
  11842. height = _fitRatio.height;
  11843. this.elements.scrubbing.container.style.width = "".concat(width, "px");
  11844. this.elements.scrubbing.container.style.height = "".concat(height, "px");
  11845. } // Sprites need to be offset to the correct location
  11846. }, {
  11847. key: "setImageSizeAndOffset",
  11848. value: function setImageSizeAndOffset(previewImage, frame) {
  11849. if (!this.usingSprites) {
  11850. return;
  11851. } // Find difference between height and preview container height
  11852. var multiplier = this.thumbContainerHeight / frame.h; // eslint-disable-next-line no-param-reassign
  11853. previewImage.style.height = "".concat(previewImage.naturalHeight * multiplier, "px"); // eslint-disable-next-line no-param-reassign
  11854. previewImage.style.width = "".concat(previewImage.naturalWidth * multiplier, "px"); // eslint-disable-next-line no-param-reassign
  11855. previewImage.style.left = "-".concat(frame.x * multiplier, "px"); // eslint-disable-next-line no-param-reassign
  11856. previewImage.style.top = "-".concat(frame.y * multiplier, "px");
  11857. }
  11858. }, {
  11859. key: "enabled",
  11860. get: function get() {
  11861. return this.player.isHTML5 && this.player.isVideo && this.player.config.previewThumbnails.enabled;
  11862. }
  11863. }, {
  11864. key: "currentImageContainer",
  11865. get: function get() {
  11866. if (this.mouseDown) {
  11867. return this.elements.scrubbing.container;
  11868. }
  11869. return this.elements.thumb.imageContainer;
  11870. }
  11871. }, {
  11872. key: "usingSprites",
  11873. get: function get() {
  11874. return Object.keys(this.thumbnails[0].frames[0]).includes('w');
  11875. }
  11876. }, {
  11877. key: "thumbAspectRatio",
  11878. get: function get() {
  11879. if (this.usingSprites) {
  11880. return this.thumbnails[0].frames[0].w / this.thumbnails[0].frames[0].h;
  11881. }
  11882. return this.thumbnails[0].width / this.thumbnails[0].height;
  11883. }
  11884. }, {
  11885. key: "thumbContainerHeight",
  11886. get: function get() {
  11887. if (this.mouseDown) {
  11888. var _fitRatio2 = fitRatio(this.thumbAspectRatio, {
  11889. width: this.player.media.clientWidth,
  11890. height: this.player.media.clientHeight
  11891. }),
  11892. height = _fitRatio2.height;
  11893. return height;
  11894. } // If css is used this needs to return the css height for sprites to work (see setImageSizeAndOffset)
  11895. if (this.sizeSpecifiedInCSS) {
  11896. return this.elements.thumb.imageContainer.clientHeight;
  11897. }
  11898. return Math.floor(this.player.media.clientWidth / this.thumbAspectRatio / 4);
  11899. }
  11900. }, {
  11901. key: "currentImageElement",
  11902. get: function get() {
  11903. if (this.mouseDown) {
  11904. return this.currentScrubbingImageElement;
  11905. }
  11906. return this.currentThumbnailImageElement;
  11907. },
  11908. set: function set(element) {
  11909. if (this.mouseDown) {
  11910. this.currentScrubbingImageElement = element;
  11911. } else {
  11912. this.currentThumbnailImageElement = element;
  11913. }
  11914. }
  11915. }]);
  11916. return PreviewThumbnails;
  11917. }();
  11918. var source = {
  11919. // Add elements to HTML5 media (source, tracks, etc)
  11920. insertElements: function insertElements(type, attributes) {
  11921. var _this = this;
  11922. if (is$1.string(attributes)) {
  11923. insertElement(type, this.media, {
  11924. src: attributes
  11925. });
  11926. } else if (is$1.array(attributes)) {
  11927. attributes.forEach(function (attribute) {
  11928. insertElement(type, _this.media, attribute);
  11929. });
  11930. }
  11931. },
  11932. // Update source
  11933. // Sources are not checked for support so be careful
  11934. change: function change(input) {
  11935. var _this2 = this;
  11936. if (!getDeep(input, 'sources.length')) {
  11937. this.debug.warn('Invalid source format');
  11938. return;
  11939. } // Cancel current network requests
  11940. html5.cancelRequests.call(this); // Destroy instance and re-setup
  11941. this.destroy.call(this, function () {
  11942. // Reset quality options
  11943. _this2.options.quality = []; // Remove elements
  11944. removeElement(_this2.media);
  11945. _this2.media = null; // Reset class name
  11946. if (is$1.element(_this2.elements.container)) {
  11947. _this2.elements.container.removeAttribute('class');
  11948. } // Set the type and provider
  11949. var sources = input.sources,
  11950. type = input.type;
  11951. var _sources = _slicedToArray(sources, 1),
  11952. _sources$ = _sources[0],
  11953. _sources$$provider = _sources$.provider,
  11954. provider = _sources$$provider === void 0 ? providers.html5 : _sources$$provider,
  11955. src = _sources$.src;
  11956. var tagName = provider === 'html5' ? type : 'div';
  11957. var attributes = provider === 'html5' ? {} : {
  11958. src: src
  11959. };
  11960. Object.assign(_this2, {
  11961. provider: provider,
  11962. type: type,
  11963. // Check for support
  11964. supported: support.check(type, provider, _this2.config.playsinline),
  11965. // Create new element
  11966. media: createElement(tagName, attributes)
  11967. }); // Inject the new element
  11968. _this2.elements.container.appendChild(_this2.media); // Autoplay the new source?
  11969. if (is$1.boolean(input.autoplay)) {
  11970. _this2.config.autoplay = input.autoplay;
  11971. } // Set attributes for audio and video
  11972. if (_this2.isHTML5) {
  11973. if (_this2.config.crossorigin) {
  11974. _this2.media.setAttribute('crossorigin', '');
  11975. }
  11976. if (_this2.config.autoplay) {
  11977. _this2.media.setAttribute('autoplay', '');
  11978. }
  11979. if (!is$1.empty(input.poster)) {
  11980. _this2.poster = input.poster;
  11981. }
  11982. if (_this2.config.loop.active) {
  11983. _this2.media.setAttribute('loop', '');
  11984. }
  11985. if (_this2.config.muted) {
  11986. _this2.media.setAttribute('muted', '');
  11987. }
  11988. if (_this2.config.playsinline) {
  11989. _this2.media.setAttribute('playsinline', '');
  11990. }
  11991. } // Restore class hook
  11992. ui.addStyleHook.call(_this2); // Set new sources for html5
  11993. if (_this2.isHTML5) {
  11994. source.insertElements.call(_this2, 'source', sources);
  11995. } // Set video title
  11996. _this2.config.title = input.title; // Set up from scratch
  11997. media.setup.call(_this2); // HTML5 stuff
  11998. if (_this2.isHTML5) {
  11999. // Setup captions
  12000. if (Object.keys(input).includes('tracks')) {
  12001. source.insertElements.call(_this2, 'track', input.tracks);
  12002. }
  12003. } // If HTML5 or embed but not fully supported, setupInterface and call ready now
  12004. if (_this2.isHTML5 || _this2.isEmbed && !_this2.supported.ui) {
  12005. // Setup interface
  12006. ui.build.call(_this2);
  12007. } // Load HTML5 sources
  12008. if (_this2.isHTML5) {
  12009. _this2.media.load();
  12010. } // Update previewThumbnails config & reload plugin
  12011. if (!is$1.empty(input.previewThumbnails)) {
  12012. Object.assign(_this2.config.previewThumbnails, input.previewThumbnails); // Cleanup previewThumbnails plugin if it was loaded
  12013. if (_this2.previewThumbnails && _this2.previewThumbnails.loaded) {
  12014. _this2.previewThumbnails.destroy();
  12015. _this2.previewThumbnails = null;
  12016. } // Create new instance if it is still enabled
  12017. if (_this2.config.previewThumbnails.enabled) {
  12018. _this2.previewThumbnails = new PreviewThumbnails(_this2);
  12019. }
  12020. } // Update the fullscreen support
  12021. _this2.fullscreen.update();
  12022. }, true);
  12023. }
  12024. };
  12025. /**
  12026. * Returns a number whose value is limited to the given range.
  12027. *
  12028. * Example: limit the output of this computation to between 0 and 255
  12029. * (x * 255).clamp(0, 255)
  12030. *
  12031. * @param {Number} input
  12032. * @param {Number} min The lower boundary of the output range
  12033. * @param {Number} max The upper boundary of the output range
  12034. * @returns A number in the range [min, max]
  12035. * @type Number
  12036. */
  12037. function clamp() {
  12038. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  12039. var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  12040. var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 255;
  12041. return Math.min(Math.max(input, min), max);
  12042. }
  12043. // TODO: Use a WeakMap for private globals
  12044. // const globals = new WeakMap();
  12045. // Plyr instance
  12046. var Plyr = /*#__PURE__*/function () {
  12047. function Plyr(target, options) {
  12048. var _this = this;
  12049. _classCallCheck(this, Plyr);
  12050. this.timers = {}; // State
  12051. this.ready = false;
  12052. this.loading = false;
  12053. this.failed = false; // Touch device
  12054. this.touch = support.touch; // Set the media element
  12055. this.media = target; // String selector passed
  12056. if (is$1.string(this.media)) {
  12057. this.media = document.querySelectorAll(this.media);
  12058. } // jQuery, NodeList or Array passed, use first element
  12059. if (window.jQuery && this.media instanceof jQuery || is$1.nodeList(this.media) || is$1.array(this.media)) {
  12060. // eslint-disable-next-line
  12061. this.media = this.media[0];
  12062. } // Set config
  12063. this.config = extend({}, defaults$1, Plyr.defaults, options || {}, function () {
  12064. try {
  12065. return JSON.parse(_this.media.getAttribute('data-plyr-config'));
  12066. } catch (e) {
  12067. return {};
  12068. }
  12069. }()); // Elements cache
  12070. this.elements = {
  12071. container: null,
  12072. fullscreen: null,
  12073. captions: null,
  12074. buttons: {},
  12075. display: {},
  12076. progress: {},
  12077. inputs: {},
  12078. settings: {
  12079. popup: null,
  12080. menu: null,
  12081. panels: {},
  12082. buttons: {}
  12083. }
  12084. }; // Captions
  12085. this.captions = {
  12086. active: null,
  12087. currentTrack: -1,
  12088. meta: new WeakMap()
  12089. }; // Fullscreen
  12090. this.fullscreen = {
  12091. active: false
  12092. }; // Options
  12093. this.options = {
  12094. speed: [],
  12095. quality: []
  12096. }; // Debugging
  12097. // TODO: move to globals
  12098. this.debug = new Console(this.config.debug); // Log config options and support
  12099. this.debug.log('Config', this.config);
  12100. this.debug.log('Support', support); // We need an element to setup
  12101. if (is$1.nullOrUndefined(this.media) || !is$1.element(this.media)) {
  12102. this.debug.error('Setup failed: no suitable element passed');
  12103. return;
  12104. } // Bail if the element is initialized
  12105. if (this.media.plyr) {
  12106. this.debug.warn('Target already setup');
  12107. return;
  12108. } // Bail if not enabled
  12109. if (!this.config.enabled) {
  12110. this.debug.error('Setup failed: disabled by config');
  12111. return;
  12112. } // Bail if disabled or no basic support
  12113. // You may want to disable certain UAs etc
  12114. if (!support.check().api) {
  12115. this.debug.error('Setup failed: no support');
  12116. return;
  12117. } // Cache original element state for .destroy()
  12118. var clone = this.media.cloneNode(true);
  12119. clone.autoplay = false;
  12120. this.elements.original = clone; // Set media type based on tag or data attribute
  12121. // Supported: video, audio, vimeo, youtube
  12122. var type = this.media.tagName.toLowerCase(); // Embed properties
  12123. var iframe = null;
  12124. var url = null; // Different setup based on type
  12125. switch (type) {
  12126. case 'div':
  12127. // Find the frame
  12128. iframe = this.media.querySelector('iframe'); // <iframe> type
  12129. if (is$1.element(iframe)) {
  12130. // Detect provider
  12131. url = parseUrl(iframe.getAttribute('src'));
  12132. this.provider = getProviderByUrl(url.toString()); // Rework elements
  12133. this.elements.container = this.media;
  12134. this.media = iframe; // Reset classname
  12135. this.elements.container.className = ''; // Get attributes from URL and set config
  12136. if (url.search.length) {
  12137. var truthy = ['1', 'true'];
  12138. if (truthy.includes(url.searchParams.get('autoplay'))) {
  12139. this.config.autoplay = true;
  12140. }
  12141. if (truthy.includes(url.searchParams.get('loop'))) {
  12142. this.config.loop.active = true;
  12143. } // TODO: replace fullscreen.iosNative with this playsinline config option
  12144. // YouTube requires the playsinline in the URL
  12145. if (this.isYouTube) {
  12146. this.config.playsinline = truthy.includes(url.searchParams.get('playsinline'));
  12147. this.config.youtube.hl = url.searchParams.get('hl'); // TODO: Should this be setting language?
  12148. } else {
  12149. this.config.playsinline = true;
  12150. }
  12151. }
  12152. } else {
  12153. // <div> with attributes
  12154. this.provider = this.media.getAttribute(this.config.attributes.embed.provider); // Remove attribute
  12155. this.media.removeAttribute(this.config.attributes.embed.provider);
  12156. } // Unsupported or missing provider
  12157. if (is$1.empty(this.provider) || !Object.keys(providers).includes(this.provider)) {
  12158. this.debug.error('Setup failed: Invalid provider');
  12159. return;
  12160. } // Audio will come later for external providers
  12161. this.type = types.video;
  12162. break;
  12163. case 'video':
  12164. case 'audio':
  12165. this.type = type;
  12166. this.provider = providers.html5; // Get config from attributes
  12167. if (this.media.hasAttribute('crossorigin')) {
  12168. this.config.crossorigin = true;
  12169. }
  12170. if (this.media.hasAttribute('autoplay')) {
  12171. this.config.autoplay = true;
  12172. }
  12173. if (this.media.hasAttribute('playsinline') || this.media.hasAttribute('webkit-playsinline')) {
  12174. this.config.playsinline = true;
  12175. }
  12176. if (this.media.hasAttribute('muted')) {
  12177. this.config.muted = true;
  12178. }
  12179. if (this.media.hasAttribute('loop')) {
  12180. this.config.loop.active = true;
  12181. }
  12182. break;
  12183. default:
  12184. this.debug.error('Setup failed: unsupported type');
  12185. return;
  12186. } // Check for support again but with type
  12187. this.supported = support.check(this.type, this.provider, this.config.playsinline); // If no support for even API, bail
  12188. if (!this.supported.api) {
  12189. this.debug.error('Setup failed: no support');
  12190. return;
  12191. }
  12192. this.eventListeners = []; // Create listeners
  12193. this.listeners = new Listeners(this); // Setup local storage for user settings
  12194. this.storage = new Storage(this); // Store reference
  12195. this.media.plyr = this; // Wrap media
  12196. if (!is$1.element(this.elements.container)) {
  12197. this.elements.container = createElement('div', {
  12198. tabindex: 0
  12199. });
  12200. wrap$1(this.media, this.elements.container);
  12201. } // Migrate custom properties from media to container (so they work 😉)
  12202. ui.migrateStyles.call(this); // Add style hook
  12203. ui.addStyleHook.call(this); // Setup media
  12204. media.setup.call(this); // Listen for events if debugging
  12205. if (this.config.debug) {
  12206. on.call(this, this.elements.container, this.config.events.join(' '), function (event) {
  12207. _this.debug.log("event: ".concat(event.type));
  12208. });
  12209. } // Setup fullscreen
  12210. this.fullscreen = new Fullscreen(this); // Setup interface
  12211. // If embed but not fully supported, build interface now to avoid flash of controls
  12212. if (this.isHTML5 || this.isEmbed && !this.supported.ui) {
  12213. ui.build.call(this);
  12214. } // Container listeners
  12215. this.listeners.container(); // Global listeners
  12216. this.listeners.global(); // Setup ads if provided
  12217. if (this.config.ads.enabled) {
  12218. this.ads = new Ads(this);
  12219. } // Autoplay if required
  12220. if (this.isHTML5 && this.config.autoplay) {
  12221. setTimeout(function () {
  12222. return silencePromise(_this.play());
  12223. }, 10);
  12224. } // Seek time will be recorded (in listeners.js) so we can prevent hiding controls for a few seconds after seek
  12225. this.lastSeekTime = 0; // Setup preview thumbnails if enabled
  12226. if (this.config.previewThumbnails.enabled) {
  12227. this.previewThumbnails = new PreviewThumbnails(this);
  12228. }
  12229. } // ---------------------------------------
  12230. // API
  12231. // ---------------------------------------
  12232. /**
  12233. * Types and provider helpers
  12234. */
  12235. _createClass(Plyr, [{
  12236. key: "play",
  12237. /**
  12238. * Play the media, or play the advertisement (if they are not blocked)
  12239. */
  12240. value: function play() {
  12241. var _this2 = this;
  12242. if (!is$1.function(this.media.play)) {
  12243. return null;
  12244. } // Intecept play with ads
  12245. if (this.ads && this.ads.enabled) {
  12246. this.ads.managerPromise.then(function () {
  12247. return _this2.ads.play();
  12248. }).catch(function () {
  12249. return silencePromise(_this2.media.play());
  12250. });
  12251. } // Return the promise (for HTML5)
  12252. return this.media.play();
  12253. }
  12254. /**
  12255. * Pause the media
  12256. */
  12257. }, {
  12258. key: "pause",
  12259. value: function pause() {
  12260. if (!this.playing || !is$1.function(this.media.pause)) {
  12261. return null;
  12262. }
  12263. return this.media.pause();
  12264. }
  12265. /**
  12266. * Get playing state
  12267. */
  12268. }, {
  12269. key: "togglePlay",
  12270. /**
  12271. * Toggle playback based on current status
  12272. * @param {Boolean} input
  12273. */
  12274. value: function togglePlay(input) {
  12275. // Toggle based on current state if nothing passed
  12276. var toggle = is$1.boolean(input) ? input : !this.playing;
  12277. if (toggle) {
  12278. return this.play();
  12279. }
  12280. return this.pause();
  12281. }
  12282. /**
  12283. * Stop playback
  12284. */
  12285. }, {
  12286. key: "stop",
  12287. value: function stop() {
  12288. if (this.isHTML5) {
  12289. this.pause();
  12290. this.restart();
  12291. } else if (is$1.function(this.media.stop)) {
  12292. this.media.stop();
  12293. }
  12294. }
  12295. /**
  12296. * Restart playback
  12297. */
  12298. }, {
  12299. key: "restart",
  12300. value: function restart() {
  12301. this.currentTime = 0;
  12302. }
  12303. /**
  12304. * Rewind
  12305. * @param {Number} seekTime - how far to rewind in seconds. Defaults to the config.seekTime
  12306. */
  12307. }, {
  12308. key: "rewind",
  12309. value: function rewind(seekTime) {
  12310. this.currentTime -= is$1.number(seekTime) ? seekTime : this.config.seekTime;
  12311. }
  12312. /**
  12313. * Fast forward
  12314. * @param {Number} seekTime - how far to fast forward in seconds. Defaults to the config.seekTime
  12315. */
  12316. }, {
  12317. key: "forward",
  12318. value: function forward(seekTime) {
  12319. this.currentTime += is$1.number(seekTime) ? seekTime : this.config.seekTime;
  12320. }
  12321. /**
  12322. * Seek to a time
  12323. * @param {Number} input - where to seek to in seconds. Defaults to 0 (the start)
  12324. */
  12325. }, {
  12326. key: "increaseVolume",
  12327. /**
  12328. * Increase volume
  12329. * @param {Boolean} step - How much to decrease by (between 0 and 1)
  12330. */
  12331. value: function increaseVolume(step) {
  12332. var volume = this.media.muted ? 0 : this.volume;
  12333. this.volume = volume + (is$1.number(step) ? step : 0);
  12334. }
  12335. /**
  12336. * Decrease volume
  12337. * @param {Boolean} step - How much to decrease by (between 0 and 1)
  12338. */
  12339. }, {
  12340. key: "decreaseVolume",
  12341. value: function decreaseVolume(step) {
  12342. this.increaseVolume(-step);
  12343. }
  12344. /**
  12345. * Set muted state
  12346. * @param {Boolean} mute
  12347. */
  12348. }, {
  12349. key: "toggleCaptions",
  12350. /**
  12351. * Toggle captions
  12352. * @param {Boolean} input - Whether to enable captions
  12353. */
  12354. value: function toggleCaptions(input) {
  12355. captions.toggle.call(this, input, false);
  12356. }
  12357. /**
  12358. * Set the caption track by index
  12359. * @param {Number} - Caption index
  12360. */
  12361. }, {
  12362. key: "airplay",
  12363. /**
  12364. * Trigger the airplay dialog
  12365. * TODO: update player with state, support, enabled
  12366. */
  12367. value: function airplay() {
  12368. // Show dialog if supported
  12369. if (support.airplay) {
  12370. this.media.webkitShowPlaybackTargetPicker();
  12371. }
  12372. }
  12373. /**
  12374. * Toggle the player controls
  12375. * @param {Boolean} [toggle] - Whether to show the controls
  12376. */
  12377. }, {
  12378. key: "toggleControls",
  12379. value: function toggleControls(toggle) {
  12380. // Don't toggle if missing UI support or if it's audio
  12381. if (this.supported.ui && !this.isAudio) {
  12382. // Get state before change
  12383. var isHidden = hasClass(this.elements.container, this.config.classNames.hideControls); // Negate the argument if not undefined since adding the class to hides the controls
  12384. var force = typeof toggle === 'undefined' ? undefined : !toggle; // Apply and get updated state
  12385. var hiding = toggleClass(this.elements.container, this.config.classNames.hideControls, force); // Close menu
  12386. if (hiding && is$1.array(this.config.controls) && this.config.controls.includes('settings') && !is$1.empty(this.config.settings)) {
  12387. controls.toggleMenu.call(this, false);
  12388. } // Trigger event on change
  12389. if (hiding !== isHidden) {
  12390. var eventName = hiding ? 'controlshidden' : 'controlsshown';
  12391. triggerEvent.call(this, this.media, eventName);
  12392. }
  12393. return !hiding;
  12394. }
  12395. return false;
  12396. }
  12397. /**
  12398. * Add event listeners
  12399. * @param {String} event - Event type
  12400. * @param {Function} callback - Callback for when event occurs
  12401. */
  12402. }, {
  12403. key: "on",
  12404. value: function on$1(event, callback) {
  12405. on.call(this, this.elements.container, event, callback);
  12406. }
  12407. /**
  12408. * Add event listeners once
  12409. * @param {String} event - Event type
  12410. * @param {Function} callback - Callback for when event occurs
  12411. */
  12412. }, {
  12413. key: "once",
  12414. value: function once$1(event, callback) {
  12415. once.call(this, this.elements.container, event, callback);
  12416. }
  12417. /**
  12418. * Remove event listeners
  12419. * @param {String} event - Event type
  12420. * @param {Function} callback - Callback for when event occurs
  12421. */
  12422. }, {
  12423. key: "off",
  12424. value: function off$1(event, callback) {
  12425. off(this.elements.container, event, callback);
  12426. }
  12427. /**
  12428. * Destroy an instance
  12429. * Event listeners are removed when elements are removed
  12430. * http://stackoverflow.com/questions/12528049/if-a-dom-element-is-removed-are-its-listeners-also-removed-from-memory
  12431. * @param {Function} callback - Callback for when destroy is complete
  12432. * @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
  12433. */
  12434. }, {
  12435. key: "destroy",
  12436. value: function destroy(callback) {
  12437. var _this3 = this;
  12438. var soft = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12439. if (!this.ready) {
  12440. return;
  12441. }
  12442. var done = function done() {
  12443. // Reset overflow (incase destroyed while in fullscreen)
  12444. document.body.style.overflow = ''; // GC for embed
  12445. _this3.embed = null; // If it's a soft destroy, make minimal changes
  12446. if (soft) {
  12447. if (Object.keys(_this3.elements).length) {
  12448. // Remove elements
  12449. removeElement(_this3.elements.buttons.play);
  12450. removeElement(_this3.elements.captions);
  12451. removeElement(_this3.elements.controls);
  12452. removeElement(_this3.elements.wrapper); // Clear for GC
  12453. _this3.elements.buttons.play = null;
  12454. _this3.elements.captions = null;
  12455. _this3.elements.controls = null;
  12456. _this3.elements.wrapper = null;
  12457. } // Callback
  12458. if (is$1.function(callback)) {
  12459. callback();
  12460. }
  12461. } else {
  12462. // Unbind listeners
  12463. unbindListeners.call(_this3); // Replace the container with the original element provided
  12464. replaceElement(_this3.elements.original, _this3.elements.container); // Event
  12465. triggerEvent.call(_this3, _this3.elements.original, 'destroyed', true); // Callback
  12466. if (is$1.function(callback)) {
  12467. callback.call(_this3.elements.original);
  12468. } // Reset state
  12469. _this3.ready = false; // Clear for garbage collection
  12470. setTimeout(function () {
  12471. _this3.elements = null;
  12472. _this3.media = null;
  12473. }, 200);
  12474. }
  12475. }; // Stop playback
  12476. this.stop(); // Clear timeouts
  12477. clearTimeout(this.timers.loading);
  12478. clearTimeout(this.timers.controls);
  12479. clearTimeout(this.timers.resized); // Provider specific stuff
  12480. if (this.isHTML5) {
  12481. // Restore native video controls
  12482. ui.toggleNativeControls.call(this, true); // Clean up
  12483. done();
  12484. } else if (this.isYouTube) {
  12485. // Clear timers
  12486. clearInterval(this.timers.buffering);
  12487. clearInterval(this.timers.playing); // Destroy YouTube API
  12488. if (this.embed !== null && is$1.function(this.embed.destroy)) {
  12489. this.embed.destroy();
  12490. } // Clean up
  12491. done();
  12492. } else if (this.isVimeo) {
  12493. // Destroy Vimeo API
  12494. // then clean up (wait, to prevent postmessage errors)
  12495. if (this.embed !== null) {
  12496. this.embed.unload().then(done);
  12497. } // Vimeo does not always return
  12498. setTimeout(done, 200);
  12499. }
  12500. }
  12501. /**
  12502. * Check for support for a mime type (HTML5 only)
  12503. * @param {String} type - Mime type
  12504. */
  12505. }, {
  12506. key: "supports",
  12507. value: function supports(type) {
  12508. return support.mime.call(this, type);
  12509. }
  12510. /**
  12511. * Check for support
  12512. * @param {String} type - Player type (audio/video)
  12513. * @param {String} provider - Provider (html5/youtube/vimeo)
  12514. * @param {Boolean} inline - Where player has `playsinline` sttribute
  12515. */
  12516. }, {
  12517. key: "isHTML5",
  12518. get: function get() {
  12519. return this.provider === providers.html5;
  12520. }
  12521. }, {
  12522. key: "isEmbed",
  12523. get: function get() {
  12524. return this.isYouTube || this.isVimeo;
  12525. }
  12526. }, {
  12527. key: "isYouTube",
  12528. get: function get() {
  12529. return this.provider === providers.youtube;
  12530. }
  12531. }, {
  12532. key: "isVimeo",
  12533. get: function get() {
  12534. return this.provider === providers.vimeo;
  12535. }
  12536. }, {
  12537. key: "isVideo",
  12538. get: function get() {
  12539. return this.type === types.video;
  12540. }
  12541. }, {
  12542. key: "isAudio",
  12543. get: function get() {
  12544. return this.type === types.audio;
  12545. }
  12546. }, {
  12547. key: "playing",
  12548. get: function get() {
  12549. return Boolean(this.ready && !this.paused && !this.ended);
  12550. }
  12551. /**
  12552. * Get paused state
  12553. */
  12554. }, {
  12555. key: "paused",
  12556. get: function get() {
  12557. return Boolean(this.media.paused);
  12558. }
  12559. /**
  12560. * Get stopped state
  12561. */
  12562. }, {
  12563. key: "stopped",
  12564. get: function get() {
  12565. return Boolean(this.paused && this.currentTime === 0);
  12566. }
  12567. /**
  12568. * Get ended state
  12569. */
  12570. }, {
  12571. key: "ended",
  12572. get: function get() {
  12573. return Boolean(this.media.ended);
  12574. }
  12575. }, {
  12576. key: "currentTime",
  12577. set: function set(input) {
  12578. // Bail if media duration isn't available yet
  12579. if (!this.duration) {
  12580. return;
  12581. } // Validate input
  12582. var inputIsValid = is$1.number(input) && input > 0; // Set
  12583. this.media.currentTime = inputIsValid ? Math.min(input, this.duration) : 0; // Logging
  12584. this.debug.log("Seeking to ".concat(this.currentTime, " seconds"));
  12585. }
  12586. /**
  12587. * Get current time
  12588. */
  12589. ,
  12590. get: function get() {
  12591. return Number(this.media.currentTime);
  12592. }
  12593. /**
  12594. * Get buffered
  12595. */
  12596. }, {
  12597. key: "buffered",
  12598. get: function get() {
  12599. var buffered = this.media.buffered; // YouTube / Vimeo return a float between 0-1
  12600. if (is$1.number(buffered)) {
  12601. return buffered;
  12602. } // HTML5
  12603. // TODO: Handle buffered chunks of the media
  12604. // (i.e. seek to another section buffers only that section)
  12605. if (buffered && buffered.length && this.duration > 0) {
  12606. return buffered.end(0) / this.duration;
  12607. }
  12608. return 0;
  12609. }
  12610. /**
  12611. * Get seeking status
  12612. */
  12613. }, {
  12614. key: "seeking",
  12615. get: function get() {
  12616. return Boolean(this.media.seeking);
  12617. }
  12618. /**
  12619. * Get the duration of the current media
  12620. */
  12621. }, {
  12622. key: "duration",
  12623. get: function get() {
  12624. // Faux duration set via config
  12625. var fauxDuration = parseFloat(this.config.duration); // Media duration can be NaN or Infinity before the media has loaded
  12626. var realDuration = (this.media || {}).duration;
  12627. var duration = !is$1.number(realDuration) || realDuration === Infinity ? 0 : realDuration; // If config duration is funky, use regular duration
  12628. return fauxDuration || duration;
  12629. }
  12630. /**
  12631. * Set the player volume
  12632. * @param {Number} value - must be between 0 and 1. Defaults to the value from local storage and config.volume if not set in storage
  12633. */
  12634. }, {
  12635. key: "volume",
  12636. set: function set(value) {
  12637. var volume = value;
  12638. var max = 1;
  12639. var min = 0;
  12640. if (is$1.string(volume)) {
  12641. volume = Number(volume);
  12642. } // Load volume from storage if no value specified
  12643. if (!is$1.number(volume)) {
  12644. volume = this.storage.get('volume');
  12645. } // Use config if all else fails
  12646. if (!is$1.number(volume)) {
  12647. volume = this.config.volume;
  12648. } // Maximum is volumeMax
  12649. if (volume > max) {
  12650. volume = max;
  12651. } // Minimum is volumeMin
  12652. if (volume < min) {
  12653. volume = min;
  12654. } // Update config
  12655. this.config.volume = volume; // Set the player volume
  12656. this.media.volume = volume; // If muted, and we're increasing volume manually, reset muted state
  12657. if (!is$1.empty(value) && this.muted && volume > 0) {
  12658. this.muted = false;
  12659. }
  12660. }
  12661. /**
  12662. * Get the current player volume
  12663. */
  12664. ,
  12665. get: function get() {
  12666. return Number(this.media.volume);
  12667. }
  12668. }, {
  12669. key: "muted",
  12670. set: function set(mute) {
  12671. var toggle = mute; // Load muted state from storage
  12672. if (!is$1.boolean(toggle)) {
  12673. toggle = this.storage.get('muted');
  12674. } // Use config if all else fails
  12675. if (!is$1.boolean(toggle)) {
  12676. toggle = this.config.muted;
  12677. } // Update config
  12678. this.config.muted = toggle; // Set mute on the player
  12679. this.media.muted = toggle;
  12680. }
  12681. /**
  12682. * Get current muted state
  12683. */
  12684. ,
  12685. get: function get() {
  12686. return Boolean(this.media.muted);
  12687. }
  12688. /**
  12689. * Check if the media has audio
  12690. */
  12691. }, {
  12692. key: "hasAudio",
  12693. get: function get() {
  12694. // Assume yes for all non HTML5 (as we can't tell...)
  12695. if (!this.isHTML5) {
  12696. return true;
  12697. }
  12698. if (this.isAudio) {
  12699. return true;
  12700. } // Get audio tracks
  12701. return Boolean(this.media.mozHasAudio) || Boolean(this.media.webkitAudioDecodedByteCount) || Boolean(this.media.audioTracks && this.media.audioTracks.length);
  12702. }
  12703. /**
  12704. * Set playback speed
  12705. * @param {Number} speed - the speed of playback (0.5-2.0)
  12706. */
  12707. }, {
  12708. key: "speed",
  12709. set: function set(input) {
  12710. var _this4 = this;
  12711. var speed = null;
  12712. if (is$1.number(input)) {
  12713. speed = input;
  12714. }
  12715. if (!is$1.number(speed)) {
  12716. speed = this.storage.get('speed');
  12717. }
  12718. if (!is$1.number(speed)) {
  12719. speed = this.config.speed.selected;
  12720. } // Clamp to min/max
  12721. var min = this.minimumSpeed,
  12722. max = this.maximumSpeed;
  12723. speed = clamp(speed, min, max); // Update config
  12724. this.config.speed.selected = speed; // Set media speed
  12725. setTimeout(function () {
  12726. _this4.media.playbackRate = speed;
  12727. }, 0);
  12728. }
  12729. /**
  12730. * Get current playback speed
  12731. */
  12732. ,
  12733. get: function get() {
  12734. return Number(this.media.playbackRate);
  12735. }
  12736. /**
  12737. * Get the minimum allowed speed
  12738. */
  12739. }, {
  12740. key: "minimumSpeed",
  12741. get: function get() {
  12742. if (this.isYouTube) {
  12743. // https://developers.google.com/youtube/iframe_api_reference#setPlaybackRate
  12744. return Math.min.apply(Math, _toConsumableArray(this.options.speed));
  12745. }
  12746. if (this.isVimeo) {
  12747. // https://github.com/vimeo/player.js/#setplaybackrateplaybackrate-number-promisenumber-rangeerrorerror
  12748. return 0.5;
  12749. } // https://stackoverflow.com/a/32320020/1191319
  12750. return 0.0625;
  12751. }
  12752. /**
  12753. * Get the maximum allowed speed
  12754. */
  12755. }, {
  12756. key: "maximumSpeed",
  12757. get: function get() {
  12758. if (this.isYouTube) {
  12759. // https://developers.google.com/youtube/iframe_api_reference#setPlaybackRate
  12760. return Math.max.apply(Math, _toConsumableArray(this.options.speed));
  12761. }
  12762. if (this.isVimeo) {
  12763. // https://github.com/vimeo/player.js/#setplaybackrateplaybackrate-number-promisenumber-rangeerrorerror
  12764. return 2;
  12765. } // https://stackoverflow.com/a/32320020/1191319
  12766. return 16;
  12767. }
  12768. /**
  12769. * Set playback quality
  12770. * Currently HTML5 & YouTube only
  12771. * @param {Number} input - Quality level
  12772. */
  12773. }, {
  12774. key: "quality",
  12775. set: function set(input) {
  12776. var config = this.config.quality;
  12777. var options = this.options.quality;
  12778. if (!options.length) {
  12779. return;
  12780. }
  12781. var quality = [!is$1.empty(input) && Number(input), this.storage.get('quality'), config.selected, config.default].find(is$1.number);
  12782. var updateStorage = true;
  12783. if (!options.includes(quality)) {
  12784. var value = closest$1(options, quality);
  12785. this.debug.warn("Unsupported quality option: ".concat(quality, ", using ").concat(value, " instead"));
  12786. quality = value; // Don't update storage if quality is not supported
  12787. updateStorage = false;
  12788. } // Update config
  12789. config.selected = quality; // Set quality
  12790. this.media.quality = quality; // Save to storage
  12791. if (updateStorage) {
  12792. this.storage.set({
  12793. quality: quality
  12794. });
  12795. }
  12796. }
  12797. /**
  12798. * Get current quality level
  12799. */
  12800. ,
  12801. get: function get() {
  12802. return this.media.quality;
  12803. }
  12804. /**
  12805. * Toggle loop
  12806. * TODO: Finish fancy new logic. Set the indicator on load as user may pass loop as config
  12807. * @param {Boolean} input - Whether to loop or not
  12808. */
  12809. }, {
  12810. key: "loop",
  12811. set: function set(input) {
  12812. var toggle = is$1.boolean(input) ? input : this.config.loop.active;
  12813. this.config.loop.active = toggle;
  12814. this.media.loop = toggle; // Set default to be a true toggle
  12815. /* const type = ['start', 'end', 'all', 'none', 'toggle'].includes(input) ? input : 'toggle';
  12816. switch (type) {
  12817. case 'start':
  12818. if (this.config.loop.end && this.config.loop.end <= this.currentTime) {
  12819. this.config.loop.end = null;
  12820. }
  12821. this.config.loop.start = this.currentTime;
  12822. // this.config.loop.indicator.start = this.elements.display.played.value;
  12823. break;
  12824. case 'end':
  12825. if (this.config.loop.start >= this.currentTime) {
  12826. return this;
  12827. }
  12828. this.config.loop.end = this.currentTime;
  12829. // this.config.loop.indicator.end = this.elements.display.played.value;
  12830. break;
  12831. case 'all':
  12832. this.config.loop.start = 0;
  12833. this.config.loop.end = this.duration - 2;
  12834. this.config.loop.indicator.start = 0;
  12835. this.config.loop.indicator.end = 100;
  12836. break;
  12837. case 'toggle':
  12838. if (this.config.loop.active) {
  12839. this.config.loop.start = 0;
  12840. this.config.loop.end = null;
  12841. } else {
  12842. this.config.loop.start = 0;
  12843. this.config.loop.end = this.duration - 2;
  12844. }
  12845. break;
  12846. default:
  12847. this.config.loop.start = 0;
  12848. this.config.loop.end = null;
  12849. break;
  12850. } */
  12851. }
  12852. /**
  12853. * Get current loop state
  12854. */
  12855. ,
  12856. get: function get() {
  12857. return Boolean(this.media.loop);
  12858. }
  12859. /**
  12860. * Set new media source
  12861. * @param {Object} input - The new source object (see docs)
  12862. */
  12863. }, {
  12864. key: "source",
  12865. set: function set(input) {
  12866. source.change.call(this, input);
  12867. }
  12868. /**
  12869. * Get current source
  12870. */
  12871. ,
  12872. get: function get() {
  12873. return this.media.currentSrc;
  12874. }
  12875. /**
  12876. * Get a download URL (either source or custom)
  12877. */
  12878. }, {
  12879. key: "download",
  12880. get: function get() {
  12881. var download = this.config.urls.download;
  12882. return is$1.url(download) ? download : this.source;
  12883. }
  12884. /**
  12885. * Set the download URL
  12886. */
  12887. ,
  12888. set: function set(input) {
  12889. if (!is$1.url(input)) {
  12890. return;
  12891. }
  12892. this.config.urls.download = input;
  12893. controls.setDownloadUrl.call(this);
  12894. }
  12895. /**
  12896. * Set the poster image for a video
  12897. * @param {String} input - the URL for the new poster image
  12898. */
  12899. }, {
  12900. key: "poster",
  12901. set: function set(input) {
  12902. if (!this.isVideo) {
  12903. this.debug.warn('Poster can only be set for video');
  12904. return;
  12905. }
  12906. ui.setPoster.call(this, input, false).catch(function () {});
  12907. }
  12908. /**
  12909. * Get the current poster image
  12910. */
  12911. ,
  12912. get: function get() {
  12913. if (!this.isVideo) {
  12914. return null;
  12915. }
  12916. return this.media.getAttribute('poster') || this.media.getAttribute('data-poster');
  12917. }
  12918. /**
  12919. * Get the current aspect ratio in use
  12920. */
  12921. }, {
  12922. key: "ratio",
  12923. get: function get() {
  12924. if (!this.isVideo) {
  12925. return null;
  12926. }
  12927. var ratio = reduceAspectRatio(getAspectRatio.call(this));
  12928. return is$1.array(ratio) ? ratio.join(':') : ratio;
  12929. }
  12930. /**
  12931. * Set video aspect ratio
  12932. */
  12933. ,
  12934. set: function set(input) {
  12935. if (!this.isVideo) {
  12936. this.debug.warn('Aspect ratio can only be set for video');
  12937. return;
  12938. }
  12939. if (!is$1.string(input) || !validateRatio(input)) {
  12940. this.debug.error("Invalid aspect ratio specified (".concat(input, ")"));
  12941. return;
  12942. }
  12943. this.config.ratio = input;
  12944. setAspectRatio.call(this);
  12945. }
  12946. /**
  12947. * Set the autoplay state
  12948. * @param {Boolean} input - Whether to autoplay or not
  12949. */
  12950. }, {
  12951. key: "autoplay",
  12952. set: function set(input) {
  12953. var toggle = is$1.boolean(input) ? input : this.config.autoplay;
  12954. this.config.autoplay = toggle;
  12955. }
  12956. /**
  12957. * Get the current autoplay state
  12958. */
  12959. ,
  12960. get: function get() {
  12961. return Boolean(this.config.autoplay);
  12962. }
  12963. }, {
  12964. key: "currentTrack",
  12965. set: function set(input) {
  12966. captions.set.call(this, input, false);
  12967. }
  12968. /**
  12969. * Get the current caption track index (-1 if disabled)
  12970. */
  12971. ,
  12972. get: function get() {
  12973. var _this$captions = this.captions,
  12974. toggled = _this$captions.toggled,
  12975. currentTrack = _this$captions.currentTrack;
  12976. return toggled ? currentTrack : -1;
  12977. }
  12978. /**
  12979. * Set the wanted language for captions
  12980. * Since tracks can be added later it won't update the actual caption track until there is a matching track
  12981. * @param {String} - Two character ISO language code (e.g. EN, FR, PT, etc)
  12982. */
  12983. }, {
  12984. key: "language",
  12985. set: function set(input) {
  12986. captions.setLanguage.call(this, input, false);
  12987. }
  12988. /**
  12989. * Get the current track's language
  12990. */
  12991. ,
  12992. get: function get() {
  12993. return (captions.getCurrentTrack.call(this) || {}).language;
  12994. }
  12995. /**
  12996. * Toggle picture-in-picture playback on WebKit/MacOS
  12997. * TODO: update player with state, support, enabled
  12998. * TODO: detect outside changes
  12999. */
  13000. }, {
  13001. key: "pip",
  13002. set: function set(input) {
  13003. // Bail if no support
  13004. if (!support.pip) {
  13005. return;
  13006. } // Toggle based on current state if not passed
  13007. var toggle = is$1.boolean(input) ? input : !this.pip; // Toggle based on current state
  13008. // Safari
  13009. if (is$1.function(this.media.webkitSetPresentationMode)) {
  13010. this.media.webkitSetPresentationMode(toggle ? pip.active : pip.inactive);
  13011. } // Chrome
  13012. if (is$1.function(this.media.requestPictureInPicture)) {
  13013. if (!this.pip && toggle) {
  13014. this.media.requestPictureInPicture();
  13015. } else if (this.pip && !toggle) {
  13016. document.exitPictureInPicture();
  13017. }
  13018. }
  13019. }
  13020. /**
  13021. * Get the current picture-in-picture state
  13022. */
  13023. ,
  13024. get: function get() {
  13025. if (!support.pip) {
  13026. return null;
  13027. } // Safari
  13028. if (!is$1.empty(this.media.webkitPresentationMode)) {
  13029. return this.media.webkitPresentationMode === pip.active;
  13030. } // Chrome
  13031. return this.media === document.pictureInPictureElement;
  13032. }
  13033. }], [{
  13034. key: "supported",
  13035. value: function supported(type, provider, inline) {
  13036. return support.check(type, provider, inline);
  13037. }
  13038. /**
  13039. * Load an SVG sprite into the page
  13040. * @param {String} url - URL for the SVG sprite
  13041. * @param {String} [id] - Unique ID
  13042. */
  13043. }, {
  13044. key: "loadSprite",
  13045. value: function loadSprite$1(url, id) {
  13046. return loadSprite(url, id);
  13047. }
  13048. /**
  13049. * Setup multiple instances
  13050. * @param {*} selector
  13051. * @param {Object} options
  13052. */
  13053. }, {
  13054. key: "setup",
  13055. value: function setup(selector) {
  13056. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13057. var targets = null;
  13058. if (is$1.string(selector)) {
  13059. targets = Array.from(document.querySelectorAll(selector));
  13060. } else if (is$1.nodeList(selector)) {
  13061. targets = Array.from(selector);
  13062. } else if (is$1.array(selector)) {
  13063. targets = selector.filter(is$1.element);
  13064. }
  13065. if (is$1.empty(targets)) {
  13066. return null;
  13067. }
  13068. return targets.map(function (t) {
  13069. return new Plyr(t, options);
  13070. });
  13071. }
  13072. }]);
  13073. return Plyr;
  13074. }();
  13075. Plyr.defaults = cloneDeep(defaults$1);
  13076. // ==========================================================================
  13077. export default Plyr;