plyr.polyfilled.js 524 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762
  1. typeof navigator === "object" && (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  3. typeof define === 'function' && define.amd ? define('Plyr', factory) :
  4. (global = global || self, global.Plyr = factory());
  5. }(this, (function () { 'use strict';
  6. // Polyfill for creating CustomEvents on IE9/10/11
  7. // code pulled from:
  8. // https://github.com/d4tocchini/customevent-polyfill
  9. // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
  10. (function () {
  11. if (typeof window === 'undefined') {
  12. return;
  13. }
  14. try {
  15. var ce = new window.CustomEvent('test', {
  16. cancelable: true
  17. });
  18. ce.preventDefault();
  19. if (ce.defaultPrevented !== true) {
  20. // IE has problems with .preventDefault() on custom events
  21. // http://stackoverflow.com/questions/23349191
  22. throw new Error('Could not prevent default');
  23. }
  24. } catch (e) {
  25. var CustomEvent = function CustomEvent(event, params) {
  26. var evt, origPrevent;
  27. params = params || {};
  28. params.bubbles = !!params.bubbles;
  29. params.cancelable = !!params.cancelable;
  30. evt = document.createEvent('CustomEvent');
  31. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  32. origPrevent = evt.preventDefault;
  33. evt.preventDefault = function () {
  34. origPrevent.call(this);
  35. try {
  36. Object.defineProperty(this, 'defaultPrevented', {
  37. get: function get() {
  38. return true;
  39. }
  40. });
  41. } catch (e) {
  42. this.defaultPrevented = true;
  43. }
  44. };
  45. return evt;
  46. };
  47. CustomEvent.prototype = window.Event.prototype;
  48. window.CustomEvent = CustomEvent; // expose definition to window
  49. }
  50. })();
  51. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  52. function createCommonjsModule(fn, module) {
  53. return module = { exports: {} }, fn(module, module.exports), module.exports;
  54. }
  55. var check = function (it) {
  56. return it && it.Math == Math && it;
  57. };
  58. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  59. var global_1 =
  60. // eslint-disable-next-line no-undef
  61. check(typeof globalThis == 'object' && globalThis) ||
  62. check(typeof window == 'object' && window) ||
  63. check(typeof self == 'object' && self) ||
  64. check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
  65. // eslint-disable-next-line no-new-func
  66. Function('return this')();
  67. var fails = function (exec) {
  68. try {
  69. return !!exec();
  70. } catch (error) {
  71. return true;
  72. }
  73. };
  74. // Thank's IE8 for his funny defineProperty
  75. var descriptors = !fails(function () {
  76. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  77. });
  78. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  79. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  80. // Nashorn ~ JDK8 bug
  81. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  82. // `Object.prototype.propertyIsEnumerable` method implementation
  83. // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
  84. var f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  85. var descriptor = getOwnPropertyDescriptor(this, V);
  86. return !!descriptor && descriptor.enumerable;
  87. } : nativePropertyIsEnumerable;
  88. var objectPropertyIsEnumerable = {
  89. f: f
  90. };
  91. var createPropertyDescriptor = function (bitmap, value) {
  92. return {
  93. enumerable: !(bitmap & 1),
  94. configurable: !(bitmap & 2),
  95. writable: !(bitmap & 4),
  96. value: value
  97. };
  98. };
  99. var toString = {}.toString;
  100. var classofRaw = function (it) {
  101. return toString.call(it).slice(8, -1);
  102. };
  103. var split = ''.split;
  104. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  105. var indexedObject = fails(function () {
  106. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  107. // eslint-disable-next-line no-prototype-builtins
  108. return !Object('z').propertyIsEnumerable(0);
  109. }) ? function (it) {
  110. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  111. } : Object;
  112. // `RequireObjectCoercible` abstract operation
  113. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  114. var requireObjectCoercible = function (it) {
  115. if (it == undefined) throw TypeError("Can't call method on " + it);
  116. return it;
  117. };
  118. // toObject with fallback for non-array-like ES3 strings
  119. var toIndexedObject = function (it) {
  120. return indexedObject(requireObjectCoercible(it));
  121. };
  122. var isObject = function (it) {
  123. return typeof it === 'object' ? it !== null : typeof it === 'function';
  124. };
  125. // `ToPrimitive` abstract operation
  126. // https://tc39.github.io/ecma262/#sec-toprimitive
  127. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  128. // and the second argument - flag - preferred type is a string
  129. var toPrimitive = function (input, PREFERRED_STRING) {
  130. if (!isObject(input)) return input;
  131. var fn, val;
  132. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  133. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
  134. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  135. throw TypeError("Can't convert object to primitive value");
  136. };
  137. var hasOwnProperty = {}.hasOwnProperty;
  138. var has = function (it, key) {
  139. return hasOwnProperty.call(it, key);
  140. };
  141. var document$1 = global_1.document;
  142. // typeof document.createElement is 'object' in old IE
  143. var EXISTS = isObject(document$1) && isObject(document$1.createElement);
  144. var documentCreateElement = function (it) {
  145. return EXISTS ? document$1.createElement(it) : {};
  146. };
  147. // Thank's IE8 for his funny defineProperty
  148. var ie8DomDefine = !descriptors && !fails(function () {
  149. return Object.defineProperty(documentCreateElement('div'), 'a', {
  150. get: function () { return 7; }
  151. }).a != 7;
  152. });
  153. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  154. // `Object.getOwnPropertyDescriptor` method
  155. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  156. var f$1 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  157. O = toIndexedObject(O);
  158. P = toPrimitive(P, true);
  159. if (ie8DomDefine) try {
  160. return nativeGetOwnPropertyDescriptor(O, P);
  161. } catch (error) { /* empty */ }
  162. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  163. };
  164. var objectGetOwnPropertyDescriptor = {
  165. f: f$1
  166. };
  167. var anObject = function (it) {
  168. if (!isObject(it)) {
  169. throw TypeError(String(it) + ' is not an object');
  170. } return it;
  171. };
  172. var nativeDefineProperty = Object.defineProperty;
  173. // `Object.defineProperty` method
  174. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  175. var f$2 = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  176. anObject(O);
  177. P = toPrimitive(P, true);
  178. anObject(Attributes);
  179. if (ie8DomDefine) try {
  180. return nativeDefineProperty(O, P, Attributes);
  181. } catch (error) { /* empty */ }
  182. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  183. if ('value' in Attributes) O[P] = Attributes.value;
  184. return O;
  185. };
  186. var objectDefineProperty = {
  187. f: f$2
  188. };
  189. var createNonEnumerableProperty = descriptors ? function (object, key, value) {
  190. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  191. } : function (object, key, value) {
  192. object[key] = value;
  193. return object;
  194. };
  195. var setGlobal = function (key, value) {
  196. try {
  197. createNonEnumerableProperty(global_1, key, value);
  198. } catch (error) {
  199. global_1[key] = value;
  200. } return value;
  201. };
  202. var SHARED = '__core-js_shared__';
  203. var store = global_1[SHARED] || setGlobal(SHARED, {});
  204. var sharedStore = store;
  205. var functionToString = Function.toString;
  206. // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
  207. if (typeof sharedStore.inspectSource != 'function') {
  208. sharedStore.inspectSource = function (it) {
  209. return functionToString.call(it);
  210. };
  211. }
  212. var inspectSource = sharedStore.inspectSource;
  213. var WeakMap$1 = global_1.WeakMap;
  214. var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(inspectSource(WeakMap$1));
  215. var isPure = false;
  216. var shared = createCommonjsModule(function (module) {
  217. (module.exports = function (key, value) {
  218. return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
  219. })('versions', []).push({
  220. version: '3.6.5',
  221. mode: 'global',
  222. copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
  223. });
  224. });
  225. var id = 0;
  226. var postfix = Math.random();
  227. var uid = function (key) {
  228. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  229. };
  230. var keys = shared('keys');
  231. var sharedKey = function (key) {
  232. return keys[key] || (keys[key] = uid(key));
  233. };
  234. var hiddenKeys = {};
  235. var WeakMap$2 = global_1.WeakMap;
  236. var set, get, has$1;
  237. var enforce = function (it) {
  238. return has$1(it) ? get(it) : set(it, {});
  239. };
  240. var getterFor = function (TYPE) {
  241. return function (it) {
  242. var state;
  243. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  244. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  245. } return state;
  246. };
  247. };
  248. if (nativeWeakMap) {
  249. var store$1 = new WeakMap$2();
  250. var wmget = store$1.get;
  251. var wmhas = store$1.has;
  252. var wmset = store$1.set;
  253. set = function (it, metadata) {
  254. wmset.call(store$1, it, metadata);
  255. return metadata;
  256. };
  257. get = function (it) {
  258. return wmget.call(store$1, it) || {};
  259. };
  260. has$1 = function (it) {
  261. return wmhas.call(store$1, it);
  262. };
  263. } else {
  264. var STATE = sharedKey('state');
  265. hiddenKeys[STATE] = true;
  266. set = function (it, metadata) {
  267. createNonEnumerableProperty(it, STATE, metadata);
  268. return metadata;
  269. };
  270. get = function (it) {
  271. return has(it, STATE) ? it[STATE] : {};
  272. };
  273. has$1 = function (it) {
  274. return has(it, STATE);
  275. };
  276. }
  277. var internalState = {
  278. set: set,
  279. get: get,
  280. has: has$1,
  281. enforce: enforce,
  282. getterFor: getterFor
  283. };
  284. var redefine = createCommonjsModule(function (module) {
  285. var getInternalState = internalState.get;
  286. var enforceInternalState = internalState.enforce;
  287. var TEMPLATE = String(String).split('String');
  288. (module.exports = function (O, key, value, options) {
  289. var unsafe = options ? !!options.unsafe : false;
  290. var simple = options ? !!options.enumerable : false;
  291. var noTargetGet = options ? !!options.noTargetGet : false;
  292. if (typeof value == 'function') {
  293. if (typeof key == 'string' && !has(value, 'name')) createNonEnumerableProperty(value, 'name', key);
  294. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  295. }
  296. if (O === global_1) {
  297. if (simple) O[key] = value;
  298. else setGlobal(key, value);
  299. return;
  300. } else if (!unsafe) {
  301. delete O[key];
  302. } else if (!noTargetGet && O[key]) {
  303. simple = true;
  304. }
  305. if (simple) O[key] = value;
  306. else createNonEnumerableProperty(O, key, value);
  307. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  308. })(Function.prototype, 'toString', function toString() {
  309. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  310. });
  311. });
  312. var path = global_1;
  313. var aFunction = function (variable) {
  314. return typeof variable == 'function' ? variable : undefined;
  315. };
  316. var getBuiltIn = function (namespace, method) {
  317. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace])
  318. : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
  319. };
  320. var ceil = Math.ceil;
  321. var floor = Math.floor;
  322. // `ToInteger` abstract operation
  323. // https://tc39.github.io/ecma262/#sec-tointeger
  324. var toInteger = function (argument) {
  325. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  326. };
  327. var min = Math.min;
  328. // `ToLength` abstract operation
  329. // https://tc39.github.io/ecma262/#sec-tolength
  330. var toLength = function (argument) {
  331. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  332. };
  333. var max = Math.max;
  334. var min$1 = Math.min;
  335. // Helper for a popular repeating case of the spec:
  336. // Let integer be ? ToInteger(index).
  337. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  338. var toAbsoluteIndex = function (index, length) {
  339. var integer = toInteger(index);
  340. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  341. };
  342. // `Array.prototype.{ indexOf, includes }` methods implementation
  343. var createMethod = function (IS_INCLUDES) {
  344. return function ($this, el, fromIndex) {
  345. var O = toIndexedObject($this);
  346. var length = toLength(O.length);
  347. var index = toAbsoluteIndex(fromIndex, length);
  348. var value;
  349. // Array#includes uses SameValueZero equality algorithm
  350. // eslint-disable-next-line no-self-compare
  351. if (IS_INCLUDES && el != el) while (length > index) {
  352. value = O[index++];
  353. // eslint-disable-next-line no-self-compare
  354. if (value != value) return true;
  355. // Array#indexOf ignores holes, Array#includes - not
  356. } else for (;length > index; index++) {
  357. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  358. } return !IS_INCLUDES && -1;
  359. };
  360. };
  361. var arrayIncludes = {
  362. // `Array.prototype.includes` method
  363. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  364. includes: createMethod(true),
  365. // `Array.prototype.indexOf` method
  366. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  367. indexOf: createMethod(false)
  368. };
  369. var indexOf = arrayIncludes.indexOf;
  370. var objectKeysInternal = function (object, names) {
  371. var O = toIndexedObject(object);
  372. var i = 0;
  373. var result = [];
  374. var key;
  375. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  376. // Don't enum bug & hidden keys
  377. while (names.length > i) if (has(O, key = names[i++])) {
  378. ~indexOf(result, key) || result.push(key);
  379. }
  380. return result;
  381. };
  382. // IE8- don't enum bug keys
  383. var enumBugKeys = [
  384. 'constructor',
  385. 'hasOwnProperty',
  386. 'isPrototypeOf',
  387. 'propertyIsEnumerable',
  388. 'toLocaleString',
  389. 'toString',
  390. 'valueOf'
  391. ];
  392. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  393. // `Object.getOwnPropertyNames` method
  394. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  395. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  396. return objectKeysInternal(O, hiddenKeys$1);
  397. };
  398. var objectGetOwnPropertyNames = {
  399. f: f$3
  400. };
  401. var f$4 = Object.getOwnPropertySymbols;
  402. var objectGetOwnPropertySymbols = {
  403. f: f$4
  404. };
  405. // all object keys, includes non-enumerable and symbols
  406. var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  407. var keys = objectGetOwnPropertyNames.f(anObject(it));
  408. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  409. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  410. };
  411. var copyConstructorProperties = function (target, source) {
  412. var keys = ownKeys(source);
  413. var defineProperty = objectDefineProperty.f;
  414. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  415. for (var i = 0; i < keys.length; i++) {
  416. var key = keys[i];
  417. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  418. }
  419. };
  420. var replacement = /#|\.prototype\./;
  421. var isForced = function (feature, detection) {
  422. var value = data[normalize(feature)];
  423. return value == POLYFILL ? true
  424. : value == NATIVE ? false
  425. : typeof detection == 'function' ? fails(detection)
  426. : !!detection;
  427. };
  428. var normalize = isForced.normalize = function (string) {
  429. return String(string).replace(replacement, '.').toLowerCase();
  430. };
  431. var data = isForced.data = {};
  432. var NATIVE = isForced.NATIVE = 'N';
  433. var POLYFILL = isForced.POLYFILL = 'P';
  434. var isForced_1 = isForced;
  435. var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  436. /*
  437. options.target - name of the target object
  438. options.global - target is the global object
  439. options.stat - export as static methods of target
  440. options.proto - export as prototype methods of target
  441. options.real - real prototype method for the `pure` version
  442. options.forced - export even if the native feature is available
  443. options.bind - bind methods to the target, required for the `pure` version
  444. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  445. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  446. options.sham - add a flag to not completely full polyfills
  447. options.enumerable - export as enumerable property
  448. options.noTargetGet - prevent calling a getter on target
  449. */
  450. var _export = function (options, source) {
  451. var TARGET = options.target;
  452. var GLOBAL = options.global;
  453. var STATIC = options.stat;
  454. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  455. if (GLOBAL) {
  456. target = global_1;
  457. } else if (STATIC) {
  458. target = global_1[TARGET] || setGlobal(TARGET, {});
  459. } else {
  460. target = (global_1[TARGET] || {}).prototype;
  461. }
  462. if (target) for (key in source) {
  463. sourceProperty = source[key];
  464. if (options.noTargetGet) {
  465. descriptor = getOwnPropertyDescriptor$1(target, key);
  466. targetProperty = descriptor && descriptor.value;
  467. } else targetProperty = target[key];
  468. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  469. // contained in target
  470. if (!FORCED && targetProperty !== undefined) {
  471. if (typeof sourceProperty === typeof targetProperty) continue;
  472. copyConstructorProperties(sourceProperty, targetProperty);
  473. }
  474. // add a flag to not completely full polyfills
  475. if (options.sham || (targetProperty && targetProperty.sham)) {
  476. createNonEnumerableProperty(sourceProperty, 'sham', true);
  477. }
  478. // extend global
  479. redefine(target, key, sourceProperty, options);
  480. }
  481. };
  482. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
  483. // Chrome 38 Symbol has incorrect toString conversion
  484. // eslint-disable-next-line no-undef
  485. return !String(Symbol());
  486. });
  487. var useSymbolAsUid = nativeSymbol
  488. // eslint-disable-next-line no-undef
  489. && !Symbol.sham
  490. // eslint-disable-next-line no-undef
  491. && typeof Symbol.iterator == 'symbol';
  492. // `IsArray` abstract operation
  493. // https://tc39.github.io/ecma262/#sec-isarray
  494. var isArray = Array.isArray || function isArray(arg) {
  495. return classofRaw(arg) == 'Array';
  496. };
  497. // `ToObject` abstract operation
  498. // https://tc39.github.io/ecma262/#sec-toobject
  499. var toObject = function (argument) {
  500. return Object(requireObjectCoercible(argument));
  501. };
  502. // `Object.keys` method
  503. // https://tc39.github.io/ecma262/#sec-object.keys
  504. var objectKeys = Object.keys || function keys(O) {
  505. return objectKeysInternal(O, enumBugKeys);
  506. };
  507. // `Object.defineProperties` method
  508. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  509. var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  510. anObject(O);
  511. var keys = objectKeys(Properties);
  512. var length = keys.length;
  513. var index = 0;
  514. var key;
  515. while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
  516. return O;
  517. };
  518. var html = getBuiltIn('document', 'documentElement');
  519. var GT = '>';
  520. var LT = '<';
  521. var PROTOTYPE = 'prototype';
  522. var SCRIPT = 'script';
  523. var IE_PROTO = sharedKey('IE_PROTO');
  524. var EmptyConstructor = function () { /* empty */ };
  525. var scriptTag = function (content) {
  526. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  527. };
  528. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  529. var NullProtoObjectViaActiveX = function (activeXDocument) {
  530. activeXDocument.write(scriptTag(''));
  531. activeXDocument.close();
  532. var temp = activeXDocument.parentWindow.Object;
  533. activeXDocument = null; // avoid memory leak
  534. return temp;
  535. };
  536. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  537. var NullProtoObjectViaIFrame = function () {
  538. // Thrash, waste and sodomy: IE GC bug
  539. var iframe = documentCreateElement('iframe');
  540. var JS = 'java' + SCRIPT + ':';
  541. var iframeDocument;
  542. iframe.style.display = 'none';
  543. html.appendChild(iframe);
  544. // https://github.com/zloirock/core-js/issues/475
  545. iframe.src = String(JS);
  546. iframeDocument = iframe.contentWindow.document;
  547. iframeDocument.open();
  548. iframeDocument.write(scriptTag('document.F=Object'));
  549. iframeDocument.close();
  550. return iframeDocument.F;
  551. };
  552. // Check for document.domain and active x support
  553. // No need to use active x approach when document.domain is not set
  554. // see https://github.com/es-shims/es5-shim/issues/150
  555. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  556. // avoid IE GC bug
  557. var activeXDocument;
  558. var NullProtoObject = function () {
  559. try {
  560. /* global ActiveXObject */
  561. activeXDocument = document.domain && new ActiveXObject('htmlfile');
  562. } catch (error) { /* ignore */ }
  563. NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
  564. var length = enumBugKeys.length;
  565. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  566. return NullProtoObject();
  567. };
  568. hiddenKeys[IE_PROTO] = true;
  569. // `Object.create` method
  570. // https://tc39.github.io/ecma262/#sec-object.create
  571. var objectCreate = Object.create || function create(O, Properties) {
  572. var result;
  573. if (O !== null) {
  574. EmptyConstructor[PROTOTYPE] = anObject(O);
  575. result = new EmptyConstructor();
  576. EmptyConstructor[PROTOTYPE] = null;
  577. // add "__proto__" for Object.getPrototypeOf polyfill
  578. result[IE_PROTO] = O;
  579. } else result = NullProtoObject();
  580. return Properties === undefined ? result : objectDefineProperties(result, Properties);
  581. };
  582. var nativeGetOwnPropertyNames = objectGetOwnPropertyNames.f;
  583. var toString$1 = {}.toString;
  584. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  585. ? Object.getOwnPropertyNames(window) : [];
  586. var getWindowNames = function (it) {
  587. try {
  588. return nativeGetOwnPropertyNames(it);
  589. } catch (error) {
  590. return windowNames.slice();
  591. }
  592. };
  593. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  594. var f$5 = function getOwnPropertyNames(it) {
  595. return windowNames && toString$1.call(it) == '[object Window]'
  596. ? getWindowNames(it)
  597. : nativeGetOwnPropertyNames(toIndexedObject(it));
  598. };
  599. var objectGetOwnPropertyNamesExternal = {
  600. f: f$5
  601. };
  602. var WellKnownSymbolsStore = shared('wks');
  603. var Symbol$1 = global_1.Symbol;
  604. var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
  605. var wellKnownSymbol = function (name) {
  606. if (!has(WellKnownSymbolsStore, name)) {
  607. if (nativeSymbol && has(Symbol$1, name)) WellKnownSymbolsStore[name] = Symbol$1[name];
  608. else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  609. } return WellKnownSymbolsStore[name];
  610. };
  611. var f$6 = wellKnownSymbol;
  612. var wellKnownSymbolWrapped = {
  613. f: f$6
  614. };
  615. var defineProperty = objectDefineProperty.f;
  616. var defineWellKnownSymbol = function (NAME) {
  617. var Symbol = path.Symbol || (path.Symbol = {});
  618. if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
  619. value: wellKnownSymbolWrapped.f(NAME)
  620. });
  621. };
  622. var defineProperty$1 = objectDefineProperty.f;
  623. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  624. var setToStringTag = function (it, TAG, STATIC) {
  625. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  626. defineProperty$1(it, TO_STRING_TAG, { configurable: true, value: TAG });
  627. }
  628. };
  629. var aFunction$1 = function (it) {
  630. if (typeof it != 'function') {
  631. throw TypeError(String(it) + ' is not a function');
  632. } return it;
  633. };
  634. // optional / simple context binding
  635. var functionBindContext = function (fn, that, length) {
  636. aFunction$1(fn);
  637. if (that === undefined) return fn;
  638. switch (length) {
  639. case 0: return function () {
  640. return fn.call(that);
  641. };
  642. case 1: return function (a) {
  643. return fn.call(that, a);
  644. };
  645. case 2: return function (a, b) {
  646. return fn.call(that, a, b);
  647. };
  648. case 3: return function (a, b, c) {
  649. return fn.call(that, a, b, c);
  650. };
  651. }
  652. return function (/* ...args */) {
  653. return fn.apply(that, arguments);
  654. };
  655. };
  656. var SPECIES = wellKnownSymbol('species');
  657. // `ArraySpeciesCreate` abstract operation
  658. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  659. var arraySpeciesCreate = function (originalArray, length) {
  660. var C;
  661. if (isArray(originalArray)) {
  662. C = originalArray.constructor;
  663. // cross-realm fallback
  664. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  665. else if (isObject(C)) {
  666. C = C[SPECIES];
  667. if (C === null) C = undefined;
  668. }
  669. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  670. };
  671. var push = [].push;
  672. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  673. var createMethod$1 = function (TYPE) {
  674. var IS_MAP = TYPE == 1;
  675. var IS_FILTER = TYPE == 2;
  676. var IS_SOME = TYPE == 3;
  677. var IS_EVERY = TYPE == 4;
  678. var IS_FIND_INDEX = TYPE == 6;
  679. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  680. return function ($this, callbackfn, that, specificCreate) {
  681. var O = toObject($this);
  682. var self = indexedObject(O);
  683. var boundFunction = functionBindContext(callbackfn, that, 3);
  684. var length = toLength(self.length);
  685. var index = 0;
  686. var create = specificCreate || arraySpeciesCreate;
  687. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  688. var value, result;
  689. for (;length > index; index++) if (NO_HOLES || index in self) {
  690. value = self[index];
  691. result = boundFunction(value, index, O);
  692. if (TYPE) {
  693. if (IS_MAP) target[index] = result; // map
  694. else if (result) switch (TYPE) {
  695. case 3: return true; // some
  696. case 5: return value; // find
  697. case 6: return index; // findIndex
  698. case 2: push.call(target, value); // filter
  699. } else if (IS_EVERY) return false; // every
  700. }
  701. }
  702. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  703. };
  704. };
  705. var arrayIteration = {
  706. // `Array.prototype.forEach` method
  707. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  708. forEach: createMethod$1(0),
  709. // `Array.prototype.map` method
  710. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  711. map: createMethod$1(1),
  712. // `Array.prototype.filter` method
  713. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  714. filter: createMethod$1(2),
  715. // `Array.prototype.some` method
  716. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  717. some: createMethod$1(3),
  718. // `Array.prototype.every` method
  719. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  720. every: createMethod$1(4),
  721. // `Array.prototype.find` method
  722. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  723. find: createMethod$1(5),
  724. // `Array.prototype.findIndex` method
  725. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  726. findIndex: createMethod$1(6)
  727. };
  728. var $forEach = arrayIteration.forEach;
  729. var HIDDEN = sharedKey('hidden');
  730. var SYMBOL = 'Symbol';
  731. var PROTOTYPE$1 = 'prototype';
  732. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  733. var setInternalState = internalState.set;
  734. var getInternalState = internalState.getterFor(SYMBOL);
  735. var ObjectPrototype = Object[PROTOTYPE$1];
  736. var $Symbol = global_1.Symbol;
  737. var $stringify = getBuiltIn('JSON', 'stringify');
  738. var nativeGetOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
  739. var nativeDefineProperty$1 = objectDefineProperty.f;
  740. var nativeGetOwnPropertyNames$1 = objectGetOwnPropertyNamesExternal.f;
  741. var nativePropertyIsEnumerable$1 = objectPropertyIsEnumerable.f;
  742. var AllSymbols = shared('symbols');
  743. var ObjectPrototypeSymbols = shared('op-symbols');
  744. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  745. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  746. var WellKnownSymbolsStore$1 = shared('wks');
  747. var QObject = global_1.QObject;
  748. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  749. var USE_SETTER = !QObject || !QObject[PROTOTYPE$1] || !QObject[PROTOTYPE$1].findChild;
  750. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  751. var setSymbolDescriptor = descriptors && fails(function () {
  752. return objectCreate(nativeDefineProperty$1({}, 'a', {
  753. get: function () { return nativeDefineProperty$1(this, 'a', { value: 7 }).a; }
  754. })).a != 7;
  755. }) ? function (O, P, Attributes) {
  756. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$1(ObjectPrototype, P);
  757. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  758. nativeDefineProperty$1(O, P, Attributes);
  759. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  760. nativeDefineProperty$1(ObjectPrototype, P, ObjectPrototypeDescriptor);
  761. }
  762. } : nativeDefineProperty$1;
  763. var wrap = function (tag, description) {
  764. var symbol = AllSymbols[tag] = objectCreate($Symbol[PROTOTYPE$1]);
  765. setInternalState(symbol, {
  766. type: SYMBOL,
  767. tag: tag,
  768. description: description
  769. });
  770. if (!descriptors) symbol.description = description;
  771. return symbol;
  772. };
  773. var isSymbol = useSymbolAsUid ? function (it) {
  774. return typeof it == 'symbol';
  775. } : function (it) {
  776. return Object(it) instanceof $Symbol;
  777. };
  778. var $defineProperty = function defineProperty(O, P, Attributes) {
  779. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  780. anObject(O);
  781. var key = toPrimitive(P, true);
  782. anObject(Attributes);
  783. if (has(AllSymbols, key)) {
  784. if (!Attributes.enumerable) {
  785. if (!has(O, HIDDEN)) nativeDefineProperty$1(O, HIDDEN, createPropertyDescriptor(1, {}));
  786. O[HIDDEN][key] = true;
  787. } else {
  788. if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  789. Attributes = objectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  790. } return setSymbolDescriptor(O, key, Attributes);
  791. } return nativeDefineProperty$1(O, key, Attributes);
  792. };
  793. var $defineProperties = function defineProperties(O, Properties) {
  794. anObject(O);
  795. var properties = toIndexedObject(Properties);
  796. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  797. $forEach(keys, function (key) {
  798. if (!descriptors || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
  799. });
  800. return O;
  801. };
  802. var $create = function create(O, Properties) {
  803. return Properties === undefined ? objectCreate(O) : $defineProperties(objectCreate(O), Properties);
  804. };
  805. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  806. var P = toPrimitive(V, true);
  807. var enumerable = nativePropertyIsEnumerable$1.call(this, P);
  808. if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;
  809. return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
  810. };
  811. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  812. var it = toIndexedObject(O);
  813. var key = toPrimitive(P, true);
  814. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
  815. var descriptor = nativeGetOwnPropertyDescriptor$1(it, key);
  816. if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
  817. descriptor.enumerable = true;
  818. }
  819. return descriptor;
  820. };
  821. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  822. var names = nativeGetOwnPropertyNames$1(toIndexedObject(O));
  823. var result = [];
  824. $forEach(names, function (key) {
  825. if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);
  826. });
  827. return result;
  828. };
  829. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  830. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  831. var names = nativeGetOwnPropertyNames$1(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  832. var result = [];
  833. $forEach(names, function (key) {
  834. if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
  835. result.push(AllSymbols[key]);
  836. }
  837. });
  838. return result;
  839. };
  840. // `Symbol` constructor
  841. // https://tc39.github.io/ecma262/#sec-symbol-constructor
  842. if (!nativeSymbol) {
  843. $Symbol = function Symbol() {
  844. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
  845. var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
  846. var tag = uid(description);
  847. var setter = function (value) {
  848. if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
  849. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  850. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  851. };
  852. if (descriptors && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  853. return wrap(tag, description);
  854. };
  855. redefine($Symbol[PROTOTYPE$1], 'toString', function toString() {
  856. return getInternalState(this).tag;
  857. });
  858. redefine($Symbol, 'withoutSetter', function (description) {
  859. return wrap(uid(description), description);
  860. });
  861. objectPropertyIsEnumerable.f = $propertyIsEnumerable;
  862. objectDefineProperty.f = $defineProperty;
  863. objectGetOwnPropertyDescriptor.f = $getOwnPropertyDescriptor;
  864. objectGetOwnPropertyNames.f = objectGetOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  865. objectGetOwnPropertySymbols.f = $getOwnPropertySymbols;
  866. wellKnownSymbolWrapped.f = function (name) {
  867. return wrap(wellKnownSymbol(name), name);
  868. };
  869. if (descriptors) {
  870. // https://github.com/tc39/proposal-Symbol-description
  871. nativeDefineProperty$1($Symbol[PROTOTYPE$1], 'description', {
  872. configurable: true,
  873. get: function description() {
  874. return getInternalState(this).description;
  875. }
  876. });
  877. {
  878. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  879. }
  880. }
  881. }
  882. _export({ global: true, wrap: true, forced: !nativeSymbol, sham: !nativeSymbol }, {
  883. Symbol: $Symbol
  884. });
  885. $forEach(objectKeys(WellKnownSymbolsStore$1), function (name) {
  886. defineWellKnownSymbol(name);
  887. });
  888. _export({ target: SYMBOL, stat: true, forced: !nativeSymbol }, {
  889. // `Symbol.for` method
  890. // https://tc39.github.io/ecma262/#sec-symbol.for
  891. 'for': function (key) {
  892. var string = String(key);
  893. if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  894. var symbol = $Symbol(string);
  895. StringToSymbolRegistry[string] = symbol;
  896. SymbolToStringRegistry[symbol] = string;
  897. return symbol;
  898. },
  899. // `Symbol.keyFor` method
  900. // https://tc39.github.io/ecma262/#sec-symbol.keyfor
  901. keyFor: function keyFor(sym) {
  902. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
  903. if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  904. },
  905. useSetter: function () { USE_SETTER = true; },
  906. useSimple: function () { USE_SETTER = false; }
  907. });
  908. _export({ target: 'Object', stat: true, forced: !nativeSymbol, sham: !descriptors }, {
  909. // `Object.create` method
  910. // https://tc39.github.io/ecma262/#sec-object.create
  911. create: $create,
  912. // `Object.defineProperty` method
  913. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  914. defineProperty: $defineProperty,
  915. // `Object.defineProperties` method
  916. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  917. defineProperties: $defineProperties,
  918. // `Object.getOwnPropertyDescriptor` method
  919. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  920. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  921. });
  922. _export({ target: 'Object', stat: true, forced: !nativeSymbol }, {
  923. // `Object.getOwnPropertyNames` method
  924. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  925. getOwnPropertyNames: $getOwnPropertyNames,
  926. // `Object.getOwnPropertySymbols` method
  927. // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
  928. getOwnPropertySymbols: $getOwnPropertySymbols
  929. });
  930. // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  931. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  932. _export({ target: 'Object', stat: true, forced: fails(function () { objectGetOwnPropertySymbols.f(1); }) }, {
  933. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  934. return objectGetOwnPropertySymbols.f(toObject(it));
  935. }
  936. });
  937. // `JSON.stringify` method behavior with symbols
  938. // https://tc39.github.io/ecma262/#sec-json.stringify
  939. if ($stringify) {
  940. var FORCED_JSON_STRINGIFY = !nativeSymbol || fails(function () {
  941. var symbol = $Symbol();
  942. // MS Edge converts symbol values to JSON as {}
  943. return $stringify([symbol]) != '[null]'
  944. // WebKit converts symbol values to JSON as null
  945. || $stringify({ a: symbol }) != '{}'
  946. // V8 throws on boxed symbols
  947. || $stringify(Object(symbol)) != '{}';
  948. });
  949. _export({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
  950. // eslint-disable-next-line no-unused-vars
  951. stringify: function stringify(it, replacer, space) {
  952. var args = [it];
  953. var index = 1;
  954. var $replacer;
  955. while (arguments.length > index) args.push(arguments[index++]);
  956. $replacer = replacer;
  957. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  958. if (!isArray(replacer)) replacer = function (key, value) {
  959. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  960. if (!isSymbol(value)) return value;
  961. };
  962. args[1] = replacer;
  963. return $stringify.apply(null, args);
  964. }
  965. });
  966. }
  967. // `Symbol.prototype[@@toPrimitive]` method
  968. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
  969. if (!$Symbol[PROTOTYPE$1][TO_PRIMITIVE]) {
  970. createNonEnumerableProperty($Symbol[PROTOTYPE$1], TO_PRIMITIVE, $Symbol[PROTOTYPE$1].valueOf);
  971. }
  972. // `Symbol.prototype[@@toStringTag]` property
  973. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
  974. setToStringTag($Symbol, SYMBOL);
  975. hiddenKeys[HIDDEN] = true;
  976. var defineProperty$2 = objectDefineProperty.f;
  977. var NativeSymbol = global_1.Symbol;
  978. if (descriptors && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
  979. // Safari 12 bug
  980. NativeSymbol().description !== undefined
  981. )) {
  982. var EmptyStringDescriptionStore = {};
  983. // wrap Symbol constructor for correct work with undefined description
  984. var SymbolWrapper = function Symbol() {
  985. var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
  986. var result = this instanceof SymbolWrapper
  987. ? new NativeSymbol(description)
  988. // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
  989. : description === undefined ? NativeSymbol() : NativeSymbol(description);
  990. if (description === '') EmptyStringDescriptionStore[result] = true;
  991. return result;
  992. };
  993. copyConstructorProperties(SymbolWrapper, NativeSymbol);
  994. var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
  995. symbolPrototype.constructor = SymbolWrapper;
  996. var symbolToString = symbolPrototype.toString;
  997. var native = String(NativeSymbol('test')) == 'Symbol(test)';
  998. var regexp = /^Symbol\((.*)\)[^)]+$/;
  999. defineProperty$2(symbolPrototype, 'description', {
  1000. configurable: true,
  1001. get: function description() {
  1002. var symbol = isObject(this) ? this.valueOf() : this;
  1003. var string = symbolToString.call(symbol);
  1004. if (has(EmptyStringDescriptionStore, symbol)) return '';
  1005. var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
  1006. return desc === '' ? undefined : desc;
  1007. }
  1008. });
  1009. _export({ global: true, forced: true }, {
  1010. Symbol: SymbolWrapper
  1011. });
  1012. }
  1013. // `Symbol.iterator` well-known symbol
  1014. // https://tc39.github.io/ecma262/#sec-symbol.iterator
  1015. defineWellKnownSymbol('iterator');
  1016. var arrayMethodIsStrict = function (METHOD_NAME, argument) {
  1017. var method = [][METHOD_NAME];
  1018. return !!method && fails(function () {
  1019. // eslint-disable-next-line no-useless-call,no-throw-literal
  1020. method.call(null, argument || function () { throw 1; }, 1);
  1021. });
  1022. };
  1023. var defineProperty$3 = Object.defineProperty;
  1024. var cache = {};
  1025. var thrower = function (it) { throw it; };
  1026. var arrayMethodUsesToLength = function (METHOD_NAME, options) {
  1027. if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
  1028. if (!options) options = {};
  1029. var method = [][METHOD_NAME];
  1030. var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
  1031. var argument0 = has(options, 0) ? options[0] : thrower;
  1032. var argument1 = has(options, 1) ? options[1] : undefined;
  1033. return cache[METHOD_NAME] = !!method && !fails(function () {
  1034. if (ACCESSORS && !descriptors) return true;
  1035. var O = { length: -1 };
  1036. if (ACCESSORS) defineProperty$3(O, 1, { enumerable: true, get: thrower });
  1037. else O[1] = 1;
  1038. method.call(O, argument0, argument1);
  1039. });
  1040. };
  1041. var $forEach$1 = arrayIteration.forEach;
  1042. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  1043. var USES_TO_LENGTH = arrayMethodUsesToLength('forEach');
  1044. // `Array.prototype.forEach` method implementation
  1045. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  1046. var arrayForEach = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) {
  1047. return $forEach$1(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  1048. } : [].forEach;
  1049. // `Array.prototype.forEach` method
  1050. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  1051. _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, {
  1052. forEach: arrayForEach
  1053. });
  1054. var $indexOf = arrayIncludes.indexOf;
  1055. var nativeIndexOf = [].indexOf;
  1056. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
  1057. var STRICT_METHOD$1 = arrayMethodIsStrict('indexOf');
  1058. var USES_TO_LENGTH$1 = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  1059. // `Array.prototype.indexOf` method
  1060. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  1061. _export({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD$1 || !USES_TO_LENGTH$1 }, {
  1062. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  1063. return NEGATIVE_ZERO
  1064. // convert -0 to +0
  1065. ? nativeIndexOf.apply(this, arguments) || 0
  1066. : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
  1067. }
  1068. });
  1069. var UNSCOPABLES = wellKnownSymbol('unscopables');
  1070. var ArrayPrototype = Array.prototype;
  1071. // Array.prototype[@@unscopables]
  1072. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  1073. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  1074. objectDefineProperty.f(ArrayPrototype, UNSCOPABLES, {
  1075. configurable: true,
  1076. value: objectCreate(null)
  1077. });
  1078. }
  1079. // add a key to Array.prototype[@@unscopables]
  1080. var addToUnscopables = function (key) {
  1081. ArrayPrototype[UNSCOPABLES][key] = true;
  1082. };
  1083. var iterators = {};
  1084. var correctPrototypeGetter = !fails(function () {
  1085. function F() { /* empty */ }
  1086. F.prototype.constructor = null;
  1087. return Object.getPrototypeOf(new F()) !== F.prototype;
  1088. });
  1089. var IE_PROTO$1 = sharedKey('IE_PROTO');
  1090. var ObjectPrototype$1 = Object.prototype;
  1091. // `Object.getPrototypeOf` method
  1092. // https://tc39.github.io/ecma262/#sec-object.getprototypeof
  1093. var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
  1094. O = toObject(O);
  1095. if (has(O, IE_PROTO$1)) return O[IE_PROTO$1];
  1096. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1097. return O.constructor.prototype;
  1098. } return O instanceof Object ? ObjectPrototype$1 : null;
  1099. };
  1100. var ITERATOR = wellKnownSymbol('iterator');
  1101. var BUGGY_SAFARI_ITERATORS = false;
  1102. var returnThis = function () { return this; };
  1103. // `%IteratorPrototype%` object
  1104. // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
  1105. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  1106. if ([].keys) {
  1107. arrayIterator = [].keys();
  1108. // Safari 8 has buggy iterators w/o `next`
  1109. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  1110. else {
  1111. PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
  1112. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  1113. }
  1114. }
  1115. if (IteratorPrototype == undefined) IteratorPrototype = {};
  1116. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  1117. if ( !has(IteratorPrototype, ITERATOR)) {
  1118. createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
  1119. }
  1120. var iteratorsCore = {
  1121. IteratorPrototype: IteratorPrototype,
  1122. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  1123. };
  1124. var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
  1125. var returnThis$1 = function () { return this; };
  1126. var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
  1127. var TO_STRING_TAG = NAME + ' Iterator';
  1128. IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(1, next) });
  1129. setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
  1130. iterators[TO_STRING_TAG] = returnThis$1;
  1131. return IteratorConstructor;
  1132. };
  1133. var aPossiblePrototype = function (it) {
  1134. if (!isObject(it) && it !== null) {
  1135. throw TypeError("Can't set " + String(it) + ' as a prototype');
  1136. } return it;
  1137. };
  1138. // `Object.setPrototypeOf` method
  1139. // https://tc39.github.io/ecma262/#sec-object.setprototypeof
  1140. // Works with __proto__ only. Old v8 can't work with null proto objects.
  1141. /* eslint-disable no-proto */
  1142. var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  1143. var CORRECT_SETTER = false;
  1144. var test = {};
  1145. var setter;
  1146. try {
  1147. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  1148. setter.call(test, []);
  1149. CORRECT_SETTER = test instanceof Array;
  1150. } catch (error) { /* empty */ }
  1151. return function setPrototypeOf(O, proto) {
  1152. anObject(O);
  1153. aPossiblePrototype(proto);
  1154. if (CORRECT_SETTER) setter.call(O, proto);
  1155. else O.__proto__ = proto;
  1156. return O;
  1157. };
  1158. }() : undefined);
  1159. var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
  1160. var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
  1161. var ITERATOR$1 = wellKnownSymbol('iterator');
  1162. var KEYS = 'keys';
  1163. var VALUES = 'values';
  1164. var ENTRIES = 'entries';
  1165. var returnThis$2 = function () { return this; };
  1166. var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  1167. createIteratorConstructor(IteratorConstructor, NAME, next);
  1168. var getIterationMethod = function (KIND) {
  1169. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  1170. if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
  1171. switch (KIND) {
  1172. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  1173. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  1174. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  1175. } return function () { return new IteratorConstructor(this); };
  1176. };
  1177. var TO_STRING_TAG = NAME + ' Iterator';
  1178. var INCORRECT_VALUES_NAME = false;
  1179. var IterablePrototype = Iterable.prototype;
  1180. var nativeIterator = IterablePrototype[ITERATOR$1]
  1181. || IterablePrototype['@@iterator']
  1182. || DEFAULT && IterablePrototype[DEFAULT];
  1183. var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
  1184. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  1185. var CurrentIteratorPrototype, methods, KEY;
  1186. // fix native
  1187. if (anyNativeIterator) {
  1188. CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
  1189. if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
  1190. if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) {
  1191. if (objectSetPrototypeOf) {
  1192. objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
  1193. } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') {
  1194. createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR$1, returnThis$2);
  1195. }
  1196. }
  1197. // Set @@toStringTag to native iterators
  1198. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
  1199. }
  1200. }
  1201. // fix Array#{values, @@iterator}.name in V8 / FF
  1202. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  1203. INCORRECT_VALUES_NAME = true;
  1204. defaultIterator = function values() { return nativeIterator.call(this); };
  1205. }
  1206. // define iterator
  1207. if ( IterablePrototype[ITERATOR$1] !== defaultIterator) {
  1208. createNonEnumerableProperty(IterablePrototype, ITERATOR$1, defaultIterator);
  1209. }
  1210. iterators[NAME] = defaultIterator;
  1211. // export additional methods
  1212. if (DEFAULT) {
  1213. methods = {
  1214. values: getIterationMethod(VALUES),
  1215. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  1216. entries: getIterationMethod(ENTRIES)
  1217. };
  1218. if (FORCED) for (KEY in methods) {
  1219. if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  1220. redefine(IterablePrototype, KEY, methods[KEY]);
  1221. }
  1222. } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME }, methods);
  1223. }
  1224. return methods;
  1225. };
  1226. var ARRAY_ITERATOR = 'Array Iterator';
  1227. var setInternalState$1 = internalState.set;
  1228. var getInternalState$1 = internalState.getterFor(ARRAY_ITERATOR);
  1229. // `Array.prototype.entries` method
  1230. // https://tc39.github.io/ecma262/#sec-array.prototype.entries
  1231. // `Array.prototype.keys` method
  1232. // https://tc39.github.io/ecma262/#sec-array.prototype.keys
  1233. // `Array.prototype.values` method
  1234. // https://tc39.github.io/ecma262/#sec-array.prototype.values
  1235. // `Array.prototype[@@iterator]` method
  1236. // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
  1237. // `CreateArrayIterator` internal method
  1238. // https://tc39.github.io/ecma262/#sec-createarrayiterator
  1239. var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
  1240. setInternalState$1(this, {
  1241. type: ARRAY_ITERATOR,
  1242. target: toIndexedObject(iterated), // target
  1243. index: 0, // next index
  1244. kind: kind // kind
  1245. });
  1246. // `%ArrayIteratorPrototype%.next` method
  1247. // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
  1248. }, function () {
  1249. var state = getInternalState$1(this);
  1250. var target = state.target;
  1251. var kind = state.kind;
  1252. var index = state.index++;
  1253. if (!target || index >= target.length) {
  1254. state.target = undefined;
  1255. return { value: undefined, done: true };
  1256. }
  1257. if (kind == 'keys') return { value: index, done: false };
  1258. if (kind == 'values') return { value: target[index], done: false };
  1259. return { value: [index, target[index]], done: false };
  1260. }, 'values');
  1261. // argumentsList[@@iterator] is %ArrayProto_values%
  1262. // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
  1263. // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
  1264. iterators.Arguments = iterators.Array;
  1265. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  1266. addToUnscopables('keys');
  1267. addToUnscopables('values');
  1268. addToUnscopables('entries');
  1269. var nativeJoin = [].join;
  1270. var ES3_STRINGS = indexedObject != Object;
  1271. var STRICT_METHOD$2 = arrayMethodIsStrict('join', ',');
  1272. // `Array.prototype.join` method
  1273. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  1274. _export({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD$2 }, {
  1275. join: function join(separator) {
  1276. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  1277. }
  1278. });
  1279. var createProperty = function (object, key, value) {
  1280. var propertyKey = toPrimitive(key);
  1281. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  1282. else object[propertyKey] = value;
  1283. };
  1284. var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
  1285. var process = global_1.process;
  1286. var versions = process && process.versions;
  1287. var v8 = versions && versions.v8;
  1288. var match, version;
  1289. if (v8) {
  1290. match = v8.split('.');
  1291. version = match[0] + match[1];
  1292. } else if (engineUserAgent) {
  1293. match = engineUserAgent.match(/Edge\/(\d+)/);
  1294. if (!match || match[1] >= 74) {
  1295. match = engineUserAgent.match(/Chrome\/(\d+)/);
  1296. if (match) version = match[1];
  1297. }
  1298. }
  1299. var engineV8Version = version && +version;
  1300. var SPECIES$1 = wellKnownSymbol('species');
  1301. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  1302. // We can't use this feature detection in V8 since it causes
  1303. // deoptimization and serious performance degradation
  1304. // https://github.com/zloirock/core-js/issues/677
  1305. return engineV8Version >= 51 || !fails(function () {
  1306. var array = [];
  1307. var constructor = array.constructor = {};
  1308. constructor[SPECIES$1] = function () {
  1309. return { foo: 1 };
  1310. };
  1311. return array[METHOD_NAME](Boolean).foo !== 1;
  1312. });
  1313. };
  1314. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  1315. var USES_TO_LENGTH$2 = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 });
  1316. var SPECIES$2 = wellKnownSymbol('species');
  1317. var nativeSlice = [].slice;
  1318. var max$1 = Math.max;
  1319. // `Array.prototype.slice` method
  1320. // https://tc39.github.io/ecma262/#sec-array.prototype.slice
  1321. // fallback for not array-like ES3 strings and DOM objects
  1322. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH$2 }, {
  1323. slice: function slice(start, end) {
  1324. var O = toIndexedObject(this);
  1325. var length = toLength(O.length);
  1326. var k = toAbsoluteIndex(start, length);
  1327. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  1328. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  1329. var Constructor, result, n;
  1330. if (isArray(O)) {
  1331. Constructor = O.constructor;
  1332. // cross-realm fallback
  1333. if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
  1334. Constructor = undefined;
  1335. } else if (isObject(Constructor)) {
  1336. Constructor = Constructor[SPECIES$2];
  1337. if (Constructor === null) Constructor = undefined;
  1338. }
  1339. if (Constructor === Array || Constructor === undefined) {
  1340. return nativeSlice.call(O, k, fin);
  1341. }
  1342. }
  1343. result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
  1344. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  1345. result.length = n;
  1346. return result;
  1347. }
  1348. });
  1349. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  1350. var test = {};
  1351. test[TO_STRING_TAG$1] = 'z';
  1352. var toStringTagSupport = String(test) === '[object z]';
  1353. var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
  1354. // ES3 wrong here
  1355. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  1356. // fallback for IE11 Script Access Denied error
  1357. var tryGet = function (it, key) {
  1358. try {
  1359. return it[key];
  1360. } catch (error) { /* empty */ }
  1361. };
  1362. // getting tag from ES6+ `Object.prototype.toString`
  1363. var classof = toStringTagSupport ? classofRaw : function (it) {
  1364. var O, tag, result;
  1365. return it === undefined ? 'Undefined' : it === null ? 'Null'
  1366. // @@toStringTag case
  1367. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$2)) == 'string' ? tag
  1368. // builtinTag case
  1369. : CORRECT_ARGUMENTS ? classofRaw(O)
  1370. // ES3 arguments fallback
  1371. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  1372. };
  1373. // `Object.prototype.toString` method implementation
  1374. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  1375. var objectToString = toStringTagSupport ? {}.toString : function toString() {
  1376. return '[object ' + classof(this) + ']';
  1377. };
  1378. // `Object.prototype.toString` method
  1379. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  1380. if (!toStringTagSupport) {
  1381. redefine(Object.prototype, 'toString', objectToString, { unsafe: true });
  1382. }
  1383. // `RegExp.prototype.flags` getter implementation
  1384. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  1385. var regexpFlags = function () {
  1386. var that = anObject(this);
  1387. var result = '';
  1388. if (that.global) result += 'g';
  1389. if (that.ignoreCase) result += 'i';
  1390. if (that.multiline) result += 'm';
  1391. if (that.dotAll) result += 's';
  1392. if (that.unicode) result += 'u';
  1393. if (that.sticky) result += 'y';
  1394. return result;
  1395. };
  1396. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
  1397. // so we use an intermediate function.
  1398. function RE(s, f) {
  1399. return RegExp(s, f);
  1400. }
  1401. var UNSUPPORTED_Y = fails(function () {
  1402. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  1403. var re = RE('a', 'y');
  1404. re.lastIndex = 2;
  1405. return re.exec('abcd') != null;
  1406. });
  1407. var BROKEN_CARET = fails(function () {
  1408. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  1409. var re = RE('^r', 'gy');
  1410. re.lastIndex = 2;
  1411. return re.exec('str') != null;
  1412. });
  1413. var regexpStickyHelpers = {
  1414. UNSUPPORTED_Y: UNSUPPORTED_Y,
  1415. BROKEN_CARET: BROKEN_CARET
  1416. };
  1417. var nativeExec = RegExp.prototype.exec;
  1418. // This always refers to the native implementation, because the
  1419. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  1420. // which loads this file before patching the method.
  1421. var nativeReplace = String.prototype.replace;
  1422. var patchedExec = nativeExec;
  1423. var UPDATES_LAST_INDEX_WRONG = (function () {
  1424. var re1 = /a/;
  1425. var re2 = /b*/g;
  1426. nativeExec.call(re1, 'a');
  1427. nativeExec.call(re2, 'a');
  1428. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  1429. })();
  1430. var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y || regexpStickyHelpers.BROKEN_CARET;
  1431. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  1432. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  1433. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1;
  1434. if (PATCH) {
  1435. patchedExec = function exec(str) {
  1436. var re = this;
  1437. var lastIndex, reCopy, match, i;
  1438. var sticky = UNSUPPORTED_Y$1 && re.sticky;
  1439. var flags = regexpFlags.call(re);
  1440. var source = re.source;
  1441. var charsAdded = 0;
  1442. var strCopy = str;
  1443. if (sticky) {
  1444. flags = flags.replace('y', '');
  1445. if (flags.indexOf('g') === -1) {
  1446. flags += 'g';
  1447. }
  1448. strCopy = String(str).slice(re.lastIndex);
  1449. // Support anchored sticky behavior.
  1450. if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\n')) {
  1451. source = '(?: ' + source + ')';
  1452. strCopy = ' ' + strCopy;
  1453. charsAdded++;
  1454. }
  1455. // ^(? + rx + ) is needed, in combination with some str slicing, to
  1456. // simulate the 'y' flag.
  1457. reCopy = new RegExp('^(?:' + source + ')', flags);
  1458. }
  1459. if (NPCG_INCLUDED) {
  1460. reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
  1461. }
  1462. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  1463. match = nativeExec.call(sticky ? reCopy : re, strCopy);
  1464. if (sticky) {
  1465. if (match) {
  1466. match.input = match.input.slice(charsAdded);
  1467. match[0] = match[0].slice(charsAdded);
  1468. match.index = re.lastIndex;
  1469. re.lastIndex += match[0].length;
  1470. } else re.lastIndex = 0;
  1471. } else if (UPDATES_LAST_INDEX_WRONG && match) {
  1472. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  1473. }
  1474. if (NPCG_INCLUDED && match && match.length > 1) {
  1475. // Fix browsers whose `exec` methods don't consistently return `undefined`
  1476. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  1477. nativeReplace.call(match[0], reCopy, function () {
  1478. for (i = 1; i < arguments.length - 2; i++) {
  1479. if (arguments[i] === undefined) match[i] = undefined;
  1480. }
  1481. });
  1482. }
  1483. return match;
  1484. };
  1485. }
  1486. var regexpExec = patchedExec;
  1487. _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
  1488. exec: regexpExec
  1489. });
  1490. var TO_STRING = 'toString';
  1491. var RegExpPrototype = RegExp.prototype;
  1492. var nativeToString = RegExpPrototype[TO_STRING];
  1493. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
  1494. // FF44- RegExp#toString has a wrong name
  1495. var INCORRECT_NAME = nativeToString.name != TO_STRING;
  1496. // `RegExp.prototype.toString` method
  1497. // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
  1498. if (NOT_GENERIC || INCORRECT_NAME) {
  1499. redefine(RegExp.prototype, TO_STRING, function toString() {
  1500. var R = anObject(this);
  1501. var p = String(R.source);
  1502. var rf = R.flags;
  1503. var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? regexpFlags.call(R) : rf);
  1504. return '/' + p + '/' + f;
  1505. }, { unsafe: true });
  1506. }
  1507. // `String.prototype.{ codePointAt, at }` methods implementation
  1508. var createMethod$2 = function (CONVERT_TO_STRING) {
  1509. return function ($this, pos) {
  1510. var S = String(requireObjectCoercible($this));
  1511. var position = toInteger(pos);
  1512. var size = S.length;
  1513. var first, second;
  1514. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  1515. first = S.charCodeAt(position);
  1516. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  1517. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  1518. ? CONVERT_TO_STRING ? S.charAt(position) : first
  1519. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  1520. };
  1521. };
  1522. var stringMultibyte = {
  1523. // `String.prototype.codePointAt` method
  1524. // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
  1525. codeAt: createMethod$2(false),
  1526. // `String.prototype.at` method
  1527. // https://github.com/mathiasbynens/String.prototype.at
  1528. charAt: createMethod$2(true)
  1529. };
  1530. var charAt = stringMultibyte.charAt;
  1531. var STRING_ITERATOR = 'String Iterator';
  1532. var setInternalState$2 = internalState.set;
  1533. var getInternalState$2 = internalState.getterFor(STRING_ITERATOR);
  1534. // `String.prototype[@@iterator]` method
  1535. // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
  1536. defineIterator(String, 'String', function (iterated) {
  1537. setInternalState$2(this, {
  1538. type: STRING_ITERATOR,
  1539. string: String(iterated),
  1540. index: 0
  1541. });
  1542. // `%StringIteratorPrototype%.next` method
  1543. // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
  1544. }, function next() {
  1545. var state = getInternalState$2(this);
  1546. var string = state.string;
  1547. var index = state.index;
  1548. var point;
  1549. if (index >= string.length) return { value: undefined, done: true };
  1550. point = charAt(string, index);
  1551. state.index += point.length;
  1552. return { value: point, done: false };
  1553. });
  1554. // TODO: Remove from `core-js@4` since it's moved to entry points
  1555. var SPECIES$3 = wellKnownSymbol('species');
  1556. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  1557. // #replace needs built-in support for named groups.
  1558. // #match works fine because it just return the exec results, even if it has
  1559. // a "grops" property.
  1560. var re = /./;
  1561. re.exec = function () {
  1562. var result = [];
  1563. result.groups = { a: '7' };
  1564. return result;
  1565. };
  1566. return ''.replace(re, '$<a>') !== '7';
  1567. });
  1568. // IE <= 11 replaces $0 with the whole match, as if it was $&
  1569. // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
  1570. var REPLACE_KEEPS_$0 = (function () {
  1571. return 'a'.replace(/./, '$0') === '$0';
  1572. })();
  1573. var REPLACE = wellKnownSymbol('replace');
  1574. // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
  1575. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
  1576. if (/./[REPLACE]) {
  1577. return /./[REPLACE]('a', '$0') === '';
  1578. }
  1579. return false;
  1580. })();
  1581. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  1582. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  1583. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  1584. var re = /(?:)/;
  1585. var originalExec = re.exec;
  1586. re.exec = function () { return originalExec.apply(this, arguments); };
  1587. var result = 'ab'.split(re);
  1588. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  1589. });
  1590. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  1591. var SYMBOL = wellKnownSymbol(KEY);
  1592. var DELEGATES_TO_SYMBOL = !fails(function () {
  1593. // String methods call symbol-named RegEp methods
  1594. var O = {};
  1595. O[SYMBOL] = function () { return 7; };
  1596. return ''[KEY](O) != 7;
  1597. });
  1598. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  1599. // Symbol-named RegExp methods call .exec
  1600. var execCalled = false;
  1601. var re = /a/;
  1602. if (KEY === 'split') {
  1603. // We can't use real regex here since it causes deoptimization
  1604. // and serious performance degradation in V8
  1605. // https://github.com/zloirock/core-js/issues/306
  1606. re = {};
  1607. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  1608. // a new one. We need to return the patched regex when creating the new one.
  1609. re.constructor = {};
  1610. re.constructor[SPECIES$3] = function () { return re; };
  1611. re.flags = '';
  1612. re[SYMBOL] = /./[SYMBOL];
  1613. }
  1614. re.exec = function () { execCalled = true; return null; };
  1615. re[SYMBOL]('');
  1616. return !execCalled;
  1617. });
  1618. if (
  1619. !DELEGATES_TO_SYMBOL ||
  1620. !DELEGATES_TO_EXEC ||
  1621. (KEY === 'replace' && !(
  1622. REPLACE_SUPPORTS_NAMED_GROUPS &&
  1623. REPLACE_KEEPS_$0 &&
  1624. !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
  1625. )) ||
  1626. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  1627. ) {
  1628. var nativeRegExpMethod = /./[SYMBOL];
  1629. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  1630. if (regexp.exec === regexpExec) {
  1631. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  1632. // The native String method already delegates to @@method (this
  1633. // polyfilled function), leasing to infinite recursion.
  1634. // We avoid it by directly calling the native @@method method.
  1635. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  1636. }
  1637. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  1638. }
  1639. return { done: false };
  1640. }, {
  1641. REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,
  1642. REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
  1643. });
  1644. var stringMethod = methods[0];
  1645. var regexMethod = methods[1];
  1646. redefine(String.prototype, KEY, stringMethod);
  1647. redefine(RegExp.prototype, SYMBOL, length == 2
  1648. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  1649. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  1650. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  1651. // 21.2.5.6 RegExp.prototype[@@match](string)
  1652. // 21.2.5.9 RegExp.prototype[@@search](string)
  1653. : function (string) { return regexMethod.call(string, this); }
  1654. );
  1655. }
  1656. if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);
  1657. };
  1658. var charAt$1 = stringMultibyte.charAt;
  1659. // `AdvanceStringIndex` abstract operation
  1660. // https://tc39.github.io/ecma262/#sec-advancestringindex
  1661. var advanceStringIndex = function (S, index, unicode) {
  1662. return index + (unicode ? charAt$1(S, index).length : 1);
  1663. };
  1664. // `RegExpExec` abstract operation
  1665. // https://tc39.github.io/ecma262/#sec-regexpexec
  1666. var regexpExecAbstract = function (R, S) {
  1667. var exec = R.exec;
  1668. if (typeof exec === 'function') {
  1669. var result = exec.call(R, S);
  1670. if (typeof result !== 'object') {
  1671. throw TypeError('RegExp exec method returned something other than an Object or null');
  1672. }
  1673. return result;
  1674. }
  1675. if (classofRaw(R) !== 'RegExp') {
  1676. throw TypeError('RegExp#exec called on incompatible receiver');
  1677. }
  1678. return regexpExec.call(R, S);
  1679. };
  1680. var max$2 = Math.max;
  1681. var min$2 = Math.min;
  1682. var floor$1 = Math.floor;
  1683. var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g;
  1684. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g;
  1685. var maybeToString = function (it) {
  1686. return it === undefined ? it : String(it);
  1687. };
  1688. // @@replace logic
  1689. fixRegexpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) {
  1690. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;
  1691. var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;
  1692. var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
  1693. return [
  1694. // `String.prototype.replace` method
  1695. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  1696. function replace(searchValue, replaceValue) {
  1697. var O = requireObjectCoercible(this);
  1698. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  1699. return replacer !== undefined
  1700. ? replacer.call(searchValue, O, replaceValue)
  1701. : nativeReplace.call(String(O), searchValue, replaceValue);
  1702. },
  1703. // `RegExp.prototype[@@replace]` method
  1704. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  1705. function (regexp, replaceValue) {
  1706. if (
  1707. (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) ||
  1708. (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1)
  1709. ) {
  1710. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  1711. if (res.done) return res.value;
  1712. }
  1713. var rx = anObject(regexp);
  1714. var S = String(this);
  1715. var functionalReplace = typeof replaceValue === 'function';
  1716. if (!functionalReplace) replaceValue = String(replaceValue);
  1717. var global = rx.global;
  1718. if (global) {
  1719. var fullUnicode = rx.unicode;
  1720. rx.lastIndex = 0;
  1721. }
  1722. var results = [];
  1723. while (true) {
  1724. var result = regexpExecAbstract(rx, S);
  1725. if (result === null) break;
  1726. results.push(result);
  1727. if (!global) break;
  1728. var matchStr = String(result[0]);
  1729. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  1730. }
  1731. var accumulatedResult = '';
  1732. var nextSourcePosition = 0;
  1733. for (var i = 0; i < results.length; i++) {
  1734. result = results[i];
  1735. var matched = String(result[0]);
  1736. var position = max$2(min$2(toInteger(result.index), S.length), 0);
  1737. var captures = [];
  1738. // NOTE: This is equivalent to
  1739. // captures = result.slice(1).map(maybeToString)
  1740. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  1741. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  1742. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  1743. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  1744. var namedCaptures = result.groups;
  1745. if (functionalReplace) {
  1746. var replacerArgs = [matched].concat(captures, position, S);
  1747. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  1748. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  1749. } else {
  1750. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  1751. }
  1752. if (position >= nextSourcePosition) {
  1753. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  1754. nextSourcePosition = position + matched.length;
  1755. }
  1756. }
  1757. return accumulatedResult + S.slice(nextSourcePosition);
  1758. }
  1759. ];
  1760. // https://tc39.github.io/ecma262/#sec-getsubstitution
  1761. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  1762. var tailPos = position + matched.length;
  1763. var m = captures.length;
  1764. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  1765. if (namedCaptures !== undefined) {
  1766. namedCaptures = toObject(namedCaptures);
  1767. symbols = SUBSTITUTION_SYMBOLS;
  1768. }
  1769. return nativeReplace.call(replacement, symbols, function (match, ch) {
  1770. var capture;
  1771. switch (ch.charAt(0)) {
  1772. case '$': return '$';
  1773. case '&': return matched;
  1774. case '`': return str.slice(0, position);
  1775. case "'": return str.slice(tailPos);
  1776. case '<':
  1777. capture = namedCaptures[ch.slice(1, -1)];
  1778. break;
  1779. default: // \d\d?
  1780. var n = +ch;
  1781. if (n === 0) return match;
  1782. if (n > m) {
  1783. var f = floor$1(n / 10);
  1784. if (f === 0) return match;
  1785. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  1786. return match;
  1787. }
  1788. capture = captures[n - 1];
  1789. }
  1790. return capture === undefined ? '' : capture;
  1791. });
  1792. }
  1793. });
  1794. // `SameValue` abstract operation
  1795. // https://tc39.github.io/ecma262/#sec-samevalue
  1796. var sameValue = Object.is || function is(x, y) {
  1797. // eslint-disable-next-line no-self-compare
  1798. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  1799. };
  1800. // @@search logic
  1801. fixRegexpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) {
  1802. return [
  1803. // `String.prototype.search` method
  1804. // https://tc39.github.io/ecma262/#sec-string.prototype.search
  1805. function search(regexp) {
  1806. var O = requireObjectCoercible(this);
  1807. var searcher = regexp == undefined ? undefined : regexp[SEARCH];
  1808. return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  1809. },
  1810. // `RegExp.prototype[@@search]` method
  1811. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
  1812. function (regexp) {
  1813. var res = maybeCallNative(nativeSearch, regexp, this);
  1814. if (res.done) return res.value;
  1815. var rx = anObject(regexp);
  1816. var S = String(this);
  1817. var previousLastIndex = rx.lastIndex;
  1818. if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
  1819. var result = regexpExecAbstract(rx, S);
  1820. if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
  1821. return result === null ? -1 : result.index;
  1822. }
  1823. ];
  1824. });
  1825. var MATCH = wellKnownSymbol('match');
  1826. // `IsRegExp` abstract operation
  1827. // https://tc39.github.io/ecma262/#sec-isregexp
  1828. var isRegexp = function (it) {
  1829. var isRegExp;
  1830. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
  1831. };
  1832. var SPECIES$4 = wellKnownSymbol('species');
  1833. // `SpeciesConstructor` abstract operation
  1834. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  1835. var speciesConstructor = function (O, defaultConstructor) {
  1836. var C = anObject(O).constructor;
  1837. var S;
  1838. return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aFunction$1(S);
  1839. };
  1840. var arrayPush = [].push;
  1841. var min$3 = Math.min;
  1842. var MAX_UINT32 = 0xFFFFFFFF;
  1843. // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
  1844. var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
  1845. // @@split logic
  1846. fixRegexpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {
  1847. var internalSplit;
  1848. if (
  1849. 'abbc'.split(/(b)*/)[1] == 'c' ||
  1850. 'test'.split(/(?:)/, -1).length != 4 ||
  1851. 'ab'.split(/(?:ab)*/).length != 2 ||
  1852. '.'.split(/(.?)(.?)/).length != 4 ||
  1853. '.'.split(/()()/).length > 1 ||
  1854. ''.split(/.?/).length
  1855. ) {
  1856. // based on es5-shim implementation, need to rework it
  1857. internalSplit = function (separator, limit) {
  1858. var string = String(requireObjectCoercible(this));
  1859. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1860. if (lim === 0) return [];
  1861. if (separator === undefined) return [string];
  1862. // If `separator` is not a regex, use native split
  1863. if (!isRegexp(separator)) {
  1864. return nativeSplit.call(string, separator, lim);
  1865. }
  1866. var output = [];
  1867. var flags = (separator.ignoreCase ? 'i' : '') +
  1868. (separator.multiline ? 'm' : '') +
  1869. (separator.unicode ? 'u' : '') +
  1870. (separator.sticky ? 'y' : '');
  1871. var lastLastIndex = 0;
  1872. // Make `global` and avoid `lastIndex` issues by working with a copy
  1873. var separatorCopy = new RegExp(separator.source, flags + 'g');
  1874. var match, lastIndex, lastLength;
  1875. while (match = regexpExec.call(separatorCopy, string)) {
  1876. lastIndex = separatorCopy.lastIndex;
  1877. if (lastIndex > lastLastIndex) {
  1878. output.push(string.slice(lastLastIndex, match.index));
  1879. if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
  1880. lastLength = match[0].length;
  1881. lastLastIndex = lastIndex;
  1882. if (output.length >= lim) break;
  1883. }
  1884. if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
  1885. }
  1886. if (lastLastIndex === string.length) {
  1887. if (lastLength || !separatorCopy.test('')) output.push('');
  1888. } else output.push(string.slice(lastLastIndex));
  1889. return output.length > lim ? output.slice(0, lim) : output;
  1890. };
  1891. // Chakra, V8
  1892. } else if ('0'.split(undefined, 0).length) {
  1893. internalSplit = function (separator, limit) {
  1894. return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
  1895. };
  1896. } else internalSplit = nativeSplit;
  1897. return [
  1898. // `String.prototype.split` method
  1899. // https://tc39.github.io/ecma262/#sec-string.prototype.split
  1900. function split(separator, limit) {
  1901. var O = requireObjectCoercible(this);
  1902. var splitter = separator == undefined ? undefined : separator[SPLIT];
  1903. return splitter !== undefined
  1904. ? splitter.call(separator, O, limit)
  1905. : internalSplit.call(String(O), separator, limit);
  1906. },
  1907. // `RegExp.prototype[@@split]` method
  1908. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
  1909. //
  1910. // NOTE: This cannot be properly polyfilled in engines that don't support
  1911. // the 'y' flag.
  1912. function (regexp, limit) {
  1913. var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
  1914. if (res.done) return res.value;
  1915. var rx = anObject(regexp);
  1916. var S = String(this);
  1917. var C = speciesConstructor(rx, RegExp);
  1918. var unicodeMatching = rx.unicode;
  1919. var flags = (rx.ignoreCase ? 'i' : '') +
  1920. (rx.multiline ? 'm' : '') +
  1921. (rx.unicode ? 'u' : '') +
  1922. (SUPPORTS_Y ? 'y' : 'g');
  1923. // ^(? + rx + ) is needed, in combination with some S slicing, to
  1924. // simulate the 'y' flag.
  1925. var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
  1926. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1927. if (lim === 0) return [];
  1928. if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
  1929. var p = 0;
  1930. var q = 0;
  1931. var A = [];
  1932. while (q < S.length) {
  1933. splitter.lastIndex = SUPPORTS_Y ? q : 0;
  1934. var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
  1935. var e;
  1936. if (
  1937. z === null ||
  1938. (e = min$3(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
  1939. ) {
  1940. q = advanceStringIndex(S, q, unicodeMatching);
  1941. } else {
  1942. A.push(S.slice(p, q));
  1943. if (A.length === lim) return A;
  1944. for (var i = 1; i <= z.length - 1; i++) {
  1945. A.push(z[i]);
  1946. if (A.length === lim) return A;
  1947. }
  1948. q = p = e;
  1949. }
  1950. }
  1951. A.push(S.slice(p));
  1952. return A;
  1953. }
  1954. ];
  1955. }, !SUPPORTS_Y);
  1956. // iterable DOM collections
  1957. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  1958. var domIterables = {
  1959. CSSRuleList: 0,
  1960. CSSStyleDeclaration: 0,
  1961. CSSValueList: 0,
  1962. ClientRectList: 0,
  1963. DOMRectList: 0,
  1964. DOMStringList: 0,
  1965. DOMTokenList: 1,
  1966. DataTransferItemList: 0,
  1967. FileList: 0,
  1968. HTMLAllCollection: 0,
  1969. HTMLCollection: 0,
  1970. HTMLFormElement: 0,
  1971. HTMLSelectElement: 0,
  1972. MediaList: 0,
  1973. MimeTypeArray: 0,
  1974. NamedNodeMap: 0,
  1975. NodeList: 1,
  1976. PaintRequestList: 0,
  1977. Plugin: 0,
  1978. PluginArray: 0,
  1979. SVGLengthList: 0,
  1980. SVGNumberList: 0,
  1981. SVGPathSegList: 0,
  1982. SVGPointList: 0,
  1983. SVGStringList: 0,
  1984. SVGTransformList: 0,
  1985. SourceBufferList: 0,
  1986. StyleSheetList: 0,
  1987. TextTrackCueList: 0,
  1988. TextTrackList: 0,
  1989. TouchList: 0
  1990. };
  1991. for (var COLLECTION_NAME in domIterables) {
  1992. var Collection = global_1[COLLECTION_NAME];
  1993. var CollectionPrototype = Collection && Collection.prototype;
  1994. // some Chrome versions have non-configurable methods on DOMTokenList
  1995. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  1996. createNonEnumerableProperty(CollectionPrototype, 'forEach', arrayForEach);
  1997. } catch (error) {
  1998. CollectionPrototype.forEach = arrayForEach;
  1999. }
  2000. }
  2001. var ITERATOR$2 = wellKnownSymbol('iterator');
  2002. var TO_STRING_TAG$3 = wellKnownSymbol('toStringTag');
  2003. var ArrayValues = es_array_iterator.values;
  2004. for (var COLLECTION_NAME$1 in domIterables) {
  2005. var Collection$1 = global_1[COLLECTION_NAME$1];
  2006. var CollectionPrototype$1 = Collection$1 && Collection$1.prototype;
  2007. if (CollectionPrototype$1) {
  2008. // some Chrome versions have non-configurable methods on DOMTokenList
  2009. if (CollectionPrototype$1[ITERATOR$2] !== ArrayValues) try {
  2010. createNonEnumerableProperty(CollectionPrototype$1, ITERATOR$2, ArrayValues);
  2011. } catch (error) {
  2012. CollectionPrototype$1[ITERATOR$2] = ArrayValues;
  2013. }
  2014. if (!CollectionPrototype$1[TO_STRING_TAG$3]) {
  2015. createNonEnumerableProperty(CollectionPrototype$1, TO_STRING_TAG$3, COLLECTION_NAME$1);
  2016. }
  2017. if (domIterables[COLLECTION_NAME$1]) for (var METHOD_NAME in es_array_iterator) {
  2018. // some Chrome versions have non-configurable methods on DOMTokenList
  2019. if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) try {
  2020. createNonEnumerableProperty(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]);
  2021. } catch (error) {
  2022. CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME];
  2023. }
  2024. }
  2025. }
  2026. }
  2027. var ITERATOR$3 = wellKnownSymbol('iterator');
  2028. var nativeUrl = !fails(function () {
  2029. var url = new URL('b?a=1&b=2&c=3', 'http://a');
  2030. var searchParams = url.searchParams;
  2031. var result = '';
  2032. url.pathname = 'c%20d';
  2033. searchParams.forEach(function (value, key) {
  2034. searchParams['delete']('b');
  2035. result += key + value;
  2036. });
  2037. return (isPure && !url.toJSON)
  2038. || !searchParams.sort
  2039. || url.href !== 'http://a/c%20d?a=1&c=3'
  2040. || searchParams.get('c') !== '3'
  2041. || String(new URLSearchParams('?a=1')) !== 'a=1'
  2042. || !searchParams[ITERATOR$3]
  2043. // throws in Edge
  2044. || new URL('https://a@b').username !== 'a'
  2045. || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
  2046. // not punycoded in Edge
  2047. || new URL('http://тест').host !== 'xn--e1aybc'
  2048. // not escaped in Chrome 62-
  2049. || new URL('http://a#б').hash !== '#%D0%B1'
  2050. // fails in Chrome 66-
  2051. || result !== 'a1c3'
  2052. // throws in Safari
  2053. || new URL('http://x', undefined).host !== 'x';
  2054. });
  2055. var anInstance = function (it, Constructor, name) {
  2056. if (!(it instanceof Constructor)) {
  2057. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  2058. } return it;
  2059. };
  2060. var nativeAssign = Object.assign;
  2061. var defineProperty$4 = Object.defineProperty;
  2062. // `Object.assign` method
  2063. // https://tc39.github.io/ecma262/#sec-object.assign
  2064. var objectAssign = !nativeAssign || fails(function () {
  2065. // should have correct order of operations (Edge bug)
  2066. if (descriptors && nativeAssign({ b: 1 }, nativeAssign(defineProperty$4({}, 'a', {
  2067. enumerable: true,
  2068. get: function () {
  2069. defineProperty$4(this, 'b', {
  2070. value: 3,
  2071. enumerable: false
  2072. });
  2073. }
  2074. }), { b: 2 })).b !== 1) return true;
  2075. // should work with symbols and should have deterministic property order (V8 bug)
  2076. var A = {};
  2077. var B = {};
  2078. // eslint-disable-next-line no-undef
  2079. var symbol = Symbol();
  2080. var alphabet = 'abcdefghijklmnopqrst';
  2081. A[symbol] = 7;
  2082. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  2083. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  2084. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  2085. var T = toObject(target);
  2086. var argumentsLength = arguments.length;
  2087. var index = 1;
  2088. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  2089. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  2090. while (argumentsLength > index) {
  2091. var S = indexedObject(arguments[index++]);
  2092. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  2093. var length = keys.length;
  2094. var j = 0;
  2095. var key;
  2096. while (length > j) {
  2097. key = keys[j++];
  2098. if (!descriptors || propertyIsEnumerable.call(S, key)) T[key] = S[key];
  2099. }
  2100. } return T;
  2101. } : nativeAssign;
  2102. // call something on iterator step with safe closing on error
  2103. var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
  2104. try {
  2105. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  2106. // 7.4.6 IteratorClose(iterator, completion)
  2107. } catch (error) {
  2108. var returnMethod = iterator['return'];
  2109. if (returnMethod !== undefined) anObject(returnMethod.call(iterator));
  2110. throw error;
  2111. }
  2112. };
  2113. var ITERATOR$4 = wellKnownSymbol('iterator');
  2114. var ArrayPrototype$1 = Array.prototype;
  2115. // check on default Array iterator
  2116. var isArrayIteratorMethod = function (it) {
  2117. return it !== undefined && (iterators.Array === it || ArrayPrototype$1[ITERATOR$4] === it);
  2118. };
  2119. var ITERATOR$5 = wellKnownSymbol('iterator');
  2120. var getIteratorMethod = function (it) {
  2121. if (it != undefined) return it[ITERATOR$5]
  2122. || it['@@iterator']
  2123. || iterators[classof(it)];
  2124. };
  2125. // `Array.from` method implementation
  2126. // https://tc39.github.io/ecma262/#sec-array.from
  2127. var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  2128. var O = toObject(arrayLike);
  2129. var C = typeof this == 'function' ? this : Array;
  2130. var argumentsLength = arguments.length;
  2131. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  2132. var mapping = mapfn !== undefined;
  2133. var iteratorMethod = getIteratorMethod(O);
  2134. var index = 0;
  2135. var length, result, step, iterator, next, value;
  2136. if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  2137. // if the target is not iterable or it's an array with the default iterator - use a simple case
  2138. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  2139. iterator = iteratorMethod.call(O);
  2140. next = iterator.next;
  2141. result = new C();
  2142. for (;!(step = next.call(iterator)).done; index++) {
  2143. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  2144. createProperty(result, index, value);
  2145. }
  2146. } else {
  2147. length = toLength(O.length);
  2148. result = new C(length);
  2149. for (;length > index; index++) {
  2150. value = mapping ? mapfn(O[index], index) : O[index];
  2151. createProperty(result, index, value);
  2152. }
  2153. }
  2154. result.length = index;
  2155. return result;
  2156. };
  2157. // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
  2158. var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
  2159. var base = 36;
  2160. var tMin = 1;
  2161. var tMax = 26;
  2162. var skew = 38;
  2163. var damp = 700;
  2164. var initialBias = 72;
  2165. var initialN = 128; // 0x80
  2166. var delimiter = '-'; // '\x2D'
  2167. var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
  2168. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
  2169. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  2170. var baseMinusTMin = base - tMin;
  2171. var floor$2 = Math.floor;
  2172. var stringFromCharCode = String.fromCharCode;
  2173. /**
  2174. * Creates an array containing the numeric code points of each Unicode
  2175. * character in the string. While JavaScript uses UCS-2 internally,
  2176. * this function will convert a pair of surrogate halves (each of which
  2177. * UCS-2 exposes as separate characters) into a single code point,
  2178. * matching UTF-16.
  2179. */
  2180. var ucs2decode = function (string) {
  2181. var output = [];
  2182. var counter = 0;
  2183. var length = string.length;
  2184. while (counter < length) {
  2185. var value = string.charCodeAt(counter++);
  2186. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  2187. // It's a high surrogate, and there is a next character.
  2188. var extra = string.charCodeAt(counter++);
  2189. if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
  2190. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  2191. } else {
  2192. // It's an unmatched surrogate; only append this code unit, in case the
  2193. // next code unit is the high surrogate of a surrogate pair.
  2194. output.push(value);
  2195. counter--;
  2196. }
  2197. } else {
  2198. output.push(value);
  2199. }
  2200. }
  2201. return output;
  2202. };
  2203. /**
  2204. * Converts a digit/integer into a basic code point.
  2205. */
  2206. var digitToBasic = function (digit) {
  2207. // 0..25 map to ASCII a..z or A..Z
  2208. // 26..35 map to ASCII 0..9
  2209. return digit + 22 + 75 * (digit < 26);
  2210. };
  2211. /**
  2212. * Bias adaptation function as per section 3.4 of RFC 3492.
  2213. * https://tools.ietf.org/html/rfc3492#section-3.4
  2214. */
  2215. var adapt = function (delta, numPoints, firstTime) {
  2216. var k = 0;
  2217. delta = firstTime ? floor$2(delta / damp) : delta >> 1;
  2218. delta += floor$2(delta / numPoints);
  2219. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  2220. delta = floor$2(delta / baseMinusTMin);
  2221. }
  2222. return floor$2(k + (baseMinusTMin + 1) * delta / (delta + skew));
  2223. };
  2224. /**
  2225. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  2226. * Punycode string of ASCII-only symbols.
  2227. */
  2228. // eslint-disable-next-line max-statements
  2229. var encode = function (input) {
  2230. var output = [];
  2231. // Convert the input in UCS-2 to an array of Unicode code points.
  2232. input = ucs2decode(input);
  2233. // Cache the length.
  2234. var inputLength = input.length;
  2235. // Initialize the state.
  2236. var n = initialN;
  2237. var delta = 0;
  2238. var bias = initialBias;
  2239. var i, currentValue;
  2240. // Handle the basic code points.
  2241. for (i = 0; i < input.length; i++) {
  2242. currentValue = input[i];
  2243. if (currentValue < 0x80) {
  2244. output.push(stringFromCharCode(currentValue));
  2245. }
  2246. }
  2247. var basicLength = output.length; // number of basic code points.
  2248. var handledCPCount = basicLength; // number of code points that have been handled;
  2249. // Finish the basic string with a delimiter unless it's empty.
  2250. if (basicLength) {
  2251. output.push(delimiter);
  2252. }
  2253. // Main encoding loop:
  2254. while (handledCPCount < inputLength) {
  2255. // All non-basic code points < n have been handled already. Find the next larger one:
  2256. var m = maxInt;
  2257. for (i = 0; i < input.length; i++) {
  2258. currentValue = input[i];
  2259. if (currentValue >= n && currentValue < m) {
  2260. m = currentValue;
  2261. }
  2262. }
  2263. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
  2264. var handledCPCountPlusOne = handledCPCount + 1;
  2265. if (m - n > floor$2((maxInt - delta) / handledCPCountPlusOne)) {
  2266. throw RangeError(OVERFLOW_ERROR);
  2267. }
  2268. delta += (m - n) * handledCPCountPlusOne;
  2269. n = m;
  2270. for (i = 0; i < input.length; i++) {
  2271. currentValue = input[i];
  2272. if (currentValue < n && ++delta > maxInt) {
  2273. throw RangeError(OVERFLOW_ERROR);
  2274. }
  2275. if (currentValue == n) {
  2276. // Represent delta as a generalized variable-length integer.
  2277. var q = delta;
  2278. for (var k = base; /* no condition */; k += base) {
  2279. var t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  2280. if (q < t) break;
  2281. var qMinusT = q - t;
  2282. var baseMinusT = base - t;
  2283. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
  2284. q = floor$2(qMinusT / baseMinusT);
  2285. }
  2286. output.push(stringFromCharCode(digitToBasic(q)));
  2287. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  2288. delta = 0;
  2289. ++handledCPCount;
  2290. }
  2291. }
  2292. ++delta;
  2293. ++n;
  2294. }
  2295. return output.join('');
  2296. };
  2297. var stringPunycodeToAscii = function (input) {
  2298. var encoded = [];
  2299. var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.');
  2300. var i, label;
  2301. for (i = 0; i < labels.length; i++) {
  2302. label = labels[i];
  2303. encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);
  2304. }
  2305. return encoded.join('.');
  2306. };
  2307. var redefineAll = function (target, src, options) {
  2308. for (var key in src) redefine(target, key, src[key], options);
  2309. return target;
  2310. };
  2311. var getIterator = function (it) {
  2312. var iteratorMethod = getIteratorMethod(it);
  2313. if (typeof iteratorMethod != 'function') {
  2314. throw TypeError(String(it) + ' is not iterable');
  2315. } return anObject(iteratorMethod.call(it));
  2316. };
  2317. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  2318. var $fetch = getBuiltIn('fetch');
  2319. var Headers = getBuiltIn('Headers');
  2320. var ITERATOR$6 = wellKnownSymbol('iterator');
  2321. var URL_SEARCH_PARAMS = 'URLSearchParams';
  2322. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  2323. var setInternalState$3 = internalState.set;
  2324. var getInternalParamsState = internalState.getterFor(URL_SEARCH_PARAMS);
  2325. var getInternalIteratorState = internalState.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  2326. var plus = /\+/g;
  2327. var sequences = Array(4);
  2328. var percentSequence = function (bytes) {
  2329. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  2330. };
  2331. var percentDecode = function (sequence) {
  2332. try {
  2333. return decodeURIComponent(sequence);
  2334. } catch (error) {
  2335. return sequence;
  2336. }
  2337. };
  2338. var deserialize = function (it) {
  2339. var result = it.replace(plus, ' ');
  2340. var bytes = 4;
  2341. try {
  2342. return decodeURIComponent(result);
  2343. } catch (error) {
  2344. while (bytes) {
  2345. result = result.replace(percentSequence(bytes--), percentDecode);
  2346. }
  2347. return result;
  2348. }
  2349. };
  2350. var find = /[!'()~]|%20/g;
  2351. var replace = {
  2352. '!': '%21',
  2353. "'": '%27',
  2354. '(': '%28',
  2355. ')': '%29',
  2356. '~': '%7E',
  2357. '%20': '+'
  2358. };
  2359. var replacer = function (match) {
  2360. return replace[match];
  2361. };
  2362. var serialize = function (it) {
  2363. return encodeURIComponent(it).replace(find, replacer);
  2364. };
  2365. var parseSearchParams = function (result, query) {
  2366. if (query) {
  2367. var attributes = query.split('&');
  2368. var index = 0;
  2369. var attribute, entry;
  2370. while (index < attributes.length) {
  2371. attribute = attributes[index++];
  2372. if (attribute.length) {
  2373. entry = attribute.split('=');
  2374. result.push({
  2375. key: deserialize(entry.shift()),
  2376. value: deserialize(entry.join('='))
  2377. });
  2378. }
  2379. }
  2380. }
  2381. };
  2382. var updateSearchParams = function (query) {
  2383. this.entries.length = 0;
  2384. parseSearchParams(this.entries, query);
  2385. };
  2386. var validateArgumentsLength = function (passed, required) {
  2387. if (passed < required) throw TypeError('Not enough arguments');
  2388. };
  2389. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  2390. setInternalState$3(this, {
  2391. type: URL_SEARCH_PARAMS_ITERATOR,
  2392. iterator: getIterator(getInternalParamsState(params).entries),
  2393. kind: kind
  2394. });
  2395. }, 'Iterator', function next() {
  2396. var state = getInternalIteratorState(this);
  2397. var kind = state.kind;
  2398. var step = state.iterator.next();
  2399. var entry = step.value;
  2400. if (!step.done) {
  2401. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
  2402. } return step;
  2403. });
  2404. // `URLSearchParams` constructor
  2405. // https://url.spec.whatwg.org/#interface-urlsearchparams
  2406. var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
  2407. anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  2408. var init = arguments.length > 0 ? arguments[0] : undefined;
  2409. var that = this;
  2410. var entries = [];
  2411. var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key;
  2412. setInternalState$3(that, {
  2413. type: URL_SEARCH_PARAMS,
  2414. entries: entries,
  2415. updateURL: function () { /* empty */ },
  2416. updateSearchParams: updateSearchParams
  2417. });
  2418. if (init !== undefined) {
  2419. if (isObject(init)) {
  2420. iteratorMethod = getIteratorMethod(init);
  2421. if (typeof iteratorMethod === 'function') {
  2422. iterator = iteratorMethod.call(init);
  2423. next = iterator.next;
  2424. while (!(step = next.call(iterator)).done) {
  2425. entryIterator = getIterator(anObject(step.value));
  2426. entryNext = entryIterator.next;
  2427. if (
  2428. (first = entryNext.call(entryIterator)).done ||
  2429. (second = entryNext.call(entryIterator)).done ||
  2430. !entryNext.call(entryIterator).done
  2431. ) throw TypeError('Expected sequence with length 2');
  2432. entries.push({ key: first.value + '', value: second.value + '' });
  2433. }
  2434. } else for (key in init) if (has(init, key)) entries.push({ key: key, value: init[key] + '' });
  2435. } else {
  2436. parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');
  2437. }
  2438. }
  2439. };
  2440. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  2441. redefineAll(URLSearchParamsPrototype, {
  2442. // `URLSearchParams.prototype.appent` method
  2443. // https://url.spec.whatwg.org/#dom-urlsearchparams-append
  2444. append: function append(name, value) {
  2445. validateArgumentsLength(arguments.length, 2);
  2446. var state = getInternalParamsState(this);
  2447. state.entries.push({ key: name + '', value: value + '' });
  2448. state.updateURL();
  2449. },
  2450. // `URLSearchParams.prototype.delete` method
  2451. // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
  2452. 'delete': function (name) {
  2453. validateArgumentsLength(arguments.length, 1);
  2454. var state = getInternalParamsState(this);
  2455. var entries = state.entries;
  2456. var key = name + '';
  2457. var index = 0;
  2458. while (index < entries.length) {
  2459. if (entries[index].key === key) entries.splice(index, 1);
  2460. else index++;
  2461. }
  2462. state.updateURL();
  2463. },
  2464. // `URLSearchParams.prototype.get` method
  2465. // https://url.spec.whatwg.org/#dom-urlsearchparams-get
  2466. get: function get(name) {
  2467. validateArgumentsLength(arguments.length, 1);
  2468. var entries = getInternalParamsState(this).entries;
  2469. var key = name + '';
  2470. var index = 0;
  2471. for (; index < entries.length; index++) {
  2472. if (entries[index].key === key) return entries[index].value;
  2473. }
  2474. return null;
  2475. },
  2476. // `URLSearchParams.prototype.getAll` method
  2477. // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
  2478. getAll: function getAll(name) {
  2479. validateArgumentsLength(arguments.length, 1);
  2480. var entries = getInternalParamsState(this).entries;
  2481. var key = name + '';
  2482. var result = [];
  2483. var index = 0;
  2484. for (; index < entries.length; index++) {
  2485. if (entries[index].key === key) result.push(entries[index].value);
  2486. }
  2487. return result;
  2488. },
  2489. // `URLSearchParams.prototype.has` method
  2490. // https://url.spec.whatwg.org/#dom-urlsearchparams-has
  2491. has: function has(name) {
  2492. validateArgumentsLength(arguments.length, 1);
  2493. var entries = getInternalParamsState(this).entries;
  2494. var key = name + '';
  2495. var index = 0;
  2496. while (index < entries.length) {
  2497. if (entries[index++].key === key) return true;
  2498. }
  2499. return false;
  2500. },
  2501. // `URLSearchParams.prototype.set` method
  2502. // https://url.spec.whatwg.org/#dom-urlsearchparams-set
  2503. set: function set(name, value) {
  2504. validateArgumentsLength(arguments.length, 1);
  2505. var state = getInternalParamsState(this);
  2506. var entries = state.entries;
  2507. var found = false;
  2508. var key = name + '';
  2509. var val = value + '';
  2510. var index = 0;
  2511. var entry;
  2512. for (; index < entries.length; index++) {
  2513. entry = entries[index];
  2514. if (entry.key === key) {
  2515. if (found) entries.splice(index--, 1);
  2516. else {
  2517. found = true;
  2518. entry.value = val;
  2519. }
  2520. }
  2521. }
  2522. if (!found) entries.push({ key: key, value: val });
  2523. state.updateURL();
  2524. },
  2525. // `URLSearchParams.prototype.sort` method
  2526. // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
  2527. sort: function sort() {
  2528. var state = getInternalParamsState(this);
  2529. var entries = state.entries;
  2530. // Array#sort is not stable in some engines
  2531. var slice = entries.slice();
  2532. var entry, entriesIndex, sliceIndex;
  2533. entries.length = 0;
  2534. for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {
  2535. entry = slice[sliceIndex];
  2536. for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {
  2537. if (entries[entriesIndex].key > entry.key) {
  2538. entries.splice(entriesIndex, 0, entry);
  2539. break;
  2540. }
  2541. }
  2542. if (entriesIndex === sliceIndex) entries.push(entry);
  2543. }
  2544. state.updateURL();
  2545. },
  2546. // `URLSearchParams.prototype.forEach` method
  2547. forEach: function forEach(callback /* , thisArg */) {
  2548. var entries = getInternalParamsState(this).entries;
  2549. var boundFunction = functionBindContext(callback, arguments.length > 1 ? arguments[1] : undefined, 3);
  2550. var index = 0;
  2551. var entry;
  2552. while (index < entries.length) {
  2553. entry = entries[index++];
  2554. boundFunction(entry.value, entry.key, this);
  2555. }
  2556. },
  2557. // `URLSearchParams.prototype.keys` method
  2558. keys: function keys() {
  2559. return new URLSearchParamsIterator(this, 'keys');
  2560. },
  2561. // `URLSearchParams.prototype.values` method
  2562. values: function values() {
  2563. return new URLSearchParamsIterator(this, 'values');
  2564. },
  2565. // `URLSearchParams.prototype.entries` method
  2566. entries: function entries() {
  2567. return new URLSearchParamsIterator(this, 'entries');
  2568. }
  2569. }, { enumerable: true });
  2570. // `URLSearchParams.prototype[@@iterator]` method
  2571. redefine(URLSearchParamsPrototype, ITERATOR$6, URLSearchParamsPrototype.entries);
  2572. // `URLSearchParams.prototype.toString` method
  2573. // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
  2574. redefine(URLSearchParamsPrototype, 'toString', function toString() {
  2575. var entries = getInternalParamsState(this).entries;
  2576. var result = [];
  2577. var index = 0;
  2578. var entry;
  2579. while (index < entries.length) {
  2580. entry = entries[index++];
  2581. result.push(serialize(entry.key) + '=' + serialize(entry.value));
  2582. } return result.join('&');
  2583. }, { enumerable: true });
  2584. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  2585. _export({ global: true, forced: !nativeUrl }, {
  2586. URLSearchParams: URLSearchParamsConstructor
  2587. });
  2588. // Wrap `fetch` for correct work with polyfilled `URLSearchParams`
  2589. // https://github.com/zloirock/core-js/issues/674
  2590. if (!nativeUrl && typeof $fetch == 'function' && typeof Headers == 'function') {
  2591. _export({ global: true, enumerable: true, forced: true }, {
  2592. fetch: function fetch(input /* , init */) {
  2593. var args = [input];
  2594. var init, body, headers;
  2595. if (arguments.length > 1) {
  2596. init = arguments[1];
  2597. if (isObject(init)) {
  2598. body = init.body;
  2599. if (classof(body) === URL_SEARCH_PARAMS) {
  2600. headers = init.headers ? new Headers(init.headers) : new Headers();
  2601. if (!headers.has('content-type')) {
  2602. headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
  2603. }
  2604. init = objectCreate(init, {
  2605. body: createPropertyDescriptor(0, String(body)),
  2606. headers: createPropertyDescriptor(0, headers)
  2607. });
  2608. }
  2609. }
  2610. args.push(init);
  2611. } return $fetch.apply(this, args);
  2612. }
  2613. });
  2614. }
  2615. var web_urlSearchParams = {
  2616. URLSearchParams: URLSearchParamsConstructor,
  2617. getState: getInternalParamsState
  2618. };
  2619. // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
  2620. var codeAt = stringMultibyte.codeAt;
  2621. var NativeURL = global_1.URL;
  2622. var URLSearchParams$1 = web_urlSearchParams.URLSearchParams;
  2623. var getInternalSearchParamsState = web_urlSearchParams.getState;
  2624. var setInternalState$4 = internalState.set;
  2625. var getInternalURLState = internalState.getterFor('URL');
  2626. var floor$3 = Math.floor;
  2627. var pow = Math.pow;
  2628. var INVALID_AUTHORITY = 'Invalid authority';
  2629. var INVALID_SCHEME = 'Invalid scheme';
  2630. var INVALID_HOST = 'Invalid host';
  2631. var INVALID_PORT = 'Invalid port';
  2632. var ALPHA = /[A-Za-z]/;
  2633. var ALPHANUMERIC = /[\d+-.A-Za-z]/;
  2634. var DIGIT = /\d/;
  2635. var HEX_START = /^(0x|0X)/;
  2636. var OCT = /^[0-7]+$/;
  2637. var DEC = /^\d+$/;
  2638. var HEX = /^[\dA-Fa-f]+$/;
  2639. // eslint-disable-next-line no-control-regex
  2640. var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/;
  2641. // eslint-disable-next-line no-control-regex
  2642. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/;
  2643. // eslint-disable-next-line no-control-regex
  2644. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g;
  2645. // eslint-disable-next-line no-control-regex
  2646. var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g;
  2647. var EOF;
  2648. var parseHost = function (url, input) {
  2649. var result, codePoints, index;
  2650. if (input.charAt(0) == '[') {
  2651. if (input.charAt(input.length - 1) != ']') return INVALID_HOST;
  2652. result = parseIPv6(input.slice(1, -1));
  2653. if (!result) return INVALID_HOST;
  2654. url.host = result;
  2655. // opaque host
  2656. } else if (!isSpecial(url)) {
  2657. if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input)) return INVALID_HOST;
  2658. result = '';
  2659. codePoints = arrayFrom(input);
  2660. for (index = 0; index < codePoints.length; index++) {
  2661. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  2662. }
  2663. url.host = result;
  2664. } else {
  2665. input = stringPunycodeToAscii(input);
  2666. if (FORBIDDEN_HOST_CODE_POINT.test(input)) return INVALID_HOST;
  2667. result = parseIPv4(input);
  2668. if (result === null) return INVALID_HOST;
  2669. url.host = result;
  2670. }
  2671. };
  2672. var parseIPv4 = function (input) {
  2673. var parts = input.split('.');
  2674. var partsLength, numbers, index, part, radix, number, ipv4;
  2675. if (parts.length && parts[parts.length - 1] == '') {
  2676. parts.pop();
  2677. }
  2678. partsLength = parts.length;
  2679. if (partsLength > 4) return input;
  2680. numbers = [];
  2681. for (index = 0; index < partsLength; index++) {
  2682. part = parts[index];
  2683. if (part == '') return input;
  2684. radix = 10;
  2685. if (part.length > 1 && part.charAt(0) == '0') {
  2686. radix = HEX_START.test(part) ? 16 : 8;
  2687. part = part.slice(radix == 8 ? 1 : 2);
  2688. }
  2689. if (part === '') {
  2690. number = 0;
  2691. } else {
  2692. if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part)) return input;
  2693. number = parseInt(part, radix);
  2694. }
  2695. numbers.push(number);
  2696. }
  2697. for (index = 0; index < partsLength; index++) {
  2698. number = numbers[index];
  2699. if (index == partsLength - 1) {
  2700. if (number >= pow(256, 5 - partsLength)) return null;
  2701. } else if (number > 255) return null;
  2702. }
  2703. ipv4 = numbers.pop();
  2704. for (index = 0; index < numbers.length; index++) {
  2705. ipv4 += numbers[index] * pow(256, 3 - index);
  2706. }
  2707. return ipv4;
  2708. };
  2709. // eslint-disable-next-line max-statements
  2710. var parseIPv6 = function (input) {
  2711. var address = [0, 0, 0, 0, 0, 0, 0, 0];
  2712. var pieceIndex = 0;
  2713. var compress = null;
  2714. var pointer = 0;
  2715. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  2716. var char = function () {
  2717. return input.charAt(pointer);
  2718. };
  2719. if (char() == ':') {
  2720. if (input.charAt(1) != ':') return;
  2721. pointer += 2;
  2722. pieceIndex++;
  2723. compress = pieceIndex;
  2724. }
  2725. while (char()) {
  2726. if (pieceIndex == 8) return;
  2727. if (char() == ':') {
  2728. if (compress !== null) return;
  2729. pointer++;
  2730. pieceIndex++;
  2731. compress = pieceIndex;
  2732. continue;
  2733. }
  2734. value = length = 0;
  2735. while (length < 4 && HEX.test(char())) {
  2736. value = value * 16 + parseInt(char(), 16);
  2737. pointer++;
  2738. length++;
  2739. }
  2740. if (char() == '.') {
  2741. if (length == 0) return;
  2742. pointer -= length;
  2743. if (pieceIndex > 6) return;
  2744. numbersSeen = 0;
  2745. while (char()) {
  2746. ipv4Piece = null;
  2747. if (numbersSeen > 0) {
  2748. if (char() == '.' && numbersSeen < 4) pointer++;
  2749. else return;
  2750. }
  2751. if (!DIGIT.test(char())) return;
  2752. while (DIGIT.test(char())) {
  2753. number = parseInt(char(), 10);
  2754. if (ipv4Piece === null) ipv4Piece = number;
  2755. else if (ipv4Piece == 0) return;
  2756. else ipv4Piece = ipv4Piece * 10 + number;
  2757. if (ipv4Piece > 255) return;
  2758. pointer++;
  2759. }
  2760. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  2761. numbersSeen++;
  2762. if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
  2763. }
  2764. if (numbersSeen != 4) return;
  2765. break;
  2766. } else if (char() == ':') {
  2767. pointer++;
  2768. if (!char()) return;
  2769. } else if (char()) return;
  2770. address[pieceIndex++] = value;
  2771. }
  2772. if (compress !== null) {
  2773. swaps = pieceIndex - compress;
  2774. pieceIndex = 7;
  2775. while (pieceIndex != 0 && swaps > 0) {
  2776. swap = address[pieceIndex];
  2777. address[pieceIndex--] = address[compress + swaps - 1];
  2778. address[compress + --swaps] = swap;
  2779. }
  2780. } else if (pieceIndex != 8) return;
  2781. return address;
  2782. };
  2783. var findLongestZeroSequence = function (ipv6) {
  2784. var maxIndex = null;
  2785. var maxLength = 1;
  2786. var currStart = null;
  2787. var currLength = 0;
  2788. var index = 0;
  2789. for (; index < 8; index++) {
  2790. if (ipv6[index] !== 0) {
  2791. if (currLength > maxLength) {
  2792. maxIndex = currStart;
  2793. maxLength = currLength;
  2794. }
  2795. currStart = null;
  2796. currLength = 0;
  2797. } else {
  2798. if (currStart === null) currStart = index;
  2799. ++currLength;
  2800. }
  2801. }
  2802. if (currLength > maxLength) {
  2803. maxIndex = currStart;
  2804. maxLength = currLength;
  2805. }
  2806. return maxIndex;
  2807. };
  2808. var serializeHost = function (host) {
  2809. var result, index, compress, ignore0;
  2810. // ipv4
  2811. if (typeof host == 'number') {
  2812. result = [];
  2813. for (index = 0; index < 4; index++) {
  2814. result.unshift(host % 256);
  2815. host = floor$3(host / 256);
  2816. } return result.join('.');
  2817. // ipv6
  2818. } else if (typeof host == 'object') {
  2819. result = '';
  2820. compress = findLongestZeroSequence(host);
  2821. for (index = 0; index < 8; index++) {
  2822. if (ignore0 && host[index] === 0) continue;
  2823. if (ignore0) ignore0 = false;
  2824. if (compress === index) {
  2825. result += index ? ':' : '::';
  2826. ignore0 = true;
  2827. } else {
  2828. result += host[index].toString(16);
  2829. if (index < 7) result += ':';
  2830. }
  2831. }
  2832. return '[' + result + ']';
  2833. } return host;
  2834. };
  2835. var C0ControlPercentEncodeSet = {};
  2836. var fragmentPercentEncodeSet = objectAssign({}, C0ControlPercentEncodeSet, {
  2837. ' ': 1, '"': 1, '<': 1, '>': 1, '`': 1
  2838. });
  2839. var pathPercentEncodeSet = objectAssign({}, fragmentPercentEncodeSet, {
  2840. '#': 1, '?': 1, '{': 1, '}': 1
  2841. });
  2842. var userinfoPercentEncodeSet = objectAssign({}, pathPercentEncodeSet, {
  2843. '/': 1, ':': 1, ';': 1, '=': 1, '@': 1, '[': 1, '\\': 1, ']': 1, '^': 1, '|': 1
  2844. });
  2845. var percentEncode = function (char, set) {
  2846. var code = codeAt(char, 0);
  2847. return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);
  2848. };
  2849. var specialSchemes = {
  2850. ftp: 21,
  2851. file: null,
  2852. http: 80,
  2853. https: 443,
  2854. ws: 80,
  2855. wss: 443
  2856. };
  2857. var isSpecial = function (url) {
  2858. return has(specialSchemes, url.scheme);
  2859. };
  2860. var includesCredentials = function (url) {
  2861. return url.username != '' || url.password != '';
  2862. };
  2863. var cannotHaveUsernamePasswordPort = function (url) {
  2864. return !url.host || url.cannotBeABaseURL || url.scheme == 'file';
  2865. };
  2866. var isWindowsDriveLetter = function (string, normalized) {
  2867. var second;
  2868. return string.length == 2 && ALPHA.test(string.charAt(0))
  2869. && ((second = string.charAt(1)) == ':' || (!normalized && second == '|'));
  2870. };
  2871. var startsWithWindowsDriveLetter = function (string) {
  2872. var third;
  2873. return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (
  2874. string.length == 2 ||
  2875. ((third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#')
  2876. );
  2877. };
  2878. var shortenURLsPath = function (url) {
  2879. var path = url.path;
  2880. var pathSize = path.length;
  2881. if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  2882. path.pop();
  2883. }
  2884. };
  2885. var isSingleDot = function (segment) {
  2886. return segment === '.' || segment.toLowerCase() === '%2e';
  2887. };
  2888. var isDoubleDot = function (segment) {
  2889. segment = segment.toLowerCase();
  2890. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  2891. };
  2892. // States:
  2893. var SCHEME_START = {};
  2894. var SCHEME = {};
  2895. var NO_SCHEME = {};
  2896. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  2897. var PATH_OR_AUTHORITY = {};
  2898. var RELATIVE = {};
  2899. var RELATIVE_SLASH = {};
  2900. var SPECIAL_AUTHORITY_SLASHES = {};
  2901. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  2902. var AUTHORITY = {};
  2903. var HOST = {};
  2904. var HOSTNAME = {};
  2905. var PORT = {};
  2906. var FILE = {};
  2907. var FILE_SLASH = {};
  2908. var FILE_HOST = {};
  2909. var PATH_START = {};
  2910. var PATH = {};
  2911. var CANNOT_BE_A_BASE_URL_PATH = {};
  2912. var QUERY = {};
  2913. var FRAGMENT = {};
  2914. // eslint-disable-next-line max-statements
  2915. var parseURL = function (url, input, stateOverride, base) {
  2916. var state = stateOverride || SCHEME_START;
  2917. var pointer = 0;
  2918. var buffer = '';
  2919. var seenAt = false;
  2920. var seenBracket = false;
  2921. var seenPasswordToken = false;
  2922. var codePoints, char, bufferCodePoints, failure;
  2923. if (!stateOverride) {
  2924. url.scheme = '';
  2925. url.username = '';
  2926. url.password = '';
  2927. url.host = null;
  2928. url.port = null;
  2929. url.path = [];
  2930. url.query = null;
  2931. url.fragment = null;
  2932. url.cannotBeABaseURL = false;
  2933. input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  2934. }
  2935. input = input.replace(TAB_AND_NEW_LINE, '');
  2936. codePoints = arrayFrom(input);
  2937. while (pointer <= codePoints.length) {
  2938. char = codePoints[pointer];
  2939. switch (state) {
  2940. case SCHEME_START:
  2941. if (char && ALPHA.test(char)) {
  2942. buffer += char.toLowerCase();
  2943. state = SCHEME;
  2944. } else if (!stateOverride) {
  2945. state = NO_SCHEME;
  2946. continue;
  2947. } else return INVALID_SCHEME;
  2948. break;
  2949. case SCHEME:
  2950. if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {
  2951. buffer += char.toLowerCase();
  2952. } else if (char == ':') {
  2953. if (stateOverride && (
  2954. (isSpecial(url) != has(specialSchemes, buffer)) ||
  2955. (buffer == 'file' && (includesCredentials(url) || url.port !== null)) ||
  2956. (url.scheme == 'file' && !url.host)
  2957. )) return;
  2958. url.scheme = buffer;
  2959. if (stateOverride) {
  2960. if (isSpecial(url) && specialSchemes[url.scheme] == url.port) url.port = null;
  2961. return;
  2962. }
  2963. buffer = '';
  2964. if (url.scheme == 'file') {
  2965. state = FILE;
  2966. } else if (isSpecial(url) && base && base.scheme == url.scheme) {
  2967. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  2968. } else if (isSpecial(url)) {
  2969. state = SPECIAL_AUTHORITY_SLASHES;
  2970. } else if (codePoints[pointer + 1] == '/') {
  2971. state = PATH_OR_AUTHORITY;
  2972. pointer++;
  2973. } else {
  2974. url.cannotBeABaseURL = true;
  2975. url.path.push('');
  2976. state = CANNOT_BE_A_BASE_URL_PATH;
  2977. }
  2978. } else if (!stateOverride) {
  2979. buffer = '';
  2980. state = NO_SCHEME;
  2981. pointer = 0;
  2982. continue;
  2983. } else return INVALID_SCHEME;
  2984. break;
  2985. case NO_SCHEME:
  2986. if (!base || (base.cannotBeABaseURL && char != '#')) return INVALID_SCHEME;
  2987. if (base.cannotBeABaseURL && char == '#') {
  2988. url.scheme = base.scheme;
  2989. url.path = base.path.slice();
  2990. url.query = base.query;
  2991. url.fragment = '';
  2992. url.cannotBeABaseURL = true;
  2993. state = FRAGMENT;
  2994. break;
  2995. }
  2996. state = base.scheme == 'file' ? FILE : RELATIVE;
  2997. continue;
  2998. case SPECIAL_RELATIVE_OR_AUTHORITY:
  2999. if (char == '/' && codePoints[pointer + 1] == '/') {
  3000. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  3001. pointer++;
  3002. } else {
  3003. state = RELATIVE;
  3004. continue;
  3005. } break;
  3006. case PATH_OR_AUTHORITY:
  3007. if (char == '/') {
  3008. state = AUTHORITY;
  3009. break;
  3010. } else {
  3011. state = PATH;
  3012. continue;
  3013. }
  3014. case RELATIVE:
  3015. url.scheme = base.scheme;
  3016. if (char == EOF) {
  3017. url.username = base.username;
  3018. url.password = base.password;
  3019. url.host = base.host;
  3020. url.port = base.port;
  3021. url.path = base.path.slice();
  3022. url.query = base.query;
  3023. } else if (char == '/' || (char == '\\' && isSpecial(url))) {
  3024. state = RELATIVE_SLASH;
  3025. } else if (char == '?') {
  3026. url.username = base.username;
  3027. url.password = base.password;
  3028. url.host = base.host;
  3029. url.port = base.port;
  3030. url.path = base.path.slice();
  3031. url.query = '';
  3032. state = QUERY;
  3033. } else if (char == '#') {
  3034. url.username = base.username;
  3035. url.password = base.password;
  3036. url.host = base.host;
  3037. url.port = base.port;
  3038. url.path = base.path.slice();
  3039. url.query = base.query;
  3040. url.fragment = '';
  3041. state = FRAGMENT;
  3042. } else {
  3043. url.username = base.username;
  3044. url.password = base.password;
  3045. url.host = base.host;
  3046. url.port = base.port;
  3047. url.path = base.path.slice();
  3048. url.path.pop();
  3049. state = PATH;
  3050. continue;
  3051. } break;
  3052. case RELATIVE_SLASH:
  3053. if (isSpecial(url) && (char == '/' || char == '\\')) {
  3054. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  3055. } else if (char == '/') {
  3056. state = AUTHORITY;
  3057. } else {
  3058. url.username = base.username;
  3059. url.password = base.password;
  3060. url.host = base.host;
  3061. url.port = base.port;
  3062. state = PATH;
  3063. continue;
  3064. } break;
  3065. case SPECIAL_AUTHORITY_SLASHES:
  3066. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  3067. if (char != '/' || buffer.charAt(pointer + 1) != '/') continue;
  3068. pointer++;
  3069. break;
  3070. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  3071. if (char != '/' && char != '\\') {
  3072. state = AUTHORITY;
  3073. continue;
  3074. } break;
  3075. case AUTHORITY:
  3076. if (char == '@') {
  3077. if (seenAt) buffer = '%40' + buffer;
  3078. seenAt = true;
  3079. bufferCodePoints = arrayFrom(buffer);
  3080. for (var i = 0; i < bufferCodePoints.length; i++) {
  3081. var codePoint = bufferCodePoints[i];
  3082. if (codePoint == ':' && !seenPasswordToken) {
  3083. seenPasswordToken = true;
  3084. continue;
  3085. }
  3086. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  3087. if (seenPasswordToken) url.password += encodedCodePoints;
  3088. else url.username += encodedCodePoints;
  3089. }
  3090. buffer = '';
  3091. } else if (
  3092. char == EOF || char == '/' || char == '?' || char == '#' ||
  3093. (char == '\\' && isSpecial(url))
  3094. ) {
  3095. if (seenAt && buffer == '') return INVALID_AUTHORITY;
  3096. pointer -= arrayFrom(buffer).length + 1;
  3097. buffer = '';
  3098. state = HOST;
  3099. } else buffer += char;
  3100. break;
  3101. case HOST:
  3102. case HOSTNAME:
  3103. if (stateOverride && url.scheme == 'file') {
  3104. state = FILE_HOST;
  3105. continue;
  3106. } else if (char == ':' && !seenBracket) {
  3107. if (buffer == '') return INVALID_HOST;
  3108. failure = parseHost(url, buffer);
  3109. if (failure) return failure;
  3110. buffer = '';
  3111. state = PORT;
  3112. if (stateOverride == HOSTNAME) return;
  3113. } else if (
  3114. char == EOF || char == '/' || char == '?' || char == '#' ||
  3115. (char == '\\' && isSpecial(url))
  3116. ) {
  3117. if (isSpecial(url) && buffer == '') return INVALID_HOST;
  3118. if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null)) return;
  3119. failure = parseHost(url, buffer);
  3120. if (failure) return failure;
  3121. buffer = '';
  3122. state = PATH_START;
  3123. if (stateOverride) return;
  3124. continue;
  3125. } else {
  3126. if (char == '[') seenBracket = true;
  3127. else if (char == ']') seenBracket = false;
  3128. buffer += char;
  3129. } break;
  3130. case PORT:
  3131. if (DIGIT.test(char)) {
  3132. buffer += char;
  3133. } else if (
  3134. char == EOF || char == '/' || char == '?' || char == '#' ||
  3135. (char == '\\' && isSpecial(url)) ||
  3136. stateOverride
  3137. ) {
  3138. if (buffer != '') {
  3139. var port = parseInt(buffer, 10);
  3140. if (port > 0xFFFF) return INVALID_PORT;
  3141. url.port = (isSpecial(url) && port === specialSchemes[url.scheme]) ? null : port;
  3142. buffer = '';
  3143. }
  3144. if (stateOverride) return;
  3145. state = PATH_START;
  3146. continue;
  3147. } else return INVALID_PORT;
  3148. break;
  3149. case FILE:
  3150. url.scheme = 'file';
  3151. if (char == '/' || char == '\\') state = FILE_SLASH;
  3152. else if (base && base.scheme == 'file') {
  3153. if (char == EOF) {
  3154. url.host = base.host;
  3155. url.path = base.path.slice();
  3156. url.query = base.query;
  3157. } else if (char == '?') {
  3158. url.host = base.host;
  3159. url.path = base.path.slice();
  3160. url.query = '';
  3161. state = QUERY;
  3162. } else if (char == '#') {
  3163. url.host = base.host;
  3164. url.path = base.path.slice();
  3165. url.query = base.query;
  3166. url.fragment = '';
  3167. state = FRAGMENT;
  3168. } else {
  3169. if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  3170. url.host = base.host;
  3171. url.path = base.path.slice();
  3172. shortenURLsPath(url);
  3173. }
  3174. state = PATH;
  3175. continue;
  3176. }
  3177. } else {
  3178. state = PATH;
  3179. continue;
  3180. } break;
  3181. case FILE_SLASH:
  3182. if (char == '/' || char == '\\') {
  3183. state = FILE_HOST;
  3184. break;
  3185. }
  3186. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  3187. if (isWindowsDriveLetter(base.path[0], true)) url.path.push(base.path[0]);
  3188. else url.host = base.host;
  3189. }
  3190. state = PATH;
  3191. continue;
  3192. case FILE_HOST:
  3193. if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') {
  3194. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  3195. state = PATH;
  3196. } else if (buffer == '') {
  3197. url.host = '';
  3198. if (stateOverride) return;
  3199. state = PATH_START;
  3200. } else {
  3201. failure = parseHost(url, buffer);
  3202. if (failure) return failure;
  3203. if (url.host == 'localhost') url.host = '';
  3204. if (stateOverride) return;
  3205. buffer = '';
  3206. state = PATH_START;
  3207. } continue;
  3208. } else buffer += char;
  3209. break;
  3210. case PATH_START:
  3211. if (isSpecial(url)) {
  3212. state = PATH;
  3213. if (char != '/' && char != '\\') continue;
  3214. } else if (!stateOverride && char == '?') {
  3215. url.query = '';
  3216. state = QUERY;
  3217. } else if (!stateOverride && char == '#') {
  3218. url.fragment = '';
  3219. state = FRAGMENT;
  3220. } else if (char != EOF) {
  3221. state = PATH;
  3222. if (char != '/') continue;
  3223. } break;
  3224. case PATH:
  3225. if (
  3226. char == EOF || char == '/' ||
  3227. (char == '\\' && isSpecial(url)) ||
  3228. (!stateOverride && (char == '?' || char == '#'))
  3229. ) {
  3230. if (isDoubleDot(buffer)) {
  3231. shortenURLsPath(url);
  3232. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  3233. url.path.push('');
  3234. }
  3235. } else if (isSingleDot(buffer)) {
  3236. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  3237. url.path.push('');
  3238. }
  3239. } else {
  3240. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  3241. if (url.host) url.host = '';
  3242. buffer = buffer.charAt(0) + ':'; // normalize windows drive letter
  3243. }
  3244. url.path.push(buffer);
  3245. }
  3246. buffer = '';
  3247. if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {
  3248. while (url.path.length > 1 && url.path[0] === '') {
  3249. url.path.shift();
  3250. }
  3251. }
  3252. if (char == '?') {
  3253. url.query = '';
  3254. state = QUERY;
  3255. } else if (char == '#') {
  3256. url.fragment = '';
  3257. state = FRAGMENT;
  3258. }
  3259. } else {
  3260. buffer += percentEncode(char, pathPercentEncodeSet);
  3261. } break;
  3262. case CANNOT_BE_A_BASE_URL_PATH:
  3263. if (char == '?') {
  3264. url.query = '';
  3265. state = QUERY;
  3266. } else if (char == '#') {
  3267. url.fragment = '';
  3268. state = FRAGMENT;
  3269. } else if (char != EOF) {
  3270. url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);
  3271. } break;
  3272. case QUERY:
  3273. if (!stateOverride && char == '#') {
  3274. url.fragment = '';
  3275. state = FRAGMENT;
  3276. } else if (char != EOF) {
  3277. if (char == "'" && isSpecial(url)) url.query += '%27';
  3278. else if (char == '#') url.query += '%23';
  3279. else url.query += percentEncode(char, C0ControlPercentEncodeSet);
  3280. } break;
  3281. case FRAGMENT:
  3282. if (char != EOF) url.fragment += percentEncode(char, fragmentPercentEncodeSet);
  3283. break;
  3284. }
  3285. pointer++;
  3286. }
  3287. };
  3288. // `URL` constructor
  3289. // https://url.spec.whatwg.org/#url-class
  3290. var URLConstructor = function URL(url /* , base */) {
  3291. var that = anInstance(this, URLConstructor, 'URL');
  3292. var base = arguments.length > 1 ? arguments[1] : undefined;
  3293. var urlString = String(url);
  3294. var state = setInternalState$4(that, { type: 'URL' });
  3295. var baseState, failure;
  3296. if (base !== undefined) {
  3297. if (base instanceof URLConstructor) baseState = getInternalURLState(base);
  3298. else {
  3299. failure = parseURL(baseState = {}, String(base));
  3300. if (failure) throw TypeError(failure);
  3301. }
  3302. }
  3303. failure = parseURL(state, urlString, null, baseState);
  3304. if (failure) throw TypeError(failure);
  3305. var searchParams = state.searchParams = new URLSearchParams$1();
  3306. var searchParamsState = getInternalSearchParamsState(searchParams);
  3307. searchParamsState.updateSearchParams(state.query);
  3308. searchParamsState.updateURL = function () {
  3309. state.query = String(searchParams) || null;
  3310. };
  3311. if (!descriptors) {
  3312. that.href = serializeURL.call(that);
  3313. that.origin = getOrigin.call(that);
  3314. that.protocol = getProtocol.call(that);
  3315. that.username = getUsername.call(that);
  3316. that.password = getPassword.call(that);
  3317. that.host = getHost.call(that);
  3318. that.hostname = getHostname.call(that);
  3319. that.port = getPort.call(that);
  3320. that.pathname = getPathname.call(that);
  3321. that.search = getSearch.call(that);
  3322. that.searchParams = getSearchParams.call(that);
  3323. that.hash = getHash.call(that);
  3324. }
  3325. };
  3326. var URLPrototype = URLConstructor.prototype;
  3327. var serializeURL = function () {
  3328. var url = getInternalURLState(this);
  3329. var scheme = url.scheme;
  3330. var username = url.username;
  3331. var password = url.password;
  3332. var host = url.host;
  3333. var port = url.port;
  3334. var path = url.path;
  3335. var query = url.query;
  3336. var fragment = url.fragment;
  3337. var output = scheme + ':';
  3338. if (host !== null) {
  3339. output += '//';
  3340. if (includesCredentials(url)) {
  3341. output += username + (password ? ':' + password : '') + '@';
  3342. }
  3343. output += serializeHost(host);
  3344. if (port !== null) output += ':' + port;
  3345. } else if (scheme == 'file') output += '//';
  3346. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  3347. if (query !== null) output += '?' + query;
  3348. if (fragment !== null) output += '#' + fragment;
  3349. return output;
  3350. };
  3351. var getOrigin = function () {
  3352. var url = getInternalURLState(this);
  3353. var scheme = url.scheme;
  3354. var port = url.port;
  3355. if (scheme == 'blob') try {
  3356. return new URL(scheme.path[0]).origin;
  3357. } catch (error) {
  3358. return 'null';
  3359. }
  3360. if (scheme == 'file' || !isSpecial(url)) return 'null';
  3361. return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');
  3362. };
  3363. var getProtocol = function () {
  3364. return getInternalURLState(this).scheme + ':';
  3365. };
  3366. var getUsername = function () {
  3367. return getInternalURLState(this).username;
  3368. };
  3369. var getPassword = function () {
  3370. return getInternalURLState(this).password;
  3371. };
  3372. var getHost = function () {
  3373. var url = getInternalURLState(this);
  3374. var host = url.host;
  3375. var port = url.port;
  3376. return host === null ? ''
  3377. : port === null ? serializeHost(host)
  3378. : serializeHost(host) + ':' + port;
  3379. };
  3380. var getHostname = function () {
  3381. var host = getInternalURLState(this).host;
  3382. return host === null ? '' : serializeHost(host);
  3383. };
  3384. var getPort = function () {
  3385. var port = getInternalURLState(this).port;
  3386. return port === null ? '' : String(port);
  3387. };
  3388. var getPathname = function () {
  3389. var url = getInternalURLState(this);
  3390. var path = url.path;
  3391. return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  3392. };
  3393. var getSearch = function () {
  3394. var query = getInternalURLState(this).query;
  3395. return query ? '?' + query : '';
  3396. };
  3397. var getSearchParams = function () {
  3398. return getInternalURLState(this).searchParams;
  3399. };
  3400. var getHash = function () {
  3401. var fragment = getInternalURLState(this).fragment;
  3402. return fragment ? '#' + fragment : '';
  3403. };
  3404. var accessorDescriptor = function (getter, setter) {
  3405. return { get: getter, set: setter, configurable: true, enumerable: true };
  3406. };
  3407. if (descriptors) {
  3408. objectDefineProperties(URLPrototype, {
  3409. // `URL.prototype.href` accessors pair
  3410. // https://url.spec.whatwg.org/#dom-url-href
  3411. href: accessorDescriptor(serializeURL, function (href) {
  3412. var url = getInternalURLState(this);
  3413. var urlString = String(href);
  3414. var failure = parseURL(url, urlString);
  3415. if (failure) throw TypeError(failure);
  3416. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  3417. }),
  3418. // `URL.prototype.origin` getter
  3419. // https://url.spec.whatwg.org/#dom-url-origin
  3420. origin: accessorDescriptor(getOrigin),
  3421. // `URL.prototype.protocol` accessors pair
  3422. // https://url.spec.whatwg.org/#dom-url-protocol
  3423. protocol: accessorDescriptor(getProtocol, function (protocol) {
  3424. var url = getInternalURLState(this);
  3425. parseURL(url, String(protocol) + ':', SCHEME_START);
  3426. }),
  3427. // `URL.prototype.username` accessors pair
  3428. // https://url.spec.whatwg.org/#dom-url-username
  3429. username: accessorDescriptor(getUsername, function (username) {
  3430. var url = getInternalURLState(this);
  3431. var codePoints = arrayFrom(String(username));
  3432. if (cannotHaveUsernamePasswordPort(url)) return;
  3433. url.username = '';
  3434. for (var i = 0; i < codePoints.length; i++) {
  3435. url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  3436. }
  3437. }),
  3438. // `URL.prototype.password` accessors pair
  3439. // https://url.spec.whatwg.org/#dom-url-password
  3440. password: accessorDescriptor(getPassword, function (password) {
  3441. var url = getInternalURLState(this);
  3442. var codePoints = arrayFrom(String(password));
  3443. if (cannotHaveUsernamePasswordPort(url)) return;
  3444. url.password = '';
  3445. for (var i = 0; i < codePoints.length; i++) {
  3446. url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  3447. }
  3448. }),
  3449. // `URL.prototype.host` accessors pair
  3450. // https://url.spec.whatwg.org/#dom-url-host
  3451. host: accessorDescriptor(getHost, function (host) {
  3452. var url = getInternalURLState(this);
  3453. if (url.cannotBeABaseURL) return;
  3454. parseURL(url, String(host), HOST);
  3455. }),
  3456. // `URL.prototype.hostname` accessors pair
  3457. // https://url.spec.whatwg.org/#dom-url-hostname
  3458. hostname: accessorDescriptor(getHostname, function (hostname) {
  3459. var url = getInternalURLState(this);
  3460. if (url.cannotBeABaseURL) return;
  3461. parseURL(url, String(hostname), HOSTNAME);
  3462. }),
  3463. // `URL.prototype.port` accessors pair
  3464. // https://url.spec.whatwg.org/#dom-url-port
  3465. port: accessorDescriptor(getPort, function (port) {
  3466. var url = getInternalURLState(this);
  3467. if (cannotHaveUsernamePasswordPort(url)) return;
  3468. port = String(port);
  3469. if (port == '') url.port = null;
  3470. else parseURL(url, port, PORT);
  3471. }),
  3472. // `URL.prototype.pathname` accessors pair
  3473. // https://url.spec.whatwg.org/#dom-url-pathname
  3474. pathname: accessorDescriptor(getPathname, function (pathname) {
  3475. var url = getInternalURLState(this);
  3476. if (url.cannotBeABaseURL) return;
  3477. url.path = [];
  3478. parseURL(url, pathname + '', PATH_START);
  3479. }),
  3480. // `URL.prototype.search` accessors pair
  3481. // https://url.spec.whatwg.org/#dom-url-search
  3482. search: accessorDescriptor(getSearch, function (search) {
  3483. var url = getInternalURLState(this);
  3484. search = String(search);
  3485. if (search == '') {
  3486. url.query = null;
  3487. } else {
  3488. if ('?' == search.charAt(0)) search = search.slice(1);
  3489. url.query = '';
  3490. parseURL(url, search, QUERY);
  3491. }
  3492. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  3493. }),
  3494. // `URL.prototype.searchParams` getter
  3495. // https://url.spec.whatwg.org/#dom-url-searchparams
  3496. searchParams: accessorDescriptor(getSearchParams),
  3497. // `URL.prototype.hash` accessors pair
  3498. // https://url.spec.whatwg.org/#dom-url-hash
  3499. hash: accessorDescriptor(getHash, function (hash) {
  3500. var url = getInternalURLState(this);
  3501. hash = String(hash);
  3502. if (hash == '') {
  3503. url.fragment = null;
  3504. return;
  3505. }
  3506. if ('#' == hash.charAt(0)) hash = hash.slice(1);
  3507. url.fragment = '';
  3508. parseURL(url, hash, FRAGMENT);
  3509. })
  3510. });
  3511. }
  3512. // `URL.prototype.toJSON` method
  3513. // https://url.spec.whatwg.org/#dom-url-tojson
  3514. redefine(URLPrototype, 'toJSON', function toJSON() {
  3515. return serializeURL.call(this);
  3516. }, { enumerable: true });
  3517. // `URL.prototype.toString` method
  3518. // https://url.spec.whatwg.org/#URL-stringification-behavior
  3519. redefine(URLPrototype, 'toString', function toString() {
  3520. return serializeURL.call(this);
  3521. }, { enumerable: true });
  3522. if (NativeURL) {
  3523. var nativeCreateObjectURL = NativeURL.createObjectURL;
  3524. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  3525. // `URL.createObjectURL` method
  3526. // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
  3527. // eslint-disable-next-line no-unused-vars
  3528. if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {
  3529. return nativeCreateObjectURL.apply(NativeURL, arguments);
  3530. });
  3531. // `URL.revokeObjectURL` method
  3532. // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
  3533. // eslint-disable-next-line no-unused-vars
  3534. if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {
  3535. return nativeRevokeObjectURL.apply(NativeURL, arguments);
  3536. });
  3537. }
  3538. setToStringTag(URLConstructor, 'URL');
  3539. _export({ global: true, forced: !nativeUrl, sham: !descriptors }, {
  3540. URL: URLConstructor
  3541. });
  3542. function _typeof(obj) {
  3543. "@babel/helpers - typeof";
  3544. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  3545. _typeof = function (obj) {
  3546. return typeof obj;
  3547. };
  3548. } else {
  3549. _typeof = function (obj) {
  3550. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  3551. };
  3552. }
  3553. return _typeof(obj);
  3554. }
  3555. function _classCallCheck(instance, Constructor) {
  3556. if (!(instance instanceof Constructor)) {
  3557. throw new TypeError("Cannot call a class as a function");
  3558. }
  3559. }
  3560. function _defineProperties(target, props) {
  3561. for (var i = 0; i < props.length; i++) {
  3562. var descriptor = props[i];
  3563. descriptor.enumerable = descriptor.enumerable || false;
  3564. descriptor.configurable = true;
  3565. if ("value" in descriptor) descriptor.writable = true;
  3566. Object.defineProperty(target, descriptor.key, descriptor);
  3567. }
  3568. }
  3569. function _createClass(Constructor, protoProps, staticProps) {
  3570. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  3571. if (staticProps) _defineProperties(Constructor, staticProps);
  3572. return Constructor;
  3573. }
  3574. function _defineProperty(obj, key, value) {
  3575. if (key in obj) {
  3576. Object.defineProperty(obj, key, {
  3577. value: value,
  3578. enumerable: true,
  3579. configurable: true,
  3580. writable: true
  3581. });
  3582. } else {
  3583. obj[key] = value;
  3584. }
  3585. return obj;
  3586. }
  3587. function ownKeys$1(object, enumerableOnly) {
  3588. var keys = Object.keys(object);
  3589. if (Object.getOwnPropertySymbols) {
  3590. var symbols = Object.getOwnPropertySymbols(object);
  3591. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  3592. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  3593. });
  3594. keys.push.apply(keys, symbols);
  3595. }
  3596. return keys;
  3597. }
  3598. function _objectSpread2(target) {
  3599. for (var i = 1; i < arguments.length; i++) {
  3600. var source = arguments[i] != null ? arguments[i] : {};
  3601. if (i % 2) {
  3602. ownKeys$1(Object(source), true).forEach(function (key) {
  3603. _defineProperty(target, key, source[key]);
  3604. });
  3605. } else if (Object.getOwnPropertyDescriptors) {
  3606. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  3607. } else {
  3608. ownKeys$1(Object(source)).forEach(function (key) {
  3609. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  3610. });
  3611. }
  3612. }
  3613. return target;
  3614. }
  3615. function _objectWithoutPropertiesLoose(source, excluded) {
  3616. if (source == null) return {};
  3617. var target = {};
  3618. var sourceKeys = Object.keys(source);
  3619. var key, i;
  3620. for (i = 0; i < sourceKeys.length; i++) {
  3621. key = sourceKeys[i];
  3622. if (excluded.indexOf(key) >= 0) continue;
  3623. target[key] = source[key];
  3624. }
  3625. return target;
  3626. }
  3627. function _objectWithoutProperties(source, excluded) {
  3628. if (source == null) return {};
  3629. var target = _objectWithoutPropertiesLoose(source, excluded);
  3630. var key, i;
  3631. if (Object.getOwnPropertySymbols) {
  3632. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  3633. for (i = 0; i < sourceSymbolKeys.length; i++) {
  3634. key = sourceSymbolKeys[i];
  3635. if (excluded.indexOf(key) >= 0) continue;
  3636. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  3637. target[key] = source[key];
  3638. }
  3639. }
  3640. return target;
  3641. }
  3642. function _slicedToArray(arr, i) {
  3643. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  3644. }
  3645. function _toConsumableArray(arr) {
  3646. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  3647. }
  3648. function _arrayWithoutHoles(arr) {
  3649. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  3650. }
  3651. function _arrayWithHoles(arr) {
  3652. if (Array.isArray(arr)) return arr;
  3653. }
  3654. function _iterableToArray(iter) {
  3655. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  3656. }
  3657. function _iterableToArrayLimit(arr, i) {
  3658. if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
  3659. var _arr = [];
  3660. var _n = true;
  3661. var _d = false;
  3662. var _e = undefined;
  3663. try {
  3664. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  3665. _arr.push(_s.value);
  3666. if (i && _arr.length === i) break;
  3667. }
  3668. } catch (err) {
  3669. _d = true;
  3670. _e = err;
  3671. } finally {
  3672. try {
  3673. if (!_n && _i["return"] != null) _i["return"]();
  3674. } finally {
  3675. if (_d) throw _e;
  3676. }
  3677. }
  3678. return _arr;
  3679. }
  3680. function _unsupportedIterableToArray(o, minLen) {
  3681. if (!o) return;
  3682. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  3683. var n = Object.prototype.toString.call(o).slice(8, -1);
  3684. if (n === "Object" && o.constructor) n = o.constructor.name;
  3685. if (n === "Map" || n === "Set") return Array.from(o);
  3686. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  3687. }
  3688. function _arrayLikeToArray(arr, len) {
  3689. if (len == null || len > arr.length) len = arr.length;
  3690. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  3691. return arr2;
  3692. }
  3693. function _nonIterableSpread() {
  3694. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3695. }
  3696. function _nonIterableRest() {
  3697. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3698. }
  3699. (function (global) {
  3700. /**
  3701. * Polyfill URLSearchParams
  3702. *
  3703. * Inspired from : https://github.com/WebReflection/url-search-params/blob/master/src/url-search-params.js
  3704. */
  3705. var checkIfIteratorIsSupported = function checkIfIteratorIsSupported() {
  3706. try {
  3707. return !!Symbol.iterator;
  3708. } catch (error) {
  3709. return false;
  3710. }
  3711. };
  3712. var iteratorSupported = checkIfIteratorIsSupported();
  3713. var createIterator = function createIterator(items) {
  3714. var iterator = {
  3715. next: function next() {
  3716. var value = items.shift();
  3717. return {
  3718. done: value === void 0,
  3719. value: value
  3720. };
  3721. }
  3722. };
  3723. if (iteratorSupported) {
  3724. iterator[Symbol.iterator] = function () {
  3725. return iterator;
  3726. };
  3727. }
  3728. return iterator;
  3729. };
  3730. /**
  3731. * Search param name and values should be encoded according to https://url.spec.whatwg.org/#urlencoded-serializing
  3732. * encodeURIComponent() produces the same result except encoding spaces as `%20` instead of `+`.
  3733. */
  3734. var serializeParam = function serializeParam(value) {
  3735. return encodeURIComponent(value).replace(/%20/g, '+');
  3736. };
  3737. var deserializeParam = function deserializeParam(value) {
  3738. return decodeURIComponent(String(value).replace(/\+/g, ' '));
  3739. };
  3740. var polyfillURLSearchParams = function polyfillURLSearchParams() {
  3741. var URLSearchParams = function URLSearchParams(searchString) {
  3742. Object.defineProperty(this, '_entries', {
  3743. writable: true,
  3744. value: {}
  3745. });
  3746. var typeofSearchString = _typeof(searchString);
  3747. if (typeofSearchString === 'undefined') ; else if (typeofSearchString === 'string') {
  3748. if (searchString !== '') {
  3749. this._fromString(searchString);
  3750. }
  3751. } else if (searchString instanceof URLSearchParams) {
  3752. var _this = this;
  3753. searchString.forEach(function (value, name) {
  3754. _this.append(name, value);
  3755. });
  3756. } else if (searchString !== null && typeofSearchString === 'object') {
  3757. if (Object.prototype.toString.call(searchString) === '[object Array]') {
  3758. for (var i = 0; i < searchString.length; i++) {
  3759. var entry = searchString[i];
  3760. if (Object.prototype.toString.call(entry) === '[object Array]' || entry.length !== 2) {
  3761. this.append(entry[0], entry[1]);
  3762. } else {
  3763. throw new TypeError('Expected [string, any] as entry at index ' + i + ' of URLSearchParams\'s input');
  3764. }
  3765. }
  3766. } else {
  3767. for (var key in searchString) {
  3768. if (searchString.hasOwnProperty(key)) {
  3769. this.append(key, searchString[key]);
  3770. }
  3771. }
  3772. }
  3773. } else {
  3774. throw new TypeError('Unsupported input\'s type for URLSearchParams');
  3775. }
  3776. };
  3777. var proto = URLSearchParams.prototype;
  3778. proto.append = function (name, value) {
  3779. if (name in this._entries) {
  3780. this._entries[name].push(String(value));
  3781. } else {
  3782. this._entries[name] = [String(value)];
  3783. }
  3784. };
  3785. proto.delete = function (name) {
  3786. delete this._entries[name];
  3787. };
  3788. proto.get = function (name) {
  3789. return name in this._entries ? this._entries[name][0] : null;
  3790. };
  3791. proto.getAll = function (name) {
  3792. return name in this._entries ? this._entries[name].slice(0) : [];
  3793. };
  3794. proto.has = function (name) {
  3795. return name in this._entries;
  3796. };
  3797. proto.set = function (name, value) {
  3798. this._entries[name] = [String(value)];
  3799. };
  3800. proto.forEach = function (callback, thisArg) {
  3801. var entries;
  3802. for (var name in this._entries) {
  3803. if (this._entries.hasOwnProperty(name)) {
  3804. entries = this._entries[name];
  3805. for (var i = 0; i < entries.length; i++) {
  3806. callback.call(thisArg, entries[i], name, this);
  3807. }
  3808. }
  3809. }
  3810. };
  3811. proto.keys = function () {
  3812. var items = [];
  3813. this.forEach(function (value, name) {
  3814. items.push(name);
  3815. });
  3816. return createIterator(items);
  3817. };
  3818. proto.values = function () {
  3819. var items = [];
  3820. this.forEach(function (value) {
  3821. items.push(value);
  3822. });
  3823. return createIterator(items);
  3824. };
  3825. proto.entries = function () {
  3826. var items = [];
  3827. this.forEach(function (value, name) {
  3828. items.push([name, value]);
  3829. });
  3830. return createIterator(items);
  3831. };
  3832. if (iteratorSupported) {
  3833. proto[Symbol.iterator] = proto.entries;
  3834. }
  3835. proto.toString = function () {
  3836. var searchArray = [];
  3837. this.forEach(function (value, name) {
  3838. searchArray.push(serializeParam(name) + '=' + serializeParam(value));
  3839. });
  3840. return searchArray.join('&');
  3841. };
  3842. global.URLSearchParams = URLSearchParams;
  3843. };
  3844. var checkIfURLSearchParamsSupported = function checkIfURLSearchParamsSupported() {
  3845. try {
  3846. var URLSearchParams = global.URLSearchParams;
  3847. return new URLSearchParams('?a=1').toString() === 'a=1' && typeof URLSearchParams.prototype.set === 'function';
  3848. } catch (e) {
  3849. return false;
  3850. }
  3851. };
  3852. if (!checkIfURLSearchParamsSupported()) {
  3853. polyfillURLSearchParams();
  3854. }
  3855. var proto = global.URLSearchParams.prototype;
  3856. if (typeof proto.sort !== 'function') {
  3857. proto.sort = function () {
  3858. var _this = this;
  3859. var items = [];
  3860. this.forEach(function (value, name) {
  3861. items.push([name, value]);
  3862. if (!_this._entries) {
  3863. _this.delete(name);
  3864. }
  3865. });
  3866. items.sort(function (a, b) {
  3867. if (a[0] < b[0]) {
  3868. return -1;
  3869. } else if (a[0] > b[0]) {
  3870. return +1;
  3871. } else {
  3872. return 0;
  3873. }
  3874. });
  3875. if (_this._entries) {
  3876. // force reset because IE keeps keys index
  3877. _this._entries = {};
  3878. }
  3879. for (var i = 0; i < items.length; i++) {
  3880. this.append(items[i][0], items[i][1]);
  3881. }
  3882. };
  3883. }
  3884. if (typeof proto._fromString !== 'function') {
  3885. Object.defineProperty(proto, '_fromString', {
  3886. enumerable: false,
  3887. configurable: false,
  3888. writable: false,
  3889. value: function value(searchString) {
  3890. if (this._entries) {
  3891. this._entries = {};
  3892. } else {
  3893. var keys = [];
  3894. this.forEach(function (value, name) {
  3895. keys.push(name);
  3896. });
  3897. for (var i = 0; i < keys.length; i++) {
  3898. this.delete(keys[i]);
  3899. }
  3900. }
  3901. searchString = searchString.replace(/^\?/, '');
  3902. var attributes = searchString.split('&');
  3903. var attribute;
  3904. for (var i = 0; i < attributes.length; i++) {
  3905. attribute = attributes[i].split('=');
  3906. this.append(deserializeParam(attribute[0]), attribute.length > 1 ? deserializeParam(attribute[1]) : '');
  3907. }
  3908. }
  3909. });
  3910. } // HTMLAnchorElement
  3911. })(typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal);
  3912. (function (global) {
  3913. /**
  3914. * Polyfill URL
  3915. *
  3916. * Inspired from : https://github.com/arv/DOM-URL-Polyfill/blob/master/src/url.js
  3917. */
  3918. var checkIfURLIsSupported = function checkIfURLIsSupported() {
  3919. try {
  3920. var u = new global.URL('b', 'http://a');
  3921. u.pathname = 'c d';
  3922. return u.href === 'http://a/c%20d' && u.searchParams;
  3923. } catch (e) {
  3924. return false;
  3925. }
  3926. };
  3927. var polyfillURL = function polyfillURL() {
  3928. var _URL = global.URL;
  3929. var URL = function URL(url, base) {
  3930. if (typeof url !== 'string') url = String(url); // Only create another document if the base is different from current location.
  3931. var doc = document,
  3932. baseElement;
  3933. if (base && (global.location === void 0 || base !== global.location.href)) {
  3934. doc = document.implementation.createHTMLDocument('');
  3935. baseElement = doc.createElement('base');
  3936. baseElement.href = base;
  3937. doc.head.appendChild(baseElement);
  3938. try {
  3939. if (baseElement.href.indexOf(base) !== 0) throw new Error(baseElement.href);
  3940. } catch (err) {
  3941. throw new Error('URL unable to set base ' + base + ' due to ' + err);
  3942. }
  3943. }
  3944. var anchorElement = doc.createElement('a');
  3945. anchorElement.href = url;
  3946. if (baseElement) {
  3947. doc.body.appendChild(anchorElement);
  3948. anchorElement.href = anchorElement.href; // force href to refresh
  3949. }
  3950. var inputElement = doc.createElement('input');
  3951. inputElement.type = 'url';
  3952. inputElement.value = url;
  3953. if (anchorElement.protocol === ':' || !/:/.test(anchorElement.href) || !inputElement.checkValidity() && !base) {
  3954. throw new TypeError('Invalid URL');
  3955. }
  3956. Object.defineProperty(this, '_anchorElement', {
  3957. value: anchorElement
  3958. }); // create a linked searchParams which reflect its changes on URL
  3959. var searchParams = new global.URLSearchParams(this.search);
  3960. var enableSearchUpdate = true;
  3961. var enableSearchParamsUpdate = true;
  3962. var _this = this;
  3963. ['append', 'delete', 'set'].forEach(function (methodName) {
  3964. var method = searchParams[methodName];
  3965. searchParams[methodName] = function () {
  3966. method.apply(searchParams, arguments);
  3967. if (enableSearchUpdate) {
  3968. enableSearchParamsUpdate = false;
  3969. _this.search = searchParams.toString();
  3970. enableSearchParamsUpdate = true;
  3971. }
  3972. };
  3973. });
  3974. Object.defineProperty(this, 'searchParams', {
  3975. value: searchParams,
  3976. enumerable: true
  3977. });
  3978. var search = void 0;
  3979. Object.defineProperty(this, '_updateSearchParams', {
  3980. enumerable: false,
  3981. configurable: false,
  3982. writable: false,
  3983. value: function value() {
  3984. if (this.search !== search) {
  3985. search = this.search;
  3986. if (enableSearchParamsUpdate) {
  3987. enableSearchUpdate = false;
  3988. this.searchParams._fromString(this.search);
  3989. enableSearchUpdate = true;
  3990. }
  3991. }
  3992. }
  3993. });
  3994. };
  3995. var proto = URL.prototype;
  3996. var linkURLWithAnchorAttribute = function linkURLWithAnchorAttribute(attributeName) {
  3997. Object.defineProperty(proto, attributeName, {
  3998. get: function get() {
  3999. return this._anchorElement[attributeName];
  4000. },
  4001. set: function set(value) {
  4002. this._anchorElement[attributeName] = value;
  4003. },
  4004. enumerable: true
  4005. });
  4006. };
  4007. ['hash', 'host', 'hostname', 'port', 'protocol'].forEach(function (attributeName) {
  4008. linkURLWithAnchorAttribute(attributeName);
  4009. });
  4010. Object.defineProperty(proto, 'search', {
  4011. get: function get() {
  4012. return this._anchorElement['search'];
  4013. },
  4014. set: function set(value) {
  4015. this._anchorElement['search'] = value;
  4016. this._updateSearchParams();
  4017. },
  4018. enumerable: true
  4019. });
  4020. Object.defineProperties(proto, {
  4021. 'toString': {
  4022. get: function get() {
  4023. var _this = this;
  4024. return function () {
  4025. return _this.href;
  4026. };
  4027. }
  4028. },
  4029. 'href': {
  4030. get: function get() {
  4031. return this._anchorElement.href.replace(/\?$/, '');
  4032. },
  4033. set: function set(value) {
  4034. this._anchorElement.href = value;
  4035. this._updateSearchParams();
  4036. },
  4037. enumerable: true
  4038. },
  4039. 'pathname': {
  4040. get: function get() {
  4041. return this._anchorElement.pathname.replace(/(^\/?)/, '/');
  4042. },
  4043. set: function set(value) {
  4044. this._anchorElement.pathname = value;
  4045. },
  4046. enumerable: true
  4047. },
  4048. 'origin': {
  4049. get: function get() {
  4050. // get expected port from protocol
  4051. var expectedPort = {
  4052. 'http:': 80,
  4053. 'https:': 443,
  4054. 'ftp:': 21
  4055. }[this._anchorElement.protocol]; // add port to origin if, expected port is different than actual port
  4056. // and it is not empty f.e http://foo:8080
  4057. // 8080 != 80 && 8080 != ''
  4058. var addPortToOrigin = this._anchorElement.port != expectedPort && this._anchorElement.port !== '';
  4059. return this._anchorElement.protocol + '//' + this._anchorElement.hostname + (addPortToOrigin ? ':' + this._anchorElement.port : '');
  4060. },
  4061. enumerable: true
  4062. },
  4063. 'password': {
  4064. // TODO
  4065. get: function get() {
  4066. return '';
  4067. },
  4068. set: function set(value) {},
  4069. enumerable: true
  4070. },
  4071. 'username': {
  4072. // TODO
  4073. get: function get() {
  4074. return '';
  4075. },
  4076. set: function set(value) {},
  4077. enumerable: true
  4078. }
  4079. });
  4080. URL.createObjectURL = function (blob) {
  4081. return _URL.createObjectURL.apply(_URL, arguments);
  4082. };
  4083. URL.revokeObjectURL = function (url) {
  4084. return _URL.revokeObjectURL.apply(_URL, arguments);
  4085. };
  4086. global.URL = URL;
  4087. };
  4088. if (!checkIfURLIsSupported()) {
  4089. polyfillURL();
  4090. }
  4091. if (global.location !== void 0 && !('origin' in global.location)) {
  4092. var getOrigin = function getOrigin() {
  4093. return global.location.protocol + '//' + global.location.hostname + (global.location.port ? ':' + global.location.port : '');
  4094. };
  4095. try {
  4096. Object.defineProperty(global.location, 'origin', {
  4097. get: getOrigin,
  4098. enumerable: true
  4099. });
  4100. } catch (e) {
  4101. setInterval(function () {
  4102. global.location.origin = getOrigin();
  4103. }, 100);
  4104. }
  4105. }
  4106. })(typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal);
  4107. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  4108. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  4109. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  4110. // We can't use this feature detection in V8 since it causes
  4111. // deoptimization and serious performance degradation
  4112. // https://github.com/zloirock/core-js/issues/679
  4113. var IS_CONCAT_SPREADABLE_SUPPORT = engineV8Version >= 51 || !fails(function () {
  4114. var array = [];
  4115. array[IS_CONCAT_SPREADABLE] = false;
  4116. return array.concat()[0] !== array;
  4117. });
  4118. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  4119. var isConcatSpreadable = function (O) {
  4120. if (!isObject(O)) return false;
  4121. var spreadable = O[IS_CONCAT_SPREADABLE];
  4122. return spreadable !== undefined ? !!spreadable : isArray(O);
  4123. };
  4124. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  4125. // `Array.prototype.concat` method
  4126. // https://tc39.github.io/ecma262/#sec-array.prototype.concat
  4127. // with adding support of @@isConcatSpreadable and @@species
  4128. _export({ target: 'Array', proto: true, forced: FORCED }, {
  4129. concat: function concat(arg) { // eslint-disable-line no-unused-vars
  4130. var O = toObject(this);
  4131. var A = arraySpeciesCreate(O, 0);
  4132. var n = 0;
  4133. var i, k, length, len, E;
  4134. for (i = -1, length = arguments.length; i < length; i++) {
  4135. E = i === -1 ? O : arguments[i];
  4136. if (isConcatSpreadable(E)) {
  4137. len = toLength(E.length);
  4138. if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  4139. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  4140. } else {
  4141. if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  4142. createProperty(A, n++, E);
  4143. }
  4144. }
  4145. A.length = n;
  4146. return A;
  4147. }
  4148. });
  4149. var $filter = arrayIteration.filter;
  4150. var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('filter');
  4151. // Edge 14- issue
  4152. var USES_TO_LENGTH$3 = arrayMethodUsesToLength('filter');
  4153. // `Array.prototype.filter` method
  4154. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  4155. // with adding support of @@species
  4156. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 || !USES_TO_LENGTH$3 }, {
  4157. filter: function filter(callbackfn /* , thisArg */) {
  4158. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4159. }
  4160. });
  4161. var $find = arrayIteration.find;
  4162. var FIND = 'find';
  4163. var SKIPS_HOLES = true;
  4164. var USES_TO_LENGTH$4 = arrayMethodUsesToLength(FIND);
  4165. // Shouldn't skip holes
  4166. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  4167. // `Array.prototype.find` method
  4168. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  4169. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH$4 }, {
  4170. find: function find(callbackfn /* , that = undefined */) {
  4171. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4172. }
  4173. });
  4174. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  4175. addToUnscopables(FIND);
  4176. var ITERATOR$7 = wellKnownSymbol('iterator');
  4177. var SAFE_CLOSING = false;
  4178. try {
  4179. var called = 0;
  4180. var iteratorWithReturn = {
  4181. next: function () {
  4182. return { done: !!called++ };
  4183. },
  4184. 'return': function () {
  4185. SAFE_CLOSING = true;
  4186. }
  4187. };
  4188. iteratorWithReturn[ITERATOR$7] = function () {
  4189. return this;
  4190. };
  4191. // eslint-disable-next-line no-throw-literal
  4192. Array.from(iteratorWithReturn, function () { throw 2; });
  4193. } catch (error) { /* empty */ }
  4194. var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
  4195. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  4196. var ITERATION_SUPPORT = false;
  4197. try {
  4198. var object = {};
  4199. object[ITERATOR$7] = function () {
  4200. return {
  4201. next: function () {
  4202. return { done: ITERATION_SUPPORT = true };
  4203. }
  4204. };
  4205. };
  4206. exec(object);
  4207. } catch (error) { /* empty */ }
  4208. return ITERATION_SUPPORT;
  4209. };
  4210. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  4211. Array.from(iterable);
  4212. });
  4213. // `Array.from` method
  4214. // https://tc39.github.io/ecma262/#sec-array.from
  4215. _export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  4216. from: arrayFrom
  4217. });
  4218. var $includes = arrayIncludes.includes;
  4219. var USES_TO_LENGTH$5 = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  4220. // `Array.prototype.includes` method
  4221. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  4222. _export({ target: 'Array', proto: true, forced: !USES_TO_LENGTH$5 }, {
  4223. includes: function includes(el /* , fromIndex = 0 */) {
  4224. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  4225. }
  4226. });
  4227. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  4228. addToUnscopables('includes');
  4229. var $map = arrayIteration.map;
  4230. var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('map');
  4231. // FF49- issue
  4232. var USES_TO_LENGTH$6 = arrayMethodUsesToLength('map');
  4233. // `Array.prototype.map` method
  4234. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  4235. // with adding support of @@species
  4236. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 || !USES_TO_LENGTH$6 }, {
  4237. map: function map(callbackfn /* , thisArg */) {
  4238. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4239. }
  4240. });
  4241. // makes subclassing work correct for wrapped built-ins
  4242. var inheritIfRequired = function ($this, dummy, Wrapper) {
  4243. var NewTarget, NewTargetPrototype;
  4244. if (
  4245. // it can work only with native `setPrototypeOf`
  4246. objectSetPrototypeOf &&
  4247. // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
  4248. typeof (NewTarget = dummy.constructor) == 'function' &&
  4249. NewTarget !== Wrapper &&
  4250. isObject(NewTargetPrototype = NewTarget.prototype) &&
  4251. NewTargetPrototype !== Wrapper.prototype
  4252. ) objectSetPrototypeOf($this, NewTargetPrototype);
  4253. return $this;
  4254. };
  4255. // a string of all valid unicode whitespaces
  4256. // eslint-disable-next-line max-len
  4257. 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';
  4258. var whitespace = '[' + whitespaces + ']';
  4259. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  4260. var rtrim = RegExp(whitespace + whitespace + '*$');
  4261. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  4262. var createMethod$3 = function (TYPE) {
  4263. return function ($this) {
  4264. var string = String(requireObjectCoercible($this));
  4265. if (TYPE & 1) string = string.replace(ltrim, '');
  4266. if (TYPE & 2) string = string.replace(rtrim, '');
  4267. return string;
  4268. };
  4269. };
  4270. var stringTrim = {
  4271. // `String.prototype.{ trimLeft, trimStart }` methods
  4272. // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
  4273. start: createMethod$3(1),
  4274. // `String.prototype.{ trimRight, trimEnd }` methods
  4275. // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
  4276. end: createMethod$3(2),
  4277. // `String.prototype.trim` method
  4278. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  4279. trim: createMethod$3(3)
  4280. };
  4281. var getOwnPropertyNames = objectGetOwnPropertyNames.f;
  4282. var getOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
  4283. var defineProperty$5 = objectDefineProperty.f;
  4284. var trim = stringTrim.trim;
  4285. var NUMBER = 'Number';
  4286. var NativeNumber = global_1[NUMBER];
  4287. var NumberPrototype = NativeNumber.prototype;
  4288. // Opera ~12 has broken Object#toString
  4289. var BROKEN_CLASSOF = classofRaw(objectCreate(NumberPrototype)) == NUMBER;
  4290. // `ToNumber` abstract operation
  4291. // https://tc39.github.io/ecma262/#sec-tonumber
  4292. var toNumber = function (argument) {
  4293. var it = toPrimitive(argument, false);
  4294. var first, third, radix, maxCode, digits, length, index, code;
  4295. if (typeof it == 'string' && it.length > 2) {
  4296. it = trim(it);
  4297. first = it.charCodeAt(0);
  4298. if (first === 43 || first === 45) {
  4299. third = it.charCodeAt(2);
  4300. if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
  4301. } else if (first === 48) {
  4302. switch (it.charCodeAt(1)) {
  4303. case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
  4304. case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
  4305. default: return +it;
  4306. }
  4307. digits = it.slice(2);
  4308. length = digits.length;
  4309. for (index = 0; index < length; index++) {
  4310. code = digits.charCodeAt(index);
  4311. // parseInt parses a string to a first unavailable symbol
  4312. // but ToNumber should return NaN if a string contains unavailable symbols
  4313. if (code < 48 || code > maxCode) return NaN;
  4314. } return parseInt(digits, radix);
  4315. }
  4316. } return +it;
  4317. };
  4318. // `Number` constructor
  4319. // https://tc39.github.io/ecma262/#sec-number-constructor
  4320. if (isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
  4321. var NumberWrapper = function Number(value) {
  4322. var it = arguments.length < 1 ? 0 : value;
  4323. var dummy = this;
  4324. return dummy instanceof NumberWrapper
  4325. // check on 1..constructor(foo) case
  4326. && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classofRaw(dummy) != NUMBER)
  4327. ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);
  4328. };
  4329. for (var keys$1 = descriptors ? getOwnPropertyNames(NativeNumber) : (
  4330. // ES3:
  4331. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  4332. // ES2015 (in case, if modules with ES2015 Number statics required before):
  4333. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  4334. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  4335. ).split(','), j = 0, key; keys$1.length > j; j++) {
  4336. if (has(NativeNumber, key = keys$1[j]) && !has(NumberWrapper, key)) {
  4337. defineProperty$5(NumberWrapper, key, getOwnPropertyDescriptor$2(NativeNumber, key));
  4338. }
  4339. }
  4340. NumberWrapper.prototype = NumberPrototype;
  4341. NumberPrototype.constructor = NumberWrapper;
  4342. redefine(global_1, NUMBER, NumberWrapper);
  4343. }
  4344. var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
  4345. // `Object.keys` method
  4346. // https://tc39.github.io/ecma262/#sec-object.keys
  4347. _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  4348. keys: function keys(it) {
  4349. return objectKeys(toObject(it));
  4350. }
  4351. });
  4352. var notARegexp = function (it) {
  4353. if (isRegexp(it)) {
  4354. throw TypeError("The method doesn't accept regular expressions");
  4355. } return it;
  4356. };
  4357. var MATCH$1 = wellKnownSymbol('match');
  4358. var correctIsRegexpLogic = function (METHOD_NAME) {
  4359. var regexp = /./;
  4360. try {
  4361. '/./'[METHOD_NAME](regexp);
  4362. } catch (e) {
  4363. try {
  4364. regexp[MATCH$1] = false;
  4365. return '/./'[METHOD_NAME](regexp);
  4366. } catch (f) { /* empty */ }
  4367. } return false;
  4368. };
  4369. // `String.prototype.includes` method
  4370. // https://tc39.github.io/ecma262/#sec-string.prototype.includes
  4371. _export({ target: 'String', proto: true, forced: !correctIsRegexpLogic('includes') }, {
  4372. includes: function includes(searchString /* , position = 0 */) {
  4373. return !!~String(requireObjectCoercible(this))
  4374. .indexOf(notARegexp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  4375. }
  4376. });
  4377. var freezing = !fails(function () {
  4378. return Object.isExtensible(Object.preventExtensions({}));
  4379. });
  4380. var internalMetadata = createCommonjsModule(function (module) {
  4381. var defineProperty = objectDefineProperty.f;
  4382. var METADATA = uid('meta');
  4383. var id = 0;
  4384. var isExtensible = Object.isExtensible || function () {
  4385. return true;
  4386. };
  4387. var setMetadata = function (it) {
  4388. defineProperty(it, METADATA, { value: {
  4389. objectID: 'O' + ++id, // object ID
  4390. weakData: {} // weak collections IDs
  4391. } });
  4392. };
  4393. var fastKey = function (it, create) {
  4394. // return a primitive with prefix
  4395. if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  4396. if (!has(it, METADATA)) {
  4397. // can't set metadata to uncaught frozen object
  4398. if (!isExtensible(it)) return 'F';
  4399. // not necessary to add metadata
  4400. if (!create) return 'E';
  4401. // add missing metadata
  4402. setMetadata(it);
  4403. // return object ID
  4404. } return it[METADATA].objectID;
  4405. };
  4406. var getWeakData = function (it, create) {
  4407. if (!has(it, METADATA)) {
  4408. // can't set metadata to uncaught frozen object
  4409. if (!isExtensible(it)) return true;
  4410. // not necessary to add metadata
  4411. if (!create) return false;
  4412. // add missing metadata
  4413. setMetadata(it);
  4414. // return the store of weak collections IDs
  4415. } return it[METADATA].weakData;
  4416. };
  4417. // add metadata on freeze-family methods calling
  4418. var onFreeze = function (it) {
  4419. if (freezing && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);
  4420. return it;
  4421. };
  4422. var meta = module.exports = {
  4423. REQUIRED: false,
  4424. fastKey: fastKey,
  4425. getWeakData: getWeakData,
  4426. onFreeze: onFreeze
  4427. };
  4428. hiddenKeys[METADATA] = true;
  4429. });
  4430. var internalMetadata_1 = internalMetadata.REQUIRED;
  4431. var internalMetadata_2 = internalMetadata.fastKey;
  4432. var internalMetadata_3 = internalMetadata.getWeakData;
  4433. var internalMetadata_4 = internalMetadata.onFreeze;
  4434. var iterate_1 = createCommonjsModule(function (module) {
  4435. var Result = function (stopped, result) {
  4436. this.stopped = stopped;
  4437. this.result = result;
  4438. };
  4439. var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
  4440. var boundFunction = functionBindContext(fn, that, AS_ENTRIES ? 2 : 1);
  4441. var iterator, iterFn, index, length, result, next, step;
  4442. if (IS_ITERATOR) {
  4443. iterator = iterable;
  4444. } else {
  4445. iterFn = getIteratorMethod(iterable);
  4446. if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
  4447. // optimisation for array iterators
  4448. if (isArrayIteratorMethod(iterFn)) {
  4449. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  4450. result = AS_ENTRIES
  4451. ? boundFunction(anObject(step = iterable[index])[0], step[1])
  4452. : boundFunction(iterable[index]);
  4453. if (result && result instanceof Result) return result;
  4454. } return new Result(false);
  4455. }
  4456. iterator = iterFn.call(iterable);
  4457. }
  4458. next = iterator.next;
  4459. while (!(step = next.call(iterator)).done) {
  4460. result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
  4461. if (typeof result == 'object' && result && result instanceof Result) return result;
  4462. } return new Result(false);
  4463. };
  4464. iterate.stop = function (result) {
  4465. return new Result(true, result);
  4466. };
  4467. });
  4468. var collection = function (CONSTRUCTOR_NAME, wrapper, common) {
  4469. var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
  4470. var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
  4471. var ADDER = IS_MAP ? 'set' : 'add';
  4472. var NativeConstructor = global_1[CONSTRUCTOR_NAME];
  4473. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  4474. var Constructor = NativeConstructor;
  4475. var exported = {};
  4476. var fixMethod = function (KEY) {
  4477. var nativeMethod = NativePrototype[KEY];
  4478. redefine(NativePrototype, KEY,
  4479. KEY == 'add' ? function add(value) {
  4480. nativeMethod.call(this, value === 0 ? 0 : value);
  4481. return this;
  4482. } : KEY == 'delete' ? function (key) {
  4483. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  4484. } : KEY == 'get' ? function get(key) {
  4485. return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);
  4486. } : KEY == 'has' ? function has(key) {
  4487. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  4488. } : function set(key, value) {
  4489. nativeMethod.call(this, key === 0 ? 0 : key, value);
  4490. return this;
  4491. }
  4492. );
  4493. };
  4494. // eslint-disable-next-line max-len
  4495. if (isForced_1(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
  4496. new NativeConstructor().entries().next();
  4497. })))) {
  4498. // create collection constructor
  4499. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  4500. internalMetadata.REQUIRED = true;
  4501. } else if (isForced_1(CONSTRUCTOR_NAME, true)) {
  4502. var instance = new Constructor();
  4503. // early implementations not supports chaining
  4504. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  4505. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  4506. var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
  4507. // most early implementations doesn't supports iterables, most modern - not close it correctly
  4508. // eslint-disable-next-line no-new
  4509. var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); });
  4510. // for early implementations -0 and +0 not the same
  4511. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  4512. // V8 ~ Chromium 42- fails only with 5+ elements
  4513. var $instance = new NativeConstructor();
  4514. var index = 5;
  4515. while (index--) $instance[ADDER](index, index);
  4516. return !$instance.has(-0);
  4517. });
  4518. if (!ACCEPT_ITERABLES) {
  4519. Constructor = wrapper(function (dummy, iterable) {
  4520. anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
  4521. var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
  4522. if (iterable != undefined) iterate_1(iterable, that[ADDER], that, IS_MAP);
  4523. return that;
  4524. });
  4525. Constructor.prototype = NativePrototype;
  4526. NativePrototype.constructor = Constructor;
  4527. }
  4528. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  4529. fixMethod('delete');
  4530. fixMethod('has');
  4531. IS_MAP && fixMethod('get');
  4532. }
  4533. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  4534. // weak collections should not contains .clear method
  4535. if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;
  4536. }
  4537. exported[CONSTRUCTOR_NAME] = Constructor;
  4538. _export({ global: true, forced: Constructor != NativeConstructor }, exported);
  4539. setToStringTag(Constructor, CONSTRUCTOR_NAME);
  4540. if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  4541. return Constructor;
  4542. };
  4543. var getWeakData = internalMetadata.getWeakData;
  4544. var setInternalState$5 = internalState.set;
  4545. var internalStateGetterFor = internalState.getterFor;
  4546. var find$1 = arrayIteration.find;
  4547. var findIndex = arrayIteration.findIndex;
  4548. var id$1 = 0;
  4549. // fallback for uncaught frozen keys
  4550. var uncaughtFrozenStore = function (store) {
  4551. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  4552. };
  4553. var UncaughtFrozenStore = function () {
  4554. this.entries = [];
  4555. };
  4556. var findUncaughtFrozen = function (store, key) {
  4557. return find$1(store.entries, function (it) {
  4558. return it[0] === key;
  4559. });
  4560. };
  4561. UncaughtFrozenStore.prototype = {
  4562. get: function (key) {
  4563. var entry = findUncaughtFrozen(this, key);
  4564. if (entry) return entry[1];
  4565. },
  4566. has: function (key) {
  4567. return !!findUncaughtFrozen(this, key);
  4568. },
  4569. set: function (key, value) {
  4570. var entry = findUncaughtFrozen(this, key);
  4571. if (entry) entry[1] = value;
  4572. else this.entries.push([key, value]);
  4573. },
  4574. 'delete': function (key) {
  4575. var index = findIndex(this.entries, function (it) {
  4576. return it[0] === key;
  4577. });
  4578. if (~index) this.entries.splice(index, 1);
  4579. return !!~index;
  4580. }
  4581. };
  4582. var collectionWeak = {
  4583. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  4584. var C = wrapper(function (that, iterable) {
  4585. anInstance(that, C, CONSTRUCTOR_NAME);
  4586. setInternalState$5(that, {
  4587. type: CONSTRUCTOR_NAME,
  4588. id: id$1++,
  4589. frozen: undefined
  4590. });
  4591. if (iterable != undefined) iterate_1(iterable, that[ADDER], that, IS_MAP);
  4592. });
  4593. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  4594. var define = function (that, key, value) {
  4595. var state = getInternalState(that);
  4596. var data = getWeakData(anObject(key), true);
  4597. if (data === true) uncaughtFrozenStore(state).set(key, value);
  4598. else data[state.id] = value;
  4599. return that;
  4600. };
  4601. redefineAll(C.prototype, {
  4602. // 23.3.3.2 WeakMap.prototype.delete(key)
  4603. // 23.4.3.3 WeakSet.prototype.delete(value)
  4604. 'delete': function (key) {
  4605. var state = getInternalState(this);
  4606. if (!isObject(key)) return false;
  4607. var data = getWeakData(key);
  4608. if (data === true) return uncaughtFrozenStore(state)['delete'](key);
  4609. return data && has(data, state.id) && delete data[state.id];
  4610. },
  4611. // 23.3.3.4 WeakMap.prototype.has(key)
  4612. // 23.4.3.4 WeakSet.prototype.has(value)
  4613. has: function has$1(key) {
  4614. var state = getInternalState(this);
  4615. if (!isObject(key)) return false;
  4616. var data = getWeakData(key);
  4617. if (data === true) return uncaughtFrozenStore(state).has(key);
  4618. return data && has(data, state.id);
  4619. }
  4620. });
  4621. redefineAll(C.prototype, IS_MAP ? {
  4622. // 23.3.3.3 WeakMap.prototype.get(key)
  4623. get: function get(key) {
  4624. var state = getInternalState(this);
  4625. if (isObject(key)) {
  4626. var data = getWeakData(key);
  4627. if (data === true) return uncaughtFrozenStore(state).get(key);
  4628. return data ? data[state.id] : undefined;
  4629. }
  4630. },
  4631. // 23.3.3.5 WeakMap.prototype.set(key, value)
  4632. set: function set(key, value) {
  4633. return define(this, key, value);
  4634. }
  4635. } : {
  4636. // 23.4.3.1 WeakSet.prototype.add(value)
  4637. add: function add(value) {
  4638. return define(this, value, true);
  4639. }
  4640. });
  4641. return C;
  4642. }
  4643. };
  4644. var es_weakMap = createCommonjsModule(function (module) {
  4645. var enforceIternalState = internalState.enforce;
  4646. var IS_IE11 = !global_1.ActiveXObject && 'ActiveXObject' in global_1;
  4647. var isExtensible = Object.isExtensible;
  4648. var InternalWeakMap;
  4649. var wrapper = function (init) {
  4650. return function WeakMap() {
  4651. return init(this, arguments.length ? arguments[0] : undefined);
  4652. };
  4653. };
  4654. // `WeakMap` constructor
  4655. // https://tc39.github.io/ecma262/#sec-weakmap-constructor
  4656. var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak);
  4657. // IE11 WeakMap frozen keys fix
  4658. // We can't use feature detection because it crash some old IE builds
  4659. // https://github.com/zloirock/core-js/issues/485
  4660. if (nativeWeakMap && IS_IE11) {
  4661. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  4662. internalMetadata.REQUIRED = true;
  4663. var WeakMapPrototype = $WeakMap.prototype;
  4664. var nativeDelete = WeakMapPrototype['delete'];
  4665. var nativeHas = WeakMapPrototype.has;
  4666. var nativeGet = WeakMapPrototype.get;
  4667. var nativeSet = WeakMapPrototype.set;
  4668. redefineAll(WeakMapPrototype, {
  4669. 'delete': function (key) {
  4670. if (isObject(key) && !isExtensible(key)) {
  4671. var state = enforceIternalState(this);
  4672. if (!state.frozen) state.frozen = new InternalWeakMap();
  4673. return nativeDelete.call(this, key) || state.frozen['delete'](key);
  4674. } return nativeDelete.call(this, key);
  4675. },
  4676. has: function has(key) {
  4677. if (isObject(key) && !isExtensible(key)) {
  4678. var state = enforceIternalState(this);
  4679. if (!state.frozen) state.frozen = new InternalWeakMap();
  4680. return nativeHas.call(this, key) || state.frozen.has(key);
  4681. } return nativeHas.call(this, key);
  4682. },
  4683. get: function get(key) {
  4684. if (isObject(key) && !isExtensible(key)) {
  4685. var state = enforceIternalState(this);
  4686. if (!state.frozen) state.frozen = new InternalWeakMap();
  4687. return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
  4688. } return nativeGet.call(this, key);
  4689. },
  4690. set: function set(key, value) {
  4691. if (isObject(key) && !isExtensible(key)) {
  4692. var state = enforceIternalState(this);
  4693. if (!state.frozen) state.frozen = new InternalWeakMap();
  4694. nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
  4695. } else nativeSet.call(this, key, value);
  4696. return this;
  4697. }
  4698. });
  4699. }
  4700. });
  4701. var $every = arrayIteration.every;
  4702. var STRICT_METHOD$3 = arrayMethodIsStrict('every');
  4703. var USES_TO_LENGTH$7 = arrayMethodUsesToLength('every');
  4704. // `Array.prototype.every` method
  4705. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  4706. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$3 || !USES_TO_LENGTH$7 }, {
  4707. every: function every(callbackfn /* , thisArg */) {
  4708. return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4709. }
  4710. });
  4711. // `Object.assign` method
  4712. // https://tc39.github.io/ecma262/#sec-object.assign
  4713. _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, {
  4714. assign: objectAssign
  4715. });
  4716. var non = '\u200B\u0085\u180E';
  4717. // check that a method works with the correct list
  4718. // of whitespaces and has a correct name
  4719. var stringTrimForced = function (METHOD_NAME) {
  4720. return fails(function () {
  4721. return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
  4722. });
  4723. };
  4724. var $trim = stringTrim.trim;
  4725. // `String.prototype.trim` method
  4726. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  4727. _export({ target: 'String', proto: true, forced: stringTrimForced('trim') }, {
  4728. trim: function trim() {
  4729. return $trim(this);
  4730. }
  4731. });
  4732. var $some = arrayIteration.some;
  4733. var STRICT_METHOD$4 = arrayMethodIsStrict('some');
  4734. var USES_TO_LENGTH$8 = arrayMethodUsesToLength('some');
  4735. // `Array.prototype.some` method
  4736. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  4737. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$4 || !USES_TO_LENGTH$8 }, {
  4738. some: function some(callbackfn /* , thisArg */) {
  4739. return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  4740. }
  4741. });
  4742. // `thisNumberValue` abstract operation
  4743. // https://tc39.github.io/ecma262/#sec-thisnumbervalue
  4744. var thisNumberValue = function (value) {
  4745. if (typeof value != 'number' && classofRaw(value) != 'Number') {
  4746. throw TypeError('Incorrect invocation');
  4747. }
  4748. return +value;
  4749. };
  4750. // `String.prototype.repeat` method implementation
  4751. // https://tc39.github.io/ecma262/#sec-string.prototype.repeat
  4752. var stringRepeat = ''.repeat || function repeat(count) {
  4753. var str = String(requireObjectCoercible(this));
  4754. var result = '';
  4755. var n = toInteger(count);
  4756. if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
  4757. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
  4758. return result;
  4759. };
  4760. var nativeToFixed = 1.0.toFixed;
  4761. var floor$4 = Math.floor;
  4762. var pow$1 = function (x, n, acc) {
  4763. return n === 0 ? acc : n % 2 === 1 ? pow$1(x, n - 1, acc * x) : pow$1(x * x, n / 2, acc);
  4764. };
  4765. var log = function (x) {
  4766. var n = 0;
  4767. var x2 = x;
  4768. while (x2 >= 4096) {
  4769. n += 12;
  4770. x2 /= 4096;
  4771. }
  4772. while (x2 >= 2) {
  4773. n += 1;
  4774. x2 /= 2;
  4775. } return n;
  4776. };
  4777. var FORCED$1 = nativeToFixed && (
  4778. 0.00008.toFixed(3) !== '0.000' ||
  4779. 0.9.toFixed(0) !== '1' ||
  4780. 1.255.toFixed(2) !== '1.25' ||
  4781. 1000000000000000128.0.toFixed(0) !== '1000000000000000128'
  4782. ) || !fails(function () {
  4783. // V8 ~ Android 4.3-
  4784. nativeToFixed.call({});
  4785. });
  4786. // `Number.prototype.toFixed` method
  4787. // https://tc39.github.io/ecma262/#sec-number.prototype.tofixed
  4788. _export({ target: 'Number', proto: true, forced: FORCED$1 }, {
  4789. // eslint-disable-next-line max-statements
  4790. toFixed: function toFixed(fractionDigits) {
  4791. var number = thisNumberValue(this);
  4792. var fractDigits = toInteger(fractionDigits);
  4793. var data = [0, 0, 0, 0, 0, 0];
  4794. var sign = '';
  4795. var result = '0';
  4796. var e, z, j, k;
  4797. var multiply = function (n, c) {
  4798. var index = -1;
  4799. var c2 = c;
  4800. while (++index < 6) {
  4801. c2 += n * data[index];
  4802. data[index] = c2 % 1e7;
  4803. c2 = floor$4(c2 / 1e7);
  4804. }
  4805. };
  4806. var divide = function (n) {
  4807. var index = 6;
  4808. var c = 0;
  4809. while (--index >= 0) {
  4810. c += data[index];
  4811. data[index] = floor$4(c / n);
  4812. c = (c % n) * 1e7;
  4813. }
  4814. };
  4815. var dataToString = function () {
  4816. var index = 6;
  4817. var s = '';
  4818. while (--index >= 0) {
  4819. if (s !== '' || index === 0 || data[index] !== 0) {
  4820. var t = String(data[index]);
  4821. s = s === '' ? t : s + stringRepeat.call('0', 7 - t.length) + t;
  4822. }
  4823. } return s;
  4824. };
  4825. if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits');
  4826. // eslint-disable-next-line no-self-compare
  4827. if (number != number) return 'NaN';
  4828. if (number <= -1e21 || number >= 1e21) return String(number);
  4829. if (number < 0) {
  4830. sign = '-';
  4831. number = -number;
  4832. }
  4833. if (number > 1e-21) {
  4834. e = log(number * pow$1(2, 69, 1)) - 69;
  4835. z = e < 0 ? number * pow$1(2, -e, 1) : number / pow$1(2, e, 1);
  4836. z *= 0x10000000000000;
  4837. e = 52 - e;
  4838. if (e > 0) {
  4839. multiply(0, z);
  4840. j = fractDigits;
  4841. while (j >= 7) {
  4842. multiply(1e7, 0);
  4843. j -= 7;
  4844. }
  4845. multiply(pow$1(10, j, 1), 0);
  4846. j = e - 1;
  4847. while (j >= 23) {
  4848. divide(1 << 23);
  4849. j -= 23;
  4850. }
  4851. divide(1 << j);
  4852. multiply(1, 1);
  4853. divide(2);
  4854. result = dataToString();
  4855. } else {
  4856. multiply(0, z);
  4857. multiply(1 << -e, 0);
  4858. result = dataToString() + stringRepeat.call('0', fractDigits);
  4859. }
  4860. }
  4861. if (fractDigits > 0) {
  4862. k = result.length;
  4863. result = sign + (k <= fractDigits
  4864. ? '0.' + stringRepeat.call('0', fractDigits - k) + result
  4865. : result.slice(0, k - fractDigits) + '.' + result.slice(k - fractDigits));
  4866. } else {
  4867. result = sign + result;
  4868. } return result;
  4869. }
  4870. });
  4871. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  4872. // `Object.{ entries, values }` methods implementation
  4873. var createMethod$4 = function (TO_ENTRIES) {
  4874. return function (it) {
  4875. var O = toIndexedObject(it);
  4876. var keys = objectKeys(O);
  4877. var length = keys.length;
  4878. var i = 0;
  4879. var result = [];
  4880. var key;
  4881. while (length > i) {
  4882. key = keys[i++];
  4883. if (!descriptors || propertyIsEnumerable.call(O, key)) {
  4884. result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
  4885. }
  4886. }
  4887. return result;
  4888. };
  4889. };
  4890. var objectToArray = {
  4891. // `Object.entries` method
  4892. // https://tc39.github.io/ecma262/#sec-object.entries
  4893. entries: createMethod$4(true),
  4894. // `Object.values` method
  4895. // https://tc39.github.io/ecma262/#sec-object.values
  4896. values: createMethod$4(false)
  4897. };
  4898. var $entries = objectToArray.entries;
  4899. // `Object.entries` method
  4900. // https://tc39.github.io/ecma262/#sec-object.entries
  4901. _export({ target: 'Object', stat: true }, {
  4902. entries: function entries(O) {
  4903. return $entries(O);
  4904. }
  4905. });
  4906. var $values = objectToArray.values;
  4907. // `Object.values` method
  4908. // https://tc39.github.io/ecma262/#sec-object.values
  4909. _export({ target: 'Object', stat: true }, {
  4910. values: function values(O) {
  4911. return $values(O);
  4912. }
  4913. });
  4914. // `Number.isNaN` method
  4915. // https://tc39.github.io/ecma262/#sec-number.isnan
  4916. _export({ target: 'Number', stat: true }, {
  4917. isNaN: function isNaN(number) {
  4918. // eslint-disable-next-line no-self-compare
  4919. return number != number;
  4920. }
  4921. });
  4922. var nativeGetOwnPropertyDescriptor$2 = objectGetOwnPropertyDescriptor.f;
  4923. var FAILS_ON_PRIMITIVES$1 = fails(function () { nativeGetOwnPropertyDescriptor$2(1); });
  4924. var FORCED$2 = !descriptors || FAILS_ON_PRIMITIVES$1;
  4925. // `Object.getOwnPropertyDescriptor` method
  4926. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  4927. _export({ target: 'Object', stat: true, forced: FORCED$2, sham: !descriptors }, {
  4928. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
  4929. return nativeGetOwnPropertyDescriptor$2(toIndexedObject(it), key);
  4930. }
  4931. });
  4932. // `Object.getOwnPropertyDescriptors` method
  4933. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  4934. _export({ target: 'Object', stat: true, sham: !descriptors }, {
  4935. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
  4936. var O = toIndexedObject(object);
  4937. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  4938. var keys = ownKeys(O);
  4939. var result = {};
  4940. var index = 0;
  4941. var key, descriptor;
  4942. while (keys.length > index) {
  4943. descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
  4944. if (descriptor !== undefined) createProperty(result, key, descriptor);
  4945. }
  4946. return result;
  4947. }
  4948. });
  4949. // @@match logic
  4950. fixRegexpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
  4951. return [
  4952. // `String.prototype.match` method
  4953. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  4954. function match(regexp) {
  4955. var O = requireObjectCoercible(this);
  4956. var matcher = regexp == undefined ? undefined : regexp[MATCH];
  4957. return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  4958. },
  4959. // `RegExp.prototype[@@match]` method
  4960. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  4961. function (regexp) {
  4962. var res = maybeCallNative(nativeMatch, regexp, this);
  4963. if (res.done) return res.value;
  4964. var rx = anObject(regexp);
  4965. var S = String(this);
  4966. if (!rx.global) return regexpExecAbstract(rx, S);
  4967. var fullUnicode = rx.unicode;
  4968. rx.lastIndex = 0;
  4969. var A = [];
  4970. var n = 0;
  4971. var result;
  4972. while ((result = regexpExecAbstract(rx, S)) !== null) {
  4973. var matchStr = String(result[0]);
  4974. A[n] = matchStr;
  4975. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  4976. n++;
  4977. }
  4978. return n === 0 ? null : A;
  4979. }
  4980. ];
  4981. });
  4982. function _classCallCheck$1(e, t) {
  4983. if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
  4984. }
  4985. function _defineProperties$1(e, t) {
  4986. for (var n = 0; n < t.length; n++) {
  4987. var r = t[n];
  4988. r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
  4989. }
  4990. }
  4991. function _createClass$1(e, t, n) {
  4992. return t && _defineProperties$1(e.prototype, t), n && _defineProperties$1(e, n), e;
  4993. }
  4994. function _defineProperty$1(e, t, n) {
  4995. return t in e ? Object.defineProperty(e, t, {
  4996. value: n,
  4997. enumerable: !0,
  4998. configurable: !0,
  4999. writable: !0
  5000. }) : e[t] = n, e;
  5001. }
  5002. function ownKeys$2(e, t) {
  5003. var n = Object.keys(e);
  5004. if (Object.getOwnPropertySymbols) {
  5005. var r = Object.getOwnPropertySymbols(e);
  5006. t && (r = r.filter(function (t) {
  5007. return Object.getOwnPropertyDescriptor(e, t).enumerable;
  5008. })), n.push.apply(n, r);
  5009. }
  5010. return n;
  5011. }
  5012. function _objectSpread2$1(e) {
  5013. for (var t = 1; t < arguments.length; t++) {
  5014. var n = null != arguments[t] ? arguments[t] : {};
  5015. t % 2 ? ownKeys$2(Object(n), !0).forEach(function (t) {
  5016. _defineProperty$1(e, t, n[t]);
  5017. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : ownKeys$2(Object(n)).forEach(function (t) {
  5018. Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
  5019. });
  5020. }
  5021. return e;
  5022. }
  5023. var defaults = {
  5024. addCSS: !0,
  5025. thumbWidth: 15,
  5026. watch: !0
  5027. };
  5028. function matches(e, t) {
  5029. return function () {
  5030. return Array.from(document.querySelectorAll(t)).includes(this);
  5031. }.call(e, t);
  5032. }
  5033. function trigger(e, t) {
  5034. if (e && t) {
  5035. var n = new Event(t, {
  5036. bubbles: !0
  5037. });
  5038. e.dispatchEvent(n);
  5039. }
  5040. }
  5041. var getConstructor = function getConstructor(e) {
  5042. return null != e ? e.constructor : null;
  5043. },
  5044. instanceOf = function instanceOf(e, t) {
  5045. return !!(e && t && e instanceof t);
  5046. },
  5047. isNullOrUndefined = function isNullOrUndefined(e) {
  5048. return null == e;
  5049. },
  5050. isObject$1 = function isObject(e) {
  5051. return getConstructor(e) === Object;
  5052. },
  5053. isNumber = function isNumber(e) {
  5054. return getConstructor(e) === Number && !Number.isNaN(e);
  5055. },
  5056. isString = function isString(e) {
  5057. return getConstructor(e) === String;
  5058. },
  5059. isBoolean = function isBoolean(e) {
  5060. return getConstructor(e) === Boolean;
  5061. },
  5062. isFunction = function isFunction(e) {
  5063. return getConstructor(e) === Function;
  5064. },
  5065. isArray$1 = function isArray(e) {
  5066. return Array.isArray(e);
  5067. },
  5068. isNodeList = function isNodeList(e) {
  5069. return instanceOf(e, NodeList);
  5070. },
  5071. isElement = function isElement(e) {
  5072. return instanceOf(e, Element);
  5073. },
  5074. isEvent = function isEvent(e) {
  5075. return instanceOf(e, Event);
  5076. },
  5077. isEmpty = function isEmpty(e) {
  5078. return isNullOrUndefined(e) || (isString(e) || isArray$1(e) || isNodeList(e)) && !e.length || isObject$1(e) && !Object.keys(e).length;
  5079. },
  5080. is = {
  5081. nullOrUndefined: isNullOrUndefined,
  5082. object: isObject$1,
  5083. number: isNumber,
  5084. string: isString,
  5085. boolean: isBoolean,
  5086. function: isFunction,
  5087. array: isArray$1,
  5088. nodeList: isNodeList,
  5089. element: isElement,
  5090. event: isEvent,
  5091. empty: isEmpty
  5092. };
  5093. function getDecimalPlaces(e) {
  5094. var t = "".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
  5095. return t ? Math.max(0, (t[1] ? t[1].length : 0) - (t[2] ? +t[2] : 0)) : 0;
  5096. }
  5097. function round(e, t) {
  5098. if (1 > t) {
  5099. var n = getDecimalPlaces(t);
  5100. return parseFloat(e.toFixed(n));
  5101. }
  5102. return Math.round(e / t) * t;
  5103. }
  5104. var RangeTouch = function () {
  5105. function e(t, n) {
  5106. _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());
  5107. }
  5108. return _createClass$1(e, [{
  5109. key: "init",
  5110. value: function value() {
  5111. 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);
  5112. }
  5113. }, {
  5114. key: "destroy",
  5115. value: function value() {
  5116. e.enabled && (this.config.addCSS && (this.element.style.userSelect = "", this.element.style.webKitUserSelect = "", this.element.style.touchAction = ""), this.listeners(!1), this.element.rangeTouch = null);
  5117. }
  5118. }, {
  5119. key: "listeners",
  5120. value: function value(e) {
  5121. var t = this,
  5122. n = e ? "addEventListener" : "removeEventListener";
  5123. ["touchstart", "touchmove", "touchend"].forEach(function (e) {
  5124. t.element[n](e, function (e) {
  5125. return t.set(e);
  5126. }, !1);
  5127. });
  5128. }
  5129. }, {
  5130. key: "get",
  5131. value: function value(t) {
  5132. if (!e.enabled || !is.event(t)) return null;
  5133. var n,
  5134. r = t.target,
  5135. i = t.changedTouches[0],
  5136. o = parseFloat(r.getAttribute("min")) || 0,
  5137. s = parseFloat(r.getAttribute("max")) || 100,
  5138. u = parseFloat(r.getAttribute("step")) || 1,
  5139. c = r.getBoundingClientRect(),
  5140. a = 100 / c.width * (this.config.thumbWidth / 2) / 100;
  5141. 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);
  5142. }
  5143. }, {
  5144. key: "set",
  5145. value: function value(t) {
  5146. e.enabled && is.event(t) && !t.target.disabled && (t.preventDefault(), t.target.value = this.get(t), trigger(t.target, "touchend" === t.type ? "change" : "input"));
  5147. }
  5148. }], [{
  5149. key: "setup",
  5150. value: function value(t) {
  5151. var n = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {},
  5152. r = null;
  5153. 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;
  5154. var i = _objectSpread2$1({}, defaults, {}, n);
  5155. if (is.string(t) && i.watch) {
  5156. var o = new MutationObserver(function (n) {
  5157. Array.from(n).forEach(function (n) {
  5158. Array.from(n.addedNodes).forEach(function (n) {
  5159. is.element(n) && matches(n, t) && new e(n, i);
  5160. });
  5161. });
  5162. });
  5163. o.observe(document.body, {
  5164. childList: !0,
  5165. subtree: !0
  5166. });
  5167. }
  5168. return r.map(function (t) {
  5169. return new e(t, n);
  5170. });
  5171. }
  5172. }, {
  5173. key: "enabled",
  5174. get: function get() {
  5175. return "ontouchstart" in document.documentElement;
  5176. }
  5177. }]), e;
  5178. }();
  5179. var nativePromiseConstructor = global_1.Promise;
  5180. var SPECIES$5 = wellKnownSymbol('species');
  5181. var setSpecies = function (CONSTRUCTOR_NAME) {
  5182. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  5183. var defineProperty = objectDefineProperty.f;
  5184. if (descriptors && Constructor && !Constructor[SPECIES$5]) {
  5185. defineProperty(Constructor, SPECIES$5, {
  5186. configurable: true,
  5187. get: function () { return this; }
  5188. });
  5189. }
  5190. };
  5191. var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(engineUserAgent);
  5192. var location = global_1.location;
  5193. var set$1 = global_1.setImmediate;
  5194. var clear = global_1.clearImmediate;
  5195. var process$1 = global_1.process;
  5196. var MessageChannel = global_1.MessageChannel;
  5197. var Dispatch = global_1.Dispatch;
  5198. var counter = 0;
  5199. var queue = {};
  5200. var ONREADYSTATECHANGE = 'onreadystatechange';
  5201. var defer, channel, port;
  5202. var run = function (id) {
  5203. // eslint-disable-next-line no-prototype-builtins
  5204. if (queue.hasOwnProperty(id)) {
  5205. var fn = queue[id];
  5206. delete queue[id];
  5207. fn();
  5208. }
  5209. };
  5210. var runner = function (id) {
  5211. return function () {
  5212. run(id);
  5213. };
  5214. };
  5215. var listener = function (event) {
  5216. run(event.data);
  5217. };
  5218. var post = function (id) {
  5219. // old engines have not location.origin
  5220. global_1.postMessage(id + '', location.protocol + '//' + location.host);
  5221. };
  5222. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  5223. if (!set$1 || !clear) {
  5224. set$1 = function setImmediate(fn) {
  5225. var args = [];
  5226. var i = 1;
  5227. while (arguments.length > i) args.push(arguments[i++]);
  5228. queue[++counter] = function () {
  5229. // eslint-disable-next-line no-new-func
  5230. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  5231. };
  5232. defer(counter);
  5233. return counter;
  5234. };
  5235. clear = function clearImmediate(id) {
  5236. delete queue[id];
  5237. };
  5238. // Node.js 0.8-
  5239. if (classofRaw(process$1) == 'process') {
  5240. defer = function (id) {
  5241. process$1.nextTick(runner(id));
  5242. };
  5243. // Sphere (JS game engine) Dispatch API
  5244. } else if (Dispatch && Dispatch.now) {
  5245. defer = function (id) {
  5246. Dispatch.now(runner(id));
  5247. };
  5248. // Browsers with MessageChannel, includes WebWorkers
  5249. // except iOS - https://github.com/zloirock/core-js/issues/624
  5250. } else if (MessageChannel && !engineIsIos) {
  5251. channel = new MessageChannel();
  5252. port = channel.port2;
  5253. channel.port1.onmessage = listener;
  5254. defer = functionBindContext(port.postMessage, port, 1);
  5255. // Browsers with postMessage, skip WebWorkers
  5256. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  5257. } else if (
  5258. global_1.addEventListener &&
  5259. typeof postMessage == 'function' &&
  5260. !global_1.importScripts &&
  5261. !fails(post) &&
  5262. location.protocol !== 'file:'
  5263. ) {
  5264. defer = post;
  5265. global_1.addEventListener('message', listener, false);
  5266. // IE8-
  5267. } else if (ONREADYSTATECHANGE in documentCreateElement('script')) {
  5268. defer = function (id) {
  5269. html.appendChild(documentCreateElement('script'))[ONREADYSTATECHANGE] = function () {
  5270. html.removeChild(this);
  5271. run(id);
  5272. };
  5273. };
  5274. // Rest old browsers
  5275. } else {
  5276. defer = function (id) {
  5277. setTimeout(runner(id), 0);
  5278. };
  5279. }
  5280. }
  5281. var task = {
  5282. set: set$1,
  5283. clear: clear
  5284. };
  5285. var getOwnPropertyDescriptor$3 = objectGetOwnPropertyDescriptor.f;
  5286. var macrotask = task.set;
  5287. var MutationObserver$1 = global_1.MutationObserver || global_1.WebKitMutationObserver;
  5288. var process$2 = global_1.process;
  5289. var Promise$1 = global_1.Promise;
  5290. var IS_NODE = classofRaw(process$2) == 'process';
  5291. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  5292. var queueMicrotaskDescriptor = getOwnPropertyDescriptor$3(global_1, 'queueMicrotask');
  5293. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  5294. var flush, head, last, notify, toggle, node, promise, then;
  5295. // modern engines have queueMicrotask method
  5296. if (!queueMicrotask) {
  5297. flush = function () {
  5298. var parent, fn;
  5299. if (IS_NODE && (parent = process$2.domain)) parent.exit();
  5300. while (head) {
  5301. fn = head.fn;
  5302. head = head.next;
  5303. try {
  5304. fn();
  5305. } catch (error) {
  5306. if (head) notify();
  5307. else last = undefined;
  5308. throw error;
  5309. }
  5310. } last = undefined;
  5311. if (parent) parent.enter();
  5312. };
  5313. // Node.js
  5314. if (IS_NODE) {
  5315. notify = function () {
  5316. process$2.nextTick(flush);
  5317. };
  5318. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  5319. } else if (MutationObserver$1 && !engineIsIos) {
  5320. toggle = true;
  5321. node = document.createTextNode('');
  5322. new MutationObserver$1(flush).observe(node, { characterData: true });
  5323. notify = function () {
  5324. node.data = toggle = !toggle;
  5325. };
  5326. // environments with maybe non-completely correct, but existent Promise
  5327. } else if (Promise$1 && Promise$1.resolve) {
  5328. // Promise.resolve without an argument throws an error in LG WebOS 2
  5329. promise = Promise$1.resolve(undefined);
  5330. then = promise.then;
  5331. notify = function () {
  5332. then.call(promise, flush);
  5333. };
  5334. // for other environments - macrotask based on:
  5335. // - setImmediate
  5336. // - MessageChannel
  5337. // - window.postMessag
  5338. // - onreadystatechange
  5339. // - setTimeout
  5340. } else {
  5341. notify = function () {
  5342. // strange IE + webpack dev server bug - use .call(global)
  5343. macrotask.call(global_1, flush);
  5344. };
  5345. }
  5346. }
  5347. var microtask = queueMicrotask || function (fn) {
  5348. var task = { fn: fn, next: undefined };
  5349. if (last) last.next = task;
  5350. if (!head) {
  5351. head = task;
  5352. notify();
  5353. } last = task;
  5354. };
  5355. var PromiseCapability = function (C) {
  5356. var resolve, reject;
  5357. this.promise = new C(function ($$resolve, $$reject) {
  5358. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  5359. resolve = $$resolve;
  5360. reject = $$reject;
  5361. });
  5362. this.resolve = aFunction$1(resolve);
  5363. this.reject = aFunction$1(reject);
  5364. };
  5365. // 25.4.1.5 NewPromiseCapability(C)
  5366. var f$7 = function (C) {
  5367. return new PromiseCapability(C);
  5368. };
  5369. var newPromiseCapability = {
  5370. f: f$7
  5371. };
  5372. var promiseResolve = function (C, x) {
  5373. anObject(C);
  5374. if (isObject(x) && x.constructor === C) return x;
  5375. var promiseCapability = newPromiseCapability.f(C);
  5376. var resolve = promiseCapability.resolve;
  5377. resolve(x);
  5378. return promiseCapability.promise;
  5379. };
  5380. var hostReportErrors = function (a, b) {
  5381. var console = global_1.console;
  5382. if (console && console.error) {
  5383. arguments.length === 1 ? console.error(a) : console.error(a, b);
  5384. }
  5385. };
  5386. var perform = function (exec) {
  5387. try {
  5388. return { error: false, value: exec() };
  5389. } catch (error) {
  5390. return { error: true, value: error };
  5391. }
  5392. };
  5393. var task$1 = task.set;
  5394. var SPECIES$6 = wellKnownSymbol('species');
  5395. var PROMISE = 'Promise';
  5396. var getInternalState$3 = internalState.get;
  5397. var setInternalState$6 = internalState.set;
  5398. var getInternalPromiseState = internalState.getterFor(PROMISE);
  5399. var PromiseConstructor = nativePromiseConstructor;
  5400. var TypeError$1 = global_1.TypeError;
  5401. var document$2 = global_1.document;
  5402. var process$3 = global_1.process;
  5403. var $fetch$1 = getBuiltIn('fetch');
  5404. var newPromiseCapability$1 = newPromiseCapability.f;
  5405. var newGenericPromiseCapability = newPromiseCapability$1;
  5406. var IS_NODE$1 = classofRaw(process$3) == 'process';
  5407. var DISPATCH_EVENT = !!(document$2 && document$2.createEvent && global_1.dispatchEvent);
  5408. var UNHANDLED_REJECTION = 'unhandledrejection';
  5409. var REJECTION_HANDLED = 'rejectionhandled';
  5410. var PENDING = 0;
  5411. var FULFILLED = 1;
  5412. var REJECTED = 2;
  5413. var HANDLED = 1;
  5414. var UNHANDLED = 2;
  5415. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  5416. var FORCED$3 = isForced_1(PROMISE, function () {
  5417. var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
  5418. if (!GLOBAL_CORE_JS_PROMISE) {
  5419. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  5420. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  5421. // We can't detect it synchronously, so just check versions
  5422. if (engineV8Version === 66) return true;
  5423. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  5424. if (!IS_NODE$1 && typeof PromiseRejectionEvent != 'function') return true;
  5425. }
  5426. // We can't use @@species feature detection in V8 since it causes
  5427. // deoptimization and performance degradation
  5428. // https://github.com/zloirock/core-js/issues/679
  5429. if (engineV8Version >= 51 && /native code/.test(PromiseConstructor)) return false;
  5430. // Detect correctness of subclassing with @@species support
  5431. var promise = PromiseConstructor.resolve(1);
  5432. var FakePromise = function (exec) {
  5433. exec(function () { /* empty */ }, function () { /* empty */ });
  5434. };
  5435. var constructor = promise.constructor = {};
  5436. constructor[SPECIES$6] = FakePromise;
  5437. return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
  5438. });
  5439. var INCORRECT_ITERATION$1 = FORCED$3 || !checkCorrectnessOfIteration(function (iterable) {
  5440. PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
  5441. });
  5442. // helpers
  5443. var isThenable = function (it) {
  5444. var then;
  5445. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  5446. };
  5447. var notify$1 = function (promise, state, isReject) {
  5448. if (state.notified) return;
  5449. state.notified = true;
  5450. var chain = state.reactions;
  5451. microtask(function () {
  5452. var value = state.value;
  5453. var ok = state.state == FULFILLED;
  5454. var index = 0;
  5455. // variable length - can't use forEach
  5456. while (chain.length > index) {
  5457. var reaction = chain[index++];
  5458. var handler = ok ? reaction.ok : reaction.fail;
  5459. var resolve = reaction.resolve;
  5460. var reject = reaction.reject;
  5461. var domain = reaction.domain;
  5462. var result, then, exited;
  5463. try {
  5464. if (handler) {
  5465. if (!ok) {
  5466. if (state.rejection === UNHANDLED) onHandleUnhandled(promise, state);
  5467. state.rejection = HANDLED;
  5468. }
  5469. if (handler === true) result = value;
  5470. else {
  5471. if (domain) domain.enter();
  5472. result = handler(value); // can throw
  5473. if (domain) {
  5474. domain.exit();
  5475. exited = true;
  5476. }
  5477. }
  5478. if (result === reaction.promise) {
  5479. reject(TypeError$1('Promise-chain cycle'));
  5480. } else if (then = isThenable(result)) {
  5481. then.call(result, resolve, reject);
  5482. } else resolve(result);
  5483. } else reject(value);
  5484. } catch (error) {
  5485. if (domain && !exited) domain.exit();
  5486. reject(error);
  5487. }
  5488. }
  5489. state.reactions = [];
  5490. state.notified = false;
  5491. if (isReject && !state.rejection) onUnhandled(promise, state);
  5492. });
  5493. };
  5494. var dispatchEvent = function (name, promise, reason) {
  5495. var event, handler;
  5496. if (DISPATCH_EVENT) {
  5497. event = document$2.createEvent('Event');
  5498. event.promise = promise;
  5499. event.reason = reason;
  5500. event.initEvent(name, false, true);
  5501. global_1.dispatchEvent(event);
  5502. } else event = { promise: promise, reason: reason };
  5503. if (handler = global_1['on' + name]) handler(event);
  5504. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  5505. };
  5506. var onUnhandled = function (promise, state) {
  5507. task$1.call(global_1, function () {
  5508. var value = state.value;
  5509. var IS_UNHANDLED = isUnhandled(state);
  5510. var result;
  5511. if (IS_UNHANDLED) {
  5512. result = perform(function () {
  5513. if (IS_NODE$1) {
  5514. process$3.emit('unhandledRejection', value, promise);
  5515. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  5516. });
  5517. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  5518. state.rejection = IS_NODE$1 || isUnhandled(state) ? UNHANDLED : HANDLED;
  5519. if (result.error) throw result.value;
  5520. }
  5521. });
  5522. };
  5523. var isUnhandled = function (state) {
  5524. return state.rejection !== HANDLED && !state.parent;
  5525. };
  5526. var onHandleUnhandled = function (promise, state) {
  5527. task$1.call(global_1, function () {
  5528. if (IS_NODE$1) {
  5529. process$3.emit('rejectionHandled', promise);
  5530. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  5531. });
  5532. };
  5533. var bind = function (fn, promise, state, unwrap) {
  5534. return function (value) {
  5535. fn(promise, state, value, unwrap);
  5536. };
  5537. };
  5538. var internalReject = function (promise, state, value, unwrap) {
  5539. if (state.done) return;
  5540. state.done = true;
  5541. if (unwrap) state = unwrap;
  5542. state.value = value;
  5543. state.state = REJECTED;
  5544. notify$1(promise, state, true);
  5545. };
  5546. var internalResolve = function (promise, state, value, unwrap) {
  5547. if (state.done) return;
  5548. state.done = true;
  5549. if (unwrap) state = unwrap;
  5550. try {
  5551. if (promise === value) throw TypeError$1("Promise can't be resolved itself");
  5552. var then = isThenable(value);
  5553. if (then) {
  5554. microtask(function () {
  5555. var wrapper = { done: false };
  5556. try {
  5557. then.call(value,
  5558. bind(internalResolve, promise, wrapper, state),
  5559. bind(internalReject, promise, wrapper, state)
  5560. );
  5561. } catch (error) {
  5562. internalReject(promise, wrapper, error, state);
  5563. }
  5564. });
  5565. } else {
  5566. state.value = value;
  5567. state.state = FULFILLED;
  5568. notify$1(promise, state, false);
  5569. }
  5570. } catch (error) {
  5571. internalReject(promise, { done: false }, error, state);
  5572. }
  5573. };
  5574. // constructor polyfill
  5575. if (FORCED$3) {
  5576. // 25.4.3.1 Promise(executor)
  5577. PromiseConstructor = function Promise(executor) {
  5578. anInstance(this, PromiseConstructor, PROMISE);
  5579. aFunction$1(executor);
  5580. Internal.call(this);
  5581. var state = getInternalState$3(this);
  5582. try {
  5583. executor(bind(internalResolve, this, state), bind(internalReject, this, state));
  5584. } catch (error) {
  5585. internalReject(this, state, error);
  5586. }
  5587. };
  5588. // eslint-disable-next-line no-unused-vars
  5589. Internal = function Promise(executor) {
  5590. setInternalState$6(this, {
  5591. type: PROMISE,
  5592. done: false,
  5593. notified: false,
  5594. parent: false,
  5595. reactions: [],
  5596. rejection: false,
  5597. state: PENDING,
  5598. value: undefined
  5599. });
  5600. };
  5601. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  5602. // `Promise.prototype.then` method
  5603. // https://tc39.github.io/ecma262/#sec-promise.prototype.then
  5604. then: function then(onFulfilled, onRejected) {
  5605. var state = getInternalPromiseState(this);
  5606. var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
  5607. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  5608. reaction.fail = typeof onRejected == 'function' && onRejected;
  5609. reaction.domain = IS_NODE$1 ? process$3.domain : undefined;
  5610. state.parent = true;
  5611. state.reactions.push(reaction);
  5612. if (state.state != PENDING) notify$1(this, state, false);
  5613. return reaction.promise;
  5614. },
  5615. // `Promise.prototype.catch` method
  5616. // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
  5617. 'catch': function (onRejected) {
  5618. return this.then(undefined, onRejected);
  5619. }
  5620. });
  5621. OwnPromiseCapability = function () {
  5622. var promise = new Internal();
  5623. var state = getInternalState$3(promise);
  5624. this.promise = promise;
  5625. this.resolve = bind(internalResolve, promise, state);
  5626. this.reject = bind(internalReject, promise, state);
  5627. };
  5628. newPromiseCapability.f = newPromiseCapability$1 = function (C) {
  5629. return C === PromiseConstructor || C === PromiseWrapper
  5630. ? new OwnPromiseCapability(C)
  5631. : newGenericPromiseCapability(C);
  5632. };
  5633. if ( typeof nativePromiseConstructor == 'function') {
  5634. nativeThen = nativePromiseConstructor.prototype.then;
  5635. // wrap native Promise#then for native async functions
  5636. redefine(nativePromiseConstructor.prototype, 'then', function then(onFulfilled, onRejected) {
  5637. var that = this;
  5638. return new PromiseConstructor(function (resolve, reject) {
  5639. nativeThen.call(that, resolve, reject);
  5640. }).then(onFulfilled, onRejected);
  5641. // https://github.com/zloirock/core-js/issues/640
  5642. }, { unsafe: true });
  5643. // wrap fetch result
  5644. if (typeof $fetch$1 == 'function') _export({ global: true, enumerable: true, forced: true }, {
  5645. // eslint-disable-next-line no-unused-vars
  5646. fetch: function fetch(input /* , init */) {
  5647. return promiseResolve(PromiseConstructor, $fetch$1.apply(global_1, arguments));
  5648. }
  5649. });
  5650. }
  5651. }
  5652. _export({ global: true, wrap: true, forced: FORCED$3 }, {
  5653. Promise: PromiseConstructor
  5654. });
  5655. setToStringTag(PromiseConstructor, PROMISE, false);
  5656. setSpecies(PROMISE);
  5657. PromiseWrapper = getBuiltIn(PROMISE);
  5658. // statics
  5659. _export({ target: PROMISE, stat: true, forced: FORCED$3 }, {
  5660. // `Promise.reject` method
  5661. // https://tc39.github.io/ecma262/#sec-promise.reject
  5662. reject: function reject(r) {
  5663. var capability = newPromiseCapability$1(this);
  5664. capability.reject.call(undefined, r);
  5665. return capability.promise;
  5666. }
  5667. });
  5668. _export({ target: PROMISE, stat: true, forced: FORCED$3 }, {
  5669. // `Promise.resolve` method
  5670. // https://tc39.github.io/ecma262/#sec-promise.resolve
  5671. resolve: function resolve(x) {
  5672. return promiseResolve( this, x);
  5673. }
  5674. });
  5675. _export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION$1 }, {
  5676. // `Promise.all` method
  5677. // https://tc39.github.io/ecma262/#sec-promise.all
  5678. all: function all(iterable) {
  5679. var C = this;
  5680. var capability = newPromiseCapability$1(C);
  5681. var resolve = capability.resolve;
  5682. var reject = capability.reject;
  5683. var result = perform(function () {
  5684. var $promiseResolve = aFunction$1(C.resolve);
  5685. var values = [];
  5686. var counter = 0;
  5687. var remaining = 1;
  5688. iterate_1(iterable, function (promise) {
  5689. var index = counter++;
  5690. var alreadyCalled = false;
  5691. values.push(undefined);
  5692. remaining++;
  5693. $promiseResolve.call(C, promise).then(function (value) {
  5694. if (alreadyCalled) return;
  5695. alreadyCalled = true;
  5696. values[index] = value;
  5697. --remaining || resolve(values);
  5698. }, reject);
  5699. });
  5700. --remaining || resolve(values);
  5701. });
  5702. if (result.error) reject(result.value);
  5703. return capability.promise;
  5704. },
  5705. // `Promise.race` method
  5706. // https://tc39.github.io/ecma262/#sec-promise.race
  5707. race: function race(iterable) {
  5708. var C = this;
  5709. var capability = newPromiseCapability$1(C);
  5710. var reject = capability.reject;
  5711. var result = perform(function () {
  5712. var $promiseResolve = aFunction$1(C.resolve);
  5713. iterate_1(iterable, function (promise) {
  5714. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  5715. });
  5716. });
  5717. if (result.error) reject(result.value);
  5718. return capability.promise;
  5719. }
  5720. });
  5721. var getOwnPropertyDescriptor$4 = objectGetOwnPropertyDescriptor.f;
  5722. var nativeStartsWith = ''.startsWith;
  5723. var min$4 = Math.min;
  5724. var CORRECT_IS_REGEXP_LOGIC = correctIsRegexpLogic('startsWith');
  5725. // https://github.com/zloirock/core-js/pull/702
  5726. var MDN_POLYFILL_BUG = !CORRECT_IS_REGEXP_LOGIC && !!function () {
  5727. var descriptor = getOwnPropertyDescriptor$4(String.prototype, 'startsWith');
  5728. return descriptor && !descriptor.writable;
  5729. }();
  5730. // `String.prototype.startsWith` method
  5731. // https://tc39.github.io/ecma262/#sec-string.prototype.startswith
  5732. _export({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  5733. startsWith: function startsWith(searchString /* , position = 0 */) {
  5734. var that = String(requireObjectCoercible(this));
  5735. notARegexp(searchString);
  5736. var index = toLength(min$4(arguments.length > 1 ? arguments[1] : undefined, that.length));
  5737. var search = String(searchString);
  5738. return nativeStartsWith
  5739. ? nativeStartsWith.call(that, search, index)
  5740. : that.slice(index, index + search.length) === search;
  5741. }
  5742. });
  5743. // ==========================================================================
  5744. // Type checking utils
  5745. // ==========================================================================
  5746. var getConstructor$1 = function getConstructor(input) {
  5747. return input !== null && typeof input !== 'undefined' ? input.constructor : null;
  5748. };
  5749. var instanceOf$1 = function instanceOf(input, constructor) {
  5750. return Boolean(input && constructor && input instanceof constructor);
  5751. };
  5752. var isNullOrUndefined$1 = function isNullOrUndefined(input) {
  5753. return input === null || typeof input === 'undefined';
  5754. };
  5755. var isObject$2 = function isObject(input) {
  5756. return getConstructor$1(input) === Object;
  5757. };
  5758. var isNumber$1 = function isNumber(input) {
  5759. return getConstructor$1(input) === Number && !Number.isNaN(input);
  5760. };
  5761. var isString$1 = function isString(input) {
  5762. return getConstructor$1(input) === String;
  5763. };
  5764. var isBoolean$1 = function isBoolean(input) {
  5765. return getConstructor$1(input) === Boolean;
  5766. };
  5767. var isFunction$1 = function isFunction(input) {
  5768. return getConstructor$1(input) === Function;
  5769. };
  5770. var isArray$2 = function isArray(input) {
  5771. return Array.isArray(input);
  5772. };
  5773. var isWeakMap = function isWeakMap(input) {
  5774. return instanceOf$1(input, WeakMap);
  5775. };
  5776. var isNodeList$1 = function isNodeList(input) {
  5777. return instanceOf$1(input, NodeList);
  5778. };
  5779. var isElement$1 = function isElement(input) {
  5780. return instanceOf$1(input, Element);
  5781. };
  5782. var isTextNode = function isTextNode(input) {
  5783. return getConstructor$1(input) === Text;
  5784. };
  5785. var isEvent$1 = function isEvent(input) {
  5786. return instanceOf$1(input, Event);
  5787. };
  5788. var isKeyboardEvent = function isKeyboardEvent(input) {
  5789. return instanceOf$1(input, KeyboardEvent);
  5790. };
  5791. var isCue = function isCue(input) {
  5792. return instanceOf$1(input, window.TextTrackCue) || instanceOf$1(input, window.VTTCue);
  5793. };
  5794. var isTrack = function isTrack(input) {
  5795. return instanceOf$1(input, TextTrack) || !isNullOrUndefined$1(input) && isString$1(input.kind);
  5796. };
  5797. var isPromise = function isPromise(input) {
  5798. return instanceOf$1(input, Promise) && isFunction$1(input.then);
  5799. };
  5800. var isEmpty$1 = function isEmpty(input) {
  5801. return isNullOrUndefined$1(input) || (isString$1(input) || isArray$2(input) || isNodeList$1(input)) && !input.length || isObject$2(input) && !Object.keys(input).length;
  5802. };
  5803. var isUrl = function isUrl(input) {
  5804. // Accept a URL object
  5805. if (instanceOf$1(input, window.URL)) {
  5806. return true;
  5807. } // Must be string from here
  5808. if (!isString$1(input)) {
  5809. return false;
  5810. } // Add the protocol if required
  5811. var string = input;
  5812. if (!input.startsWith('http://') || !input.startsWith('https://')) {
  5813. string = "http://".concat(input);
  5814. }
  5815. try {
  5816. return !isEmpty$1(new URL(string).hostname);
  5817. } catch (e) {
  5818. return false;
  5819. }
  5820. };
  5821. var is$1 = {
  5822. nullOrUndefined: isNullOrUndefined$1,
  5823. object: isObject$2,
  5824. number: isNumber$1,
  5825. string: isString$1,
  5826. boolean: isBoolean$1,
  5827. function: isFunction$1,
  5828. array: isArray$2,
  5829. weakMap: isWeakMap,
  5830. nodeList: isNodeList$1,
  5831. element: isElement$1,
  5832. textNode: isTextNode,
  5833. event: isEvent$1,
  5834. keyboardEvent: isKeyboardEvent,
  5835. cue: isCue,
  5836. track: isTrack,
  5837. promise: isPromise,
  5838. url: isUrl,
  5839. empty: isEmpty$1
  5840. };
  5841. var transitionEndEvent = function () {
  5842. var element = document.createElement('span');
  5843. var events = {
  5844. WebkitTransition: 'webkitTransitionEnd',
  5845. MozTransition: 'transitionend',
  5846. OTransition: 'oTransitionEnd otransitionend',
  5847. transition: 'transitionend'
  5848. };
  5849. var type = Object.keys(events).find(function (event) {
  5850. return element.style[event] !== undefined;
  5851. });
  5852. return is$1.string(type) ? events[type] : false;
  5853. }(); // Force repaint of element
  5854. function repaint(element, delay) {
  5855. setTimeout(function () {
  5856. try {
  5857. // eslint-disable-next-line no-param-reassign
  5858. element.hidden = true; // eslint-disable-next-line no-unused-expressions
  5859. element.offsetHeight; // eslint-disable-next-line no-param-reassign
  5860. element.hidden = false;
  5861. } catch (e) {// Do nothing
  5862. }
  5863. }, delay);
  5864. }
  5865. // ==========================================================================
  5866. // Browser sniffing
  5867. // Unfortunately, due to mixed support, UA sniffing is required
  5868. // ==========================================================================
  5869. var browser = {
  5870. isIE:
  5871. /* @cc_on!@ */
  5872. !!document.documentMode,
  5873. isEdge: window.navigator.userAgent.includes('Edge'),
  5874. isWebkit: 'WebkitAppearance' in document.documentElement.style && !/Edge/.test(navigator.userAgent),
  5875. isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
  5876. isIos: /(iPad|iPhone|iPod)/gi.test(navigator.platform)
  5877. };
  5878. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  5879. var createMethod$5 = function (IS_RIGHT) {
  5880. return function (that, callbackfn, argumentsLength, memo) {
  5881. aFunction$1(callbackfn);
  5882. var O = toObject(that);
  5883. var self = indexedObject(O);
  5884. var length = toLength(O.length);
  5885. var index = IS_RIGHT ? length - 1 : 0;
  5886. var i = IS_RIGHT ? -1 : 1;
  5887. if (argumentsLength < 2) while (true) {
  5888. if (index in self) {
  5889. memo = self[index];
  5890. index += i;
  5891. break;
  5892. }
  5893. index += i;
  5894. if (IS_RIGHT ? index < 0 : length <= index) {
  5895. throw TypeError('Reduce of empty array with no initial value');
  5896. }
  5897. }
  5898. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  5899. memo = callbackfn(memo, self[index], index, O);
  5900. }
  5901. return memo;
  5902. };
  5903. };
  5904. var arrayReduce = {
  5905. // `Array.prototype.reduce` method
  5906. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  5907. left: createMethod$5(false),
  5908. // `Array.prototype.reduceRight` method
  5909. // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
  5910. right: createMethod$5(true)
  5911. };
  5912. var $reduce = arrayReduce.left;
  5913. var STRICT_METHOD$5 = arrayMethodIsStrict('reduce');
  5914. var USES_TO_LENGTH$9 = arrayMethodUsesToLength('reduce', { 1: 0 });
  5915. // `Array.prototype.reduce` method
  5916. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  5917. _export({ target: 'Array', proto: true, forced: !STRICT_METHOD$5 || !USES_TO_LENGTH$9 }, {
  5918. reduce: function reduce(callbackfn /* , initialValue */) {
  5919. return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
  5920. }
  5921. });
  5922. function cloneDeep(object) {
  5923. return JSON.parse(JSON.stringify(object));
  5924. } // Get a nested value in an object
  5925. function getDeep(object, path) {
  5926. return path.split('.').reduce(function (obj, key) {
  5927. return obj && obj[key];
  5928. }, object);
  5929. } // Deep extend destination object with N more objects
  5930. function extend() {
  5931. var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5932. for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5933. sources[_key - 1] = arguments[_key];
  5934. }
  5935. if (!sources.length) {
  5936. return target;
  5937. }
  5938. var source = sources.shift();
  5939. if (!is$1.object(source)) {
  5940. return target;
  5941. }
  5942. Object.keys(source).forEach(function (key) {
  5943. if (is$1.object(source[key])) {
  5944. if (!Object.keys(target).includes(key)) {
  5945. Object.assign(target, _defineProperty({}, key, {}));
  5946. }
  5947. extend(target[key], source[key]);
  5948. } else {
  5949. Object.assign(target, _defineProperty({}, key, source[key]));
  5950. }
  5951. });
  5952. return extend.apply(void 0, [target].concat(sources));
  5953. }
  5954. function wrap$1(elements, wrapper) {
  5955. // Convert `elements` to an array, if necessary.
  5956. var targets = elements.length ? elements : [elements]; // Loops backwards to prevent having to clone the wrapper on the
  5957. // first element (see `child` below).
  5958. Array.from(targets).reverse().forEach(function (element, index) {
  5959. var child = index > 0 ? wrapper.cloneNode(true) : wrapper; // Cache the current parent and sibling.
  5960. var parent = element.parentNode;
  5961. var sibling = element.nextSibling; // Wrap the element (is automatically removed from its current
  5962. // parent).
  5963. child.appendChild(element); // If the element had a sibling, insert the wrapper before
  5964. // the sibling to maintain the HTML structure; otherwise, just
  5965. // append it to the parent.
  5966. if (sibling) {
  5967. parent.insertBefore(child, sibling);
  5968. } else {
  5969. parent.appendChild(child);
  5970. }
  5971. });
  5972. } // Set attributes
  5973. function setAttributes(element, attributes) {
  5974. if (!is$1.element(element) || is$1.empty(attributes)) {
  5975. return;
  5976. } // Assume null and undefined attributes should be left out,
  5977. // Setting them would otherwise convert them to "null" and "undefined"
  5978. Object.entries(attributes).filter(function (_ref) {
  5979. var _ref2 = _slicedToArray(_ref, 2),
  5980. value = _ref2[1];
  5981. return !is$1.nullOrUndefined(value);
  5982. }).forEach(function (_ref3) {
  5983. var _ref4 = _slicedToArray(_ref3, 2),
  5984. key = _ref4[0],
  5985. value = _ref4[1];
  5986. return element.setAttribute(key, value);
  5987. });
  5988. } // Create a DocumentFragment
  5989. function createElement(type, attributes, text) {
  5990. // Create a new <element>
  5991. var element = document.createElement(type); // Set all passed attributes
  5992. if (is$1.object(attributes)) {
  5993. setAttributes(element, attributes);
  5994. } // Add text node
  5995. if (is$1.string(text)) {
  5996. element.innerText = text;
  5997. } // Return built element
  5998. return element;
  5999. } // Inaert an element after another
  6000. function insertAfter(element, target) {
  6001. if (!is$1.element(element) || !is$1.element(target)) {
  6002. return;
  6003. }
  6004. target.parentNode.insertBefore(element, target.nextSibling);
  6005. } // Insert a DocumentFragment
  6006. function insertElement(type, parent, attributes, text) {
  6007. if (!is$1.element(parent)) {
  6008. return;
  6009. }
  6010. parent.appendChild(createElement(type, attributes, text));
  6011. } // Remove element(s)
  6012. function removeElement(element) {
  6013. if (is$1.nodeList(element) || is$1.array(element)) {
  6014. Array.from(element).forEach(removeElement);
  6015. return;
  6016. }
  6017. if (!is$1.element(element) || !is$1.element(element.parentNode)) {
  6018. return;
  6019. }
  6020. element.parentNode.removeChild(element);
  6021. } // Remove all child elements
  6022. function emptyElement(element) {
  6023. if (!is$1.element(element)) {
  6024. return;
  6025. }
  6026. var length = element.childNodes.length;
  6027. while (length > 0) {
  6028. element.removeChild(element.lastChild);
  6029. length -= 1;
  6030. }
  6031. } // Replace element
  6032. function replaceElement(newChild, oldChild) {
  6033. if (!is$1.element(oldChild) || !is$1.element(oldChild.parentNode) || !is$1.element(newChild)) {
  6034. return null;
  6035. }
  6036. oldChild.parentNode.replaceChild(newChild, oldChild);
  6037. return newChild;
  6038. } // Get an attribute object from a string selector
  6039. function getAttributesFromSelector(sel, existingAttributes) {
  6040. // For example:
  6041. // '.test' to { class: 'test' }
  6042. // '#test' to { id: 'test' }
  6043. // '[data-test="test"]' to { 'data-test': 'test' }
  6044. if (!is$1.string(sel) || is$1.empty(sel)) {
  6045. return {};
  6046. }
  6047. var attributes = {};
  6048. var existing = extend({}, existingAttributes);
  6049. sel.split(',').forEach(function (s) {
  6050. // Remove whitespace
  6051. var selector = s.trim();
  6052. var className = selector.replace('.', '');
  6053. var stripped = selector.replace(/[[\]]/g, ''); // Get the parts and value
  6054. var parts = stripped.split('=');
  6055. var _parts = _slicedToArray(parts, 1),
  6056. key = _parts[0];
  6057. var value = parts.length > 1 ? parts[1].replace(/["']/g, '') : ''; // Get the first character
  6058. var start = selector.charAt(0);
  6059. switch (start) {
  6060. case '.':
  6061. // Add to existing classname
  6062. if (is$1.string(existing.class)) {
  6063. attributes.class = "".concat(existing.class, " ").concat(className);
  6064. } else {
  6065. attributes.class = className;
  6066. }
  6067. break;
  6068. case '#':
  6069. // ID selector
  6070. attributes.id = selector.replace('#', '');
  6071. break;
  6072. case '[':
  6073. // Attribute selector
  6074. attributes[key] = value;
  6075. break;
  6076. }
  6077. });
  6078. return extend(existing, attributes);
  6079. } // Toggle hidden
  6080. function toggleHidden(element, hidden) {
  6081. if (!is$1.element(element)) {
  6082. return;
  6083. }
  6084. var hide = hidden;
  6085. if (!is$1.boolean(hide)) {
  6086. hide = !element.hidden;
  6087. } // eslint-disable-next-line no-param-reassign
  6088. element.hidden = hide;
  6089. } // Mirror Element.classList.toggle, with IE compatibility for "force" argument
  6090. function toggleClass(element, className, force) {
  6091. if (is$1.nodeList(element)) {
  6092. return Array.from(element).map(function (e) {
  6093. return toggleClass(e, className, force);
  6094. });
  6095. }
  6096. if (is$1.element(element)) {
  6097. var method = 'toggle';
  6098. if (typeof force !== 'undefined') {
  6099. method = force ? 'add' : 'remove';
  6100. }
  6101. element.classList[method](className);
  6102. return element.classList.contains(className);
  6103. }
  6104. return false;
  6105. } // Has class name
  6106. function hasClass(element, className) {
  6107. return is$1.element(element) && element.classList.contains(className);
  6108. } // Element matches selector
  6109. function matches$1(element, selector) {
  6110. var _Element = Element,
  6111. prototype = _Element.prototype;
  6112. function match() {
  6113. return Array.from(document.querySelectorAll(selector)).includes(this);
  6114. }
  6115. var method = prototype.matches || prototype.webkitMatchesSelector || prototype.mozMatchesSelector || prototype.msMatchesSelector || match;
  6116. return method.call(element, selector);
  6117. } // Closest ancestor element matching selector (also tests element itself)
  6118. function closest(element, selector) {
  6119. var _Element2 = Element,
  6120. prototype = _Element2.prototype; // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
  6121. function closestElement() {
  6122. var el = this;
  6123. do {
  6124. if (matches$1.matches(el, selector)) return el;
  6125. el = el.parentElement || el.parentNode;
  6126. } while (el !== null && el.nodeType === 1);
  6127. return null;
  6128. }
  6129. var method = prototype.closest || closestElement;
  6130. return method.call(element, selector);
  6131. } // Find all elements
  6132. function getElements(selector) {
  6133. return this.elements.container.querySelectorAll(selector);
  6134. } // Find a single element
  6135. function getElement(selector) {
  6136. return this.elements.container.querySelector(selector);
  6137. } // Set focus and tab focus class
  6138. function setFocus() {
  6139. var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6140. var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6141. if (!is$1.element(element)) {
  6142. return;
  6143. } // Set regular focus
  6144. element.focus({
  6145. preventScroll: true
  6146. }); // If we want to mimic keyboard focus via tab
  6147. if (tabFocus) {
  6148. toggleClass(element, this.config.classNames.tabFocus);
  6149. }
  6150. }
  6151. var defaultCodecs = {
  6152. 'audio/ogg': 'vorbis',
  6153. 'audio/wav': '1',
  6154. 'video/webm': 'vp8, vorbis',
  6155. 'video/mp4': 'avc1.42E01E, mp4a.40.2',
  6156. 'video/ogg': 'theora'
  6157. }; // Check for feature support
  6158. var support = {
  6159. // Basic support
  6160. audio: 'canPlayType' in document.createElement('audio'),
  6161. video: 'canPlayType' in document.createElement('video'),
  6162. // Check for support
  6163. // Basic functionality vs full UI
  6164. check: function check(type, provider, playsinline) {
  6165. var canPlayInline = browser.isIPhone && playsinline && support.playsinline;
  6166. var api = support[type] || provider !== 'html5';
  6167. var ui = api && support.rangeInput && (type !== 'video' || !browser.isIPhone || canPlayInline);
  6168. return {
  6169. api: api,
  6170. ui: ui
  6171. };
  6172. },
  6173. // Picture-in-picture support
  6174. // Safari & Chrome only currently
  6175. pip: function () {
  6176. if (browser.isIPhone) {
  6177. return false;
  6178. } // Safari
  6179. // https://developer.apple.com/documentation/webkitjs/adding_picture_in_picture_to_your_safari_media_controls
  6180. if (is$1.function(createElement('video').webkitSetPresentationMode)) {
  6181. return true;
  6182. } // Chrome
  6183. // https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture
  6184. if (document.pictureInPictureEnabled && !createElement('video').disablePictureInPicture) {
  6185. return true;
  6186. }
  6187. return false;
  6188. }(),
  6189. // Airplay support
  6190. // Safari only currently
  6191. airplay: is$1.function(window.WebKitPlaybackTargetAvailabilityEvent),
  6192. // Inline playback support
  6193. // https://webkit.org/blog/6784/new-video-policies-for-ios/
  6194. playsinline: 'playsInline' in document.createElement('video'),
  6195. // Check for mime type support against a player instance
  6196. // Credits: http://diveintohtml5.info/everything.html
  6197. // Related: http://www.leanbackplayer.com/test/h5mt.html
  6198. mime: function mime(input) {
  6199. if (is$1.empty(input)) {
  6200. return false;
  6201. }
  6202. var _input$split = input.split('/'),
  6203. _input$split2 = _slicedToArray(_input$split, 1),
  6204. mediaType = _input$split2[0];
  6205. var type = input; // Verify we're using HTML5 and there's no media type mismatch
  6206. if (!this.isHTML5 || mediaType !== this.type) {
  6207. return false;
  6208. } // Add codec if required
  6209. if (Object.keys(defaultCodecs).includes(type)) {
  6210. type += "; codecs=\"".concat(defaultCodecs[input], "\"");
  6211. }
  6212. try {
  6213. return Boolean(type && this.media.canPlayType(type).replace(/no/, ''));
  6214. } catch (e) {
  6215. return false;
  6216. }
  6217. },
  6218. // Check for textTracks support
  6219. textTracks: 'textTracks' in document.createElement('video'),
  6220. // <input type="range"> Sliders
  6221. rangeInput: function () {
  6222. var range = document.createElement('input');
  6223. range.type = 'range';
  6224. return range.type === 'range';
  6225. }(),
  6226. // Touch
  6227. // NOTE: Remember a device can be mouse + touch enabled so we check on first touch event
  6228. touch: 'ontouchstart' in document.documentElement,
  6229. // Detect transitions support
  6230. transitions: transitionEndEvent !== false,
  6231. // Reduced motion iOS & MacOS setting
  6232. // https://webkit.org/blog/7551/responsive-design-for-motion/
  6233. reducedMotion: 'matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches
  6234. };
  6235. // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
  6236. // https://www.youtube.com/watch?v=NPM6172J22g
  6237. var supportsPassiveListeners = function () {
  6238. // Test via a getter in the options object to see if the passive property is accessed
  6239. var supported = false;
  6240. try {
  6241. var options = Object.defineProperty({}, 'passive', {
  6242. get: function get() {
  6243. supported = true;
  6244. return null;
  6245. }
  6246. });
  6247. window.addEventListener('test', null, options);
  6248. window.removeEventListener('test', null, options);
  6249. } catch (e) {// Do nothing
  6250. }
  6251. return supported;
  6252. }(); // Toggle event listener
  6253. function toggleListener(element, event, callback) {
  6254. var _this = this;
  6255. var toggle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6256. var passive = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  6257. var capture = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
  6258. // Bail if no element, event, or callback
  6259. if (!element || !('addEventListener' in element) || is$1.empty(event) || !is$1.function(callback)) {
  6260. return;
  6261. } // Allow multiple events
  6262. var events = event.split(' '); // Build options
  6263. // Default to just the capture boolean for browsers with no passive listener support
  6264. var options = capture; // If passive events listeners are supported
  6265. if (supportsPassiveListeners) {
  6266. options = {
  6267. // Whether the listener can be passive (i.e. default never prevented)
  6268. passive: passive,
  6269. // Whether the listener is a capturing listener or not
  6270. capture: capture
  6271. };
  6272. } // If a single node is passed, bind the event listener
  6273. events.forEach(function (type) {
  6274. if (_this && _this.eventListeners && toggle) {
  6275. // Cache event listener
  6276. _this.eventListeners.push({
  6277. element: element,
  6278. type: type,
  6279. callback: callback,
  6280. options: options
  6281. });
  6282. }
  6283. element[toggle ? 'addEventListener' : 'removeEventListener'](type, callback, options);
  6284. });
  6285. } // Bind event handler
  6286. function on(element) {
  6287. var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6288. var callback = arguments.length > 2 ? arguments[2] : undefined;
  6289. var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6290. var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6291. toggleListener.call(this, element, events, callback, true, passive, capture);
  6292. } // Unbind event handler
  6293. function off(element) {
  6294. var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6295. var callback = arguments.length > 2 ? arguments[2] : undefined;
  6296. var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6297. var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6298. toggleListener.call(this, element, events, callback, false, passive, capture);
  6299. } // Bind once-only event handler
  6300. function once(element) {
  6301. var _this2 = this;
  6302. var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6303. var callback = arguments.length > 2 ? arguments[2] : undefined;
  6304. var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6305. var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6306. var onceCallback = function onceCallback() {
  6307. off(element, events, onceCallback, passive, capture);
  6308. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6309. args[_key] = arguments[_key];
  6310. }
  6311. callback.apply(_this2, args);
  6312. };
  6313. toggleListener.call(this, element, events, onceCallback, true, passive, capture);
  6314. } // Trigger event
  6315. function triggerEvent(element) {
  6316. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6317. var bubbles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6318. var detail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  6319. // Bail if no element
  6320. if (!is$1.element(element) || is$1.empty(type)) {
  6321. return;
  6322. } // Create and dispatch the event
  6323. var event = new CustomEvent(type, {
  6324. bubbles: bubbles,
  6325. detail: _objectSpread2(_objectSpread2({}, detail), {}, {
  6326. plyr: this
  6327. })
  6328. }); // Dispatch the event
  6329. element.dispatchEvent(event);
  6330. } // Unbind all cached event listeners
  6331. function unbindListeners() {
  6332. if (this && this.eventListeners) {
  6333. this.eventListeners.forEach(function (item) {
  6334. var element = item.element,
  6335. type = item.type,
  6336. callback = item.callback,
  6337. options = item.options;
  6338. element.removeEventListener(type, callback, options);
  6339. });
  6340. this.eventListeners = [];
  6341. }
  6342. } // Run method when / if player is ready
  6343. function ready() {
  6344. var _this3 = this;
  6345. return new Promise(function (resolve) {
  6346. return _this3.ready ? setTimeout(resolve, 0) : on.call(_this3, _this3.elements.container, 'ready', resolve);
  6347. }).then(function () {});
  6348. }
  6349. /**
  6350. * Silence a Promise-like object.
  6351. * This is useful for avoiding non-harmful, but potentially confusing "uncaught
  6352. * play promise" rejection error messages.
  6353. * @param {Object} value An object that may or may not be `Promise`-like.
  6354. */
  6355. function silencePromise(value) {
  6356. if (is$1.promise(value)) {
  6357. value.then(null, function () {});
  6358. }
  6359. }
  6360. function validateRatio(input) {
  6361. if (!is$1.array(input) && (!is$1.string(input) || !input.includes(':'))) {
  6362. return false;
  6363. }
  6364. var ratio = is$1.array(input) ? input : input.split(':');
  6365. return ratio.map(Number).every(is$1.number);
  6366. }
  6367. function reduceAspectRatio(ratio) {
  6368. if (!is$1.array(ratio) || !ratio.every(is$1.number)) {
  6369. return null;
  6370. }
  6371. var _ratio = _slicedToArray(ratio, 2),
  6372. width = _ratio[0],
  6373. height = _ratio[1];
  6374. var getDivider = function getDivider(w, h) {
  6375. return h === 0 ? w : getDivider(h, w % h);
  6376. };
  6377. var divider = getDivider(width, height);
  6378. return [width / divider, height / divider];
  6379. }
  6380. function getAspectRatio(input) {
  6381. var parse = function parse(ratio) {
  6382. return validateRatio(ratio) ? ratio.split(':').map(Number) : null;
  6383. }; // Try provided ratio
  6384. var ratio = parse(input); // Get from config
  6385. if (ratio === null) {
  6386. ratio = parse(this.config.ratio);
  6387. } // Get from embed
  6388. if (ratio === null && !is$1.empty(this.embed) && is$1.array(this.embed.ratio)) {
  6389. ratio = this.embed.ratio;
  6390. } // Get from HTML5 video
  6391. if (ratio === null && this.isHTML5) {
  6392. var _this$media = this.media,
  6393. videoWidth = _this$media.videoWidth,
  6394. videoHeight = _this$media.videoHeight;
  6395. ratio = reduceAspectRatio([videoWidth, videoHeight]);
  6396. }
  6397. return ratio;
  6398. } // Set aspect ratio for responsive container
  6399. function setAspectRatio(input) {
  6400. if (!this.isVideo) {
  6401. return {};
  6402. }
  6403. var wrapper = this.elements.wrapper;
  6404. var ratio = getAspectRatio.call(this, input);
  6405. var _ref = is$1.array(ratio) ? ratio : [0, 0],
  6406. _ref2 = _slicedToArray(_ref, 2),
  6407. w = _ref2[0],
  6408. h = _ref2[1];
  6409. var padding = 100 / w * h;
  6410. wrapper.style.paddingBottom = "".concat(padding, "%"); // For Vimeo we have an extra <div> to hide the standard controls and UI
  6411. if (this.isVimeo && !this.config.vimeo.premium && this.supported.ui) {
  6412. var height = 100 / this.media.offsetWidth * parseInt(window.getComputedStyle(this.media).paddingBottom, 10);
  6413. var offset = (height - padding) / (height / 50);
  6414. this.media.style.transform = "translateY(-".concat(offset, "%)");
  6415. } else if (this.isHTML5) {
  6416. wrapper.classList.toggle(this.config.classNames.videoFixedRatio, ratio !== null);
  6417. }
  6418. return {
  6419. padding: padding,
  6420. ratio: ratio
  6421. };
  6422. }
  6423. var html5 = {
  6424. getSources: function getSources() {
  6425. var _this = this;
  6426. if (!this.isHTML5) {
  6427. return [];
  6428. }
  6429. var sources = Array.from(this.media.querySelectorAll('source')); // Filter out unsupported sources (if type is specified)
  6430. return sources.filter(function (source) {
  6431. var type = source.getAttribute('type');
  6432. if (is$1.empty(type)) {
  6433. return true;
  6434. }
  6435. return support.mime.call(_this, type);
  6436. });
  6437. },
  6438. // Get quality levels
  6439. getQualityOptions: function getQualityOptions() {
  6440. // Whether we're forcing all options (e.g. for streaming)
  6441. if (this.config.quality.forced) {
  6442. return this.config.quality.options;
  6443. } // Get sizes from <source> elements
  6444. return html5.getSources.call(this).map(function (source) {
  6445. return Number(source.getAttribute('data-res'));
  6446. }).filter(Boolean);
  6447. },
  6448. setup: function setup() {
  6449. if (!this.isHTML5) {
  6450. return;
  6451. }
  6452. var player = this; // Set speed options from config
  6453. player.options.speed = player.config.speed.options; // Set aspect ratio if fixed
  6454. if (!is$1.empty(this.config.ratio)) {
  6455. setAspectRatio.call(player);
  6456. } // Quality
  6457. Object.defineProperty(player.media, 'quality', {
  6458. get: function get() {
  6459. // Get sources
  6460. var sources = html5.getSources.call(player);
  6461. var source = sources.find(function (s) {
  6462. return s.getAttribute('src') === player.source;
  6463. }); // Return size, if match is found
  6464. return source && Number(source.getAttribute('data-res'));
  6465. },
  6466. set: function set(input) {
  6467. if (player.quality === input) {
  6468. return;
  6469. } // If we're using an an external handler...
  6470. if (player.config.quality.forced && is$1.function(player.config.quality.onChange)) {
  6471. player.config.quality.onChange(input);
  6472. } else {
  6473. // Get sources
  6474. var sources = html5.getSources.call(player); // Get first match for requested size
  6475. var source = sources.find(function (s) {
  6476. return Number(s.getAttribute('data-res')) === input;
  6477. }); // No matching source found
  6478. if (!source) {
  6479. return;
  6480. } // Get current state
  6481. var _player$media = player.media,
  6482. currentTime = _player$media.currentTime,
  6483. paused = _player$media.paused,
  6484. preload = _player$media.preload,
  6485. readyState = _player$media.readyState,
  6486. playbackRate = _player$media.playbackRate; // Set new source
  6487. player.media.src = source.getAttribute('src'); // Prevent loading if preload="none" and the current source isn't loaded (#1044)
  6488. if (preload !== 'none' || readyState) {
  6489. // Restore time
  6490. player.once('loadedmetadata', function () {
  6491. player.speed = playbackRate;
  6492. player.currentTime = currentTime; // Resume playing
  6493. if (!paused) {
  6494. silencePromise(player.play());
  6495. }
  6496. }); // Load new source
  6497. player.media.load();
  6498. }
  6499. } // Trigger change event
  6500. triggerEvent.call(player, player.media, 'qualitychange', false, {
  6501. quality: input
  6502. });
  6503. }
  6504. });
  6505. },
  6506. // Cancel current network requests
  6507. // See https://github.com/sampotts/plyr/issues/174
  6508. cancelRequests: function cancelRequests() {
  6509. if (!this.isHTML5) {
  6510. return;
  6511. } // Remove child sources
  6512. removeElement(html5.getSources.call(this)); // Set blank video src attribute
  6513. // This is to prevent a MEDIA_ERR_SRC_NOT_SUPPORTED error
  6514. // Info: http://stackoverflow.com/questions/32231579/how-to-properly-dispose-of-an-html5-video-and-close-socket-or-connection
  6515. this.media.setAttribute('src', this.config.blankVideo); // Load the new empty source
  6516. // This will cancel existing requests
  6517. // See https://github.com/sampotts/plyr/issues/174
  6518. this.media.load(); // Debugging
  6519. this.debug.log('Cancelled network requests');
  6520. }
  6521. };
  6522. function dedupe(array) {
  6523. if (!is$1.array(array)) {
  6524. return array;
  6525. }
  6526. return array.filter(function (item, index) {
  6527. return array.indexOf(item) === index;
  6528. });
  6529. } // Get the closest value in an array
  6530. function closest$1(array, value) {
  6531. if (!is$1.array(array) || !array.length) {
  6532. return null;
  6533. }
  6534. return array.reduce(function (prev, curr) {
  6535. return Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev;
  6536. });
  6537. }
  6538. var defineProperty$6 = objectDefineProperty.f;
  6539. var getOwnPropertyNames$1 = objectGetOwnPropertyNames.f;
  6540. var setInternalState$7 = internalState.set;
  6541. var MATCH$2 = wellKnownSymbol('match');
  6542. var NativeRegExp = global_1.RegExp;
  6543. var RegExpPrototype$1 = NativeRegExp.prototype;
  6544. var re1 = /a/g;
  6545. var re2 = /a/g;
  6546. // "new" should create a new object, old webkit bug
  6547. var CORRECT_NEW = new NativeRegExp(re1) !== re1;
  6548. var UNSUPPORTED_Y$2 = regexpStickyHelpers.UNSUPPORTED_Y;
  6549. var FORCED$4 = descriptors && isForced_1('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y$2 || fails(function () {
  6550. re2[MATCH$2] = false;
  6551. // RegExp constructor can alter flags and IsRegExp works correct with @@match
  6552. return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
  6553. })));
  6554. // `RegExp` constructor
  6555. // https://tc39.github.io/ecma262/#sec-regexp-constructor
  6556. if (FORCED$4) {
  6557. var RegExpWrapper = function RegExp(pattern, flags) {
  6558. var thisIsRegExp = this instanceof RegExpWrapper;
  6559. var patternIsRegExp = isRegexp(pattern);
  6560. var flagsAreUndefined = flags === undefined;
  6561. var sticky;
  6562. if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
  6563. return pattern;
  6564. }
  6565. if (CORRECT_NEW) {
  6566. if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;
  6567. } else if (pattern instanceof RegExpWrapper) {
  6568. if (flagsAreUndefined) flags = regexpFlags.call(pattern);
  6569. pattern = pattern.source;
  6570. }
  6571. if (UNSUPPORTED_Y$2) {
  6572. sticky = !!flags && flags.indexOf('y') > -1;
  6573. if (sticky) flags = flags.replace(/y/g, '');
  6574. }
  6575. var result = inheritIfRequired(
  6576. CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),
  6577. thisIsRegExp ? this : RegExpPrototype$1,
  6578. RegExpWrapper
  6579. );
  6580. if (UNSUPPORTED_Y$2 && sticky) setInternalState$7(result, { sticky: sticky });
  6581. return result;
  6582. };
  6583. var proxy = function (key) {
  6584. key in RegExpWrapper || defineProperty$6(RegExpWrapper, key, {
  6585. configurable: true,
  6586. get: function () { return NativeRegExp[key]; },
  6587. set: function (it) { NativeRegExp[key] = it; }
  6588. });
  6589. };
  6590. var keys$2 = getOwnPropertyNames$1(NativeRegExp);
  6591. var index = 0;
  6592. while (keys$2.length > index) proxy(keys$2[index++]);
  6593. RegExpPrototype$1.constructor = RegExpWrapper;
  6594. RegExpWrapper.prototype = RegExpPrototype$1;
  6595. redefine(global_1, 'RegExp', RegExpWrapper);
  6596. }
  6597. // https://tc39.github.io/ecma262/#sec-get-regexp-@@species
  6598. setSpecies('RegExp');
  6599. function generateId(prefix) {
  6600. return "".concat(prefix, "-").concat(Math.floor(Math.random() * 10000));
  6601. } // Format string
  6602. function format(input) {
  6603. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6604. args[_key - 1] = arguments[_key];
  6605. }
  6606. if (is$1.empty(input)) {
  6607. return input;
  6608. }
  6609. return input.toString().replace(/{(\d+)}/g, function (match, i) {
  6610. return args[i].toString();
  6611. });
  6612. } // Get percentage
  6613. function getPercentage(current, max) {
  6614. if (current === 0 || max === 0 || Number.isNaN(current) || Number.isNaN(max)) {
  6615. return 0;
  6616. }
  6617. return (current / max * 100).toFixed(2);
  6618. } // Replace all occurances of a string in a string
  6619. var replaceAll = function replaceAll() {
  6620. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6621. var find = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  6622. var replace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  6623. return input.replace(new RegExp(find.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'), 'g'), replace.toString());
  6624. }; // Convert to title case
  6625. var toTitleCase = function toTitleCase() {
  6626. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6627. return input.toString().replace(/\w\S*/g, function (text) {
  6628. return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
  6629. });
  6630. }; // Convert string to pascalCase
  6631. function toPascalCase() {
  6632. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6633. var string = input.toString(); // Convert kebab case
  6634. string = replaceAll(string, '-', ' '); // Convert snake case
  6635. string = replaceAll(string, '_', ' '); // Convert to title case
  6636. string = toTitleCase(string); // Convert to pascal case
  6637. return replaceAll(string, ' ', '');
  6638. } // Convert string to pascalCase
  6639. function toCamelCase() {
  6640. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6641. var string = input.toString(); // Convert to pascal case
  6642. string = toPascalCase(string); // Convert first character to lowercase
  6643. return string.charAt(0).toLowerCase() + string.slice(1);
  6644. } // Remove HTML from a string
  6645. function stripHTML(source) {
  6646. var fragment = document.createDocumentFragment();
  6647. var element = document.createElement('div');
  6648. fragment.appendChild(element);
  6649. element.innerHTML = source;
  6650. return fragment.firstChild.innerText;
  6651. } // Like outerHTML, but also works for DocumentFragment
  6652. function getHTML(element) {
  6653. var wrapper = document.createElement('div');
  6654. wrapper.appendChild(element);
  6655. return wrapper.innerHTML;
  6656. }
  6657. var resources = {
  6658. pip: 'PIP',
  6659. airplay: 'AirPlay',
  6660. html5: 'HTML5',
  6661. vimeo: 'Vimeo',
  6662. youtube: 'YouTube'
  6663. };
  6664. var i18n = {
  6665. get: function get() {
  6666. var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  6667. var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6668. if (is$1.empty(key) || is$1.empty(config)) {
  6669. return '';
  6670. }
  6671. var string = getDeep(config.i18n, key);
  6672. if (is$1.empty(string)) {
  6673. if (Object.keys(resources).includes(key)) {
  6674. return resources[key];
  6675. }
  6676. return '';
  6677. }
  6678. var replace = {
  6679. '{seektime}': config.seekTime,
  6680. '{title}': config.title
  6681. };
  6682. Object.entries(replace).forEach(function (_ref) {
  6683. var _ref2 = _slicedToArray(_ref, 2),
  6684. k = _ref2[0],
  6685. v = _ref2[1];
  6686. string = replaceAll(string, k, v);
  6687. });
  6688. return string;
  6689. }
  6690. };
  6691. var Storage = /*#__PURE__*/function () {
  6692. function Storage(player) {
  6693. _classCallCheck(this, Storage);
  6694. this.enabled = player.config.storage.enabled;
  6695. this.key = player.config.storage.key;
  6696. } // Check for actual support (see if we can use it)
  6697. _createClass(Storage, [{
  6698. key: "get",
  6699. value: function get(key) {
  6700. if (!Storage.supported || !this.enabled) {
  6701. return null;
  6702. }
  6703. var store = window.localStorage.getItem(this.key);
  6704. if (is$1.empty(store)) {
  6705. return null;
  6706. }
  6707. var json = JSON.parse(store);
  6708. return is$1.string(key) && key.length ? json[key] : json;
  6709. }
  6710. }, {
  6711. key: "set",
  6712. value: function set(object) {
  6713. // Bail if we don't have localStorage support or it's disabled
  6714. if (!Storage.supported || !this.enabled) {
  6715. return;
  6716. } // Can only store objectst
  6717. if (!is$1.object(object)) {
  6718. return;
  6719. } // Get current storage
  6720. var storage = this.get(); // Default to empty object
  6721. if (is$1.empty(storage)) {
  6722. storage = {};
  6723. } // Update the working copy of the values
  6724. extend(storage, object); // Update storage
  6725. window.localStorage.setItem(this.key, JSON.stringify(storage));
  6726. }
  6727. }], [{
  6728. key: "supported",
  6729. get: function get() {
  6730. try {
  6731. if (!('localStorage' in window)) {
  6732. return false;
  6733. }
  6734. var test = '___test'; // Try to use it (it might be disabled, e.g. user is in private mode)
  6735. // see: https://github.com/sampotts/plyr/issues/131
  6736. window.localStorage.setItem(test, test);
  6737. window.localStorage.removeItem(test);
  6738. return true;
  6739. } catch (e) {
  6740. return false;
  6741. }
  6742. }
  6743. }]);
  6744. return Storage;
  6745. }();
  6746. // ==========================================================================
  6747. // Fetch wrapper
  6748. // Using XHR to avoid issues with older browsers
  6749. // ==========================================================================
  6750. function fetch(url) {
  6751. var responseType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'text';
  6752. return new Promise(function (resolve, reject) {
  6753. try {
  6754. var request = new XMLHttpRequest(); // Check for CORS support
  6755. if (!('withCredentials' in request)) {
  6756. return;
  6757. }
  6758. request.addEventListener('load', function () {
  6759. if (responseType === 'text') {
  6760. try {
  6761. resolve(JSON.parse(request.responseText));
  6762. } catch (e) {
  6763. resolve(request.responseText);
  6764. }
  6765. } else {
  6766. resolve(request.response);
  6767. }
  6768. });
  6769. request.addEventListener('error', function () {
  6770. throw new Error(request.status);
  6771. });
  6772. request.open('GET', url, true); // Set the required response type
  6773. request.responseType = responseType;
  6774. request.send();
  6775. } catch (e) {
  6776. reject(e);
  6777. }
  6778. });
  6779. }
  6780. // ==========================================================================
  6781. function loadSprite(url, id) {
  6782. if (!is$1.string(url)) {
  6783. return;
  6784. }
  6785. var prefix = 'cache';
  6786. var hasId = is$1.string(id);
  6787. var isCached = false;
  6788. var exists = function exists() {
  6789. return document.getElementById(id) !== null;
  6790. };
  6791. var update = function update(container, data) {
  6792. // eslint-disable-next-line no-param-reassign
  6793. container.innerHTML = data; // Check again incase of race condition
  6794. if (hasId && exists()) {
  6795. return;
  6796. } // Inject the SVG to the body
  6797. document.body.insertAdjacentElement('afterbegin', container);
  6798. }; // Only load once if ID set
  6799. if (!hasId || !exists()) {
  6800. var useStorage = Storage.supported; // Create container
  6801. var container = document.createElement('div');
  6802. container.setAttribute('hidden', '');
  6803. if (hasId) {
  6804. container.setAttribute('id', id);
  6805. } // Check in cache
  6806. if (useStorage) {
  6807. var cached = window.localStorage.getItem("".concat(prefix, "-").concat(id));
  6808. isCached = cached !== null;
  6809. if (isCached) {
  6810. var data = JSON.parse(cached);
  6811. update(container, data.content);
  6812. }
  6813. } // Get the sprite
  6814. fetch(url).then(function (result) {
  6815. if (is$1.empty(result)) {
  6816. return;
  6817. }
  6818. if (useStorage) {
  6819. window.localStorage.setItem("".concat(prefix, "-").concat(id), JSON.stringify({
  6820. content: result
  6821. }));
  6822. }
  6823. update(container, result);
  6824. }).catch(function () {});
  6825. }
  6826. }
  6827. var ceil$1 = Math.ceil;
  6828. var floor$5 = Math.floor;
  6829. // `Math.trunc` method
  6830. // https://tc39.github.io/ecma262/#sec-math.trunc
  6831. _export({ target: 'Math', stat: true }, {
  6832. trunc: function trunc(it) {
  6833. return (it > 0 ? floor$5 : ceil$1)(it);
  6834. }
  6835. });
  6836. var getHours = function getHours(value) {
  6837. return Math.trunc(value / 60 / 60 % 60, 10);
  6838. };
  6839. var getMinutes = function getMinutes(value) {
  6840. return Math.trunc(value / 60 % 60, 10);
  6841. };
  6842. var getSeconds = function getSeconds(value) {
  6843. return Math.trunc(value % 60, 10);
  6844. }; // Format time to UI friendly string
  6845. function formatTime() {
  6846. var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  6847. var displayHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6848. var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6849. // Bail if the value isn't a number
  6850. if (!is$1.number(time)) {
  6851. return formatTime(undefined, displayHours, inverted);
  6852. } // Format time component to add leading zero
  6853. var format = function format(value) {
  6854. return "0".concat(value).slice(-2);
  6855. }; // Breakdown to hours, mins, secs
  6856. var hours = getHours(time);
  6857. var mins = getMinutes(time);
  6858. var secs = getSeconds(time); // Do we need to display hours?
  6859. if (displayHours || hours > 0) {
  6860. hours = "".concat(hours, ":");
  6861. } else {
  6862. hours = '';
  6863. } // Render
  6864. return "".concat(inverted && time > 0 ? '-' : '').concat(hours).concat(format(mins), ":").concat(format(secs));
  6865. }
  6866. var controls = {
  6867. // Get icon URL
  6868. getIconUrl: function getIconUrl() {
  6869. var url = new URL(this.config.iconUrl, window.location);
  6870. var cors = url.host !== window.location.host || browser.isIE && !window.svg4everybody;
  6871. return {
  6872. url: this.config.iconUrl,
  6873. cors: cors
  6874. };
  6875. },
  6876. // Find the UI controls
  6877. findElements: function findElements() {
  6878. try {
  6879. this.elements.controls = getElement.call(this, this.config.selectors.controls.wrapper); // Buttons
  6880. this.elements.buttons = {
  6881. play: getElements.call(this, this.config.selectors.buttons.play),
  6882. pause: getElement.call(this, this.config.selectors.buttons.pause),
  6883. restart: getElement.call(this, this.config.selectors.buttons.restart),
  6884. rewind: getElement.call(this, this.config.selectors.buttons.rewind),
  6885. fastForward: getElement.call(this, this.config.selectors.buttons.fastForward),
  6886. mute: getElement.call(this, this.config.selectors.buttons.mute),
  6887. pip: getElement.call(this, this.config.selectors.buttons.pip),
  6888. airplay: getElement.call(this, this.config.selectors.buttons.airplay),
  6889. settings: getElement.call(this, this.config.selectors.buttons.settings),
  6890. captions: getElement.call(this, this.config.selectors.buttons.captions),
  6891. fullscreen: getElement.call(this, this.config.selectors.buttons.fullscreen)
  6892. }; // Progress
  6893. this.elements.progress = getElement.call(this, this.config.selectors.progress); // Inputs
  6894. this.elements.inputs = {
  6895. seek: getElement.call(this, this.config.selectors.inputs.seek),
  6896. volume: getElement.call(this, this.config.selectors.inputs.volume)
  6897. }; // Display
  6898. this.elements.display = {
  6899. buffer: getElement.call(this, this.config.selectors.display.buffer),
  6900. currentTime: getElement.call(this, this.config.selectors.display.currentTime),
  6901. duration: getElement.call(this, this.config.selectors.display.duration)
  6902. }; // Seek tooltip
  6903. if (is$1.element(this.elements.progress)) {
  6904. this.elements.display.seekTooltip = this.elements.progress.querySelector(".".concat(this.config.classNames.tooltip));
  6905. }
  6906. return true;
  6907. } catch (error) {
  6908. // Log it
  6909. this.debug.warn('It looks like there is a problem with your custom controls HTML', error); // Restore native video controls
  6910. this.toggleNativeControls(true);
  6911. return false;
  6912. }
  6913. },
  6914. // Create <svg> icon
  6915. createIcon: function createIcon(type, attributes) {
  6916. var namespace = 'http://www.w3.org/2000/svg';
  6917. var iconUrl = controls.getIconUrl.call(this);
  6918. var iconPath = "".concat(!iconUrl.cors ? iconUrl.url : '', "#").concat(this.config.iconPrefix); // Create <svg>
  6919. var icon = document.createElementNS(namespace, 'svg');
  6920. setAttributes(icon, extend(attributes, {
  6921. 'aria-hidden': 'true',
  6922. focusable: 'false'
  6923. })); // Create the <use> to reference sprite
  6924. var use = document.createElementNS(namespace, 'use');
  6925. var path = "".concat(iconPath, "-").concat(type); // Set `href` attributes
  6926. // https://github.com/sampotts/plyr/issues/460
  6927. // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href
  6928. if ('href' in use) {
  6929. use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', path);
  6930. } // Always set the older attribute even though it's "deprecated" (it'll be around for ages)
  6931. use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', path); // Add <use> to <svg>
  6932. icon.appendChild(use);
  6933. return icon;
  6934. },
  6935. // Create hidden text label
  6936. createLabel: function createLabel(key) {
  6937. var attr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6938. var text = i18n.get(key, this.config);
  6939. var attributes = _objectSpread2(_objectSpread2({}, attr), {}, {
  6940. class: [attr.class, this.config.classNames.hidden].filter(Boolean).join(' ')
  6941. });
  6942. return createElement('span', attributes, text);
  6943. },
  6944. // Create a badge
  6945. createBadge: function createBadge(text) {
  6946. if (is$1.empty(text)) {
  6947. return null;
  6948. }
  6949. var badge = createElement('span', {
  6950. class: this.config.classNames.menu.value
  6951. });
  6952. badge.appendChild(createElement('span', {
  6953. class: this.config.classNames.menu.badge
  6954. }, text));
  6955. return badge;
  6956. },
  6957. // Create a <button>
  6958. createButton: function createButton(buttonType, attr) {
  6959. var _this = this;
  6960. var attributes = extend({}, attr);
  6961. var type = toCamelCase(buttonType);
  6962. var props = {
  6963. element: 'button',
  6964. toggle: false,
  6965. label: null,
  6966. icon: null,
  6967. labelPressed: null,
  6968. iconPressed: null
  6969. };
  6970. ['element', 'icon', 'label'].forEach(function (key) {
  6971. if (Object.keys(attributes).includes(key)) {
  6972. props[key] = attributes[key];
  6973. delete attributes[key];
  6974. }
  6975. }); // Default to 'button' type to prevent form submission
  6976. if (props.element === 'button' && !Object.keys(attributes).includes('type')) {
  6977. attributes.type = 'button';
  6978. } // Set class name
  6979. if (Object.keys(attributes).includes('class')) {
  6980. if (!attributes.class.split(' ').some(function (c) {
  6981. return c === _this.config.classNames.control;
  6982. })) {
  6983. extend(attributes, {
  6984. class: "".concat(attributes.class, " ").concat(this.config.classNames.control)
  6985. });
  6986. }
  6987. } else {
  6988. attributes.class = this.config.classNames.control;
  6989. } // Large play button
  6990. switch (buttonType) {
  6991. case 'play':
  6992. props.toggle = true;
  6993. props.label = 'play';
  6994. props.labelPressed = 'pause';
  6995. props.icon = 'play';
  6996. props.iconPressed = 'pause';
  6997. break;
  6998. case 'mute':
  6999. props.toggle = true;
  7000. props.label = 'mute';
  7001. props.labelPressed = 'unmute';
  7002. props.icon = 'volume';
  7003. props.iconPressed = 'muted';
  7004. break;
  7005. case 'captions':
  7006. props.toggle = true;
  7007. props.label = 'enableCaptions';
  7008. props.labelPressed = 'disableCaptions';
  7009. props.icon = 'captions-off';
  7010. props.iconPressed = 'captions-on';
  7011. break;
  7012. case 'fullscreen':
  7013. props.toggle = true;
  7014. props.label = 'enterFullscreen';
  7015. props.labelPressed = 'exitFullscreen';
  7016. props.icon = 'enter-fullscreen';
  7017. props.iconPressed = 'exit-fullscreen';
  7018. break;
  7019. case 'play-large':
  7020. attributes.class += " ".concat(this.config.classNames.control, "--overlaid");
  7021. type = 'play';
  7022. props.label = 'play';
  7023. props.icon = 'play';
  7024. break;
  7025. default:
  7026. if (is$1.empty(props.label)) {
  7027. props.label = type;
  7028. }
  7029. if (is$1.empty(props.icon)) {
  7030. props.icon = buttonType;
  7031. }
  7032. }
  7033. var button = createElement(props.element); // Setup toggle icon and labels
  7034. if (props.toggle) {
  7035. // Icon
  7036. button.appendChild(controls.createIcon.call(this, props.iconPressed, {
  7037. class: 'icon--pressed'
  7038. }));
  7039. button.appendChild(controls.createIcon.call(this, props.icon, {
  7040. class: 'icon--not-pressed'
  7041. })); // Label/Tooltip
  7042. button.appendChild(controls.createLabel.call(this, props.labelPressed, {
  7043. class: 'label--pressed'
  7044. }));
  7045. button.appendChild(controls.createLabel.call(this, props.label, {
  7046. class: 'label--not-pressed'
  7047. }));
  7048. } else {
  7049. button.appendChild(controls.createIcon.call(this, props.icon));
  7050. button.appendChild(controls.createLabel.call(this, props.label));
  7051. } // Merge and set attributes
  7052. extend(attributes, getAttributesFromSelector(this.config.selectors.buttons[type], attributes));
  7053. setAttributes(button, attributes); // We have multiple play buttons
  7054. if (type === 'play') {
  7055. if (!is$1.array(this.elements.buttons[type])) {
  7056. this.elements.buttons[type] = [];
  7057. }
  7058. this.elements.buttons[type].push(button);
  7059. } else {
  7060. this.elements.buttons[type] = button;
  7061. }
  7062. return button;
  7063. },
  7064. // Create an <input type='range'>
  7065. createRange: function createRange(type, attributes) {
  7066. // Seek input
  7067. var input = createElement('input', extend(getAttributesFromSelector(this.config.selectors.inputs[type]), {
  7068. type: 'range',
  7069. min: 0,
  7070. max: 100,
  7071. step: 0.01,
  7072. value: 0,
  7073. autocomplete: 'off',
  7074. // A11y fixes for https://github.com/sampotts/plyr/issues/905
  7075. role: 'slider',
  7076. 'aria-label': i18n.get(type, this.config),
  7077. 'aria-valuemin': 0,
  7078. 'aria-valuemax': 100,
  7079. 'aria-valuenow': 0
  7080. }, attributes));
  7081. this.elements.inputs[type] = input; // Set the fill for webkit now
  7082. controls.updateRangeFill.call(this, input); // Improve support on touch devices
  7083. RangeTouch.setup(input);
  7084. return input;
  7085. },
  7086. // Create a <progress>
  7087. createProgress: function createProgress(type, attributes) {
  7088. var progress = createElement('progress', extend(getAttributesFromSelector(this.config.selectors.display[type]), {
  7089. min: 0,
  7090. max: 100,
  7091. value: 0,
  7092. role: 'progressbar',
  7093. 'aria-hidden': true
  7094. }, attributes)); // Create the label inside
  7095. if (type !== 'volume') {
  7096. progress.appendChild(createElement('span', null, '0'));
  7097. var suffixKey = {
  7098. played: 'played',
  7099. buffer: 'buffered'
  7100. }[type];
  7101. var suffix = suffixKey ? i18n.get(suffixKey, this.config) : '';
  7102. progress.innerText = "% ".concat(suffix.toLowerCase());
  7103. }
  7104. this.elements.display[type] = progress;
  7105. return progress;
  7106. },
  7107. // Create time display
  7108. createTime: function createTime(type, attrs) {
  7109. var attributes = getAttributesFromSelector(this.config.selectors.display[type], attrs);
  7110. var container = createElement('div', extend(attributes, {
  7111. class: "".concat(attributes.class ? attributes.class : '', " ").concat(this.config.classNames.display.time, " ").trim(),
  7112. 'aria-label': i18n.get(type, this.config)
  7113. }), '00:00'); // Reference for updates
  7114. this.elements.display[type] = container;
  7115. return container;
  7116. },
  7117. // Bind keyboard shortcuts for a menu item
  7118. // We have to bind to keyup otherwise Firefox triggers a click when a keydown event handler shifts focus
  7119. // https://bugzilla.mozilla.org/show_bug.cgi?id=1220143
  7120. bindMenuItemShortcuts: function bindMenuItemShortcuts(menuItem, type) {
  7121. var _this2 = this;
  7122. // Navigate through menus via arrow keys and space
  7123. on.call(this, menuItem, 'keydown keyup', function (event) {
  7124. // We only care about space and ⬆️ ⬇️️ ➡️
  7125. if (![32, 38, 39, 40].includes(event.which)) {
  7126. return;
  7127. } // Prevent play / seek
  7128. event.preventDefault();
  7129. event.stopPropagation(); // We're just here to prevent the keydown bubbling
  7130. if (event.type === 'keydown') {
  7131. return;
  7132. }
  7133. var isRadioButton = matches$1(menuItem, '[role="menuitemradio"]'); // Show the respective menu
  7134. if (!isRadioButton && [32, 39].includes(event.which)) {
  7135. controls.showMenuPanel.call(_this2, type, true);
  7136. } else {
  7137. var target;
  7138. if (event.which !== 32) {
  7139. if (event.which === 40 || isRadioButton && event.which === 39) {
  7140. target = menuItem.nextElementSibling;
  7141. if (!is$1.element(target)) {
  7142. target = menuItem.parentNode.firstElementChild;
  7143. }
  7144. } else {
  7145. target = menuItem.previousElementSibling;
  7146. if (!is$1.element(target)) {
  7147. target = menuItem.parentNode.lastElementChild;
  7148. }
  7149. }
  7150. setFocus.call(_this2, target, true);
  7151. }
  7152. }
  7153. }, false); // Enter will fire a `click` event but we still need to manage focus
  7154. // So we bind to keyup which fires after and set focus here
  7155. on.call(this, menuItem, 'keyup', function (event) {
  7156. if (event.which !== 13) {
  7157. return;
  7158. }
  7159. controls.focusFirstMenuItem.call(_this2, null, true);
  7160. });
  7161. },
  7162. // Create a settings menu item
  7163. createMenuItem: function createMenuItem(_ref) {
  7164. var _this3 = this;
  7165. var value = _ref.value,
  7166. list = _ref.list,
  7167. type = _ref.type,
  7168. title = _ref.title,
  7169. _ref$badge = _ref.badge,
  7170. badge = _ref$badge === void 0 ? null : _ref$badge,
  7171. _ref$checked = _ref.checked,
  7172. checked = _ref$checked === void 0 ? false : _ref$checked;
  7173. var attributes = getAttributesFromSelector(this.config.selectors.inputs[type]);
  7174. var menuItem = createElement('button', extend(attributes, {
  7175. type: 'button',
  7176. role: 'menuitemradio',
  7177. class: "".concat(this.config.classNames.control, " ").concat(attributes.class ? attributes.class : '').trim(),
  7178. 'aria-checked': checked,
  7179. value: value
  7180. }));
  7181. var flex = createElement('span'); // We have to set as HTML incase of special characters
  7182. flex.innerHTML = title;
  7183. if (is$1.element(badge)) {
  7184. flex.appendChild(badge);
  7185. }
  7186. menuItem.appendChild(flex); // Replicate radio button behaviour
  7187. Object.defineProperty(menuItem, 'checked', {
  7188. enumerable: true,
  7189. get: function get() {
  7190. return menuItem.getAttribute('aria-checked') === 'true';
  7191. },
  7192. set: function set(check) {
  7193. // Ensure exclusivity
  7194. if (check) {
  7195. Array.from(menuItem.parentNode.children).filter(function (node) {
  7196. return matches$1(node, '[role="menuitemradio"]');
  7197. }).forEach(function (node) {
  7198. return node.setAttribute('aria-checked', 'false');
  7199. });
  7200. }
  7201. menuItem.setAttribute('aria-checked', check ? 'true' : 'false');
  7202. }
  7203. });
  7204. this.listeners.bind(menuItem, 'click keyup', function (event) {
  7205. if (is$1.keyboardEvent(event) && event.which !== 32) {
  7206. return;
  7207. }
  7208. event.preventDefault();
  7209. event.stopPropagation();
  7210. menuItem.checked = true;
  7211. switch (type) {
  7212. case 'language':
  7213. _this3.currentTrack = Number(value);
  7214. break;
  7215. case 'quality':
  7216. _this3.quality = value;
  7217. break;
  7218. case 'speed':
  7219. _this3.speed = parseFloat(value);
  7220. break;
  7221. }
  7222. controls.showMenuPanel.call(_this3, 'home', is$1.keyboardEvent(event));
  7223. }, type, false);
  7224. controls.bindMenuItemShortcuts.call(this, menuItem, type);
  7225. list.appendChild(menuItem);
  7226. },
  7227. // Format a time for display
  7228. formatTime: function formatTime$1() {
  7229. var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7230. var inverted = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7231. // Bail if the value isn't a number
  7232. if (!is$1.number(time)) {
  7233. return time;
  7234. } // Always display hours if duration is over an hour
  7235. var forceHours = getHours(this.duration) > 0;
  7236. return formatTime(time, forceHours, inverted);
  7237. },
  7238. // Update the displayed time
  7239. updateTimeDisplay: function updateTimeDisplay() {
  7240. var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7241. var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  7242. var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7243. // Bail if there's no element to display or the value isn't a number
  7244. if (!is$1.element(target) || !is$1.number(time)) {
  7245. return;
  7246. } // eslint-disable-next-line no-param-reassign
  7247. target.innerText = controls.formatTime(time, inverted);
  7248. },
  7249. // Update volume UI and storage
  7250. updateVolume: function updateVolume() {
  7251. if (!this.supported.ui) {
  7252. return;
  7253. } // Update range
  7254. if (is$1.element(this.elements.inputs.volume)) {
  7255. controls.setRange.call(this, this.elements.inputs.volume, this.muted ? 0 : this.volume);
  7256. } // Update mute state
  7257. if (is$1.element(this.elements.buttons.mute)) {
  7258. this.elements.buttons.mute.pressed = this.muted || this.volume === 0;
  7259. }
  7260. },
  7261. // Update seek value and lower fill
  7262. setRange: function setRange(target) {
  7263. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  7264. if (!is$1.element(target)) {
  7265. return;
  7266. } // eslint-disable-next-line
  7267. target.value = value; // Webkit range fill
  7268. controls.updateRangeFill.call(this, target);
  7269. },
  7270. // Update <progress> elements
  7271. updateProgress: function updateProgress(event) {
  7272. var _this4 = this;
  7273. if (!this.supported.ui || !is$1.event(event)) {
  7274. return;
  7275. }
  7276. var value = 0;
  7277. var setProgress = function setProgress(target, input) {
  7278. var val = is$1.number(input) ? input : 0;
  7279. var progress = is$1.element(target) ? target : _this4.elements.display.buffer; // Update value and label
  7280. if (is$1.element(progress)) {
  7281. progress.value = val; // Update text label inside
  7282. var label = progress.getElementsByTagName('span')[0];
  7283. if (is$1.element(label)) {
  7284. label.childNodes[0].nodeValue = val;
  7285. }
  7286. }
  7287. };
  7288. if (event) {
  7289. switch (event.type) {
  7290. // Video playing
  7291. case 'timeupdate':
  7292. case 'seeking':
  7293. case 'seeked':
  7294. value = getPercentage(this.currentTime, this.duration); // Set seek range value only if it's a 'natural' time event
  7295. if (event.type === 'timeupdate') {
  7296. controls.setRange.call(this, this.elements.inputs.seek, value);
  7297. }
  7298. break;
  7299. // Check buffer status
  7300. case 'playing':
  7301. case 'progress':
  7302. setProgress(this.elements.display.buffer, this.buffered * 100);
  7303. break;
  7304. }
  7305. }
  7306. },
  7307. // Webkit polyfill for lower fill range
  7308. updateRangeFill: function updateRangeFill(target) {
  7309. // Get range from event if event passed
  7310. var range = is$1.event(target) ? target.target : target; // Needs to be a valid <input type='range'>
  7311. if (!is$1.element(range) || range.getAttribute('type') !== 'range') {
  7312. return;
  7313. } // Set aria values for https://github.com/sampotts/plyr/issues/905
  7314. if (matches$1(range, this.config.selectors.inputs.seek)) {
  7315. range.setAttribute('aria-valuenow', this.currentTime);
  7316. var currentTime = controls.formatTime(this.currentTime);
  7317. var duration = controls.formatTime(this.duration);
  7318. var format = i18n.get('seekLabel', this.config);
  7319. range.setAttribute('aria-valuetext', format.replace('{currentTime}', currentTime).replace('{duration}', duration));
  7320. } else if (matches$1(range, this.config.selectors.inputs.volume)) {
  7321. var percent = range.value * 100;
  7322. range.setAttribute('aria-valuenow', percent);
  7323. range.setAttribute('aria-valuetext', "".concat(percent.toFixed(1), "%"));
  7324. } else {
  7325. range.setAttribute('aria-valuenow', range.value);
  7326. } // WebKit only
  7327. if (!browser.isWebkit) {
  7328. return;
  7329. } // Set CSS custom property
  7330. range.style.setProperty('--value', "".concat(range.value / range.max * 100, "%"));
  7331. },
  7332. // Update hover tooltip for seeking
  7333. updateSeekTooltip: function updateSeekTooltip(event) {
  7334. var _this5 = this;
  7335. // Bail if setting not true
  7336. if (!this.config.tooltips.seek || !is$1.element(this.elements.inputs.seek) || !is$1.element(this.elements.display.seekTooltip) || this.duration === 0) {
  7337. return;
  7338. }
  7339. var visible = "".concat(this.config.classNames.tooltip, "--visible");
  7340. var toggle = function toggle(show) {
  7341. return toggleClass(_this5.elements.display.seekTooltip, visible, show);
  7342. }; // Hide on touch
  7343. if (this.touch) {
  7344. toggle(false);
  7345. return;
  7346. } // Determine percentage, if already visible
  7347. var percent = 0;
  7348. var clientRect = this.elements.progress.getBoundingClientRect();
  7349. if (is$1.event(event)) {
  7350. percent = 100 / clientRect.width * (event.pageX - clientRect.left);
  7351. } else if (hasClass(this.elements.display.seekTooltip, visible)) {
  7352. percent = parseFloat(this.elements.display.seekTooltip.style.left, 10);
  7353. } else {
  7354. return;
  7355. } // Set bounds
  7356. if (percent < 0) {
  7357. percent = 0;
  7358. } else if (percent > 100) {
  7359. percent = 100;
  7360. } // Display the time a click would seek to
  7361. controls.updateTimeDisplay.call(this, this.elements.display.seekTooltip, this.duration / 100 * percent); // Set position
  7362. this.elements.display.seekTooltip.style.left = "".concat(percent, "%"); // Show/hide the tooltip
  7363. // If the event is a moues in/out and percentage is inside bounds
  7364. if (is$1.event(event) && ['mouseenter', 'mouseleave'].includes(event.type)) {
  7365. toggle(event.type === 'mouseenter');
  7366. }
  7367. },
  7368. // Handle time change event
  7369. timeUpdate: function timeUpdate(event) {
  7370. // Only invert if only one time element is displayed and used for both duration and currentTime
  7371. var invert = !is$1.element(this.elements.display.duration) && this.config.invertTime; // Duration
  7372. controls.updateTimeDisplay.call(this, this.elements.display.currentTime, invert ? this.duration - this.currentTime : this.currentTime, invert); // Ignore updates while seeking
  7373. if (event && event.type === 'timeupdate' && this.media.seeking) {
  7374. return;
  7375. } // Playing progress
  7376. controls.updateProgress.call(this, event);
  7377. },
  7378. // Show the duration on metadataloaded or durationchange events
  7379. durationUpdate: function durationUpdate() {
  7380. // Bail if no UI or durationchange event triggered after playing/seek when invertTime is false
  7381. if (!this.supported.ui || !this.config.invertTime && this.currentTime) {
  7382. return;
  7383. } // 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.
  7384. // https://github.com/video-dev/hls.js/blob/5820d29d3c4c8a46e8b75f1e3afa3e68c1a9a2db/src/controller/buffer-controller.js#L415
  7385. // https://github.com/google/shaka-player/blob/4d889054631f4e1cf0fbd80ddd2b71887c02e232/lib/media/streaming_engine.js#L1062
  7386. // https://github.com/Dash-Industry-Forum/dash.js/blob/69859f51b969645b234666800d4cb596d89c602d/src/dash/models/DashManifestModel.js#L338
  7387. if (this.duration >= Math.pow(2, 32)) {
  7388. toggleHidden(this.elements.display.currentTime, true);
  7389. toggleHidden(this.elements.progress, true);
  7390. return;
  7391. } // Update ARIA values
  7392. if (is$1.element(this.elements.inputs.seek)) {
  7393. this.elements.inputs.seek.setAttribute('aria-valuemax', this.duration);
  7394. } // If there's a spot to display duration
  7395. var hasDuration = is$1.element(this.elements.display.duration); // If there's only one time display, display duration there
  7396. if (!hasDuration && this.config.displayDuration && this.paused) {
  7397. controls.updateTimeDisplay.call(this, this.elements.display.currentTime, this.duration);
  7398. } // If there's a duration element, update content
  7399. if (hasDuration) {
  7400. controls.updateTimeDisplay.call(this, this.elements.display.duration, this.duration);
  7401. } // Update the tooltip (if visible)
  7402. controls.updateSeekTooltip.call(this);
  7403. },
  7404. // Hide/show a tab
  7405. toggleMenuButton: function toggleMenuButton(setting, toggle) {
  7406. toggleHidden(this.elements.settings.buttons[setting], !toggle);
  7407. },
  7408. // Update the selected setting
  7409. updateSetting: function updateSetting(setting, container, input) {
  7410. var pane = this.elements.settings.panels[setting];
  7411. var value = null;
  7412. var list = container;
  7413. if (setting === 'captions') {
  7414. value = this.currentTrack;
  7415. } else {
  7416. value = !is$1.empty(input) ? input : this[setting]; // Get default
  7417. if (is$1.empty(value)) {
  7418. value = this.config[setting].default;
  7419. } // Unsupported value
  7420. if (!is$1.empty(this.options[setting]) && !this.options[setting].includes(value)) {
  7421. this.debug.warn("Unsupported value of '".concat(value, "' for ").concat(setting));
  7422. return;
  7423. } // Disabled value
  7424. if (!this.config[setting].options.includes(value)) {
  7425. this.debug.warn("Disabled value of '".concat(value, "' for ").concat(setting));
  7426. return;
  7427. }
  7428. } // Get the list if we need to
  7429. if (!is$1.element(list)) {
  7430. list = pane && pane.querySelector('[role="menu"]');
  7431. } // If there's no list it means it's not been rendered...
  7432. if (!is$1.element(list)) {
  7433. return;
  7434. } // Update the label
  7435. var label = this.elements.settings.buttons[setting].querySelector(".".concat(this.config.classNames.menu.value));
  7436. label.innerHTML = controls.getLabel.call(this, setting, value); // Find the radio option and check it
  7437. var target = list && list.querySelector("[value=\"".concat(value, "\"]"));
  7438. if (is$1.element(target)) {
  7439. target.checked = true;
  7440. }
  7441. },
  7442. // Translate a value into a nice label
  7443. getLabel: function getLabel(setting, value) {
  7444. switch (setting) {
  7445. case 'speed':
  7446. return value === 1 ? i18n.get('normal', this.config) : "".concat(value, "&times;");
  7447. case 'quality':
  7448. if (is$1.number(value)) {
  7449. var label = i18n.get("qualityLabel.".concat(value), this.config);
  7450. if (!label.length) {
  7451. return "".concat(value, "p");
  7452. }
  7453. return label;
  7454. }
  7455. return toTitleCase(value);
  7456. case 'captions':
  7457. return captions.getLabel.call(this);
  7458. default:
  7459. return null;
  7460. }
  7461. },
  7462. // Set the quality menu
  7463. setQualityMenu: function setQualityMenu(options) {
  7464. var _this6 = this;
  7465. // Menu required
  7466. if (!is$1.element(this.elements.settings.panels.quality)) {
  7467. return;
  7468. }
  7469. var type = 'quality';
  7470. var list = this.elements.settings.panels.quality.querySelector('[role="menu"]'); // Set options if passed and filter based on uniqueness and config
  7471. if (is$1.array(options)) {
  7472. this.options.quality = dedupe(options).filter(function (quality) {
  7473. return _this6.config.quality.options.includes(quality);
  7474. });
  7475. } // Toggle the pane and tab
  7476. var toggle = !is$1.empty(this.options.quality) && this.options.quality.length > 1;
  7477. controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
  7478. emptyElement(list); // Check if we need to toggle the parent
  7479. controls.checkMenu.call(this); // If we're hiding, nothing more to do
  7480. if (!toggle) {
  7481. return;
  7482. } // Get the badge HTML for HD, 4K etc
  7483. var getBadge = function getBadge(quality) {
  7484. var label = i18n.get("qualityBadge.".concat(quality), _this6.config);
  7485. if (!label.length) {
  7486. return null;
  7487. }
  7488. return controls.createBadge.call(_this6, label);
  7489. }; // Sort options by the config and then render options
  7490. this.options.quality.sort(function (a, b) {
  7491. var sorting = _this6.config.quality.options;
  7492. return sorting.indexOf(a) > sorting.indexOf(b) ? 1 : -1;
  7493. }).forEach(function (quality) {
  7494. controls.createMenuItem.call(_this6, {
  7495. value: quality,
  7496. list: list,
  7497. type: type,
  7498. title: controls.getLabel.call(_this6, 'quality', quality),
  7499. badge: getBadge(quality)
  7500. });
  7501. });
  7502. controls.updateSetting.call(this, type, list);
  7503. },
  7504. // Set the looping options
  7505. /* setLoopMenu() {
  7506. // Menu required
  7507. if (!is.element(this.elements.settings.panels.loop)) {
  7508. return;
  7509. }
  7510. const options = ['start', 'end', 'all', 'reset'];
  7511. const list = this.elements.settings.panels.loop.querySelector('[role="menu"]');
  7512. // Show the pane and tab
  7513. toggleHidden(this.elements.settings.buttons.loop, false);
  7514. toggleHidden(this.elements.settings.panels.loop, false);
  7515. // Toggle the pane and tab
  7516. const toggle = !is.empty(this.loop.options);
  7517. controls.toggleMenuButton.call(this, 'loop', toggle);
  7518. // Empty the menu
  7519. emptyElement(list);
  7520. options.forEach(option => {
  7521. const item = createElement('li');
  7522. const button = createElement(
  7523. 'button',
  7524. extend(getAttributesFromSelector(this.config.selectors.buttons.loop), {
  7525. type: 'button',
  7526. class: this.config.classNames.control,
  7527. 'data-plyr-loop-action': option,
  7528. }),
  7529. i18n.get(option, this.config)
  7530. );
  7531. if (['start', 'end'].includes(option)) {
  7532. const badge = controls.createBadge.call(this, '00:00');
  7533. button.appendChild(badge);
  7534. }
  7535. item.appendChild(button);
  7536. list.appendChild(item);
  7537. });
  7538. }, */
  7539. // Get current selected caption language
  7540. // TODO: rework this to user the getter in the API?
  7541. // Set a list of available captions languages
  7542. setCaptionsMenu: function setCaptionsMenu() {
  7543. var _this7 = this;
  7544. // Menu required
  7545. if (!is$1.element(this.elements.settings.panels.captions)) {
  7546. return;
  7547. } // TODO: Captions or language? Currently it's mixed
  7548. var type = 'captions';
  7549. var list = this.elements.settings.panels.captions.querySelector('[role="menucaptions"]');
  7550. var tracks = captions.getTracks.call(this);
  7551. var toggle = Boolean(tracks.length); // Toggle the pane and tab
  7552. controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
  7553. emptyElement(list); // Check if we need to toggle the parent
  7554. controls.checkMenu.call(this); // If there's no captions, bail
  7555. if (!toggle) {
  7556. return;
  7557. } // Generate options data
  7558. var options = tracks.map(function (track, value) {
  7559. return {
  7560. value: value,
  7561. checked: _this7.captions.toggled && _this7.currentTrack === value,
  7562. title: captions.getLabel.call(_this7, track),
  7563. badge: track.language && controls.createBadge.call(_this7, track.language.toUpperCase()),
  7564. list: list,
  7565. type: 'language'
  7566. };
  7567. }); // Add the "Disabled" option to turn off captions
  7568. options.unshift({
  7569. value: -1,
  7570. checked: !this.captions.toggled,
  7571. title: i18n.get('disabled', this.config),
  7572. list: list,
  7573. type: 'language'
  7574. }); // Generate options
  7575. options.forEach(controls.createMenuItem.bind(this));
  7576. controls.updateSetting.call(this, type, list);
  7577. },
  7578. // Set a list of available captions languages
  7579. setSpeedMenu: function setSpeedMenu() {
  7580. var _this8 = this;
  7581. // Menu required
  7582. if (!is$1.element(this.elements.settings.panels.speed)) {
  7583. return;
  7584. }
  7585. var type = 'speed';
  7586. var list = this.elements.settings.panels.speed.querySelector('[role="menu"]'); // Filter out invalid speeds
  7587. this.options.speed = this.options.speed.filter(function (o) {
  7588. return o >= _this8.minimumSpeed && o <= _this8.maximumSpeed;
  7589. }); // Toggle the pane and tab
  7590. var toggle = !is$1.empty(this.options.speed) && this.options.speed.length > 1;
  7591. controls.toggleMenuButton.call(this, type, toggle); // Empty the menu
  7592. emptyElement(list); // Check if we need to toggle the parent
  7593. controls.checkMenu.call(this); // If we're hiding, nothing more to do
  7594. if (!toggle) {
  7595. return;
  7596. } // Create items
  7597. this.options.speed.forEach(function (speed) {
  7598. controls.createMenuItem.call(_this8, {
  7599. value: speed,
  7600. list: list,
  7601. type: type,
  7602. title: controls.getLabel.call(_this8, 'speed', speed)
  7603. });
  7604. });
  7605. controls.updateSetting.call(this, type, list);
  7606. },
  7607. // Check if we need to hide/show the settings menu
  7608. checkMenu: function checkMenu() {
  7609. var buttons = this.elements.settings.buttons;
  7610. var visible = !is$1.empty(buttons) && Object.values(buttons).some(function (button) {
  7611. return !button.hidden;
  7612. });
  7613. toggleHidden(this.elements.settings.menu, !visible);
  7614. },
  7615. // Focus the first menu item in a given (or visible) menu
  7616. focusFirstMenuItem: function focusFirstMenuItem(pane) {
  7617. var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7618. if (this.elements.settings.popup.hidden) {
  7619. return;
  7620. }
  7621. var target = pane;
  7622. if (!is$1.element(target)) {
  7623. target = Object.values(this.elements.settings.panels).find(function (p) {
  7624. return !p.hidden;
  7625. });
  7626. }
  7627. var firstItem = target.querySelector('[role^="menuitem"]');
  7628. setFocus.call(this, firstItem, tabFocus);
  7629. },
  7630. // Show/hide menu
  7631. toggleMenu: function toggleMenu(input) {
  7632. var popup = this.elements.settings.popup;
  7633. var button = this.elements.buttons.settings; // Menu and button are required
  7634. if (!is$1.element(popup) || !is$1.element(button)) {
  7635. return;
  7636. } // True toggle by default
  7637. var hidden = popup.hidden;
  7638. var show = hidden;
  7639. if (is$1.boolean(input)) {
  7640. show = input;
  7641. } else if (is$1.keyboardEvent(input) && input.which === 27) {
  7642. show = false;
  7643. } else if (is$1.event(input)) {
  7644. // If Plyr is in a shadowDOM, the event target is set to the component, instead of the
  7645. // Element in the shadowDOM. The path, if available, is complete.
  7646. var target = is$1.function(input.composedPath) ? input.composedPath()[0] : input.target;
  7647. var isMenuItem = popup.contains(target); // If the click was inside the menu or if the click
  7648. // wasn't the button or menu item and we're trying to
  7649. // show the menu (a doc click shouldn't show the menu)
  7650. if (isMenuItem || !isMenuItem && input.target !== button && show) {
  7651. return;
  7652. }
  7653. } // Set button attributes
  7654. button.setAttribute('aria-expanded', show); // Show the actual popup
  7655. toggleHidden(popup, !show); // Add class hook
  7656. toggleClass(this.elements.container, this.config.classNames.menu.open, show); // Focus the first item if key interaction
  7657. if (show && is$1.keyboardEvent(input)) {
  7658. controls.focusFirstMenuItem.call(this, null, true);
  7659. } else if (!show && !hidden) {
  7660. // If closing, re-focus the button
  7661. setFocus.call(this, button, is$1.keyboardEvent(input));
  7662. }
  7663. },
  7664. // Get the natural size of a menu panel
  7665. getMenuSize: function getMenuSize(tab) {
  7666. var clone = tab.cloneNode(true);
  7667. clone.style.position = 'absolute';
  7668. clone.style.opacity = 0;
  7669. clone.removeAttribute('hidden'); // Append to parent so we get the "real" size
  7670. tab.parentNode.appendChild(clone); // Get the sizes before we remove
  7671. var width = clone.scrollWidth;
  7672. var height = clone.scrollHeight; // Remove from the DOM
  7673. removeElement(clone);
  7674. return {
  7675. width: width,
  7676. height: height
  7677. };
  7678. },
  7679. // Show a panel in the menu
  7680. showMenuPanel: function showMenuPanel() {
  7681. var _this9 = this;
  7682. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  7683. var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7684. var target = this.elements.container.querySelector("#plyr-settings-".concat(this.id, "-").concat(type)); // Nothing to show, bail
  7685. if (!is$1.element(target)) {
  7686. return;
  7687. } // Hide all other panels
  7688. var container = target.parentNode;
  7689. var current = Array.from(container.children).find(function (node) {
  7690. return !node.hidden;
  7691. }); // If we can do fancy animations, we'll animate the height/width
  7692. if (support.transitions && !support.reducedMotion) {
  7693. // Set the current width as a base
  7694. container.style.width = "".concat(current.scrollWidth, "px");
  7695. container.style.height = "".concat(current.scrollHeight, "px"); // Get potential sizes
  7696. var size = controls.getMenuSize.call(this, target); // Restore auto height/width
  7697. var restore = function restore(event) {
  7698. // We're only bothered about height and width on the container
  7699. if (event.target !== container || !['width', 'height'].includes(event.propertyName)) {
  7700. return;
  7701. } // Revert back to auto
  7702. container.style.width = '';
  7703. container.style.height = ''; // Only listen once
  7704. off.call(_this9, container, transitionEndEvent, restore);
  7705. }; // Listen for the transition finishing and restore auto height/width
  7706. on.call(this, container, transitionEndEvent, restore); // Set dimensions to target
  7707. container.style.width = "".concat(size.width, "px");
  7708. container.style.height = "".concat(size.height, "px");
  7709. } // Set attributes on current tab
  7710. toggleHidden(current, true); // Set attributes on target
  7711. toggleHidden(target, false); // Focus the first item
  7712. controls.focusFirstMenuItem.call(this, target, tabFocus);
  7713. },
  7714. // Set the download URL
  7715. setDownloadUrl: function setDownloadUrl() {
  7716. var button = this.elements.buttons.download; // Bail if no button
  7717. if (!is$1.element(button)) {
  7718. return;
  7719. } // Set attribute
  7720. button.setAttribute('href', this.download);
  7721. },
  7722. // Build the default HTML
  7723. create: function create(data) {
  7724. var _this10 = this;
  7725. var bindMenuItemShortcuts = controls.bindMenuItemShortcuts,
  7726. createButton = controls.createButton,
  7727. createProgress = controls.createProgress,
  7728. createRange = controls.createRange,
  7729. createTime = controls.createTime,
  7730. setQualityMenu = controls.setQualityMenu,
  7731. setSpeedMenu = controls.setSpeedMenu,
  7732. showMenuPanel = controls.showMenuPanel;
  7733. this.elements.controls = null; // Larger overlaid play button
  7734. if (is$1.array(this.config.controls) && this.config.controls.includes('play-large')) {
  7735. this.elements.container.appendChild(createButton.call(this, 'play-large'));
  7736. } // Create the container
  7737. var container = createElement('div', getAttributesFromSelector(this.config.selectors.controls.wrapper));
  7738. this.elements.controls = container; // Default item attributes
  7739. var defaultAttributes = {
  7740. class: 'plyr__controls__item'
  7741. }; // Loop through controls in order
  7742. dedupe(is$1.array(this.config.controls) ? this.config.controls : []).forEach(function (control) {
  7743. // Restart button
  7744. if (control === 'restart') {
  7745. container.appendChild(createButton.call(_this10, 'restart', defaultAttributes));
  7746. } // Rewind button
  7747. if (control === 'rewind') {
  7748. container.appendChild(createButton.call(_this10, 'rewind', defaultAttributes));
  7749. } // Play/Pause button
  7750. if (control === 'play') {
  7751. container.appendChild(createButton.call(_this10, 'play', defaultAttributes));
  7752. } // Fast forward button
  7753. if (control === 'fast-forward') {
  7754. container.appendChild(createButton.call(_this10, 'fast-forward', defaultAttributes));
  7755. } // Progress
  7756. if (control === 'progress') {
  7757. var progressContainer = createElement('div', {
  7758. class: "".concat(defaultAttributes.class, " plyr__progress__container")
  7759. });
  7760. var progress = createElement('div', getAttributesFromSelector(_this10.config.selectors.progress)); // Seek range slider
  7761. progress.appendChild(createRange.call(_this10, 'seek', {
  7762. id: "plyr-seek-".concat(data.id)
  7763. })); // Buffer progress
  7764. progress.appendChild(createProgress.call(_this10, 'buffer')); // TODO: Add loop display indicator
  7765. // Seek tooltip
  7766. if (_this10.config.tooltips.seek) {
  7767. var tooltip = createElement('span', {
  7768. class: _this10.config.classNames.tooltip
  7769. }, '00:00');
  7770. progress.appendChild(tooltip);
  7771. _this10.elements.display.seekTooltip = tooltip;
  7772. }
  7773. _this10.elements.progress = progress;
  7774. progressContainer.appendChild(_this10.elements.progress);
  7775. container.appendChild(progressContainer);
  7776. } // Media current time display
  7777. if (control === 'current-time') {
  7778. container.appendChild(createTime.call(_this10, 'currentTime', defaultAttributes));
  7779. } // Media duration display
  7780. if (control === 'duration') {
  7781. container.appendChild(createTime.call(_this10, 'duration', defaultAttributes));
  7782. } // Volume controls
  7783. if (control === 'mute' || control === 'volume') {
  7784. var volume = _this10.elements.volume; // Create the volume container if needed
  7785. if (!is$1.element(volume) || !container.contains(volume)) {
  7786. volume = createElement('div', extend({}, defaultAttributes, {
  7787. class: "".concat(defaultAttributes.class, " plyr__volume").trim()
  7788. }));
  7789. _this10.elements.volume = volume;
  7790. container.appendChild(volume);
  7791. } // Toggle mute button
  7792. if (control === 'mute') {
  7793. volume.appendChild(createButton.call(_this10, 'mute'));
  7794. } // Volume range control
  7795. // Ignored on iOS as it's handled globally
  7796. // https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html
  7797. if (control === 'volume' && !browser.isIos) {
  7798. // Set the attributes
  7799. var attributes = {
  7800. max: 1,
  7801. step: 0.05,
  7802. value: _this10.config.volume
  7803. }; // Create the volume range slider
  7804. volume.appendChild(createRange.call(_this10, 'volume', extend(attributes, {
  7805. id: "plyr-volume-".concat(data.id)
  7806. })));
  7807. }
  7808. } // Toggle captions button
  7809. if (control === 'captions') {
  7810. container.appendChild(createButton.call(_this10, 'captions', defaultAttributes));
  7811. } // Settings button / menu
  7812. if (control === 'settings' && !is$1.empty(_this10.config.settings)) {
  7813. var wrapper = createElement('div', extend({}, defaultAttributes, {
  7814. class: "".concat(defaultAttributes.class, " plyr__menu").trim(),
  7815. hidden: ''
  7816. }));
  7817. wrapper.appendChild(createButton.call(_this10, 'settings', {
  7818. 'aria-haspopup': true,
  7819. 'aria-controls': "plyr-settings-".concat(data.id),
  7820. 'aria-expanded': false
  7821. }));
  7822. var popup = createElement('div', {
  7823. class: 'plyr__menu__container',
  7824. id: "plyr-settings-".concat(data.id),
  7825. hidden: ''
  7826. });
  7827. var inner = createElement('div');
  7828. var home = createElement('div', {
  7829. id: "plyr-settings-".concat(data.id, "-home")
  7830. }); // Create the menu
  7831. var menu = createElement('div', {
  7832. role: 'menu'
  7833. });
  7834. home.appendChild(menu);
  7835. inner.appendChild(home);
  7836. _this10.elements.settings.panels.home = home; // Build the menu items
  7837. _this10.config.settings.forEach(function (type) {
  7838. // TODO: bundle this with the createMenuItem helper and bindings
  7839. var menuItem = createElement('button', extend(getAttributesFromSelector(_this10.config.selectors.buttons.settings), {
  7840. type: 'button',
  7841. class: "".concat(_this10.config.classNames.control, " ").concat(_this10.config.classNames.control, "--forward"),
  7842. role: 'menuitem',
  7843. 'aria-haspopup': true,
  7844. hidden: ''
  7845. })); // Bind menu shortcuts for keyboard users
  7846. bindMenuItemShortcuts.call(_this10, menuItem, type); // Show menu on click
  7847. on.call(_this10, menuItem, 'click', function () {
  7848. showMenuPanel.call(_this10, type, false);
  7849. });
  7850. var flex = createElement('span', null, i18n.get(type, _this10.config));
  7851. var value = createElement('span', {
  7852. class: _this10.config.classNames.menu.value
  7853. }); // Speed contains HTML entities
  7854. value.innerHTML = data[type];
  7855. flex.appendChild(value);
  7856. menuItem.appendChild(flex);
  7857. menu.appendChild(menuItem); // Build the panes
  7858. var pane = createElement('div', {
  7859. id: "plyr-settings-".concat(data.id, "-").concat(type),
  7860. hidden: ''
  7861. }); // Back button
  7862. var backButton = createElement('button', {
  7863. type: 'button',
  7864. class: "".concat(_this10.config.classNames.control, " ").concat(_this10.config.classNames.control, "--back")
  7865. }); // Visible label
  7866. backButton.appendChild(createElement('span', {
  7867. 'aria-hidden': true
  7868. }, i18n.get(type, _this10.config))); // Screen reader label
  7869. backButton.appendChild(createElement('span', {
  7870. class: _this10.config.classNames.hidden
  7871. }, i18n.get('menuBack', _this10.config))); // Go back via keyboard
  7872. on.call(_this10, pane, 'keydown', function (event) {
  7873. // We only care about <-
  7874. if (event.which !== 37) {
  7875. return;
  7876. } // Prevent seek
  7877. event.preventDefault();
  7878. event.stopPropagation(); // Show the respective menu
  7879. showMenuPanel.call(_this10, 'home', true);
  7880. }, false); // Go back via button click
  7881. on.call(_this10, backButton, 'click', function () {
  7882. showMenuPanel.call(_this10, 'home', false);
  7883. }); // Add to pane
  7884. pane.appendChild(backButton); // Menu
  7885. pane.appendChild(createElement('div', {
  7886. role: 'menu'
  7887. })); // Menu Captions
  7888. pane.appendChild(createElement('div', {
  7889. role: 'menucaptions'
  7890. }));
  7891. inner.appendChild(pane);
  7892. _this10.elements.settings.buttons[type] = menuItem;
  7893. _this10.elements.settings.panels[type] = pane;
  7894. });
  7895. popup.appendChild(inner);
  7896. wrapper.appendChild(popup);
  7897. container.appendChild(wrapper);
  7898. _this10.elements.settings.popup = popup;
  7899. _this10.elements.settings.menu = wrapper;
  7900. } // Picture in picture button
  7901. if (control === 'pip' && support.pip) {
  7902. container.appendChild(createButton.call(_this10, 'pip', defaultAttributes));
  7903. } // Airplay button
  7904. if (control === 'airplay' && support.airplay) {
  7905. container.appendChild(createButton.call(_this10, 'airplay', defaultAttributes));
  7906. } // Download button
  7907. if (control === 'download') {
  7908. var _attributes = extend({}, defaultAttributes, {
  7909. element: 'a',
  7910. href: _this10.download,
  7911. target: '_blank'
  7912. }); // Set download attribute for HTML5 only
  7913. if (_this10.isHTML5) {
  7914. _attributes.download = '';
  7915. }
  7916. var download = _this10.config.urls.download;
  7917. if (!is$1.url(download) && _this10.isEmbed) {
  7918. extend(_attributes, {
  7919. icon: "logo-".concat(_this10.provider),
  7920. label: _this10.provider
  7921. });
  7922. }
  7923. container.appendChild(createButton.call(_this10, 'download', _attributes));
  7924. } // Toggle fullscreen button
  7925. if (control === 'fullscreen') {
  7926. container.appendChild(createButton.call(_this10, 'fullscreen', defaultAttributes));
  7927. }
  7928. }); // Set available quality levels
  7929. if (this.isHTML5) {
  7930. setQualityMenu.call(this, html5.getQualityOptions.call(this));
  7931. }
  7932. setSpeedMenu.call(this);
  7933. return container;
  7934. },
  7935. // Insert controls
  7936. inject: function inject() {
  7937. var _this11 = this;
  7938. // Sprite
  7939. if (this.config.loadSprite) {
  7940. var icon = controls.getIconUrl.call(this); // Only load external sprite using AJAX
  7941. if (icon.cors) {
  7942. loadSprite(icon.url, 'sprite-plyr');
  7943. }
  7944. } // Create a unique ID
  7945. this.id = Math.floor(Math.random() * 10000); // Null by default
  7946. var container = null;
  7947. this.elements.controls = null; // Set template properties
  7948. var props = {
  7949. id: this.id,
  7950. seektime: this.config.seekTime,
  7951. title: this.config.title
  7952. };
  7953. var update = true; // If function, run it and use output
  7954. if (is$1.function(this.config.controls)) {
  7955. this.config.controls = this.config.controls.call(this, props);
  7956. } // Convert falsy controls to empty array (primarily for empty strings)
  7957. if (!this.config.controls) {
  7958. this.config.controls = [];
  7959. }
  7960. if (is$1.element(this.config.controls) || is$1.string(this.config.controls)) {
  7961. // HTMLElement or Non-empty string passed as the option
  7962. container = this.config.controls;
  7963. } else {
  7964. // Create controls
  7965. container = controls.create.call(this, {
  7966. id: this.id,
  7967. seektime: this.config.seekTime,
  7968. speed: this.speed,
  7969. quality: this.quality,
  7970. captions: captions.getLabel.call(this) // TODO: Looping
  7971. // loop: 'None',
  7972. });
  7973. update = false;
  7974. } // Replace props with their value
  7975. var replace = function replace(input) {
  7976. var result = input;
  7977. Object.entries(props).forEach(function (_ref2) {
  7978. var _ref3 = _slicedToArray(_ref2, 2),
  7979. key = _ref3[0],
  7980. value = _ref3[1];
  7981. result = replaceAll(result, "{".concat(key, "}"), value);
  7982. });
  7983. return result;
  7984. }; // Update markup
  7985. if (update) {
  7986. if (is$1.string(this.config.controls)) {
  7987. container = replace(container);
  7988. }
  7989. } // Controls container
  7990. var target; // Inject to custom location
  7991. if (is$1.string(this.config.selectors.controls.container)) {
  7992. target = document.querySelector(this.config.selectors.controls.container);
  7993. } // Inject into the container by default
  7994. if (!is$1.element(target)) {
  7995. target = this.elements.container;
  7996. } // Inject controls HTML (needs to be before captions, hence "afterbegin")
  7997. var insertMethod = is$1.element(container) ? 'insertAdjacentElement' : 'insertAdjacentHTML';
  7998. target[insertMethod]('afterbegin', container); // Find the elements if need be
  7999. if (!is$1.element(this.elements.controls)) {
  8000. controls.findElements.call(this);
  8001. } // Add pressed property to buttons
  8002. if (!is$1.empty(this.elements.buttons)) {
  8003. var addProperty = function addProperty(button) {
  8004. var className = _this11.config.classNames.controlPressed;
  8005. Object.defineProperty(button, 'pressed', {
  8006. enumerable: true,
  8007. get: function get() {
  8008. return hasClass(button, className);
  8009. },
  8010. set: function set() {
  8011. var pressed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8012. toggleClass(button, className, pressed);
  8013. }
  8014. });
  8015. }; // Toggle classname when pressed property is set
  8016. Object.values(this.elements.buttons).filter(Boolean).forEach(function (button) {
  8017. if (is$1.array(button) || is$1.nodeList(button)) {
  8018. Array.from(button).filter(Boolean).forEach(addProperty);
  8019. } else {
  8020. addProperty(button);
  8021. }
  8022. });
  8023. } // Edge sometimes doesn't finish the paint so force a repaint
  8024. if (browser.isEdge) {
  8025. repaint(target);
  8026. } // Setup tooltips
  8027. if (this.config.tooltips.controls) {
  8028. var _this$config = this.config,
  8029. classNames = _this$config.classNames,
  8030. selectors = _this$config.selectors;
  8031. var selector = "".concat(selectors.controls.wrapper, " ").concat(selectors.labels, " .").concat(classNames.hidden);
  8032. var labels = getElements.call(this, selector);
  8033. Array.from(labels).forEach(function (label) {
  8034. toggleClass(label, _this11.config.classNames.hidden, false);
  8035. toggleClass(label, _this11.config.classNames.tooltip, true);
  8036. });
  8037. }
  8038. }
  8039. };
  8040. /**
  8041. * Parse a string to a URL object
  8042. * @param {String} input - the URL to be parsed
  8043. * @param {Boolean} safe - failsafe parsing
  8044. */
  8045. function parseUrl(input) {
  8046. var safe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8047. var url = input;
  8048. if (safe) {
  8049. var parser = document.createElement('a');
  8050. parser.href = url;
  8051. url = parser.href;
  8052. }
  8053. try {
  8054. return new URL(url);
  8055. } catch (e) {
  8056. return null;
  8057. }
  8058. } // Convert object to URLSearchParams
  8059. function buildUrlParams(input) {
  8060. var params = new URLSearchParams();
  8061. if (is$1.object(input)) {
  8062. Object.entries(input).forEach(function (_ref) {
  8063. var _ref2 = _slicedToArray(_ref, 2),
  8064. key = _ref2[0],
  8065. value = _ref2[1];
  8066. params.set(key, value);
  8067. });
  8068. }
  8069. return params;
  8070. }
  8071. var captions = {
  8072. // Setup captions
  8073. setup: function setup() {
  8074. // Requires UI support
  8075. if (!this.supported.ui) {
  8076. return;
  8077. } // Only Vimeo and HTML5 video supported at this point
  8078. if (!this.isVideo || this.isYouTube || this.isHTML5 && !support.textTracks) {
  8079. // Clear menu and hide
  8080. if (is$1.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
  8081. controls.setCaptionsMenu.call(this);
  8082. }
  8083. return;
  8084. } // Inject the container
  8085. if (!is$1.element(this.elements.captions)) {
  8086. this.elements.captions = createElement('div', getAttributesFromSelector(this.config.selectors.captions));
  8087. insertAfter(this.elements.captions, this.elements.wrapper);
  8088. } // Fix IE captions if CORS is used
  8089. // Fetch captions and inject as blobs instead (data URIs not supported!)
  8090. if (browser.isIE && window.URL) {
  8091. var elements = this.media.querySelectorAll('track');
  8092. Array.from(elements).forEach(function (track) {
  8093. var src = track.getAttribute('src');
  8094. var url = parseUrl(src);
  8095. if (url !== null && url.hostname !== window.location.href.hostname && ['http:', 'https:'].includes(url.protocol)) {
  8096. fetch(src, 'blob').then(function (blob) {
  8097. track.setAttribute('src', window.URL.createObjectURL(blob));
  8098. }).catch(function () {
  8099. removeElement(track);
  8100. });
  8101. }
  8102. });
  8103. } // Get and set initial data
  8104. // The "preferred" options are not realized unless / until the wanted language has a match
  8105. // * languages: Array of user's browser languages.
  8106. // * language: The language preferred by user settings or config
  8107. // * active: The state preferred by user settings or config
  8108. // * toggled: The real captions state
  8109. var browserLanguages = navigator.languages || [navigator.language || navigator.userLanguage || 'en'];
  8110. var languages = dedupe(browserLanguages.map(function (language) {
  8111. return language.split('-')[0];
  8112. }));
  8113. var language = (this.storage.get('language') || this.config.captions.language || 'auto').toLowerCase(); // Use first browser language when language is 'auto'
  8114. if (language === 'auto') {
  8115. var _languages = _slicedToArray(languages, 1);
  8116. language = _languages[0];
  8117. }
  8118. var active = this.storage.get('captions');
  8119. if (!is$1.boolean(active)) {
  8120. active = this.config.captions.active;
  8121. }
  8122. Object.assign(this.captions, {
  8123. toggled: false,
  8124. active: active,
  8125. language: language,
  8126. languages: languages
  8127. }); // Watch changes to textTracks and update captions menu
  8128. if (this.isHTML5) {
  8129. var trackEvents = this.config.captions.update ? 'addtrack removetrack' : 'removetrack';
  8130. on.call(this, this.media.textTracks, trackEvents, captions.update.bind(this));
  8131. } // Update available languages in list next tick (the event must not be triggered before the listeners)
  8132. setTimeout(captions.update.bind(this), 0);
  8133. },
  8134. // Update available language options in settings based on tracks
  8135. update: function update() {
  8136. var _this = this;
  8137. var tracks = captions.getTracks.call(this, true); // Get the wanted language
  8138. var _this$captions = this.captions,
  8139. active = _this$captions.active,
  8140. language = _this$captions.language,
  8141. meta = _this$captions.meta,
  8142. currentTrackNode = _this$captions.currentTrackNode;
  8143. var languageExists = Boolean(tracks.find(function (track) {
  8144. return track.language === language;
  8145. })); // Handle tracks (add event listener and "pseudo"-default)
  8146. if (this.isHTML5 && this.isVideo) {
  8147. tracks.filter(function (track) {
  8148. return !meta.get(track);
  8149. }).forEach(function (track) {
  8150. _this.debug.log('Track added', track); // Attempt to store if the original dom element was "default"
  8151. meta.set(track, {
  8152. default: track.mode === 'showing'
  8153. }); // Turn off native caption rendering to avoid double captions
  8154. // Note: mode='hidden' forces a track to download. To ensure every track
  8155. // isn't downloaded at once, only 'showing' tracks should be reassigned
  8156. // eslint-disable-next-line no-param-reassign
  8157. if (track.mode === 'showing') {
  8158. // eslint-disable-next-line no-param-reassign
  8159. track.mode = 'hidden';
  8160. } // Add event listener for cue changes
  8161. on.call(_this, track, 'cuechange', function () {
  8162. return captions.updateCues.call(_this);
  8163. });
  8164. });
  8165. } // Update language first time it matches, or if the previous matching track was removed
  8166. if (languageExists && this.language !== language || !tracks.includes(currentTrackNode)) {
  8167. captions.setLanguage.call(this, language);
  8168. captions.toggle.call(this, active && languageExists);
  8169. } // Enable or disable captions based on track length
  8170. toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is$1.empty(tracks)); // Update available languages in list
  8171. if (is$1.array(this.config.controls) && this.config.controls.includes('settings') && this.config.settings.includes('captions')) {
  8172. controls.setCaptionsMenu.call(this);
  8173. }
  8174. },
  8175. // Toggle captions display
  8176. // Used internally for the toggleCaptions method, with the passive option forced to false
  8177. toggle: function toggle(input) {
  8178. var _this2 = this;
  8179. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8180. // If there's no full support
  8181. if (!this.supported.ui) {
  8182. return;
  8183. }
  8184. var toggled = this.captions.toggled; // Current state
  8185. var activeClass = this.config.classNames.captions.active; // Get the next state
  8186. // If the method is called without parameter, toggle based on current value
  8187. var active = is$1.nullOrUndefined(input) ? !toggled : input; // Update state and trigger event
  8188. if (active !== toggled) {
  8189. // When passive, don't override user preferences
  8190. if (!passive) {
  8191. this.captions.active = active;
  8192. this.storage.set({
  8193. captions: active
  8194. });
  8195. } // Force language if the call isn't passive and there is no matching language to toggle to
  8196. if (!this.language && active && !passive) {
  8197. var tracks = captions.getTracks.call(this);
  8198. 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
  8199. this.captions.language = track.language; // Set caption, but don't store in localStorage as user preference
  8200. captions.set.call(this, tracks.indexOf(track));
  8201. return;
  8202. } // Toggle button if it's enabled
  8203. if (this.elements.buttons.captions) {
  8204. this.elements.buttons.captions.pressed = active;
  8205. } // Add class hook
  8206. toggleClass(this.elements.container, activeClass, active);
  8207. this.captions.toggled = active; // Update settings menu
  8208. controls.updateSetting.call(this, 'captions'); // Trigger event (not used internally)
  8209. triggerEvent.call(this, this.media, active ? 'captionsenabled' : 'captionsdisabled');
  8210. } // Wait for the call stack to clear before setting mode='hidden'
  8211. // on the active track - forcing the browser to download it
  8212. setTimeout(function () {
  8213. if (active && _this2.captions.toggled) {
  8214. _this2.captions.currentTrackNode.mode = 'hidden';
  8215. }
  8216. });
  8217. },
  8218. // Set captions by track index
  8219. // Used internally for the currentTrack setter with the passive option forced to false
  8220. set: function set(index) {
  8221. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8222. var tracks = captions.getTracks.call(this); // Disable captions if setting to -1
  8223. if (index === -1) {
  8224. captions.toggle.call(this, false, passive);
  8225. return;
  8226. }
  8227. if (!is$1.number(index)) {
  8228. this.debug.warn('Invalid caption argument', index);
  8229. return;
  8230. }
  8231. if (!(index in tracks)) {
  8232. this.debug.warn('Track not found', index);
  8233. return;
  8234. }
  8235. if (this.captions.currentTrack !== index) {
  8236. this.captions.currentTrack = index;
  8237. var track = tracks[index];
  8238. var _ref = track || {},
  8239. language = _ref.language; // Store reference to node for invalidation on remove
  8240. this.captions.currentTrackNode = track; // Update settings menu
  8241. controls.updateSetting.call(this, 'captions'); // When passive, don't override user preferences
  8242. if (!passive) {
  8243. this.captions.language = language;
  8244. this.storage.set({
  8245. language: language
  8246. });
  8247. } // Handle Vimeo captions
  8248. if (this.isVimeo) {
  8249. this.embed.enableTextTrack(language);
  8250. } // Trigger event
  8251. triggerEvent.call(this, this.media, 'languagechange');
  8252. } // Show captions
  8253. captions.toggle.call(this, true, passive);
  8254. if (this.isHTML5 && this.isVideo) {
  8255. // If we change the active track while a cue is already displayed we need to update it
  8256. captions.updateCues.call(this);
  8257. }
  8258. },
  8259. // Set captions by language
  8260. // Used internally for the language setter with the passive option forced to false
  8261. setLanguage: function setLanguage(input) {
  8262. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  8263. if (!is$1.string(input)) {
  8264. this.debug.warn('Invalid language argument', input);
  8265. return;
  8266. } // Normalize
  8267. var language = input.toLowerCase();
  8268. this.captions.language = language; // Set currentTrack
  8269. var tracks = captions.getTracks.call(this);
  8270. var track = captions.findTrack.call(this, [language]);
  8271. captions.set.call(this, tracks.indexOf(track), passive);
  8272. },
  8273. // Get current valid caption tracks
  8274. // If update is false it will also ignore tracks without metadata
  8275. // This is used to "freeze" the language options when captions.update is false
  8276. getTracks: function getTracks() {
  8277. var _this3 = this;
  8278. var update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8279. // Handle media or textTracks missing or null
  8280. var tracks = Array.from((this.media || {}).textTracks || []); // For HTML5, use cache instead of current tracks when it exists (if captions.update is false)
  8281. // Filter out removed tracks and tracks that aren't captions/subtitles (for example metadata)
  8282. return tracks.filter(function (track) {
  8283. return !_this3.isHTML5 || update || _this3.captions.meta.has(track);
  8284. }).filter(function (track) {
  8285. return ['captions', 'subtitles'].includes(track.kind);
  8286. });
  8287. },
  8288. // Match tracks based on languages and get the first
  8289. findTrack: function findTrack(languages) {
  8290. var _this4 = this;
  8291. var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8292. var tracks = captions.getTracks.call(this);
  8293. var sortIsDefault = function sortIsDefault(track) {
  8294. return Number((_this4.captions.meta.get(track) || {}).default);
  8295. };
  8296. var sorted = Array.from(tracks).sort(function (a, b) {
  8297. return sortIsDefault(b) - sortIsDefault(a);
  8298. });
  8299. var track;
  8300. languages.every(function (language) {
  8301. track = sorted.find(function (t) {
  8302. return t.language === language;
  8303. });
  8304. return !track; // Break iteration if there is a match
  8305. }); // If no match is found but is required, get first
  8306. return track || (force ? sorted[0] : undefined);
  8307. },
  8308. // Get the current track
  8309. getCurrentTrack: function getCurrentTrack() {
  8310. return captions.getTracks.call(this)[this.currentTrack];
  8311. },
  8312. // Get UI label for track
  8313. getLabel: function getLabel(track) {
  8314. var currentTrack = track;
  8315. if (!is$1.track(currentTrack) && support.textTracks && this.captions.toggled) {
  8316. currentTrack = captions.getCurrentTrack.call(this);
  8317. }
  8318. if (is$1.track(currentTrack)) {
  8319. if (!is$1.empty(currentTrack.label)) {
  8320. return currentTrack.label;
  8321. }
  8322. if (!is$1.empty(currentTrack.language)) {
  8323. return track.language.toUpperCase();
  8324. }
  8325. return i18n.get('enabled', this.config);
  8326. }
  8327. return i18n.get('disabled', this.config);
  8328. },
  8329. // Update captions using current track's active cues
  8330. // Also optional array argument in case there isn't any track (ex: vimeo)
  8331. updateCues: function updateCues(input) {
  8332. // Requires UI
  8333. if (!this.supported.ui) {
  8334. return;
  8335. }
  8336. if (!is$1.element(this.elements.captions)) {
  8337. this.debug.warn('No captions element to render to');
  8338. return;
  8339. } // Only accept array or empty input
  8340. if (!is$1.nullOrUndefined(input) && !Array.isArray(input)) {
  8341. this.debug.warn('updateCues: Invalid input', input);
  8342. return;
  8343. }
  8344. var cues = input; // Get cues from track
  8345. if (!cues) {
  8346. var track = captions.getCurrentTrack.call(this);
  8347. cues = Array.from((track || {}).activeCues || []).map(function (cue) {
  8348. return cue.getCueAsHTML();
  8349. }).map(getHTML);
  8350. } // Set new caption text
  8351. var content = cues.map(function (cueText) {
  8352. return cueText.trim();
  8353. }).join('\n');
  8354. var changed = content !== this.elements.captions.innerHTML;
  8355. if (changed) {
  8356. // Empty the container and create a new child element
  8357. emptyElement(this.elements.captions);
  8358. var caption = createElement('span', getAttributesFromSelector(this.config.selectors.caption));
  8359. caption.innerHTML = content;
  8360. this.elements.captions.appendChild(caption); // Trigger event
  8361. triggerEvent.call(this, this.media, 'cuechange');
  8362. }
  8363. }
  8364. };
  8365. // ==========================================================================
  8366. // Plyr default config
  8367. // ==========================================================================
  8368. var defaults$1 = {
  8369. // Disable
  8370. enabled: true,
  8371. // Custom media title
  8372. title: '',
  8373. // Logging to console
  8374. debug: false,
  8375. // Auto play (if supported)
  8376. autoplay: false,
  8377. // Only allow one media playing at once (vimeo only)
  8378. autopause: true,
  8379. // Allow inline playback on iOS (this effects YouTube/Vimeo - HTML5 requires the attribute present)
  8380. // TODO: Remove iosNative fullscreen option in favour of this (logic needs work)
  8381. playsinline: true,
  8382. // Default time to skip when rewind/fast forward
  8383. seekTime: 10,
  8384. // Default volume
  8385. volume: 1,
  8386. muted: false,
  8387. // Pass a custom duration
  8388. duration: null,
  8389. // Display the media duration on load in the current time position
  8390. // If you have opted to display both duration and currentTime, this is ignored
  8391. displayDuration: true,
  8392. // Invert the current time to be a countdown
  8393. invertTime: true,
  8394. // Clicking the currentTime inverts it's value to show time left rather than elapsed
  8395. toggleInvert: true,
  8396. // Force an aspect ratio
  8397. // The format must be `'w:h'` (e.g. `'16:9'`)
  8398. ratio: null,
  8399. // Click video container to play/pause
  8400. clickToPlay: true,
  8401. // Auto hide the controls
  8402. hideControls: true,
  8403. // Reset to start when playback ended
  8404. resetOnEnd: false,
  8405. // Disable the standard context menu
  8406. disableContextMenu: true,
  8407. // Sprite (for icons)
  8408. loadSprite: true,
  8409. iconPrefix: 'plyr',
  8410. iconUrl: '/theme/modules/plyr/plyr.svg',
  8411. // Blank video (used to prevent errors on source change)
  8412. blankVideo: '/theme/modules/plyr/blank.webm',
  8413. // Quality default
  8414. quality: {
  8415. default: 576,
  8416. // The options to display in the UI, if available for the source media
  8417. options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240],
  8418. forced: false,
  8419. onChange: null
  8420. },
  8421. // Set loops
  8422. loop: {
  8423. active: false // start: null,
  8424. // end: null,
  8425. },
  8426. // Speed default and options to display
  8427. speed: {
  8428. selected: 1,
  8429. // The options to display in the UI, if available for the source media (e.g. Vimeo and YouTube only support 0.5x-4x)
  8430. options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4]
  8431. },
  8432. // Keyboard shortcut settings
  8433. keyboard: {
  8434. focused: true,
  8435. global: false
  8436. },
  8437. // Display tooltips
  8438. tooltips: {
  8439. controls: false,
  8440. seek: true
  8441. },
  8442. // Captions settings
  8443. captions: {
  8444. active: false,
  8445. language: 'auto',
  8446. // Listen to new tracks added after Plyr is initialized.
  8447. // This is needed for streaming captions, but may result in unselectable options
  8448. update: false
  8449. },
  8450. // Fullscreen settings
  8451. fullscreen: {
  8452. enabled: true,
  8453. // Allow fullscreen?
  8454. fallback: true,
  8455. // Fallback using full viewport/window
  8456. iosNative: false // Use the native fullscreen in iOS (disables custom controls)
  8457. // Selector for the fullscreen container so contextual / non-player content can remain visible in fullscreen mode
  8458. // Non-ancestors of the player element will be ignored
  8459. // container: null, // defaults to the player element
  8460. },
  8461. // Local storage
  8462. storage: {
  8463. enabled: true,
  8464. key: 'plyr'
  8465. },
  8466. // Default controls
  8467. controls: ['play-large', // 'restart',
  8468. // 'rewind',
  8469. 'play', // 'fast-forward',
  8470. 'progress', 'current-time', // 'duration',
  8471. 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', // 'download',
  8472. 'fullscreen'],
  8473. settings: ['captions', 'quality', 'speed'],
  8474. // Localisation
  8475. i18n: {
  8476. restart: 'Restart',
  8477. rewind: 'Rewind {seektime}s',
  8478. play: 'Play',
  8479. pause: 'Pause',
  8480. fastForward: 'Forward {seektime}s',
  8481. seek: 'Seek',
  8482. seekLabel: '{currentTime} of {duration}',
  8483. played: 'Played',
  8484. buffered: 'Buffered',
  8485. currentTime: 'Current time',
  8486. duration: 'Duration',
  8487. volume: 'Volume',
  8488. mute: 'Mute',
  8489. unmute: 'Unmute',
  8490. enableCaptions: 'Enable captions',
  8491. disableCaptions: 'Disable captions',
  8492. download: 'Download',
  8493. enterFullscreen: 'Enter fullscreen',
  8494. exitFullscreen: 'Exit fullscreen',
  8495. frameTitle: 'Player for {title}',
  8496. captions: 'Captions',
  8497. settings: 'Settings',
  8498. pip: 'PIP',
  8499. menuBack: 'Go back to previous menu',
  8500. speed: 'Speed',
  8501. normal: 'Normal',
  8502. quality: 'Quality',
  8503. loop: 'Loop',
  8504. start: 'Start',
  8505. end: 'End',
  8506. all: 'All',
  8507. reset: 'Reset',
  8508. disabled: 'Disabled',
  8509. enabled: 'Enabled',
  8510. advertisement: 'Ad',
  8511. qualityBadge: {
  8512. 2160: '4K',
  8513. 1440: 'HD',
  8514. 1080: 'HD',
  8515. 720: 'HD',
  8516. 576: 'SD',
  8517. 480: 'SD'
  8518. }
  8519. },
  8520. // URLs
  8521. urls: {
  8522. download: null,
  8523. vimeo: {
  8524. sdk: 'https://player.vimeo.com/api/player.js',
  8525. iframe: 'https://player.vimeo.com/video/{0}?{1}',
  8526. api: 'https://vimeo.com/api/v2/video/{0}.json'
  8527. },
  8528. youtube: {
  8529. sdk: 'https://www.youtube.com/iframe_api',
  8530. api: 'https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}'
  8531. },
  8532. googleIMA: {
  8533. sdk: 'https://imasdk.googleapis.com/js/sdkloader/ima3.js'
  8534. }
  8535. },
  8536. // Custom control listeners
  8537. listeners: {
  8538. seek: null,
  8539. play: null,
  8540. pause: null,
  8541. restart: null,
  8542. rewind: null,
  8543. fastForward: null,
  8544. mute: null,
  8545. volume: null,
  8546. captions: null,
  8547. download: null,
  8548. fullscreen: null,
  8549. pip: null,
  8550. airplay: null,
  8551. speed: null,
  8552. quality: null,
  8553. loop: null,
  8554. language: null
  8555. },
  8556. // Events to watch and bubble
  8557. events: [// Events to watch on HTML5 media elements and bubble
  8558. // https://developer.mozilla.org/en/docs/Web/Guide/Events/Media_events
  8559. 'ended', 'progress', 'stalled', 'playing', 'waiting', 'canplay', 'canplaythrough', 'loadstart', 'loadeddata', 'loadedmetadata', 'timeupdate', 'volumechange', 'play', 'pause', 'error', 'seeking', 'seeked', 'emptied', 'ratechange', 'cuechange', // Custom events
  8560. 'download', 'enterfullscreen', 'exitfullscreen', 'captionsenabled', 'captionsdisabled', 'languagechange', 'controlshidden', 'controlsshown', 'ready', // YouTube
  8561. 'statechange', // Quality
  8562. 'qualitychange', // Ads
  8563. 'adsloaded', 'adscontentpause', 'adscontentresume', 'adstarted', 'adsmidpoint', 'adscomplete', 'adsallcomplete', 'adsimpression', 'adsclick'],
  8564. // Selectors
  8565. // Change these to match your template if using custom HTML
  8566. selectors: {
  8567. editable: 'input, textarea, select, [contenteditable]',
  8568. container: '.plyr',
  8569. controls: {
  8570. container: null,
  8571. wrapper: '.plyr__controls'
  8572. },
  8573. labels: '[data-plyr]',
  8574. buttons: {
  8575. play: '[data-plyr="play"]',
  8576. pause: '[data-plyr="pause"]',
  8577. restart: '[data-plyr="restart"]',
  8578. rewind: '[data-plyr="rewind"]',
  8579. fastForward: '[data-plyr="fast-forward"]',
  8580. mute: '[data-plyr="mute"]',
  8581. captions: '[data-plyr="captions"]',
  8582. download: '[data-plyr="download"]',
  8583. fullscreen: '[data-plyr="fullscreen"]',
  8584. pip: '[data-plyr="pip"]',
  8585. airplay: '[data-plyr="airplay"]',
  8586. settings: '[data-plyr="settings"]',
  8587. loop: '[data-plyr="loop"]'
  8588. },
  8589. inputs: {
  8590. seek: '[data-plyr="seek"]',
  8591. volume: '[data-plyr="volume"]',
  8592. speed: '[data-plyr="speed"]',
  8593. language: '[data-plyr="language"]',
  8594. quality: '[data-plyr="quality"]'
  8595. },
  8596. display: {
  8597. currentTime: '.plyr__time--current',
  8598. duration: '.plyr__time--duration',
  8599. buffer: '.plyr__progress__buffer',
  8600. loop: '.plyr__progress__loop',
  8601. // Used later
  8602. volume: '.plyr__volume--display'
  8603. },
  8604. progress: '.plyr__progress',
  8605. captions: '.plyr__captions',
  8606. caption: '.plyr__caption'
  8607. },
  8608. // Class hooks added to the player in different states
  8609. classNames: {
  8610. type: 'plyr--{0}',
  8611. provider: 'plyr--{0}',
  8612. video: 'plyr__video-wrapper',
  8613. embed: 'plyr__video-embed',
  8614. videoFixedRatio: 'plyr__video-wrapper--fixed-ratio',
  8615. embedContainer: 'plyr__video-embed__container',
  8616. poster: 'plyr__poster',
  8617. posterEnabled: 'plyr__poster-enabled',
  8618. ads: 'plyr__ads',
  8619. control: 'plyr__control',
  8620. controlPressed: 'plyr__control--pressed',
  8621. playing: 'plyr--playing',
  8622. paused: 'plyr--paused',
  8623. stopped: 'plyr--stopped',
  8624. loading: 'plyr--loading',
  8625. hover: 'plyr--hover',
  8626. tooltip: 'plyr__tooltip',
  8627. cues: 'plyr__cues',
  8628. hidden: 'plyr__sr-only',
  8629. hideControls: 'plyr--hide-controls',
  8630. isIos: 'plyr--is-ios',
  8631. isTouch: 'plyr--is-touch',
  8632. uiSupported: 'plyr--full-ui',
  8633. noTransition: 'plyr--no-transition',
  8634. display: {
  8635. time: 'plyr__time'
  8636. },
  8637. menu: {
  8638. value: 'plyr__menu__value',
  8639. badge: 'plyr__badge',
  8640. open: 'plyr--menu-open'
  8641. },
  8642. captions: {
  8643. enabled: 'plyr--captions-enabled',
  8644. active: 'plyr--captions-active'
  8645. },
  8646. fullscreen: {
  8647. enabled: 'plyr--fullscreen-enabled',
  8648. fallback: 'plyr--fullscreen-fallback'
  8649. },
  8650. pip: {
  8651. supported: 'plyr--pip-supported',
  8652. active: 'plyr--pip-active'
  8653. },
  8654. airplay: {
  8655. supported: 'plyr--airplay-supported',
  8656. active: 'plyr--airplay-active'
  8657. },
  8658. tabFocus: 'plyr__tab-focus',
  8659. previewThumbnails: {
  8660. // Tooltip thumbs
  8661. thumbContainer: 'plyr__preview-thumb',
  8662. thumbContainerShown: 'plyr__preview-thumb--is-shown',
  8663. imageContainer: 'plyr__preview-thumb__image-container',
  8664. timeContainer: 'plyr__preview-thumb__time-container',
  8665. // Scrubbing
  8666. scrubbingContainer: 'plyr__preview-scrubbing',
  8667. scrubbingContainerShown: 'plyr__preview-scrubbing--is-shown'
  8668. }
  8669. },
  8670. // Embed attributes
  8671. attributes: {
  8672. embed: {
  8673. provider: 'data-plyr-provider',
  8674. id: 'data-plyr-embed-id'
  8675. }
  8676. },
  8677. // Advertisements plugin
  8678. // Register for an account here: http://vi.ai/publisher-video-monetization/?aid=plyrio
  8679. ads: {
  8680. enabled: false,
  8681. publisherId: '',
  8682. tagUrl: ''
  8683. },
  8684. // Preview Thumbnails plugin
  8685. previewThumbnails: {
  8686. enabled: false,
  8687. src: ''
  8688. },
  8689. // Vimeo plugin
  8690. vimeo: {
  8691. byline: false,
  8692. portrait: false,
  8693. title: false,
  8694. speed: true,
  8695. transparent: false,
  8696. // Whether the owner of the video has a Pro or Business account
  8697. // (which allows us to properly hide controls without CSS hacks, etc)
  8698. premium: false,
  8699. // Custom settings from Plyr
  8700. referrerPolicy: null // https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy
  8701. },
  8702. // YouTube plugin
  8703. youtube: {
  8704. noCookie: true,
  8705. // Whether to use an alternative version of YouTube without cookies
  8706. rel: 0,
  8707. // No related vids
  8708. showinfo: 0,
  8709. // Hide info
  8710. iv_load_policy: 3,
  8711. // Hide annotations
  8712. modestbranding: 1 // Hide logos as much as possible (they still show one in the corner when paused)
  8713. }
  8714. };
  8715. // ==========================================================================
  8716. // Plyr states
  8717. // ==========================================================================
  8718. var pip = {
  8719. active: 'picture-in-picture',
  8720. inactive: 'inline'
  8721. };
  8722. // ==========================================================================
  8723. // Plyr supported types and providers
  8724. // ==========================================================================
  8725. var providers = {
  8726. html5: 'html5',
  8727. youtube: 'youtube',
  8728. vimeo: 'vimeo'
  8729. };
  8730. var types = {
  8731. audio: 'audio',
  8732. video: 'video'
  8733. };
  8734. /**
  8735. * Get provider by URL
  8736. * @param {String} url
  8737. */
  8738. function getProviderByUrl(url) {
  8739. // YouTube
  8740. if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(url)) {
  8741. return providers.youtube;
  8742. } // Vimeo
  8743. if (/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(url)) {
  8744. return providers.vimeo;
  8745. }
  8746. return null;
  8747. }
  8748. // ==========================================================================
  8749. // Console wrapper
  8750. // ==========================================================================
  8751. var noop = function noop() {};
  8752. var Console = /*#__PURE__*/function () {
  8753. function Console() {
  8754. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8755. _classCallCheck(this, Console);
  8756. this.enabled = window.console && enabled;
  8757. if (this.enabled) {
  8758. this.log('Debugging enabled');
  8759. }
  8760. }
  8761. _createClass(Console, [{
  8762. key: "log",
  8763. get: function get() {
  8764. // eslint-disable-next-line no-console
  8765. return this.enabled ? Function.prototype.bind.call(console.log, console) : noop;
  8766. }
  8767. }, {
  8768. key: "warn",
  8769. get: function get() {
  8770. // eslint-disable-next-line no-console
  8771. return this.enabled ? Function.prototype.bind.call(console.warn, console) : noop;
  8772. }
  8773. }, {
  8774. key: "error",
  8775. get: function get() {
  8776. // eslint-disable-next-line no-console
  8777. return this.enabled ? Function.prototype.bind.call(console.error, console) : noop;
  8778. }
  8779. }]);
  8780. return Console;
  8781. }();
  8782. var Fullscreen = /*#__PURE__*/function () {
  8783. function Fullscreen(player) {
  8784. var _this = this;
  8785. _classCallCheck(this, Fullscreen);
  8786. // Keep reference to parent
  8787. this.player = player; // Get prefix
  8788. this.prefix = Fullscreen.prefix;
  8789. this.property = Fullscreen.property; // Scroll position
  8790. this.scrollPosition = {
  8791. x: 0,
  8792. y: 0
  8793. }; // Force the use of 'full window/browser' rather than fullscreen
  8794. this.forceFallback = player.config.fullscreen.fallback === 'force'; // Get the fullscreen element
  8795. // Checks container is an ancestor, defaults to null
  8796. this.player.elements.fullscreen = player.config.fullscreen.container && closest(this.player.elements.container, player.config.fullscreen.container); // Register event listeners
  8797. // Handle event (incase user presses escape etc)
  8798. on.call(this.player, document, this.prefix === 'ms' ? 'MSFullscreenChange' : "".concat(this.prefix, "fullscreenchange"), function () {
  8799. // TODO: Filter for target??
  8800. _this.onChange();
  8801. }); // Fullscreen toggle on double click
  8802. on.call(this.player, this.player.elements.container, 'dblclick', function (event) {
  8803. // Ignore double click in controls
  8804. if (is$1.element(_this.player.elements.controls) && _this.player.elements.controls.contains(event.target)) {
  8805. return;
  8806. }
  8807. _this.toggle();
  8808. }); // Tap focus when in fullscreen
  8809. on.call(this, this.player.elements.container, 'keydown', function (event) {
  8810. return _this.trapFocus(event);
  8811. }); // Update the UI
  8812. this.update();
  8813. } // Determine if native supported
  8814. _createClass(Fullscreen, [{
  8815. key: "onChange",
  8816. value: function onChange() {
  8817. if (!this.enabled) {
  8818. return;
  8819. } // Update toggle button
  8820. var button = this.player.elements.buttons.fullscreen;
  8821. if (is$1.element(button)) {
  8822. button.pressed = this.active;
  8823. } // Trigger an event
  8824. triggerEvent.call(this.player, this.target, this.active ? 'enterfullscreen' : 'exitfullscreen', true);
  8825. }
  8826. }, {
  8827. key: "toggleFallback",
  8828. value: function toggleFallback() {
  8829. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8830. // Store or restore scroll position
  8831. if (toggle) {
  8832. this.scrollPosition = {
  8833. x: window.scrollX || 0,
  8834. y: window.scrollY || 0
  8835. };
  8836. } else {
  8837. window.scrollTo(this.scrollPosition.x, this.scrollPosition.y);
  8838. } // Toggle scroll
  8839. document.body.style.overflow = toggle ? 'hidden' : ''; // Toggle class hook
  8840. toggleClass(this.target, this.player.config.classNames.fullscreen.fallback, toggle); // Force full viewport on iPhone X+
  8841. if (browser.isIos) {
  8842. var viewport = document.head.querySelector('meta[name="viewport"]');
  8843. var property = 'viewport-fit=cover'; // Inject the viewport meta if required
  8844. if (!viewport) {
  8845. viewport = document.createElement('meta');
  8846. viewport.setAttribute('name', 'viewport');
  8847. } // Check if the property already exists
  8848. var hasProperty = is$1.string(viewport.content) && viewport.content.includes(property);
  8849. if (toggle) {
  8850. this.cleanupViewport = !hasProperty;
  8851. if (!hasProperty) {
  8852. viewport.content += ",".concat(property);
  8853. }
  8854. } else if (this.cleanupViewport) {
  8855. viewport.content = viewport.content.split(',').filter(function (part) {
  8856. return part.trim() !== property;
  8857. }).join(',');
  8858. }
  8859. } // Toggle button and fire events
  8860. this.onChange();
  8861. } // Trap focus inside container
  8862. }, {
  8863. key: "trapFocus",
  8864. value: function trapFocus(event) {
  8865. // Bail if iOS, not active, not the tab key
  8866. if (browser.isIos || !this.active || event.key !== 'Tab' || event.keyCode !== 9) {
  8867. return;
  8868. } // Get the current focused element
  8869. var focused = document.activeElement;
  8870. var focusable = getElements.call(this.player, 'a[href], button:not(:disabled), input:not(:disabled), [tabindex]');
  8871. var _focusable = _slicedToArray(focusable, 1),
  8872. first = _focusable[0];
  8873. var last = focusable[focusable.length - 1];
  8874. if (focused === last && !event.shiftKey) {
  8875. // Move focus to first element that can be tabbed if Shift isn't used
  8876. first.focus();
  8877. event.preventDefault();
  8878. } else if (focused === first && event.shiftKey) {
  8879. // Move focus to last element that can be tabbed if Shift is used
  8880. last.focus();
  8881. event.preventDefault();
  8882. }
  8883. } // Update UI
  8884. }, {
  8885. key: "update",
  8886. value: function update() {
  8887. if (this.enabled) {
  8888. var mode;
  8889. if (this.forceFallback) {
  8890. mode = 'Fallback (forced)';
  8891. } else if (Fullscreen.native) {
  8892. mode = 'Native';
  8893. } else {
  8894. mode = 'Fallback';
  8895. }
  8896. this.player.debug.log("".concat(mode, " fullscreen enabled"));
  8897. } else {
  8898. this.player.debug.log('Fullscreen not supported and fallback disabled');
  8899. } // Add styling hook to show button
  8900. toggleClass(this.player.elements.container, this.player.config.classNames.fullscreen.enabled, this.enabled);
  8901. } // Make an element fullscreen
  8902. }, {
  8903. key: "enter",
  8904. value: function enter() {
  8905. if (!this.enabled) {
  8906. return;
  8907. } // iOS native fullscreen doesn't need the request step
  8908. if (browser.isIos && this.player.config.fullscreen.iosNative) {
  8909. this.target.webkitEnterFullscreen();
  8910. } else if (!Fullscreen.native || this.forceFallback) {
  8911. this.toggleFallback(true);
  8912. } else if (!this.prefix) {
  8913. this.target.requestFullscreen({
  8914. navigationUI: 'hide'
  8915. });
  8916. } else if (!is$1.empty(this.prefix)) {
  8917. this.target["".concat(this.prefix, "Request").concat(this.property)]();
  8918. }
  8919. } // Bail from fullscreen
  8920. }, {
  8921. key: "exit",
  8922. value: function exit() {
  8923. if (!this.enabled) {
  8924. return;
  8925. } // iOS native fullscreen
  8926. if (browser.isIos && this.player.config.fullscreen.iosNative) {
  8927. this.target.webkitExitFullscreen();
  8928. silencePromise(this.player.play());
  8929. } else if (!Fullscreen.native || this.forceFallback) {
  8930. this.toggleFallback(false);
  8931. } else if (!this.prefix) {
  8932. (document.cancelFullScreen || document.exitFullscreen).call(document);
  8933. } else if (!is$1.empty(this.prefix)) {
  8934. var action = this.prefix === 'moz' ? 'Cancel' : 'Exit';
  8935. document["".concat(this.prefix).concat(action).concat(this.property)]();
  8936. }
  8937. } // Toggle state
  8938. }, {
  8939. key: "toggle",
  8940. value: function toggle() {
  8941. if (!this.active) {
  8942. this.enter();
  8943. } else {
  8944. this.exit();
  8945. }
  8946. }
  8947. }, {
  8948. key: "usingNative",
  8949. // If we're actually using native
  8950. get: function get() {
  8951. return Fullscreen.native && !this.forceFallback;
  8952. } // Get the prefix for handlers
  8953. }, {
  8954. key: "enabled",
  8955. // Determine if fullscreen is enabled
  8956. get: function get() {
  8957. return (Fullscreen.native || this.player.config.fullscreen.fallback) && this.player.config.fullscreen.enabled && this.player.supported.ui && this.player.isVideo;
  8958. } // Get active state
  8959. }, {
  8960. key: "active",
  8961. get: function get() {
  8962. if (!this.enabled) {
  8963. return false;
  8964. } // Fallback using classname
  8965. if (!Fullscreen.native || this.forceFallback) {
  8966. return hasClass(this.target, this.player.config.classNames.fullscreen.fallback);
  8967. }
  8968. var element = !this.prefix ? document.fullscreenElement : document["".concat(this.prefix).concat(this.property, "Element")];
  8969. return element && element.shadowRoot ? element === this.target.getRootNode().host : element === this.target;
  8970. } // Get target element
  8971. }, {
  8972. key: "target",
  8973. get: function get() {
  8974. return browser.isIos && this.player.config.fullscreen.iosNative ? this.player.media : this.player.elements.fullscreen || this.player.elements.container;
  8975. }
  8976. }], [{
  8977. key: "native",
  8978. get: function get() {
  8979. return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled);
  8980. }
  8981. }, {
  8982. key: "prefix",
  8983. get: function get() {
  8984. // No prefix
  8985. if (is$1.function(document.exitFullscreen)) {
  8986. return '';
  8987. } // Check for fullscreen support by vendor prefix
  8988. var value = '';
  8989. var prefixes = ['webkit', 'moz', 'ms'];
  8990. prefixes.some(function (pre) {
  8991. if (is$1.function(document["".concat(pre, "ExitFullscreen")]) || is$1.function(document["".concat(pre, "CancelFullScreen")])) {
  8992. value = pre;
  8993. return true;
  8994. }
  8995. return false;
  8996. });
  8997. return value;
  8998. }
  8999. }, {
  9000. key: "property",
  9001. get: function get() {
  9002. return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen';
  9003. }
  9004. }]);
  9005. return Fullscreen;
  9006. }();
  9007. // `Math.sign` method implementation
  9008. // https://tc39.github.io/ecma262/#sec-math.sign
  9009. var mathSign = Math.sign || function sign(x) {
  9010. // eslint-disable-next-line no-self-compare
  9011. return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
  9012. };
  9013. // `Math.sign` method
  9014. // https://tc39.github.io/ecma262/#sec-math.sign
  9015. _export({ target: 'Math', stat: true }, {
  9016. sign: mathSign
  9017. });
  9018. // ==========================================================================
  9019. // Load image avoiding xhr/fetch CORS issues
  9020. // Server status can't be obtained this way unfortunately, so this uses "naturalWidth" to determine if the image has loaded
  9021. // By default it checks if it is at least 1px, but you can add a second argument to change this
  9022. // ==========================================================================
  9023. function loadImage(src) {
  9024. var minWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  9025. return new Promise(function (resolve, reject) {
  9026. var image = new Image();
  9027. var handler = function handler() {
  9028. delete image.onload;
  9029. delete image.onerror;
  9030. (image.naturalWidth >= minWidth ? resolve : reject)(image);
  9031. };
  9032. Object.assign(image, {
  9033. onload: handler,
  9034. onerror: handler,
  9035. src: src
  9036. });
  9037. });
  9038. }
  9039. var ui = {
  9040. addStyleHook: function addStyleHook() {
  9041. toggleClass(this.elements.container, this.config.selectors.container.replace('.', ''), true);
  9042. toggleClass(this.elements.container, this.config.classNames.uiSupported, this.supported.ui);
  9043. },
  9044. // Toggle native HTML5 media controls
  9045. toggleNativeControls: function toggleNativeControls() {
  9046. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9047. if (toggle && this.isHTML5) {
  9048. this.media.setAttribute('controls', '');
  9049. } else {
  9050. this.media.removeAttribute('controls');
  9051. }
  9052. },
  9053. // Setup the UI
  9054. build: function build() {
  9055. var _this = this;
  9056. // Re-attach media element listeners
  9057. // TODO: Use event bubbling?
  9058. this.listeners.media(); // Don't setup interface if no support
  9059. if (!this.supported.ui) {
  9060. this.debug.warn("Basic support only for ".concat(this.provider, " ").concat(this.type)); // Restore native controls
  9061. ui.toggleNativeControls.call(this, true); // Bail
  9062. return;
  9063. } // Inject custom controls if not present
  9064. if (!is$1.element(this.elements.controls)) {
  9065. // Inject custom controls
  9066. controls.inject.call(this); // Re-attach control listeners
  9067. this.listeners.controls();
  9068. } // Remove native controls
  9069. ui.toggleNativeControls.call(this); // Setup captions for HTML5
  9070. if (this.isHTML5) {
  9071. captions.setup.call(this);
  9072. } // Reset volume
  9073. this.volume = null; // Reset mute state
  9074. this.muted = null; // Reset loop state
  9075. this.loop = null; // Reset quality setting
  9076. this.quality = null; // Reset speed
  9077. this.speed = null; // Reset volume display
  9078. controls.updateVolume.call(this); // Reset time display
  9079. controls.timeUpdate.call(this); // Update the UI
  9080. ui.checkPlaying.call(this); // Check for picture-in-picture support
  9081. toggleClass(this.elements.container, this.config.classNames.pip.supported, support.pip && this.isHTML5 && this.isVideo); // Check for airplay support
  9082. toggleClass(this.elements.container, this.config.classNames.airplay.supported, support.airplay && this.isHTML5); // Add iOS class
  9083. toggleClass(this.elements.container, this.config.classNames.isIos, browser.isIos); // Add touch class
  9084. toggleClass(this.elements.container, this.config.classNames.isTouch, this.touch); // Ready for API calls
  9085. this.ready = true; // Ready event at end of execution stack
  9086. setTimeout(function () {
  9087. triggerEvent.call(_this, _this.media, 'ready');
  9088. }, 0); // Set the title
  9089. ui.setTitle.call(this); // Assure the poster image is set, if the property was added before the element was created
  9090. if (this.poster) {
  9091. ui.setPoster.call(this, this.poster, false).catch(function () {});
  9092. } // Manually set the duration if user has overridden it.
  9093. // The event listeners for it doesn't get called if preload is disabled (#701)
  9094. if (this.config.duration) {
  9095. controls.durationUpdate.call(this);
  9096. }
  9097. },
  9098. // Setup aria attribute for play and iframe title
  9099. setTitle: function setTitle() {
  9100. // Find the current text
  9101. var label = i18n.get('play', this.config); // If there's a media title set, use that for the label
  9102. if (is$1.string(this.config.title) && !is$1.empty(this.config.title)) {
  9103. label += ", ".concat(this.config.title);
  9104. } // If there's a play button, set label
  9105. Array.from(this.elements.buttons.play || []).forEach(function (button) {
  9106. button.setAttribute('aria-label', label);
  9107. }); // Set iframe title
  9108. // https://github.com/sampotts/plyr/issues/124
  9109. if (this.isEmbed) {
  9110. var iframe = getElement.call(this, 'iframe');
  9111. if (!is$1.element(iframe)) {
  9112. return;
  9113. } // Default to media type
  9114. var title = !is$1.empty(this.config.title) ? this.config.title : 'video';
  9115. var format = i18n.get('frameTitle', this.config);
  9116. iframe.setAttribute('title', format.replace('{title}', title));
  9117. }
  9118. },
  9119. // Toggle poster
  9120. togglePoster: function togglePoster(enable) {
  9121. toggleClass(this.elements.container, this.config.classNames.posterEnabled, enable);
  9122. },
  9123. // Set the poster image (async)
  9124. // Used internally for the poster setter, with the passive option forced to false
  9125. setPoster: function setPoster(poster) {
  9126. var _this2 = this;
  9127. var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  9128. // Don't override if call is passive
  9129. if (passive && this.poster) {
  9130. return Promise.reject(new Error('Poster already set'));
  9131. } // Set property synchronously to respect the call order
  9132. this.media.setAttribute('data-poster', poster); // Wait until ui is ready
  9133. return ready.call(this) // Load image
  9134. .then(function () {
  9135. return loadImage(poster);
  9136. }).catch(function (err) {
  9137. // Hide poster on error unless it's been set by another call
  9138. if (poster === _this2.poster) {
  9139. ui.togglePoster.call(_this2, false);
  9140. } // Rethrow
  9141. throw err;
  9142. }).then(function () {
  9143. // Prevent race conditions
  9144. if (poster !== _this2.poster) {
  9145. throw new Error('setPoster cancelled by later call to setPoster');
  9146. }
  9147. }).then(function () {
  9148. Object.assign(_this2.elements.poster.style, {
  9149. backgroundImage: "url('".concat(poster, "')"),
  9150. // Reset backgroundSize as well (since it can be set to "cover" for padded thumbnails for youtube)
  9151. backgroundSize: ''
  9152. });
  9153. ui.togglePoster.call(_this2, true);
  9154. return poster;
  9155. });
  9156. },
  9157. // Check playing state
  9158. checkPlaying: function checkPlaying(event) {
  9159. var _this3 = this;
  9160. // Class hooks
  9161. toggleClass(this.elements.container, this.config.classNames.playing, this.playing);
  9162. toggleClass(this.elements.container, this.config.classNames.paused, this.paused);
  9163. toggleClass(this.elements.container, this.config.classNames.stopped, this.stopped); // Set state
  9164. Array.from(this.elements.buttons.play || []).forEach(function (target) {
  9165. Object.assign(target, {
  9166. pressed: _this3.playing
  9167. });
  9168. target.setAttribute('aria-label', i18n.get(_this3.playing ? 'pause' : 'play', _this3.config));
  9169. }); // Only update controls on non timeupdate events
  9170. if (is$1.event(event) && event.type === 'timeupdate') {
  9171. return;
  9172. } // Toggle controls
  9173. ui.toggleControls.call(this);
  9174. },
  9175. // Check if media is loading
  9176. checkLoading: function checkLoading(event) {
  9177. var _this4 = this;
  9178. this.loading = ['stalled', 'waiting'].includes(event.type); // Clear timer
  9179. clearTimeout(this.timers.loading); // Timer to prevent flicker when seeking
  9180. this.timers.loading = setTimeout(function () {
  9181. // Update progress bar loading class state
  9182. toggleClass(_this4.elements.container, _this4.config.classNames.loading, _this4.loading); // Update controls visibility
  9183. ui.toggleControls.call(_this4);
  9184. }, this.loading ? 250 : 0);
  9185. },
  9186. // Toggle controls based on state and `force` argument
  9187. toggleControls: function toggleControls(force) {
  9188. var controlsElement = this.elements.controls;
  9189. if (controlsElement && this.config.hideControls) {
  9190. // 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.)
  9191. var recentTouchSeek = this.touch && this.lastSeekTime + 2000 > Date.now(); // Show controls if force, loading, paused, button interaction, or recent seek, otherwise hide
  9192. this.toggleControls(Boolean(force || this.loading || this.paused || controlsElement.pressed || controlsElement.hover || recentTouchSeek));
  9193. }
  9194. },
  9195. // Migrate any custom properties from the media to the parent
  9196. migrateStyles: function migrateStyles() {
  9197. var _this5 = this;
  9198. // Loop through values (as they are the keys when the object is spread 🤔)
  9199. Object.values(_objectSpread2({}, this.media.style)) // We're only fussed about Plyr specific properties
  9200. .filter(function (key) {
  9201. return !is$1.empty(key) && key.startsWith('--plyr');
  9202. }).forEach(function (key) {
  9203. // Set on the container
  9204. _this5.elements.container.style.setProperty(key, _this5.media.style.getPropertyValue(key)); // Clean up from media element
  9205. _this5.media.style.removeProperty(key);
  9206. }); // Remove attribute if empty
  9207. if (is$1.empty(this.media.style)) {
  9208. this.media.removeAttribute('style');
  9209. }
  9210. }
  9211. };
  9212. var Listeners = /*#__PURE__*/function () {
  9213. function Listeners(player) {
  9214. _classCallCheck(this, Listeners);
  9215. this.player = player;
  9216. this.lastKey = null;
  9217. this.focusTimer = null;
  9218. this.lastKeyDown = null;
  9219. this.handleKey = this.handleKey.bind(this);
  9220. this.toggleMenu = this.toggleMenu.bind(this);
  9221. this.setTabFocus = this.setTabFocus.bind(this);
  9222. this.firstTouch = this.firstTouch.bind(this);
  9223. } // Handle key presses
  9224. _createClass(Listeners, [{
  9225. key: "handleKey",
  9226. value: function handleKey(event) {
  9227. var player = this.player;
  9228. var elements = player.elements;
  9229. var code = event.keyCode ? event.keyCode : event.which;
  9230. var pressed = event.type === 'keydown';
  9231. var repeat = pressed && code === this.lastKey; // Bail if a modifier key is set
  9232. if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
  9233. return;
  9234. } // If the event is bubbled from the media element
  9235. // Firefox doesn't get the keycode for whatever reason
  9236. if (!is$1.number(code)) {
  9237. return;
  9238. } // Seek by the number keys
  9239. var seekByKey = function seekByKey() {
  9240. // Divide the max duration into 10th's and times by the number value
  9241. player.currentTime = player.duration / 10 * (code - 48);
  9242. }; // Handle the key on keydown
  9243. // Reset on keyup
  9244. if (pressed) {
  9245. // Check focused element
  9246. // and if the focused element is not editable (e.g. text input)
  9247. // and any that accept key input http://webaim.org/techniques/keyboard/
  9248. var focused = document.activeElement;
  9249. if (is$1.element(focused)) {
  9250. var editable = player.config.selectors.editable;
  9251. var seek = elements.inputs.seek;
  9252. if (focused !== seek && matches$1(focused, editable)) {
  9253. return;
  9254. }
  9255. if (event.which === 32 && matches$1(focused, 'button, [role^="menuitem"]')) {
  9256. return;
  9257. }
  9258. } // Which keycodes should we prevent default
  9259. 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)
  9260. if (preventDefault.includes(code)) {
  9261. event.preventDefault();
  9262. event.stopPropagation();
  9263. }
  9264. switch (code) {
  9265. case 48:
  9266. case 49:
  9267. case 50:
  9268. case 51:
  9269. case 52:
  9270. case 53:
  9271. case 54:
  9272. case 55:
  9273. case 56:
  9274. case 57:
  9275. // 0-9
  9276. if (!repeat) {
  9277. seekByKey();
  9278. }
  9279. break;
  9280. case 32:
  9281. case 75:
  9282. // Space and K key
  9283. if (!repeat) {
  9284. silencePromise(player.togglePlay());
  9285. }
  9286. break;
  9287. case 38:
  9288. // Arrow up
  9289. player.increaseVolume(0.1);
  9290. break;
  9291. case 40:
  9292. // Arrow down
  9293. player.decreaseVolume(0.1);
  9294. break;
  9295. case 77:
  9296. // M key
  9297. if (!repeat) {
  9298. player.muted = !player.muted;
  9299. }
  9300. break;
  9301. case 39:
  9302. // Arrow forward
  9303. player.forward();
  9304. break;
  9305. case 37:
  9306. // Arrow back
  9307. player.rewind();
  9308. break;
  9309. case 70:
  9310. // F key
  9311. player.fullscreen.toggle();
  9312. break;
  9313. case 67:
  9314. // C key
  9315. if (!repeat) {
  9316. player.toggleCaptions();
  9317. }
  9318. break;
  9319. case 76:
  9320. // L key
  9321. player.loop = !player.loop;
  9322. break;
  9323. } // Escape is handle natively when in full screen
  9324. // So we only need to worry about non native
  9325. if (code === 27 && !player.fullscreen.usingNative && player.fullscreen.active) {
  9326. player.fullscreen.toggle();
  9327. } // Store last code for next cycle
  9328. this.lastKey = code;
  9329. } else {
  9330. this.lastKey = null;
  9331. }
  9332. } // Toggle menu
  9333. }, {
  9334. key: "toggleMenu",
  9335. value: function toggleMenu(event) {
  9336. controls.toggleMenu.call(this.player, event);
  9337. } // Device is touch enabled
  9338. }, {
  9339. key: "firstTouch",
  9340. value: function firstTouch() {
  9341. var player = this.player;
  9342. var elements = player.elements;
  9343. player.touch = true; // Add touch class
  9344. toggleClass(elements.container, player.config.classNames.isTouch, true);
  9345. }
  9346. }, {
  9347. key: "setTabFocus",
  9348. value: function setTabFocus(event) {
  9349. var player = this.player;
  9350. var elements = player.elements;
  9351. clearTimeout(this.focusTimer); // Ignore any key other than tab
  9352. if (event.type === 'keydown' && event.which !== 9) {
  9353. return;
  9354. } // Store reference to event timeStamp
  9355. if (event.type === 'keydown') {
  9356. this.lastKeyDown = event.timeStamp;
  9357. } // Remove current classes
  9358. var removeCurrent = function removeCurrent() {
  9359. var className = player.config.classNames.tabFocus;
  9360. var current = getElements.call(player, ".".concat(className));
  9361. toggleClass(current, className, false);
  9362. }; // Determine if a key was pressed to trigger this event
  9363. var wasKeyDown = event.timeStamp - this.lastKeyDown <= 20; // Ignore focus events if a key was pressed prior
  9364. if (event.type === 'focus' && !wasKeyDown) {
  9365. return;
  9366. } // Remove all current
  9367. removeCurrent(); // Delay the adding of classname until the focus has changed
  9368. // This event fires before the focusin event
  9369. if (event.type !== 'focusout') {
  9370. this.focusTimer = setTimeout(function () {
  9371. var focused = document.activeElement; // Ignore if current focus element isn't inside the player
  9372. if (!elements.container.contains(focused)) {
  9373. return;
  9374. }
  9375. toggleClass(document.activeElement, player.config.classNames.tabFocus, true);
  9376. }, 10);
  9377. }
  9378. } // Global window & document listeners
  9379. }, {
  9380. key: "global",
  9381. value: function global() {
  9382. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  9383. var player = this.player; // Keyboard shortcuts
  9384. if (player.config.keyboard.global) {
  9385. toggleListener.call(player, window, 'keydown keyup', this.handleKey, toggle, false);
  9386. } // Click anywhere closes menu
  9387. toggleListener.call(player, document.body, 'click', this.toggleMenu, toggle); // Detect touch by events
  9388. once.call(player, document.body, 'touchstart', this.firstTouch); // Tab focus detection
  9389. toggleListener.call(player, document.body, 'keydown focus blur focusout', this.setTabFocus, toggle, false, true);
  9390. } // Container listeners
  9391. }, {
  9392. key: "container",
  9393. value: function container() {
  9394. var player = this.player;
  9395. var config = player.config,
  9396. elements = player.elements,
  9397. timers = player.timers; // Keyboard shortcuts
  9398. if (!config.keyboard.global && config.keyboard.focused) {
  9399. on.call(player, elements.container, 'keydown keyup', this.handleKey, false);
  9400. } // Toggle controls on mouse events and entering fullscreen
  9401. on.call(player, elements.container, 'mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen', function (event) {
  9402. var controlsElement = elements.controls; // Remove button states for fullscreen
  9403. if (controlsElement && event.type === 'enterfullscreen') {
  9404. controlsElement.pressed = false;
  9405. controlsElement.hover = false;
  9406. } // Show, then hide after a timeout unless another control event occurs
  9407. var show = ['touchstart', 'touchmove', 'mousemove'].includes(event.type);
  9408. var delay = 0;
  9409. if (show) {
  9410. ui.toggleControls.call(player, true); // Use longer timeout for touch devices
  9411. delay = player.touch ? 3000 : 2000;
  9412. } // Clear timer
  9413. clearTimeout(timers.controls); // Set new timer to prevent flicker when seeking
  9414. timers.controls = setTimeout(function () {
  9415. return ui.toggleControls.call(player, false);
  9416. }, delay);
  9417. }); // Set a gutter for Vimeo
  9418. var setGutter = function setGutter(ratio, padding, toggle) {
  9419. if (!player.isVimeo || player.config.vimeo.premium) {
  9420. return;
  9421. }
  9422. var target = player.elements.wrapper.firstChild;
  9423. var _ratio = _slicedToArray(ratio, 2),
  9424. y = _ratio[1];
  9425. var _getAspectRatio$call = getAspectRatio.call(player),
  9426. _getAspectRatio$call2 = _slicedToArray(_getAspectRatio$call, 2),
  9427. videoX = _getAspectRatio$call2[0],
  9428. videoY = _getAspectRatio$call2[1];
  9429. target.style.maxWidth = toggle ? "".concat(y / videoY * videoX, "px") : null;
  9430. target.style.margin = toggle ? '0 auto' : null;
  9431. }; // Resize on fullscreen change
  9432. var setPlayerSize = function setPlayerSize(measure) {
  9433. // If we don't need to measure the viewport
  9434. if (!measure) {
  9435. return setAspectRatio.call(player);
  9436. }
  9437. var rect = elements.container.getBoundingClientRect();
  9438. var width = rect.width,
  9439. height = rect.height;
  9440. return setAspectRatio.call(player, "".concat(width, ":").concat(height));
  9441. };
  9442. var resized = function resized() {
  9443. clearTimeout(timers.resized);
  9444. timers.resized = setTimeout(setPlayerSize, 50);
  9445. };
  9446. on.call(player, elements.container, 'enterfullscreen exitfullscreen', function (event) {
  9447. var _player$fullscreen = player.fullscreen,
  9448. target = _player$fullscreen.target,
  9449. usingNative = _player$fullscreen.usingNative; // Ignore events not from target
  9450. if (target !== elements.container) {
  9451. return;
  9452. } // If it's not an embed and no ratio specified
  9453. if (!player.isEmbed && is$1.empty(player.config.ratio)) {
  9454. return;
  9455. }
  9456. var isEnter = event.type === 'enterfullscreen'; // Set the player size when entering fullscreen to viewport size
  9457. var _setPlayerSize = setPlayerSize(isEnter),
  9458. padding = _setPlayerSize.padding,
  9459. ratio = _setPlayerSize.ratio; // Set Vimeo gutter
  9460. setGutter(ratio, padding, isEnter); // If not using native browser fullscreen API, we need to check for resizes of viewport
  9461. if (!usingNative) {
  9462. if (isEnter) {
  9463. on.call(player, window, 'resize', resized);
  9464. } else {
  9465. off.call(player, window, 'resize', resized);
  9466. }
  9467. }
  9468. });
  9469. } // Listen for media events
  9470. }, {
  9471. key: "media",
  9472. value: function media() {
  9473. var _this = this;
  9474. var player = this.player;
  9475. var elements = player.elements; // Time change on media
  9476. on.call(player, player.media, 'timeupdate seeking seeked', function (event) {
  9477. return controls.timeUpdate.call(player, event);
  9478. }); // Display duration
  9479. on.call(player, player.media, 'durationchange loadeddata loadedmetadata', function (event) {
  9480. return controls.durationUpdate.call(player, event);
  9481. }); // Handle the media finishing
  9482. on.call(player, player.media, 'ended', function () {
  9483. // Show poster on end
  9484. if (player.isHTML5 && player.isVideo && player.config.resetOnEnd) {
  9485. // Restart
  9486. player.restart(); // Call pause otherwise IE11 will start playing the video again
  9487. player.pause();
  9488. }
  9489. }); // Check for buffer progress
  9490. on.call(player, player.media, 'progress playing seeking seeked', function (event) {
  9491. return controls.updateProgress.call(player, event);
  9492. }); // Handle volume changes
  9493. on.call(player, player.media, 'volumechange', function (event) {
  9494. return controls.updateVolume.call(player, event);
  9495. }); // Handle play/pause
  9496. on.call(player, player.media, 'playing play pause ended emptied timeupdate', function (event) {
  9497. return ui.checkPlaying.call(player, event);
  9498. }); // Loading state
  9499. on.call(player, player.media, 'waiting canplay seeked playing', function (event) {
  9500. return ui.checkLoading.call(player, event);
  9501. }); // Click video
  9502. if (player.supported.ui && player.config.clickToPlay && !player.isAudio) {
  9503. // Re-fetch the wrapper
  9504. var wrapper = getElement.call(player, ".".concat(player.config.classNames.video)); // Bail if there's no wrapper (this should never happen)
  9505. if (!is$1.element(wrapper)) {
  9506. return;
  9507. } // On click play, pause or restart
  9508. on.call(player, elements.container, 'click', function (event) {
  9509. var targets = [elements.container, wrapper]; // Ignore if click if not container or in video wrapper
  9510. if (!targets.includes(event.target) && !wrapper.contains(event.target)) {
  9511. return;
  9512. } // Touch devices will just show controls (if hidden)
  9513. if (player.touch && player.config.hideControls) {
  9514. return;
  9515. }
  9516. if (player.ended) {
  9517. _this.proxy(event, player.restart, 'restart');
  9518. _this.proxy(event, function () {
  9519. silencePromise(player.play());
  9520. }, 'play');
  9521. } else {
  9522. _this.proxy(event, function () {
  9523. silencePromise(player.togglePlay());
  9524. }, 'play');
  9525. }
  9526. });
  9527. } // Disable right click
  9528. if (player.supported.ui && player.config.disableContextMenu) {
  9529. on.call(player, elements.wrapper, 'contextmenu', function (event) {
  9530. event.preventDefault();
  9531. }, false);
  9532. } // Volume change
  9533. on.call(player, player.media, 'volumechange', function () {
  9534. // Save to storage
  9535. player.storage.set({
  9536. volume: player.volume,
  9537. muted: player.muted
  9538. });
  9539. }); // Speed change
  9540. on.call(player, player.media, 'ratechange', function () {
  9541. // Update UI
  9542. controls.updateSetting.call(player, 'speed'); // Save to storage
  9543. player.storage.set({
  9544. speed: player.speed
  9545. });
  9546. }); // Quality change
  9547. on.call(player, player.media, 'qualitychange', function (event) {
  9548. // Update UI
  9549. controls.updateSetting.call(player, 'quality', null, event.detail.quality);
  9550. }); // Update download link when ready and if quality changes
  9551. on.call(player, player.media, 'ready qualitychange', function () {
  9552. controls.setDownloadUrl.call(player);
  9553. }); // Proxy events to container
  9554. // Bubble up key events for Edge
  9555. var proxyEvents = player.config.events.concat(['keyup', 'keydown']).join(' ');
  9556. on.call(player, player.media, proxyEvents, function (event) {
  9557. var _event$detail = event.detail,
  9558. detail = _event$detail === void 0 ? {} : _event$detail; // Get error details from media
  9559. if (event.type === 'error') {
  9560. detail = player.media.error;
  9561. }
  9562. triggerEvent.call(player, elements.container, event.type, true, detail);
  9563. });
  9564. } // Run default and custom handlers
  9565. }, {
  9566. key: "proxy",
  9567. value: function proxy(event, defaultHandler, customHandlerKey) {
  9568. var player = this.player;
  9569. var customHandler = player.config.listeners[customHandlerKey];
  9570. var hasCustomHandler = is$1.function(customHandler);
  9571. var returned = true; // Execute custom handler
  9572. if (hasCustomHandler) {
  9573. returned = customHandler.call(player, event);
  9574. } // Only call default handler if not prevented in custom handler
  9575. if (returned !== false && is$1.function(defaultHandler)) {
  9576. defaultHandler.call(player, event);
  9577. }
  9578. } // Trigger custom and default handlers
  9579. }, {
  9580. key: "bind",
  9581. value: function bind(element, type, defaultHandler, customHandlerKey) {
  9582. var _this2 = this;
  9583. var passive = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  9584. var player = this.player;
  9585. var customHandler = player.config.listeners[customHandlerKey];
  9586. var hasCustomHandler = is$1.function(customHandler);
  9587. on.call(player, element, type, function (event) {
  9588. return _this2.proxy(event, defaultHandler, customHandlerKey);
  9589. }, passive && !hasCustomHandler);
  9590. } // Listen for control events
  9591. }, {
  9592. key: "controls",
  9593. value: function controls$1() {
  9594. var _this3 = this;
  9595. var player = this.player;
  9596. var elements = player.elements; // IE doesn't support input event, so we fallback to change
  9597. var inputEvent = browser.isIE ? 'change' : 'input'; // Play/pause toggle
  9598. if (elements.buttons.play) {
  9599. Array.from(elements.buttons.play).forEach(function (button) {
  9600. _this3.bind(button, 'click', function () {
  9601. silencePromise(player.togglePlay());
  9602. }, 'play');
  9603. });
  9604. } // Pause
  9605. this.bind(elements.buttons.restart, 'click', player.restart, 'restart'); // Rewind
  9606. this.bind(elements.buttons.rewind, 'click', player.rewind, 'rewind'); // Rewind
  9607. this.bind(elements.buttons.fastForward, 'click', player.forward, 'fastForward'); // Mute toggle
  9608. this.bind(elements.buttons.mute, 'click', function () {
  9609. player.muted = !player.muted;
  9610. }, 'mute'); // Captions toggle
  9611. this.bind(elements.buttons.captions, 'click', function () {
  9612. return player.toggleCaptions();
  9613. }); // Download
  9614. this.bind(elements.buttons.download, 'click', function () {
  9615. triggerEvent.call(player, player.media, 'download');
  9616. }, 'download'); // Fullscreen toggle
  9617. this.bind(elements.buttons.fullscreen, 'click', function () {
  9618. player.fullscreen.toggle();
  9619. }, 'fullscreen'); // Picture-in-Picture
  9620. this.bind(elements.buttons.pip, 'click', function () {
  9621. player.pip = 'toggle';
  9622. }, 'pip'); // Airplay
  9623. this.bind(elements.buttons.airplay, 'click', player.airplay, 'airplay'); // Settings menu - click toggle
  9624. this.bind(elements.buttons.settings, 'click', function (event) {
  9625. // Prevent the document click listener closing the menu
  9626. event.stopPropagation();
  9627. event.preventDefault();
  9628. controls.toggleMenu.call(player, event);
  9629. }, null, false); // Can't be passive as we're preventing default
  9630. // Settings menu - keyboard toggle
  9631. // We have to bind to keyup otherwise Firefox triggers a click when a keydown event handler shifts focus
  9632. // https://bugzilla.mozilla.org/show_bug.cgi?id=1220143
  9633. this.bind(elements.buttons.settings, 'keyup', function (event) {
  9634. var code = event.which; // We only care about space and return
  9635. if (![13, 32].includes(code)) {
  9636. return;
  9637. } // Because return triggers a click anyway, all we need to do is set focus
  9638. if (code === 13) {
  9639. controls.focusFirstMenuItem.call(player, null, true);
  9640. return;
  9641. } // Prevent scroll
  9642. event.preventDefault(); // Prevent playing video (Firefox)
  9643. event.stopPropagation(); // Toggle menu
  9644. controls.toggleMenu.call(player, event);
  9645. }, null, false // Can't be passive as we're preventing default
  9646. ); // Escape closes menu
  9647. this.bind(elements.settings.menu, 'keydown', function (event) {
  9648. if (event.which === 27) {
  9649. controls.toggleMenu.call(player, event);
  9650. }
  9651. }); // Set range input alternative "value", which matches the tooltip time (#954)
  9652. this.bind(elements.inputs.seek, 'mousedown mousemove', function (event) {
  9653. var rect = elements.progress.getBoundingClientRect();
  9654. var percent = 100 / rect.width * (event.pageX - rect.left);
  9655. event.currentTarget.setAttribute('seek-value', percent);
  9656. }); // Pause while seeking
  9657. this.bind(elements.inputs.seek, 'mousedown mouseup keydown keyup touchstart touchend', function (event) {
  9658. var seek = event.currentTarget;
  9659. var code = event.keyCode ? event.keyCode : event.which;
  9660. var attribute = 'play-on-seeked';
  9661. if (is$1.keyboardEvent(event) && code !== 39 && code !== 37) {
  9662. return;
  9663. } // Record seek time so we can prevent hiding controls for a few seconds after seek
  9664. player.lastSeekTime = Date.now(); // Was playing before?
  9665. var play = seek.hasAttribute(attribute); // Done seeking
  9666. var done = ['mouseup', 'touchend', 'keyup'].includes(event.type); // If we're done seeking and it was playing, resume playback
  9667. if (play && done) {
  9668. seek.removeAttribute(attribute);
  9669. silencePromise(player.play());
  9670. } else if (!done && player.playing) {
  9671. seek.setAttribute(attribute, '');
  9672. player.pause();
  9673. }
  9674. }); // Fix range inputs on iOS
  9675. // Super weird iOS bug where after you interact with an <input type="range">,
  9676. // it takes over further interactions on the page. This is a hack
  9677. if (browser.isIos) {
  9678. var inputs = getElements.call(player, 'input[type="range"]');
  9679. Array.from(inputs).forEach(function (input) {
  9680. return _this3.bind(input, inputEvent, function (event) {
  9681. return repaint(event.target);
  9682. });
  9683. });
  9684. } // Seek
  9685. this.bind(elements.inputs.seek, inputEvent, function (event) {
  9686. var seek = event.currentTarget; // If it exists, use seek-value instead of "value" for consistency with tooltip time (#954)
  9687. var seekTo = seek.getAttribute('seek-value');
  9688. if (is$1.empty(seekTo)) {
  9689. seekTo = seek.value;
  9690. }
  9691. seek.removeAttribute('seek-value');
  9692. player.currentTime = seekTo / seek.max * player.duration;
  9693. }, 'seek'); // Seek tooltip
  9694. this.bind(elements.progress, 'mouseenter mouseleave mousemove', function (event) {
  9695. return controls.updateSeekTooltip.call(player, event);
  9696. }); // Preview thumbnails plugin
  9697. // TODO: Really need to work on some sort of plug-in wide event bus or pub-sub for this
  9698. this.bind(elements.progress, 'mousemove touchmove', function (event) {
  9699. var previewThumbnails = player.previewThumbnails;
  9700. if (previewThumbnails && previewThumbnails.loaded) {
  9701. previewThumbnails.startMove(event);
  9702. }
  9703. }); // Hide thumbnail preview - on mouse click, mouse leave, and video play/seek. All four are required, e.g., for buffering
  9704. this.bind(elements.progress, 'mouseleave touchend click', function () {
  9705. var previewThumbnails = player.previewThumbnails;
  9706. if (previewThumbnails && previewThumbnails.loaded) {
  9707. previewThumbnails.endMove(false, true);
  9708. }
  9709. }); // Show scrubbing preview
  9710. this.bind(elements.progress, 'mousedown touchstart', function (event) {
  9711. var previewThumbnails = player.previewThumbnails;
  9712. if (previewThumbnails && previewThumbnails.loaded) {
  9713. previewThumbnails.startScrubbing(event);
  9714. }
  9715. });
  9716. this.bind(elements.progress, 'mouseup touchend', function (event) {
  9717. var previewThumbnails = player.previewThumbnails;
  9718. if (previewThumbnails && previewThumbnails.loaded) {
  9719. previewThumbnails.endScrubbing(event);
  9720. }
  9721. }); // Polyfill for lower fill in <input type="range"> for webkit
  9722. if (browser.isWebkit) {
  9723. Array.from(getElements.call(player, 'input[type="range"]')).forEach(function (element) {
  9724. _this3.bind(element, 'input', function (event) {
  9725. return controls.updateRangeFill.call(player, event.target);
  9726. });
  9727. });
  9728. } // Current time invert
  9729. // Only if one time element is used for both currentTime and duration
  9730. if (player.config.toggleInvert && !is$1.element(elements.display.duration)) {
  9731. this.bind(elements.display.currentTime, 'click', function () {
  9732. // Do nothing if we're at the start
  9733. if (player.currentTime === 0) {
  9734. return;
  9735. }
  9736. player.config.invertTime = !player.config.invertTime;
  9737. controls.timeUpdate.call(player);
  9738. });
  9739. } // Volume
  9740. this.bind(elements.inputs.volume, inputEvent, function (event) {
  9741. player.volume = event.target.value;
  9742. }, 'volume'); // Update controls.hover state (used for ui.toggleControls to avoid hiding when interacting)
  9743. this.bind(elements.controls, 'mouseenter mouseleave', function (event) {
  9744. elements.controls.hover = !player.touch && event.type === 'mouseenter';
  9745. }); // Also update controls.hover state for any non-player children of fullscreen element (as above)
  9746. if (elements.fullscreen) {
  9747. Array.from(elements.fullscreen.children).filter(function (c) {
  9748. return !c.contains(elements.container);
  9749. }).forEach(function (child) {
  9750. _this3.bind(child, 'mouseenter mouseleave', function (event) {
  9751. elements.controls.hover = !player.touch && event.type === 'mouseenter';
  9752. });
  9753. });
  9754. } // Update controls.pressed state (used for ui.toggleControls to avoid hiding when interacting)
  9755. this.bind(elements.controls, 'mousedown mouseup touchstart touchend touchcancel', function (event) {
  9756. elements.controls.pressed = ['mousedown', 'touchstart'].includes(event.type);
  9757. }); // Show controls when they receive focus (e.g., when using keyboard tab key)
  9758. this.bind(elements.controls, 'focusin', function () {
  9759. var config = player.config,
  9760. timers = player.timers; // Skip transition to prevent focus from scrolling the parent element
  9761. toggleClass(elements.controls, config.classNames.noTransition, true); // Toggle
  9762. ui.toggleControls.call(player, true); // Restore transition
  9763. setTimeout(function () {
  9764. toggleClass(elements.controls, config.classNames.noTransition, false);
  9765. }, 0); // Delay a little more for mouse users
  9766. var delay = _this3.touch ? 3000 : 4000; // Clear timer
  9767. clearTimeout(timers.controls); // Hide again after delay
  9768. timers.controls = setTimeout(function () {
  9769. return ui.toggleControls.call(player, false);
  9770. }, delay);
  9771. }); // Mouse wheel for volume
  9772. this.bind(elements.inputs.volume, 'wheel', function (event) {
  9773. // Detect "natural" scroll - suppored on OS X Safari only
  9774. // Other browsers on OS X will be inverted until support improves
  9775. var inverted = event.webkitDirectionInvertedFromDevice; // Get delta from event. Invert if `inverted` is true
  9776. var _map = [event.deltaX, -event.deltaY].map(function (value) {
  9777. return inverted ? -value : value;
  9778. }),
  9779. _map2 = _slicedToArray(_map, 2),
  9780. x = _map2[0],
  9781. y = _map2[1]; // Using the biggest delta, normalize to 1 or -1 (or 0 if no delta)
  9782. var direction = Math.sign(Math.abs(x) > Math.abs(y) ? x : y); // Change the volume by 2%
  9783. player.increaseVolume(direction / 50); // Don't break page scrolling at max and min
  9784. var volume = player.media.volume;
  9785. if (direction === 1 && volume < 1 || direction === -1 && volume > 0) {
  9786. event.preventDefault();
  9787. }
  9788. }, 'volume', false);
  9789. }
  9790. }]);
  9791. return Listeners;
  9792. }();
  9793. var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('splice');
  9794. var USES_TO_LENGTH$a = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 });
  9795. var max$3 = Math.max;
  9796. var min$5 = Math.min;
  9797. var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF;
  9798. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  9799. // `Array.prototype.splice` method
  9800. // https://tc39.github.io/ecma262/#sec-array.prototype.splice
  9801. // with adding support of @@species
  9802. _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 || !USES_TO_LENGTH$a }, {
  9803. splice: function splice(start, deleteCount /* , ...items */) {
  9804. var O = toObject(this);
  9805. var len = toLength(O.length);
  9806. var actualStart = toAbsoluteIndex(start, len);
  9807. var argumentsLength = arguments.length;
  9808. var insertCount, actualDeleteCount, A, k, from, to;
  9809. if (argumentsLength === 0) {
  9810. insertCount = actualDeleteCount = 0;
  9811. } else if (argumentsLength === 1) {
  9812. insertCount = 0;
  9813. actualDeleteCount = len - actualStart;
  9814. } else {
  9815. insertCount = argumentsLength - 2;
  9816. actualDeleteCount = min$5(max$3(toInteger(deleteCount), 0), len - actualStart);
  9817. }
  9818. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$1) {
  9819. throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  9820. }
  9821. A = arraySpeciesCreate(O, actualDeleteCount);
  9822. for (k = 0; k < actualDeleteCount; k++) {
  9823. from = actualStart + k;
  9824. if (from in O) createProperty(A, k, O[from]);
  9825. }
  9826. A.length = actualDeleteCount;
  9827. if (insertCount < actualDeleteCount) {
  9828. for (k = actualStart; k < len - actualDeleteCount; k++) {
  9829. from = k + actualDeleteCount;
  9830. to = k + insertCount;
  9831. if (from in O) O[to] = O[from];
  9832. else delete O[to];
  9833. }
  9834. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  9835. } else if (insertCount > actualDeleteCount) {
  9836. for (k = len - actualDeleteCount; k > actualStart; k--) {
  9837. from = k + actualDeleteCount - 1;
  9838. to = k + insertCount - 1;
  9839. if (from in O) O[to] = O[from];
  9840. else delete O[to];
  9841. }
  9842. }
  9843. for (k = 0; k < insertCount; k++) {
  9844. O[k + actualStart] = arguments[k + 2];
  9845. }
  9846. O.length = len - actualDeleteCount + insertCount;
  9847. return A;
  9848. }
  9849. });
  9850. var loadjs_umd = createCommonjsModule(function (module, exports) {
  9851. (function (root, factory) {
  9852. {
  9853. module.exports = factory();
  9854. }
  9855. })(commonjsGlobal, function () {
  9856. /**
  9857. * Global dependencies.
  9858. * @global {Object} document - DOM
  9859. */
  9860. var devnull = function devnull() {},
  9861. bundleIdCache = {},
  9862. bundleResultCache = {},
  9863. bundleCallbackQueue = {};
  9864. /**
  9865. * Subscribe to bundle load event.
  9866. * @param {string[]} bundleIds - Bundle ids
  9867. * @param {Function} callbackFn - The callback function
  9868. */
  9869. function subscribe(bundleIds, callbackFn) {
  9870. // listify
  9871. bundleIds = bundleIds.push ? bundleIds : [bundleIds];
  9872. var depsNotFound = [],
  9873. i = bundleIds.length,
  9874. numWaiting = i,
  9875. fn,
  9876. bundleId,
  9877. r,
  9878. q; // define callback function
  9879. fn = function fn(bundleId, pathsNotFound) {
  9880. if (pathsNotFound.length) depsNotFound.push(bundleId);
  9881. numWaiting--;
  9882. if (!numWaiting) callbackFn(depsNotFound);
  9883. }; // register callback
  9884. while (i--) {
  9885. bundleId = bundleIds[i]; // execute callback if in result cache
  9886. r = bundleResultCache[bundleId];
  9887. if (r) {
  9888. fn(bundleId, r);
  9889. continue;
  9890. } // add to callback queue
  9891. q = bundleCallbackQueue[bundleId] = bundleCallbackQueue[bundleId] || [];
  9892. q.push(fn);
  9893. }
  9894. }
  9895. /**
  9896. * Publish bundle load event.
  9897. * @param {string} bundleId - Bundle id
  9898. * @param {string[]} pathsNotFound - List of files not found
  9899. */
  9900. function publish(bundleId, pathsNotFound) {
  9901. // exit if id isn't defined
  9902. if (!bundleId) return;
  9903. var q = bundleCallbackQueue[bundleId]; // cache result
  9904. bundleResultCache[bundleId] = pathsNotFound; // exit if queue is empty
  9905. if (!q) return; // empty callback queue
  9906. while (q.length) {
  9907. q[0](bundleId, pathsNotFound);
  9908. q.splice(0, 1);
  9909. }
  9910. }
  9911. /**
  9912. * Execute callbacks.
  9913. * @param {Object or Function} args - The callback args
  9914. * @param {string[]} depsNotFound - List of dependencies not found
  9915. */
  9916. function executeCallbacks(args, depsNotFound) {
  9917. // accept function as argument
  9918. if (args.call) args = {
  9919. success: args
  9920. }; // success and error callbacks
  9921. if (depsNotFound.length) (args.error || devnull)(depsNotFound);else (args.success || devnull)(args);
  9922. }
  9923. /**
  9924. * Load individual file.
  9925. * @param {string} path - The file path
  9926. * @param {Function} callbackFn - The callback function
  9927. */
  9928. function loadFile(path, callbackFn, args, numTries) {
  9929. var doc = document,
  9930. async = args.async,
  9931. maxTries = (args.numRetries || 0) + 1,
  9932. beforeCallbackFn = args.before || devnull,
  9933. pathname = path.replace(/[\?|#].*$/, ''),
  9934. pathStripped = path.replace(/^(css|img)!/, ''),
  9935. isLegacyIECss,
  9936. e;
  9937. numTries = numTries || 0;
  9938. if (/(^css!|\.css$)/.test(pathname)) {
  9939. // css
  9940. e = doc.createElement('link');
  9941. e.rel = 'stylesheet';
  9942. e.href = pathStripped; // tag IE9+
  9943. isLegacyIECss = 'hideFocus' in e; // use preload in IE Edge (to detect load errors)
  9944. if (isLegacyIECss && e.relList) {
  9945. isLegacyIECss = 0;
  9946. e.rel = 'preload';
  9947. e.as = 'style';
  9948. }
  9949. } else if (/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(pathname)) {
  9950. // image
  9951. e = doc.createElement('img');
  9952. e.src = pathStripped;
  9953. } else {
  9954. // javascript
  9955. e = doc.createElement('script');
  9956. e.src = path;
  9957. e.async = async === undefined ? true : async;
  9958. }
  9959. e.onload = e.onerror = e.onbeforeload = function (ev) {
  9960. var result = ev.type[0]; // treat empty stylesheets as failures to get around lack of onerror
  9961. // support in IE9-11
  9962. if (isLegacyIECss) {
  9963. try {
  9964. if (!e.sheet.cssText.length) result = 'e';
  9965. } catch (x) {
  9966. // sheets objects created from load errors don't allow access to
  9967. // `cssText` (unless error is Code:18 SecurityError)
  9968. if (x.code != 18) result = 'e';
  9969. }
  9970. } // handle retries in case of load failure
  9971. if (result == 'e') {
  9972. // increment counter
  9973. numTries += 1; // exit function and try again
  9974. if (numTries < maxTries) {
  9975. return loadFile(path, callbackFn, args, numTries);
  9976. }
  9977. } else if (e.rel == 'preload' && e.as == 'style') {
  9978. // activate preloaded stylesheets
  9979. return e.rel = 'stylesheet'; // jshint ignore:line
  9980. } // execute callback
  9981. callbackFn(path, result, ev.defaultPrevented);
  9982. }; // add to document (unless callback returns `false`)
  9983. if (beforeCallbackFn(path, e) !== false) doc.head.appendChild(e);
  9984. }
  9985. /**
  9986. * Load multiple files.
  9987. * @param {string[]} paths - The file paths
  9988. * @param {Function} callbackFn - The callback function
  9989. */
  9990. function loadFiles(paths, callbackFn, args) {
  9991. // listify paths
  9992. paths = paths.push ? paths : [paths];
  9993. var numWaiting = paths.length,
  9994. x = numWaiting,
  9995. pathsNotFound = [],
  9996. fn,
  9997. i; // define callback function
  9998. fn = function fn(path, result, defaultPrevented) {
  9999. // handle error
  10000. if (result == 'e') pathsNotFound.push(path); // handle beforeload event. If defaultPrevented then that means the load
  10001. // will be blocked (ex. Ghostery/ABP on Safari)
  10002. if (result == 'b') {
  10003. if (defaultPrevented) pathsNotFound.push(path);else return;
  10004. }
  10005. numWaiting--;
  10006. if (!numWaiting) callbackFn(pathsNotFound);
  10007. }; // load scripts
  10008. for (i = 0; i < x; i++) {
  10009. loadFile(paths[i], fn, args);
  10010. }
  10011. }
  10012. /**
  10013. * Initiate script load and register bundle.
  10014. * @param {(string|string[])} paths - The file paths
  10015. * @param {(string|Function|Object)} [arg1] - The (1) bundleId or (2) success
  10016. * callback or (3) object literal with success/error arguments, numRetries,
  10017. * etc.
  10018. * @param {(Function|Object)} [arg2] - The (1) success callback or (2) object
  10019. * literal with success/error arguments, numRetries, etc.
  10020. */
  10021. function loadjs(paths, arg1, arg2) {
  10022. var bundleId, args; // bundleId (if string)
  10023. if (arg1 && arg1.trim) bundleId = arg1; // args (default is {})
  10024. args = (bundleId ? arg2 : arg1) || {}; // throw error if bundle is already defined
  10025. if (bundleId) {
  10026. if (bundleId in bundleIdCache) {
  10027. throw "LoadJS";
  10028. } else {
  10029. bundleIdCache[bundleId] = true;
  10030. }
  10031. }
  10032. function loadFn(resolve, reject) {
  10033. loadFiles(paths, function (pathsNotFound) {
  10034. // execute callbacks
  10035. executeCallbacks(args, pathsNotFound); // resolve Promise
  10036. if (resolve) {
  10037. executeCallbacks({
  10038. success: resolve,
  10039. error: reject
  10040. }, pathsNotFound);
  10041. } // publish bundle load event
  10042. publish(bundleId, pathsNotFound);
  10043. }, args);
  10044. }
  10045. if (args.returnPromise) return new Promise(loadFn);else loadFn();
  10046. }
  10047. /**
  10048. * Execute callbacks when dependencies have been satisfied.
  10049. * @param {(string|string[])} deps - List of bundle ids
  10050. * @param {Object} args - success/error arguments
  10051. */
  10052. loadjs.ready = function ready(deps, args) {
  10053. // subscribe to bundle load event
  10054. subscribe(deps, function (depsNotFound) {
  10055. // execute callbacks
  10056. executeCallbacks(args, depsNotFound);
  10057. });
  10058. return loadjs;
  10059. };
  10060. /**
  10061. * Manually satisfy bundle dependencies.
  10062. * @param {string} bundleId - The bundle id
  10063. */
  10064. loadjs.done = function done(bundleId) {
  10065. publish(bundleId, []);
  10066. };
  10067. /**
  10068. * Reset loadjs dependencies statuses
  10069. */
  10070. loadjs.reset = function reset() {
  10071. bundleIdCache = {};
  10072. bundleResultCache = {};
  10073. bundleCallbackQueue = {};
  10074. };
  10075. /**
  10076. * Determine if bundle has already been defined
  10077. * @param String} bundleId - The bundle id
  10078. */
  10079. loadjs.isDefined = function isDefined(bundleId) {
  10080. return bundleId in bundleIdCache;
  10081. }; // export
  10082. return loadjs;
  10083. });
  10084. });
  10085. function loadScript(url) {
  10086. return new Promise(function (resolve, reject) {
  10087. loadjs_umd(url, {
  10088. success: resolve,
  10089. error: reject
  10090. });
  10091. });
  10092. }
  10093. function parseId(url) {
  10094. if (is$1.empty(url)) {
  10095. return null;
  10096. }
  10097. if (is$1.number(Number(url))) {
  10098. return url;
  10099. }
  10100. var regex = /^.*(vimeo.com\/|video\/)(\d+).*/;
  10101. return url.match(regex) ? RegExp.$2 : url;
  10102. } // Set playback state and trigger change (only on actual change)
  10103. function assurePlaybackState(play) {
  10104. if (play && !this.embed.hasPlayed) {
  10105. this.embed.hasPlayed = true;
  10106. }
  10107. if (this.media.paused === play) {
  10108. this.media.paused = !play;
  10109. triggerEvent.call(this, this.media, play ? 'play' : 'pause');
  10110. }
  10111. }
  10112. var vimeo = {
  10113. setup: function setup() {
  10114. var player = this; // Add embed class for responsive
  10115. toggleClass(player.elements.wrapper, player.config.classNames.embed, true); // Set speed options from config
  10116. player.options.speed = player.config.speed.options; // Set intial ratio
  10117. setAspectRatio.call(player); // Load the SDK if not already
  10118. if (!is$1.object(window.Vimeo)) {
  10119. loadScript(player.config.urls.vimeo.sdk).then(function () {
  10120. vimeo.ready.call(player);
  10121. }).catch(function (error) {
  10122. player.debug.warn('Vimeo SDK (player.js) failed to load', error);
  10123. });
  10124. } else {
  10125. vimeo.ready.call(player);
  10126. }
  10127. },
  10128. // API Ready
  10129. ready: function ready() {
  10130. var _this = this;
  10131. var player = this;
  10132. var config = player.config.vimeo;
  10133. var premium = config.premium,
  10134. referrerPolicy = config.referrerPolicy,
  10135. frameParams = _objectWithoutProperties(config, ["premium", "referrerPolicy"]); // If the owner has a pro or premium account then we can hide controls etc
  10136. if (premium) {
  10137. Object.assign(frameParams, {
  10138. controls: false,
  10139. sidedock: false
  10140. });
  10141. } // Get Vimeo params for the iframe
  10142. var params = buildUrlParams(_objectSpread2({
  10143. loop: player.config.loop.active,
  10144. autoplay: player.autoplay,
  10145. muted: player.muted,
  10146. gesture: 'media',
  10147. playsinline: !this.config.fullscreen.iosNative
  10148. }, frameParams)); // Get the source URL or ID
  10149. var source = player.media.getAttribute('src'); // Get from <div> if needed
  10150. if (is$1.empty(source)) {
  10151. source = player.media.getAttribute(player.config.attributes.embed.id);
  10152. }
  10153. var id = parseId(source); // Build an iframe
  10154. var iframe = createElement('iframe');
  10155. var src = format(player.config.urls.vimeo.iframe, id, params);
  10156. iframe.setAttribute('src', src);
  10157. iframe.setAttribute('allowfullscreen', '');
  10158. iframe.setAttribute('allow', 'autoplay,fullscreen,picture-in-picture'); // Set the referrer policy if required
  10159. if (!is$1.empty(referrerPolicy)) {
  10160. iframe.setAttribute('referrerPolicy', referrerPolicy);
  10161. } // Inject the package
  10162. var poster = player.poster;
  10163. if (premium) {
  10164. iframe.setAttribute('data-poster', poster);
  10165. player.media = replaceElement(iframe, player.media);
  10166. } else {
  10167. var wrapper = createElement('div', {
  10168. class: player.config.classNames.embedContainer,
  10169. 'data-poster': poster
  10170. });
  10171. wrapper.appendChild(iframe);
  10172. player.media = replaceElement(wrapper, player.media);
  10173. } // Get poster image
  10174. fetch(format(player.config.urls.vimeo.api, id), 'json').then(function (response) {
  10175. if (is$1.empty(response)) {
  10176. return;
  10177. } // Get the URL for thumbnail
  10178. var url = new URL(response[0].thumbnail_large); // Get original image
  10179. url.pathname = "".concat(url.pathname.split('_')[0], ".jpg"); // Set and show poster
  10180. ui.setPoster.call(player, url.href).catch(function () {});
  10181. }); // Setup instance
  10182. // https://github.com/vimeo/player.js
  10183. player.embed = new window.Vimeo.Player(iframe, {
  10184. autopause: player.config.autopause,
  10185. muted: player.muted
  10186. });
  10187. player.media.paused = true;
  10188. player.media.currentTime = 0; // Disable native text track rendering
  10189. if (player.supported.ui) {
  10190. player.embed.disableTextTrack();
  10191. } // Create a faux HTML5 API using the Vimeo API
  10192. player.media.play = function () {
  10193. assurePlaybackState.call(player, true);
  10194. return player.embed.play();
  10195. };
  10196. player.media.pause = function () {
  10197. assurePlaybackState.call(player, false);
  10198. return player.embed.pause();
  10199. };
  10200. player.media.stop = function () {
  10201. player.pause();
  10202. player.currentTime = 0;
  10203. }; // Seeking
  10204. var currentTime = player.media.currentTime;
  10205. Object.defineProperty(player.media, 'currentTime', {
  10206. get: function get() {
  10207. return currentTime;
  10208. },
  10209. set: function set(time) {
  10210. // Vimeo will automatically play on seek if the video hasn't been played before
  10211. // Get current paused state and volume etc
  10212. var embed = player.embed,
  10213. media = player.media,
  10214. paused = player.paused,
  10215. volume = player.volume;
  10216. var restorePause = paused && !embed.hasPlayed; // Set seeking state and trigger event
  10217. media.seeking = true;
  10218. triggerEvent.call(player, media, 'seeking'); // If paused, mute until seek is complete
  10219. Promise.resolve(restorePause && embed.setVolume(0)) // Seek
  10220. .then(function () {
  10221. return embed.setCurrentTime(time);
  10222. }) // Restore paused
  10223. .then(function () {
  10224. return restorePause && embed.pause();
  10225. }) // Restore volume
  10226. .then(function () {
  10227. return restorePause && embed.setVolume(volume);
  10228. }).catch(function () {// Do nothing
  10229. });
  10230. }
  10231. }); // Playback speed
  10232. var speed = player.config.speed.selected;
  10233. Object.defineProperty(player.media, 'playbackRate', {
  10234. get: function get() {
  10235. return speed;
  10236. },
  10237. set: function set(input) {
  10238. player.embed.setPlaybackRate(input).then(function () {
  10239. speed = input;
  10240. triggerEvent.call(player, player.media, 'ratechange');
  10241. }).catch(function () {
  10242. // Cannot set Playback Rate, Video is probably not on Pro account
  10243. player.options.speed = [1];
  10244. });
  10245. }
  10246. }); // Volume
  10247. var volume = player.config.volume;
  10248. Object.defineProperty(player.media, 'volume', {
  10249. get: function get() {
  10250. return volume;
  10251. },
  10252. set: function set(input) {
  10253. player.embed.setVolume(input).then(function () {
  10254. volume = input;
  10255. triggerEvent.call(player, player.media, 'volumechange');
  10256. });
  10257. }
  10258. }); // Muted
  10259. var muted = player.config.muted;
  10260. Object.defineProperty(player.media, 'muted', {
  10261. get: function get() {
  10262. return muted;
  10263. },
  10264. set: function set(input) {
  10265. var toggle = is$1.boolean(input) ? input : false;
  10266. player.embed.setVolume(toggle ? 0 : player.config.volume).then(function () {
  10267. muted = toggle;
  10268. triggerEvent.call(player, player.media, 'volumechange');
  10269. });
  10270. }
  10271. }); // Loop
  10272. var loop = player.config.loop;
  10273. Object.defineProperty(player.media, 'loop', {
  10274. get: function get() {
  10275. return loop;
  10276. },
  10277. set: function set(input) {
  10278. var toggle = is$1.boolean(input) ? input : player.config.loop.active;
  10279. player.embed.setLoop(toggle).then(function () {
  10280. loop = toggle;
  10281. });
  10282. }
  10283. }); // Source
  10284. var currentSrc;
  10285. player.embed.getVideoUrl().then(function (value) {
  10286. currentSrc = value;
  10287. controls.setDownloadUrl.call(player);
  10288. }).catch(function (error) {
  10289. _this.debug.warn(error);
  10290. });
  10291. Object.defineProperty(player.media, 'currentSrc', {
  10292. get: function get() {
  10293. return currentSrc;
  10294. }
  10295. }); // Ended
  10296. Object.defineProperty(player.media, 'ended', {
  10297. get: function get() {
  10298. return player.currentTime === player.duration;
  10299. }
  10300. }); // Set aspect ratio based on video size
  10301. Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then(function (dimensions) {
  10302. var _dimensions = _slicedToArray(dimensions, 2),
  10303. width = _dimensions[0],
  10304. height = _dimensions[1];
  10305. player.embed.ratio = [width, height];
  10306. setAspectRatio.call(_this);
  10307. }); // Set autopause
  10308. player.embed.setAutopause(player.config.autopause).then(function (state) {
  10309. player.config.autopause = state;
  10310. }); // Get title
  10311. player.embed.getVideoTitle().then(function (title) {
  10312. player.config.title = title;
  10313. ui.setTitle.call(_this);
  10314. }); // Get current time
  10315. player.embed.getCurrentTime().then(function (value) {
  10316. currentTime = value;
  10317. triggerEvent.call(player, player.media, 'timeupdate');
  10318. }); // Get duration
  10319. player.embed.getDuration().then(function (value) {
  10320. player.media.duration = value;
  10321. triggerEvent.call(player, player.media, 'durationchange');
  10322. }); // Get captions
  10323. player.embed.getTextTracks().then(function (tracks) {
  10324. player.media.textTracks = tracks;
  10325. captions.setup.call(player);
  10326. });
  10327. player.embed.on('cuechange', function (_ref) {
  10328. var _ref$cues = _ref.cues,
  10329. cues = _ref$cues === void 0 ? [] : _ref$cues;
  10330. var strippedCues = cues.map(function (cue) {
  10331. return stripHTML(cue.text);
  10332. });
  10333. captions.updateCues.call(player, strippedCues);
  10334. });
  10335. player.embed.on('loaded', function () {
  10336. // Assure state and events are updated on autoplay
  10337. player.embed.getPaused().then(function (paused) {
  10338. assurePlaybackState.call(player, !paused);
  10339. if (!paused) {
  10340. triggerEvent.call(player, player.media, 'playing');
  10341. }
  10342. });
  10343. if (is$1.element(player.embed.element) && player.supported.ui) {
  10344. var frame = player.embed.element; // Fix keyboard focus issues
  10345. // https://github.com/sampotts/plyr/issues/317
  10346. frame.setAttribute('tabindex', -1);
  10347. }
  10348. });
  10349. player.embed.on('bufferstart', function () {
  10350. triggerEvent.call(player, player.media, 'waiting');
  10351. });
  10352. player.embed.on('bufferend', function () {
  10353. triggerEvent.call(player, player.media, 'playing');
  10354. });
  10355. player.embed.on('play', function () {
  10356. assurePlaybackState.call(player, true);
  10357. triggerEvent.call(player, player.media, 'playing');
  10358. });
  10359. player.embed.on('pause', function () {
  10360. assurePlaybackState.call(player, false);
  10361. });
  10362. player.embed.on('timeupdate', function (data) {
  10363. player.media.seeking = false;
  10364. currentTime = data.seconds;
  10365. triggerEvent.call(player, player.media, 'timeupdate');
  10366. });
  10367. player.embed.on('progress', function (data) {
  10368. player.media.buffered = data.percent;
  10369. triggerEvent.call(player, player.media, 'progress'); // Check all loaded
  10370. if (parseInt(data.percent, 10) === 1) {
  10371. triggerEvent.call(player, player.media, 'canplaythrough');
  10372. } // Get duration as if we do it before load, it gives an incorrect value
  10373. // https://github.com/sampotts/plyr/issues/891
  10374. player.embed.getDuration().then(function (value) {
  10375. if (value !== player.media.duration) {
  10376. player.media.duration = value;
  10377. triggerEvent.call(player, player.media, 'durationchange');
  10378. }
  10379. });
  10380. });
  10381. player.embed.on('seeked', function () {
  10382. player.media.seeking = false;
  10383. triggerEvent.call(player, player.media, 'seeked');
  10384. });
  10385. player.embed.on('ended', function () {
  10386. player.media.paused = true;
  10387. triggerEvent.call(player, player.media, 'ended');
  10388. });
  10389. player.embed.on('error', function (detail) {
  10390. player.media.error = detail;
  10391. triggerEvent.call(player, player.media, 'error');
  10392. }); // Rebuild UI
  10393. setTimeout(function () {
  10394. return ui.build.call(player);
  10395. }, 0);
  10396. }
  10397. };
  10398. function parseId$1(url) {
  10399. if (is$1.empty(url)) {
  10400. return null;
  10401. }
  10402. var regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
  10403. return url.match(regex) ? RegExp.$2 : url;
  10404. } // Set playback state and trigger change (only on actual change)
  10405. function assurePlaybackState$1(play) {
  10406. if (play && !this.embed.hasPlayed) {
  10407. this.embed.hasPlayed = true;
  10408. }
  10409. if (this.media.paused === play) {
  10410. this.media.paused = !play;
  10411. triggerEvent.call(this, this.media, play ? 'play' : 'pause');
  10412. }
  10413. }
  10414. function getHost$1(config) {
  10415. if (config.noCookie) {
  10416. return 'https://www.youtube-nocookie.com';
  10417. }
  10418. if (window.location.protocol === 'http:') {
  10419. return 'http://www.youtube.com';
  10420. } // Use YouTube's default
  10421. return undefined;
  10422. }
  10423. var youtube = {
  10424. setup: function setup() {
  10425. var _this = this;
  10426. // Add embed class for responsive
  10427. toggleClass(this.elements.wrapper, this.config.classNames.embed, true); // Setup API
  10428. if (is$1.object(window.YT) && is$1.function(window.YT.Player)) {
  10429. youtube.ready.call(this);
  10430. } else {
  10431. // Reference current global callback
  10432. var callback = window.onYouTubeIframeAPIReady; // Set callback to process queue
  10433. window.onYouTubeIframeAPIReady = function () {
  10434. // Call global callback if set
  10435. if (is$1.function(callback)) {
  10436. callback();
  10437. }
  10438. youtube.ready.call(_this);
  10439. }; // Load the SDK
  10440. loadScript(this.config.urls.youtube.sdk).catch(function (error) {
  10441. _this.debug.warn('YouTube API failed to load', error);
  10442. });
  10443. }
  10444. },
  10445. // Get the media title
  10446. getTitle: function getTitle(videoId) {
  10447. var _this2 = this;
  10448. var url = format(this.config.urls.youtube.api, videoId);
  10449. fetch(url).then(function (data) {
  10450. if (is$1.object(data)) {
  10451. var title = data.title,
  10452. height = data.height,
  10453. width = data.width; // Set title
  10454. _this2.config.title = title;
  10455. ui.setTitle.call(_this2); // Set aspect ratio
  10456. _this2.embed.ratio = [width, height];
  10457. }
  10458. setAspectRatio.call(_this2);
  10459. }).catch(function () {
  10460. // Set aspect ratio
  10461. setAspectRatio.call(_this2);
  10462. });
  10463. },
  10464. // API ready
  10465. ready: function ready() {
  10466. var player = this; // Ignore already setup (race condition)
  10467. var currentId = player.media && player.media.getAttribute('id');
  10468. if (!is$1.empty(currentId) && currentId.startsWith('youtube-')) {
  10469. return;
  10470. } // Get the source URL or ID
  10471. var source = player.media.getAttribute('src'); // Get from <div> if needed
  10472. if (is$1.empty(source)) {
  10473. source = player.media.getAttribute(this.config.attributes.embed.id);
  10474. } // Replace the <iframe> with a <div> due to YouTube API issues
  10475. var videoId = parseId$1(source);
  10476. var id = generateId(player.provider); // Get poster, if already set
  10477. var poster = player.poster; // Replace media element
  10478. var container = createElement('div', {
  10479. id: id,
  10480. 'data-poster': poster
  10481. });
  10482. player.media = replaceElement(container, player.media); // Id to poster wrapper
  10483. var posterSrc = function posterSrc(s) {
  10484. return "https://i.ytimg.com/vi/".concat(videoId, "/").concat(s, "default.jpg");
  10485. }; // Check thumbnail images in order of quality, but reject fallback thumbnails (120px wide)
  10486. loadImage(posterSrc('maxres'), 121) // Higest quality and unpadded
  10487. .catch(function () {
  10488. return loadImage(posterSrc('sd'), 121);
  10489. }) // 480p padded 4:3
  10490. .catch(function () {
  10491. return loadImage(posterSrc('hq'));
  10492. }) // 360p padded 4:3. Always exists
  10493. .then(function (image) {
  10494. return ui.setPoster.call(player, image.src);
  10495. }).then(function (src) {
  10496. // If the image is padded, use background-size "cover" instead (like youtube does too with their posters)
  10497. if (!src.includes('maxres')) {
  10498. player.elements.poster.style.backgroundSize = 'cover';
  10499. }
  10500. }).catch(function () {});
  10501. var config = player.config.youtube; // Setup instance
  10502. // https://developers.google.com/youtube/iframe_api_reference
  10503. player.embed = new window.YT.Player(id, {
  10504. videoId: videoId,
  10505. host: getHost$1(config),
  10506. playerVars: extend({}, {
  10507. autoplay: player.config.autoplay ? 1 : 0,
  10508. // Autoplay
  10509. hl: player.config.hl,
  10510. // iframe interface language
  10511. controls: player.supported.ui ? 0 : 1,
  10512. // Only show controls if not fully supported
  10513. disablekb: 1,
  10514. // Disable keyboard as we handle it
  10515. playsinline: !player.config.fullscreen.iosNative ? 1 : 0,
  10516. // Allow iOS inline playback
  10517. // Captions are flaky on YouTube
  10518. cc_load_policy: player.captions.active ? 1 : 0,
  10519. cc_lang_pref: player.config.captions.language,
  10520. // Tracking for stats
  10521. widget_referrer: window ? window.location.href : null
  10522. }, config),
  10523. events: {
  10524. onError: function onError(event) {
  10525. // YouTube may fire onError twice, so only handle it once
  10526. if (!player.media.error) {
  10527. var code = event.data; // Messages copied from https://developers.google.com/youtube/iframe_api_reference#onError
  10528. var message = {
  10529. 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.',
  10530. 5: 'The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.',
  10531. 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.',
  10532. 101: 'The owner of the requested video does not allow it to be played in embedded players.',
  10533. 150: 'The owner of the requested video does not allow it to be played in embedded players.'
  10534. }[code] || 'An unknown error occured';
  10535. player.media.error = {
  10536. code: code,
  10537. message: message
  10538. };
  10539. triggerEvent.call(player, player.media, 'error');
  10540. }
  10541. },
  10542. onPlaybackRateChange: function onPlaybackRateChange(event) {
  10543. // Get the instance
  10544. var instance = event.target; // Get current speed
  10545. player.media.playbackRate = instance.getPlaybackRate();
  10546. triggerEvent.call(player, player.media, 'ratechange');
  10547. },
  10548. onReady: function onReady(event) {
  10549. // Bail if onReady has already been called. See issue #1108
  10550. if (is$1.function(player.media.play)) {
  10551. return;
  10552. } // Get the instance
  10553. var instance = event.target; // Get the title
  10554. youtube.getTitle.call(player, videoId); // Create a faux HTML5 API using the YouTube API
  10555. player.media.play = function () {
  10556. assurePlaybackState$1.call(player, true);
  10557. instance.playVideo();
  10558. };
  10559. player.media.pause = function () {
  10560. assurePlaybackState$1.call(player, false);
  10561. instance.pauseVideo();
  10562. };
  10563. player.media.stop = function () {
  10564. instance.stopVideo();
  10565. };
  10566. player.media.duration = instance.getDuration();
  10567. player.media.paused = true; // Seeking
  10568. player.media.currentTime = 0;
  10569. Object.defineProperty(player.media, 'currentTime', {
  10570. get: function get() {
  10571. return Number(instance.getCurrentTime());
  10572. },
  10573. set: function set(time) {
  10574. // If paused and never played, mute audio preventively (YouTube starts playing on seek if the video hasn't been played yet).
  10575. if (player.paused && !player.embed.hasPlayed) {
  10576. player.embed.mute();
  10577. } // Set seeking state and trigger event
  10578. player.media.seeking = true;
  10579. triggerEvent.call(player, player.media, 'seeking'); // Seek after events sent
  10580. instance.seekTo(time);
  10581. }
  10582. }); // Playback speed
  10583. Object.defineProperty(player.media, 'playbackRate', {
  10584. get: function get() {
  10585. return instance.getPlaybackRate();
  10586. },
  10587. set: function set(input) {
  10588. instance.setPlaybackRate(input);
  10589. }
  10590. }); // Volume
  10591. var volume = player.config.volume;
  10592. Object.defineProperty(player.media, 'volume', {
  10593. get: function get() {
  10594. return volume;
  10595. },
  10596. set: function set(input) {
  10597. volume = input;
  10598. instance.setVolume(volume * 100);
  10599. triggerEvent.call(player, player.media, 'volumechange');
  10600. }
  10601. }); // Muted
  10602. var muted = player.config.muted;
  10603. Object.defineProperty(player.media, 'muted', {
  10604. get: function get() {
  10605. return muted;
  10606. },
  10607. set: function set(input) {
  10608. var toggle = is$1.boolean(input) ? input : muted;
  10609. muted = toggle;
  10610. instance[toggle ? 'mute' : 'unMute']();
  10611. triggerEvent.call(player, player.media, 'volumechange');
  10612. }
  10613. }); // Source
  10614. Object.defineProperty(player.media, 'currentSrc', {
  10615. get: function get() {
  10616. return instance.getVideoUrl();
  10617. }
  10618. }); // Ended
  10619. Object.defineProperty(player.media, 'ended', {
  10620. get: function get() {
  10621. return player.currentTime === player.duration;
  10622. }
  10623. }); // Get available speeds
  10624. var speeds = instance.getAvailablePlaybackRates(); // Filter based on config
  10625. player.options.speed = speeds.filter(function (s) {
  10626. return player.config.speed.options.includes(s);
  10627. }); // Set the tabindex to avoid focus entering iframe
  10628. if (player.supported.ui) {
  10629. player.media.setAttribute('tabindex', -1);
  10630. }
  10631. triggerEvent.call(player, player.media, 'timeupdate');
  10632. triggerEvent.call(player, player.media, 'durationchange'); // Reset timer
  10633. clearInterval(player.timers.buffering); // Setup buffering
  10634. player.timers.buffering = setInterval(function () {
  10635. // Get loaded % from YouTube
  10636. player.media.buffered = instance.getVideoLoadedFraction(); // Trigger progress only when we actually buffer something
  10637. if (player.media.lastBuffered === null || player.media.lastBuffered < player.media.buffered) {
  10638. triggerEvent.call(player, player.media, 'progress');
  10639. } // Set last buffer point
  10640. player.media.lastBuffered = player.media.buffered; // Bail if we're at 100%
  10641. if (player.media.buffered === 1) {
  10642. clearInterval(player.timers.buffering); // Trigger event
  10643. triggerEvent.call(player, player.media, 'canplaythrough');
  10644. }
  10645. }, 200); // Rebuild UI
  10646. setTimeout(function () {
  10647. return ui.build.call(player);
  10648. }, 50);
  10649. },
  10650. onStateChange: function onStateChange(event) {
  10651. // Get the instance
  10652. var instance = event.target; // Reset timer
  10653. clearInterval(player.timers.playing);
  10654. var seeked = player.media.seeking && [1, 2].includes(event.data);
  10655. if (seeked) {
  10656. // Unset seeking and fire seeked event
  10657. player.media.seeking = false;
  10658. triggerEvent.call(player, player.media, 'seeked');
  10659. } // Handle events
  10660. // -1 Unstarted
  10661. // 0 Ended
  10662. // 1 Playing
  10663. // 2 Paused
  10664. // 3 Buffering
  10665. // 5 Video cued
  10666. switch (event.data) {
  10667. case -1:
  10668. // Update scrubber
  10669. triggerEvent.call(player, player.media, 'timeupdate'); // Get loaded % from YouTube
  10670. player.media.buffered = instance.getVideoLoadedFraction();
  10671. triggerEvent.call(player, player.media, 'progress');
  10672. break;
  10673. case 0:
  10674. assurePlaybackState$1.call(player, false); // YouTube doesn't support loop for a single video, so mimick it.
  10675. if (player.media.loop) {
  10676. // YouTube needs a call to `stopVideo` before playing again
  10677. instance.stopVideo();
  10678. instance.playVideo();
  10679. } else {
  10680. triggerEvent.call(player, player.media, 'ended');
  10681. }
  10682. break;
  10683. case 1:
  10684. // Restore paused state (YouTube starts playing on seek if the video hasn't been played yet)
  10685. if (!player.config.autoplay && player.media.paused && !player.embed.hasPlayed) {
  10686. player.media.pause();
  10687. } else {
  10688. assurePlaybackState$1.call(player, true);
  10689. triggerEvent.call(player, player.media, 'playing'); // Poll to get playback progress
  10690. player.timers.playing = setInterval(function () {
  10691. triggerEvent.call(player, player.media, 'timeupdate');
  10692. }, 50); // Check duration again due to YouTube bug
  10693. // https://github.com/sampotts/plyr/issues/374
  10694. // https://code.google.com/p/gdata-issues/issues/detail?id=8690
  10695. if (player.media.duration !== instance.getDuration()) {
  10696. player.media.duration = instance.getDuration();
  10697. triggerEvent.call(player, player.media, 'durationchange');
  10698. }
  10699. }
  10700. break;
  10701. case 2:
  10702. // Restore audio (YouTube starts playing on seek if the video hasn't been played yet)
  10703. if (!player.muted) {
  10704. player.embed.unMute();
  10705. }
  10706. assurePlaybackState$1.call(player, false);
  10707. break;
  10708. case 3:
  10709. // Trigger waiting event to add loading classes to container as the video buffers.
  10710. triggerEvent.call(player, player.media, 'waiting');
  10711. break;
  10712. }
  10713. triggerEvent.call(player, player.elements.container, 'statechange', false, {
  10714. code: event.data
  10715. });
  10716. }
  10717. }
  10718. });
  10719. }
  10720. };
  10721. var media = {
  10722. // Setup media
  10723. setup: function setup() {
  10724. // If there's no media, bail
  10725. if (!this.media) {
  10726. this.debug.warn('No media element found!');
  10727. return;
  10728. } // Add type class
  10729. toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', this.type), true); // Add provider class
  10730. toggleClass(this.elements.container, this.config.classNames.provider.replace('{0}', this.provider), true); // Add video class for embeds
  10731. // This will require changes if audio embeds are added
  10732. if (this.isEmbed) {
  10733. toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', 'video'), true);
  10734. } // Inject the player wrapper
  10735. if (this.isVideo) {
  10736. // Create the wrapper div
  10737. this.elements.wrapper = createElement('div', {
  10738. class: this.config.classNames.video
  10739. }); // Wrap the video in a container
  10740. wrap$1(this.media, this.elements.wrapper); // Poster image container
  10741. this.elements.poster = createElement('div', {
  10742. class: this.config.classNames.poster
  10743. });
  10744. this.elements.wrapper.appendChild(this.elements.poster);
  10745. }
  10746. if (this.isHTML5) {
  10747. html5.setup.call(this);
  10748. } else if (this.isYouTube) {
  10749. youtube.setup.call(this);
  10750. } else if (this.isVimeo) {
  10751. vimeo.setup.call(this);
  10752. }
  10753. }
  10754. };
  10755. var destroy = function destroy(instance) {
  10756. // Destroy our adsManager
  10757. if (instance.manager) {
  10758. instance.manager.destroy();
  10759. } // Destroy our adsManager
  10760. if (instance.elements.displayContainer) {
  10761. instance.elements.displayContainer.destroy();
  10762. }
  10763. instance.elements.container.remove();
  10764. };
  10765. var Ads = /*#__PURE__*/function () {
  10766. /**
  10767. * Ads constructor.
  10768. * @param {Object} player
  10769. * @return {Ads}
  10770. */
  10771. function Ads(player) {
  10772. var _this = this;
  10773. _classCallCheck(this, Ads);
  10774. this.player = player;
  10775. this.config = player.config.ads;
  10776. this.playing = false;
  10777. this.initialized = false;
  10778. this.elements = {
  10779. container: null,
  10780. displayContainer: null
  10781. };
  10782. this.manager = null;
  10783. this.loader = null;
  10784. this.cuePoints = null;
  10785. this.events = {};
  10786. this.safetyTimer = null;
  10787. this.countdownTimer = null; // Setup a promise to resolve when the IMA manager is ready
  10788. this.managerPromise = new Promise(function (resolve, reject) {
  10789. // The ad is loaded and ready
  10790. _this.on('loaded', resolve); // Ads failed
  10791. _this.on('error', reject);
  10792. });
  10793. this.load();
  10794. }
  10795. _createClass(Ads, [{
  10796. key: "load",
  10797. /**
  10798. * Load the IMA SDK
  10799. */
  10800. value: function load() {
  10801. var _this2 = this;
  10802. if (!this.enabled) {
  10803. return;
  10804. } // Check if the Google IMA3 SDK is loaded or load it ourselves
  10805. if (!is$1.object(window.google) || !is$1.object(window.google.ima)) {
  10806. loadScript(this.player.config.urls.googleIMA.sdk).then(function () {
  10807. _this2.ready();
  10808. }).catch(function () {
  10809. // Script failed to load or is blocked
  10810. _this2.trigger('error', new Error('Google IMA SDK failed to load'));
  10811. });
  10812. } else {
  10813. this.ready();
  10814. }
  10815. }
  10816. /**
  10817. * Get the ads instance ready
  10818. */
  10819. }, {
  10820. key: "ready",
  10821. value: function ready() {
  10822. var _this3 = this;
  10823. // Double check we're enabled
  10824. if (!this.enabled) {
  10825. destroy(this);
  10826. } // Start ticking our safety timer. If the whole advertisement
  10827. // thing doesn't resolve within our set time; we bail
  10828. this.startSafetyTimer(12000, 'ready()'); // Clear the safety timer
  10829. this.managerPromise.then(function () {
  10830. _this3.clearSafetyTimer('onAdsManagerLoaded()');
  10831. }); // Set listeners on the Plyr instance
  10832. this.listeners(); // Setup the IMA SDK
  10833. this.setupIMA();
  10834. } // Build the tag URL
  10835. }, {
  10836. key: "setupIMA",
  10837. /**
  10838. * In order for the SDK to display ads for our video, we need to tell it where to put them,
  10839. * so here we define our ad container. This div is set up to render on top of the video player.
  10840. * Using the code below, we tell the SDK to render ads within that div. We also provide a
  10841. * handle to the content video player - the SDK will poll the current time of our player to
  10842. * properly place mid-rolls. After we create the ad display container, we initialize it. On
  10843. * mobile devices, this initialization is done as the result of a user action.
  10844. */
  10845. value: function setupIMA() {
  10846. var _this4 = this;
  10847. // Create the container for our advertisements
  10848. this.elements.container = createElement('div', {
  10849. class: this.player.config.classNames.ads
  10850. });
  10851. this.player.elements.container.appendChild(this.elements.container); // So we can run VPAID2
  10852. google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED); // Set language
  10853. google.ima.settings.setLocale(this.player.config.ads.language); // Set playback for iOS10+
  10854. 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
  10855. this.elements.displayContainer = new google.ima.AdDisplayContainer(this.elements.container, this.player.media); // Create ads loader
  10856. this.loader = new google.ima.AdsLoader(this.elements.displayContainer); // Listen and respond to ads loaded and error events
  10857. this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, function (event) {
  10858. return _this4.onAdsManagerLoaded(event);
  10859. }, false);
  10860. this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, function (error) {
  10861. return _this4.onAdError(error);
  10862. }, false); // Request video ads to be pre-loaded
  10863. this.requestAds();
  10864. }
  10865. /**
  10866. * Request advertisements
  10867. */
  10868. }, {
  10869. key: "requestAds",
  10870. value: function requestAds() {
  10871. var container = this.player.elements.container;
  10872. try {
  10873. // Request video ads
  10874. var request = new google.ima.AdsRequest();
  10875. request.adTagUrl = this.tagUrl; // Specify the linear and nonlinear slot sizes. This helps the SDK
  10876. // to select the correct creative if multiple are returned
  10877. request.linearAdSlotWidth = container.offsetWidth;
  10878. request.linearAdSlotHeight = container.offsetHeight;
  10879. request.nonLinearAdSlotWidth = container.offsetWidth;
  10880. request.nonLinearAdSlotHeight = container.offsetHeight; // We only overlay ads as we only support video.
  10881. request.forceNonLinearFullSlot = false; // Mute based on current state
  10882. request.setAdWillPlayMuted(!this.player.muted);
  10883. this.loader.requestAds(request);
  10884. } catch (e) {
  10885. this.onAdError(e);
  10886. }
  10887. }
  10888. /**
  10889. * Update the ad countdown
  10890. * @param {Boolean} start
  10891. */
  10892. }, {
  10893. key: "pollCountdown",
  10894. value: function pollCountdown() {
  10895. var _this5 = this;
  10896. var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10897. if (!start) {
  10898. clearInterval(this.countdownTimer);
  10899. this.elements.container.removeAttribute('data-badge-text');
  10900. return;
  10901. }
  10902. var update = function update() {
  10903. var time = formatTime(Math.max(_this5.manager.getRemainingTime(), 0));
  10904. var label = "".concat(i18n.get('advertisement', _this5.player.config), " - ").concat(time);
  10905. _this5.elements.container.setAttribute('data-badge-text', label);
  10906. };
  10907. this.countdownTimer = setInterval(update, 100);
  10908. }
  10909. /**
  10910. * This method is called whenever the ads are ready inside the AdDisplayContainer
  10911. * @param {Event} adsManagerLoadedEvent
  10912. */
  10913. }, {
  10914. key: "onAdsManagerLoaded",
  10915. value: function onAdsManagerLoaded(event) {
  10916. var _this6 = this;
  10917. // Load could occur after a source change (race condition)
  10918. if (!this.enabled) {
  10919. return;
  10920. } // Get the ads manager
  10921. var settings = new google.ima.AdsRenderingSettings(); // Tell the SDK to save and restore content video state on our behalf
  10922. settings.restoreCustomPlaybackStateOnAdBreakComplete = true;
  10923. settings.enablePreloading = true; // The SDK is polling currentTime on the contentPlayback. And needs a duration
  10924. // so it can determine when to start the mid- and post-roll
  10925. this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
  10926. this.cuePoints = this.manager.getCuePoints(); // Add listeners to the required events
  10927. // Advertisement error events
  10928. this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, function (error) {
  10929. return _this6.onAdError(error);
  10930. }); // Advertisement regular events
  10931. Object.keys(google.ima.AdEvent.Type).forEach(function (type) {
  10932. _this6.manager.addEventListener(google.ima.AdEvent.Type[type], function (e) {
  10933. return _this6.onAdEvent(e);
  10934. });
  10935. }); // Resolve our adsManager
  10936. this.trigger('loaded');
  10937. }
  10938. }, {
  10939. key: "addCuePoints",
  10940. value: function addCuePoints() {
  10941. var _this7 = this;
  10942. // Add advertisement cue's within the time line if available
  10943. if (!is$1.empty(this.cuePoints)) {
  10944. this.cuePoints.forEach(function (cuePoint) {
  10945. if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
  10946. var seekElement = _this7.player.elements.progress;
  10947. if (is$1.element(seekElement)) {
  10948. var cuePercentage = 100 / _this7.player.duration * cuePoint;
  10949. var cue = createElement('span', {
  10950. class: _this7.player.config.classNames.cues
  10951. });
  10952. cue.style.left = "".concat(cuePercentage.toString(), "%");
  10953. seekElement.appendChild(cue);
  10954. }
  10955. }
  10956. });
  10957. }
  10958. }
  10959. /**
  10960. * This is where all the event handling takes place. Retrieve the ad from the event. Some
  10961. * events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
  10962. * https://developers.google.com/interactive-media-ads/docs/sdks/html5/v3/apis#ima.AdEvent.Type
  10963. * @param {Event} event
  10964. */
  10965. }, {
  10966. key: "onAdEvent",
  10967. value: function onAdEvent(event) {
  10968. var _this8 = this;
  10969. var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
  10970. // don't have ad object associated
  10971. var ad = event.getAd();
  10972. var adData = event.getAdData(); // Proxy event
  10973. var dispatchEvent = function dispatchEvent(type) {
  10974. triggerEvent.call(_this8.player, _this8.player.media, "ads".concat(type.replace(/_/g, '').toLowerCase()));
  10975. }; // Bubble the event
  10976. dispatchEvent(event.type);
  10977. switch (event.type) {
  10978. case google.ima.AdEvent.Type.LOADED:
  10979. // This is the first event sent for an ad - it is possible to determine whether the
  10980. // ad is a video ad or an overlay
  10981. this.trigger('loaded'); // Start countdown
  10982. this.pollCountdown(true);
  10983. if (!ad.isLinear()) {
  10984. // Position AdDisplayContainer correctly for overlay
  10985. ad.width = container.offsetWidth;
  10986. ad.height = container.offsetHeight;
  10987. } // console.info('Ad type: ' + event.getAd().getAdPodInfo().getPodIndex());
  10988. // console.info('Ad time: ' + event.getAd().getAdPodInfo().getTimeOffset());
  10989. break;
  10990. case google.ima.AdEvent.Type.STARTED:
  10991. // Set volume to match player
  10992. this.manager.setVolume(this.player.volume);
  10993. break;
  10994. case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:
  10995. // All ads for the current videos are done. We can now request new advertisements
  10996. // in case the video is re-played
  10997. // TODO: Example for what happens when a next video in a playlist would be loaded.
  10998. // So here we load a new video when all ads are done.
  10999. // Then we load new ads within a new adsManager. When the video
  11000. // Is started - after - the ads are loaded, then we get ads.
  11001. // You can also easily test cancelling and reloading by running
  11002. // player.ads.cancel() and player.ads.play from the console I guess.
  11003. // this.player.source = {
  11004. // type: 'video',
  11005. // title: 'View From A Blue Moon',
  11006. // sources: [{
  11007. // src:
  11008. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4', type:
  11009. // 'video/mp4', }], poster:
  11010. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg', tracks:
  11011. // [ { kind: 'captions', label: 'English', srclang: 'en', src:
  11012. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt',
  11013. // default: true, }, { kind: 'captions', label: 'French', srclang: 'fr', src:
  11014. // 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt', }, ],
  11015. // };
  11016. // TODO: So there is still this thing where a video should only be allowed to start
  11017. // playing when the IMA SDK is ready or has failed
  11018. if (this.player.ended) {
  11019. this.loadAds();
  11020. } else {
  11021. // The SDK won't allow new ads to be called without receiving a contentComplete()
  11022. this.loader.contentComplete();
  11023. }
  11024. break;
  11025. case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:
  11026. // This event indicates the ad has started - the video player can adjust the UI,
  11027. // for example display a pause button and remaining time. Fired when content should
  11028. // be paused. This usually happens right before an ad is about to cover the content
  11029. this.pauseContent();
  11030. break;
  11031. case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:
  11032. // This event indicates the ad has finished - the video player can perform
  11033. // appropriate UI actions, such as removing the timer for remaining time detection.
  11034. // Fired when content should be resumed. This usually happens when an ad finishes
  11035. // or collapses
  11036. this.pollCountdown();
  11037. this.resumeContent();
  11038. break;
  11039. case google.ima.AdEvent.Type.LOG:
  11040. if (adData.adError) {
  11041. this.player.debug.warn("Non-fatal ad error: ".concat(adData.adError.getMessage()));
  11042. }
  11043. break;
  11044. }
  11045. }
  11046. /**
  11047. * Any ad error handling comes through here
  11048. * @param {Event} event
  11049. */
  11050. }, {
  11051. key: "onAdError",
  11052. value: function onAdError(event) {
  11053. this.cancel();
  11054. this.player.debug.warn('Ads error', event);
  11055. }
  11056. /**
  11057. * Setup hooks for Plyr and window events. This ensures
  11058. * the mid- and post-roll launch at the correct time. And
  11059. * resize the advertisement when the player resizes
  11060. */
  11061. }, {
  11062. key: "listeners",
  11063. value: function listeners() {
  11064. var _this9 = this;
  11065. var container = this.player.elements.container;
  11066. var time;
  11067. this.player.on('canplay', function () {
  11068. _this9.addCuePoints();
  11069. });
  11070. this.player.on('ended', function () {
  11071. _this9.loader.contentComplete();
  11072. });
  11073. this.player.on('timeupdate', function () {
  11074. time = _this9.player.currentTime;
  11075. });
  11076. this.player.on('seeked', function () {
  11077. var seekedTime = _this9.player.currentTime;
  11078. if (is$1.empty(_this9.cuePoints)) {
  11079. return;
  11080. }
  11081. _this9.cuePoints.forEach(function (cuePoint, index) {
  11082. if (time < cuePoint && cuePoint < seekedTime) {
  11083. _this9.manager.discardAdBreak();
  11084. _this9.cuePoints.splice(index, 1);
  11085. }
  11086. });
  11087. }); // Listen to the resizing of the window. And resize ad accordingly
  11088. // TODO: eventually implement ResizeObserver
  11089. window.addEventListener('resize', function () {
  11090. if (_this9.manager) {
  11091. _this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
  11092. }
  11093. });
  11094. }
  11095. /**
  11096. * Initialize the adsManager and start playing advertisements
  11097. */
  11098. }, {
  11099. key: "play",
  11100. value: function play() {
  11101. var _this10 = this;
  11102. var container = this.player.elements.container;
  11103. if (!this.managerPromise) {
  11104. this.resumeContent();
  11105. } // Play the requested advertisement whenever the adsManager is ready
  11106. this.managerPromise.then(function () {
  11107. // Set volume to match player
  11108. _this10.manager.setVolume(_this10.player.volume); // Initialize the container. Must be done via a user action on mobile devices
  11109. _this10.elements.displayContainer.initialize();
  11110. try {
  11111. if (!_this10.initialized) {
  11112. // Initialize the ads manager. Ad rules playlist will start at this time
  11113. _this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
  11114. // start at this time; the call will be ignored for ad rules
  11115. _this10.manager.start();
  11116. }
  11117. _this10.initialized = true;
  11118. } catch (adError) {
  11119. // An error may be thrown if there was a problem with the
  11120. // VAST response
  11121. _this10.onAdError(adError);
  11122. }
  11123. }).catch(function () {});
  11124. }
  11125. /**
  11126. * Resume our video
  11127. */
  11128. }, {
  11129. key: "resumeContent",
  11130. value: function resumeContent() {
  11131. // Hide the advertisement container
  11132. this.elements.container.style.zIndex = ''; // Ad is stopped
  11133. this.playing = false; // Play video
  11134. silencePromise(this.player.media.play());
  11135. }
  11136. /**
  11137. * Pause our video
  11138. */
  11139. }, {
  11140. key: "pauseContent",
  11141. value: function pauseContent() {
  11142. // Show the advertisement container
  11143. this.elements.container.style.zIndex = 3; // Ad is playing
  11144. this.playing = true; // Pause our video.
  11145. this.player.media.pause();
  11146. }
  11147. /**
  11148. * Destroy the adsManager so we can grab new ads after this. If we don't then we're not
  11149. * allowed to call new ads based on google policies, as they interpret this as an accidental
  11150. * video requests. https://developers.google.com/interactive-
  11151. * media-ads/docs/sdks/android/faq#8
  11152. */
  11153. }, {
  11154. key: "cancel",
  11155. value: function cancel() {
  11156. // Pause our video
  11157. if (this.initialized) {
  11158. this.resumeContent();
  11159. } // Tell our instance that we're done for now
  11160. this.trigger('error'); // Re-create our adsManager
  11161. this.loadAds();
  11162. }
  11163. /**
  11164. * Re-create our adsManager
  11165. */
  11166. }, {
  11167. key: "loadAds",
  11168. value: function loadAds() {
  11169. var _this11 = this;
  11170. // Tell our adsManager to go bye bye
  11171. this.managerPromise.then(function () {
  11172. // Destroy our adsManager
  11173. if (_this11.manager) {
  11174. _this11.manager.destroy();
  11175. } // Re-set our adsManager promises
  11176. _this11.managerPromise = new Promise(function (resolve) {
  11177. _this11.on('loaded', resolve);
  11178. _this11.player.debug.log(_this11.manager);
  11179. }); // Now that the manager has been destroyed set it to also be un-initialized
  11180. _this11.initialized = false; // Now request some new advertisements
  11181. _this11.requestAds();
  11182. }).catch(function () {});
  11183. }
  11184. /**
  11185. * Handles callbacks after an ad event was invoked
  11186. * @param {String} event - Event type
  11187. */
  11188. }, {
  11189. key: "trigger",
  11190. value: function trigger(event) {
  11191. var _this12 = this;
  11192. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  11193. args[_key - 1] = arguments[_key];
  11194. }
  11195. var handlers = this.events[event];
  11196. if (is$1.array(handlers)) {
  11197. handlers.forEach(function (handler) {
  11198. if (is$1.function(handler)) {
  11199. handler.apply(_this12, args);
  11200. }
  11201. });
  11202. }
  11203. }
  11204. /**
  11205. * Add event listeners
  11206. * @param {String} event - Event type
  11207. * @param {Function} callback - Callback for when event occurs
  11208. * @return {Ads}
  11209. */
  11210. }, {
  11211. key: "on",
  11212. value: function on(event, callback) {
  11213. if (!is$1.array(this.events[event])) {
  11214. this.events[event] = [];
  11215. }
  11216. this.events[event].push(callback);
  11217. return this;
  11218. }
  11219. /**
  11220. * Setup a safety timer for when the ad network doesn't respond for whatever reason.
  11221. * The advertisement has 12 seconds to get its things together. We stop this timer when the
  11222. * advertisement is playing, or when a user action is required to start, then we clear the
  11223. * timer on ad ready
  11224. * @param {Number} time
  11225. * @param {String} from
  11226. */
  11227. }, {
  11228. key: "startSafetyTimer",
  11229. value: function startSafetyTimer(time, from) {
  11230. var _this13 = this;
  11231. this.player.debug.log("Safety timer invoked from: ".concat(from));
  11232. this.safetyTimer = setTimeout(function () {
  11233. _this13.cancel();
  11234. _this13.clearSafetyTimer('startSafetyTimer()');
  11235. }, time);
  11236. }
  11237. /**
  11238. * Clear our safety timer(s)
  11239. * @param {String} from
  11240. */
  11241. }, {
  11242. key: "clearSafetyTimer",
  11243. value: function clearSafetyTimer(from) {
  11244. if (!is$1.nullOrUndefined(this.safetyTimer)) {
  11245. this.player.debug.log("Safety timer cleared from: ".concat(from));
  11246. clearTimeout(this.safetyTimer);
  11247. this.safetyTimer = null;
  11248. }
  11249. }
  11250. }, {
  11251. key: "enabled",
  11252. get: function get() {
  11253. var config = this.config;
  11254. return this.player.isHTML5 && this.player.isVideo && config.enabled && (!is$1.empty(config.publisherId) || is$1.url(config.tagUrl));
  11255. }
  11256. }, {
  11257. key: "tagUrl",
  11258. get: function get() {
  11259. var config = this.config;
  11260. if (is$1.url(config.tagUrl)) {
  11261. return config.tagUrl;
  11262. }
  11263. var params = {
  11264. AV_PUBLISHERID: '58c25bb0073ef448b1087ad6',
  11265. AV_CHANNELID: '5a0458dc28a06145e4519d21',
  11266. AV_URL: window.location.hostname,
  11267. cb: Date.now(),
  11268. AV_WIDTH: 640,
  11269. AV_HEIGHT: 480,
  11270. AV_CDIM2: config.publisherId
  11271. };
  11272. var base = 'https://go.aniview.com/api/adserver6/vast/';
  11273. return "".concat(base, "?").concat(buildUrlParams(params));
  11274. }
  11275. }]);
  11276. return Ads;
  11277. }();
  11278. var $findIndex = arrayIteration.findIndex;
  11279. var FIND_INDEX = 'findIndex';
  11280. var SKIPS_HOLES$1 = true;
  11281. var USES_TO_LENGTH$b = arrayMethodUsesToLength(FIND_INDEX);
  11282. // Shouldn't skip holes
  11283. if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () { SKIPS_HOLES$1 = false; });
  11284. // `Array.prototype.findIndex` method
  11285. // https://tc39.github.io/ecma262/#sec-array.prototype.findindex
  11286. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES$1 || !USES_TO_LENGTH$b }, {
  11287. findIndex: function findIndex(callbackfn /* , that = undefined */) {
  11288. return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  11289. }
  11290. });
  11291. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  11292. addToUnscopables(FIND_INDEX);
  11293. var min$6 = Math.min;
  11294. var nativeLastIndexOf = [].lastIndexOf;
  11295. var NEGATIVE_ZERO$1 = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
  11296. var STRICT_METHOD$6 = arrayMethodIsStrict('lastIndexOf');
  11297. // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
  11298. var USES_TO_LENGTH$c = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  11299. var FORCED$5 = NEGATIVE_ZERO$1 || !STRICT_METHOD$6 || !USES_TO_LENGTH$c;
  11300. // `Array.prototype.lastIndexOf` method implementation
  11301. // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
  11302. var arrayLastIndexOf = FORCED$5 ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
  11303. // convert -0 to +0
  11304. if (NEGATIVE_ZERO$1) return nativeLastIndexOf.apply(this, arguments) || 0;
  11305. var O = toIndexedObject(this);
  11306. var length = toLength(O.length);
  11307. var index = length - 1;
  11308. if (arguments.length > 1) index = min$6(index, toInteger(arguments[1]));
  11309. if (index < 0) index = length + index;
  11310. for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
  11311. return -1;
  11312. } : nativeLastIndexOf;
  11313. // `Array.prototype.lastIndexOf` method
  11314. // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
  11315. _export({ target: 'Array', proto: true, forced: arrayLastIndexOf !== [].lastIndexOf }, {
  11316. lastIndexOf: arrayLastIndexOf
  11317. });
  11318. var parseVtt = function parseVtt(vttDataString) {
  11319. var processedList = [];
  11320. var frames = vttDataString.split(/\r\n\r\n|\n\n|\r\r/);
  11321. frames.forEach(function (frame) {
  11322. var result = {};
  11323. var lines = frame.split(/\r\n|\n|\r/);
  11324. lines.forEach(function (line) {
  11325. if (!is$1.number(result.startTime)) {
  11326. // The line with start and end times on it is the first line of interest
  11327. 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
  11328. if (matchTimes) {
  11329. result.startTime = Number(matchTimes[1] || 0) * 60 * 60 + Number(matchTimes[2]) * 60 + Number(matchTimes[3]) + Number("0.".concat(matchTimes[4]));
  11330. result.endTime = Number(matchTimes[6] || 0) * 60 * 60 + Number(matchTimes[7]) * 60 + Number(matchTimes[8]) + Number("0.".concat(matchTimes[9]));
  11331. }
  11332. } else if (!is$1.empty(line.trim()) && is$1.empty(result.text)) {
  11333. // If we already have the startTime, then we're definitely up to the text line(s)
  11334. var lineSplit = line.trim().split('#xywh=');
  11335. var _lineSplit = _slicedToArray(lineSplit, 1);
  11336. result.text = _lineSplit[0];
  11337. // If there's content in lineSplit[1], then we have sprites. If not, then it's just one frame per image
  11338. if (lineSplit[1]) {
  11339. var _lineSplit$1$split = lineSplit[1].split(',');
  11340. var _lineSplit$1$split2 = _slicedToArray(_lineSplit$1$split, 4);
  11341. result.x = _lineSplit$1$split2[0];
  11342. result.y = _lineSplit$1$split2[1];
  11343. result.w = _lineSplit$1$split2[2];
  11344. result.h = _lineSplit$1$split2[3];
  11345. }
  11346. }
  11347. });
  11348. if (result.text) {
  11349. processedList.push(result);
  11350. }
  11351. });
  11352. return processedList;
  11353. };
  11354. /**
  11355. * Preview thumbnails for seek hover and scrubbing
  11356. * Seeking: Hover over the seek bar (desktop only): shows a small preview container above the seek bar
  11357. * 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
  11358. *
  11359. * Notes:
  11360. * - 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
  11361. * - 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
  11362. * - 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
  11363. */
  11364. var fitRatio = function fitRatio(ratio, outer) {
  11365. var targetRatio = outer.width / outer.height;
  11366. var result = {};
  11367. if (ratio > targetRatio) {
  11368. result.width = outer.width;
  11369. result.height = 1 / ratio * outer.width;
  11370. } else {
  11371. result.height = outer.height;
  11372. result.width = ratio * outer.height;
  11373. }
  11374. return result;
  11375. };
  11376. var PreviewThumbnails = /*#__PURE__*/function () {
  11377. /**
  11378. * PreviewThumbnails constructor.
  11379. * @param {Plyr} player
  11380. * @return {PreviewThumbnails}
  11381. */
  11382. function PreviewThumbnails(player) {
  11383. _classCallCheck(this, PreviewThumbnails);
  11384. this.player = player;
  11385. this.thumbnails = [];
  11386. this.loaded = false;
  11387. this.lastMouseMoveTime = Date.now();
  11388. this.mouseDown = false;
  11389. this.loadedImages = [];
  11390. this.elements = {
  11391. thumb: {},
  11392. scrubbing: {}
  11393. };
  11394. this.load();
  11395. }
  11396. _createClass(PreviewThumbnails, [{
  11397. key: "load",
  11398. value: function load() {
  11399. var _this = this;
  11400. // Toggle the regular seek tooltip
  11401. if (this.player.elements.display.seekTooltip) {
  11402. this.player.elements.display.seekTooltip.hidden = this.enabled;
  11403. }
  11404. if (!this.enabled) {
  11405. return;
  11406. }
  11407. this.getThumbnails().then(function () {
  11408. if (!_this.enabled) {
  11409. return;
  11410. } // Render DOM elements
  11411. _this.render(); // Check to see if thumb container size was specified manually in CSS
  11412. _this.determineContainerAutoSizing();
  11413. _this.loaded = true;
  11414. });
  11415. } // Download VTT files and parse them
  11416. }, {
  11417. key: "getThumbnails",
  11418. value: function getThumbnails() {
  11419. var _this2 = this;
  11420. return new Promise(function (resolve) {
  11421. var src = _this2.player.config.previewThumbnails.src;
  11422. if (is$1.empty(src)) {
  11423. throw new Error('Missing previewThumbnails.src config attribute');
  11424. } // Resolve promise
  11425. var sortAndResolve = function sortAndResolve() {
  11426. // Sort smallest to biggest (e.g., [120p, 480p, 1080p])
  11427. _this2.thumbnails.sort(function (x, y) {
  11428. return x.height - y.height;
  11429. });
  11430. _this2.player.debug.log('Preview thumbnails', _this2.thumbnails);
  11431. resolve();
  11432. }; // Via callback()
  11433. if (is$1.function(src)) {
  11434. src(function (thumbnails) {
  11435. _this2.thumbnails = thumbnails;
  11436. sortAndResolve();
  11437. });
  11438. } // VTT urls
  11439. else {
  11440. // If string, convert into single-element list
  11441. 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
  11442. var promises = urls.map(function (u) {
  11443. return _this2.getThumbnail(u);
  11444. }); // Resolve
  11445. Promise.all(promises).then(sortAndResolve);
  11446. }
  11447. });
  11448. } // Process individual VTT file
  11449. }, {
  11450. key: "getThumbnail",
  11451. value: function getThumbnail(url) {
  11452. var _this3 = this;
  11453. return new Promise(function (resolve) {
  11454. fetch(url).then(function (response) {
  11455. var thumbnail = {
  11456. frames: parseVtt(response),
  11457. height: null,
  11458. urlPrefix: ''
  11459. }; // If the URLs don't start with '/', then we need to set their relative path to be the location of the VTT file
  11460. // If the URLs do start with '/', then they obviously don't need a prefix, so it will remain blank
  11461. // 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
  11462. if (!thumbnail.frames[0].text.startsWith('/') && !thumbnail.frames[0].text.startsWith('http://') && !thumbnail.frames[0].text.startsWith('https://')) {
  11463. thumbnail.urlPrefix = url.substring(0, url.lastIndexOf('/') + 1);
  11464. } // Download the first frame, so that we can determine/set the height of this thumbnailsDef
  11465. var tempImage = new Image();
  11466. tempImage.onload = function () {
  11467. thumbnail.height = tempImage.naturalHeight;
  11468. thumbnail.width = tempImage.naturalWidth;
  11469. _this3.thumbnails.push(thumbnail);
  11470. resolve();
  11471. };
  11472. tempImage.src = thumbnail.urlPrefix + thumbnail.frames[0].text;
  11473. });
  11474. });
  11475. }
  11476. }, {
  11477. key: "startMove",
  11478. value: function startMove(event) {
  11479. if (!this.loaded) {
  11480. return;
  11481. }
  11482. if (!is$1.event(event) || !['touchmove', 'mousemove'].includes(event.type)) {
  11483. return;
  11484. } // Wait until media has a duration
  11485. if (!this.player.media.duration) {
  11486. return;
  11487. }
  11488. if (event.type === 'touchmove') {
  11489. // Calculate seek hover position as approx video seconds
  11490. this.seekTime = this.player.media.duration * (this.player.elements.inputs.seek.value / 100);
  11491. } else {
  11492. // Calculate seek hover position as approx video seconds
  11493. var clientRect = this.player.elements.progress.getBoundingClientRect();
  11494. var percentage = 100 / clientRect.width * (event.pageX - clientRect.left);
  11495. this.seekTime = this.player.media.duration * (percentage / 100);
  11496. if (this.seekTime < 0) {
  11497. // The mousemove fires for 10+px out to the left
  11498. this.seekTime = 0;
  11499. }
  11500. if (this.seekTime > this.player.media.duration - 1) {
  11501. // Took 1 second off the duration for safety, because different players can disagree on the real duration of a video
  11502. this.seekTime = this.player.media.duration - 1;
  11503. }
  11504. this.mousePosX = event.pageX; // Set time text inside image container
  11505. this.elements.thumb.time.innerText = formatTime(this.seekTime);
  11506. } // Download and show image
  11507. this.showImageAtCurrentTime();
  11508. }
  11509. }, {
  11510. key: "endMove",
  11511. value: function endMove() {
  11512. this.toggleThumbContainer(false, true);
  11513. }
  11514. }, {
  11515. key: "startScrubbing",
  11516. value: function startScrubbing(event) {
  11517. // Only act on left mouse button (0), or touch device (event.button does not exist or is false)
  11518. if (is$1.nullOrUndefined(event.button) || event.button === false || event.button === 0) {
  11519. this.mouseDown = true; // Wait until media has a duration
  11520. if (this.player.media.duration) {
  11521. this.toggleScrubbingContainer(true);
  11522. this.toggleThumbContainer(false, true); // Download and show image
  11523. this.showImageAtCurrentTime();
  11524. }
  11525. }
  11526. }
  11527. }, {
  11528. key: "endScrubbing",
  11529. value: function endScrubbing() {
  11530. var _this4 = this;
  11531. this.mouseDown = false; // Hide scrubbing preview. But wait until the video has successfully seeked before hiding the scrubbing preview
  11532. if (Math.ceil(this.lastTime) === Math.ceil(this.player.media.currentTime)) {
  11533. // The video was already seeked/loaded at the chosen time - hide immediately
  11534. this.toggleScrubbingContainer(false);
  11535. } else {
  11536. // The video hasn't seeked yet. Wait for that
  11537. once.call(this.player, this.player.media, 'timeupdate', function () {
  11538. // Re-check mousedown - we might have already started scrubbing again
  11539. if (!_this4.mouseDown) {
  11540. _this4.toggleScrubbingContainer(false);
  11541. }
  11542. });
  11543. }
  11544. }
  11545. /**
  11546. * Setup hooks for Plyr and window events
  11547. */
  11548. }, {
  11549. key: "listeners",
  11550. value: function listeners() {
  11551. var _this5 = this;
  11552. // 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
  11553. this.player.on('play', function () {
  11554. _this5.toggleThumbContainer(false, true);
  11555. });
  11556. this.player.on('seeked', function () {
  11557. _this5.toggleThumbContainer(false);
  11558. });
  11559. this.player.on('timeupdate', function () {
  11560. _this5.lastTime = _this5.player.media.currentTime;
  11561. });
  11562. }
  11563. /**
  11564. * Create HTML elements for image containers
  11565. */
  11566. }, {
  11567. key: "render",
  11568. value: function render() {
  11569. // Create HTML element: plyr__preview-thumbnail-container
  11570. this.elements.thumb.container = createElement('div', {
  11571. class: this.player.config.classNames.previewThumbnails.thumbContainer
  11572. }); // Wrapper for the image for styling
  11573. this.elements.thumb.imageContainer = createElement('div', {
  11574. class: this.player.config.classNames.previewThumbnails.imageContainer
  11575. });
  11576. this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer); // Create HTML element, parent+span: time text (e.g., 01:32:00)
  11577. var timeContainer = createElement('div', {
  11578. class: this.player.config.classNames.previewThumbnails.timeContainer
  11579. });
  11580. this.elements.thumb.time = createElement('span', {}, '00:00');
  11581. timeContainer.appendChild(this.elements.thumb.time);
  11582. this.elements.thumb.container.appendChild(timeContainer); // Inject the whole thumb
  11583. if (is$1.element(this.player.elements.progress)) {
  11584. this.player.elements.progress.appendChild(this.elements.thumb.container);
  11585. } // Create HTML element: plyr__preview-scrubbing-container
  11586. this.elements.scrubbing.container = createElement('div', {
  11587. class: this.player.config.classNames.previewThumbnails.scrubbingContainer
  11588. });
  11589. this.player.elements.wrapper.appendChild(this.elements.scrubbing.container);
  11590. }
  11591. }, {
  11592. key: "destroy",
  11593. value: function destroy() {
  11594. if (this.elements.thumb.container) {
  11595. this.elements.thumb.container.remove();
  11596. }
  11597. if (this.elements.scrubbing.container) {
  11598. this.elements.scrubbing.container.remove();
  11599. }
  11600. }
  11601. }, {
  11602. key: "showImageAtCurrentTime",
  11603. value: function showImageAtCurrentTime() {
  11604. var _this6 = this;
  11605. if (this.mouseDown) {
  11606. this.setScrubbingContainerSize();
  11607. } else {
  11608. this.setThumbContainerSizeAndPos();
  11609. } // Find the desired thumbnail index
  11610. // TODO: Handle a video longer than the thumbs where thumbNum is null
  11611. var thumbNum = this.thumbnails[0].frames.findIndex(function (frame) {
  11612. return _this6.seekTime >= frame.startTime && _this6.seekTime <= frame.endTime;
  11613. });
  11614. var hasThumb = thumbNum >= 0;
  11615. var qualityIndex = 0; // Show the thumb container if we're not scrubbing
  11616. if (!this.mouseDown) {
  11617. this.toggleThumbContainer(hasThumb);
  11618. } // No matching thumb found
  11619. if (!hasThumb) {
  11620. return;
  11621. } // Check to see if we've already downloaded higher quality versions of this image
  11622. this.thumbnails.forEach(function (thumbnail, index) {
  11623. if (_this6.loadedImages.includes(thumbnail.frames[thumbNum].text)) {
  11624. qualityIndex = index;
  11625. }
  11626. }); // Only proceed if either thumbnum or thumbfilename has changed
  11627. if (thumbNum !== this.showingThumb) {
  11628. this.showingThumb = thumbNum;
  11629. this.loadImage(qualityIndex);
  11630. }
  11631. } // Show the image that's currently specified in this.showingThumb
  11632. }, {
  11633. key: "loadImage",
  11634. value: function loadImage() {
  11635. var _this7 = this;
  11636. var qualityIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11637. var thumbNum = this.showingThumb;
  11638. var thumbnail = this.thumbnails[qualityIndex];
  11639. var urlPrefix = thumbnail.urlPrefix;
  11640. var frame = thumbnail.frames[thumbNum];
  11641. var thumbFilename = thumbnail.frames[thumbNum].text;
  11642. var thumbUrl = urlPrefix + thumbFilename;
  11643. if (!this.currentImageElement || this.currentImageElement.dataset.filename !== thumbFilename) {
  11644. // If we're already loading a previous image, remove its onload handler - we don't want it to load after this one
  11645. // Only do this if not using sprites. Without sprites we really want to show as many images as possible, as a best-effort
  11646. if (this.loadingImage && this.usingSprites) {
  11647. this.loadingImage.onload = null;
  11648. } // We're building and adding a new image. In other implementations of similar functionality (YouTube), background image
  11649. // is instead used. But this causes issues with larger images in Firefox and Safari - switching between background
  11650. // images causes a flicker. Putting a new image over the top does not
  11651. var previewImage = new Image();
  11652. previewImage.src = thumbUrl;
  11653. previewImage.dataset.index = thumbNum;
  11654. previewImage.dataset.filename = thumbFilename;
  11655. this.showingThumbFilename = thumbFilename;
  11656. 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...
  11657. previewImage.onload = function () {
  11658. return _this7.showImage(previewImage, frame, qualityIndex, thumbNum, thumbFilename, true);
  11659. };
  11660. this.loadingImage = previewImage;
  11661. this.removeOldImages(previewImage);
  11662. } else {
  11663. // Update the existing image
  11664. this.showImage(this.currentImageElement, frame, qualityIndex, thumbNum, thumbFilename, false);
  11665. this.currentImageElement.dataset.index = thumbNum;
  11666. this.removeOldImages(this.currentImageElement);
  11667. }
  11668. }
  11669. }, {
  11670. key: "showImage",
  11671. value: function showImage(previewImage, frame, qualityIndex, thumbNum, thumbFilename) {
  11672. var newImage = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
  11673. this.player.debug.log("Showing thumb: ".concat(thumbFilename, ". num: ").concat(thumbNum, ". qual: ").concat(qualityIndex, ". newimg: ").concat(newImage));
  11674. this.setImageSizeAndOffset(previewImage, frame);
  11675. if (newImage) {
  11676. this.currentImageContainer.appendChild(previewImage);
  11677. this.currentImageElement = previewImage;
  11678. if (!this.loadedImages.includes(thumbFilename)) {
  11679. this.loadedImages.push(thumbFilename);
  11680. }
  11681. } // Preload images before and after the current one
  11682. // Show higher quality of the same frame
  11683. // 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
  11684. this.preloadNearby(thumbNum, true).then(this.preloadNearby(thumbNum, false)).then(this.getHigherQuality(qualityIndex, previewImage, frame, thumbFilename));
  11685. } // Remove all preview images that aren't the designated current image
  11686. }, {
  11687. key: "removeOldImages",
  11688. value: function removeOldImages(currentImage) {
  11689. var _this8 = this;
  11690. // Get a list of all images, convert it from a DOM list to an array
  11691. Array.from(this.currentImageContainer.children).forEach(function (image) {
  11692. if (image.tagName.toLowerCase() !== 'img') {
  11693. return;
  11694. }
  11695. var removeDelay = _this8.usingSprites ? 500 : 1000;
  11696. if (image.dataset.index !== currentImage.dataset.index && !image.dataset.deleting) {
  11697. // 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
  11698. // First set attribute 'deleting' to prevent multi-handling of this on repeat firing of this function
  11699. // eslint-disable-next-line no-param-reassign
  11700. image.dataset.deleting = true; // This has to be set before the timeout - to prevent issues switching between hover and scrub
  11701. var currentImageContainer = _this8.currentImageContainer;
  11702. setTimeout(function () {
  11703. currentImageContainer.removeChild(image);
  11704. _this8.player.debug.log("Removing thumb: ".concat(image.dataset.filename));
  11705. }, removeDelay);
  11706. }
  11707. });
  11708. } // Preload images before and after the current one. Only if the user is still hovering/seeking the same frame
  11709. // This will only preload the lowest quality
  11710. }, {
  11711. key: "preloadNearby",
  11712. value: function preloadNearby(thumbNum) {
  11713. var _this9 = this;
  11714. var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  11715. return new Promise(function (resolve) {
  11716. setTimeout(function () {
  11717. var oldThumbFilename = _this9.thumbnails[0].frames[thumbNum].text;
  11718. if (_this9.showingThumbFilename === oldThumbFilename) {
  11719. // 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
  11720. var thumbnailsClone;
  11721. if (forward) {
  11722. thumbnailsClone = _this9.thumbnails[0].frames.slice(thumbNum);
  11723. } else {
  11724. thumbnailsClone = _this9.thumbnails[0].frames.slice(0, thumbNum).reverse();
  11725. }
  11726. var foundOne = false;
  11727. thumbnailsClone.forEach(function (frame) {
  11728. var newThumbFilename = frame.text;
  11729. if (newThumbFilename !== oldThumbFilename) {
  11730. // Found one with a different filename. Make sure it hasn't already been loaded on this page visit
  11731. if (!_this9.loadedImages.includes(newThumbFilename)) {
  11732. foundOne = true;
  11733. _this9.player.debug.log("Preloading thumb filename: ".concat(newThumbFilename));
  11734. var urlPrefix = _this9.thumbnails[0].urlPrefix;
  11735. var thumbURL = urlPrefix + newThumbFilename;
  11736. var previewImage = new Image();
  11737. previewImage.src = thumbURL;
  11738. previewImage.onload = function () {
  11739. _this9.player.debug.log("Preloaded thumb filename: ".concat(newThumbFilename));
  11740. if (!_this9.loadedImages.includes(newThumbFilename)) _this9.loadedImages.push(newThumbFilename); // We don't resolve until the thumb is loaded
  11741. resolve();
  11742. };
  11743. }
  11744. }
  11745. }); // If there are none to preload then we want to resolve immediately
  11746. if (!foundOne) {
  11747. resolve();
  11748. }
  11749. }
  11750. }, 300);
  11751. });
  11752. } // If user has been hovering current image for half a second, look for a higher quality one
  11753. }, {
  11754. key: "getHigherQuality",
  11755. value: function getHigherQuality(currentQualityIndex, previewImage, frame, thumbFilename) {
  11756. var _this10 = this;
  11757. if (currentQualityIndex < this.thumbnails.length - 1) {
  11758. // 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
  11759. var previewImageHeight = previewImage.naturalHeight;
  11760. if (this.usingSprites) {
  11761. previewImageHeight = frame.h;
  11762. }
  11763. if (previewImageHeight < this.thumbContainerHeight) {
  11764. // Recurse back to the loadImage function - show a higher quality one, but only if the viewer is on this frame for a while
  11765. setTimeout(function () {
  11766. // Make sure the mouse hasn't already moved on and started hovering at another image
  11767. if (_this10.showingThumbFilename === thumbFilename) {
  11768. _this10.player.debug.log("Showing higher quality thumb for: ".concat(thumbFilename));
  11769. _this10.loadImage(currentQualityIndex + 1);
  11770. }
  11771. }, 300);
  11772. }
  11773. }
  11774. }
  11775. }, {
  11776. key: "toggleThumbContainer",
  11777. value: function toggleThumbContainer() {
  11778. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11779. var clearShowing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11780. var className = this.player.config.classNames.previewThumbnails.thumbContainerShown;
  11781. this.elements.thumb.container.classList.toggle(className, toggle);
  11782. if (!toggle && clearShowing) {
  11783. this.showingThumb = null;
  11784. this.showingThumbFilename = null;
  11785. }
  11786. }
  11787. }, {
  11788. key: "toggleScrubbingContainer",
  11789. value: function toggleScrubbingContainer() {
  11790. var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11791. var className = this.player.config.classNames.previewThumbnails.scrubbingContainerShown;
  11792. this.elements.scrubbing.container.classList.toggle(className, toggle);
  11793. if (!toggle) {
  11794. this.showingThumb = null;
  11795. this.showingThumbFilename = null;
  11796. }
  11797. }
  11798. }, {
  11799. key: "determineContainerAutoSizing",
  11800. value: function determineContainerAutoSizing() {
  11801. if (this.elements.thumb.imageContainer.clientHeight > 20 || this.elements.thumb.imageContainer.clientWidth > 20) {
  11802. // This will prevent auto sizing in this.setThumbContainerSizeAndPos()
  11803. this.sizeSpecifiedInCSS = true;
  11804. }
  11805. } // 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
  11806. }, {
  11807. key: "setThumbContainerSizeAndPos",
  11808. value: function setThumbContainerSizeAndPos() {
  11809. if (!this.sizeSpecifiedInCSS) {
  11810. var thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio);
  11811. this.elements.thumb.imageContainer.style.height = "".concat(this.thumbContainerHeight, "px");
  11812. this.elements.thumb.imageContainer.style.width = "".concat(thumbWidth, "px");
  11813. } else if (this.elements.thumb.imageContainer.clientHeight > 20 && this.elements.thumb.imageContainer.clientWidth < 20) {
  11814. var _thumbWidth = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio);
  11815. this.elements.thumb.imageContainer.style.width = "".concat(_thumbWidth, "px");
  11816. } else if (this.elements.thumb.imageContainer.clientHeight < 20 && this.elements.thumb.imageContainer.clientWidth > 20) {
  11817. var thumbHeight = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio);
  11818. this.elements.thumb.imageContainer.style.height = "".concat(thumbHeight, "px");
  11819. }
  11820. this.setThumbContainerPos();
  11821. }
  11822. }, {
  11823. key: "setThumbContainerPos",
  11824. value: function setThumbContainerPos() {
  11825. var seekbarRect = this.player.elements.progress.getBoundingClientRect();
  11826. var plyrRect = this.player.elements.container.getBoundingClientRect();
  11827. 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
  11828. var minVal = plyrRect.left - seekbarRect.left + 10;
  11829. var maxVal = plyrRect.right - seekbarRect.left - container.clientWidth - 10; // Set preview container position to: mousepos, minus seekbar.left, minus half of previewContainer.clientWidth
  11830. var previewPos = this.mousePosX - seekbarRect.left - container.clientWidth / 2;
  11831. if (previewPos < minVal) {
  11832. previewPos = minVal;
  11833. }
  11834. if (previewPos > maxVal) {
  11835. previewPos = maxVal;
  11836. }
  11837. container.style.left = "".concat(previewPos, "px");
  11838. } // Can't use 100% width, in case the video is a different aspect ratio to the video container
  11839. }, {
  11840. key: "setScrubbingContainerSize",
  11841. value: function setScrubbingContainerSize() {
  11842. var _fitRatio = fitRatio(this.thumbAspectRatio, {
  11843. width: this.player.media.clientWidth,
  11844. height: this.player.media.clientHeight
  11845. }),
  11846. width = _fitRatio.width,
  11847. height = _fitRatio.height;
  11848. this.elements.scrubbing.container.style.width = "".concat(width, "px");
  11849. this.elements.scrubbing.container.style.height = "".concat(height, "px");
  11850. } // Sprites need to be offset to the correct location
  11851. }, {
  11852. key: "setImageSizeAndOffset",
  11853. value: function setImageSizeAndOffset(previewImage, frame) {
  11854. if (!this.usingSprites) {
  11855. return;
  11856. } // Find difference between height and preview container height
  11857. var multiplier = this.thumbContainerHeight / frame.h; // eslint-disable-next-line no-param-reassign
  11858. previewImage.style.height = "".concat(previewImage.naturalHeight * multiplier, "px"); // eslint-disable-next-line no-param-reassign
  11859. previewImage.style.width = "".concat(previewImage.naturalWidth * multiplier, "px"); // eslint-disable-next-line no-param-reassign
  11860. previewImage.style.left = "-".concat(frame.x * multiplier, "px"); // eslint-disable-next-line no-param-reassign
  11861. previewImage.style.top = "-".concat(frame.y * multiplier, "px");
  11862. }
  11863. }, {
  11864. key: "enabled",
  11865. get: function get() {
  11866. return this.player.isHTML5 && this.player.isVideo && this.player.config.previewThumbnails.enabled;
  11867. }
  11868. }, {
  11869. key: "currentImageContainer",
  11870. get: function get() {
  11871. if (this.mouseDown) {
  11872. return this.elements.scrubbing.container;
  11873. }
  11874. return this.elements.thumb.imageContainer;
  11875. }
  11876. }, {
  11877. key: "usingSprites",
  11878. get: function get() {
  11879. return Object.keys(this.thumbnails[0].frames[0]).includes('w');
  11880. }
  11881. }, {
  11882. key: "thumbAspectRatio",
  11883. get: function get() {
  11884. if (this.usingSprites) {
  11885. return this.thumbnails[0].frames[0].w / this.thumbnails[0].frames[0].h;
  11886. }
  11887. return this.thumbnails[0].width / this.thumbnails[0].height;
  11888. }
  11889. }, {
  11890. key: "thumbContainerHeight",
  11891. get: function get() {
  11892. if (this.mouseDown) {
  11893. var _fitRatio2 = fitRatio(this.thumbAspectRatio, {
  11894. width: this.player.media.clientWidth,
  11895. height: this.player.media.clientHeight
  11896. }),
  11897. height = _fitRatio2.height;
  11898. return height;
  11899. } // If css is used this needs to return the css height for sprites to work (see setImageSizeAndOffset)
  11900. if (this.sizeSpecifiedInCSS) {
  11901. return this.elements.thumb.imageContainer.clientHeight;
  11902. }
  11903. return Math.floor(this.player.media.clientWidth / this.thumbAspectRatio / 4);
  11904. }
  11905. }, {
  11906. key: "currentImageElement",
  11907. get: function get() {
  11908. if (this.mouseDown) {
  11909. return this.currentScrubbingImageElement;
  11910. }
  11911. return this.currentThumbnailImageElement;
  11912. },
  11913. set: function set(element) {
  11914. if (this.mouseDown) {
  11915. this.currentScrubbingImageElement = element;
  11916. } else {
  11917. this.currentThumbnailImageElement = element;
  11918. }
  11919. }
  11920. }]);
  11921. return PreviewThumbnails;
  11922. }();
  11923. var source = {
  11924. // Add elements to HTML5 media (source, tracks, etc)
  11925. insertElements: function insertElements(type, attributes) {
  11926. var _this = this;
  11927. if (is$1.string(attributes)) {
  11928. insertElement(type, this.media, {
  11929. src: attributes
  11930. });
  11931. } else if (is$1.array(attributes)) {
  11932. attributes.forEach(function (attribute) {
  11933. insertElement(type, _this.media, attribute);
  11934. });
  11935. }
  11936. },
  11937. // Update source
  11938. // Sources are not checked for support so be careful
  11939. change: function change(input) {
  11940. var _this2 = this;
  11941. if (!getDeep(input, 'sources.length')) {
  11942. this.debug.warn('Invalid source format');
  11943. return;
  11944. } // Cancel current network requests
  11945. html5.cancelRequests.call(this); // Destroy instance and re-setup
  11946. this.destroy.call(this, function () {
  11947. // Reset quality options
  11948. _this2.options.quality = []; // Remove elements
  11949. removeElement(_this2.media);
  11950. _this2.media = null; // Reset class name
  11951. if (is$1.element(_this2.elements.container)) {
  11952. _this2.elements.container.removeAttribute('class');
  11953. } // Set the type and provider
  11954. var sources = input.sources,
  11955. type = input.type;
  11956. var _sources = _slicedToArray(sources, 1),
  11957. _sources$ = _sources[0],
  11958. _sources$$provider = _sources$.provider,
  11959. provider = _sources$$provider === void 0 ? providers.html5 : _sources$$provider,
  11960. src = _sources$.src;
  11961. var tagName = provider === 'html5' ? type : 'div';
  11962. var attributes = provider === 'html5' ? {} : {
  11963. src: src
  11964. };
  11965. Object.assign(_this2, {
  11966. provider: provider,
  11967. type: type,
  11968. // Check for support
  11969. supported: support.check(type, provider, _this2.config.playsinline),
  11970. // Create new element
  11971. media: createElement(tagName, attributes)
  11972. }); // Inject the new element
  11973. _this2.elements.container.appendChild(_this2.media); // Autoplay the new source?
  11974. if (is$1.boolean(input.autoplay)) {
  11975. _this2.config.autoplay = input.autoplay;
  11976. } // Set attributes for audio and video
  11977. if (_this2.isHTML5) {
  11978. if (_this2.config.crossorigin) {
  11979. _this2.media.setAttribute('crossorigin', '');
  11980. }
  11981. if (_this2.config.autoplay) {
  11982. _this2.media.setAttribute('autoplay', '');
  11983. }
  11984. if (!is$1.empty(input.poster)) {
  11985. _this2.poster = input.poster;
  11986. }
  11987. if (_this2.config.loop.active) {
  11988. _this2.media.setAttribute('loop', '');
  11989. }
  11990. if (_this2.config.muted) {
  11991. _this2.media.setAttribute('muted', '');
  11992. }
  11993. if (_this2.config.playsinline) {
  11994. _this2.media.setAttribute('playsinline', '');
  11995. }
  11996. } // Restore class hook
  11997. ui.addStyleHook.call(_this2); // Set new sources for html5
  11998. if (_this2.isHTML5) {
  11999. source.insertElements.call(_this2, 'source', sources);
  12000. } // Set video title
  12001. _this2.config.title = input.title; // Set up from scratch
  12002. media.setup.call(_this2); // HTML5 stuff
  12003. if (_this2.isHTML5) {
  12004. // Setup captions
  12005. if (Object.keys(input).includes('tracks')) {
  12006. source.insertElements.call(_this2, 'track', input.tracks);
  12007. }
  12008. } // If HTML5 or embed but not fully supported, setupInterface and call ready now
  12009. if (_this2.isHTML5 || _this2.isEmbed && !_this2.supported.ui) {
  12010. // Setup interface
  12011. ui.build.call(_this2);
  12012. } // Load HTML5 sources
  12013. if (_this2.isHTML5) {
  12014. _this2.media.load();
  12015. } // Update previewThumbnails config & reload plugin
  12016. if (!is$1.empty(input.previewThumbnails)) {
  12017. Object.assign(_this2.config.previewThumbnails, input.previewThumbnails); // Cleanup previewThumbnails plugin if it was loaded
  12018. if (_this2.previewThumbnails && _this2.previewThumbnails.loaded) {
  12019. _this2.previewThumbnails.destroy();
  12020. _this2.previewThumbnails = null;
  12021. } // Create new instance if it is still enabled
  12022. if (_this2.config.previewThumbnails.enabled) {
  12023. _this2.previewThumbnails = new PreviewThumbnails(_this2);
  12024. }
  12025. } // Update the fullscreen support
  12026. _this2.fullscreen.update();
  12027. }, true);
  12028. }
  12029. };
  12030. /**
  12031. * Returns a number whose value is limited to the given range.
  12032. *
  12033. * Example: limit the output of this computation to between 0 and 255
  12034. * (x * 255).clamp(0, 255)
  12035. *
  12036. * @param {Number} input
  12037. * @param {Number} min The lower boundary of the output range
  12038. * @param {Number} max The upper boundary of the output range
  12039. * @returns A number in the range [min, max]
  12040. * @type Number
  12041. */
  12042. function clamp() {
  12043. var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  12044. var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  12045. var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 255;
  12046. return Math.min(Math.max(input, min), max);
  12047. }
  12048. // TODO: Use a WeakMap for private globals
  12049. // const globals = new WeakMap();
  12050. // Plyr instance
  12051. var Plyr = /*#__PURE__*/function () {
  12052. function Plyr(target, options) {
  12053. var _this = this;
  12054. _classCallCheck(this, Plyr);
  12055. this.timers = {}; // State
  12056. this.ready = false;
  12057. this.loading = false;
  12058. this.failed = false; // Touch device
  12059. this.touch = support.touch; // Set the media element
  12060. this.media = target; // String selector passed
  12061. if (is$1.string(this.media)) {
  12062. this.media = document.querySelectorAll(this.media);
  12063. } // jQuery, NodeList or Array passed, use first element
  12064. if (window.jQuery && this.media instanceof jQuery || is$1.nodeList(this.media) || is$1.array(this.media)) {
  12065. // eslint-disable-next-line
  12066. this.media = this.media[0];
  12067. } // Set config
  12068. this.config = extend({}, defaults$1, Plyr.defaults, options || {}, function () {
  12069. try {
  12070. return JSON.parse(_this.media.getAttribute('data-plyr-config'));
  12071. } catch (e) {
  12072. return {};
  12073. }
  12074. }()); // Elements cache
  12075. this.elements = {
  12076. container: null,
  12077. fullscreen: null,
  12078. captions: null,
  12079. buttons: {},
  12080. display: {},
  12081. progress: {},
  12082. inputs: {},
  12083. settings: {
  12084. popup: null,
  12085. menu: null,
  12086. panels: {},
  12087. buttons: {}
  12088. }
  12089. }; // Captions
  12090. this.captions = {
  12091. active: null,
  12092. currentTrack: -1,
  12093. meta: new WeakMap()
  12094. }; // Fullscreen
  12095. this.fullscreen = {
  12096. active: false
  12097. }; // Options
  12098. this.options = {
  12099. speed: [],
  12100. quality: []
  12101. }; // Debugging
  12102. // TODO: move to globals
  12103. this.debug = new Console(this.config.debug); // Log config options and support
  12104. this.debug.log('Config', this.config);
  12105. this.debug.log('Support', support); // We need an element to setup
  12106. if (is$1.nullOrUndefined(this.media) || !is$1.element(this.media)) {
  12107. this.debug.error('Setup failed: no suitable element passed');
  12108. return;
  12109. } // Bail if the element is initialized
  12110. if (this.media.plyr) {
  12111. this.debug.warn('Target already setup');
  12112. return;
  12113. } // Bail if not enabled
  12114. if (!this.config.enabled) {
  12115. this.debug.error('Setup failed: disabled by config');
  12116. return;
  12117. } // Bail if disabled or no basic support
  12118. // You may want to disable certain UAs etc
  12119. if (!support.check().api) {
  12120. this.debug.error('Setup failed: no support');
  12121. return;
  12122. } // Cache original element state for .destroy()
  12123. var clone = this.media.cloneNode(true);
  12124. clone.autoplay = false;
  12125. this.elements.original = clone; // Set media type based on tag or data attribute
  12126. // Supported: video, audio, vimeo, youtube
  12127. var type = this.media.tagName.toLowerCase(); // Embed properties
  12128. var iframe = null;
  12129. var url = null; // Different setup based on type
  12130. switch (type) {
  12131. case 'div':
  12132. // Find the frame
  12133. iframe = this.media.querySelector('iframe'); // <iframe> type
  12134. if (is$1.element(iframe)) {
  12135. // Detect provider
  12136. url = parseUrl(iframe.getAttribute('src'));
  12137. this.provider = getProviderByUrl(url.toString()); // Rework elements
  12138. this.elements.container = this.media;
  12139. this.media = iframe; // Reset classname
  12140. this.elements.container.className = ''; // Get attributes from URL and set config
  12141. if (url.search.length) {
  12142. var truthy = ['1', 'true'];
  12143. if (truthy.includes(url.searchParams.get('autoplay'))) {
  12144. this.config.autoplay = true;
  12145. }
  12146. if (truthy.includes(url.searchParams.get('loop'))) {
  12147. this.config.loop.active = true;
  12148. } // TODO: replace fullscreen.iosNative with this playsinline config option
  12149. // YouTube requires the playsinline in the URL
  12150. if (this.isYouTube) {
  12151. this.config.playsinline = truthy.includes(url.searchParams.get('playsinline'));
  12152. this.config.youtube.hl = url.searchParams.get('hl'); // TODO: Should this be setting language?
  12153. } else {
  12154. this.config.playsinline = true;
  12155. }
  12156. }
  12157. } else {
  12158. // <div> with attributes
  12159. this.provider = this.media.getAttribute(this.config.attributes.embed.provider); // Remove attribute
  12160. this.media.removeAttribute(this.config.attributes.embed.provider);
  12161. } // Unsupported or missing provider
  12162. if (is$1.empty(this.provider) || !Object.keys(providers).includes(this.provider)) {
  12163. this.debug.error('Setup failed: Invalid provider');
  12164. return;
  12165. } // Audio will come later for external providers
  12166. this.type = types.video;
  12167. break;
  12168. case 'video':
  12169. case 'audio':
  12170. this.type = type;
  12171. this.provider = providers.html5; // Get config from attributes
  12172. if (this.media.hasAttribute('crossorigin')) {
  12173. this.config.crossorigin = true;
  12174. }
  12175. if (this.media.hasAttribute('autoplay')) {
  12176. this.config.autoplay = true;
  12177. }
  12178. if (this.media.hasAttribute('playsinline') || this.media.hasAttribute('webkit-playsinline')) {
  12179. this.config.playsinline = true;
  12180. }
  12181. if (this.media.hasAttribute('muted')) {
  12182. this.config.muted = true;
  12183. }
  12184. if (this.media.hasAttribute('loop')) {
  12185. this.config.loop.active = true;
  12186. }
  12187. break;
  12188. default:
  12189. this.debug.error('Setup failed: unsupported type');
  12190. return;
  12191. } // Check for support again but with type
  12192. this.supported = support.check(this.type, this.provider, this.config.playsinline); // If no support for even API, bail
  12193. if (!this.supported.api) {
  12194. this.debug.error('Setup failed: no support');
  12195. return;
  12196. }
  12197. this.eventListeners = []; // Create listeners
  12198. this.listeners = new Listeners(this); // Setup local storage for user settings
  12199. this.storage = new Storage(this); // Store reference
  12200. this.media.plyr = this; // Wrap media
  12201. if (!is$1.element(this.elements.container)) {
  12202. this.elements.container = createElement('div', {
  12203. tabindex: 0
  12204. });
  12205. wrap$1(this.media, this.elements.container);
  12206. } // Migrate custom properties from media to container (so they work 😉)
  12207. ui.migrateStyles.call(this); // Add style hook
  12208. ui.addStyleHook.call(this); // Setup media
  12209. media.setup.call(this); // Listen for events if debugging
  12210. if (this.config.debug) {
  12211. on.call(this, this.elements.container, this.config.events.join(' '), function (event) {
  12212. _this.debug.log("event: ".concat(event.type));
  12213. });
  12214. } // Setup fullscreen
  12215. this.fullscreen = new Fullscreen(this); // Setup interface
  12216. // If embed but not fully supported, build interface now to avoid flash of controls
  12217. if (this.isHTML5 || this.isEmbed && !this.supported.ui) {
  12218. ui.build.call(this);
  12219. } // Container listeners
  12220. this.listeners.container(); // Global listeners
  12221. this.listeners.global(); // Setup ads if provided
  12222. if (this.config.ads.enabled) {
  12223. this.ads = new Ads(this);
  12224. } // Autoplay if required
  12225. if (this.isHTML5 && this.config.autoplay) {
  12226. setTimeout(function () {
  12227. return silencePromise(_this.play());
  12228. }, 10);
  12229. } // Seek time will be recorded (in listeners.js) so we can prevent hiding controls for a few seconds after seek
  12230. this.lastSeekTime = 0; // Setup preview thumbnails if enabled
  12231. if (this.config.previewThumbnails.enabled) {
  12232. this.previewThumbnails = new PreviewThumbnails(this);
  12233. }
  12234. } // ---------------------------------------
  12235. // API
  12236. // ---------------------------------------
  12237. /**
  12238. * Types and provider helpers
  12239. */
  12240. _createClass(Plyr, [{
  12241. key: "play",
  12242. /**
  12243. * Play the media, or play the advertisement (if they are not blocked)
  12244. */
  12245. value: function play() {
  12246. var _this2 = this;
  12247. if (!is$1.function(this.media.play)) {
  12248. return null;
  12249. } // Intecept play with ads
  12250. if (this.ads && this.ads.enabled) {
  12251. this.ads.managerPromise.then(function () {
  12252. return _this2.ads.play();
  12253. }).catch(function () {
  12254. return silencePromise(_this2.media.play());
  12255. });
  12256. } // Return the promise (for HTML5)
  12257. return this.media.play();
  12258. }
  12259. /**
  12260. * Pause the media
  12261. */
  12262. }, {
  12263. key: "pause",
  12264. value: function pause() {
  12265. if (!this.playing || !is$1.function(this.media.pause)) {
  12266. return null;
  12267. }
  12268. return this.media.pause();
  12269. }
  12270. /**
  12271. * Get playing state
  12272. */
  12273. }, {
  12274. key: "togglePlay",
  12275. /**
  12276. * Toggle playback based on current status
  12277. * @param {Boolean} input
  12278. */
  12279. value: function togglePlay(input) {
  12280. // Toggle based on current state if nothing passed
  12281. var toggle = is$1.boolean(input) ? input : !this.playing;
  12282. if (toggle) {
  12283. return this.play();
  12284. }
  12285. return this.pause();
  12286. }
  12287. /**
  12288. * Stop playback
  12289. */
  12290. }, {
  12291. key: "stop",
  12292. value: function stop() {
  12293. if (this.isHTML5) {
  12294. this.pause();
  12295. this.restart();
  12296. } else if (is$1.function(this.media.stop)) {
  12297. this.media.stop();
  12298. }
  12299. }
  12300. /**
  12301. * Restart playback
  12302. */
  12303. }, {
  12304. key: "restart",
  12305. value: function restart() {
  12306. this.currentTime = 0;
  12307. }
  12308. /**
  12309. * Rewind
  12310. * @param {Number} seekTime - how far to rewind in seconds. Defaults to the config.seekTime
  12311. */
  12312. }, {
  12313. key: "rewind",
  12314. value: function rewind(seekTime) {
  12315. this.currentTime -= is$1.number(seekTime) ? seekTime : this.config.seekTime;
  12316. }
  12317. /**
  12318. * Fast forward
  12319. * @param {Number} seekTime - how far to fast forward in seconds. Defaults to the config.seekTime
  12320. */
  12321. }, {
  12322. key: "forward",
  12323. value: function forward(seekTime) {
  12324. this.currentTime += is$1.number(seekTime) ? seekTime : this.config.seekTime;
  12325. }
  12326. /**
  12327. * Seek to a time
  12328. * @param {Number} input - where to seek to in seconds. Defaults to 0 (the start)
  12329. */
  12330. }, {
  12331. key: "increaseVolume",
  12332. /**
  12333. * Increase volume
  12334. * @param {Boolean} step - How much to decrease by (between 0 and 1)
  12335. */
  12336. value: function increaseVolume(step) {
  12337. var volume = this.media.muted ? 0 : this.volume;
  12338. this.volume = volume + (is$1.number(step) ? step : 0);
  12339. }
  12340. /**
  12341. * Decrease volume
  12342. * @param {Boolean} step - How much to decrease by (between 0 and 1)
  12343. */
  12344. }, {
  12345. key: "decreaseVolume",
  12346. value: function decreaseVolume(step) {
  12347. this.increaseVolume(-step);
  12348. }
  12349. /**
  12350. * Set muted state
  12351. * @param {Boolean} mute
  12352. */
  12353. }, {
  12354. key: "toggleCaptions",
  12355. /**
  12356. * Toggle captions
  12357. * @param {Boolean} input - Whether to enable captions
  12358. */
  12359. value: function toggleCaptions(input) {
  12360. captions.toggle.call(this, input, false);
  12361. }
  12362. /**
  12363. * Set the caption track by index
  12364. * @param {Number} - Caption index
  12365. */
  12366. }, {
  12367. key: "airplay",
  12368. /**
  12369. * Trigger the airplay dialog
  12370. * TODO: update player with state, support, enabled
  12371. */
  12372. value: function airplay() {
  12373. // Show dialog if supported
  12374. if (support.airplay) {
  12375. this.media.webkitShowPlaybackTargetPicker();
  12376. }
  12377. }
  12378. /**
  12379. * Toggle the player controls
  12380. * @param {Boolean} [toggle] - Whether to show the controls
  12381. */
  12382. }, {
  12383. key: "toggleControls",
  12384. value: function toggleControls(toggle) {
  12385. // Don't toggle if missing UI support or if it's audio
  12386. if (this.supported.ui && !this.isAudio) {
  12387. // Get state before change
  12388. var isHidden = hasClass(this.elements.container, this.config.classNames.hideControls); // Negate the argument if not undefined since adding the class to hides the controls
  12389. var force = typeof toggle === 'undefined' ? undefined : !toggle; // Apply and get updated state
  12390. var hiding = toggleClass(this.elements.container, this.config.classNames.hideControls, force); // Close menu
  12391. if (hiding && is$1.array(this.config.controls) && this.config.controls.includes('settings') && !is$1.empty(this.config.settings)) {
  12392. controls.toggleMenu.call(this, false);
  12393. } // Trigger event on change
  12394. if (hiding !== isHidden) {
  12395. var eventName = hiding ? 'controlshidden' : 'controlsshown';
  12396. triggerEvent.call(this, this.media, eventName);
  12397. }
  12398. return !hiding;
  12399. }
  12400. return false;
  12401. }
  12402. /**
  12403. * Add event listeners
  12404. * @param {String} event - Event type
  12405. * @param {Function} callback - Callback for when event occurs
  12406. */
  12407. }, {
  12408. key: "on",
  12409. value: function on$1(event, callback) {
  12410. on.call(this, this.elements.container, event, callback);
  12411. }
  12412. /**
  12413. * Add event listeners once
  12414. * @param {String} event - Event type
  12415. * @param {Function} callback - Callback for when event occurs
  12416. */
  12417. }, {
  12418. key: "once",
  12419. value: function once$1(event, callback) {
  12420. once.call(this, this.elements.container, event, callback);
  12421. }
  12422. /**
  12423. * Remove event listeners
  12424. * @param {String} event - Event type
  12425. * @param {Function} callback - Callback for when event occurs
  12426. */
  12427. }, {
  12428. key: "off",
  12429. value: function off$1(event, callback) {
  12430. off(this.elements.container, event, callback);
  12431. }
  12432. /**
  12433. * Destroy an instance
  12434. * Event listeners are removed when elements are removed
  12435. * http://stackoverflow.com/questions/12528049/if-a-dom-element-is-removed-are-its-listeners-also-removed-from-memory
  12436. * @param {Function} callback - Callback for when destroy is complete
  12437. * @param {Boolean} soft - Whether it's a soft destroy (for source changes etc)
  12438. */
  12439. }, {
  12440. key: "destroy",
  12441. value: function destroy(callback) {
  12442. var _this3 = this;
  12443. var soft = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12444. if (!this.ready) {
  12445. return;
  12446. }
  12447. var done = function done() {
  12448. // Reset overflow (incase destroyed while in fullscreen)
  12449. document.body.style.overflow = ''; // GC for embed
  12450. _this3.embed = null; // If it's a soft destroy, make minimal changes
  12451. if (soft) {
  12452. if (Object.keys(_this3.elements).length) {
  12453. // Remove elements
  12454. removeElement(_this3.elements.buttons.play);
  12455. removeElement(_this3.elements.captions);
  12456. removeElement(_this3.elements.controls);
  12457. removeElement(_this3.elements.wrapper); // Clear for GC
  12458. _this3.elements.buttons.play = null;
  12459. _this3.elements.captions = null;
  12460. _this3.elements.controls = null;
  12461. _this3.elements.wrapper = null;
  12462. } // Callback
  12463. if (is$1.function(callback)) {
  12464. callback();
  12465. }
  12466. } else {
  12467. // Unbind listeners
  12468. unbindListeners.call(_this3); // Replace the container with the original element provided
  12469. replaceElement(_this3.elements.original, _this3.elements.container); // Event
  12470. triggerEvent.call(_this3, _this3.elements.original, 'destroyed', true); // Callback
  12471. if (is$1.function(callback)) {
  12472. callback.call(_this3.elements.original);
  12473. } // Reset state
  12474. _this3.ready = false; // Clear for garbage collection
  12475. setTimeout(function () {
  12476. _this3.elements = null;
  12477. _this3.media = null;
  12478. }, 200);
  12479. }
  12480. }; // Stop playback
  12481. this.stop(); // Clear timeouts
  12482. clearTimeout(this.timers.loading);
  12483. clearTimeout(this.timers.controls);
  12484. clearTimeout(this.timers.resized); // Provider specific stuff
  12485. if (this.isHTML5) {
  12486. // Restore native video controls
  12487. ui.toggleNativeControls.call(this, true); // Clean up
  12488. done();
  12489. } else if (this.isYouTube) {
  12490. // Clear timers
  12491. clearInterval(this.timers.buffering);
  12492. clearInterval(this.timers.playing); // Destroy YouTube API
  12493. if (this.embed !== null && is$1.function(this.embed.destroy)) {
  12494. this.embed.destroy();
  12495. } // Clean up
  12496. done();
  12497. } else if (this.isVimeo) {
  12498. // Destroy Vimeo API
  12499. // then clean up (wait, to prevent postmessage errors)
  12500. if (this.embed !== null) {
  12501. this.embed.unload().then(done);
  12502. } // Vimeo does not always return
  12503. setTimeout(done, 200);
  12504. }
  12505. }
  12506. /**
  12507. * Check for support for a mime type (HTML5 only)
  12508. * @param {String} type - Mime type
  12509. */
  12510. }, {
  12511. key: "supports",
  12512. value: function supports(type) {
  12513. return support.mime.call(this, type);
  12514. }
  12515. /**
  12516. * Check for support
  12517. * @param {String} type - Player type (audio/video)
  12518. * @param {String} provider - Provider (html5/youtube/vimeo)
  12519. * @param {Boolean} inline - Where player has `playsinline` sttribute
  12520. */
  12521. }, {
  12522. key: "isHTML5",
  12523. get: function get() {
  12524. return this.provider === providers.html5;
  12525. }
  12526. }, {
  12527. key: "isEmbed",
  12528. get: function get() {
  12529. return this.isYouTube || this.isVimeo;
  12530. }
  12531. }, {
  12532. key: "isYouTube",
  12533. get: function get() {
  12534. return this.provider === providers.youtube;
  12535. }
  12536. }, {
  12537. key: "isVimeo",
  12538. get: function get() {
  12539. return this.provider === providers.vimeo;
  12540. }
  12541. }, {
  12542. key: "isVideo",
  12543. get: function get() {
  12544. return this.type === types.video;
  12545. }
  12546. }, {
  12547. key: "isAudio",
  12548. get: function get() {
  12549. return this.type === types.audio;
  12550. }
  12551. }, {
  12552. key: "playing",
  12553. get: function get() {
  12554. return Boolean(this.ready && !this.paused && !this.ended);
  12555. }
  12556. /**
  12557. * Get paused state
  12558. */
  12559. }, {
  12560. key: "paused",
  12561. get: function get() {
  12562. return Boolean(this.media.paused);
  12563. }
  12564. /**
  12565. * Get stopped state
  12566. */
  12567. }, {
  12568. key: "stopped",
  12569. get: function get() {
  12570. return Boolean(this.paused && this.currentTime === 0);
  12571. }
  12572. /**
  12573. * Get ended state
  12574. */
  12575. }, {
  12576. key: "ended",
  12577. get: function get() {
  12578. return Boolean(this.media.ended);
  12579. }
  12580. }, {
  12581. key: "currentTime",
  12582. set: function set(input) {
  12583. // Bail if media duration isn't available yet
  12584. if (!this.duration) {
  12585. return;
  12586. } // Validate input
  12587. var inputIsValid = is$1.number(input) && input > 0; // Set
  12588. this.media.currentTime = inputIsValid ? Math.min(input, this.duration) : 0; // Logging
  12589. this.debug.log("Seeking to ".concat(this.currentTime, " seconds"));
  12590. }
  12591. /**
  12592. * Get current time
  12593. */
  12594. ,
  12595. get: function get() {
  12596. return Number(this.media.currentTime);
  12597. }
  12598. /**
  12599. * Get buffered
  12600. */
  12601. }, {
  12602. key: "buffered",
  12603. get: function get() {
  12604. var buffered = this.media.buffered; // YouTube / Vimeo return a float between 0-1
  12605. if (is$1.number(buffered)) {
  12606. return buffered;
  12607. } // HTML5
  12608. // TODO: Handle buffered chunks of the media
  12609. // (i.e. seek to another section buffers only that section)
  12610. if (buffered && buffered.length && this.duration > 0) {
  12611. return buffered.end(0) / this.duration;
  12612. }
  12613. return 0;
  12614. }
  12615. /**
  12616. * Get seeking status
  12617. */
  12618. }, {
  12619. key: "seeking",
  12620. get: function get() {
  12621. return Boolean(this.media.seeking);
  12622. }
  12623. /**
  12624. * Get the duration of the current media
  12625. */
  12626. }, {
  12627. key: "duration",
  12628. get: function get() {
  12629. // Faux duration set via config
  12630. var fauxDuration = parseFloat(this.config.duration); // Media duration can be NaN or Infinity before the media has loaded
  12631. var realDuration = (this.media || {}).duration;
  12632. var duration = !is$1.number(realDuration) || realDuration === Infinity ? 0 : realDuration; // If config duration is funky, use regular duration
  12633. return fauxDuration || duration;
  12634. }
  12635. /**
  12636. * Set the player volume
  12637. * @param {Number} value - must be between 0 and 1. Defaults to the value from local storage and config.volume if not set in storage
  12638. */
  12639. }, {
  12640. key: "volume",
  12641. set: function set(value) {
  12642. var volume = value;
  12643. var max = 1;
  12644. var min = 0;
  12645. if (is$1.string(volume)) {
  12646. volume = Number(volume);
  12647. } // Load volume from storage if no value specified
  12648. if (!is$1.number(volume)) {
  12649. volume = this.storage.get('volume');
  12650. } // Use config if all else fails
  12651. if (!is$1.number(volume)) {
  12652. volume = this.config.volume;
  12653. } // Maximum is volumeMax
  12654. if (volume > max) {
  12655. volume = max;
  12656. } // Minimum is volumeMin
  12657. if (volume < min) {
  12658. volume = min;
  12659. } // Update config
  12660. this.config.volume = volume; // Set the player volume
  12661. this.media.volume = volume; // If muted, and we're increasing volume manually, reset muted state
  12662. if (!is$1.empty(value) && this.muted && volume > 0) {
  12663. this.muted = false;
  12664. }
  12665. }
  12666. /**
  12667. * Get the current player volume
  12668. */
  12669. ,
  12670. get: function get() {
  12671. return Number(this.media.volume);
  12672. }
  12673. }, {
  12674. key: "muted",
  12675. set: function set(mute) {
  12676. var toggle = mute; // Load muted state from storage
  12677. if (!is$1.boolean(toggle)) {
  12678. toggle = this.storage.get('muted');
  12679. } // Use config if all else fails
  12680. if (!is$1.boolean(toggle)) {
  12681. toggle = this.config.muted;
  12682. } // Update config
  12683. this.config.muted = toggle; // Set mute on the player
  12684. this.media.muted = toggle;
  12685. }
  12686. /**
  12687. * Get current muted state
  12688. */
  12689. ,
  12690. get: function get() {
  12691. return Boolean(this.media.muted);
  12692. }
  12693. /**
  12694. * Check if the media has audio
  12695. */
  12696. }, {
  12697. key: "hasAudio",
  12698. get: function get() {
  12699. // Assume yes for all non HTML5 (as we can't tell...)
  12700. if (!this.isHTML5) {
  12701. return true;
  12702. }
  12703. if (this.isAudio) {
  12704. return true;
  12705. } // Get audio tracks
  12706. return Boolean(this.media.mozHasAudio) || Boolean(this.media.webkitAudioDecodedByteCount) || Boolean(this.media.audioTracks && this.media.audioTracks.length);
  12707. }
  12708. /**
  12709. * Set playback speed
  12710. * @param {Number} speed - the speed of playback (0.5-2.0)
  12711. */
  12712. }, {
  12713. key: "speed",
  12714. set: function set(input) {
  12715. var _this4 = this;
  12716. var speed = null;
  12717. if (is$1.number(input)) {
  12718. speed = input;
  12719. }
  12720. if (!is$1.number(speed)) {
  12721. speed = this.storage.get('speed');
  12722. }
  12723. if (!is$1.number(speed)) {
  12724. speed = this.config.speed.selected;
  12725. } // Clamp to min/max
  12726. var min = this.minimumSpeed,
  12727. max = this.maximumSpeed;
  12728. speed = clamp(speed, min, max); // Update config
  12729. this.config.speed.selected = speed; // Set media speed
  12730. setTimeout(function () {
  12731. _this4.media.playbackRate = speed;
  12732. }, 0);
  12733. }
  12734. /**
  12735. * Get current playback speed
  12736. */
  12737. ,
  12738. get: function get() {
  12739. return Number(this.media.playbackRate);
  12740. }
  12741. /**
  12742. * Get the minimum allowed speed
  12743. */
  12744. }, {
  12745. key: "minimumSpeed",
  12746. get: function get() {
  12747. if (this.isYouTube) {
  12748. // https://developers.google.com/youtube/iframe_api_reference#setPlaybackRate
  12749. return Math.min.apply(Math, _toConsumableArray(this.options.speed));
  12750. }
  12751. if (this.isVimeo) {
  12752. // https://github.com/vimeo/player.js/#setplaybackrateplaybackrate-number-promisenumber-rangeerrorerror
  12753. return 0.5;
  12754. } // https://stackoverflow.com/a/32320020/1191319
  12755. return 0.0625;
  12756. }
  12757. /**
  12758. * Get the maximum allowed speed
  12759. */
  12760. }, {
  12761. key: "maximumSpeed",
  12762. get: function get() {
  12763. if (this.isYouTube) {
  12764. // https://developers.google.com/youtube/iframe_api_reference#setPlaybackRate
  12765. return Math.max.apply(Math, _toConsumableArray(this.options.speed));
  12766. }
  12767. if (this.isVimeo) {
  12768. // https://github.com/vimeo/player.js/#setplaybackrateplaybackrate-number-promisenumber-rangeerrorerror
  12769. return 2;
  12770. } // https://stackoverflow.com/a/32320020/1191319
  12771. return 16;
  12772. }
  12773. /**
  12774. * Set playback quality
  12775. * Currently HTML5 & YouTube only
  12776. * @param {Number} input - Quality level
  12777. */
  12778. }, {
  12779. key: "quality",
  12780. set: function set(input) {
  12781. var config = this.config.quality;
  12782. var options = this.options.quality;
  12783. if (!options.length) {
  12784. return;
  12785. }
  12786. var quality = [!is$1.empty(input) && Number(input), this.storage.get('quality'), config.selected, config.default].find(is$1.number);
  12787. var updateStorage = true;
  12788. if (!options.includes(quality)) {
  12789. var value = closest$1(options, quality);
  12790. this.debug.warn("Unsupported quality option: ".concat(quality, ", using ").concat(value, " instead"));
  12791. quality = value; // Don't update storage if quality is not supported
  12792. updateStorage = false;
  12793. } // Update config
  12794. config.selected = quality; // Set quality
  12795. this.media.quality = quality; // Save to storage
  12796. if (updateStorage) {
  12797. this.storage.set({
  12798. quality: quality
  12799. });
  12800. }
  12801. }
  12802. /**
  12803. * Get current quality level
  12804. */
  12805. ,
  12806. get: function get() {
  12807. return this.media.quality;
  12808. }
  12809. /**
  12810. * Toggle loop
  12811. * TODO: Finish fancy new logic. Set the indicator on load as user may pass loop as config
  12812. * @param {Boolean} input - Whether to loop or not
  12813. */
  12814. }, {
  12815. key: "loop",
  12816. set: function set(input) {
  12817. var toggle = is$1.boolean(input) ? input : this.config.loop.active;
  12818. this.config.loop.active = toggle;
  12819. this.media.loop = toggle; // Set default to be a true toggle
  12820. /* const type = ['start', 'end', 'all', 'none', 'toggle'].includes(input) ? input : 'toggle';
  12821. switch (type) {
  12822. case 'start':
  12823. if (this.config.loop.end && this.config.loop.end <= this.currentTime) {
  12824. this.config.loop.end = null;
  12825. }
  12826. this.config.loop.start = this.currentTime;
  12827. // this.config.loop.indicator.start = this.elements.display.played.value;
  12828. break;
  12829. case 'end':
  12830. if (this.config.loop.start >= this.currentTime) {
  12831. return this;
  12832. }
  12833. this.config.loop.end = this.currentTime;
  12834. // this.config.loop.indicator.end = this.elements.display.played.value;
  12835. break;
  12836. case 'all':
  12837. this.config.loop.start = 0;
  12838. this.config.loop.end = this.duration - 2;
  12839. this.config.loop.indicator.start = 0;
  12840. this.config.loop.indicator.end = 100;
  12841. break;
  12842. case 'toggle':
  12843. if (this.config.loop.active) {
  12844. this.config.loop.start = 0;
  12845. this.config.loop.end = null;
  12846. } else {
  12847. this.config.loop.start = 0;
  12848. this.config.loop.end = this.duration - 2;
  12849. }
  12850. break;
  12851. default:
  12852. this.config.loop.start = 0;
  12853. this.config.loop.end = null;
  12854. break;
  12855. } */
  12856. }
  12857. /**
  12858. * Get current loop state
  12859. */
  12860. ,
  12861. get: function get() {
  12862. return Boolean(this.media.loop);
  12863. }
  12864. /**
  12865. * Set new media source
  12866. * @param {Object} input - The new source object (see docs)
  12867. */
  12868. }, {
  12869. key: "source",
  12870. set: function set(input) {
  12871. source.change.call(this, input);
  12872. }
  12873. /**
  12874. * Get current source
  12875. */
  12876. ,
  12877. get: function get() {
  12878. return this.media.currentSrc;
  12879. }
  12880. /**
  12881. * Get a download URL (either source or custom)
  12882. */
  12883. }, {
  12884. key: "download",
  12885. get: function get() {
  12886. var download = this.config.urls.download;
  12887. return is$1.url(download) ? download : this.source;
  12888. }
  12889. /**
  12890. * Set the download URL
  12891. */
  12892. ,
  12893. set: function set(input) {
  12894. if (!is$1.url(input)) {
  12895. return;
  12896. }
  12897. this.config.urls.download = input;
  12898. controls.setDownloadUrl.call(this);
  12899. }
  12900. /**
  12901. * Set the poster image for a video
  12902. * @param {String} input - the URL for the new poster image
  12903. */
  12904. }, {
  12905. key: "poster",
  12906. set: function set(input) {
  12907. if (!this.isVideo) {
  12908. this.debug.warn('Poster can only be set for video');
  12909. return;
  12910. }
  12911. ui.setPoster.call(this, input, false).catch(function () {});
  12912. }
  12913. /**
  12914. * Get the current poster image
  12915. */
  12916. ,
  12917. get: function get() {
  12918. if (!this.isVideo) {
  12919. return null;
  12920. }
  12921. return this.media.getAttribute('poster') || this.media.getAttribute('data-poster');
  12922. }
  12923. /**
  12924. * Get the current aspect ratio in use
  12925. */
  12926. }, {
  12927. key: "ratio",
  12928. get: function get() {
  12929. if (!this.isVideo) {
  12930. return null;
  12931. }
  12932. var ratio = reduceAspectRatio(getAspectRatio.call(this));
  12933. return is$1.array(ratio) ? ratio.join(':') : ratio;
  12934. }
  12935. /**
  12936. * Set video aspect ratio
  12937. */
  12938. ,
  12939. set: function set(input) {
  12940. if (!this.isVideo) {
  12941. this.debug.warn('Aspect ratio can only be set for video');
  12942. return;
  12943. }
  12944. if (!is$1.string(input) || !validateRatio(input)) {
  12945. this.debug.error("Invalid aspect ratio specified (".concat(input, ")"));
  12946. return;
  12947. }
  12948. this.config.ratio = input;
  12949. setAspectRatio.call(this);
  12950. }
  12951. /**
  12952. * Set the autoplay state
  12953. * @param {Boolean} input - Whether to autoplay or not
  12954. */
  12955. }, {
  12956. key: "autoplay",
  12957. set: function set(input) {
  12958. var toggle = is$1.boolean(input) ? input : this.config.autoplay;
  12959. this.config.autoplay = toggle;
  12960. }
  12961. /**
  12962. * Get the current autoplay state
  12963. */
  12964. ,
  12965. get: function get() {
  12966. return Boolean(this.config.autoplay);
  12967. }
  12968. }, {
  12969. key: "currentTrack",
  12970. set: function set(input) {
  12971. captions.set.call(this, input, false);
  12972. }
  12973. /**
  12974. * Get the current caption track index (-1 if disabled)
  12975. */
  12976. ,
  12977. get: function get() {
  12978. var _this$captions = this.captions,
  12979. toggled = _this$captions.toggled,
  12980. currentTrack = _this$captions.currentTrack;
  12981. return toggled ? currentTrack : -1;
  12982. }
  12983. /**
  12984. * Set the wanted language for captions
  12985. * Since tracks can be added later it won't update the actual caption track until there is a matching track
  12986. * @param {String} - Two character ISO language code (e.g. EN, FR, PT, etc)
  12987. */
  12988. }, {
  12989. key: "language",
  12990. set: function set(input) {
  12991. captions.setLanguage.call(this, input, false);
  12992. }
  12993. /**
  12994. * Get the current track's language
  12995. */
  12996. ,
  12997. get: function get() {
  12998. return (captions.getCurrentTrack.call(this) || {}).language;
  12999. }
  13000. /**
  13001. * Toggle picture-in-picture playback on WebKit/MacOS
  13002. * TODO: update player with state, support, enabled
  13003. * TODO: detect outside changes
  13004. */
  13005. }, {
  13006. key: "pip",
  13007. set: function set(input) {
  13008. // Bail if no support
  13009. if (!support.pip) {
  13010. return;
  13011. } // Toggle based on current state if not passed
  13012. var toggle = is$1.boolean(input) ? input : !this.pip; // Toggle based on current state
  13013. // Safari
  13014. if (is$1.function(this.media.webkitSetPresentationMode)) {
  13015. this.media.webkitSetPresentationMode(toggle ? pip.active : pip.inactive);
  13016. } // Chrome
  13017. if (is$1.function(this.media.requestPictureInPicture)) {
  13018. if (!this.pip && toggle) {
  13019. this.media.requestPictureInPicture();
  13020. } else if (this.pip && !toggle) {
  13021. document.exitPictureInPicture();
  13022. }
  13023. }
  13024. }
  13025. /**
  13026. * Get the current picture-in-picture state
  13027. */
  13028. ,
  13029. get: function get() {
  13030. if (!support.pip) {
  13031. return null;
  13032. } // Safari
  13033. if (!is$1.empty(this.media.webkitPresentationMode)) {
  13034. return this.media.webkitPresentationMode === pip.active;
  13035. } // Chrome
  13036. return this.media === document.pictureInPictureElement;
  13037. }
  13038. }], [{
  13039. key: "supported",
  13040. value: function supported(type, provider, inline) {
  13041. return support.check(type, provider, inline);
  13042. }
  13043. /**
  13044. * Load an SVG sprite into the page
  13045. * @param {String} url - URL for the SVG sprite
  13046. * @param {String} [id] - Unique ID
  13047. */
  13048. }, {
  13049. key: "loadSprite",
  13050. value: function loadSprite$1(url, id) {
  13051. return loadSprite(url, id);
  13052. }
  13053. /**
  13054. * Setup multiple instances
  13055. * @param {*} selector
  13056. * @param {Object} options
  13057. */
  13058. }, {
  13059. key: "setup",
  13060. value: function setup(selector) {
  13061. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  13062. var targets = null;
  13063. if (is$1.string(selector)) {
  13064. targets = Array.from(document.querySelectorAll(selector));
  13065. } else if (is$1.nodeList(selector)) {
  13066. targets = Array.from(selector);
  13067. } else if (is$1.array(selector)) {
  13068. targets = selector.filter(is$1.element);
  13069. }
  13070. if (is$1.empty(targets)) {
  13071. return null;
  13072. }
  13073. return targets.map(function (t) {
  13074. return new Plyr(t, options);
  13075. });
  13076. }
  13077. }]);
  13078. return Plyr;
  13079. }();
  13080. Plyr.defaults = cloneDeep(defaults$1);
  13081. // ==========================================================================
  13082. return Plyr;
  13083. })));