vendors.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214
  1. /*!
  2. Anime
  3. Version: v3.2.2
  4. Plugin URL: animejs.com
  5. License: Copyright 2023 Julian Garnier | Released under the MIT license
  6. !*/
  7. !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.anime=e()}(this,function(){"use strict";var i={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},M={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},j=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],l={CSS:{},springs:{}};function C(n,e,t){return Math.min(Math.max(n,e),t)}function u(n,e){return-1<n.indexOf(e)}function o(n,e){return n.apply(null,e)}var w={arr:function(n){return Array.isArray(n)},obj:function(n){return u(Object.prototype.toString.call(n),"Object")},pth:function(n){return w.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||w.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},nil:function(n){return w.und(n)||null===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return w.hex(n)||w.rgb(n)||w.hsl(n)},key:function(n){return!i.hasOwnProperty(n)&&!M.hasOwnProperty(n)&&"targets"!==n&&"keyframes"!==n}};function d(n){n=/\(([^)]+)\)/.exec(n);return n?n[1].split(",").map(function(n){return parseFloat(n)}):[]}function c(r,t){var n=d(r),e=C(w.und(n[0])?1:n[0],.1,100),a=C(w.und(n[1])?100:n[1],.1,100),o=C(w.und(n[2])?10:n[2],.1,100),n=C(w.und(n[3])?0:n[3],.1,100),u=Math.sqrt(a/e),i=o/(2*Math.sqrt(a*e)),c=i<1?u*Math.sqrt(1-i*i):0,s=i<1?(i*u-n)/c:-n+u;function f(n){var e=t?t*n/1e3:n,e=i<1?Math.exp(-e*i*u)*(+Math.cos(c*e)+s*Math.sin(c*e)):(1+s*e)*Math.exp(-e*u);return 0===n||1===n?n:1-e}return t?f:function(){var n=l.springs[r];if(n)return n;for(var e=0,t=0;;)if(1===f(e+=1/6)){if(16<=++t)break}else t=0;return n=e*(1/6)*1e3,l.springs[r]=n}}function q(e){return void 0===e&&(e=10),function(n){return Math.ceil(C(n,1e-6,1)*e)*(1/e)}}var H=function(b,e,M,t){if(0<=b&&b<=1&&0<=M&&M<=1){var x=new Float32Array(11);if(b!==e||M!==t)for(var n=0;n<11;++n)x[n]=k(.1*n,b,M);return function(n){return b===e&&M===t||0===n||1===n?n:k(r(n),e,t)}}function r(n){for(var e=0,t=1;10!==t&&x[t]<=n;++t)e+=.1;var r=e+.1*((n-x[--t])/(x[t+1]-x[t])),a=O(r,b,M);if(.001<=a){for(var o=n,u=r,i=b,c=M,s=0;s<4;++s){var f=O(u,i,c);if(0===f)return u;u-=(k(u,i,c)-o)/f}return u}if(0===a)return r;for(var l,d,p=n,h=e,g=e+.1,m=b,v=M,y=0;0<(l=k(d=h+(g-h)/2,m,v)-p)?g=d:h=d,1e-7<Math.abs(l)&&++y<10;);return d}};function r(n,e){return 1-3*e+3*n}function k(n,e,t){return((r(e,t)*n+(3*t-6*e))*n+3*e)*n}function O(n,e,t){return 3*r(e,t)*n*n+2*(3*t-6*e)*n+3*e}e={linear:function(){return function(n){return n}}},t={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Expo:function(){return function(n){return n?Math.pow(2,10*n-10):0}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,t=4;n<((e=Math.pow(2,--t))-1)/11;);return 1/Math.pow(4,3-t)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===e&&(e=.5);var t=C(n=void 0===n?1:n,1,10),r=C(e,.1,2);return function(n){return 0===n||1===n?n:-t*Math.pow(2,10*(n-1))*Math.sin((n-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint"].forEach(function(n,e){t[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(t).forEach(function(n){var r=t[n];e["easeIn"+n]=r,e["easeOut"+n]=function(e,t){return function(n){return 1-r(e,t)(1-n)}},e["easeInOut"+n]=function(e,t){return function(n){return n<.5?r(e,t)(2*n)/2:1-r(e,t)(-2*n+2)/2}},e["easeOutIn"+n]=function(e,t){return function(n){return n<.5?(1-r(e,t)(1-2*n))/2:(r(e,t)(2*n-1)+1)/2}}});var e,t,s=e;function P(n,e){if(w.fnc(n))return n;var t=n.split("(")[0],r=s[t],a=d(n);switch(t){case"spring":return c(n,e);case"cubicBezier":return o(H,a);case"steps":return o(q,a);default:return o(r,a)}}function a(n){try{return document.querySelectorAll(n)}catch(n){}}function I(n,e){for(var t,r=n.length,a=2<=arguments.length?e:void 0,o=[],u=0;u<r;u++)u in n&&(t=n[u],e.call(a,t,u,n))&&o.push(t);return o}function f(n){return n.reduce(function(n,e){return n.concat(w.arr(e)?f(e):e)},[])}function p(n){return w.arr(n)?n:(n=w.str(n)?a(n)||n:n)instanceof NodeList||n instanceof HTMLCollection?[].slice.call(n):[n]}function h(n,e){return n.some(function(n){return n===e})}function g(n){var e,t={};for(e in n)t[e]=n[e];return t}function x(n,e){var t,r=g(n);for(t in n)r[t]=(e.hasOwnProperty(t)?e:n)[t];return r}function D(n,e){var t,r=g(n);for(t in e)r[t]=(w.und(n[t])?e:n)[t];return r}function V(n){var e,t,r,a,o,u,i;return w.rgb(n)?(e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(t=n))?"rgba("+e[1]+",1)":t:w.hex(n)?(e=(e=n).replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(n,e,t,r){return e+e+t+t+r+r}),e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),"rgba("+parseInt(e[1],16)+","+parseInt(e[2],16)+","+parseInt(e[3],16)+",1)"):w.hsl(n)?(t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t=n)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t),n=parseInt(t[1],10)/360,u=parseInt(t[2],10)/100,i=parseInt(t[3],10)/100,t=t[4]||1,0==u?r=a=o=i:(r=c(u=2*i-(i=i<.5?i*(1+u):i+u-i*u),i,n+1/3),a=c(u,i,n),o=c(u,i,n-1/3)),"rgba("+255*r+","+255*a+","+255*o+","+t+")"):void 0;function c(n,e,t){return t<0&&(t+=1),1<t&&--t,t<1/6?n+6*(e-n)*t:t<.5?e:t<2/3?n+(e-n)*(2/3-t)*6:n}}function B(n){n=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(n)return n[1]}function m(n,e){return w.fnc(n)?n(e.target,e.id,e.total):n}function v(n,e){return n.getAttribute(e)}function y(n,e,t){var r,a,o;return h([t,"deg","rad","turn"],B(e))?e:(r=l.CSS[e+t],w.und(r)?(a=document.createElement(n.tagName),(n=n.parentNode&&n.parentNode!==document?n.parentNode:document.body).appendChild(a),a.style.position="absolute",a.style.width=100+t,o=100/a.offsetWidth,n.removeChild(a),n=o*parseFloat(e),l.CSS[e+t]=n):r)}function $(n,e,t){var r;if(e in n.style)return r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),e=n.style[e]||getComputedStyle(n).getPropertyValue(r)||"0",t?y(n,e,t):e}function b(n,e){return w.dom(n)&&!w.inp(n)&&(!w.nil(v(n,e))||w.svg(n)&&n[e])?"attribute":w.dom(n)&&h(j,e)?"transform":w.dom(n)&&"transform"!==e&&$(n,e)?"css":null!=n[e]?"object":void 0}function W(n){if(w.dom(n)){for(var e,t=n.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;e=r.exec(t);)a.set(e[1],e[2]);return a}}function X(n,e,t,r){var a=u(e,"scale")?1:0+(u(a=e,"translate")||"perspective"===a?"px":u(a,"rotate")||u(a,"skew")?"deg":void 0),o=W(n).get(e)||a;return t&&(t.transforms.list.set(e,o),t.transforms.last=e),r?y(n,o,r):o}function T(n,e,t,r){switch(b(n,e)){case"transform":return X(n,e,r,t);case"css":return $(n,e,t);case"attribute":return v(n,e);default:return n[e]||0}}function E(n,e){var t=/^(\*=|\+=|-=)/.exec(n);if(!t)return n;var r=B(n)||0,a=parseFloat(e),o=parseFloat(n.replace(t[0],""));switch(t[0][0]){case"+":return a+o+r;case"-":return a-o+r;case"*":return a*o+r}}function Y(n,e){var t;return w.col(n)?V(n):/\s/g.test(n)?n:(t=(t=B(n))?n.substr(0,n.length-t.length):n,e?t+e:t)}function F(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function Z(n){for(var e,t=n.points,r=0,a=0;a<t.numberOfItems;a++){var o=t.getItem(a);0<a&&(r+=F(e,o)),e=o}return r}function G(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return 2*Math.PI*v(n,"r");case"rect":return 2*v(t=n,"width")+2*v(t,"height");case"line":return F({x:v(t=n,"x1"),y:v(t,"y1")},{x:v(t,"x2"),y:v(t,"y2")});case"polyline":return Z(n);case"polygon":return e=n.points,Z(n)+F(e.getItem(e.numberOfItems-1),e.getItem(0))}var e,t}function Q(n,e){var e=e||{},n=e.el||function(n){for(var e=n.parentNode;w.svg(e)&&w.svg(e.parentNode);)e=e.parentNode;return e}(n),t=n.getBoundingClientRect(),r=v(n,"viewBox"),a=t.width,t=t.height,e=e.viewBox||(r?r.split(" "):[0,0,a,t]);return{el:n,viewBox:e,x:+e[0],y:+e[1],w:a,h:t,vW:e[2],vH:e[3]}}function z(n,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=Y(w.pth(n)?n.totalLength:n,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:w.str(n)||e?r.split(t):[]}}function A(n){return I(n?f(w.arr(n)?n.map(p):p(n)):[],function(n,e,t){return t.indexOf(n)===e})}function _(n){var t=A(n);return t.map(function(n,e){return{target:n,id:e,total:t.length,transforms:{list:W(n)}}})}function R(e){for(var t=I(f(e.map(function(n){return Object.keys(n)})),function(n){return w.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),a={},n=0;n<t.length;n++)!function(n){var r=t[n];a[r]=e.map(function(n){var e,t={};for(e in n)w.key(e)?e==r&&(t.value=n[e]):t[e]=n[e];return t})}(n);return a}function J(n,e){var t,r=[],a=e.keyframes;for(t in e=a?D(R(a),e):e)w.key(t)&&r.push({name:t,tweens:function(n,t){var e,r=g(t),a=(/^spring/.test(r.easing)&&(r.duration=c(r.easing)),w.arr(n)&&(2===(e=n.length)&&!w.obj(n[0])?n={value:n}:w.fnc(t.duration)||(r.duration=t.duration/e)),w.arr(n)?n:[n]);return a.map(function(n,e){n=w.obj(n)&&!w.pth(n)?n:{value:n};return w.und(n.delay)&&(n.delay=e?0:t.delay),w.und(n.endDelay)&&(n.endDelay=e===a.length-1?t.endDelay:0),n}).map(function(n){return D(n,r)})}(e[t],n)});return r}function K(i,c){var s;return i.tweens.map(function(n){var n=function(n,e){var t,r={};for(t in n){var a=m(n[t],e);w.arr(a)&&1===(a=a.map(function(n){return m(n,e)})).length&&(a=a[0]),r[t]=a}return r.duration=parseFloat(r.duration),r.delay=parseFloat(r.delay),r}(n,c),e=n.value,t=w.arr(e)?e[1]:e,r=B(t),a=T(c.target,i.name,r,c),o=s?s.to.original:a,u=w.arr(e)?e[0]:o,a=B(u)||B(a),r=r||a;return w.und(t)&&(t=o),n.from=z(u,r),n.to=z(E(t,u),r),n.start=s?s.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=P(n.easing,n.duration),n.isPath=w.pth(e),n.isPathTargetInsideSVG=n.isPath&&w.svg(c.target),n.isColor=w.col(n.from.original),n.isColor&&(n.round=1),s=n})}var U={css:function(n,e,t){return n.style[e]=t},attribute:function(n,e,t){return n.setAttribute(e,t)},object:function(n,e,t){return n[e]=t},transform:function(n,e,t,r,a){var o;r.list.set(e,t),e!==r.last&&!a||(o="",r.list.forEach(function(n,e){o+=e+"("+n+") "}),n.style.transform=o)}};function nn(n,u){_(n).forEach(function(n){for(var e in u){var t=m(u[e],n),r=n.target,a=B(t),o=T(r,e,a,n),t=E(Y(t,a||B(o)),o),a=b(r,e);U[a](r,e,t,n.transforms,!0)}})}function en(n,e){return I(f(n.map(function(o){return e.map(function(n){var e,t,r=o,a=b(r.target,n.name);if(a)return t=(e=K(n,r))[e.length-1],{type:a,property:n.name,animatable:r,tweens:e,duration:t.end,delay:e[0].delay,endDelay:t.endDelay}})})),function(n){return!w.und(n)})}function tn(n,e){function t(n){return n.timelineOffset||0}var r=n.length,a={};return a.duration=r?Math.max.apply(Math,n.map(function(n){return t(n)+n.duration})):e.duration,a.delay=r?Math.min.apply(Math,n.map(function(n){return t(n)+n.delay})):e.delay,a.endDelay=r?a.duration-Math.max.apply(Math,n.map(function(n){return t(n)+n.duration-n.endDelay})):e.endDelay,a}var rn=0;var N,S=[],an=("undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){L.suspendWhenDocumentHidden&&(n()?N=cancelAnimationFrame(N):(S.forEach(function(n){return n._onDocumentVisibility()}),an()))}),function(){!(N||n()&&L.suspendWhenDocumentHidden)&&0<S.length&&(N=requestAnimationFrame(on))});function on(n){for(var e=S.length,t=0;t<e;){var r=S[t];r.paused?(S.splice(t,1),e--):(r.tick(n),t++)}N=0<t?requestAnimationFrame(on):void 0}function n(){return document&&document.hidden}function L(n){var c,s=0,f=0,l=0,d=0,p=null;function h(n){var e=window.Promise&&new Promise(function(n){return p=n});return n.finished=e}e=x(i,n=n=void 0===n?{}:n),t=J(r=x(M,n),n),n=_(n.targets),r=tn(t=en(n,t),r),a=rn,rn++;var e,t,r,a,k=D(e,{id:a,children:[],animatables:n,animations:t,duration:r.duration,delay:r.delay,endDelay:r.endDelay});h(k);function g(){var n=k.direction;"alternate"!==n&&(k.direction="normal"!==n?"normal":"reverse"),k.reversed=!k.reversed,c.forEach(function(n){return n.reversed=k.reversed})}function m(n){return k.reversed?k.duration-n:n}function o(){s=0,f=m(k.currentTime)*(1/L.speed)}function v(n,e){e&&e.seek(n-e.timelineOffset)}function y(e){for(var n=0,t=k.animations,r=t.length;n<r;){for(var a=t[n],o=a.animatable,u=a.tweens,i=u.length-1,c=u[i],i=(i&&(c=I(u,function(n){return e<n.end})[0]||c),C(e-c.start-c.delay,0,c.duration)/c.duration),s=isNaN(i)?1:c.easing(i),f=c.to.strings,l=c.round,d=[],p=c.to.numbers.length,h=void 0,g=0;g<p;g++){var m=void 0,v=c.to.numbers[g],y=c.from.numbers[g]||0,m=c.isPath?function(e,t,n){function r(n){return e.el.getPointAtLength(1<=t+(n=void 0===n?0:n)?t+n:0)}var a=Q(e.el,e.svg),o=r(),u=r(-1),i=r(1),c=n?1:a.w/a.vW,s=n?1:a.h/a.vH;switch(e.property){case"x":return(o.x-a.x)*c;case"y":return(o.y-a.y)*s;case"angle":return 180*Math.atan2(i.y-u.y,i.x-u.x)/Math.PI}}(c.value,s*v,c.isPathTargetInsideSVG):y+s*(v-y);!l||c.isColor&&2<g||(m=Math.round(m*l)/l),d.push(m)}var b=f.length;if(b)for(var h=f[0],M=0;M<b;M++){f[M];var x=f[M+1],w=d[M];isNaN(w)||(h+=x?w+x:w+" ")}else h=d[0];U[a.type](o.target,a.property,h,o.transforms),a.currentValue=h,n++}}function b(n){k[n]&&!k.passThrough&&k[n](k)}function u(n){var e=k.duration,t=k.delay,r=e-k.endDelay,a=m(n);if(k.progress=C(a/e*100,0,100),k.reversePlayback=a<k.currentTime,c){var o=a;if(k.reversePlayback)for(var u=d;u--;)v(o,c[u]);else for(var i=0;i<d;i++)v(o,c[i])}!k.began&&0<k.currentTime&&(k.began=!0,b("begin")),!k.loopBegan&&0<k.currentTime&&(k.loopBegan=!0,b("loopBegin")),a<=t&&0!==k.currentTime&&y(0),(r<=a&&k.currentTime!==e||!e)&&y(e),t<a&&a<r?(k.changeBegan||(k.changeBegan=!0,k.changeCompleted=!1,b("changeBegin")),b("change"),y(a)):k.changeBegan&&(k.changeCompleted=!0,k.changeBegan=!1,b("changeComplete")),k.currentTime=C(a,0,e),k.began&&b("update"),e<=n&&(f=0,k.remaining&&!0!==k.remaining&&k.remaining--,k.remaining?(s=l,b("loopComplete"),k.loopBegan=!1,"alternate"===k.direction&&g()):(k.paused=!0,k.completed||(k.completed=!0,b("loopComplete"),b("complete"),!k.passThrough&&"Promise"in window&&(p(),h(k)))))}return k.reset=function(){var n=k.direction;k.passThrough=!1,k.currentTime=0,k.progress=0,k.paused=!0,k.began=!1,k.loopBegan=!1,k.changeBegan=!1,k.completed=!1,k.changeCompleted=!1,k.reversePlayback=!1,k.reversed="reverse"===n,k.remaining=k.loop,c=k.children;for(var e=d=c.length;e--;)k.children[e].reset();(k.reversed&&!0!==k.loop||"alternate"===n&&1===k.loop)&&k.remaining++,y(k.reversed?k.duration:0)},k._onDocumentVisibility=o,k.set=function(n,e){return nn(n,e),k},k.tick=function(n){u(((l=n)+(f-(s=s||l)))*L.speed)},k.seek=function(n){u(m(n))},k.pause=function(){k.paused=!0,o()},k.play=function(){k.paused&&(k.completed&&k.reset(),k.paused=!1,S.push(k),o(),an())},k.reverse=function(){g(),k.completed=!k.reversed,o()},k.restart=function(){k.reset(),k.play()},k.remove=function(n){cn(A(n),k)},k.reset(),k.autoplay&&k.play(),k}function un(n,e){for(var t=e.length;t--;)h(n,e[t].animatable.target)&&e.splice(t,1)}function cn(n,e){var t=e.animations,r=e.children;un(n,t);for(var a=r.length;a--;){var o=r[a],u=o.animations;un(n,u),u.length||o.children.length||r.splice(a,1)}t.length||r.length||e.pause()}return L.version="3.2.2",L.speed=1,L.suspendWhenDocumentHidden=!0,L.running=S,L.remove=function(n){for(var e=A(n),t=S.length;t--;)cn(e,S[t])},L.get=T,L.set=nn,L.convertPx=y,L.path=function(n,e){var t=w.str(n)?a(n)[0]:n,r=e||100;return function(n){return{property:n,el:t,svg:Q(t),totalLength:G(t)*(r/100)}}},L.setDashoffset=function(n){var e=G(n);return n.setAttribute("stroke-dasharray",e),e},L.stagger=function(n,e){var i=(e=void 0===e?{}:e).direction||"normal",c=e.easing?P(e.easing):null,s=e.grid,f=e.axis,l=e.from||0,d="first"===l,p="center"===l,h="last"===l,g=w.arr(n),m=g?parseFloat(n[0]):parseFloat(n),v=g?parseFloat(n[1]):0,y=B(g?n[1]:n)||0,b=e.start||0+(g?m:0),M=[],x=0;return function(n,e,t){if(d&&(l=0),p&&(l=(t-1)/2),h&&(l=t-1),!M.length){for(var r,a,o,u=0;u<t;u++)s?(r=p?(s[0]-1)/2:l%s[0],a=p?(s[1]-1)/2:Math.floor(l/s[0]),r=r-u%s[0],a=a-Math.floor(u/s[0]),o=Math.sqrt(r*r+a*a),"x"===f&&(o=-r),M.push(o="y"===f?-a:o)):M.push(Math.abs(l-u)),x=Math.max.apply(Math,M);c&&(M=M.map(function(n){return c(n/x)*x})),"reverse"===i&&(M=M.map(function(n){return f?n<0?-1*n:-n:Math.abs(x-n)}))}return b+(g?(v-m)/x:m)*(Math.round(100*M[e])/100)+y}},L.timeline=function(u){var i=L(u=void 0===u?{}:u);return i.duration=0,i.add=function(n,e){var t=S.indexOf(i),r=i.children;function a(n){n.passThrough=!0}-1<t&&S.splice(t,1);for(var o=0;o<r.length;o++)a(r[o]);t=D(n,x(M,u)),t.targets=t.targets||u.targets,n=i.duration,t.autoplay=!1,t.direction=i.direction,t.timelineOffset=w.und(e)?n:E(e,n),a(i),i.seek(t.timelineOffset),e=L(t),a(e),r.push(e),n=tn(r,u);return i.delay=n.delay,i.endDelay=n.endDelay,i.duration=n.duration,i.seek(0),i.reset(),i.autoplay&&i.play(),i},i},L.easing=P,L.penner=s,L.random=function(n,e){return Math.floor(Math.random()*(e-n+1))+n},L});
  8. /*!
  9. Atropos
  10. Version: 2.0.2
  11. Plugin URL: https://atroposjs.com
  12. License: Copyright 2021-2024 | Released under the MIT License
  13. !*/
  14. var Atropos = (function () {
  15. 'use strict';
  16. function _extends() {
  17. _extends = Object.assign ? Object.assign.bind() : function (target) {
  18. for (var i = 1; i < arguments.length; i++) {
  19. var source = arguments[i];
  20. for (var key in source) {
  21. if (Object.prototype.hasOwnProperty.call(source, key)) {
  22. target[key] = source[key];
  23. }
  24. }
  25. }
  26. return target;
  27. };
  28. return _extends.apply(this, arguments);
  29. }
  30. /* eslint-disable no-restricted-globals */
  31. var $ = function $(el, sel) {
  32. return el.querySelector(sel);
  33. };
  34. var $$ = function $$(el, sel) {
  35. return el.querySelectorAll(sel);
  36. };
  37. var removeUndefinedProps = function removeUndefinedProps(obj) {
  38. if (obj === void 0) {
  39. obj = {};
  40. }
  41. var result = {};
  42. Object.keys(obj).forEach(function (key) {
  43. if (typeof obj[key] !== 'undefined') result[key] = obj[key];
  44. });
  45. return result;
  46. };
  47. var defaults = {
  48. alwaysActive: false,
  49. activeOffset: 50,
  50. shadowOffset: 50,
  51. shadowScale: 1,
  52. duration: 300,
  53. rotate: true,
  54. rotateTouch: true,
  55. rotateXMax: 15,
  56. rotateYMax: 15,
  57. rotateXInvert: false,
  58. rotateYInvert: false,
  59. stretchX: 0,
  60. stretchY: 0,
  61. stretchZ: 0,
  62. commonOrigin: true,
  63. shadow: true,
  64. highlight: true
  65. };
  66. function Atropos(originalParams) {
  67. if (originalParams === void 0) {
  68. originalParams = {};
  69. }
  70. var _originalParams = originalParams,
  71. el = _originalParams.el,
  72. eventsEl = _originalParams.eventsEl;
  73. var _originalParams2 = originalParams,
  74. isComponent = _originalParams2.isComponent;
  75. var childrenRootEl;
  76. var self = {
  77. __atropos__: true,
  78. params: _extends({}, defaults, {
  79. onEnter: null,
  80. onLeave: null,
  81. onRotate: null
  82. }, removeUndefinedProps(originalParams || {})),
  83. destroyed: false,
  84. isActive: false
  85. };
  86. var params = self.params;
  87. var rotateEl;
  88. var scaleEl;
  89. var innerEl;
  90. var elBoundingClientRect;
  91. var eventsElBoundingClientRect;
  92. var shadowEl;
  93. var highlightEl;
  94. var isScrolling;
  95. var clientXStart;
  96. var clientYStart;
  97. var queue = [];
  98. var queueFrameId;
  99. var purgeQueue = function purgeQueue() {
  100. queueFrameId = requestAnimationFrame(function () {
  101. queue.forEach(function (data) {
  102. if (typeof data === 'function') {
  103. data();
  104. } else {
  105. var element = data.element,
  106. prop = data.prop,
  107. value = data.value;
  108. element.style[prop] = value;
  109. }
  110. });
  111. queue.splice(0, queue.length);
  112. purgeQueue();
  113. });
  114. };
  115. purgeQueue();
  116. var $setDuration = function $setDuration(element, value) {
  117. queue.push({
  118. element: element,
  119. prop: 'transitionDuration',
  120. value: value
  121. });
  122. };
  123. var $setEasing = function $setEasing(element, value) {
  124. queue.push({
  125. element: element,
  126. prop: 'transitionTimingFunction',
  127. value: value
  128. });
  129. };
  130. var $setTransform = function $setTransform(element, value) {
  131. queue.push({
  132. element: element,
  133. prop: 'transform',
  134. value: value
  135. });
  136. };
  137. var $setOpacity = function $setOpacity(element, value) {
  138. queue.push({
  139. element: element,
  140. prop: 'opacity',
  141. value: value
  142. });
  143. };
  144. var $setOrigin = function $setOrigin(element, value) {
  145. queue.push({
  146. element: element,
  147. prop: 'transformOrigin',
  148. value: value
  149. });
  150. };
  151. var $on = function $on(element, event, handler, props) {
  152. return element.addEventListener(event, handler, props);
  153. };
  154. var $off = function $off(element, event, handler, props) {
  155. return element.removeEventListener(event, handler, props);
  156. };
  157. var createShadow = function createShadow() {
  158. var created;
  159. shadowEl = $(el, '.atropos-shadow');
  160. if (!shadowEl) {
  161. shadowEl = document.createElement('span');
  162. shadowEl.classList.add('atropos-shadow');
  163. created = true;
  164. }
  165. $setTransform(shadowEl, "translate3d(0,0,-" + params.shadowOffset + "px) scale(" + params.shadowScale + ")");
  166. if (created) {
  167. rotateEl.appendChild(shadowEl);
  168. }
  169. };
  170. var createHighlight = function createHighlight() {
  171. var created;
  172. highlightEl = $(el, '.atropos-highlight');
  173. if (!highlightEl) {
  174. highlightEl = document.createElement('span');
  175. highlightEl.classList.add('atropos-highlight');
  176. created = true;
  177. }
  178. $setTransform(highlightEl, "translate3d(0,0,0)");
  179. if (created) {
  180. innerEl.appendChild(highlightEl);
  181. }
  182. };
  183. var setChildrenOffset = function setChildrenOffset(_ref) {
  184. var _ref$rotateXPercentag = _ref.rotateXPercentage,
  185. rotateXPercentage = _ref$rotateXPercentag === void 0 ? 0 : _ref$rotateXPercentag,
  186. _ref$rotateYPercentag = _ref.rotateYPercentage,
  187. rotateYPercentage = _ref$rotateYPercentag === void 0 ? 0 : _ref$rotateYPercentag,
  188. duration = _ref.duration,
  189. opacityOnly = _ref.opacityOnly,
  190. easeOut = _ref.easeOut;
  191. var getOpacity = function getOpacity(element) {
  192. if (element.dataset.atroposOpacity && typeof element.dataset.atroposOpacity === 'string') {
  193. return element.dataset.atroposOpacity.split(';').map(function (v) {
  194. return parseFloat(v);
  195. });
  196. }
  197. return undefined;
  198. };
  199. $$(childrenRootEl, '[data-atropos-offset], [data-atropos-opacity]').forEach(function (childEl) {
  200. $setDuration(childEl, duration);
  201. $setEasing(childEl, easeOut ? 'ease-out' : '');
  202. var elementOpacity = getOpacity(childEl);
  203. if (rotateXPercentage === 0 && rotateYPercentage === 0) {
  204. if (!opacityOnly) $setTransform(childEl, "translate3d(0, 0, 0)");
  205. if (elementOpacity) $setOpacity(childEl, elementOpacity[0]);
  206. } else {
  207. var childElOffset = parseFloat(childEl.dataset.atroposOffset) / 100;
  208. if (!Number.isNaN(childElOffset) && !opacityOnly) {
  209. $setTransform(childEl, "translate3d(" + -rotateYPercentage * -childElOffset + "%, " + rotateXPercentage * -childElOffset + "%, 0)");
  210. }
  211. if (elementOpacity) {
  212. var min = elementOpacity[0],
  213. max = elementOpacity[1];
  214. var rotatePercentage = Math.max(Math.abs(rotateXPercentage), Math.abs(rotateYPercentage));
  215. $setOpacity(childEl, min + (max - min) * rotatePercentage / 100);
  216. }
  217. }
  218. });
  219. };
  220. var setElements = function setElements(clientX, clientY) {
  221. var isMultiple = el !== eventsEl;
  222. if (!elBoundingClientRect) {
  223. elBoundingClientRect = el.getBoundingClientRect();
  224. }
  225. if (isMultiple && !eventsElBoundingClientRect) {
  226. eventsElBoundingClientRect = eventsEl.getBoundingClientRect();
  227. }
  228. if (typeof clientX === 'undefined' && typeof clientY === 'undefined') {
  229. var rect = isMultiple ? eventsElBoundingClientRect : elBoundingClientRect;
  230. clientX = rect.left + rect.width / 2;
  231. clientY = rect.top + rect.height / 2;
  232. }
  233. var rotateX = 0;
  234. var rotateY = 0;
  235. var _elBoundingClientRect = elBoundingClientRect,
  236. top = _elBoundingClientRect.top,
  237. left = _elBoundingClientRect.left,
  238. width = _elBoundingClientRect.width,
  239. height = _elBoundingClientRect.height;
  240. var transformOrigin;
  241. if (!isMultiple) {
  242. var centerX = width / 2;
  243. var centerY = height / 2;
  244. var coordX = clientX - left;
  245. var coordY = clientY - top;
  246. rotateY = params.rotateYMax * (coordX - centerX) / (width / 2) * -1;
  247. rotateX = params.rotateXMax * (coordY - centerY) / (height / 2);
  248. } else {
  249. var _eventsElBoundingClie = eventsElBoundingClientRect,
  250. parentTop = _eventsElBoundingClie.top,
  251. parentLeft = _eventsElBoundingClie.left,
  252. parentWidth = _eventsElBoundingClie.width,
  253. parentHeight = _eventsElBoundingClie.height;
  254. var offsetLeft = left - parentLeft;
  255. var offsetTop = top - parentTop;
  256. var _centerX = width / 2 + offsetLeft;
  257. var _centerY = height / 2 + offsetTop;
  258. var _coordX = clientX - parentLeft;
  259. var _coordY = clientY - parentTop;
  260. rotateY = params.rotateYMax * (_coordX - _centerX) / (parentWidth - width / 2) * -1;
  261. rotateX = params.rotateXMax * (_coordY - _centerY) / (parentHeight - height / 2);
  262. transformOrigin = clientX - left + "px " + (clientY - top) + "px";
  263. }
  264. rotateX = Math.min(Math.max(-rotateX, -params.rotateXMax), params.rotateXMax);
  265. if (params.rotateXInvert) rotateX = -rotateX;
  266. rotateY = Math.min(Math.max(-rotateY, -params.rotateYMax), params.rotateYMax);
  267. if (params.rotateYInvert) rotateY = -rotateY;
  268. var rotateXPercentage = rotateX / params.rotateXMax * 100;
  269. var rotateYPercentage = rotateY / params.rotateYMax * 100;
  270. var stretchX = (isMultiple ? rotateYPercentage / 100 * params.stretchX : 0) * (params.rotateYInvert ? -1 : 1);
  271. var stretchY = (isMultiple ? rotateXPercentage / 100 * params.stretchY : 0) * (params.rotateXInvert ? -1 : 1);
  272. var stretchZ = isMultiple ? Math.max(Math.abs(rotateXPercentage), Math.abs(rotateYPercentage)) / 100 * params.stretchZ : 0;
  273. $setTransform(rotateEl, "translate3d(" + stretchX + "%, " + -stretchY + "%, " + -stretchZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)");
  274. if (transformOrigin && params.commonOrigin) {
  275. $setOrigin(rotateEl, transformOrigin);
  276. }
  277. if (highlightEl) {
  278. $setDuration(highlightEl, params.duration + "ms");
  279. $setEasing(highlightEl, 'ease-out');
  280. $setTransform(highlightEl, "translate3d(" + -rotateYPercentage * 0.25 + "%, " + rotateXPercentage * 0.25 + "%, 0)");
  281. $setOpacity(highlightEl, Math.max(Math.abs(rotateXPercentage), Math.abs(rotateYPercentage)) / 100);
  282. }
  283. setChildrenOffset({
  284. rotateXPercentage: rotateXPercentage,
  285. rotateYPercentage: rotateYPercentage,
  286. duration: params.duration + "ms",
  287. easeOut: true
  288. });
  289. if (typeof params.onRotate === 'function') params.onRotate(rotateX, rotateY);
  290. };
  291. var activate = function activate() {
  292. queue.push(function () {
  293. return el.classList.add('atropos-active');
  294. });
  295. $setDuration(rotateEl, params.duration + "ms");
  296. $setEasing(rotateEl, 'ease-out');
  297. $setTransform(scaleEl, "translate3d(0,0, " + params.activeOffset + "px)");
  298. $setDuration(scaleEl, params.duration + "ms");
  299. $setEasing(scaleEl, 'ease-out');
  300. if (shadowEl) {
  301. $setDuration(shadowEl, params.duration + "ms");
  302. $setEasing(shadowEl, 'ease-out');
  303. }
  304. self.isActive = true;
  305. };
  306. var onPointerEnter = function onPointerEnter(e) {
  307. isScrolling = undefined;
  308. if (e.type === 'pointerdown' && e.pointerType === 'mouse') return;
  309. if (e.type === 'pointerenter' && e.pointerType !== 'mouse') return;
  310. if (e.type === 'pointerdown') {
  311. e.preventDefault();
  312. }
  313. clientXStart = e.clientX;
  314. clientYStart = e.clientY;
  315. if (params.alwaysActive) {
  316. elBoundingClientRect = undefined;
  317. eventsElBoundingClientRect = undefined;
  318. return;
  319. }
  320. activate();
  321. if (typeof params.onEnter === 'function') params.onEnter();
  322. };
  323. var onTouchMove = function onTouchMove(e) {
  324. if (isScrolling === false && e.cancelable) {
  325. e.preventDefault();
  326. }
  327. };
  328. var onPointerMove = function onPointerMove(e) {
  329. if (!params.rotate || !self.isActive) return;
  330. if (e.pointerType !== 'mouse') {
  331. if (!params.rotateTouch) return;
  332. e.preventDefault();
  333. }
  334. var clientX = e.clientX,
  335. clientY = e.clientY;
  336. var diffX = clientX - clientXStart;
  337. var diffY = clientY - clientYStart;
  338. if (typeof params.rotateTouch === 'string' && (diffX !== 0 || diffY !== 0) && typeof isScrolling === 'undefined') {
  339. if (diffX * diffX + diffY * diffY >= 25) {
  340. var touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
  341. isScrolling = params.rotateTouch === 'scroll-y' ? touchAngle > 45 : 90 - touchAngle > 45;
  342. }
  343. if (isScrolling === false) {
  344. el.classList.add('atropos-rotate-touch');
  345. if (e.cancelable) {
  346. e.preventDefault();
  347. }
  348. }
  349. }
  350. if (e.pointerType !== 'mouse' && isScrolling) {
  351. return;
  352. }
  353. setElements(clientX, clientY);
  354. };
  355. var onPointerLeave = function onPointerLeave(e) {
  356. elBoundingClientRect = undefined;
  357. eventsElBoundingClientRect = undefined;
  358. if (!self.isActive) return;
  359. if (e && e.type === 'pointerup' && e.pointerType === 'mouse') return;
  360. if (e && e.type === 'pointerleave' && e.pointerType !== 'mouse') return;
  361. if (typeof params.rotateTouch === 'string' && isScrolling) {
  362. el.classList.remove('atropos-rotate-touch');
  363. }
  364. if (params.alwaysActive) {
  365. setElements();
  366. if (typeof params.onRotate === 'function') params.onRotate(0, 0);
  367. if (typeof params.onLeave === 'function') params.onLeave();
  368. return;
  369. }
  370. queue.push(function () {
  371. return el.classList.remove('atropos-active');
  372. });
  373. $setDuration(scaleEl, params.duration + "ms");
  374. $setEasing(scaleEl, '');
  375. $setTransform(scaleEl, "translate3d(0,0, " + 0 + "px)");
  376. if (shadowEl) {
  377. $setDuration(shadowEl, params.duration + "ms");
  378. $setEasing(shadowEl, '');
  379. }
  380. if (highlightEl) {
  381. $setDuration(highlightEl, params.duration + "ms");
  382. $setEasing(highlightEl, '');
  383. $setTransform(highlightEl, "translate3d(0, 0, 0)");
  384. $setOpacity(highlightEl, 0);
  385. }
  386. $setDuration(rotateEl, params.duration + "ms");
  387. $setEasing(rotateEl, '');
  388. $setTransform(rotateEl, "translate3d(0,0,0) rotateX(0deg) rotateY(0deg)");
  389. setChildrenOffset({
  390. duration: params.duration + "ms"
  391. });
  392. self.isActive = false;
  393. if (typeof params.onRotate === 'function') params.onRotate(0, 0);
  394. if (typeof params.onLeave === 'function') params.onLeave();
  395. };
  396. var onDocumentClick = function onDocumentClick(e) {
  397. var clickTarget = e.target;
  398. if (!eventsEl.contains(clickTarget) && clickTarget !== eventsEl && self.isActive) {
  399. onPointerLeave();
  400. }
  401. };
  402. var initDOM = function initDOM() {
  403. if (typeof el === 'string') {
  404. el = $(document, el);
  405. }
  406. if (!el) return;
  407. // eslint-disable-next-line
  408. if (el.__atropos__) return;
  409. if (typeof eventsEl !== 'undefined') {
  410. if (typeof eventsEl === 'string') {
  411. eventsEl = $(document, eventsEl);
  412. }
  413. } else {
  414. eventsEl = el;
  415. }
  416. childrenRootEl = isComponent ? el.parentNode.host : el;
  417. Object.assign(self, {
  418. el: el
  419. });
  420. rotateEl = $(el, '.atropos-rotate');
  421. scaleEl = $(el, '.atropos-scale');
  422. innerEl = $(el, '.atropos-inner');
  423. // eslint-disable-next-line
  424. el.__atropos__ = self;
  425. };
  426. var init = function init() {
  427. initDOM();
  428. if (!el || !eventsEl) return;
  429. if (params.shadow) {
  430. createShadow();
  431. }
  432. if (params.highlight) {
  433. createHighlight();
  434. }
  435. if (params.rotateTouch) {
  436. if (typeof params.rotateTouch === 'string') {
  437. el.classList.add("atropos-rotate-touch-" + params.rotateTouch);
  438. } else {
  439. el.classList.add('atropos-rotate-touch');
  440. }
  441. }
  442. if ($(childrenRootEl, '[data-atropos-opacity]')) {
  443. setChildrenOffset({
  444. opacityOnly: true
  445. });
  446. }
  447. $on(document, 'click', onDocumentClick);
  448. $on(eventsEl, 'pointerdown', onPointerEnter);
  449. $on(eventsEl, 'pointerenter', onPointerEnter);
  450. $on(eventsEl, 'pointermove', onPointerMove);
  451. $on(eventsEl, 'touchmove', onTouchMove);
  452. $on(eventsEl, 'pointerleave', onPointerLeave);
  453. $on(eventsEl, 'pointerup', onPointerLeave);
  454. $on(eventsEl, 'lostpointercapture', onPointerLeave);
  455. if (params.alwaysActive) {
  456. activate();
  457. setElements();
  458. }
  459. };
  460. var destroy = function destroy() {
  461. self.destroyed = true;
  462. cancelAnimationFrame(queueFrameId);
  463. $off(document, 'click', onDocumentClick);
  464. $off(eventsEl, 'pointerdown', onPointerEnter);
  465. $off(eventsEl, 'pointerenter', onPointerEnter);
  466. $off(eventsEl, 'pointermove', onPointerMove);
  467. $off(eventsEl, 'touchmove', onTouchMove);
  468. $off(eventsEl, 'pointerleave', onPointerLeave);
  469. $off(eventsEl, 'pointerup', onPointerLeave);
  470. $off(eventsEl, 'lostpointercapture', onPointerLeave);
  471. // eslint-disable-next-line
  472. delete el.__atropos__;
  473. };
  474. self.destroy = destroy;
  475. init();
  476. // eslint-disable-next-line
  477. return self;
  478. }
  479. return Atropos;
  480. })();
  481. /*!
  482. Bootstrap
  483. Version: 5.3.2
  484. Plugin URL: https://getbootstrap.com/
  485. License: Copyright 2011-2024 The Bootstrap Authors | Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  486. !*/
  487. (function (global, factory) {
  488. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  489. typeof define === 'function' && define.amd ? define(factory) :
  490. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bootstrap = factory());
  491. })(this, (function () { 'use strict';
  492. /**
  493. * --------------------------------------------------------------------------
  494. * Bootstrap dom/data.js
  495. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  496. * --------------------------------------------------------------------------
  497. */
  498. /**
  499. * Constants
  500. */
  501. const elementMap = new Map();
  502. const Data = {
  503. set(element, key, instance) {
  504. if (!elementMap.has(element)) {
  505. elementMap.set(element, new Map());
  506. }
  507. const instanceMap = elementMap.get(element);
  508. // make it clear we only want one instance per element
  509. // can be removed later when multiple key/instances are fine to be used
  510. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  511. // eslint-disable-next-line no-console
  512. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  513. return;
  514. }
  515. instanceMap.set(key, instance);
  516. },
  517. get(element, key) {
  518. if (elementMap.has(element)) {
  519. return elementMap.get(element).get(key) || null;
  520. }
  521. return null;
  522. },
  523. remove(element, key) {
  524. if (!elementMap.has(element)) {
  525. return;
  526. }
  527. const instanceMap = elementMap.get(element);
  528. instanceMap.delete(key);
  529. // free up element references if there are no instances left for an element
  530. if (instanceMap.size === 0) {
  531. elementMap.delete(element);
  532. }
  533. }
  534. };
  535. /**
  536. * --------------------------------------------------------------------------
  537. * Bootstrap util/index.js
  538. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  539. * --------------------------------------------------------------------------
  540. */
  541. const MAX_UID = 1000000;
  542. const MILLISECONDS_MULTIPLIER = 1000;
  543. const TRANSITION_END = 'transitionend';
  544. /**
  545. * Properly escape IDs selectors to handle weird IDs
  546. * @param {string} selector
  547. * @returns {string}
  548. */
  549. const parseSelector = selector => {
  550. if (selector && window.CSS && window.CSS.escape) {
  551. // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
  552. selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
  553. }
  554. return selector;
  555. };
  556. // Shout-out Angus Croll (https://goo.gl/pxwQGp)
  557. const toType = object => {
  558. if (object === null || object === undefined) {
  559. return `${object}`;
  560. }
  561. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  562. };
  563. /**
  564. * Public Util API
  565. */
  566. const getUID = prefix => {
  567. do {
  568. prefix += Math.floor(Math.random() * MAX_UID);
  569. } while (document.getElementById(prefix));
  570. return prefix;
  571. };
  572. const getTransitionDurationFromElement = element => {
  573. if (!element) {
  574. return 0;
  575. }
  576. // Get transition-duration of the element
  577. let {
  578. transitionDuration,
  579. transitionDelay
  580. } = window.getComputedStyle(element);
  581. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  582. const floatTransitionDelay = Number.parseFloat(transitionDelay);
  583. // Return 0 if element or transition duration is not found
  584. if (!floatTransitionDuration && !floatTransitionDelay) {
  585. return 0;
  586. }
  587. // If multiple durations are defined, take the first
  588. transitionDuration = transitionDuration.split(',')[0];
  589. transitionDelay = transitionDelay.split(',')[0];
  590. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  591. };
  592. const triggerTransitionEnd = element => {
  593. element.dispatchEvent(new Event(TRANSITION_END));
  594. };
  595. const isElement$1 = object => {
  596. if (!object || typeof object !== 'object') {
  597. return false;
  598. }
  599. if (typeof object.jquery !== 'undefined') {
  600. object = object[0];
  601. }
  602. return typeof object.nodeType !== 'undefined';
  603. };
  604. const getElement = object => {
  605. // it's a jQuery object or a node element
  606. if (isElement$1(object)) {
  607. return object.jquery ? object[0] : object;
  608. }
  609. if (typeof object === 'string' && object.length > 0) {
  610. return document.querySelector(parseSelector(object));
  611. }
  612. return null;
  613. };
  614. const isVisible = element => {
  615. if (!isElement$1(element) || element.getClientRects().length === 0) {
  616. return false;
  617. }
  618. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  619. // Handle `details` element as its content may falsie appear visible when it is closed
  620. const closedDetails = element.closest('details:not([open])');
  621. if (!closedDetails) {
  622. return elementIsVisible;
  623. }
  624. if (closedDetails !== element) {
  625. const summary = element.closest('summary');
  626. if (summary && summary.parentNode !== closedDetails) {
  627. return false;
  628. }
  629. if (summary === null) {
  630. return false;
  631. }
  632. }
  633. return elementIsVisible;
  634. };
  635. const isDisabled = element => {
  636. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  637. return true;
  638. }
  639. if (element.classList.contains('disabled')) {
  640. return true;
  641. }
  642. if (typeof element.disabled !== 'undefined') {
  643. return element.disabled;
  644. }
  645. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  646. };
  647. const findShadowRoot = element => {
  648. if (!document.documentElement.attachShadow) {
  649. return null;
  650. }
  651. // Can find the shadow root otherwise it'll return the document
  652. if (typeof element.getRootNode === 'function') {
  653. const root = element.getRootNode();
  654. return root instanceof ShadowRoot ? root : null;
  655. }
  656. if (element instanceof ShadowRoot) {
  657. return element;
  658. }
  659. // when we don't find a shadow root
  660. if (!element.parentNode) {
  661. return null;
  662. }
  663. return findShadowRoot(element.parentNode);
  664. };
  665. const noop = () => {};
  666. /**
  667. * Trick to restart an element's animation
  668. *
  669. * @param {HTMLElement} element
  670. * @return void
  671. *
  672. * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
  673. */
  674. const reflow = element => {
  675. element.offsetHeight; // eslint-disable-line no-unused-expressions
  676. };
  677. const getjQuery = () => {
  678. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  679. return window.jQuery;
  680. }
  681. return null;
  682. };
  683. const DOMContentLoadedCallbacks = [];
  684. const onDOMContentLoaded = callback => {
  685. if (document.readyState === 'loading') {
  686. // add listener on the first call when the document is in loading state
  687. if (!DOMContentLoadedCallbacks.length) {
  688. document.addEventListener('DOMContentLoaded', () => {
  689. for (const callback of DOMContentLoadedCallbacks) {
  690. callback();
  691. }
  692. });
  693. }
  694. DOMContentLoadedCallbacks.push(callback);
  695. } else {
  696. callback();
  697. }
  698. };
  699. const isRTL = () => document.documentElement.dir === 'rtl';
  700. const defineJQueryPlugin = plugin => {
  701. onDOMContentLoaded(() => {
  702. const $ = getjQuery();
  703. /* istanbul ignore if */
  704. if ($) {
  705. const name = plugin.NAME;
  706. const JQUERY_NO_CONFLICT = $.fn[name];
  707. $.fn[name] = plugin.jQueryInterface;
  708. $.fn[name].Constructor = plugin;
  709. $.fn[name].noConflict = () => {
  710. $.fn[name] = JQUERY_NO_CONFLICT;
  711. return plugin.jQueryInterface;
  712. };
  713. }
  714. });
  715. };
  716. const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
  717. return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
  718. };
  719. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  720. if (!waitForTransition) {
  721. execute(callback);
  722. return;
  723. }
  724. const durationPadding = 5;
  725. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  726. let called = false;
  727. const handler = ({
  728. target
  729. }) => {
  730. if (target !== transitionElement) {
  731. return;
  732. }
  733. called = true;
  734. transitionElement.removeEventListener(TRANSITION_END, handler);
  735. execute(callback);
  736. };
  737. transitionElement.addEventListener(TRANSITION_END, handler);
  738. setTimeout(() => {
  739. if (!called) {
  740. triggerTransitionEnd(transitionElement);
  741. }
  742. }, emulatedDuration);
  743. };
  744. /**
  745. * Return the previous/next element of a list.
  746. *
  747. * @param {array} list The list of elements
  748. * @param activeElement The active element
  749. * @param shouldGetNext Choose to get next or previous element
  750. * @param isCycleAllowed
  751. * @return {Element|elem} The proper element
  752. */
  753. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  754. const listLength = list.length;
  755. let index = list.indexOf(activeElement);
  756. // if the element does not exist in the list return an element
  757. // depending on the direction and if cycle is allowed
  758. if (index === -1) {
  759. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  760. }
  761. index += shouldGetNext ? 1 : -1;
  762. if (isCycleAllowed) {
  763. index = (index + listLength) % listLength;
  764. }
  765. return list[Math.max(0, Math.min(index, listLength - 1))];
  766. };
  767. /**
  768. * --------------------------------------------------------------------------
  769. * Bootstrap dom/event-handler.js
  770. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  771. * --------------------------------------------------------------------------
  772. */
  773. /**
  774. * Constants
  775. */
  776. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  777. const stripNameRegex = /\..*/;
  778. const stripUidRegex = /::\d+$/;
  779. const eventRegistry = {}; // Events storage
  780. let uidEvent = 1;
  781. const customEvents = {
  782. mouseenter: 'mouseover',
  783. mouseleave: 'mouseout'
  784. };
  785. const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']);
  786. /**
  787. * Private methods
  788. */
  789. function makeEventUid(element, uid) {
  790. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  791. }
  792. function getElementEvents(element) {
  793. const uid = makeEventUid(element);
  794. element.uidEvent = uid;
  795. eventRegistry[uid] = eventRegistry[uid] || {};
  796. return eventRegistry[uid];
  797. }
  798. function bootstrapHandler(element, fn) {
  799. return function handler(event) {
  800. hydrateObj(event, {
  801. delegateTarget: element
  802. });
  803. if (handler.oneOff) {
  804. EventHandler.off(element, event.type, fn);
  805. }
  806. return fn.apply(element, [event]);
  807. };
  808. }
  809. function bootstrapDelegationHandler(element, selector, fn) {
  810. return function handler(event) {
  811. const domElements = element.querySelectorAll(selector);
  812. for (let {
  813. target
  814. } = event; target && target !== this; target = target.parentNode) {
  815. for (const domElement of domElements) {
  816. if (domElement !== target) {
  817. continue;
  818. }
  819. hydrateObj(event, {
  820. delegateTarget: target
  821. });
  822. if (handler.oneOff) {
  823. EventHandler.off(element, event.type, selector, fn);
  824. }
  825. return fn.apply(target, [event]);
  826. }
  827. }
  828. };
  829. }
  830. function findHandler(events, callable, delegationSelector = null) {
  831. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  832. }
  833. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  834. const isDelegated = typeof handler === 'string';
  835. // TODO: tooltip passes `false` instead of selector, so we need to check
  836. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  837. let typeEvent = getTypeEvent(originalTypeEvent);
  838. if (!nativeEvents.has(typeEvent)) {
  839. typeEvent = originalTypeEvent;
  840. }
  841. return [isDelegated, callable, typeEvent];
  842. }
  843. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  844. if (typeof originalTypeEvent !== 'string' || !element) {
  845. return;
  846. }
  847. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  848. // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
  849. // this prevents the handler from being dispatched the same way as mouseover or mouseout does
  850. if (originalTypeEvent in customEvents) {
  851. const wrapFunction = fn => {
  852. return function (event) {
  853. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  854. return fn.call(this, event);
  855. }
  856. };
  857. };
  858. callable = wrapFunction(callable);
  859. }
  860. const events = getElementEvents(element);
  861. const handlers = events[typeEvent] || (events[typeEvent] = {});
  862. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  863. if (previousFunction) {
  864. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  865. return;
  866. }
  867. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  868. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  869. fn.delegationSelector = isDelegated ? handler : null;
  870. fn.callable = callable;
  871. fn.oneOff = oneOff;
  872. fn.uidEvent = uid;
  873. handlers[uid] = fn;
  874. element.addEventListener(typeEvent, fn, isDelegated);
  875. }
  876. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  877. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  878. if (!fn) {
  879. return;
  880. }
  881. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  882. delete events[typeEvent][fn.uidEvent];
  883. }
  884. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  885. const storeElementEvent = events[typeEvent] || {};
  886. for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
  887. if (handlerKey.includes(namespace)) {
  888. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  889. }
  890. }
  891. }
  892. function getTypeEvent(event) {
  893. // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
  894. event = event.replace(stripNameRegex, '');
  895. return customEvents[event] || event;
  896. }
  897. const EventHandler = {
  898. on(element, event, handler, delegationFunction) {
  899. addHandler(element, event, handler, delegationFunction, false);
  900. },
  901. one(element, event, handler, delegationFunction) {
  902. addHandler(element, event, handler, delegationFunction, true);
  903. },
  904. off(element, originalTypeEvent, handler, delegationFunction) {
  905. if (typeof originalTypeEvent !== 'string' || !element) {
  906. return;
  907. }
  908. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  909. const inNamespace = typeEvent !== originalTypeEvent;
  910. const events = getElementEvents(element);
  911. const storeElementEvent = events[typeEvent] || {};
  912. const isNamespace = originalTypeEvent.startsWith('.');
  913. if (typeof callable !== 'undefined') {
  914. // Simplest case: handler is passed, remove that listener ONLY.
  915. if (!Object.keys(storeElementEvent).length) {
  916. return;
  917. }
  918. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  919. return;
  920. }
  921. if (isNamespace) {
  922. for (const elementEvent of Object.keys(events)) {
  923. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  924. }
  925. }
  926. for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
  927. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  928. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  929. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  930. }
  931. }
  932. },
  933. trigger(element, event, args) {
  934. if (typeof event !== 'string' || !element) {
  935. return null;
  936. }
  937. const $ = getjQuery();
  938. const typeEvent = getTypeEvent(event);
  939. const inNamespace = event !== typeEvent;
  940. let jQueryEvent = null;
  941. let bubbles = true;
  942. let nativeDispatch = true;
  943. let defaultPrevented = false;
  944. if (inNamespace && $) {
  945. jQueryEvent = $.Event(event, args);
  946. $(element).trigger(jQueryEvent);
  947. bubbles = !jQueryEvent.isPropagationStopped();
  948. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  949. defaultPrevented = jQueryEvent.isDefaultPrevented();
  950. }
  951. const evt = hydrateObj(new Event(event, {
  952. bubbles,
  953. cancelable: true
  954. }), args);
  955. if (defaultPrevented) {
  956. evt.preventDefault();
  957. }
  958. if (nativeDispatch) {
  959. element.dispatchEvent(evt);
  960. }
  961. if (evt.defaultPrevented && jQueryEvent) {
  962. jQueryEvent.preventDefault();
  963. }
  964. return evt;
  965. }
  966. };
  967. function hydrateObj(obj, meta = {}) {
  968. for (const [key, value] of Object.entries(meta)) {
  969. try {
  970. obj[key] = value;
  971. } catch (_unused) {
  972. Object.defineProperty(obj, key, {
  973. configurable: true,
  974. get() {
  975. return value;
  976. }
  977. });
  978. }
  979. }
  980. return obj;
  981. }
  982. /**
  983. * --------------------------------------------------------------------------
  984. * Bootstrap dom/manipulator.js
  985. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  986. * --------------------------------------------------------------------------
  987. */
  988. function normalizeData(value) {
  989. if (value === 'true') {
  990. return true;
  991. }
  992. if (value === 'false') {
  993. return false;
  994. }
  995. if (value === Number(value).toString()) {
  996. return Number(value);
  997. }
  998. if (value === '' || value === 'null') {
  999. return null;
  1000. }
  1001. if (typeof value !== 'string') {
  1002. return value;
  1003. }
  1004. try {
  1005. return JSON.parse(decodeURIComponent(value));
  1006. } catch (_unused) {
  1007. return value;
  1008. }
  1009. }
  1010. function normalizeDataKey(key) {
  1011. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  1012. }
  1013. const Manipulator = {
  1014. setDataAttribute(element, key, value) {
  1015. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  1016. },
  1017. removeDataAttribute(element, key) {
  1018. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  1019. },
  1020. getDataAttributes(element) {
  1021. if (!element) {
  1022. return {};
  1023. }
  1024. const attributes = {};
  1025. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  1026. for (const key of bsKeys) {
  1027. let pureKey = key.replace(/^bs/, '');
  1028. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  1029. attributes[pureKey] = normalizeData(element.dataset[key]);
  1030. }
  1031. return attributes;
  1032. },
  1033. getDataAttribute(element, key) {
  1034. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  1035. }
  1036. };
  1037. /**
  1038. * --------------------------------------------------------------------------
  1039. * Bootstrap util/config.js
  1040. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1041. * --------------------------------------------------------------------------
  1042. */
  1043. /**
  1044. * Class definition
  1045. */
  1046. class Config {
  1047. // Getters
  1048. static get Default() {
  1049. return {};
  1050. }
  1051. static get DefaultType() {
  1052. return {};
  1053. }
  1054. static get NAME() {
  1055. throw new Error('You have to implement the static method "NAME", for each component!');
  1056. }
  1057. _getConfig(config) {
  1058. config = this._mergeConfigObj(config);
  1059. config = this._configAfterMerge(config);
  1060. this._typeCheckConfig(config);
  1061. return config;
  1062. }
  1063. _configAfterMerge(config) {
  1064. return config;
  1065. }
  1066. _mergeConfigObj(config, element) {
  1067. const jsonConfig = isElement$1(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse
  1068. return {
  1069. ...this.constructor.Default,
  1070. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  1071. ...(isElement$1(element) ? Manipulator.getDataAttributes(element) : {}),
  1072. ...(typeof config === 'object' ? config : {})
  1073. };
  1074. }
  1075. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  1076. for (const [property, expectedTypes] of Object.entries(configTypes)) {
  1077. const value = config[property];
  1078. const valueType = isElement$1(value) ? 'element' : toType(value);
  1079. if (!new RegExp(expectedTypes).test(valueType)) {
  1080. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  1081. }
  1082. }
  1083. }
  1084. }
  1085. /**
  1086. * --------------------------------------------------------------------------
  1087. * Bootstrap base-component.js
  1088. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1089. * --------------------------------------------------------------------------
  1090. */
  1091. /**
  1092. * Constants
  1093. */
  1094. const VERSION = '5.3.2';
  1095. /**
  1096. * Class definition
  1097. */
  1098. class BaseComponent extends Config {
  1099. constructor(element, config) {
  1100. super();
  1101. element = getElement(element);
  1102. if (!element) {
  1103. return;
  1104. }
  1105. this._element = element;
  1106. this._config = this._getConfig(config);
  1107. Data.set(this._element, this.constructor.DATA_KEY, this);
  1108. }
  1109. // Public
  1110. dispose() {
  1111. Data.remove(this._element, this.constructor.DATA_KEY);
  1112. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  1113. for (const propertyName of Object.getOwnPropertyNames(this)) {
  1114. this[propertyName] = null;
  1115. }
  1116. }
  1117. _queueCallback(callback, element, isAnimated = true) {
  1118. executeAfterTransition(callback, element, isAnimated);
  1119. }
  1120. _getConfig(config) {
  1121. config = this._mergeConfigObj(config, this._element);
  1122. config = this._configAfterMerge(config);
  1123. this._typeCheckConfig(config);
  1124. return config;
  1125. }
  1126. // Static
  1127. static getInstance(element) {
  1128. return Data.get(getElement(element), this.DATA_KEY);
  1129. }
  1130. static getOrCreateInstance(element, config = {}) {
  1131. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  1132. }
  1133. static get VERSION() {
  1134. return VERSION;
  1135. }
  1136. static get DATA_KEY() {
  1137. return `bs.${this.NAME}`;
  1138. }
  1139. static get EVENT_KEY() {
  1140. return `.${this.DATA_KEY}`;
  1141. }
  1142. static eventName(name) {
  1143. return `${name}${this.EVENT_KEY}`;
  1144. }
  1145. }
  1146. /**
  1147. * --------------------------------------------------------------------------
  1148. * Bootstrap dom/selector-engine.js
  1149. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1150. * --------------------------------------------------------------------------
  1151. */
  1152. const getSelector = element => {
  1153. let selector = element.getAttribute('data-bs-target');
  1154. if (!selector || selector === '#') {
  1155. let hrefAttribute = element.getAttribute('href');
  1156. // The only valid content that could double as a selector are IDs or classes,
  1157. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  1158. // `document.querySelector` will rightfully complain it is invalid.
  1159. // See https://github.com/twbs/bootstrap/issues/32273
  1160. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  1161. return null;
  1162. }
  1163. // Just in case some CMS puts out a full URL with the anchor appended
  1164. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  1165. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  1166. }
  1167. selector = hrefAttribute && hrefAttribute !== '#' ? parseSelector(hrefAttribute.trim()) : null;
  1168. }
  1169. return selector;
  1170. };
  1171. const SelectorEngine = {
  1172. find(selector, element = document.documentElement) {
  1173. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  1174. },
  1175. findOne(selector, element = document.documentElement) {
  1176. return Element.prototype.querySelector.call(element, selector);
  1177. },
  1178. children(element, selector) {
  1179. return [].concat(...element.children).filter(child => child.matches(selector));
  1180. },
  1181. parents(element, selector) {
  1182. const parents = [];
  1183. let ancestor = element.parentNode.closest(selector);
  1184. while (ancestor) {
  1185. parents.push(ancestor);
  1186. ancestor = ancestor.parentNode.closest(selector);
  1187. }
  1188. return parents;
  1189. },
  1190. prev(element, selector) {
  1191. let previous = element.previousElementSibling;
  1192. while (previous) {
  1193. if (previous.matches(selector)) {
  1194. return [previous];
  1195. }
  1196. previous = previous.previousElementSibling;
  1197. }
  1198. return [];
  1199. },
  1200. // TODO: this is now unused; remove later along with prev()
  1201. next(element, selector) {
  1202. let next = element.nextElementSibling;
  1203. while (next) {
  1204. if (next.matches(selector)) {
  1205. return [next];
  1206. }
  1207. next = next.nextElementSibling;
  1208. }
  1209. return [];
  1210. },
  1211. focusableChildren(element) {
  1212. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  1213. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  1214. },
  1215. getSelectorFromElement(element) {
  1216. const selector = getSelector(element);
  1217. if (selector) {
  1218. return SelectorEngine.findOne(selector) ? selector : null;
  1219. }
  1220. return null;
  1221. },
  1222. getElementFromSelector(element) {
  1223. const selector = getSelector(element);
  1224. return selector ? SelectorEngine.findOne(selector) : null;
  1225. },
  1226. getMultipleElementsFromSelector(element) {
  1227. const selector = getSelector(element);
  1228. return selector ? SelectorEngine.find(selector) : [];
  1229. }
  1230. };
  1231. /**
  1232. * --------------------------------------------------------------------------
  1233. * Bootstrap util/component-functions.js
  1234. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1235. * --------------------------------------------------------------------------
  1236. */
  1237. const enableDismissTrigger = (component, method = 'hide') => {
  1238. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  1239. const name = component.NAME;
  1240. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  1241. if (['A', 'AREA'].includes(this.tagName)) {
  1242. event.preventDefault();
  1243. }
  1244. if (isDisabled(this)) {
  1245. return;
  1246. }
  1247. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  1248. const instance = component.getOrCreateInstance(target);
  1249. // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  1250. instance[method]();
  1251. });
  1252. };
  1253. /**
  1254. * --------------------------------------------------------------------------
  1255. * Bootstrap alert.js
  1256. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1257. * --------------------------------------------------------------------------
  1258. */
  1259. /**
  1260. * Constants
  1261. */
  1262. const NAME$f = 'alert';
  1263. const DATA_KEY$a = 'bs.alert';
  1264. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  1265. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  1266. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  1267. const CLASS_NAME_FADE$5 = 'fade';
  1268. const CLASS_NAME_SHOW$8 = 'show';
  1269. /**
  1270. * Class definition
  1271. */
  1272. class Alert extends BaseComponent {
  1273. // Getters
  1274. static get NAME() {
  1275. return NAME$f;
  1276. }
  1277. // Public
  1278. close() {
  1279. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  1280. if (closeEvent.defaultPrevented) {
  1281. return;
  1282. }
  1283. this._element.classList.remove(CLASS_NAME_SHOW$8);
  1284. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  1285. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  1286. }
  1287. // Private
  1288. _destroyElement() {
  1289. this._element.remove();
  1290. EventHandler.trigger(this._element, EVENT_CLOSED);
  1291. this.dispose();
  1292. }
  1293. // Static
  1294. static jQueryInterface(config) {
  1295. return this.each(function () {
  1296. const data = Alert.getOrCreateInstance(this);
  1297. if (typeof config !== 'string') {
  1298. return;
  1299. }
  1300. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1301. throw new TypeError(`No method named "${config}"`);
  1302. }
  1303. data[config](this);
  1304. });
  1305. }
  1306. }
  1307. /**
  1308. * Data API implementation
  1309. */
  1310. enableDismissTrigger(Alert, 'close');
  1311. /**
  1312. * jQuery
  1313. */
  1314. defineJQueryPlugin(Alert);
  1315. /**
  1316. * --------------------------------------------------------------------------
  1317. * Bootstrap button.js
  1318. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1319. * --------------------------------------------------------------------------
  1320. */
  1321. /**
  1322. * Constants
  1323. */
  1324. const NAME$e = 'button';
  1325. const DATA_KEY$9 = 'bs.button';
  1326. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  1327. const DATA_API_KEY$6 = '.data-api';
  1328. const CLASS_NAME_ACTIVE$3 = 'active';
  1329. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  1330. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  1331. /**
  1332. * Class definition
  1333. */
  1334. class Button extends BaseComponent {
  1335. // Getters
  1336. static get NAME() {
  1337. return NAME$e;
  1338. }
  1339. // Public
  1340. toggle() {
  1341. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  1342. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  1343. }
  1344. // Static
  1345. static jQueryInterface(config) {
  1346. return this.each(function () {
  1347. const data = Button.getOrCreateInstance(this);
  1348. if (config === 'toggle') {
  1349. data[config]();
  1350. }
  1351. });
  1352. }
  1353. }
  1354. /**
  1355. * Data API implementation
  1356. */
  1357. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  1358. event.preventDefault();
  1359. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  1360. const data = Button.getOrCreateInstance(button);
  1361. data.toggle();
  1362. });
  1363. /**
  1364. * jQuery
  1365. */
  1366. defineJQueryPlugin(Button);
  1367. /**
  1368. * --------------------------------------------------------------------------
  1369. * Bootstrap util/swipe.js
  1370. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1371. * --------------------------------------------------------------------------
  1372. */
  1373. /**
  1374. * Constants
  1375. */
  1376. const NAME$d = 'swipe';
  1377. const EVENT_KEY$9 = '.bs.swipe';
  1378. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  1379. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  1380. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  1381. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  1382. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  1383. const POINTER_TYPE_TOUCH = 'touch';
  1384. const POINTER_TYPE_PEN = 'pen';
  1385. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  1386. const SWIPE_THRESHOLD = 40;
  1387. const Default$c = {
  1388. endCallback: null,
  1389. leftCallback: null,
  1390. rightCallback: null
  1391. };
  1392. const DefaultType$c = {
  1393. endCallback: '(function|null)',
  1394. leftCallback: '(function|null)',
  1395. rightCallback: '(function|null)'
  1396. };
  1397. /**
  1398. * Class definition
  1399. */
  1400. class Swipe extends Config {
  1401. constructor(element, config) {
  1402. super();
  1403. this._element = element;
  1404. if (!element || !Swipe.isSupported()) {
  1405. return;
  1406. }
  1407. this._config = this._getConfig(config);
  1408. this._deltaX = 0;
  1409. this._supportPointerEvents = Boolean(window.PointerEvent);
  1410. this._initEvents();
  1411. }
  1412. // Getters
  1413. static get Default() {
  1414. return Default$c;
  1415. }
  1416. static get DefaultType() {
  1417. return DefaultType$c;
  1418. }
  1419. static get NAME() {
  1420. return NAME$d;
  1421. }
  1422. // Public
  1423. dispose() {
  1424. EventHandler.off(this._element, EVENT_KEY$9);
  1425. }
  1426. // Private
  1427. _start(event) {
  1428. if (!this._supportPointerEvents) {
  1429. this._deltaX = event.touches[0].clientX;
  1430. return;
  1431. }
  1432. if (this._eventIsPointerPenTouch(event)) {
  1433. this._deltaX = event.clientX;
  1434. }
  1435. }
  1436. _end(event) {
  1437. if (this._eventIsPointerPenTouch(event)) {
  1438. this._deltaX = event.clientX - this._deltaX;
  1439. }
  1440. this._handleSwipe();
  1441. execute(this._config.endCallback);
  1442. }
  1443. _move(event) {
  1444. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  1445. }
  1446. _handleSwipe() {
  1447. const absDeltaX = Math.abs(this._deltaX);
  1448. if (absDeltaX <= SWIPE_THRESHOLD) {
  1449. return;
  1450. }
  1451. const direction = absDeltaX / this._deltaX;
  1452. this._deltaX = 0;
  1453. if (!direction) {
  1454. return;
  1455. }
  1456. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  1457. }
  1458. _initEvents() {
  1459. if (this._supportPointerEvents) {
  1460. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  1461. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  1462. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  1463. } else {
  1464. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  1465. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  1466. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  1467. }
  1468. }
  1469. _eventIsPointerPenTouch(event) {
  1470. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  1471. }
  1472. // Static
  1473. static isSupported() {
  1474. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  1475. }
  1476. }
  1477. /**
  1478. * --------------------------------------------------------------------------
  1479. * Bootstrap carousel.js
  1480. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1481. * --------------------------------------------------------------------------
  1482. */
  1483. /**
  1484. * Constants
  1485. */
  1486. const NAME$c = 'carousel';
  1487. const DATA_KEY$8 = 'bs.carousel';
  1488. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  1489. const DATA_API_KEY$5 = '.data-api';
  1490. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  1491. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  1492. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  1493. const ORDER_NEXT = 'next';
  1494. const ORDER_PREV = 'prev';
  1495. const DIRECTION_LEFT = 'left';
  1496. const DIRECTION_RIGHT = 'right';
  1497. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  1498. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  1499. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  1500. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  1501. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  1502. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  1503. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1504. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1505. const CLASS_NAME_CAROUSEL = 'carousel';
  1506. const CLASS_NAME_ACTIVE$2 = 'active';
  1507. const CLASS_NAME_SLIDE = 'slide';
  1508. const CLASS_NAME_END = 'carousel-item-end';
  1509. const CLASS_NAME_START = 'carousel-item-start';
  1510. const CLASS_NAME_NEXT = 'carousel-item-next';
  1511. const CLASS_NAME_PREV = 'carousel-item-prev';
  1512. const SELECTOR_ACTIVE = '.active';
  1513. const SELECTOR_ITEM = '.carousel-item';
  1514. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  1515. const SELECTOR_ITEM_IMG = '.carousel-item img';
  1516. const SELECTOR_INDICATORS = '.carousel-indicators';
  1517. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  1518. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  1519. const KEY_TO_DIRECTION = {
  1520. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  1521. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  1522. };
  1523. const Default$b = {
  1524. interval: 5000,
  1525. keyboard: true,
  1526. pause: 'hover',
  1527. ride: false,
  1528. touch: true,
  1529. wrap: true
  1530. };
  1531. const DefaultType$b = {
  1532. interval: '(number|boolean)',
  1533. // TODO:v6 remove boolean support
  1534. keyboard: 'boolean',
  1535. pause: '(string|boolean)',
  1536. ride: '(boolean|string)',
  1537. touch: 'boolean',
  1538. wrap: 'boolean'
  1539. };
  1540. /**
  1541. * Class definition
  1542. */
  1543. class Carousel extends BaseComponent {
  1544. constructor(element, config) {
  1545. super(element, config);
  1546. this._interval = null;
  1547. this._activeElement = null;
  1548. this._isSliding = false;
  1549. this.touchTimeout = null;
  1550. this._swipeHelper = null;
  1551. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  1552. this._addEventListeners();
  1553. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  1554. this.cycle();
  1555. }
  1556. }
  1557. // Getters
  1558. static get Default() {
  1559. return Default$b;
  1560. }
  1561. static get DefaultType() {
  1562. return DefaultType$b;
  1563. }
  1564. static get NAME() {
  1565. return NAME$c;
  1566. }
  1567. // Public
  1568. next() {
  1569. this._slide(ORDER_NEXT);
  1570. }
  1571. nextWhenVisible() {
  1572. // FIXME TODO use `document.visibilityState`
  1573. // Don't call next when the page isn't visible
  1574. // or the carousel or its parent isn't visible
  1575. if (!document.hidden && isVisible(this._element)) {
  1576. this.next();
  1577. }
  1578. }
  1579. prev() {
  1580. this._slide(ORDER_PREV);
  1581. }
  1582. pause() {
  1583. if (this._isSliding) {
  1584. triggerTransitionEnd(this._element);
  1585. }
  1586. this._clearInterval();
  1587. }
  1588. cycle() {
  1589. this._clearInterval();
  1590. this._updateInterval();
  1591. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  1592. }
  1593. _maybeEnableCycle() {
  1594. if (!this._config.ride) {
  1595. return;
  1596. }
  1597. if (this._isSliding) {
  1598. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  1599. return;
  1600. }
  1601. this.cycle();
  1602. }
  1603. to(index) {
  1604. const items = this._getItems();
  1605. if (index > items.length - 1 || index < 0) {
  1606. return;
  1607. }
  1608. if (this._isSliding) {
  1609. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  1610. return;
  1611. }
  1612. const activeIndex = this._getItemIndex(this._getActive());
  1613. if (activeIndex === index) {
  1614. return;
  1615. }
  1616. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  1617. this._slide(order, items[index]);
  1618. }
  1619. dispose() {
  1620. if (this._swipeHelper) {
  1621. this._swipeHelper.dispose();
  1622. }
  1623. super.dispose();
  1624. }
  1625. // Private
  1626. _configAfterMerge(config) {
  1627. config.defaultInterval = config.interval;
  1628. return config;
  1629. }
  1630. _addEventListeners() {
  1631. if (this._config.keyboard) {
  1632. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  1633. }
  1634. if (this._config.pause === 'hover') {
  1635. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  1636. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  1637. }
  1638. if (this._config.touch && Swipe.isSupported()) {
  1639. this._addTouchEventListeners();
  1640. }
  1641. }
  1642. _addTouchEventListeners() {
  1643. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  1644. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  1645. }
  1646. const endCallBack = () => {
  1647. if (this._config.pause !== 'hover') {
  1648. return;
  1649. }
  1650. // If it's a touch-enabled device, mouseenter/leave are fired as
  1651. // part of the mouse compatibility events on first tap - the carousel
  1652. // would stop cycling until user tapped out of it;
  1653. // here, we listen for touchend, explicitly pause the carousel
  1654. // (as if it's the second time we tap on it, mouseenter compat event
  1655. // is NOT fired) and after a timeout (to allow for mouse compatibility
  1656. // events to fire) we explicitly restart cycling
  1657. this.pause();
  1658. if (this.touchTimeout) {
  1659. clearTimeout(this.touchTimeout);
  1660. }
  1661. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  1662. };
  1663. const swipeConfig = {
  1664. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  1665. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  1666. endCallback: endCallBack
  1667. };
  1668. this._swipeHelper = new Swipe(this._element, swipeConfig);
  1669. }
  1670. _keydown(event) {
  1671. if (/input|textarea/i.test(event.target.tagName)) {
  1672. return;
  1673. }
  1674. const direction = KEY_TO_DIRECTION[event.key];
  1675. if (direction) {
  1676. event.preventDefault();
  1677. this._slide(this._directionToOrder(direction));
  1678. }
  1679. }
  1680. _getItemIndex(element) {
  1681. return this._getItems().indexOf(element);
  1682. }
  1683. _setActiveIndicatorElement(index) {
  1684. if (!this._indicatorsElement) {
  1685. return;
  1686. }
  1687. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  1688. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  1689. activeIndicator.removeAttribute('aria-current');
  1690. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  1691. if (newActiveIndicator) {
  1692. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  1693. newActiveIndicator.setAttribute('aria-current', 'true');
  1694. }
  1695. }
  1696. _updateInterval() {
  1697. const element = this._activeElement || this._getActive();
  1698. if (!element) {
  1699. return;
  1700. }
  1701. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  1702. this._config.interval = elementInterval || this._config.defaultInterval;
  1703. }
  1704. _slide(order, element = null) {
  1705. if (this._isSliding) {
  1706. return;
  1707. }
  1708. const activeElement = this._getActive();
  1709. const isNext = order === ORDER_NEXT;
  1710. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  1711. if (nextElement === activeElement) {
  1712. return;
  1713. }
  1714. const nextElementIndex = this._getItemIndex(nextElement);
  1715. const triggerEvent = eventName => {
  1716. return EventHandler.trigger(this._element, eventName, {
  1717. relatedTarget: nextElement,
  1718. direction: this._orderToDirection(order),
  1719. from: this._getItemIndex(activeElement),
  1720. to: nextElementIndex
  1721. });
  1722. };
  1723. const slideEvent = triggerEvent(EVENT_SLIDE);
  1724. if (slideEvent.defaultPrevented) {
  1725. return;
  1726. }
  1727. if (!activeElement || !nextElement) {
  1728. // Some weirdness is happening, so we bail
  1729. // TODO: change tests that use empty divs to avoid this check
  1730. return;
  1731. }
  1732. const isCycling = Boolean(this._interval);
  1733. this.pause();
  1734. this._isSliding = true;
  1735. this._setActiveIndicatorElement(nextElementIndex);
  1736. this._activeElement = nextElement;
  1737. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  1738. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  1739. nextElement.classList.add(orderClassName);
  1740. reflow(nextElement);
  1741. activeElement.classList.add(directionalClassName);
  1742. nextElement.classList.add(directionalClassName);
  1743. const completeCallBack = () => {
  1744. nextElement.classList.remove(directionalClassName, orderClassName);
  1745. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1746. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  1747. this._isSliding = false;
  1748. triggerEvent(EVENT_SLID);
  1749. };
  1750. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  1751. if (isCycling) {
  1752. this.cycle();
  1753. }
  1754. }
  1755. _isAnimated() {
  1756. return this._element.classList.contains(CLASS_NAME_SLIDE);
  1757. }
  1758. _getActive() {
  1759. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1760. }
  1761. _getItems() {
  1762. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  1763. }
  1764. _clearInterval() {
  1765. if (this._interval) {
  1766. clearInterval(this._interval);
  1767. this._interval = null;
  1768. }
  1769. }
  1770. _directionToOrder(direction) {
  1771. if (isRTL()) {
  1772. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  1773. }
  1774. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  1775. }
  1776. _orderToDirection(order) {
  1777. if (isRTL()) {
  1778. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1779. }
  1780. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  1781. }
  1782. // Static
  1783. static jQueryInterface(config) {
  1784. return this.each(function () {
  1785. const data = Carousel.getOrCreateInstance(this, config);
  1786. if (typeof config === 'number') {
  1787. data.to(config);
  1788. return;
  1789. }
  1790. if (typeof config === 'string') {
  1791. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1792. throw new TypeError(`No method named "${config}"`);
  1793. }
  1794. data[config]();
  1795. }
  1796. });
  1797. }
  1798. }
  1799. /**
  1800. * Data API implementation
  1801. */
  1802. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  1803. const target = SelectorEngine.getElementFromSelector(this);
  1804. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  1805. return;
  1806. }
  1807. event.preventDefault();
  1808. const carousel = Carousel.getOrCreateInstance(target);
  1809. const slideIndex = this.getAttribute('data-bs-slide-to');
  1810. if (slideIndex) {
  1811. carousel.to(slideIndex);
  1812. carousel._maybeEnableCycle();
  1813. return;
  1814. }
  1815. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  1816. carousel.next();
  1817. carousel._maybeEnableCycle();
  1818. return;
  1819. }
  1820. carousel.prev();
  1821. carousel._maybeEnableCycle();
  1822. });
  1823. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  1824. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  1825. for (const carousel of carousels) {
  1826. Carousel.getOrCreateInstance(carousel);
  1827. }
  1828. });
  1829. /**
  1830. * jQuery
  1831. */
  1832. defineJQueryPlugin(Carousel);
  1833. /**
  1834. * --------------------------------------------------------------------------
  1835. * Bootstrap collapse.js
  1836. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1837. * --------------------------------------------------------------------------
  1838. */
  1839. /**
  1840. * Constants
  1841. */
  1842. const NAME$b = 'collapse';
  1843. const DATA_KEY$7 = 'bs.collapse';
  1844. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  1845. const DATA_API_KEY$4 = '.data-api';
  1846. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  1847. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  1848. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  1849. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  1850. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  1851. const CLASS_NAME_SHOW$7 = 'show';
  1852. const CLASS_NAME_COLLAPSE = 'collapse';
  1853. const CLASS_NAME_COLLAPSING = 'collapsing';
  1854. const CLASS_NAME_COLLAPSED = 'collapsed';
  1855. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  1856. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  1857. const WIDTH = 'width';
  1858. const HEIGHT = 'height';
  1859. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  1860. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  1861. const Default$a = {
  1862. parent: null,
  1863. toggle: true
  1864. };
  1865. const DefaultType$a = {
  1866. parent: '(null|element)',
  1867. toggle: 'boolean'
  1868. };
  1869. /**
  1870. * Class definition
  1871. */
  1872. class Collapse extends BaseComponent {
  1873. constructor(element, config) {
  1874. super(element, config);
  1875. this._isTransitioning = false;
  1876. this._triggerArray = [];
  1877. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  1878. for (const elem of toggleList) {
  1879. const selector = SelectorEngine.getSelectorFromElement(elem);
  1880. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  1881. if (selector !== null && filterElement.length) {
  1882. this._triggerArray.push(elem);
  1883. }
  1884. }
  1885. this._initializeChildren();
  1886. if (!this._config.parent) {
  1887. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  1888. }
  1889. if (this._config.toggle) {
  1890. this.toggle();
  1891. }
  1892. }
  1893. // Getters
  1894. static get Default() {
  1895. return Default$a;
  1896. }
  1897. static get DefaultType() {
  1898. return DefaultType$a;
  1899. }
  1900. static get NAME() {
  1901. return NAME$b;
  1902. }
  1903. // Public
  1904. toggle() {
  1905. if (this._isShown()) {
  1906. this.hide();
  1907. } else {
  1908. this.show();
  1909. }
  1910. }
  1911. show() {
  1912. if (this._isTransitioning || this._isShown()) {
  1913. return;
  1914. }
  1915. let activeChildren = [];
  1916. // find active children
  1917. if (this._config.parent) {
  1918. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  1919. toggle: false
  1920. }));
  1921. }
  1922. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  1923. return;
  1924. }
  1925. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  1926. if (startEvent.defaultPrevented) {
  1927. return;
  1928. }
  1929. for (const activeInstance of activeChildren) {
  1930. activeInstance.hide();
  1931. }
  1932. const dimension = this._getDimension();
  1933. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  1934. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1935. this._element.style[dimension] = 0;
  1936. this._addAriaAndCollapsedClass(this._triggerArray, true);
  1937. this._isTransitioning = true;
  1938. const complete = () => {
  1939. this._isTransitioning = false;
  1940. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1941. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1942. this._element.style[dimension] = '';
  1943. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  1944. };
  1945. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  1946. const scrollSize = `scroll${capitalizedDimension}`;
  1947. this._queueCallback(complete, this._element, true);
  1948. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  1949. }
  1950. hide() {
  1951. if (this._isTransitioning || !this._isShown()) {
  1952. return;
  1953. }
  1954. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  1955. if (startEvent.defaultPrevented) {
  1956. return;
  1957. }
  1958. const dimension = this._getDimension();
  1959. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  1960. reflow(this._element);
  1961. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1962. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1963. for (const trigger of this._triggerArray) {
  1964. const element = SelectorEngine.getElementFromSelector(trigger);
  1965. if (element && !this._isShown(element)) {
  1966. this._addAriaAndCollapsedClass([trigger], false);
  1967. }
  1968. }
  1969. this._isTransitioning = true;
  1970. const complete = () => {
  1971. this._isTransitioning = false;
  1972. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1973. this._element.classList.add(CLASS_NAME_COLLAPSE);
  1974. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  1975. };
  1976. this._element.style[dimension] = '';
  1977. this._queueCallback(complete, this._element, true);
  1978. }
  1979. _isShown(element = this._element) {
  1980. return element.classList.contains(CLASS_NAME_SHOW$7);
  1981. }
  1982. // Private
  1983. _configAfterMerge(config) {
  1984. config.toggle = Boolean(config.toggle); // Coerce string values
  1985. config.parent = getElement(config.parent);
  1986. return config;
  1987. }
  1988. _getDimension() {
  1989. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  1990. }
  1991. _initializeChildren() {
  1992. if (!this._config.parent) {
  1993. return;
  1994. }
  1995. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  1996. for (const element of children) {
  1997. const selected = SelectorEngine.getElementFromSelector(element);
  1998. if (selected) {
  1999. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  2000. }
  2001. }
  2002. }
  2003. _getFirstLevelChildren(selector) {
  2004. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  2005. // remove children if greater depth
  2006. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  2007. }
  2008. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  2009. if (!triggerArray.length) {
  2010. return;
  2011. }
  2012. for (const element of triggerArray) {
  2013. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  2014. element.setAttribute('aria-expanded', isOpen);
  2015. }
  2016. }
  2017. // Static
  2018. static jQueryInterface(config) {
  2019. const _config = {};
  2020. if (typeof config === 'string' && /show|hide/.test(config)) {
  2021. _config.toggle = false;
  2022. }
  2023. return this.each(function () {
  2024. const data = Collapse.getOrCreateInstance(this, _config);
  2025. if (typeof config === 'string') {
  2026. if (typeof data[config] === 'undefined') {
  2027. throw new TypeError(`No method named "${config}"`);
  2028. }
  2029. data[config]();
  2030. }
  2031. });
  2032. }
  2033. }
  2034. /**
  2035. * Data API implementation
  2036. */
  2037. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  2038. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  2039. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  2040. event.preventDefault();
  2041. }
  2042. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  2043. Collapse.getOrCreateInstance(element, {
  2044. toggle: false
  2045. }).toggle();
  2046. }
  2047. });
  2048. /**
  2049. * jQuery
  2050. */
  2051. defineJQueryPlugin(Collapse);
  2052. var top = 'top';
  2053. var bottom = 'bottom';
  2054. var right = 'right';
  2055. var left = 'left';
  2056. var auto = 'auto';
  2057. var basePlacements = [top, bottom, right, left];
  2058. var start = 'start';
  2059. var end = 'end';
  2060. var clippingParents = 'clippingParents';
  2061. var viewport = 'viewport';
  2062. var popper = 'popper';
  2063. var reference = 'reference';
  2064. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  2065. return acc.concat([placement + "-" + start, placement + "-" + end]);
  2066. }, []);
  2067. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  2068. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  2069. }, []); // modifiers that need to read the DOM
  2070. var beforeRead = 'beforeRead';
  2071. var read = 'read';
  2072. var afterRead = 'afterRead'; // pure-logic modifiers
  2073. var beforeMain = 'beforeMain';
  2074. var main = 'main';
  2075. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  2076. var beforeWrite = 'beforeWrite';
  2077. var write = 'write';
  2078. var afterWrite = 'afterWrite';
  2079. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  2080. function getNodeName(element) {
  2081. return element ? (element.nodeName || '').toLowerCase() : null;
  2082. }
  2083. function getWindow(node) {
  2084. if (node == null) {
  2085. return window;
  2086. }
  2087. if (node.toString() !== '[object Window]') {
  2088. var ownerDocument = node.ownerDocument;
  2089. return ownerDocument ? ownerDocument.defaultView || window : window;
  2090. }
  2091. return node;
  2092. }
  2093. function isElement(node) {
  2094. var OwnElement = getWindow(node).Element;
  2095. return node instanceof OwnElement || node instanceof Element;
  2096. }
  2097. function isHTMLElement(node) {
  2098. var OwnElement = getWindow(node).HTMLElement;
  2099. return node instanceof OwnElement || node instanceof HTMLElement;
  2100. }
  2101. function isShadowRoot(node) {
  2102. // IE 11 has no ShadowRoot
  2103. if (typeof ShadowRoot === 'undefined') {
  2104. return false;
  2105. }
  2106. var OwnElement = getWindow(node).ShadowRoot;
  2107. return node instanceof OwnElement || node instanceof ShadowRoot;
  2108. }
  2109. // and applies them to the HTMLElements such as popper and arrow
  2110. function applyStyles(_ref) {
  2111. var state = _ref.state;
  2112. Object.keys(state.elements).forEach(function (name) {
  2113. var style = state.styles[name] || {};
  2114. var attributes = state.attributes[name] || {};
  2115. var element = state.elements[name]; // arrow is optional + virtual elements
  2116. if (!isHTMLElement(element) || !getNodeName(element)) {
  2117. return;
  2118. } // Flow doesn't support to extend this property, but it's the most
  2119. // effective way to apply styles to an HTMLElement
  2120. // $FlowFixMe[cannot-write]
  2121. Object.assign(element.style, style);
  2122. Object.keys(attributes).forEach(function (name) {
  2123. var value = attributes[name];
  2124. if (value === false) {
  2125. element.removeAttribute(name);
  2126. } else {
  2127. element.setAttribute(name, value === true ? '' : value);
  2128. }
  2129. });
  2130. });
  2131. }
  2132. function effect$2(_ref2) {
  2133. var state = _ref2.state;
  2134. var initialStyles = {
  2135. popper: {
  2136. position: state.options.strategy,
  2137. left: '0',
  2138. top: '0',
  2139. margin: '0'
  2140. },
  2141. arrow: {
  2142. position: 'absolute'
  2143. },
  2144. reference: {}
  2145. };
  2146. Object.assign(state.elements.popper.style, initialStyles.popper);
  2147. state.styles = initialStyles;
  2148. if (state.elements.arrow) {
  2149. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  2150. }
  2151. return function () {
  2152. Object.keys(state.elements).forEach(function (name) {
  2153. var element = state.elements[name];
  2154. var attributes = state.attributes[name] || {};
  2155. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  2156. var style = styleProperties.reduce(function (style, property) {
  2157. style[property] = '';
  2158. return style;
  2159. }, {}); // arrow is optional + virtual elements
  2160. if (!isHTMLElement(element) || !getNodeName(element)) {
  2161. return;
  2162. }
  2163. Object.assign(element.style, style);
  2164. Object.keys(attributes).forEach(function (attribute) {
  2165. element.removeAttribute(attribute);
  2166. });
  2167. });
  2168. };
  2169. } // eslint-disable-next-line import/no-unused-modules
  2170. const applyStyles$1 = {
  2171. name: 'applyStyles',
  2172. enabled: true,
  2173. phase: 'write',
  2174. fn: applyStyles,
  2175. effect: effect$2,
  2176. requires: ['computeStyles']
  2177. };
  2178. function getBasePlacement(placement) {
  2179. return placement.split('-')[0];
  2180. }
  2181. var max = Math.max;
  2182. var min = Math.min;
  2183. var round = Math.round;
  2184. function getUAString() {
  2185. var uaData = navigator.userAgentData;
  2186. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  2187. return uaData.brands.map(function (item) {
  2188. return item.brand + "/" + item.version;
  2189. }).join(' ');
  2190. }
  2191. return navigator.userAgent;
  2192. }
  2193. function isLayoutViewport() {
  2194. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  2195. }
  2196. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  2197. if (includeScale === void 0) {
  2198. includeScale = false;
  2199. }
  2200. if (isFixedStrategy === void 0) {
  2201. isFixedStrategy = false;
  2202. }
  2203. var clientRect = element.getBoundingClientRect();
  2204. var scaleX = 1;
  2205. var scaleY = 1;
  2206. if (includeScale && isHTMLElement(element)) {
  2207. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  2208. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  2209. }
  2210. var _ref = isElement(element) ? getWindow(element) : window,
  2211. visualViewport = _ref.visualViewport;
  2212. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  2213. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  2214. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  2215. var width = clientRect.width / scaleX;
  2216. var height = clientRect.height / scaleY;
  2217. return {
  2218. width: width,
  2219. height: height,
  2220. top: y,
  2221. right: x + width,
  2222. bottom: y + height,
  2223. left: x,
  2224. x: x,
  2225. y: y
  2226. };
  2227. }
  2228. // means it doesn't take into account transforms.
  2229. function getLayoutRect(element) {
  2230. var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
  2231. // Fixes https://github.com/popperjs/popper-core/issues/1223
  2232. var width = element.offsetWidth;
  2233. var height = element.offsetHeight;
  2234. if (Math.abs(clientRect.width - width) <= 1) {
  2235. width = clientRect.width;
  2236. }
  2237. if (Math.abs(clientRect.height - height) <= 1) {
  2238. height = clientRect.height;
  2239. }
  2240. return {
  2241. x: element.offsetLeft,
  2242. y: element.offsetTop,
  2243. width: width,
  2244. height: height
  2245. };
  2246. }
  2247. function contains(parent, child) {
  2248. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  2249. if (parent.contains(child)) {
  2250. return true;
  2251. } // then fallback to custom implementation with Shadow DOM support
  2252. else if (rootNode && isShadowRoot(rootNode)) {
  2253. var next = child;
  2254. do {
  2255. if (next && parent.isSameNode(next)) {
  2256. return true;
  2257. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  2258. next = next.parentNode || next.host;
  2259. } while (next);
  2260. } // Give up, the result is false
  2261. return false;
  2262. }
  2263. function getComputedStyle$1(element) {
  2264. return getWindow(element).getComputedStyle(element);
  2265. }
  2266. function isTableElement(element) {
  2267. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  2268. }
  2269. function getDocumentElement(element) {
  2270. // $FlowFixMe[incompatible-return]: assume body is always available
  2271. return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  2272. element.document) || window.document).documentElement;
  2273. }
  2274. function getParentNode(element) {
  2275. if (getNodeName(element) === 'html') {
  2276. return element;
  2277. }
  2278. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  2279. // $FlowFixMe[incompatible-return]
  2280. // $FlowFixMe[prop-missing]
  2281. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  2282. element.parentNode || ( // DOM Element detected
  2283. isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  2284. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  2285. getDocumentElement(element) // fallback
  2286. );
  2287. }
  2288. function getTrueOffsetParent(element) {
  2289. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  2290. getComputedStyle$1(element).position === 'fixed') {
  2291. return null;
  2292. }
  2293. return element.offsetParent;
  2294. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  2295. // return the containing block
  2296. function getContainingBlock(element) {
  2297. var isFirefox = /firefox/i.test(getUAString());
  2298. var isIE = /Trident/i.test(getUAString());
  2299. if (isIE && isHTMLElement(element)) {
  2300. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  2301. var elementCss = getComputedStyle$1(element);
  2302. if (elementCss.position === 'fixed') {
  2303. return null;
  2304. }
  2305. }
  2306. var currentNode = getParentNode(element);
  2307. if (isShadowRoot(currentNode)) {
  2308. currentNode = currentNode.host;
  2309. }
  2310. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  2311. var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  2312. // create a containing block.
  2313. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  2314. if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
  2315. return currentNode;
  2316. } else {
  2317. currentNode = currentNode.parentNode;
  2318. }
  2319. }
  2320. return null;
  2321. } // Gets the closest ancestor positioned element. Handles some edge cases,
  2322. // such as table ancestors and cross browser bugs.
  2323. function getOffsetParent(element) {
  2324. var window = getWindow(element);
  2325. var offsetParent = getTrueOffsetParent(element);
  2326. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  2327. offsetParent = getTrueOffsetParent(offsetParent);
  2328. }
  2329. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  2330. return window;
  2331. }
  2332. return offsetParent || getContainingBlock(element) || window;
  2333. }
  2334. function getMainAxisFromPlacement(placement) {
  2335. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  2336. }
  2337. function within(min$1, value, max$1) {
  2338. return max(min$1, min(value, max$1));
  2339. }
  2340. function withinMaxClamp(min, value, max) {
  2341. var v = within(min, value, max);
  2342. return v > max ? max : v;
  2343. }
  2344. function getFreshSideObject() {
  2345. return {
  2346. top: 0,
  2347. right: 0,
  2348. bottom: 0,
  2349. left: 0
  2350. };
  2351. }
  2352. function mergePaddingObject(paddingObject) {
  2353. return Object.assign({}, getFreshSideObject(), paddingObject);
  2354. }
  2355. function expandToHashMap(value, keys) {
  2356. return keys.reduce(function (hashMap, key) {
  2357. hashMap[key] = value;
  2358. return hashMap;
  2359. }, {});
  2360. }
  2361. var toPaddingObject = function toPaddingObject(padding, state) {
  2362. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  2363. placement: state.placement
  2364. })) : padding;
  2365. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2366. };
  2367. function arrow(_ref) {
  2368. var _state$modifiersData$;
  2369. var state = _ref.state,
  2370. name = _ref.name,
  2371. options = _ref.options;
  2372. var arrowElement = state.elements.arrow;
  2373. var popperOffsets = state.modifiersData.popperOffsets;
  2374. var basePlacement = getBasePlacement(state.placement);
  2375. var axis = getMainAxisFromPlacement(basePlacement);
  2376. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  2377. var len = isVertical ? 'height' : 'width';
  2378. if (!arrowElement || !popperOffsets) {
  2379. return;
  2380. }
  2381. var paddingObject = toPaddingObject(options.padding, state);
  2382. var arrowRect = getLayoutRect(arrowElement);
  2383. var minProp = axis === 'y' ? top : left;
  2384. var maxProp = axis === 'y' ? bottom : right;
  2385. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  2386. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  2387. var arrowOffsetParent = getOffsetParent(arrowElement);
  2388. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  2389. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  2390. // outside of the popper bounds
  2391. var min = paddingObject[minProp];
  2392. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  2393. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  2394. var offset = within(min, center, max); // Prevents breaking syntax highlighting...
  2395. var axisProp = axis;
  2396. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  2397. }
  2398. function effect$1(_ref2) {
  2399. var state = _ref2.state,
  2400. options = _ref2.options;
  2401. var _options$element = options.element,
  2402. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  2403. if (arrowElement == null) {
  2404. return;
  2405. } // CSS selector
  2406. if (typeof arrowElement === 'string') {
  2407. arrowElement = state.elements.popper.querySelector(arrowElement);
  2408. if (!arrowElement) {
  2409. return;
  2410. }
  2411. }
  2412. if (!contains(state.elements.popper, arrowElement)) {
  2413. return;
  2414. }
  2415. state.elements.arrow = arrowElement;
  2416. } // eslint-disable-next-line import/no-unused-modules
  2417. const arrow$1 = {
  2418. name: 'arrow',
  2419. enabled: true,
  2420. phase: 'main',
  2421. fn: arrow,
  2422. effect: effect$1,
  2423. requires: ['popperOffsets'],
  2424. requiresIfExists: ['preventOverflow']
  2425. };
  2426. function getVariation(placement) {
  2427. return placement.split('-')[1];
  2428. }
  2429. var unsetSides = {
  2430. top: 'auto',
  2431. right: 'auto',
  2432. bottom: 'auto',
  2433. left: 'auto'
  2434. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  2435. // Zooming can change the DPR, but it seems to report a value that will
  2436. // cleanly divide the values into the appropriate subpixels.
  2437. function roundOffsetsByDPR(_ref, win) {
  2438. var x = _ref.x,
  2439. y = _ref.y;
  2440. var dpr = win.devicePixelRatio || 1;
  2441. return {
  2442. x: round(x * dpr) / dpr || 0,
  2443. y: round(y * dpr) / dpr || 0
  2444. };
  2445. }
  2446. function mapToStyles(_ref2) {
  2447. var _Object$assign2;
  2448. var popper = _ref2.popper,
  2449. popperRect = _ref2.popperRect,
  2450. placement = _ref2.placement,
  2451. variation = _ref2.variation,
  2452. offsets = _ref2.offsets,
  2453. position = _ref2.position,
  2454. gpuAcceleration = _ref2.gpuAcceleration,
  2455. adaptive = _ref2.adaptive,
  2456. roundOffsets = _ref2.roundOffsets,
  2457. isFixed = _ref2.isFixed;
  2458. var _offsets$x = offsets.x,
  2459. x = _offsets$x === void 0 ? 0 : _offsets$x,
  2460. _offsets$y = offsets.y,
  2461. y = _offsets$y === void 0 ? 0 : _offsets$y;
  2462. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  2463. x: x,
  2464. y: y
  2465. }) : {
  2466. x: x,
  2467. y: y
  2468. };
  2469. x = _ref3.x;
  2470. y = _ref3.y;
  2471. var hasX = offsets.hasOwnProperty('x');
  2472. var hasY = offsets.hasOwnProperty('y');
  2473. var sideX = left;
  2474. var sideY = top;
  2475. var win = window;
  2476. if (adaptive) {
  2477. var offsetParent = getOffsetParent(popper);
  2478. var heightProp = 'clientHeight';
  2479. var widthProp = 'clientWidth';
  2480. if (offsetParent === getWindow(popper)) {
  2481. offsetParent = getDocumentElement(popper);
  2482. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  2483. heightProp = 'scrollHeight';
  2484. widthProp = 'scrollWidth';
  2485. }
  2486. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  2487. offsetParent = offsetParent;
  2488. if (placement === top || (placement === left || placement === right) && variation === end) {
  2489. sideY = bottom;
  2490. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
  2491. offsetParent[heightProp];
  2492. y -= offsetY - popperRect.height;
  2493. y *= gpuAcceleration ? 1 : -1;
  2494. }
  2495. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  2496. sideX = right;
  2497. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
  2498. offsetParent[widthProp];
  2499. x -= offsetX - popperRect.width;
  2500. x *= gpuAcceleration ? 1 : -1;
  2501. }
  2502. }
  2503. var commonStyles = Object.assign({
  2504. position: position
  2505. }, adaptive && unsetSides);
  2506. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  2507. x: x,
  2508. y: y
  2509. }, getWindow(popper)) : {
  2510. x: x,
  2511. y: y
  2512. };
  2513. x = _ref4.x;
  2514. y = _ref4.y;
  2515. if (gpuAcceleration) {
  2516. var _Object$assign;
  2517. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  2518. }
  2519. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  2520. }
  2521. function computeStyles(_ref5) {
  2522. var state = _ref5.state,
  2523. options = _ref5.options;
  2524. var _options$gpuAccelerat = options.gpuAcceleration,
  2525. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  2526. _options$adaptive = options.adaptive,
  2527. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  2528. _options$roundOffsets = options.roundOffsets,
  2529. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  2530. var commonStyles = {
  2531. placement: getBasePlacement(state.placement),
  2532. variation: getVariation(state.placement),
  2533. popper: state.elements.popper,
  2534. popperRect: state.rects.popper,
  2535. gpuAcceleration: gpuAcceleration,
  2536. isFixed: state.options.strategy === 'fixed'
  2537. };
  2538. if (state.modifiersData.popperOffsets != null) {
  2539. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  2540. offsets: state.modifiersData.popperOffsets,
  2541. position: state.options.strategy,
  2542. adaptive: adaptive,
  2543. roundOffsets: roundOffsets
  2544. })));
  2545. }
  2546. if (state.modifiersData.arrow != null) {
  2547. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  2548. offsets: state.modifiersData.arrow,
  2549. position: 'absolute',
  2550. adaptive: false,
  2551. roundOffsets: roundOffsets
  2552. })));
  2553. }
  2554. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  2555. 'data-popper-placement': state.placement
  2556. });
  2557. } // eslint-disable-next-line import/no-unused-modules
  2558. const computeStyles$1 = {
  2559. name: 'computeStyles',
  2560. enabled: true,
  2561. phase: 'beforeWrite',
  2562. fn: computeStyles,
  2563. data: {}
  2564. };
  2565. var passive = {
  2566. passive: true
  2567. };
  2568. function effect(_ref) {
  2569. var state = _ref.state,
  2570. instance = _ref.instance,
  2571. options = _ref.options;
  2572. var _options$scroll = options.scroll,
  2573. scroll = _options$scroll === void 0 ? true : _options$scroll,
  2574. _options$resize = options.resize,
  2575. resize = _options$resize === void 0 ? true : _options$resize;
  2576. var window = getWindow(state.elements.popper);
  2577. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  2578. if (scroll) {
  2579. scrollParents.forEach(function (scrollParent) {
  2580. scrollParent.addEventListener('scroll', instance.update, passive);
  2581. });
  2582. }
  2583. if (resize) {
  2584. window.addEventListener('resize', instance.update, passive);
  2585. }
  2586. return function () {
  2587. if (scroll) {
  2588. scrollParents.forEach(function (scrollParent) {
  2589. scrollParent.removeEventListener('scroll', instance.update, passive);
  2590. });
  2591. }
  2592. if (resize) {
  2593. window.removeEventListener('resize', instance.update, passive);
  2594. }
  2595. };
  2596. } // eslint-disable-next-line import/no-unused-modules
  2597. const eventListeners = {
  2598. name: 'eventListeners',
  2599. enabled: true,
  2600. phase: 'write',
  2601. fn: function fn() {},
  2602. effect: effect,
  2603. data: {}
  2604. };
  2605. var hash$1 = {
  2606. left: 'right',
  2607. right: 'left',
  2608. bottom: 'top',
  2609. top: 'bottom'
  2610. };
  2611. function getOppositePlacement(placement) {
  2612. return placement.replace(/left|right|bottom|top/g, function (matched) {
  2613. return hash$1[matched];
  2614. });
  2615. }
  2616. var hash = {
  2617. start: 'end',
  2618. end: 'start'
  2619. };
  2620. function getOppositeVariationPlacement(placement) {
  2621. return placement.replace(/start|end/g, function (matched) {
  2622. return hash[matched];
  2623. });
  2624. }
  2625. function getWindowScroll(node) {
  2626. var win = getWindow(node);
  2627. var scrollLeft = win.pageXOffset;
  2628. var scrollTop = win.pageYOffset;
  2629. return {
  2630. scrollLeft: scrollLeft,
  2631. scrollTop: scrollTop
  2632. };
  2633. }
  2634. function getWindowScrollBarX(element) {
  2635. // If <html> has a CSS width greater than the viewport, then this will be
  2636. // incorrect for RTL.
  2637. // Popper 1 is broken in this case and never had a bug report so let's assume
  2638. // it's not an issue. I don't think anyone ever specifies width on <html>
  2639. // anyway.
  2640. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  2641. // this (e.g. Edge 2019, IE11, Safari)
  2642. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  2643. }
  2644. function getViewportRect(element, strategy) {
  2645. var win = getWindow(element);
  2646. var html = getDocumentElement(element);
  2647. var visualViewport = win.visualViewport;
  2648. var width = html.clientWidth;
  2649. var height = html.clientHeight;
  2650. var x = 0;
  2651. var y = 0;
  2652. if (visualViewport) {
  2653. width = visualViewport.width;
  2654. height = visualViewport.height;
  2655. var layoutViewport = isLayoutViewport();
  2656. if (layoutViewport || !layoutViewport && strategy === 'fixed') {
  2657. x = visualViewport.offsetLeft;
  2658. y = visualViewport.offsetTop;
  2659. }
  2660. }
  2661. return {
  2662. width: width,
  2663. height: height,
  2664. x: x + getWindowScrollBarX(element),
  2665. y: y
  2666. };
  2667. }
  2668. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  2669. function getDocumentRect(element) {
  2670. var _element$ownerDocumen;
  2671. var html = getDocumentElement(element);
  2672. var winScroll = getWindowScroll(element);
  2673. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  2674. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  2675. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  2676. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  2677. var y = -winScroll.scrollTop;
  2678. if (getComputedStyle$1(body || html).direction === 'rtl') {
  2679. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  2680. }
  2681. return {
  2682. width: width,
  2683. height: height,
  2684. x: x,
  2685. y: y
  2686. };
  2687. }
  2688. function isScrollParent(element) {
  2689. // Firefox wants us to check `-x` and `-y` variations as well
  2690. var _getComputedStyle = getComputedStyle$1(element),
  2691. overflow = _getComputedStyle.overflow,
  2692. overflowX = _getComputedStyle.overflowX,
  2693. overflowY = _getComputedStyle.overflowY;
  2694. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  2695. }
  2696. function getScrollParent(node) {
  2697. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  2698. // $FlowFixMe[incompatible-return]: assume body is always available
  2699. return node.ownerDocument.body;
  2700. }
  2701. if (isHTMLElement(node) && isScrollParent(node)) {
  2702. return node;
  2703. }
  2704. return getScrollParent(getParentNode(node));
  2705. }
  2706. /*
  2707. given a DOM element, return the list of all scroll parents, up the list of ancesors
  2708. until we get to the top window object. This list is what we attach scroll listeners
  2709. to, because if any of these parent elements scroll, we'll need to re-calculate the
  2710. reference element's position.
  2711. */
  2712. function listScrollParents(element, list) {
  2713. var _element$ownerDocumen;
  2714. if (list === void 0) {
  2715. list = [];
  2716. }
  2717. var scrollParent = getScrollParent(element);
  2718. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  2719. var win = getWindow(scrollParent);
  2720. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  2721. var updatedList = list.concat(target);
  2722. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  2723. updatedList.concat(listScrollParents(getParentNode(target)));
  2724. }
  2725. function rectToClientRect(rect) {
  2726. return Object.assign({}, rect, {
  2727. left: rect.x,
  2728. top: rect.y,
  2729. right: rect.x + rect.width,
  2730. bottom: rect.y + rect.height
  2731. });
  2732. }
  2733. function getInnerBoundingClientRect(element, strategy) {
  2734. var rect = getBoundingClientRect(element, false, strategy === 'fixed');
  2735. rect.top = rect.top + element.clientTop;
  2736. rect.left = rect.left + element.clientLeft;
  2737. rect.bottom = rect.top + element.clientHeight;
  2738. rect.right = rect.left + element.clientWidth;
  2739. rect.width = element.clientWidth;
  2740. rect.height = element.clientHeight;
  2741. rect.x = rect.left;
  2742. rect.y = rect.top;
  2743. return rect;
  2744. }
  2745. function getClientRectFromMixedType(element, clippingParent, strategy) {
  2746. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  2747. } // A "clipping parent" is an overflowable container with the characteristic of
  2748. // clipping (or hiding) overflowing elements with a position different from
  2749. // `initial`
  2750. function getClippingParents(element) {
  2751. var clippingParents = listScrollParents(getParentNode(element));
  2752. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  2753. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  2754. if (!isElement(clipperElement)) {
  2755. return [];
  2756. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  2757. return clippingParents.filter(function (clippingParent) {
  2758. return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  2759. });
  2760. } // Gets the maximum area that the element is visible in due to any number of
  2761. // clipping parents
  2762. function getClippingRect(element, boundary, rootBoundary, strategy) {
  2763. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  2764. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  2765. var firstClippingParent = clippingParents[0];
  2766. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  2767. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  2768. accRect.top = max(rect.top, accRect.top);
  2769. accRect.right = min(rect.right, accRect.right);
  2770. accRect.bottom = min(rect.bottom, accRect.bottom);
  2771. accRect.left = max(rect.left, accRect.left);
  2772. return accRect;
  2773. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  2774. clippingRect.width = clippingRect.right - clippingRect.left;
  2775. clippingRect.height = clippingRect.bottom - clippingRect.top;
  2776. clippingRect.x = clippingRect.left;
  2777. clippingRect.y = clippingRect.top;
  2778. return clippingRect;
  2779. }
  2780. function computeOffsets(_ref) {
  2781. var reference = _ref.reference,
  2782. element = _ref.element,
  2783. placement = _ref.placement;
  2784. var basePlacement = placement ? getBasePlacement(placement) : null;
  2785. var variation = placement ? getVariation(placement) : null;
  2786. var commonX = reference.x + reference.width / 2 - element.width / 2;
  2787. var commonY = reference.y + reference.height / 2 - element.height / 2;
  2788. var offsets;
  2789. switch (basePlacement) {
  2790. case top:
  2791. offsets = {
  2792. x: commonX,
  2793. y: reference.y - element.height
  2794. };
  2795. break;
  2796. case bottom:
  2797. offsets = {
  2798. x: commonX,
  2799. y: reference.y + reference.height
  2800. };
  2801. break;
  2802. case right:
  2803. offsets = {
  2804. x: reference.x + reference.width,
  2805. y: commonY
  2806. };
  2807. break;
  2808. case left:
  2809. offsets = {
  2810. x: reference.x - element.width,
  2811. y: commonY
  2812. };
  2813. break;
  2814. default:
  2815. offsets = {
  2816. x: reference.x,
  2817. y: reference.y
  2818. };
  2819. }
  2820. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  2821. if (mainAxis != null) {
  2822. var len = mainAxis === 'y' ? 'height' : 'width';
  2823. switch (variation) {
  2824. case start:
  2825. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  2826. break;
  2827. case end:
  2828. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  2829. break;
  2830. }
  2831. }
  2832. return offsets;
  2833. }
  2834. function detectOverflow(state, options) {
  2835. if (options === void 0) {
  2836. options = {};
  2837. }
  2838. var _options = options,
  2839. _options$placement = _options.placement,
  2840. placement = _options$placement === void 0 ? state.placement : _options$placement,
  2841. _options$strategy = _options.strategy,
  2842. strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
  2843. _options$boundary = _options.boundary,
  2844. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  2845. _options$rootBoundary = _options.rootBoundary,
  2846. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  2847. _options$elementConte = _options.elementContext,
  2848. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  2849. _options$altBoundary = _options.altBoundary,
  2850. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  2851. _options$padding = _options.padding,
  2852. padding = _options$padding === void 0 ? 0 : _options$padding;
  2853. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2854. var altContext = elementContext === popper ? reference : popper;
  2855. var popperRect = state.rects.popper;
  2856. var element = state.elements[altBoundary ? altContext : elementContext];
  2857. var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  2858. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  2859. var popperOffsets = computeOffsets({
  2860. reference: referenceClientRect,
  2861. element: popperRect,
  2862. strategy: 'absolute',
  2863. placement: placement
  2864. });
  2865. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  2866. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
  2867. // 0 or negative = within the clipping rect
  2868. var overflowOffsets = {
  2869. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  2870. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  2871. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  2872. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  2873. };
  2874. var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
  2875. if (elementContext === popper && offsetData) {
  2876. var offset = offsetData[placement];
  2877. Object.keys(overflowOffsets).forEach(function (key) {
  2878. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  2879. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  2880. overflowOffsets[key] += offset[axis] * multiply;
  2881. });
  2882. }
  2883. return overflowOffsets;
  2884. }
  2885. function computeAutoPlacement(state, options) {
  2886. if (options === void 0) {
  2887. options = {};
  2888. }
  2889. var _options = options,
  2890. placement = _options.placement,
  2891. boundary = _options.boundary,
  2892. rootBoundary = _options.rootBoundary,
  2893. padding = _options.padding,
  2894. flipVariations = _options.flipVariations,
  2895. _options$allowedAutoP = _options.allowedAutoPlacements,
  2896. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  2897. var variation = getVariation(placement);
  2898. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  2899. return getVariation(placement) === variation;
  2900. }) : basePlacements;
  2901. var allowedPlacements = placements$1.filter(function (placement) {
  2902. return allowedAutoPlacements.indexOf(placement) >= 0;
  2903. });
  2904. if (allowedPlacements.length === 0) {
  2905. allowedPlacements = placements$1;
  2906. } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
  2907. var overflows = allowedPlacements.reduce(function (acc, placement) {
  2908. acc[placement] = detectOverflow(state, {
  2909. placement: placement,
  2910. boundary: boundary,
  2911. rootBoundary: rootBoundary,
  2912. padding: padding
  2913. })[getBasePlacement(placement)];
  2914. return acc;
  2915. }, {});
  2916. return Object.keys(overflows).sort(function (a, b) {
  2917. return overflows[a] - overflows[b];
  2918. });
  2919. }
  2920. function getExpandedFallbackPlacements(placement) {
  2921. if (getBasePlacement(placement) === auto) {
  2922. return [];
  2923. }
  2924. var oppositePlacement = getOppositePlacement(placement);
  2925. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  2926. }
  2927. function flip(_ref) {
  2928. var state = _ref.state,
  2929. options = _ref.options,
  2930. name = _ref.name;
  2931. if (state.modifiersData[name]._skip) {
  2932. return;
  2933. }
  2934. var _options$mainAxis = options.mainAxis,
  2935. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  2936. _options$altAxis = options.altAxis,
  2937. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  2938. specifiedFallbackPlacements = options.fallbackPlacements,
  2939. padding = options.padding,
  2940. boundary = options.boundary,
  2941. rootBoundary = options.rootBoundary,
  2942. altBoundary = options.altBoundary,
  2943. _options$flipVariatio = options.flipVariations,
  2944. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  2945. allowedAutoPlacements = options.allowedAutoPlacements;
  2946. var preferredPlacement = state.options.placement;
  2947. var basePlacement = getBasePlacement(preferredPlacement);
  2948. var isBasePlacement = basePlacement === preferredPlacement;
  2949. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  2950. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  2951. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  2952. placement: placement,
  2953. boundary: boundary,
  2954. rootBoundary: rootBoundary,
  2955. padding: padding,
  2956. flipVariations: flipVariations,
  2957. allowedAutoPlacements: allowedAutoPlacements
  2958. }) : placement);
  2959. }, []);
  2960. var referenceRect = state.rects.reference;
  2961. var popperRect = state.rects.popper;
  2962. var checksMap = new Map();
  2963. var makeFallbackChecks = true;
  2964. var firstFittingPlacement = placements[0];
  2965. for (var i = 0; i < placements.length; i++) {
  2966. var placement = placements[i];
  2967. var _basePlacement = getBasePlacement(placement);
  2968. var isStartVariation = getVariation(placement) === start;
  2969. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  2970. var len = isVertical ? 'width' : 'height';
  2971. var overflow = detectOverflow(state, {
  2972. placement: placement,
  2973. boundary: boundary,
  2974. rootBoundary: rootBoundary,
  2975. altBoundary: altBoundary,
  2976. padding: padding
  2977. });
  2978. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  2979. if (referenceRect[len] > popperRect[len]) {
  2980. mainVariationSide = getOppositePlacement(mainVariationSide);
  2981. }
  2982. var altVariationSide = getOppositePlacement(mainVariationSide);
  2983. var checks = [];
  2984. if (checkMainAxis) {
  2985. checks.push(overflow[_basePlacement] <= 0);
  2986. }
  2987. if (checkAltAxis) {
  2988. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  2989. }
  2990. if (checks.every(function (check) {
  2991. return check;
  2992. })) {
  2993. firstFittingPlacement = placement;
  2994. makeFallbackChecks = false;
  2995. break;
  2996. }
  2997. checksMap.set(placement, checks);
  2998. }
  2999. if (makeFallbackChecks) {
  3000. // `2` may be desired in some cases – research later
  3001. var numberOfChecks = flipVariations ? 3 : 1;
  3002. var _loop = function _loop(_i) {
  3003. var fittingPlacement = placements.find(function (placement) {
  3004. var checks = checksMap.get(placement);
  3005. if (checks) {
  3006. return checks.slice(0, _i).every(function (check) {
  3007. return check;
  3008. });
  3009. }
  3010. });
  3011. if (fittingPlacement) {
  3012. firstFittingPlacement = fittingPlacement;
  3013. return "break";
  3014. }
  3015. };
  3016. for (var _i = numberOfChecks; _i > 0; _i--) {
  3017. var _ret = _loop(_i);
  3018. if (_ret === "break") break;
  3019. }
  3020. }
  3021. if (state.placement !== firstFittingPlacement) {
  3022. state.modifiersData[name]._skip = true;
  3023. state.placement = firstFittingPlacement;
  3024. state.reset = true;
  3025. }
  3026. } // eslint-disable-next-line import/no-unused-modules
  3027. const flip$1 = {
  3028. name: 'flip',
  3029. enabled: true,
  3030. phase: 'main',
  3031. fn: flip,
  3032. requiresIfExists: ['offset'],
  3033. data: {
  3034. _skip: false
  3035. }
  3036. };
  3037. function getSideOffsets(overflow, rect, preventedOffsets) {
  3038. if (preventedOffsets === void 0) {
  3039. preventedOffsets = {
  3040. x: 0,
  3041. y: 0
  3042. };
  3043. }
  3044. return {
  3045. top: overflow.top - rect.height - preventedOffsets.y,
  3046. right: overflow.right - rect.width + preventedOffsets.x,
  3047. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  3048. left: overflow.left - rect.width - preventedOffsets.x
  3049. };
  3050. }
  3051. function isAnySideFullyClipped(overflow) {
  3052. return [top, right, bottom, left].some(function (side) {
  3053. return overflow[side] >= 0;
  3054. });
  3055. }
  3056. function hide(_ref) {
  3057. var state = _ref.state,
  3058. name = _ref.name;
  3059. var referenceRect = state.rects.reference;
  3060. var popperRect = state.rects.popper;
  3061. var preventedOffsets = state.modifiersData.preventOverflow;
  3062. var referenceOverflow = detectOverflow(state, {
  3063. elementContext: 'reference'
  3064. });
  3065. var popperAltOverflow = detectOverflow(state, {
  3066. altBoundary: true
  3067. });
  3068. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  3069. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  3070. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  3071. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  3072. state.modifiersData[name] = {
  3073. referenceClippingOffsets: referenceClippingOffsets,
  3074. popperEscapeOffsets: popperEscapeOffsets,
  3075. isReferenceHidden: isReferenceHidden,
  3076. hasPopperEscaped: hasPopperEscaped
  3077. };
  3078. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  3079. 'data-popper-reference-hidden': isReferenceHidden,
  3080. 'data-popper-escaped': hasPopperEscaped
  3081. });
  3082. } // eslint-disable-next-line import/no-unused-modules
  3083. const hide$1 = {
  3084. name: 'hide',
  3085. enabled: true,
  3086. phase: 'main',
  3087. requiresIfExists: ['preventOverflow'],
  3088. fn: hide
  3089. };
  3090. function distanceAndSkiddingToXY(placement, rects, offset) {
  3091. var basePlacement = getBasePlacement(placement);
  3092. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  3093. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  3094. placement: placement
  3095. })) : offset,
  3096. skidding = _ref[0],
  3097. distance = _ref[1];
  3098. skidding = skidding || 0;
  3099. distance = (distance || 0) * invertDistance;
  3100. return [left, right].indexOf(basePlacement) >= 0 ? {
  3101. x: distance,
  3102. y: skidding
  3103. } : {
  3104. x: skidding,
  3105. y: distance
  3106. };
  3107. }
  3108. function offset(_ref2) {
  3109. var state = _ref2.state,
  3110. options = _ref2.options,
  3111. name = _ref2.name;
  3112. var _options$offset = options.offset,
  3113. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  3114. var data = placements.reduce(function (acc, placement) {
  3115. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  3116. return acc;
  3117. }, {});
  3118. var _data$state$placement = data[state.placement],
  3119. x = _data$state$placement.x,
  3120. y = _data$state$placement.y;
  3121. if (state.modifiersData.popperOffsets != null) {
  3122. state.modifiersData.popperOffsets.x += x;
  3123. state.modifiersData.popperOffsets.y += y;
  3124. }
  3125. state.modifiersData[name] = data;
  3126. } // eslint-disable-next-line import/no-unused-modules
  3127. const offset$1 = {
  3128. name: 'offset',
  3129. enabled: true,
  3130. phase: 'main',
  3131. requires: ['popperOffsets'],
  3132. fn: offset
  3133. };
  3134. function popperOffsets(_ref) {
  3135. var state = _ref.state,
  3136. name = _ref.name;
  3137. // Offsets are the actual position the popper needs to have to be
  3138. // properly positioned near its reference element
  3139. // This is the most basic placement, and will be adjusted by
  3140. // the modifiers in the next step
  3141. state.modifiersData[name] = computeOffsets({
  3142. reference: state.rects.reference,
  3143. element: state.rects.popper,
  3144. strategy: 'absolute',
  3145. placement: state.placement
  3146. });
  3147. } // eslint-disable-next-line import/no-unused-modules
  3148. const popperOffsets$1 = {
  3149. name: 'popperOffsets',
  3150. enabled: true,
  3151. phase: 'read',
  3152. fn: popperOffsets,
  3153. data: {}
  3154. };
  3155. function getAltAxis(axis) {
  3156. return axis === 'x' ? 'y' : 'x';
  3157. }
  3158. function preventOverflow(_ref) {
  3159. var state = _ref.state,
  3160. options = _ref.options,
  3161. name = _ref.name;
  3162. var _options$mainAxis = options.mainAxis,
  3163. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  3164. _options$altAxis = options.altAxis,
  3165. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  3166. boundary = options.boundary,
  3167. rootBoundary = options.rootBoundary,
  3168. altBoundary = options.altBoundary,
  3169. padding = options.padding,
  3170. _options$tether = options.tether,
  3171. tether = _options$tether === void 0 ? true : _options$tether,
  3172. _options$tetherOffset = options.tetherOffset,
  3173. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  3174. var overflow = detectOverflow(state, {
  3175. boundary: boundary,
  3176. rootBoundary: rootBoundary,
  3177. padding: padding,
  3178. altBoundary: altBoundary
  3179. });
  3180. var basePlacement = getBasePlacement(state.placement);
  3181. var variation = getVariation(state.placement);
  3182. var isBasePlacement = !variation;
  3183. var mainAxis = getMainAxisFromPlacement(basePlacement);
  3184. var altAxis = getAltAxis(mainAxis);
  3185. var popperOffsets = state.modifiersData.popperOffsets;
  3186. var referenceRect = state.rects.reference;
  3187. var popperRect = state.rects.popper;
  3188. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  3189. placement: state.placement
  3190. })) : tetherOffset;
  3191. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  3192. mainAxis: tetherOffsetValue,
  3193. altAxis: tetherOffsetValue
  3194. } : Object.assign({
  3195. mainAxis: 0,
  3196. altAxis: 0
  3197. }, tetherOffsetValue);
  3198. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  3199. var data = {
  3200. x: 0,
  3201. y: 0
  3202. };
  3203. if (!popperOffsets) {
  3204. return;
  3205. }
  3206. if (checkMainAxis) {
  3207. var _offsetModifierState$;
  3208. var mainSide = mainAxis === 'y' ? top : left;
  3209. var altSide = mainAxis === 'y' ? bottom : right;
  3210. var len = mainAxis === 'y' ? 'height' : 'width';
  3211. var offset = popperOffsets[mainAxis];
  3212. var min$1 = offset + overflow[mainSide];
  3213. var max$1 = offset - overflow[altSide];
  3214. var additive = tether ? -popperRect[len] / 2 : 0;
  3215. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  3216. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  3217. // outside the reference bounds
  3218. var arrowElement = state.elements.arrow;
  3219. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  3220. width: 0,
  3221. height: 0
  3222. };
  3223. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  3224. var arrowPaddingMin = arrowPaddingObject[mainSide];
  3225. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  3226. // to include its full size in the calculation. If the reference is small
  3227. // and near the edge of a boundary, the popper can overflow even if the
  3228. // reference is not overflowing as well (e.g. virtual elements with no
  3229. // width or height)
  3230. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  3231. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  3232. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  3233. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  3234. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  3235. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  3236. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  3237. var tetherMax = offset + maxOffset - offsetModifierValue;
  3238. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  3239. popperOffsets[mainAxis] = preventedOffset;
  3240. data[mainAxis] = preventedOffset - offset;
  3241. }
  3242. if (checkAltAxis) {
  3243. var _offsetModifierState$2;
  3244. var _mainSide = mainAxis === 'x' ? top : left;
  3245. var _altSide = mainAxis === 'x' ? bottom : right;
  3246. var _offset = popperOffsets[altAxis];
  3247. var _len = altAxis === 'y' ? 'height' : 'width';
  3248. var _min = _offset + overflow[_mainSide];
  3249. var _max = _offset - overflow[_altSide];
  3250. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  3251. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  3252. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  3253. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  3254. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  3255. popperOffsets[altAxis] = _preventedOffset;
  3256. data[altAxis] = _preventedOffset - _offset;
  3257. }
  3258. state.modifiersData[name] = data;
  3259. } // eslint-disable-next-line import/no-unused-modules
  3260. const preventOverflow$1 = {
  3261. name: 'preventOverflow',
  3262. enabled: true,
  3263. phase: 'main',
  3264. fn: preventOverflow,
  3265. requiresIfExists: ['offset']
  3266. };
  3267. function getHTMLElementScroll(element) {
  3268. return {
  3269. scrollLeft: element.scrollLeft,
  3270. scrollTop: element.scrollTop
  3271. };
  3272. }
  3273. function getNodeScroll(node) {
  3274. if (node === getWindow(node) || !isHTMLElement(node)) {
  3275. return getWindowScroll(node);
  3276. } else {
  3277. return getHTMLElementScroll(node);
  3278. }
  3279. }
  3280. function isElementScaled(element) {
  3281. var rect = element.getBoundingClientRect();
  3282. var scaleX = round(rect.width) / element.offsetWidth || 1;
  3283. var scaleY = round(rect.height) / element.offsetHeight || 1;
  3284. return scaleX !== 1 || scaleY !== 1;
  3285. } // Returns the composite rect of an element relative to its offsetParent.
  3286. // Composite means it takes into account transforms as well as layout.
  3287. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  3288. if (isFixed === void 0) {
  3289. isFixed = false;
  3290. }
  3291. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  3292. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  3293. var documentElement = getDocumentElement(offsetParent);
  3294. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  3295. var scroll = {
  3296. scrollLeft: 0,
  3297. scrollTop: 0
  3298. };
  3299. var offsets = {
  3300. x: 0,
  3301. y: 0
  3302. };
  3303. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  3304. if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  3305. isScrollParent(documentElement)) {
  3306. scroll = getNodeScroll(offsetParent);
  3307. }
  3308. if (isHTMLElement(offsetParent)) {
  3309. offsets = getBoundingClientRect(offsetParent, true);
  3310. offsets.x += offsetParent.clientLeft;
  3311. offsets.y += offsetParent.clientTop;
  3312. } else if (documentElement) {
  3313. offsets.x = getWindowScrollBarX(documentElement);
  3314. }
  3315. }
  3316. return {
  3317. x: rect.left + scroll.scrollLeft - offsets.x,
  3318. y: rect.top + scroll.scrollTop - offsets.y,
  3319. width: rect.width,
  3320. height: rect.height
  3321. };
  3322. }
  3323. function order(modifiers) {
  3324. var map = new Map();
  3325. var visited = new Set();
  3326. var result = [];
  3327. modifiers.forEach(function (modifier) {
  3328. map.set(modifier.name, modifier);
  3329. }); // On visiting object, check for its dependencies and visit them recursively
  3330. function sort(modifier) {
  3331. visited.add(modifier.name);
  3332. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  3333. requires.forEach(function (dep) {
  3334. if (!visited.has(dep)) {
  3335. var depModifier = map.get(dep);
  3336. if (depModifier) {
  3337. sort(depModifier);
  3338. }
  3339. }
  3340. });
  3341. result.push(modifier);
  3342. }
  3343. modifiers.forEach(function (modifier) {
  3344. if (!visited.has(modifier.name)) {
  3345. // check for visited object
  3346. sort(modifier);
  3347. }
  3348. });
  3349. return result;
  3350. }
  3351. function orderModifiers(modifiers) {
  3352. // order based on dependencies
  3353. var orderedModifiers = order(modifiers); // order based on phase
  3354. return modifierPhases.reduce(function (acc, phase) {
  3355. return acc.concat(orderedModifiers.filter(function (modifier) {
  3356. return modifier.phase === phase;
  3357. }));
  3358. }, []);
  3359. }
  3360. function debounce(fn) {
  3361. var pending;
  3362. return function () {
  3363. if (!pending) {
  3364. pending = new Promise(function (resolve) {
  3365. Promise.resolve().then(function () {
  3366. pending = undefined;
  3367. resolve(fn());
  3368. });
  3369. });
  3370. }
  3371. return pending;
  3372. };
  3373. }
  3374. function mergeByName(modifiers) {
  3375. var merged = modifiers.reduce(function (merged, current) {
  3376. var existing = merged[current.name];
  3377. merged[current.name] = existing ? Object.assign({}, existing, current, {
  3378. options: Object.assign({}, existing.options, current.options),
  3379. data: Object.assign({}, existing.data, current.data)
  3380. }) : current;
  3381. return merged;
  3382. }, {}); // IE11 does not support Object.values
  3383. return Object.keys(merged).map(function (key) {
  3384. return merged[key];
  3385. });
  3386. }
  3387. var DEFAULT_OPTIONS = {
  3388. placement: 'bottom',
  3389. modifiers: [],
  3390. strategy: 'absolute'
  3391. };
  3392. function areValidElements() {
  3393. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3394. args[_key] = arguments[_key];
  3395. }
  3396. return !args.some(function (element) {
  3397. return !(element && typeof element.getBoundingClientRect === 'function');
  3398. });
  3399. }
  3400. function popperGenerator(generatorOptions) {
  3401. if (generatorOptions === void 0) {
  3402. generatorOptions = {};
  3403. }
  3404. var _generatorOptions = generatorOptions,
  3405. _generatorOptions$def = _generatorOptions.defaultModifiers,
  3406. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  3407. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  3408. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  3409. return function createPopper(reference, popper, options) {
  3410. if (options === void 0) {
  3411. options = defaultOptions;
  3412. }
  3413. var state = {
  3414. placement: 'bottom',
  3415. orderedModifiers: [],
  3416. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  3417. modifiersData: {},
  3418. elements: {
  3419. reference: reference,
  3420. popper: popper
  3421. },
  3422. attributes: {},
  3423. styles: {}
  3424. };
  3425. var effectCleanupFns = [];
  3426. var isDestroyed = false;
  3427. var instance = {
  3428. state: state,
  3429. setOptions: function setOptions(setOptionsAction) {
  3430. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  3431. cleanupModifierEffects();
  3432. state.options = Object.assign({}, defaultOptions, state.options, options);
  3433. state.scrollParents = {
  3434. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  3435. popper: listScrollParents(popper)
  3436. }; // Orders the modifiers based on their dependencies and `phase`
  3437. // properties
  3438. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  3439. state.orderedModifiers = orderedModifiers.filter(function (m) {
  3440. return m.enabled;
  3441. });
  3442. runModifierEffects();
  3443. return instance.update();
  3444. },
  3445. // Sync update – it will always be executed, even if not necessary. This
  3446. // is useful for low frequency updates where sync behavior simplifies the
  3447. // logic.
  3448. // For high frequency updates (e.g. `resize` and `scroll` events), always
  3449. // prefer the async Popper#update method
  3450. forceUpdate: function forceUpdate() {
  3451. if (isDestroyed) {
  3452. return;
  3453. }
  3454. var _state$elements = state.elements,
  3455. reference = _state$elements.reference,
  3456. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  3457. // anymore
  3458. if (!areValidElements(reference, popper)) {
  3459. return;
  3460. } // Store the reference and popper rects to be read by modifiers
  3461. state.rects = {
  3462. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  3463. popper: getLayoutRect(popper)
  3464. }; // Modifiers have the ability to reset the current update cycle. The
  3465. // most common use case for this is the `flip` modifier changing the
  3466. // placement, which then needs to re-run all the modifiers, because the
  3467. // logic was previously ran for the previous placement and is therefore
  3468. // stale/incorrect
  3469. state.reset = false;
  3470. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  3471. // is filled with the initial data specified by the modifier. This means
  3472. // it doesn't persist and is fresh on each update.
  3473. // To ensure persistent data, use `${name}#persistent`
  3474. state.orderedModifiers.forEach(function (modifier) {
  3475. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  3476. });
  3477. for (var index = 0; index < state.orderedModifiers.length; index++) {
  3478. if (state.reset === true) {
  3479. state.reset = false;
  3480. index = -1;
  3481. continue;
  3482. }
  3483. var _state$orderedModifie = state.orderedModifiers[index],
  3484. fn = _state$orderedModifie.fn,
  3485. _state$orderedModifie2 = _state$orderedModifie.options,
  3486. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  3487. name = _state$orderedModifie.name;
  3488. if (typeof fn === 'function') {
  3489. state = fn({
  3490. state: state,
  3491. options: _options,
  3492. name: name,
  3493. instance: instance
  3494. }) || state;
  3495. }
  3496. }
  3497. },
  3498. // Async and optimistically optimized update – it will not be executed if
  3499. // not necessary (debounced to run at most once-per-tick)
  3500. update: debounce(function () {
  3501. return new Promise(function (resolve) {
  3502. instance.forceUpdate();
  3503. resolve(state);
  3504. });
  3505. }),
  3506. destroy: function destroy() {
  3507. cleanupModifierEffects();
  3508. isDestroyed = true;
  3509. }
  3510. };
  3511. if (!areValidElements(reference, popper)) {
  3512. return instance;
  3513. }
  3514. instance.setOptions(options).then(function (state) {
  3515. if (!isDestroyed && options.onFirstUpdate) {
  3516. options.onFirstUpdate(state);
  3517. }
  3518. }); // Modifiers have the ability to execute arbitrary code before the first
  3519. // update cycle runs. They will be executed in the same order as the update
  3520. // cycle. This is useful when a modifier adds some persistent data that
  3521. // other modifiers need to use, but the modifier is run after the dependent
  3522. // one.
  3523. function runModifierEffects() {
  3524. state.orderedModifiers.forEach(function (_ref) {
  3525. var name = _ref.name,
  3526. _ref$options = _ref.options,
  3527. options = _ref$options === void 0 ? {} : _ref$options,
  3528. effect = _ref.effect;
  3529. if (typeof effect === 'function') {
  3530. var cleanupFn = effect({
  3531. state: state,
  3532. name: name,
  3533. instance: instance,
  3534. options: options
  3535. });
  3536. var noopFn = function noopFn() {};
  3537. effectCleanupFns.push(cleanupFn || noopFn);
  3538. }
  3539. });
  3540. }
  3541. function cleanupModifierEffects() {
  3542. effectCleanupFns.forEach(function (fn) {
  3543. return fn();
  3544. });
  3545. effectCleanupFns = [];
  3546. }
  3547. return instance;
  3548. };
  3549. }
  3550. var createPopper$2 = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules
  3551. var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
  3552. var createPopper$1 = /*#__PURE__*/popperGenerator({
  3553. defaultModifiers: defaultModifiers$1
  3554. }); // eslint-disable-next-line import/no-unused-modules
  3555. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  3556. var createPopper = /*#__PURE__*/popperGenerator({
  3557. defaultModifiers: defaultModifiers
  3558. }); // eslint-disable-next-line import/no-unused-modules
  3559. const Popper = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  3560. __proto__: null,
  3561. afterMain,
  3562. afterRead,
  3563. afterWrite,
  3564. applyStyles: applyStyles$1,
  3565. arrow: arrow$1,
  3566. auto,
  3567. basePlacements,
  3568. beforeMain,
  3569. beforeRead,
  3570. beforeWrite,
  3571. bottom,
  3572. clippingParents,
  3573. computeStyles: computeStyles$1,
  3574. createPopper,
  3575. createPopperBase: createPopper$2,
  3576. createPopperLite: createPopper$1,
  3577. detectOverflow,
  3578. end,
  3579. eventListeners,
  3580. flip: flip$1,
  3581. hide: hide$1,
  3582. left,
  3583. main,
  3584. modifierPhases,
  3585. offset: offset$1,
  3586. placements,
  3587. popper,
  3588. popperGenerator,
  3589. popperOffsets: popperOffsets$1,
  3590. preventOverflow: preventOverflow$1,
  3591. read,
  3592. reference,
  3593. right,
  3594. start,
  3595. top,
  3596. variationPlacements,
  3597. viewport,
  3598. write
  3599. }, Symbol.toStringTag, { value: 'Module' }));
  3600. /**
  3601. * --------------------------------------------------------------------------
  3602. * Bootstrap dropdown.js
  3603. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3604. * --------------------------------------------------------------------------
  3605. */
  3606. /**
  3607. * Constants
  3608. */
  3609. const NAME$a = 'dropdown';
  3610. const DATA_KEY$6 = 'bs.dropdown';
  3611. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  3612. const DATA_API_KEY$3 = '.data-api';
  3613. const ESCAPE_KEY$2 = 'Escape';
  3614. const TAB_KEY$1 = 'Tab';
  3615. const ARROW_UP_KEY$1 = 'ArrowUp';
  3616. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  3617. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  3618. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  3619. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  3620. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  3621. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  3622. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3623. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3624. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3625. const CLASS_NAME_SHOW$6 = 'show';
  3626. const CLASS_NAME_DROPUP = 'dropup';
  3627. const CLASS_NAME_DROPEND = 'dropend';
  3628. const CLASS_NAME_DROPSTART = 'dropstart';
  3629. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  3630. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  3631. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  3632. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  3633. const SELECTOR_MENU = '.dropdown-menu';
  3634. const SELECTOR_NAVBAR = '.navbar';
  3635. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  3636. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  3637. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  3638. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  3639. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  3640. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  3641. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  3642. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  3643. const PLACEMENT_TOPCENTER = 'top';
  3644. const PLACEMENT_BOTTOMCENTER = 'bottom';
  3645. const Default$9 = {
  3646. autoClose: true,
  3647. boundary: 'clippingParents',
  3648. display: 'dynamic',
  3649. offset: [0, 2],
  3650. popperConfig: null,
  3651. reference: 'toggle'
  3652. };
  3653. const DefaultType$9 = {
  3654. autoClose: '(boolean|string)',
  3655. boundary: '(string|element)',
  3656. display: 'string',
  3657. offset: '(array|string|function)',
  3658. popperConfig: '(null|object|function)',
  3659. reference: '(string|element|object)'
  3660. };
  3661. /**
  3662. * Class definition
  3663. */
  3664. class Dropdown extends BaseComponent {
  3665. constructor(element, config) {
  3666. super(element, config);
  3667. this._popper = null;
  3668. this._parent = this._element.parentNode; // dropdown wrapper
  3669. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  3670. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  3671. this._inNavbar = this._detectNavbar();
  3672. }
  3673. // Getters
  3674. static get Default() {
  3675. return Default$9;
  3676. }
  3677. static get DefaultType() {
  3678. return DefaultType$9;
  3679. }
  3680. static get NAME() {
  3681. return NAME$a;
  3682. }
  3683. // Public
  3684. toggle() {
  3685. return this._isShown() ? this.hide() : this.show();
  3686. }
  3687. show() {
  3688. if (isDisabled(this._element) || this._isShown()) {
  3689. return;
  3690. }
  3691. const relatedTarget = {
  3692. relatedTarget: this._element
  3693. };
  3694. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  3695. if (showEvent.defaultPrevented) {
  3696. return;
  3697. }
  3698. this._createPopper();
  3699. // If this is a touch-enabled device we add extra
  3700. // empty mouseover listeners to the body's immediate children;
  3701. // only needed because of broken event delegation on iOS
  3702. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3703. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  3704. for (const element of [].concat(...document.body.children)) {
  3705. EventHandler.on(element, 'mouseover', noop);
  3706. }
  3707. }
  3708. this._element.focus();
  3709. this._element.setAttribute('aria-expanded', true);
  3710. this._menu.classList.add(CLASS_NAME_SHOW$6);
  3711. this._element.classList.add(CLASS_NAME_SHOW$6);
  3712. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  3713. }
  3714. hide() {
  3715. if (isDisabled(this._element) || !this._isShown()) {
  3716. return;
  3717. }
  3718. const relatedTarget = {
  3719. relatedTarget: this._element
  3720. };
  3721. this._completeHide(relatedTarget);
  3722. }
  3723. dispose() {
  3724. if (this._popper) {
  3725. this._popper.destroy();
  3726. }
  3727. super.dispose();
  3728. }
  3729. update() {
  3730. this._inNavbar = this._detectNavbar();
  3731. if (this._popper) {
  3732. this._popper.update();
  3733. }
  3734. }
  3735. // Private
  3736. _completeHide(relatedTarget) {
  3737. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  3738. if (hideEvent.defaultPrevented) {
  3739. return;
  3740. }
  3741. // If this is a touch-enabled device we remove the extra
  3742. // empty mouseover listeners we added for iOS support
  3743. if ('ontouchstart' in document.documentElement) {
  3744. for (const element of [].concat(...document.body.children)) {
  3745. EventHandler.off(element, 'mouseover', noop);
  3746. }
  3747. }
  3748. if (this._popper) {
  3749. this._popper.destroy();
  3750. }
  3751. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  3752. this._element.classList.remove(CLASS_NAME_SHOW$6);
  3753. this._element.setAttribute('aria-expanded', 'false');
  3754. Manipulator.removeDataAttribute(this._menu, 'popper');
  3755. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  3756. }
  3757. _getConfig(config) {
  3758. config = super._getConfig(config);
  3759. if (typeof config.reference === 'object' && !isElement$1(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  3760. // Popper virtual elements require a getBoundingClientRect method
  3761. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  3762. }
  3763. return config;
  3764. }
  3765. _createPopper() {
  3766. if (typeof Popper === 'undefined') {
  3767. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  3768. }
  3769. let referenceElement = this._element;
  3770. if (this._config.reference === 'parent') {
  3771. referenceElement = this._parent;
  3772. } else if (isElement$1(this._config.reference)) {
  3773. referenceElement = getElement(this._config.reference);
  3774. } else if (typeof this._config.reference === 'object') {
  3775. referenceElement = this._config.reference;
  3776. }
  3777. const popperConfig = this._getPopperConfig();
  3778. this._popper = createPopper(referenceElement, this._menu, popperConfig);
  3779. }
  3780. _isShown() {
  3781. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  3782. }
  3783. _getPlacement() {
  3784. const parentDropdown = this._parent;
  3785. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  3786. return PLACEMENT_RIGHT;
  3787. }
  3788. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  3789. return PLACEMENT_LEFT;
  3790. }
  3791. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  3792. return PLACEMENT_TOPCENTER;
  3793. }
  3794. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  3795. return PLACEMENT_BOTTOMCENTER;
  3796. }
  3797. // We need to trim the value because custom properties can also include spaces
  3798. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  3799. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  3800. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  3801. }
  3802. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  3803. }
  3804. _detectNavbar() {
  3805. return this._element.closest(SELECTOR_NAVBAR) !== null;
  3806. }
  3807. _getOffset() {
  3808. const {
  3809. offset
  3810. } = this._config;
  3811. if (typeof offset === 'string') {
  3812. return offset.split(',').map(value => Number.parseInt(value, 10));
  3813. }
  3814. if (typeof offset === 'function') {
  3815. return popperData => offset(popperData, this._element);
  3816. }
  3817. return offset;
  3818. }
  3819. _getPopperConfig() {
  3820. const defaultBsPopperConfig = {
  3821. placement: this._getPlacement(),
  3822. modifiers: [{
  3823. name: 'preventOverflow',
  3824. options: {
  3825. boundary: this._config.boundary
  3826. }
  3827. }, {
  3828. name: 'offset',
  3829. options: {
  3830. offset: this._getOffset()
  3831. }
  3832. }]
  3833. };
  3834. // Disable Popper if we have a static display or Dropdown is in Navbar
  3835. if (this._inNavbar || this._config.display === 'static') {
  3836. Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // TODO: v6 remove
  3837. defaultBsPopperConfig.modifiers = [{
  3838. name: 'applyStyles',
  3839. enabled: false
  3840. }];
  3841. }
  3842. return {
  3843. ...defaultBsPopperConfig,
  3844. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  3845. };
  3846. }
  3847. _selectMenuItem({
  3848. key,
  3849. target
  3850. }) {
  3851. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  3852. if (!items.length) {
  3853. return;
  3854. }
  3855. // if target isn't included in items (e.g. when expanding the dropdown)
  3856. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  3857. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  3858. }
  3859. // Static
  3860. static jQueryInterface(config) {
  3861. return this.each(function () {
  3862. const data = Dropdown.getOrCreateInstance(this, config);
  3863. if (typeof config !== 'string') {
  3864. return;
  3865. }
  3866. if (typeof data[config] === 'undefined') {
  3867. throw new TypeError(`No method named "${config}"`);
  3868. }
  3869. data[config]();
  3870. });
  3871. }
  3872. static clearMenus(event) {
  3873. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  3874. return;
  3875. }
  3876. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  3877. for (const toggle of openToggles) {
  3878. const context = Dropdown.getInstance(toggle);
  3879. if (!context || context._config.autoClose === false) {
  3880. continue;
  3881. }
  3882. const composedPath = event.composedPath();
  3883. const isMenuTarget = composedPath.includes(context._menu);
  3884. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  3885. continue;
  3886. }
  3887. // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  3888. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  3889. continue;
  3890. }
  3891. const relatedTarget = {
  3892. relatedTarget: context._element
  3893. };
  3894. if (event.type === 'click') {
  3895. relatedTarget.clickEvent = event;
  3896. }
  3897. context._completeHide(relatedTarget);
  3898. }
  3899. }
  3900. static dataApiKeydownHandler(event) {
  3901. // If not an UP | DOWN | ESCAPE key => not a dropdown command
  3902. // If input/textarea && if key is other than ESCAPE => not a dropdown command
  3903. const isInput = /input|textarea/i.test(event.target.tagName);
  3904. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  3905. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  3906. if (!isUpOrDownEvent && !isEscapeEvent) {
  3907. return;
  3908. }
  3909. if (isInput && !isEscapeEvent) {
  3910. return;
  3911. }
  3912. event.preventDefault();
  3913. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  3914. const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3, event.delegateTarget.parentNode);
  3915. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  3916. if (isUpOrDownEvent) {
  3917. event.stopPropagation();
  3918. instance.show();
  3919. instance._selectMenuItem(event);
  3920. return;
  3921. }
  3922. if (instance._isShown()) {
  3923. // else is escape and we check if it is shown
  3924. event.stopPropagation();
  3925. instance.hide();
  3926. getToggleButton.focus();
  3927. }
  3928. }
  3929. }
  3930. /**
  3931. * Data API implementation
  3932. */
  3933. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  3934. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  3935. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  3936. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  3937. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  3938. event.preventDefault();
  3939. Dropdown.getOrCreateInstance(this).toggle();
  3940. });
  3941. /**
  3942. * jQuery
  3943. */
  3944. defineJQueryPlugin(Dropdown);
  3945. /**
  3946. * --------------------------------------------------------------------------
  3947. * Bootstrap util/backdrop.js
  3948. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3949. * --------------------------------------------------------------------------
  3950. */
  3951. /**
  3952. * Constants
  3953. */
  3954. const NAME$9 = 'backdrop';
  3955. const CLASS_NAME_FADE$4 = 'fade';
  3956. const CLASS_NAME_SHOW$5 = 'show';
  3957. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  3958. const Default$8 = {
  3959. className: 'modal-backdrop',
  3960. clickCallback: null,
  3961. isAnimated: false,
  3962. isVisible: true,
  3963. // if false, we use the backdrop helper without adding any element to the dom
  3964. rootElement: 'body' // give the choice to place backdrop under different elements
  3965. };
  3966. const DefaultType$8 = {
  3967. className: 'string',
  3968. clickCallback: '(function|null)',
  3969. isAnimated: 'boolean',
  3970. isVisible: 'boolean',
  3971. rootElement: '(element|string)'
  3972. };
  3973. /**
  3974. * Class definition
  3975. */
  3976. class Backdrop extends Config {
  3977. constructor(config) {
  3978. super();
  3979. this._config = this._getConfig(config);
  3980. this._isAppended = false;
  3981. this._element = null;
  3982. }
  3983. // Getters
  3984. static get Default() {
  3985. return Default$8;
  3986. }
  3987. static get DefaultType() {
  3988. return DefaultType$8;
  3989. }
  3990. static get NAME() {
  3991. return NAME$9;
  3992. }
  3993. // Public
  3994. show(callback) {
  3995. if (!this._config.isVisible) {
  3996. execute(callback);
  3997. return;
  3998. }
  3999. this._append();
  4000. const element = this._getElement();
  4001. if (this._config.isAnimated) {
  4002. reflow(element);
  4003. }
  4004. element.classList.add(CLASS_NAME_SHOW$5);
  4005. this._emulateAnimation(() => {
  4006. execute(callback);
  4007. });
  4008. }
  4009. hide(callback) {
  4010. if (!this._config.isVisible) {
  4011. execute(callback);
  4012. return;
  4013. }
  4014. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  4015. this._emulateAnimation(() => {
  4016. this.dispose();
  4017. execute(callback);
  4018. });
  4019. }
  4020. dispose() {
  4021. if (!this._isAppended) {
  4022. return;
  4023. }
  4024. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  4025. this._element.remove();
  4026. this._isAppended = false;
  4027. }
  4028. // Private
  4029. _getElement() {
  4030. if (!this._element) {
  4031. const backdrop = document.createElement('div');
  4032. backdrop.className = this._config.className;
  4033. if (this._config.isAnimated) {
  4034. backdrop.classList.add(CLASS_NAME_FADE$4);
  4035. }
  4036. this._element = backdrop;
  4037. }
  4038. return this._element;
  4039. }
  4040. _configAfterMerge(config) {
  4041. // use getElement() with the default "body" to get a fresh Element on each instantiation
  4042. config.rootElement = getElement(config.rootElement);
  4043. return config;
  4044. }
  4045. _append() {
  4046. if (this._isAppended) {
  4047. return;
  4048. }
  4049. const element = this._getElement();
  4050. this._config.rootElement.append(element);
  4051. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  4052. execute(this._config.clickCallback);
  4053. });
  4054. this._isAppended = true;
  4055. }
  4056. _emulateAnimation(callback) {
  4057. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  4058. }
  4059. }
  4060. /**
  4061. * --------------------------------------------------------------------------
  4062. * Bootstrap util/focustrap.js
  4063. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4064. * --------------------------------------------------------------------------
  4065. */
  4066. /**
  4067. * Constants
  4068. */
  4069. const NAME$8 = 'focustrap';
  4070. const DATA_KEY$5 = 'bs.focustrap';
  4071. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  4072. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  4073. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  4074. const TAB_KEY = 'Tab';
  4075. const TAB_NAV_FORWARD = 'forward';
  4076. const TAB_NAV_BACKWARD = 'backward';
  4077. const Default$7 = {
  4078. autofocus: true,
  4079. trapElement: null // The element to trap focus inside of
  4080. };
  4081. const DefaultType$7 = {
  4082. autofocus: 'boolean',
  4083. trapElement: 'element'
  4084. };
  4085. /**
  4086. * Class definition
  4087. */
  4088. class FocusTrap extends Config {
  4089. constructor(config) {
  4090. super();
  4091. this._config = this._getConfig(config);
  4092. this._isActive = false;
  4093. this._lastTabNavDirection = null;
  4094. }
  4095. // Getters
  4096. static get Default() {
  4097. return Default$7;
  4098. }
  4099. static get DefaultType() {
  4100. return DefaultType$7;
  4101. }
  4102. static get NAME() {
  4103. return NAME$8;
  4104. }
  4105. // Public
  4106. activate() {
  4107. if (this._isActive) {
  4108. return;
  4109. }
  4110. if (this._config.autofocus) {
  4111. this._config.trapElement.focus();
  4112. }
  4113. EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop
  4114. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  4115. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  4116. this._isActive = true;
  4117. }
  4118. deactivate() {
  4119. if (!this._isActive) {
  4120. return;
  4121. }
  4122. this._isActive = false;
  4123. EventHandler.off(document, EVENT_KEY$5);
  4124. }
  4125. // Private
  4126. _handleFocusin(event) {
  4127. const {
  4128. trapElement
  4129. } = this._config;
  4130. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  4131. return;
  4132. }
  4133. const elements = SelectorEngine.focusableChildren(trapElement);
  4134. if (elements.length === 0) {
  4135. trapElement.focus();
  4136. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  4137. elements[elements.length - 1].focus();
  4138. } else {
  4139. elements[0].focus();
  4140. }
  4141. }
  4142. _handleKeydown(event) {
  4143. if (event.key !== TAB_KEY) {
  4144. return;
  4145. }
  4146. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  4147. }
  4148. }
  4149. /**
  4150. * --------------------------------------------------------------------------
  4151. * Bootstrap util/scrollBar.js
  4152. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4153. * --------------------------------------------------------------------------
  4154. */
  4155. /**
  4156. * Constants
  4157. */
  4158. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  4159. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  4160. const PROPERTY_PADDING = 'padding-right';
  4161. const PROPERTY_MARGIN = 'margin-right';
  4162. /**
  4163. * Class definition
  4164. */
  4165. class ScrollBarHelper {
  4166. constructor() {
  4167. this._element = document.body;
  4168. }
  4169. // Public
  4170. getWidth() {
  4171. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  4172. const documentWidth = document.documentElement.clientWidth;
  4173. return Math.abs(window.innerWidth - documentWidth);
  4174. }
  4175. hide() {
  4176. const width = this.getWidth();
  4177. this._disableOverFlow();
  4178. // give padding to element to balance the hidden scrollbar width
  4179. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  4180. // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  4181. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  4182. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  4183. }
  4184. reset() {
  4185. this._resetElementAttributes(this._element, 'overflow');
  4186. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  4187. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  4188. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  4189. }
  4190. isOverflowing() {
  4191. return this.getWidth() > 0;
  4192. }
  4193. // Private
  4194. _disableOverFlow() {
  4195. this._saveInitialAttribute(this._element, 'overflow');
  4196. this._element.style.overflow = 'hidden';
  4197. }
  4198. _setElementAttributes(selector, styleProperty, callback) {
  4199. const scrollbarWidth = this.getWidth();
  4200. const manipulationCallBack = element => {
  4201. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  4202. return;
  4203. }
  4204. this._saveInitialAttribute(element, styleProperty);
  4205. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  4206. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  4207. };
  4208. this._applyManipulationCallback(selector, manipulationCallBack);
  4209. }
  4210. _saveInitialAttribute(element, styleProperty) {
  4211. const actualValue = element.style.getPropertyValue(styleProperty);
  4212. if (actualValue) {
  4213. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  4214. }
  4215. }
  4216. _resetElementAttributes(selector, styleProperty) {
  4217. const manipulationCallBack = element => {
  4218. const value = Manipulator.getDataAttribute(element, styleProperty);
  4219. // We only want to remove the property if the value is `null`; the value can also be zero
  4220. if (value === null) {
  4221. element.style.removeProperty(styleProperty);
  4222. return;
  4223. }
  4224. Manipulator.removeDataAttribute(element, styleProperty);
  4225. element.style.setProperty(styleProperty, value);
  4226. };
  4227. this._applyManipulationCallback(selector, manipulationCallBack);
  4228. }
  4229. _applyManipulationCallback(selector, callBack) {
  4230. if (isElement$1(selector)) {
  4231. callBack(selector);
  4232. return;
  4233. }
  4234. for (const sel of SelectorEngine.find(selector, this._element)) {
  4235. callBack(sel);
  4236. }
  4237. }
  4238. }
  4239. /**
  4240. * --------------------------------------------------------------------------
  4241. * Bootstrap modal.js
  4242. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4243. * --------------------------------------------------------------------------
  4244. */
  4245. /**
  4246. * Constants
  4247. */
  4248. const NAME$7 = 'modal';
  4249. const DATA_KEY$4 = 'bs.modal';
  4250. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  4251. const DATA_API_KEY$2 = '.data-api';
  4252. const ESCAPE_KEY$1 = 'Escape';
  4253. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  4254. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  4255. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  4256. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  4257. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  4258. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  4259. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  4260. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  4261. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  4262. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  4263. const CLASS_NAME_OPEN = 'modal-open';
  4264. const CLASS_NAME_FADE$3 = 'fade';
  4265. const CLASS_NAME_SHOW$4 = 'show';
  4266. const CLASS_NAME_STATIC = 'modal-static';
  4267. const OPEN_SELECTOR$1 = '.modal.show';
  4268. const SELECTOR_DIALOG = '.modal-dialog';
  4269. const SELECTOR_MODAL_BODY = '.modal-body';
  4270. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  4271. const Default$6 = {
  4272. backdrop: true,
  4273. focus: true,
  4274. keyboard: true
  4275. };
  4276. const DefaultType$6 = {
  4277. backdrop: '(boolean|string)',
  4278. focus: 'boolean',
  4279. keyboard: 'boolean'
  4280. };
  4281. /**
  4282. * Class definition
  4283. */
  4284. class Modal extends BaseComponent {
  4285. constructor(element, config) {
  4286. super(element, config);
  4287. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  4288. this._backdrop = this._initializeBackDrop();
  4289. this._focustrap = this._initializeFocusTrap();
  4290. this._isShown = false;
  4291. this._isTransitioning = false;
  4292. this._scrollBar = new ScrollBarHelper();
  4293. this._addEventListeners();
  4294. }
  4295. // Getters
  4296. static get Default() {
  4297. return Default$6;
  4298. }
  4299. static get DefaultType() {
  4300. return DefaultType$6;
  4301. }
  4302. static get NAME() {
  4303. return NAME$7;
  4304. }
  4305. // Public
  4306. toggle(relatedTarget) {
  4307. return this._isShown ? this.hide() : this.show(relatedTarget);
  4308. }
  4309. show(relatedTarget) {
  4310. if (this._isShown || this._isTransitioning) {
  4311. return;
  4312. }
  4313. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  4314. relatedTarget
  4315. });
  4316. if (showEvent.defaultPrevented) {
  4317. return;
  4318. }
  4319. this._isShown = true;
  4320. this._isTransitioning = true;
  4321. this._scrollBar.hide();
  4322. document.body.classList.add(CLASS_NAME_OPEN);
  4323. this._adjustDialog();
  4324. this._backdrop.show(() => this._showElement(relatedTarget));
  4325. }
  4326. hide() {
  4327. if (!this._isShown || this._isTransitioning) {
  4328. return;
  4329. }
  4330. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  4331. if (hideEvent.defaultPrevented) {
  4332. return;
  4333. }
  4334. this._isShown = false;
  4335. this._isTransitioning = true;
  4336. this._focustrap.deactivate();
  4337. this._element.classList.remove(CLASS_NAME_SHOW$4);
  4338. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  4339. }
  4340. dispose() {
  4341. EventHandler.off(window, EVENT_KEY$4);
  4342. EventHandler.off(this._dialog, EVENT_KEY$4);
  4343. this._backdrop.dispose();
  4344. this._focustrap.deactivate();
  4345. super.dispose();
  4346. }
  4347. handleUpdate() {
  4348. this._adjustDialog();
  4349. }
  4350. // Private
  4351. _initializeBackDrop() {
  4352. return new Backdrop({
  4353. isVisible: Boolean(this._config.backdrop),
  4354. // 'static' option will be translated to true, and booleans will keep their value,
  4355. isAnimated: this._isAnimated()
  4356. });
  4357. }
  4358. _initializeFocusTrap() {
  4359. return new FocusTrap({
  4360. trapElement: this._element
  4361. });
  4362. }
  4363. _showElement(relatedTarget) {
  4364. // try to append dynamic modal
  4365. if (!document.body.contains(this._element)) {
  4366. document.body.append(this._element);
  4367. }
  4368. this._element.style.display = 'block';
  4369. this._element.removeAttribute('aria-hidden');
  4370. this._element.setAttribute('aria-modal', true);
  4371. this._element.setAttribute('role', 'dialog');
  4372. this._element.scrollTop = 0;
  4373. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  4374. if (modalBody) {
  4375. modalBody.scrollTop = 0;
  4376. }
  4377. reflow(this._element);
  4378. this._element.classList.add(CLASS_NAME_SHOW$4);
  4379. const transitionComplete = () => {
  4380. if (this._config.focus) {
  4381. this._focustrap.activate();
  4382. }
  4383. this._isTransitioning = false;
  4384. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  4385. relatedTarget
  4386. });
  4387. };
  4388. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  4389. }
  4390. _addEventListeners() {
  4391. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  4392. if (event.key !== ESCAPE_KEY$1) {
  4393. return;
  4394. }
  4395. if (this._config.keyboard) {
  4396. this.hide();
  4397. return;
  4398. }
  4399. this._triggerBackdropTransition();
  4400. });
  4401. EventHandler.on(window, EVENT_RESIZE$1, () => {
  4402. if (this._isShown && !this._isTransitioning) {
  4403. this._adjustDialog();
  4404. }
  4405. });
  4406. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  4407. // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
  4408. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  4409. if (this._element !== event.target || this._element !== event2.target) {
  4410. return;
  4411. }
  4412. if (this._config.backdrop === 'static') {
  4413. this._triggerBackdropTransition();
  4414. return;
  4415. }
  4416. if (this._config.backdrop) {
  4417. this.hide();
  4418. }
  4419. });
  4420. });
  4421. }
  4422. _hideModal() {
  4423. this._element.style.display = 'none';
  4424. this._element.setAttribute('aria-hidden', true);
  4425. this._element.removeAttribute('aria-modal');
  4426. this._element.removeAttribute('role');
  4427. this._isTransitioning = false;
  4428. this._backdrop.hide(() => {
  4429. document.body.classList.remove(CLASS_NAME_OPEN);
  4430. this._resetAdjustments();
  4431. this._scrollBar.reset();
  4432. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  4433. });
  4434. }
  4435. _isAnimated() {
  4436. return this._element.classList.contains(CLASS_NAME_FADE$3);
  4437. }
  4438. _triggerBackdropTransition() {
  4439. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  4440. if (hideEvent.defaultPrevented) {
  4441. return;
  4442. }
  4443. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  4444. const initialOverflowY = this._element.style.overflowY;
  4445. // return if the following background transition hasn't yet completed
  4446. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  4447. return;
  4448. }
  4449. if (!isModalOverflowing) {
  4450. this._element.style.overflowY = 'hidden';
  4451. }
  4452. this._element.classList.add(CLASS_NAME_STATIC);
  4453. this._queueCallback(() => {
  4454. this._element.classList.remove(CLASS_NAME_STATIC);
  4455. this._queueCallback(() => {
  4456. this._element.style.overflowY = initialOverflowY;
  4457. }, this._dialog);
  4458. }, this._dialog);
  4459. this._element.focus();
  4460. }
  4461. /**
  4462. * The following methods are used to handle overflowing modals
  4463. */
  4464. _adjustDialog() {
  4465. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  4466. const scrollbarWidth = this._scrollBar.getWidth();
  4467. const isBodyOverflowing = scrollbarWidth > 0;
  4468. if (isBodyOverflowing && !isModalOverflowing) {
  4469. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  4470. this._element.style[property] = `${scrollbarWidth}px`;
  4471. }
  4472. if (!isBodyOverflowing && isModalOverflowing) {
  4473. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  4474. this._element.style[property] = `${scrollbarWidth}px`;
  4475. }
  4476. }
  4477. _resetAdjustments() {
  4478. this._element.style.paddingLeft = '';
  4479. this._element.style.paddingRight = '';
  4480. }
  4481. // Static
  4482. static jQueryInterface(config, relatedTarget) {
  4483. return this.each(function () {
  4484. const data = Modal.getOrCreateInstance(this, config);
  4485. if (typeof config !== 'string') {
  4486. return;
  4487. }
  4488. if (typeof data[config] === 'undefined') {
  4489. throw new TypeError(`No method named "${config}"`);
  4490. }
  4491. data[config](relatedTarget);
  4492. });
  4493. }
  4494. }
  4495. /**
  4496. * Data API implementation
  4497. */
  4498. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  4499. const target = SelectorEngine.getElementFromSelector(this);
  4500. if (['A', 'AREA'].includes(this.tagName)) {
  4501. event.preventDefault();
  4502. }
  4503. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  4504. if (showEvent.defaultPrevented) {
  4505. // only register focus restorer if modal will actually get shown
  4506. return;
  4507. }
  4508. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  4509. if (isVisible(this)) {
  4510. this.focus();
  4511. }
  4512. });
  4513. });
  4514. // avoid conflict when clicking modal toggler while another one is open
  4515. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  4516. if (alreadyOpen) {
  4517. Modal.getInstance(alreadyOpen).hide();
  4518. }
  4519. const data = Modal.getOrCreateInstance(target);
  4520. data.toggle(this);
  4521. });
  4522. enableDismissTrigger(Modal);
  4523. /**
  4524. * jQuery
  4525. */
  4526. defineJQueryPlugin(Modal);
  4527. /**
  4528. * --------------------------------------------------------------------------
  4529. * Bootstrap offcanvas.js
  4530. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4531. * --------------------------------------------------------------------------
  4532. */
  4533. /**
  4534. * Constants
  4535. */
  4536. const NAME$6 = 'offcanvas';
  4537. const DATA_KEY$3 = 'bs.offcanvas';
  4538. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  4539. const DATA_API_KEY$1 = '.data-api';
  4540. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  4541. const ESCAPE_KEY = 'Escape';
  4542. const CLASS_NAME_SHOW$3 = 'show';
  4543. const CLASS_NAME_SHOWING$1 = 'showing';
  4544. const CLASS_NAME_HIDING = 'hiding';
  4545. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  4546. const OPEN_SELECTOR = '.offcanvas.show';
  4547. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  4548. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  4549. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  4550. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  4551. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  4552. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  4553. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  4554. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  4555. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  4556. const Default$5 = {
  4557. backdrop: true,
  4558. keyboard: true,
  4559. scroll: false
  4560. };
  4561. const DefaultType$5 = {
  4562. backdrop: '(boolean|string)',
  4563. keyboard: 'boolean',
  4564. scroll: 'boolean'
  4565. };
  4566. /**
  4567. * Class definition
  4568. */
  4569. class Offcanvas extends BaseComponent {
  4570. constructor(element, config) {
  4571. super(element, config);
  4572. this._isShown = false;
  4573. this._backdrop = this._initializeBackDrop();
  4574. this._focustrap = this._initializeFocusTrap();
  4575. this._addEventListeners();
  4576. }
  4577. // Getters
  4578. static get Default() {
  4579. return Default$5;
  4580. }
  4581. static get DefaultType() {
  4582. return DefaultType$5;
  4583. }
  4584. static get NAME() {
  4585. return NAME$6;
  4586. }
  4587. // Public
  4588. toggle(relatedTarget) {
  4589. return this._isShown ? this.hide() : this.show(relatedTarget);
  4590. }
  4591. show(relatedTarget) {
  4592. if (this._isShown) {
  4593. return;
  4594. }
  4595. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  4596. relatedTarget
  4597. });
  4598. if (showEvent.defaultPrevented) {
  4599. return;
  4600. }
  4601. this._isShown = true;
  4602. this._backdrop.show();
  4603. if (!this._config.scroll) {
  4604. new ScrollBarHelper().hide();
  4605. }
  4606. this._element.setAttribute('aria-modal', true);
  4607. this._element.setAttribute('role', 'dialog');
  4608. this._element.classList.add(CLASS_NAME_SHOWING$1);
  4609. const completeCallBack = () => {
  4610. if (!this._config.scroll || this._config.backdrop) {
  4611. this._focustrap.activate();
  4612. }
  4613. this._element.classList.add(CLASS_NAME_SHOW$3);
  4614. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  4615. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  4616. relatedTarget
  4617. });
  4618. };
  4619. this._queueCallback(completeCallBack, this._element, true);
  4620. }
  4621. hide() {
  4622. if (!this._isShown) {
  4623. return;
  4624. }
  4625. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  4626. if (hideEvent.defaultPrevented) {
  4627. return;
  4628. }
  4629. this._focustrap.deactivate();
  4630. this._element.blur();
  4631. this._isShown = false;
  4632. this._element.classList.add(CLASS_NAME_HIDING);
  4633. this._backdrop.hide();
  4634. const completeCallback = () => {
  4635. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  4636. this._element.removeAttribute('aria-modal');
  4637. this._element.removeAttribute('role');
  4638. if (!this._config.scroll) {
  4639. new ScrollBarHelper().reset();
  4640. }
  4641. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  4642. };
  4643. this._queueCallback(completeCallback, this._element, true);
  4644. }
  4645. dispose() {
  4646. this._backdrop.dispose();
  4647. this._focustrap.deactivate();
  4648. super.dispose();
  4649. }
  4650. // Private
  4651. _initializeBackDrop() {
  4652. const clickCallback = () => {
  4653. if (this._config.backdrop === 'static') {
  4654. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  4655. return;
  4656. }
  4657. this.hide();
  4658. };
  4659. // 'static' option will be translated to true, and booleans will keep their value
  4660. const isVisible = Boolean(this._config.backdrop);
  4661. return new Backdrop({
  4662. className: CLASS_NAME_BACKDROP,
  4663. isVisible,
  4664. isAnimated: true,
  4665. rootElement: this._element.parentNode,
  4666. clickCallback: isVisible ? clickCallback : null
  4667. });
  4668. }
  4669. _initializeFocusTrap() {
  4670. return new FocusTrap({
  4671. trapElement: this._element
  4672. });
  4673. }
  4674. _addEventListeners() {
  4675. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  4676. if (event.key !== ESCAPE_KEY) {
  4677. return;
  4678. }
  4679. if (this._config.keyboard) {
  4680. this.hide();
  4681. return;
  4682. }
  4683. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  4684. });
  4685. }
  4686. // Static
  4687. static jQueryInterface(config) {
  4688. return this.each(function () {
  4689. const data = Offcanvas.getOrCreateInstance(this, config);
  4690. if (typeof config !== 'string') {
  4691. return;
  4692. }
  4693. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  4694. throw new TypeError(`No method named "${config}"`);
  4695. }
  4696. data[config](this);
  4697. });
  4698. }
  4699. }
  4700. /**
  4701. * Data API implementation
  4702. */
  4703. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  4704. const target = SelectorEngine.getElementFromSelector(this);
  4705. if (['A', 'AREA'].includes(this.tagName)) {
  4706. event.preventDefault();
  4707. }
  4708. if (isDisabled(this)) {
  4709. return;
  4710. }
  4711. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  4712. // focus on trigger when it is closed
  4713. if (isVisible(this)) {
  4714. this.focus();
  4715. }
  4716. });
  4717. // avoid conflict when clicking a toggler of an offcanvas, while another is open
  4718. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  4719. if (alreadyOpen && alreadyOpen !== target) {
  4720. Offcanvas.getInstance(alreadyOpen).hide();
  4721. }
  4722. const data = Offcanvas.getOrCreateInstance(target);
  4723. data.toggle(this);
  4724. });
  4725. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  4726. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  4727. Offcanvas.getOrCreateInstance(selector).show();
  4728. }
  4729. });
  4730. EventHandler.on(window, EVENT_RESIZE, () => {
  4731. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  4732. if (getComputedStyle(element).position !== 'fixed') {
  4733. Offcanvas.getOrCreateInstance(element).hide();
  4734. }
  4735. }
  4736. });
  4737. enableDismissTrigger(Offcanvas);
  4738. /**
  4739. * jQuery
  4740. */
  4741. defineJQueryPlugin(Offcanvas);
  4742. /**
  4743. * --------------------------------------------------------------------------
  4744. * Bootstrap util/sanitizer.js
  4745. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4746. * --------------------------------------------------------------------------
  4747. */
  4748. // js-docs-start allow-list
  4749. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4750. const DefaultAllowlist = {
  4751. // Global attributes allowed on any supplied element below.
  4752. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4753. a: ['target', 'href', 'title', 'rel'],
  4754. area: [],
  4755. b: [],
  4756. br: [],
  4757. col: [],
  4758. code: [],
  4759. div: [],
  4760. em: [],
  4761. hr: [],
  4762. h1: [],
  4763. h2: [],
  4764. h3: [],
  4765. h4: [],
  4766. h5: [],
  4767. h6: [],
  4768. i: [],
  4769. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  4770. li: [],
  4771. ol: [],
  4772. p: [],
  4773. pre: [],
  4774. s: [],
  4775. small: [],
  4776. span: [],
  4777. sub: [],
  4778. sup: [],
  4779. strong: [],
  4780. u: [],
  4781. ul: []
  4782. };
  4783. // js-docs-end allow-list
  4784. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  4785. /**
  4786. * A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
  4787. * contexts.
  4788. *
  4789. * Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
  4790. */
  4791. // eslint-disable-next-line unicorn/better-regex
  4792. const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
  4793. const allowedAttribute = (attribute, allowedAttributeList) => {
  4794. const attributeName = attribute.nodeName.toLowerCase();
  4795. if (allowedAttributeList.includes(attributeName)) {
  4796. if (uriAttributes.has(attributeName)) {
  4797. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue));
  4798. }
  4799. return true;
  4800. }
  4801. // Check if a regular expression validates the attribute.
  4802. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  4803. };
  4804. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  4805. if (!unsafeHtml.length) {
  4806. return unsafeHtml;
  4807. }
  4808. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  4809. return sanitizeFunction(unsafeHtml);
  4810. }
  4811. const domParser = new window.DOMParser();
  4812. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4813. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  4814. for (const element of elements) {
  4815. const elementName = element.nodeName.toLowerCase();
  4816. if (!Object.keys(allowList).includes(elementName)) {
  4817. element.remove();
  4818. continue;
  4819. }
  4820. const attributeList = [].concat(...element.attributes);
  4821. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  4822. for (const attribute of attributeList) {
  4823. if (!allowedAttribute(attribute, allowedAttributes)) {
  4824. element.removeAttribute(attribute.nodeName);
  4825. }
  4826. }
  4827. }
  4828. return createdDocument.body.innerHTML;
  4829. }
  4830. /**
  4831. * --------------------------------------------------------------------------
  4832. * Bootstrap util/template-factory.js
  4833. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4834. * --------------------------------------------------------------------------
  4835. */
  4836. /**
  4837. * Constants
  4838. */
  4839. const NAME$5 = 'TemplateFactory';
  4840. const Default$4 = {
  4841. allowList: DefaultAllowlist,
  4842. content: {},
  4843. // { selector : text , selector2 : text2 , }
  4844. extraClass: '',
  4845. html: false,
  4846. sanitize: true,
  4847. sanitizeFn: null,
  4848. template: '<div></div>'
  4849. };
  4850. const DefaultType$4 = {
  4851. allowList: 'object',
  4852. content: 'object',
  4853. extraClass: '(string|function)',
  4854. html: 'boolean',
  4855. sanitize: 'boolean',
  4856. sanitizeFn: '(null|function)',
  4857. template: 'string'
  4858. };
  4859. const DefaultContentType = {
  4860. entry: '(string|element|function|null)',
  4861. selector: '(string|element)'
  4862. };
  4863. /**
  4864. * Class definition
  4865. */
  4866. class TemplateFactory extends Config {
  4867. constructor(config) {
  4868. super();
  4869. this._config = this._getConfig(config);
  4870. }
  4871. // Getters
  4872. static get Default() {
  4873. return Default$4;
  4874. }
  4875. static get DefaultType() {
  4876. return DefaultType$4;
  4877. }
  4878. static get NAME() {
  4879. return NAME$5;
  4880. }
  4881. // Public
  4882. getContent() {
  4883. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  4884. }
  4885. hasContent() {
  4886. return this.getContent().length > 0;
  4887. }
  4888. changeContent(content) {
  4889. this._checkContent(content);
  4890. this._config.content = {
  4891. ...this._config.content,
  4892. ...content
  4893. };
  4894. return this;
  4895. }
  4896. toHtml() {
  4897. const templateWrapper = document.createElement('div');
  4898. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  4899. for (const [selector, text] of Object.entries(this._config.content)) {
  4900. this._setContent(templateWrapper, text, selector);
  4901. }
  4902. const template = templateWrapper.children[0];
  4903. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  4904. if (extraClass) {
  4905. template.classList.add(...extraClass.split(' '));
  4906. }
  4907. return template;
  4908. }
  4909. // Private
  4910. _typeCheckConfig(config) {
  4911. super._typeCheckConfig(config);
  4912. this._checkContent(config.content);
  4913. }
  4914. _checkContent(arg) {
  4915. for (const [selector, content] of Object.entries(arg)) {
  4916. super._typeCheckConfig({
  4917. selector,
  4918. entry: content
  4919. }, DefaultContentType);
  4920. }
  4921. }
  4922. _setContent(template, content, selector) {
  4923. const templateElement = SelectorEngine.findOne(selector, template);
  4924. if (!templateElement) {
  4925. return;
  4926. }
  4927. content = this._resolvePossibleFunction(content);
  4928. if (!content) {
  4929. templateElement.remove();
  4930. return;
  4931. }
  4932. if (isElement$1(content)) {
  4933. this._putElementInTemplate(getElement(content), templateElement);
  4934. return;
  4935. }
  4936. if (this._config.html) {
  4937. templateElement.innerHTML = this._maybeSanitize(content);
  4938. return;
  4939. }
  4940. templateElement.textContent = content;
  4941. }
  4942. _maybeSanitize(arg) {
  4943. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  4944. }
  4945. _resolvePossibleFunction(arg) {
  4946. return execute(arg, [this]);
  4947. }
  4948. _putElementInTemplate(element, templateElement) {
  4949. if (this._config.html) {
  4950. templateElement.innerHTML = '';
  4951. templateElement.append(element);
  4952. return;
  4953. }
  4954. templateElement.textContent = element.textContent;
  4955. }
  4956. }
  4957. /**
  4958. * --------------------------------------------------------------------------
  4959. * Bootstrap tooltip.js
  4960. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4961. * --------------------------------------------------------------------------
  4962. */
  4963. /**
  4964. * Constants
  4965. */
  4966. const NAME$4 = 'tooltip';
  4967. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  4968. const CLASS_NAME_FADE$2 = 'fade';
  4969. const CLASS_NAME_MODAL = 'modal';
  4970. const CLASS_NAME_SHOW$2 = 'show';
  4971. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  4972. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  4973. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  4974. const TRIGGER_HOVER = 'hover';
  4975. const TRIGGER_FOCUS = 'focus';
  4976. const TRIGGER_CLICK = 'click';
  4977. const TRIGGER_MANUAL = 'manual';
  4978. const EVENT_HIDE$2 = 'hide';
  4979. const EVENT_HIDDEN$2 = 'hidden';
  4980. const EVENT_SHOW$2 = 'show';
  4981. const EVENT_SHOWN$2 = 'shown';
  4982. const EVENT_INSERTED = 'inserted';
  4983. const EVENT_CLICK$1 = 'click';
  4984. const EVENT_FOCUSIN$1 = 'focusin';
  4985. const EVENT_FOCUSOUT$1 = 'focusout';
  4986. const EVENT_MOUSEENTER = 'mouseenter';
  4987. const EVENT_MOUSELEAVE = 'mouseleave';
  4988. const AttachmentMap = {
  4989. AUTO: 'auto',
  4990. TOP: 'top',
  4991. RIGHT: isRTL() ? 'left' : 'right',
  4992. BOTTOM: 'bottom',
  4993. LEFT: isRTL() ? 'right' : 'left'
  4994. };
  4995. const Default$3 = {
  4996. allowList: DefaultAllowlist,
  4997. animation: true,
  4998. boundary: 'clippingParents',
  4999. container: false,
  5000. customClass: '',
  5001. delay: 0,
  5002. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  5003. html: false,
  5004. offset: [0, 6],
  5005. placement: 'top',
  5006. popperConfig: null,
  5007. sanitize: true,
  5008. sanitizeFn: null,
  5009. selector: false,
  5010. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  5011. title: '',
  5012. trigger: 'hover focus'
  5013. };
  5014. const DefaultType$3 = {
  5015. allowList: 'object',
  5016. animation: 'boolean',
  5017. boundary: '(string|element)',
  5018. container: '(string|element|boolean)',
  5019. customClass: '(string|function)',
  5020. delay: '(number|object)',
  5021. fallbackPlacements: 'array',
  5022. html: 'boolean',
  5023. offset: '(array|string|function)',
  5024. placement: '(string|function)',
  5025. popperConfig: '(null|object|function)',
  5026. sanitize: 'boolean',
  5027. sanitizeFn: '(null|function)',
  5028. selector: '(string|boolean)',
  5029. template: 'string',
  5030. title: '(string|element|function)',
  5031. trigger: 'string'
  5032. };
  5033. /**
  5034. * Class definition
  5035. */
  5036. class Tooltip extends BaseComponent {
  5037. constructor(element, config) {
  5038. if (typeof Popper === 'undefined') {
  5039. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  5040. }
  5041. super(element, config);
  5042. // Private
  5043. this._isEnabled = true;
  5044. this._timeout = 0;
  5045. this._isHovered = null;
  5046. this._activeTrigger = {};
  5047. this._popper = null;
  5048. this._templateFactory = null;
  5049. this._newContent = null;
  5050. // Protected
  5051. this.tip = null;
  5052. this._setListeners();
  5053. if (!this._config.selector) {
  5054. this._fixTitle();
  5055. }
  5056. }
  5057. // Getters
  5058. static get Default() {
  5059. return Default$3;
  5060. }
  5061. static get DefaultType() {
  5062. return DefaultType$3;
  5063. }
  5064. static get NAME() {
  5065. return NAME$4;
  5066. }
  5067. // Public
  5068. enable() {
  5069. this._isEnabled = true;
  5070. }
  5071. disable() {
  5072. this._isEnabled = false;
  5073. }
  5074. toggleEnabled() {
  5075. this._isEnabled = !this._isEnabled;
  5076. }
  5077. toggle() {
  5078. if (!this._isEnabled) {
  5079. return;
  5080. }
  5081. this._activeTrigger.click = !this._activeTrigger.click;
  5082. if (this._isShown()) {
  5083. this._leave();
  5084. return;
  5085. }
  5086. this._enter();
  5087. }
  5088. dispose() {
  5089. clearTimeout(this._timeout);
  5090. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  5091. if (this._element.getAttribute('data-bs-original-title')) {
  5092. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  5093. }
  5094. this._disposePopper();
  5095. super.dispose();
  5096. }
  5097. show() {
  5098. if (this._element.style.display === 'none') {
  5099. throw new Error('Please use show on visible elements');
  5100. }
  5101. if (!(this._isWithContent() && this._isEnabled)) {
  5102. return;
  5103. }
  5104. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  5105. const shadowRoot = findShadowRoot(this._element);
  5106. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  5107. if (showEvent.defaultPrevented || !isInTheDom) {
  5108. return;
  5109. }
  5110. // TODO: v6 remove this or make it optional
  5111. this._disposePopper();
  5112. const tip = this._getTipElement();
  5113. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  5114. const {
  5115. container
  5116. } = this._config;
  5117. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  5118. container.append(tip);
  5119. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  5120. }
  5121. this._popper = this._createPopper(tip);
  5122. tip.classList.add(CLASS_NAME_SHOW$2);
  5123. // If this is a touch-enabled device we add extra
  5124. // empty mouseover listeners to the body's immediate children;
  5125. // only needed because of broken event delegation on iOS
  5126. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  5127. if ('ontouchstart' in document.documentElement) {
  5128. for (const element of [].concat(...document.body.children)) {
  5129. EventHandler.on(element, 'mouseover', noop);
  5130. }
  5131. }
  5132. const complete = () => {
  5133. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  5134. if (this._isHovered === false) {
  5135. this._leave();
  5136. }
  5137. this._isHovered = false;
  5138. };
  5139. this._queueCallback(complete, this.tip, this._isAnimated());
  5140. }
  5141. hide() {
  5142. if (!this._isShown()) {
  5143. return;
  5144. }
  5145. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  5146. if (hideEvent.defaultPrevented) {
  5147. return;
  5148. }
  5149. const tip = this._getTipElement();
  5150. tip.classList.remove(CLASS_NAME_SHOW$2);
  5151. // If this is a touch-enabled device we remove the extra
  5152. // empty mouseover listeners we added for iOS support
  5153. if ('ontouchstart' in document.documentElement) {
  5154. for (const element of [].concat(...document.body.children)) {
  5155. EventHandler.off(element, 'mouseover', noop);
  5156. }
  5157. }
  5158. this._activeTrigger[TRIGGER_CLICK] = false;
  5159. this._activeTrigger[TRIGGER_FOCUS] = false;
  5160. this._activeTrigger[TRIGGER_HOVER] = false;
  5161. this._isHovered = null; // it is a trick to support manual triggering
  5162. const complete = () => {
  5163. if (this._isWithActiveTrigger()) {
  5164. return;
  5165. }
  5166. if (!this._isHovered) {
  5167. this._disposePopper();
  5168. }
  5169. this._element.removeAttribute('aria-describedby');
  5170. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  5171. };
  5172. this._queueCallback(complete, this.tip, this._isAnimated());
  5173. }
  5174. update() {
  5175. if (this._popper) {
  5176. this._popper.update();
  5177. }
  5178. }
  5179. // Protected
  5180. _isWithContent() {
  5181. return Boolean(this._getTitle());
  5182. }
  5183. _getTipElement() {
  5184. if (!this.tip) {
  5185. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  5186. }
  5187. return this.tip;
  5188. }
  5189. _createTipElement(content) {
  5190. const tip = this._getTemplateFactory(content).toHtml();
  5191. // TODO: remove this check in v6
  5192. if (!tip) {
  5193. return null;
  5194. }
  5195. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  5196. // TODO: v6 the following can be achieved with CSS only
  5197. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  5198. const tipId = getUID(this.constructor.NAME).toString();
  5199. tip.setAttribute('id', tipId);
  5200. if (this._isAnimated()) {
  5201. tip.classList.add(CLASS_NAME_FADE$2);
  5202. }
  5203. return tip;
  5204. }
  5205. setContent(content) {
  5206. this._newContent = content;
  5207. if (this._isShown()) {
  5208. this._disposePopper();
  5209. this.show();
  5210. }
  5211. }
  5212. _getTemplateFactory(content) {
  5213. if (this._templateFactory) {
  5214. this._templateFactory.changeContent(content);
  5215. } else {
  5216. this._templateFactory = new TemplateFactory({
  5217. ...this._config,
  5218. // the `content` var has to be after `this._config`
  5219. // to override config.content in case of popover
  5220. content,
  5221. extraClass: this._resolvePossibleFunction(this._config.customClass)
  5222. });
  5223. }
  5224. return this._templateFactory;
  5225. }
  5226. _getContentForTemplate() {
  5227. return {
  5228. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  5229. };
  5230. }
  5231. _getTitle() {
  5232. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  5233. }
  5234. // Private
  5235. _initializeOnDelegatedTarget(event) {
  5236. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  5237. }
  5238. _isAnimated() {
  5239. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  5240. }
  5241. _isShown() {
  5242. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  5243. }
  5244. _createPopper(tip) {
  5245. const placement = execute(this._config.placement, [this, tip, this._element]);
  5246. const attachment = AttachmentMap[placement.toUpperCase()];
  5247. return createPopper(this._element, tip, this._getPopperConfig(attachment));
  5248. }
  5249. _getOffset() {
  5250. const {
  5251. offset
  5252. } = this._config;
  5253. if (typeof offset === 'string') {
  5254. return offset.split(',').map(value => Number.parseInt(value, 10));
  5255. }
  5256. if (typeof offset === 'function') {
  5257. return popperData => offset(popperData, this._element);
  5258. }
  5259. return offset;
  5260. }
  5261. _resolvePossibleFunction(arg) {
  5262. return execute(arg, [this._element]);
  5263. }
  5264. _getPopperConfig(attachment) {
  5265. const defaultBsPopperConfig = {
  5266. placement: attachment,
  5267. modifiers: [{
  5268. name: 'flip',
  5269. options: {
  5270. fallbackPlacements: this._config.fallbackPlacements
  5271. }
  5272. }, {
  5273. name: 'offset',
  5274. options: {
  5275. offset: this._getOffset()
  5276. }
  5277. }, {
  5278. name: 'preventOverflow',
  5279. options: {
  5280. boundary: this._config.boundary
  5281. }
  5282. }, {
  5283. name: 'arrow',
  5284. options: {
  5285. element: `.${this.constructor.NAME}-arrow`
  5286. }
  5287. }, {
  5288. name: 'preSetPlacement',
  5289. enabled: true,
  5290. phase: 'beforeMain',
  5291. fn: data => {
  5292. // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
  5293. // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
  5294. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  5295. }
  5296. }]
  5297. };
  5298. return {
  5299. ...defaultBsPopperConfig,
  5300. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  5301. };
  5302. }
  5303. _setListeners() {
  5304. const triggers = this._config.trigger.split(' ');
  5305. for (const trigger of triggers) {
  5306. if (trigger === 'click') {
  5307. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  5308. const context = this._initializeOnDelegatedTarget(event);
  5309. context.toggle();
  5310. });
  5311. } else if (trigger !== TRIGGER_MANUAL) {
  5312. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  5313. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  5314. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  5315. const context = this._initializeOnDelegatedTarget(event);
  5316. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  5317. context._enter();
  5318. });
  5319. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  5320. const context = this._initializeOnDelegatedTarget(event);
  5321. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  5322. context._leave();
  5323. });
  5324. }
  5325. }
  5326. this._hideModalHandler = () => {
  5327. if (this._element) {
  5328. this.hide();
  5329. }
  5330. };
  5331. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  5332. }
  5333. _fixTitle() {
  5334. const title = this._element.getAttribute('title');
  5335. if (!title) {
  5336. return;
  5337. }
  5338. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  5339. this._element.setAttribute('aria-label', title);
  5340. }
  5341. this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
  5342. this._element.removeAttribute('title');
  5343. }
  5344. _enter() {
  5345. if (this._isShown() || this._isHovered) {
  5346. this._isHovered = true;
  5347. return;
  5348. }
  5349. this._isHovered = true;
  5350. this._setTimeout(() => {
  5351. if (this._isHovered) {
  5352. this.show();
  5353. }
  5354. }, this._config.delay.show);
  5355. }
  5356. _leave() {
  5357. if (this._isWithActiveTrigger()) {
  5358. return;
  5359. }
  5360. this._isHovered = false;
  5361. this._setTimeout(() => {
  5362. if (!this._isHovered) {
  5363. this.hide();
  5364. }
  5365. }, this._config.delay.hide);
  5366. }
  5367. _setTimeout(handler, timeout) {
  5368. clearTimeout(this._timeout);
  5369. this._timeout = setTimeout(handler, timeout);
  5370. }
  5371. _isWithActiveTrigger() {
  5372. return Object.values(this._activeTrigger).includes(true);
  5373. }
  5374. _getConfig(config) {
  5375. const dataAttributes = Manipulator.getDataAttributes(this._element);
  5376. for (const dataAttribute of Object.keys(dataAttributes)) {
  5377. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  5378. delete dataAttributes[dataAttribute];
  5379. }
  5380. }
  5381. config = {
  5382. ...dataAttributes,
  5383. ...(typeof config === 'object' && config ? config : {})
  5384. };
  5385. config = this._mergeConfigObj(config);
  5386. config = this._configAfterMerge(config);
  5387. this._typeCheckConfig(config);
  5388. return config;
  5389. }
  5390. _configAfterMerge(config) {
  5391. config.container = config.container === false ? document.body : getElement(config.container);
  5392. if (typeof config.delay === 'number') {
  5393. config.delay = {
  5394. show: config.delay,
  5395. hide: config.delay
  5396. };
  5397. }
  5398. if (typeof config.title === 'number') {
  5399. config.title = config.title.toString();
  5400. }
  5401. if (typeof config.content === 'number') {
  5402. config.content = config.content.toString();
  5403. }
  5404. return config;
  5405. }
  5406. _getDelegateConfig() {
  5407. const config = {};
  5408. for (const [key, value] of Object.entries(this._config)) {
  5409. if (this.constructor.Default[key] !== value) {
  5410. config[key] = value;
  5411. }
  5412. }
  5413. config.selector = false;
  5414. config.trigger = 'manual';
  5415. // In the future can be replaced with:
  5416. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  5417. // `Object.fromEntries(keysWithDifferentValues)`
  5418. return config;
  5419. }
  5420. _disposePopper() {
  5421. if (this._popper) {
  5422. this._popper.destroy();
  5423. this._popper = null;
  5424. }
  5425. if (this.tip) {
  5426. this.tip.remove();
  5427. this.tip = null;
  5428. }
  5429. }
  5430. // Static
  5431. static jQueryInterface(config) {
  5432. return this.each(function () {
  5433. const data = Tooltip.getOrCreateInstance(this, config);
  5434. if (typeof config !== 'string') {
  5435. return;
  5436. }
  5437. if (typeof data[config] === 'undefined') {
  5438. throw new TypeError(`No method named "${config}"`);
  5439. }
  5440. data[config]();
  5441. });
  5442. }
  5443. }
  5444. /**
  5445. * jQuery
  5446. */
  5447. defineJQueryPlugin(Tooltip);
  5448. /**
  5449. * --------------------------------------------------------------------------
  5450. * Bootstrap popover.js
  5451. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5452. * --------------------------------------------------------------------------
  5453. */
  5454. /**
  5455. * Constants
  5456. */
  5457. const NAME$3 = 'popover';
  5458. const SELECTOR_TITLE = '.popover-header';
  5459. const SELECTOR_CONTENT = '.popover-body';
  5460. const Default$2 = {
  5461. ...Tooltip.Default,
  5462. content: '',
  5463. offset: [0, 8],
  5464. placement: 'right',
  5465. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  5466. trigger: 'click'
  5467. };
  5468. const DefaultType$2 = {
  5469. ...Tooltip.DefaultType,
  5470. content: '(null|string|element|function)'
  5471. };
  5472. /**
  5473. * Class definition
  5474. */
  5475. class Popover extends Tooltip {
  5476. // Getters
  5477. static get Default() {
  5478. return Default$2;
  5479. }
  5480. static get DefaultType() {
  5481. return DefaultType$2;
  5482. }
  5483. static get NAME() {
  5484. return NAME$3;
  5485. }
  5486. // Overrides
  5487. _isWithContent() {
  5488. return this._getTitle() || this._getContent();
  5489. }
  5490. // Private
  5491. _getContentForTemplate() {
  5492. return {
  5493. [SELECTOR_TITLE]: this._getTitle(),
  5494. [SELECTOR_CONTENT]: this._getContent()
  5495. };
  5496. }
  5497. _getContent() {
  5498. return this._resolvePossibleFunction(this._config.content);
  5499. }
  5500. // Static
  5501. static jQueryInterface(config) {
  5502. return this.each(function () {
  5503. const data = Popover.getOrCreateInstance(this, config);
  5504. if (typeof config !== 'string') {
  5505. return;
  5506. }
  5507. if (typeof data[config] === 'undefined') {
  5508. throw new TypeError(`No method named "${config}"`);
  5509. }
  5510. data[config]();
  5511. });
  5512. }
  5513. }
  5514. /**
  5515. * jQuery
  5516. */
  5517. defineJQueryPlugin(Popover);
  5518. /**
  5519. * --------------------------------------------------------------------------
  5520. * Bootstrap scrollspy.js
  5521. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5522. * --------------------------------------------------------------------------
  5523. */
  5524. /**
  5525. * Constants
  5526. */
  5527. const NAME$2 = 'scrollspy';
  5528. const DATA_KEY$2 = 'bs.scrollspy';
  5529. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  5530. const DATA_API_KEY = '.data-api';
  5531. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  5532. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  5533. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  5534. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  5535. const CLASS_NAME_ACTIVE$1 = 'active';
  5536. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  5537. const SELECTOR_TARGET_LINKS = '[href]';
  5538. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  5539. const SELECTOR_NAV_LINKS = '.nav-link';
  5540. const SELECTOR_NAV_ITEMS = '.nav-item';
  5541. const SELECTOR_LIST_ITEMS = '.list-group-item';
  5542. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  5543. const SELECTOR_DROPDOWN = '.dropdown';
  5544. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  5545. const Default$1 = {
  5546. offset: null,
  5547. // TODO: v6 @deprecated, keep it for backwards compatibility reasons
  5548. rootMargin: '0px 0px -25%',
  5549. smoothScroll: false,
  5550. target: null,
  5551. threshold: [0.1, 0.5, 1]
  5552. };
  5553. const DefaultType$1 = {
  5554. offset: '(number|null)',
  5555. // TODO v6 @deprecated, keep it for backwards compatibility reasons
  5556. rootMargin: 'string',
  5557. smoothScroll: 'boolean',
  5558. target: 'element',
  5559. threshold: 'array'
  5560. };
  5561. /**
  5562. * Class definition
  5563. */
  5564. class ScrollSpy extends BaseComponent {
  5565. constructor(element, config) {
  5566. super(element, config);
  5567. // this._element is the observablesContainer and config.target the menu links wrapper
  5568. this._targetLinks = new Map();
  5569. this._observableSections = new Map();
  5570. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  5571. this._activeTarget = null;
  5572. this._observer = null;
  5573. this._previousScrollData = {
  5574. visibleEntryTop: 0,
  5575. parentScrollTop: 0
  5576. };
  5577. this.refresh(); // initialize
  5578. }
  5579. // Getters
  5580. static get Default() {
  5581. return Default$1;
  5582. }
  5583. static get DefaultType() {
  5584. return DefaultType$1;
  5585. }
  5586. static get NAME() {
  5587. return NAME$2;
  5588. }
  5589. // Public
  5590. refresh() {
  5591. this._initializeTargetsAndObservables();
  5592. this._maybeEnableSmoothScroll();
  5593. if (this._observer) {
  5594. this._observer.disconnect();
  5595. } else {
  5596. this._observer = this._getNewObserver();
  5597. }
  5598. for (const section of this._observableSections.values()) {
  5599. this._observer.observe(section);
  5600. }
  5601. }
  5602. dispose() {
  5603. this._observer.disconnect();
  5604. super.dispose();
  5605. }
  5606. // Private
  5607. _configAfterMerge(config) {
  5608. // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
  5609. config.target = getElement(config.target) || document.body;
  5610. // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
  5611. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  5612. if (typeof config.threshold === 'string') {
  5613. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  5614. }
  5615. return config;
  5616. }
  5617. _maybeEnableSmoothScroll() {
  5618. if (!this._config.smoothScroll) {
  5619. return;
  5620. }
  5621. // unregister any previous listeners
  5622. EventHandler.off(this._config.target, EVENT_CLICK);
  5623. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  5624. const observableSection = this._observableSections.get(event.target.hash);
  5625. if (observableSection) {
  5626. event.preventDefault();
  5627. const root = this._rootElement || window;
  5628. const height = observableSection.offsetTop - this._element.offsetTop;
  5629. if (root.scrollTo) {
  5630. root.scrollTo({
  5631. top: height,
  5632. behavior: 'smooth'
  5633. });
  5634. return;
  5635. }
  5636. // Chrome 60 doesn't support `scrollTo`
  5637. root.scrollTop = height;
  5638. }
  5639. });
  5640. }
  5641. _getNewObserver() {
  5642. const options = {
  5643. root: this._rootElement,
  5644. threshold: this._config.threshold,
  5645. rootMargin: this._config.rootMargin
  5646. };
  5647. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  5648. }
  5649. // The logic of selection
  5650. _observerCallback(entries) {
  5651. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  5652. const activate = entry => {
  5653. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  5654. this._process(targetElement(entry));
  5655. };
  5656. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  5657. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  5658. this._previousScrollData.parentScrollTop = parentScrollTop;
  5659. for (const entry of entries) {
  5660. if (!entry.isIntersecting) {
  5661. this._activeTarget = null;
  5662. this._clearActiveClass(targetElement(entry));
  5663. continue;
  5664. }
  5665. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  5666. // if we are scrolling down, pick the bigger offsetTop
  5667. if (userScrollsDown && entryIsLowerThanPrevious) {
  5668. activate(entry);
  5669. // if parent isn't scrolled, let's keep the first visible item, breaking the iteration
  5670. if (!parentScrollTop) {
  5671. return;
  5672. }
  5673. continue;
  5674. }
  5675. // if we are scrolling up, pick the smallest offsetTop
  5676. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  5677. activate(entry);
  5678. }
  5679. }
  5680. }
  5681. _initializeTargetsAndObservables() {
  5682. this._targetLinks = new Map();
  5683. this._observableSections = new Map();
  5684. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  5685. for (const anchor of targetLinks) {
  5686. // ensure that the anchor has an id and is not disabled
  5687. if (!anchor.hash || isDisabled(anchor)) {
  5688. continue;
  5689. }
  5690. const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element);
  5691. // ensure that the observableSection exists & is visible
  5692. if (isVisible(observableSection)) {
  5693. this._targetLinks.set(decodeURI(anchor.hash), anchor);
  5694. this._observableSections.set(anchor.hash, observableSection);
  5695. }
  5696. }
  5697. }
  5698. _process(target) {
  5699. if (this._activeTarget === target) {
  5700. return;
  5701. }
  5702. this._clearActiveClass(this._config.target);
  5703. this._activeTarget = target;
  5704. target.classList.add(CLASS_NAME_ACTIVE$1);
  5705. this._activateParents(target);
  5706. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  5707. relatedTarget: target
  5708. });
  5709. }
  5710. _activateParents(target) {
  5711. // Activate dropdown parents
  5712. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  5713. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  5714. return;
  5715. }
  5716. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  5717. // Set triggered links parents as active
  5718. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5719. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  5720. item.classList.add(CLASS_NAME_ACTIVE$1);
  5721. }
  5722. }
  5723. }
  5724. _clearActiveClass(parent) {
  5725. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  5726. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  5727. for (const node of activeNodes) {
  5728. node.classList.remove(CLASS_NAME_ACTIVE$1);
  5729. }
  5730. }
  5731. // Static
  5732. static jQueryInterface(config) {
  5733. return this.each(function () {
  5734. const data = ScrollSpy.getOrCreateInstance(this, config);
  5735. if (typeof config !== 'string') {
  5736. return;
  5737. }
  5738. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5739. throw new TypeError(`No method named "${config}"`);
  5740. }
  5741. data[config]();
  5742. });
  5743. }
  5744. }
  5745. /**
  5746. * Data API implementation
  5747. */
  5748. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  5749. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  5750. ScrollSpy.getOrCreateInstance(spy);
  5751. }
  5752. });
  5753. /**
  5754. * jQuery
  5755. */
  5756. defineJQueryPlugin(ScrollSpy);
  5757. /**
  5758. * --------------------------------------------------------------------------
  5759. * Bootstrap tab.js
  5760. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5761. * --------------------------------------------------------------------------
  5762. */
  5763. /**
  5764. * Constants
  5765. */
  5766. const NAME$1 = 'tab';
  5767. const DATA_KEY$1 = 'bs.tab';
  5768. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  5769. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  5770. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  5771. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  5772. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  5773. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  5774. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  5775. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  5776. const ARROW_LEFT_KEY = 'ArrowLeft';
  5777. const ARROW_RIGHT_KEY = 'ArrowRight';
  5778. const ARROW_UP_KEY = 'ArrowUp';
  5779. const ARROW_DOWN_KEY = 'ArrowDown';
  5780. const HOME_KEY = 'Home';
  5781. const END_KEY = 'End';
  5782. const CLASS_NAME_ACTIVE = 'active';
  5783. const CLASS_NAME_FADE$1 = 'fade';
  5784. const CLASS_NAME_SHOW$1 = 'show';
  5785. const CLASS_DROPDOWN = 'dropdown';
  5786. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  5787. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  5788. const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_TOGGLE})`;
  5789. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  5790. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  5791. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  5792. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // TODO: could only be `tab` in v6
  5793. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  5794. const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
  5795. /**
  5796. * Class definition
  5797. */
  5798. class Tab extends BaseComponent {
  5799. constructor(element) {
  5800. super(element);
  5801. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  5802. if (!this._parent) {
  5803. return;
  5804. // TODO: should throw exception in v6
  5805. // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
  5806. }
  5807. // Set up initial aria attributes
  5808. this._setInitialAttributes(this._parent, this._getChildren());
  5809. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  5810. }
  5811. // Getters
  5812. static get NAME() {
  5813. return NAME$1;
  5814. }
  5815. // Public
  5816. show() {
  5817. // Shows this elem and deactivate the active sibling if exists
  5818. const innerElem = this._element;
  5819. if (this._elemIsActive(innerElem)) {
  5820. return;
  5821. }
  5822. // Search for active tab on same parent to deactivate it
  5823. const active = this._getActiveElem();
  5824. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  5825. relatedTarget: innerElem
  5826. }) : null;
  5827. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  5828. relatedTarget: active
  5829. });
  5830. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  5831. return;
  5832. }
  5833. this._deactivate(active, innerElem);
  5834. this._activate(innerElem, active);
  5835. }
  5836. // Private
  5837. _activate(element, relatedElem) {
  5838. if (!element) {
  5839. return;
  5840. }
  5841. element.classList.add(CLASS_NAME_ACTIVE);
  5842. this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
  5843. const complete = () => {
  5844. if (element.getAttribute('role') !== 'tab') {
  5845. element.classList.add(CLASS_NAME_SHOW$1);
  5846. return;
  5847. }
  5848. element.removeAttribute('tabindex');
  5849. element.setAttribute('aria-selected', true);
  5850. this._toggleDropDown(element, true);
  5851. EventHandler.trigger(element, EVENT_SHOWN$1, {
  5852. relatedTarget: relatedElem
  5853. });
  5854. };
  5855. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  5856. }
  5857. _deactivate(element, relatedElem) {
  5858. if (!element) {
  5859. return;
  5860. }
  5861. element.classList.remove(CLASS_NAME_ACTIVE);
  5862. element.blur();
  5863. this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
  5864. const complete = () => {
  5865. if (element.getAttribute('role') !== 'tab') {
  5866. element.classList.remove(CLASS_NAME_SHOW$1);
  5867. return;
  5868. }
  5869. element.setAttribute('aria-selected', false);
  5870. element.setAttribute('tabindex', '-1');
  5871. this._toggleDropDown(element, false);
  5872. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  5873. relatedTarget: relatedElem
  5874. });
  5875. };
  5876. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  5877. }
  5878. _keydown(event) {
  5879. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY, HOME_KEY, END_KEY].includes(event.key)) {
  5880. return;
  5881. }
  5882. event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
  5883. event.preventDefault();
  5884. const children = this._getChildren().filter(element => !isDisabled(element));
  5885. let nextActiveElement;
  5886. if ([HOME_KEY, END_KEY].includes(event.key)) {
  5887. nextActiveElement = children[event.key === HOME_KEY ? 0 : children.length - 1];
  5888. } else {
  5889. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  5890. nextActiveElement = getNextActiveElement(children, event.target, isNext, true);
  5891. }
  5892. if (nextActiveElement) {
  5893. nextActiveElement.focus({
  5894. preventScroll: true
  5895. });
  5896. Tab.getOrCreateInstance(nextActiveElement).show();
  5897. }
  5898. }
  5899. _getChildren() {
  5900. // collection of inner elements
  5901. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  5902. }
  5903. _getActiveElem() {
  5904. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  5905. }
  5906. _setInitialAttributes(parent, children) {
  5907. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  5908. for (const child of children) {
  5909. this._setInitialAttributesOnChild(child);
  5910. }
  5911. }
  5912. _setInitialAttributesOnChild(child) {
  5913. child = this._getInnerElement(child);
  5914. const isActive = this._elemIsActive(child);
  5915. const outerElem = this._getOuterElement(child);
  5916. child.setAttribute('aria-selected', isActive);
  5917. if (outerElem !== child) {
  5918. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  5919. }
  5920. if (!isActive) {
  5921. child.setAttribute('tabindex', '-1');
  5922. }
  5923. this._setAttributeIfNotExists(child, 'role', 'tab');
  5924. // set attributes to the related panel too
  5925. this._setInitialAttributesOnTargetPanel(child);
  5926. }
  5927. _setInitialAttributesOnTargetPanel(child) {
  5928. const target = SelectorEngine.getElementFromSelector(child);
  5929. if (!target) {
  5930. return;
  5931. }
  5932. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  5933. if (child.id) {
  5934. this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
  5935. }
  5936. }
  5937. _toggleDropDown(element, open) {
  5938. const outerElem = this._getOuterElement(element);
  5939. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  5940. return;
  5941. }
  5942. const toggle = (selector, className) => {
  5943. const element = SelectorEngine.findOne(selector, outerElem);
  5944. if (element) {
  5945. element.classList.toggle(className, open);
  5946. }
  5947. };
  5948. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  5949. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  5950. outerElem.setAttribute('aria-expanded', open);
  5951. }
  5952. _setAttributeIfNotExists(element, attribute, value) {
  5953. if (!element.hasAttribute(attribute)) {
  5954. element.setAttribute(attribute, value);
  5955. }
  5956. }
  5957. _elemIsActive(elem) {
  5958. return elem.classList.contains(CLASS_NAME_ACTIVE);
  5959. }
  5960. // Try to get the inner element (usually the .nav-link)
  5961. _getInnerElement(elem) {
  5962. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  5963. }
  5964. // Try to get the outer element (usually the .nav-item)
  5965. _getOuterElement(elem) {
  5966. return elem.closest(SELECTOR_OUTER) || elem;
  5967. }
  5968. // Static
  5969. static jQueryInterface(config) {
  5970. return this.each(function () {
  5971. const data = Tab.getOrCreateInstance(this);
  5972. if (typeof config !== 'string') {
  5973. return;
  5974. }
  5975. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5976. throw new TypeError(`No method named "${config}"`);
  5977. }
  5978. data[config]();
  5979. });
  5980. }
  5981. }
  5982. /**
  5983. * Data API implementation
  5984. */
  5985. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  5986. if (['A', 'AREA'].includes(this.tagName)) {
  5987. event.preventDefault();
  5988. }
  5989. if (isDisabled(this)) {
  5990. return;
  5991. }
  5992. Tab.getOrCreateInstance(this).show();
  5993. });
  5994. /**
  5995. * Initialize on focus
  5996. */
  5997. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  5998. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  5999. Tab.getOrCreateInstance(element);
  6000. }
  6001. });
  6002. /**
  6003. * jQuery
  6004. */
  6005. defineJQueryPlugin(Tab);
  6006. /**
  6007. * --------------------------------------------------------------------------
  6008. * Bootstrap toast.js
  6009. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  6010. * --------------------------------------------------------------------------
  6011. */
  6012. /**
  6013. * Constants
  6014. */
  6015. const NAME = 'toast';
  6016. const DATA_KEY = 'bs.toast';
  6017. const EVENT_KEY = `.${DATA_KEY}`;
  6018. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  6019. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  6020. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  6021. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  6022. const EVENT_HIDE = `hide${EVENT_KEY}`;
  6023. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  6024. const EVENT_SHOW = `show${EVENT_KEY}`;
  6025. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  6026. const CLASS_NAME_FADE = 'fade';
  6027. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  6028. const CLASS_NAME_SHOW = 'show';
  6029. const CLASS_NAME_SHOWING = 'showing';
  6030. const DefaultType = {
  6031. animation: 'boolean',
  6032. autohide: 'boolean',
  6033. delay: 'number'
  6034. };
  6035. const Default = {
  6036. animation: true,
  6037. autohide: true,
  6038. delay: 5000
  6039. };
  6040. /**
  6041. * Class definition
  6042. */
  6043. class Toast extends BaseComponent {
  6044. constructor(element, config) {
  6045. super(element, config);
  6046. this._timeout = null;
  6047. this._hasMouseInteraction = false;
  6048. this._hasKeyboardInteraction = false;
  6049. this._setListeners();
  6050. }
  6051. // Getters
  6052. static get Default() {
  6053. return Default;
  6054. }
  6055. static get DefaultType() {
  6056. return DefaultType;
  6057. }
  6058. static get NAME() {
  6059. return NAME;
  6060. }
  6061. // Public
  6062. show() {
  6063. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  6064. if (showEvent.defaultPrevented) {
  6065. return;
  6066. }
  6067. this._clearTimeout();
  6068. if (this._config.animation) {
  6069. this._element.classList.add(CLASS_NAME_FADE);
  6070. }
  6071. const complete = () => {
  6072. this._element.classList.remove(CLASS_NAME_SHOWING);
  6073. EventHandler.trigger(this._element, EVENT_SHOWN);
  6074. this._maybeScheduleHide();
  6075. };
  6076. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  6077. reflow(this._element);
  6078. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  6079. this._queueCallback(complete, this._element, this._config.animation);
  6080. }
  6081. hide() {
  6082. if (!this.isShown()) {
  6083. return;
  6084. }
  6085. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  6086. if (hideEvent.defaultPrevented) {
  6087. return;
  6088. }
  6089. const complete = () => {
  6090. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  6091. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  6092. EventHandler.trigger(this._element, EVENT_HIDDEN);
  6093. };
  6094. this._element.classList.add(CLASS_NAME_SHOWING);
  6095. this._queueCallback(complete, this._element, this._config.animation);
  6096. }
  6097. dispose() {
  6098. this._clearTimeout();
  6099. if (this.isShown()) {
  6100. this._element.classList.remove(CLASS_NAME_SHOW);
  6101. }
  6102. super.dispose();
  6103. }
  6104. isShown() {
  6105. return this._element.classList.contains(CLASS_NAME_SHOW);
  6106. }
  6107. // Private
  6108. _maybeScheduleHide() {
  6109. if (!this._config.autohide) {
  6110. return;
  6111. }
  6112. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  6113. return;
  6114. }
  6115. this._timeout = setTimeout(() => {
  6116. this.hide();
  6117. }, this._config.delay);
  6118. }
  6119. _onInteraction(event, isInteracting) {
  6120. switch (event.type) {
  6121. case 'mouseover':
  6122. case 'mouseout':
  6123. {
  6124. this._hasMouseInteraction = isInteracting;
  6125. break;
  6126. }
  6127. case 'focusin':
  6128. case 'focusout':
  6129. {
  6130. this._hasKeyboardInteraction = isInteracting;
  6131. break;
  6132. }
  6133. }
  6134. if (isInteracting) {
  6135. this._clearTimeout();
  6136. return;
  6137. }
  6138. const nextElement = event.relatedTarget;
  6139. if (this._element === nextElement || this._element.contains(nextElement)) {
  6140. return;
  6141. }
  6142. this._maybeScheduleHide();
  6143. }
  6144. _setListeners() {
  6145. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  6146. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  6147. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  6148. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  6149. }
  6150. _clearTimeout() {
  6151. clearTimeout(this._timeout);
  6152. this._timeout = null;
  6153. }
  6154. // Static
  6155. static jQueryInterface(config) {
  6156. return this.each(function () {
  6157. const data = Toast.getOrCreateInstance(this, config);
  6158. if (typeof config === 'string') {
  6159. if (typeof data[config] === 'undefined') {
  6160. throw new TypeError(`No method named "${config}"`);
  6161. }
  6162. data[config](this);
  6163. }
  6164. });
  6165. }
  6166. }
  6167. /**
  6168. * Data API implementation
  6169. */
  6170. enableDismissTrigger(Toast);
  6171. /**
  6172. * jQuery
  6173. */
  6174. defineJQueryPlugin(Toast);
  6175. /**
  6176. * --------------------------------------------------------------------------
  6177. * Bootstrap index.umd.js
  6178. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  6179. * --------------------------------------------------------------------------
  6180. */
  6181. const index_umd = {
  6182. Alert,
  6183. Button,
  6184. Carousel,
  6185. Collapse,
  6186. Dropdown,
  6187. Modal,
  6188. Offcanvas,
  6189. Popover,
  6190. ScrollSpy,
  6191. Tab,
  6192. Toast,
  6193. Tooltip
  6194. };
  6195. return index_umd;
  6196. }));
  6197. //# sourceMappingURL=bootstrap.bundle.js.map
  6198. /*!
  6199. GSAP
  6200. Version: 3.12.4
  6201. Plugin URL: https://gsap.com
  6202. License: Copyright 2024, GreenSock. All rights reserved. | Subject to the terms at https://gsap.com/standard-license or for Club GreenSock members, the agreement issued with that membership. | author: Jack Doyle, jack@greensock.com
  6203. !*/
  6204. (function (global, factory) {
  6205. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  6206. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  6207. (global = global || self, factory(global.window = global.window || {}));
  6208. }(this, (function (exports) { 'use strict';
  6209. function _inheritsLoose(subClass, superClass) {
  6210. subClass.prototype = Object.create(superClass.prototype);
  6211. subClass.prototype.constructor = subClass;
  6212. subClass.__proto__ = superClass;
  6213. }
  6214. function _assertThisInitialized(self) {
  6215. if (self === void 0) {
  6216. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  6217. }
  6218. return self;
  6219. }
  6220. var _config = {
  6221. autoSleep: 120,
  6222. force3D: "auto",
  6223. nullTargetWarn: 1,
  6224. units: {
  6225. lineHeight: ""
  6226. }
  6227. },
  6228. _defaults = {
  6229. duration: .5,
  6230. overwrite: false,
  6231. delay: 0
  6232. },
  6233. _suppressOverwrites,
  6234. _reverting,
  6235. _context,
  6236. _bigNum = 1e8,
  6237. _tinyNum = 1 / _bigNum,
  6238. _2PI = Math.PI * 2,
  6239. _HALF_PI = _2PI / 4,
  6240. _gsID = 0,
  6241. _sqrt = Math.sqrt,
  6242. _cos = Math.cos,
  6243. _sin = Math.sin,
  6244. _isString = function _isString(value) {
  6245. return typeof value === "string";
  6246. },
  6247. _isFunction = function _isFunction(value) {
  6248. return typeof value === "function";
  6249. },
  6250. _isNumber = function _isNumber(value) {
  6251. return typeof value === "number";
  6252. },
  6253. _isUndefined = function _isUndefined(value) {
  6254. return typeof value === "undefined";
  6255. },
  6256. _isObject = function _isObject(value) {
  6257. return typeof value === "object";
  6258. },
  6259. _isNotFalse = function _isNotFalse(value) {
  6260. return value !== false;
  6261. },
  6262. _windowExists = function _windowExists() {
  6263. return typeof window !== "undefined";
  6264. },
  6265. _isFuncOrString = function _isFuncOrString(value) {
  6266. return _isFunction(value) || _isString(value);
  6267. },
  6268. _isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {},
  6269. _isArray = Array.isArray,
  6270. _strictNumExp = /(?:-?\.?\d|\.)+/gi,
  6271. _numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,
  6272. _numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g,
  6273. _complexStringNumExp = /[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,
  6274. _relExp = /[+-]=-?[.\d]+/,
  6275. _delimitedValueExp = /[^,'"\[\]\s]+/gi,
  6276. _unitExp = /^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,
  6277. _globalTimeline,
  6278. _win,
  6279. _coreInitted,
  6280. _doc,
  6281. _globals = {},
  6282. _installScope = {},
  6283. _coreReady,
  6284. _install = function _install(scope) {
  6285. return (_installScope = _merge(scope, _globals)) && gsap;
  6286. },
  6287. _missingPlugin = function _missingPlugin(property, value) {
  6288. return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()");
  6289. },
  6290. _warn = function _warn(message, suppress) {
  6291. return !suppress && console.warn(message);
  6292. },
  6293. _addGlobal = function _addGlobal(name, obj) {
  6294. return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals;
  6295. },
  6296. _emptyFunc = function _emptyFunc() {
  6297. return 0;
  6298. },
  6299. _startAtRevertConfig = {
  6300. suppressEvents: true,
  6301. isStart: true,
  6302. kill: false
  6303. },
  6304. _revertConfigNoKill = {
  6305. suppressEvents: true,
  6306. kill: false
  6307. },
  6308. _revertConfig = {
  6309. suppressEvents: true
  6310. },
  6311. _reservedProps = {},
  6312. _lazyTweens = [],
  6313. _lazyLookup = {},
  6314. _lastRenderedFrame,
  6315. _plugins = {},
  6316. _effects = {},
  6317. _nextGCFrame = 30,
  6318. _harnessPlugins = [],
  6319. _callbackNames = "",
  6320. _harness = function _harness(targets) {
  6321. var target = targets[0],
  6322. harnessPlugin,
  6323. i;
  6324. _isObject(target) || _isFunction(target) || (targets = [targets]);
  6325. if (!(harnessPlugin = (target._gsap || {}).harness)) {
  6326. i = _harnessPlugins.length;
  6327. while (i-- && !_harnessPlugins[i].targetTest(target)) {}
  6328. harnessPlugin = _harnessPlugins[i];
  6329. }
  6330. i = targets.length;
  6331. while (i--) {
  6332. targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1);
  6333. }
  6334. return targets;
  6335. },
  6336. _getCache = function _getCache(target) {
  6337. return target._gsap || _harness(toArray(target))[0]._gsap;
  6338. },
  6339. _getProperty = function _getProperty(target, property, v) {
  6340. return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v;
  6341. },
  6342. _forEachName = function _forEachName(names, func) {
  6343. return (names = names.split(",")).forEach(func) || names;
  6344. },
  6345. _round = function _round(value) {
  6346. return Math.round(value * 100000) / 100000 || 0;
  6347. },
  6348. _roundPrecise = function _roundPrecise(value) {
  6349. return Math.round(value * 10000000) / 10000000 || 0;
  6350. },
  6351. _parseRelative = function _parseRelative(start, value) {
  6352. var operator = value.charAt(0),
  6353. end = parseFloat(value.substr(2));
  6354. start = parseFloat(start);
  6355. return operator === "+" ? start + end : operator === "-" ? start - end : operator === "*" ? start * end : start / end;
  6356. },
  6357. _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) {
  6358. var l = toFind.length,
  6359. i = 0;
  6360. for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {}
  6361. return i < l;
  6362. },
  6363. _lazyRender = function _lazyRender() {
  6364. var l = _lazyTweens.length,
  6365. a = _lazyTweens.slice(0),
  6366. i,
  6367. tween;
  6368. _lazyLookup = {};
  6369. _lazyTweens.length = 0;
  6370. for (i = 0; i < l; i++) {
  6371. tween = a[i];
  6372. tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0);
  6373. }
  6374. },
  6375. _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) {
  6376. _lazyTweens.length && !_reverting && _lazyRender();
  6377. animation.render(time, suppressEvents, force || _reverting && time < 0 && (animation._initted || animation._startAt));
  6378. _lazyTweens.length && !_reverting && _lazyRender();
  6379. },
  6380. _numericIfPossible = function _numericIfPossible(value) {
  6381. var n = parseFloat(value);
  6382. return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value;
  6383. },
  6384. _passThrough = function _passThrough(p) {
  6385. return p;
  6386. },
  6387. _setDefaults = function _setDefaults(obj, defaults) {
  6388. for (var p in defaults) {
  6389. p in obj || (obj[p] = defaults[p]);
  6390. }
  6391. return obj;
  6392. },
  6393. _setKeyframeDefaults = function _setKeyframeDefaults(excludeDuration) {
  6394. return function (obj, defaults) {
  6395. for (var p in defaults) {
  6396. p in obj || p === "duration" && excludeDuration || p === "ease" || (obj[p] = defaults[p]);
  6397. }
  6398. };
  6399. },
  6400. _merge = function _merge(base, toMerge) {
  6401. for (var p in toMerge) {
  6402. base[p] = toMerge[p];
  6403. }
  6404. return base;
  6405. },
  6406. _mergeDeep = function _mergeDeep(base, toMerge) {
  6407. for (var p in toMerge) {
  6408. p !== "__proto__" && p !== "constructor" && p !== "prototype" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]);
  6409. }
  6410. return base;
  6411. },
  6412. _copyExcluding = function _copyExcluding(obj, excluding) {
  6413. var copy = {},
  6414. p;
  6415. for (p in obj) {
  6416. p in excluding || (copy[p] = obj[p]);
  6417. }
  6418. return copy;
  6419. },
  6420. _inheritDefaults = function _inheritDefaults(vars) {
  6421. var parent = vars.parent || _globalTimeline,
  6422. func = vars.keyframes ? _setKeyframeDefaults(_isArray(vars.keyframes)) : _setDefaults;
  6423. if (_isNotFalse(vars.inherit)) {
  6424. while (parent) {
  6425. func(vars, parent.vars.defaults);
  6426. parent = parent.parent || parent._dp;
  6427. }
  6428. }
  6429. return vars;
  6430. },
  6431. _arraysMatch = function _arraysMatch(a1, a2) {
  6432. var i = a1.length,
  6433. match = i === a2.length;
  6434. while (match && i-- && a1[i] === a2[i]) {}
  6435. return i < 0;
  6436. },
  6437. _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) {
  6438. if (firstProp === void 0) {
  6439. firstProp = "_first";
  6440. }
  6441. if (lastProp === void 0) {
  6442. lastProp = "_last";
  6443. }
  6444. var prev = parent[lastProp],
  6445. t;
  6446. if (sortBy) {
  6447. t = child[sortBy];
  6448. while (prev && prev[sortBy] > t) {
  6449. prev = prev._prev;
  6450. }
  6451. }
  6452. if (prev) {
  6453. child._next = prev._next;
  6454. prev._next = child;
  6455. } else {
  6456. child._next = parent[firstProp];
  6457. parent[firstProp] = child;
  6458. }
  6459. if (child._next) {
  6460. child._next._prev = child;
  6461. } else {
  6462. parent[lastProp] = child;
  6463. }
  6464. child._prev = prev;
  6465. child.parent = child._dp = parent;
  6466. return child;
  6467. },
  6468. _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) {
  6469. if (firstProp === void 0) {
  6470. firstProp = "_first";
  6471. }
  6472. if (lastProp === void 0) {
  6473. lastProp = "_last";
  6474. }
  6475. var prev = child._prev,
  6476. next = child._next;
  6477. if (prev) {
  6478. prev._next = next;
  6479. } else if (parent[firstProp] === child) {
  6480. parent[firstProp] = next;
  6481. }
  6482. if (next) {
  6483. next._prev = prev;
  6484. } else if (parent[lastProp] === child) {
  6485. parent[lastProp] = prev;
  6486. }
  6487. child._next = child._prev = child.parent = null;
  6488. },
  6489. _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) {
  6490. child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove && child.parent.remove(child);
  6491. child._act = 0;
  6492. },
  6493. _uncache = function _uncache(animation, child) {
  6494. if (animation && (!child || child._end > animation._dur || child._start < 0)) {
  6495. var a = animation;
  6496. while (a) {
  6497. a._dirty = 1;
  6498. a = a.parent;
  6499. }
  6500. }
  6501. return animation;
  6502. },
  6503. _recacheAncestors = function _recacheAncestors(animation) {
  6504. var parent = animation.parent;
  6505. while (parent && parent.parent) {
  6506. parent._dirty = 1;
  6507. parent.totalDuration();
  6508. parent = parent.parent;
  6509. }
  6510. return animation;
  6511. },
  6512. _rewindStartAt = function _rewindStartAt(tween, totalTime, suppressEvents, force) {
  6513. return tween._startAt && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween.vars.immediateRender && !tween.vars.autoRevert || tween._startAt.render(totalTime, true, force));
  6514. },
  6515. _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) {
  6516. return !animation || animation._ts && _hasNoPausedAncestors(animation.parent);
  6517. },
  6518. _elapsedCycleDuration = function _elapsedCycleDuration(animation) {
  6519. return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0;
  6520. },
  6521. _animationCycle = function _animationCycle(tTime, cycleDuration) {
  6522. var whole = Math.floor(tTime /= cycleDuration);
  6523. return tTime && whole === tTime ? whole - 1 : whole;
  6524. },
  6525. _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) {
  6526. return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur);
  6527. },
  6528. _setEnd = function _setEnd(animation) {
  6529. return animation._end = _roundPrecise(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0));
  6530. },
  6531. _alignPlayhead = function _alignPlayhead(animation, totalTime) {
  6532. var parent = animation._dp;
  6533. if (parent && parent.smoothChildTiming && animation._ts) {
  6534. animation._start = _roundPrecise(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts));
  6535. _setEnd(animation);
  6536. parent._dirty || _uncache(parent, animation);
  6537. }
  6538. return animation;
  6539. },
  6540. _postAddChecks = function _postAddChecks(timeline, child) {
  6541. var t;
  6542. if (child._time || !child._dur && child._initted || child._start < timeline._time && (child._dur || !child.add)) {
  6543. t = _parentToChildTotalTime(timeline.rawTime(), child);
  6544. if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) {
  6545. child.render(t, true);
  6546. }
  6547. }
  6548. if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) {
  6549. if (timeline._dur < timeline.duration()) {
  6550. t = timeline;
  6551. while (t._dp) {
  6552. t.rawTime() >= 0 && t.totalTime(t._tTime);
  6553. t = t._dp;
  6554. }
  6555. }
  6556. timeline._zTime = -_tinyNum;
  6557. }
  6558. },
  6559. _addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) {
  6560. child.parent && _removeFromParent(child);
  6561. child._start = _roundPrecise((_isNumber(position) ? position : position || timeline !== _globalTimeline ? _parsePosition(timeline, position, child) : timeline._time) + child._delay);
  6562. child._end = _roundPrecise(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0));
  6563. _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0);
  6564. _isFromOrFromStart(child) || (timeline._recent = child);
  6565. skipChecks || _postAddChecks(timeline, child);
  6566. timeline._ts < 0 && _alignPlayhead(timeline, timeline._tTime);
  6567. return timeline;
  6568. },
  6569. _scrollTrigger = function _scrollTrigger(animation, trigger) {
  6570. return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation);
  6571. },
  6572. _attemptInitTween = function _attemptInitTween(tween, time, force, suppressEvents, tTime) {
  6573. _initTween(tween, time, tTime);
  6574. if (!tween._initted) {
  6575. return 1;
  6576. }
  6577. if (!force && tween._pt && !_reverting && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) {
  6578. _lazyTweens.push(tween);
  6579. tween._lazy = [tTime, suppressEvents];
  6580. return 1;
  6581. }
  6582. },
  6583. _parentPlayheadIsBeforeStart = function _parentPlayheadIsBeforeStart(_ref) {
  6584. var parent = _ref.parent;
  6585. return parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent));
  6586. },
  6587. _isFromOrFromStart = function _isFromOrFromStart(_ref2) {
  6588. var data = _ref2.data;
  6589. return data === "isFromStart" || data === "isStart";
  6590. },
  6591. _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) {
  6592. var prevRatio = tween.ratio,
  6593. ratio = totalTime < 0 || !totalTime && (!tween._start && _parentPlayheadIsBeforeStart(tween) && !(!tween._initted && _isFromOrFromStart(tween)) || (tween._ts < 0 || tween._dp._ts < 0) && !_isFromOrFromStart(tween)) ? 0 : 1,
  6594. repeatDelay = tween._rDelay,
  6595. tTime = 0,
  6596. pt,
  6597. iteration,
  6598. prevIteration;
  6599. if (repeatDelay && tween._repeat) {
  6600. tTime = _clamp(0, tween._tDur, totalTime);
  6601. iteration = _animationCycle(tTime, repeatDelay);
  6602. tween._yoyo && iteration & 1 && (ratio = 1 - ratio);
  6603. if (iteration !== _animationCycle(tween._tTime, repeatDelay)) {
  6604. prevRatio = 1 - ratio;
  6605. tween.vars.repeatRefresh && tween._initted && tween.invalidate();
  6606. }
  6607. }
  6608. if (ratio !== prevRatio || _reverting || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) {
  6609. if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents, tTime)) {
  6610. return;
  6611. }
  6612. prevIteration = tween._zTime;
  6613. tween._zTime = totalTime || (suppressEvents ? _tinyNum : 0);
  6614. suppressEvents || (suppressEvents = totalTime && !prevIteration);
  6615. tween.ratio = ratio;
  6616. tween._from && (ratio = 1 - ratio);
  6617. tween._time = 0;
  6618. tween._tTime = tTime;
  6619. pt = tween._pt;
  6620. while (pt) {
  6621. pt.r(ratio, pt.d);
  6622. pt = pt._next;
  6623. }
  6624. totalTime < 0 && _rewindStartAt(tween, totalTime, suppressEvents, true);
  6625. tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate");
  6626. tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat");
  6627. if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) {
  6628. ratio && _removeFromParent(tween, 1);
  6629. if (!suppressEvents && !_reverting) {
  6630. _callback(tween, ratio ? "onComplete" : "onReverseComplete", true);
  6631. tween._prom && tween._prom();
  6632. }
  6633. }
  6634. } else if (!tween._zTime) {
  6635. tween._zTime = totalTime;
  6636. }
  6637. },
  6638. _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) {
  6639. var child;
  6640. if (time > prevTime) {
  6641. child = animation._first;
  6642. while (child && child._start <= time) {
  6643. if (child.data === "isPause" && child._start > prevTime) {
  6644. return child;
  6645. }
  6646. child = child._next;
  6647. }
  6648. } else {
  6649. child = animation._last;
  6650. while (child && child._start >= time) {
  6651. if (child.data === "isPause" && child._start < prevTime) {
  6652. return child;
  6653. }
  6654. child = child._prev;
  6655. }
  6656. }
  6657. },
  6658. _setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) {
  6659. var repeat = animation._repeat,
  6660. dur = _roundPrecise(duration) || 0,
  6661. totalProgress = animation._tTime / animation._tDur;
  6662. totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur);
  6663. animation._dur = dur;
  6664. animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _roundPrecise(dur * (repeat + 1) + animation._rDelay * repeat);
  6665. totalProgress > 0 && !leavePlayhead && _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress);
  6666. animation.parent && _setEnd(animation);
  6667. skipUncache || _uncache(animation.parent, animation);
  6668. return animation;
  6669. },
  6670. _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) {
  6671. return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur);
  6672. },
  6673. _zeroPosition = {
  6674. _start: 0,
  6675. endTime: _emptyFunc,
  6676. totalDuration: _emptyFunc
  6677. },
  6678. _parsePosition = function _parsePosition(animation, position, percentAnimation) {
  6679. var labels = animation.labels,
  6680. recent = animation._recent || _zeroPosition,
  6681. clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur,
  6682. i,
  6683. offset,
  6684. isPercent;
  6685. if (_isString(position) && (isNaN(position) || position in labels)) {
  6686. offset = position.charAt(0);
  6687. isPercent = position.substr(-1) === "%";
  6688. i = position.indexOf("=");
  6689. if (offset === "<" || offset === ">") {
  6690. i >= 0 && (position = position.replace(/=/, ""));
  6691. return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1);
  6692. }
  6693. if (i < 0) {
  6694. position in labels || (labels[position] = clippedDuration);
  6695. return labels[position];
  6696. }
  6697. offset = parseFloat(position.charAt(i - 1) + position.substr(i + 1));
  6698. if (isPercent && percentAnimation) {
  6699. offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration();
  6700. }
  6701. return i > 1 ? _parsePosition(animation, position.substr(0, i - 1), percentAnimation) + offset : clippedDuration + offset;
  6702. }
  6703. return position == null ? clippedDuration : +position;
  6704. },
  6705. _createTweenType = function _createTweenType(type, params, timeline) {
  6706. var isLegacy = _isNumber(params[1]),
  6707. varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),
  6708. vars = params[varsIndex],
  6709. irVars,
  6710. parent;
  6711. isLegacy && (vars.duration = params[1]);
  6712. vars.parent = timeline;
  6713. if (type) {
  6714. irVars = vars;
  6715. parent = timeline;
  6716. while (parent && !("immediateRender" in irVars)) {
  6717. irVars = parent.vars.defaults || {};
  6718. parent = _isNotFalse(parent.vars.inherit) && parent.parent;
  6719. }
  6720. vars.immediateRender = _isNotFalse(irVars.immediateRender);
  6721. type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1];
  6722. }
  6723. return new Tween(params[0], vars, params[varsIndex + 1]);
  6724. },
  6725. _conditionalReturn = function _conditionalReturn(value, func) {
  6726. return value || value === 0 ? func(value) : func;
  6727. },
  6728. _clamp = function _clamp(min, max, value) {
  6729. return value < min ? min : value > max ? max : value;
  6730. },
  6731. getUnit = function getUnit(value, v) {
  6732. return !_isString(value) || !(v = _unitExp.exec(value)) ? "" : v[1];
  6733. },
  6734. clamp = function clamp(min, max, value) {
  6735. return _conditionalReturn(value, function (v) {
  6736. return _clamp(min, max, v);
  6737. });
  6738. },
  6739. _slice = [].slice,
  6740. _isArrayLike = function _isArrayLike(value, nonEmpty) {
  6741. return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win;
  6742. },
  6743. _flatten = function _flatten(ar, leaveStrings, accumulator) {
  6744. if (accumulator === void 0) {
  6745. accumulator = [];
  6746. }
  6747. return ar.forEach(function (value) {
  6748. var _accumulator;
  6749. return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value);
  6750. }) || accumulator;
  6751. },
  6752. toArray = function toArray(value, scope, leaveStrings) {
  6753. return _context && !scope && _context.selector ? _context.selector(value) : _isString(value) && !leaveStrings && (_coreInitted || !_wake()) ? _slice.call((scope || _doc).querySelectorAll(value), 0) : _isArray(value) ? _flatten(value, leaveStrings) : _isArrayLike(value) ? _slice.call(value, 0) : value ? [value] : [];
  6754. },
  6755. selector = function selector(value) {
  6756. value = toArray(value)[0] || _warn("Invalid scope") || {};
  6757. return function (v) {
  6758. var el = value.current || value.nativeElement || value;
  6759. return toArray(v, el.querySelectorAll ? el : el === value ? _warn("Invalid scope") || _doc.createElement("div") : value);
  6760. };
  6761. },
  6762. shuffle = function shuffle(a) {
  6763. return a.sort(function () {
  6764. return .5 - Math.random();
  6765. });
  6766. },
  6767. distribute = function distribute(v) {
  6768. if (_isFunction(v)) {
  6769. return v;
  6770. }
  6771. var vars = _isObject(v) ? v : {
  6772. each: v
  6773. },
  6774. ease = _parseEase(vars.ease),
  6775. from = vars.from || 0,
  6776. base = parseFloat(vars.base) || 0,
  6777. cache = {},
  6778. isDecimal = from > 0 && from < 1,
  6779. ratios = isNaN(from) || isDecimal,
  6780. axis = vars.axis,
  6781. ratioX = from,
  6782. ratioY = from;
  6783. if (_isString(from)) {
  6784. ratioX = ratioY = {
  6785. center: .5,
  6786. edges: .5,
  6787. end: 1
  6788. }[from] || 0;
  6789. } else if (!isDecimal && ratios) {
  6790. ratioX = from[0];
  6791. ratioY = from[1];
  6792. }
  6793. return function (i, target, a) {
  6794. var l = (a || vars).length,
  6795. distances = cache[l],
  6796. originX,
  6797. originY,
  6798. x,
  6799. y,
  6800. d,
  6801. j,
  6802. max,
  6803. min,
  6804. wrapAt;
  6805. if (!distances) {
  6806. wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1];
  6807. if (!wrapAt) {
  6808. max = -_bigNum;
  6809. while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {}
  6810. wrapAt < l && wrapAt--;
  6811. }
  6812. distances = cache[l] = [];
  6813. originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt;
  6814. originY = wrapAt === _bigNum ? 0 : ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0;
  6815. max = 0;
  6816. min = _bigNum;
  6817. for (j = 0; j < l; j++) {
  6818. x = j % wrapAt - originX;
  6819. y = originY - (j / wrapAt | 0);
  6820. distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x);
  6821. d > max && (max = d);
  6822. d < min && (min = d);
  6823. }
  6824. from === "random" && shuffle(distances);
  6825. distances.max = max - min;
  6826. distances.min = min;
  6827. distances.v = l = (parseFloat(vars.amount) || parseFloat(vars.each) * (wrapAt > l ? l - 1 : !axis ? Math.max(wrapAt, l / wrapAt) : axis === "y" ? l / wrapAt : wrapAt) || 0) * (from === "edges" ? -1 : 1);
  6828. distances.b = l < 0 ? base - l : base;
  6829. distances.u = getUnit(vars.amount || vars.each) || 0;
  6830. ease = ease && l < 0 ? _invertEase(ease) : ease;
  6831. }
  6832. l = (distances[i] - distances.min) / distances.max || 0;
  6833. return _roundPrecise(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u;
  6834. };
  6835. },
  6836. _roundModifier = function _roundModifier(v) {
  6837. var p = Math.pow(10, ((v + "").split(".")[1] || "").length);
  6838. return function (raw) {
  6839. var n = _roundPrecise(Math.round(parseFloat(raw) / v) * v * p);
  6840. return (n - n % 1) / p + (_isNumber(raw) ? 0 : getUnit(raw));
  6841. };
  6842. },
  6843. snap = function snap(snapTo, value) {
  6844. var isArray = _isArray(snapTo),
  6845. radius,
  6846. is2D;
  6847. if (!isArray && _isObject(snapTo)) {
  6848. radius = isArray = snapTo.radius || _bigNum;
  6849. if (snapTo.values) {
  6850. snapTo = toArray(snapTo.values);
  6851. if (is2D = !_isNumber(snapTo[0])) {
  6852. radius *= radius;
  6853. }
  6854. } else {
  6855. snapTo = _roundModifier(snapTo.increment);
  6856. }
  6857. }
  6858. return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) {
  6859. is2D = snapTo(raw);
  6860. return Math.abs(is2D - raw) <= radius ? is2D : raw;
  6861. } : function (raw) {
  6862. var x = parseFloat(is2D ? raw.x : raw),
  6863. y = parseFloat(is2D ? raw.y : 0),
  6864. min = _bigNum,
  6865. closest = 0,
  6866. i = snapTo.length,
  6867. dx,
  6868. dy;
  6869. while (i--) {
  6870. if (is2D) {
  6871. dx = snapTo[i].x - x;
  6872. dy = snapTo[i].y - y;
  6873. dx = dx * dx + dy * dy;
  6874. } else {
  6875. dx = Math.abs(snapTo[i] - x);
  6876. }
  6877. if (dx < min) {
  6878. min = dx;
  6879. closest = i;
  6880. }
  6881. }
  6882. closest = !radius || min <= radius ? snapTo[closest] : raw;
  6883. return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw);
  6884. });
  6885. },
  6886. random = function random(min, max, roundingIncrement, returnFunction) {
  6887. return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () {
  6888. return _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e-5) && (returnFunction = roundingIncrement < 1 ? Math.pow(10, (roundingIncrement + "").length - 2) : 1) && Math.floor(Math.round((min - roundingIncrement / 2 + Math.random() * (max - min + roundingIncrement * .99)) / roundingIncrement) * roundingIncrement * returnFunction) / returnFunction;
  6889. });
  6890. },
  6891. pipe = function pipe() {
  6892. for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
  6893. functions[_key] = arguments[_key];
  6894. }
  6895. return function (value) {
  6896. return functions.reduce(function (v, f) {
  6897. return f(v);
  6898. }, value);
  6899. };
  6900. },
  6901. unitize = function unitize(func, unit) {
  6902. return function (value) {
  6903. return func(parseFloat(value)) + (unit || getUnit(value));
  6904. };
  6905. },
  6906. normalize = function normalize(min, max, value) {
  6907. return mapRange(min, max, 0, 1, value);
  6908. },
  6909. _wrapArray = function _wrapArray(a, wrapper, value) {
  6910. return _conditionalReturn(value, function (index) {
  6911. return a[~~wrapper(index)];
  6912. });
  6913. },
  6914. wrap = function wrap(min, max, value) {
  6915. var range = max - min;
  6916. return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) {
  6917. return (range + (value - min) % range) % range + min;
  6918. });
  6919. },
  6920. wrapYoyo = function wrapYoyo(min, max, value) {
  6921. var range = max - min,
  6922. total = range * 2;
  6923. return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) {
  6924. value = (total + (value - min) % total) % total || 0;
  6925. return min + (value > range ? total - value : value);
  6926. });
  6927. },
  6928. _replaceRandom = function _replaceRandom(value) {
  6929. var prev = 0,
  6930. s = "",
  6931. i,
  6932. nums,
  6933. end,
  6934. isArray;
  6935. while (~(i = value.indexOf("random(", prev))) {
  6936. end = value.indexOf(")", i);
  6937. isArray = value.charAt(i + 7) === "[";
  6938. nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp);
  6939. s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5);
  6940. prev = end + 1;
  6941. }
  6942. return s + value.substr(prev, value.length - prev);
  6943. },
  6944. mapRange = function mapRange(inMin, inMax, outMin, outMax, value) {
  6945. var inRange = inMax - inMin,
  6946. outRange = outMax - outMin;
  6947. return _conditionalReturn(value, function (value) {
  6948. return outMin + ((value - inMin) / inRange * outRange || 0);
  6949. });
  6950. },
  6951. interpolate = function interpolate(start, end, progress, mutate) {
  6952. var func = isNaN(start + end) ? 0 : function (p) {
  6953. return (1 - p) * start + p * end;
  6954. };
  6955. if (!func) {
  6956. var isString = _isString(start),
  6957. master = {},
  6958. p,
  6959. i,
  6960. interpolators,
  6961. l,
  6962. il;
  6963. progress === true && (mutate = 1) && (progress = null);
  6964. if (isString) {
  6965. start = {
  6966. p: start
  6967. };
  6968. end = {
  6969. p: end
  6970. };
  6971. } else if (_isArray(start) && !_isArray(end)) {
  6972. interpolators = [];
  6973. l = start.length;
  6974. il = l - 2;
  6975. for (i = 1; i < l; i++) {
  6976. interpolators.push(interpolate(start[i - 1], start[i]));
  6977. }
  6978. l--;
  6979. func = function func(p) {
  6980. p *= l;
  6981. var i = Math.min(il, ~~p);
  6982. return interpolators[i](p - i);
  6983. };
  6984. progress = end;
  6985. } else if (!mutate) {
  6986. start = _merge(_isArray(start) ? [] : {}, start);
  6987. }
  6988. if (!interpolators) {
  6989. for (p in end) {
  6990. _addPropTween.call(master, start, p, "get", end[p]);
  6991. }
  6992. func = function func(p) {
  6993. return _renderPropTweens(p, master) || (isString ? start.p : start);
  6994. };
  6995. }
  6996. }
  6997. return _conditionalReturn(progress, func);
  6998. },
  6999. _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) {
  7000. var labels = timeline.labels,
  7001. min = _bigNum,
  7002. p,
  7003. distance,
  7004. label;
  7005. for (p in labels) {
  7006. distance = labels[p] - fromTime;
  7007. if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) {
  7008. label = p;
  7009. min = distance;
  7010. }
  7011. }
  7012. return label;
  7013. },
  7014. _callback = function _callback(animation, type, executeLazyFirst) {
  7015. var v = animation.vars,
  7016. callback = v[type],
  7017. prevContext = _context,
  7018. context = animation._ctx,
  7019. params,
  7020. scope,
  7021. result;
  7022. if (!callback) {
  7023. return;
  7024. }
  7025. params = v[type + "Params"];
  7026. scope = v.callbackScope || animation;
  7027. executeLazyFirst && _lazyTweens.length && _lazyRender();
  7028. context && (_context = context);
  7029. result = params ? callback.apply(scope, params) : callback.call(scope);
  7030. _context = prevContext;
  7031. return result;
  7032. },
  7033. _interrupt = function _interrupt(animation) {
  7034. _removeFromParent(animation);
  7035. animation.scrollTrigger && animation.scrollTrigger.kill(!!_reverting);
  7036. animation.progress() < 1 && _callback(animation, "onInterrupt");
  7037. return animation;
  7038. },
  7039. _quickTween,
  7040. _registerPluginQueue = [],
  7041. _createPlugin = function _createPlugin(config) {
  7042. if (_windowExists() && config) {
  7043. config = !config.name && config["default"] || config;
  7044. var name = config.name,
  7045. isFunc = _isFunction(config),
  7046. Plugin = name && !isFunc && config.init ? function () {
  7047. this._props = [];
  7048. } : config,
  7049. instanceDefaults = {
  7050. init: _emptyFunc,
  7051. render: _renderPropTweens,
  7052. add: _addPropTween,
  7053. kill: _killPropTweensOf,
  7054. modifier: _addPluginModifier,
  7055. rawVars: 0
  7056. },
  7057. statics = {
  7058. targetTest: 0,
  7059. get: 0,
  7060. getSetter: _getSetter,
  7061. aliases: {},
  7062. register: 0
  7063. };
  7064. _wake();
  7065. if (config !== Plugin) {
  7066. if (_plugins[name]) {
  7067. return;
  7068. }
  7069. _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics));
  7070. _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics)));
  7071. _plugins[Plugin.prop = name] = Plugin;
  7072. if (config.targetTest) {
  7073. _harnessPlugins.push(Plugin);
  7074. _reservedProps[name] = 1;
  7075. }
  7076. name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin";
  7077. }
  7078. _addGlobal(name, Plugin);
  7079. config.register && config.register(gsap, Plugin, PropTween);
  7080. } else {
  7081. config && _registerPluginQueue.push(config);
  7082. }
  7083. },
  7084. _255 = 255,
  7085. _colorLookup = {
  7086. aqua: [0, _255, _255],
  7087. lime: [0, _255, 0],
  7088. silver: [192, 192, 192],
  7089. black: [0, 0, 0],
  7090. maroon: [128, 0, 0],
  7091. teal: [0, 128, 128],
  7092. blue: [0, 0, _255],
  7093. navy: [0, 0, 128],
  7094. white: [_255, _255, _255],
  7095. olive: [128, 128, 0],
  7096. yellow: [_255, _255, 0],
  7097. orange: [_255, 165, 0],
  7098. gray: [128, 128, 128],
  7099. purple: [128, 0, 128],
  7100. green: [0, 128, 0],
  7101. red: [_255, 0, 0],
  7102. pink: [_255, 192, 203],
  7103. cyan: [0, _255, _255],
  7104. transparent: [_255, _255, _255, 0]
  7105. },
  7106. _hue = function _hue(h, m1, m2) {
  7107. h += h < 0 ? 1 : h > 1 ? -1 : 0;
  7108. return (h * 6 < 1 ? m1 + (m2 - m1) * h * 6 : h < .5 ? m2 : h * 3 < 2 ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * _255 + .5 | 0;
  7109. },
  7110. splitColor = function splitColor(v, toHSL, forceAlpha) {
  7111. var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0,
  7112. r,
  7113. g,
  7114. b,
  7115. h,
  7116. s,
  7117. l,
  7118. max,
  7119. min,
  7120. d,
  7121. wasHSL;
  7122. if (!a) {
  7123. if (v.substr(-1) === ",") {
  7124. v = v.substr(0, v.length - 1);
  7125. }
  7126. if (_colorLookup[v]) {
  7127. a = _colorLookup[v];
  7128. } else if (v.charAt(0) === "#") {
  7129. if (v.length < 6) {
  7130. r = v.charAt(1);
  7131. g = v.charAt(2);
  7132. b = v.charAt(3);
  7133. v = "#" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : "");
  7134. }
  7135. if (v.length === 9) {
  7136. a = parseInt(v.substr(1, 6), 16);
  7137. return [a >> 16, a >> 8 & _255, a & _255, parseInt(v.substr(7), 16) / 255];
  7138. }
  7139. v = parseInt(v.substr(1), 16);
  7140. a = [v >> 16, v >> 8 & _255, v & _255];
  7141. } else if (v.substr(0, 3) === "hsl") {
  7142. a = wasHSL = v.match(_strictNumExp);
  7143. if (!toHSL) {
  7144. h = +a[0] % 360 / 360;
  7145. s = +a[1] / 100;
  7146. l = +a[2] / 100;
  7147. g = l <= .5 ? l * (s + 1) : l + s - l * s;
  7148. r = l * 2 - g;
  7149. a.length > 3 && (a[3] *= 1);
  7150. a[0] = _hue(h + 1 / 3, r, g);
  7151. a[1] = _hue(h, r, g);
  7152. a[2] = _hue(h - 1 / 3, r, g);
  7153. } else if (~v.indexOf("=")) {
  7154. a = v.match(_numExp);
  7155. forceAlpha && a.length < 4 && (a[3] = 1);
  7156. return a;
  7157. }
  7158. } else {
  7159. a = v.match(_strictNumExp) || _colorLookup.transparent;
  7160. }
  7161. a = a.map(Number);
  7162. }
  7163. if (toHSL && !wasHSL) {
  7164. r = a[0] / _255;
  7165. g = a[1] / _255;
  7166. b = a[2] / _255;
  7167. max = Math.max(r, g, b);
  7168. min = Math.min(r, g, b);
  7169. l = (max + min) / 2;
  7170. if (max === min) {
  7171. h = s = 0;
  7172. } else {
  7173. d = max - min;
  7174. s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
  7175. h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
  7176. h *= 60;
  7177. }
  7178. a[0] = ~~(h + .5);
  7179. a[1] = ~~(s * 100 + .5);
  7180. a[2] = ~~(l * 100 + .5);
  7181. }
  7182. forceAlpha && a.length < 4 && (a[3] = 1);
  7183. return a;
  7184. },
  7185. _colorOrderData = function _colorOrderData(v) {
  7186. var values = [],
  7187. c = [],
  7188. i = -1;
  7189. v.split(_colorExp).forEach(function (v) {
  7190. var a = v.match(_numWithUnitExp) || [];
  7191. values.push.apply(values, a);
  7192. c.push(i += a.length + 1);
  7193. });
  7194. values.c = c;
  7195. return values;
  7196. },
  7197. _formatColors = function _formatColors(s, toHSL, orderMatchData) {
  7198. var result = "",
  7199. colors = (s + result).match(_colorExp),
  7200. type = toHSL ? "hsla(" : "rgba(",
  7201. i = 0,
  7202. c,
  7203. shell,
  7204. d,
  7205. l;
  7206. if (!colors) {
  7207. return s;
  7208. }
  7209. colors = colors.map(function (color) {
  7210. return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")";
  7211. });
  7212. if (orderMatchData) {
  7213. d = _colorOrderData(s);
  7214. c = orderMatchData.c;
  7215. if (c.join(result) !== d.c.join(result)) {
  7216. shell = s.replace(_colorExp, "1").split(_numWithUnitExp);
  7217. l = shell.length - 1;
  7218. for (; i < l; i++) {
  7219. result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift());
  7220. }
  7221. }
  7222. }
  7223. if (!shell) {
  7224. shell = s.split(_colorExp);
  7225. l = shell.length - 1;
  7226. for (; i < l; i++) {
  7227. result += shell[i] + colors[i];
  7228. }
  7229. }
  7230. return result + shell[l];
  7231. },
  7232. _colorExp = function () {
  7233. var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b",
  7234. p;
  7235. for (p in _colorLookup) {
  7236. s += "|" + p + "\\b";
  7237. }
  7238. return new RegExp(s + ")", "gi");
  7239. }(),
  7240. _hslExp = /hsl[a]?\(/,
  7241. _colorStringFilter = function _colorStringFilter(a) {
  7242. var combined = a.join(" "),
  7243. toHSL;
  7244. _colorExp.lastIndex = 0;
  7245. if (_colorExp.test(combined)) {
  7246. toHSL = _hslExp.test(combined);
  7247. a[1] = _formatColors(a[1], toHSL);
  7248. a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1]));
  7249. return true;
  7250. }
  7251. },
  7252. _tickerActive,
  7253. _ticker = function () {
  7254. var _getTime = Date.now,
  7255. _lagThreshold = 500,
  7256. _adjustedLag = 33,
  7257. _startTime = _getTime(),
  7258. _lastUpdate = _startTime,
  7259. _gap = 1000 / 240,
  7260. _nextTime = _gap,
  7261. _listeners = [],
  7262. _id,
  7263. _req,
  7264. _raf,
  7265. _self,
  7266. _delta,
  7267. _i,
  7268. _tick = function _tick(v) {
  7269. var elapsed = _getTime() - _lastUpdate,
  7270. manual = v === true,
  7271. overlap,
  7272. dispatch,
  7273. time,
  7274. frame;
  7275. elapsed > _lagThreshold && (_startTime += elapsed - _adjustedLag);
  7276. _lastUpdate += elapsed;
  7277. time = _lastUpdate - _startTime;
  7278. overlap = time - _nextTime;
  7279. if (overlap > 0 || manual) {
  7280. frame = ++_self.frame;
  7281. _delta = time - _self.time * 1000;
  7282. _self.time = time = time / 1000;
  7283. _nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap);
  7284. dispatch = 1;
  7285. }
  7286. manual || (_id = _req(_tick));
  7287. if (dispatch) {
  7288. for (_i = 0; _i < _listeners.length; _i++) {
  7289. _listeners[_i](time, _delta, frame, v);
  7290. }
  7291. }
  7292. };
  7293. _self = {
  7294. time: 0,
  7295. frame: 0,
  7296. tick: function tick() {
  7297. _tick(true);
  7298. },
  7299. deltaRatio: function deltaRatio(fps) {
  7300. return _delta / (1000 / (fps || 60));
  7301. },
  7302. wake: function wake() {
  7303. if (_coreReady) {
  7304. if (!_coreInitted && _windowExists()) {
  7305. _win = _coreInitted = window;
  7306. _doc = _win.document || {};
  7307. _globals.gsap = gsap;
  7308. (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version);
  7309. _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {});
  7310. _raf = _win.requestAnimationFrame;
  7311. _registerPluginQueue.forEach(_createPlugin);
  7312. }
  7313. _id && _self.sleep();
  7314. _req = _raf || function (f) {
  7315. return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0);
  7316. };
  7317. _tickerActive = 1;
  7318. _tick(2);
  7319. }
  7320. },
  7321. sleep: function sleep() {
  7322. (_raf ? _win.cancelAnimationFrame : clearTimeout)(_id);
  7323. _tickerActive = 0;
  7324. _req = _emptyFunc;
  7325. },
  7326. lagSmoothing: function lagSmoothing(threshold, adjustedLag) {
  7327. _lagThreshold = threshold || Infinity;
  7328. _adjustedLag = Math.min(adjustedLag || 33, _lagThreshold);
  7329. },
  7330. fps: function fps(_fps) {
  7331. _gap = 1000 / (_fps || 240);
  7332. _nextTime = _self.time * 1000 + _gap;
  7333. },
  7334. add: function add(callback, once, prioritize) {
  7335. var func = once ? function (t, d, f, v) {
  7336. callback(t, d, f, v);
  7337. _self.remove(func);
  7338. } : callback;
  7339. _self.remove(callback);
  7340. _listeners[prioritize ? "unshift" : "push"](func);
  7341. _wake();
  7342. return func;
  7343. },
  7344. remove: function remove(callback, i) {
  7345. ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--;
  7346. },
  7347. _listeners: _listeners
  7348. };
  7349. return _self;
  7350. }(),
  7351. _wake = function _wake() {
  7352. return !_tickerActive && _ticker.wake();
  7353. },
  7354. _easeMap = {},
  7355. _customEaseExp = /^[\d.\-M][\d.\-,\s]/,
  7356. _quotesExp = /["']/g,
  7357. _parseObjectInString = function _parseObjectInString(value) {
  7358. var obj = {},
  7359. split = value.substr(1, value.length - 3).split(":"),
  7360. key = split[0],
  7361. i = 1,
  7362. l = split.length,
  7363. index,
  7364. val,
  7365. parsedVal;
  7366. for (; i < l; i++) {
  7367. val = split[i];
  7368. index = i !== l - 1 ? val.lastIndexOf(",") : val.length;
  7369. parsedVal = val.substr(0, index);
  7370. obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal;
  7371. key = val.substr(index + 1).trim();
  7372. }
  7373. return obj;
  7374. },
  7375. _valueInParentheses = function _valueInParentheses(value) {
  7376. var open = value.indexOf("(") + 1,
  7377. close = value.indexOf(")"),
  7378. nested = value.indexOf("(", open);
  7379. return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close);
  7380. },
  7381. _configEaseFromString = function _configEaseFromString(name) {
  7382. var split = (name + "").split("("),
  7383. ease = _easeMap[split[0]];
  7384. return ease && split.length > 1 && ease.config ? ease.config.apply(null, ~name.indexOf("{") ? [_parseObjectInString(split[1])] : _valueInParentheses(name).split(",").map(_numericIfPossible)) : _easeMap._CE && _customEaseExp.test(name) ? _easeMap._CE("", name) : ease;
  7385. },
  7386. _invertEase = function _invertEase(ease) {
  7387. return function (p) {
  7388. return 1 - ease(1 - p);
  7389. };
  7390. },
  7391. _propagateYoyoEase = function _propagateYoyoEase(timeline, isYoyo) {
  7392. var child = timeline._first,
  7393. ease;
  7394. while (child) {
  7395. if (child instanceof Timeline) {
  7396. _propagateYoyoEase(child, isYoyo);
  7397. } else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) {
  7398. if (child.timeline) {
  7399. _propagateYoyoEase(child.timeline, isYoyo);
  7400. } else {
  7401. ease = child._ease;
  7402. child._ease = child._yEase;
  7403. child._yEase = ease;
  7404. child._yoyo = isYoyo;
  7405. }
  7406. }
  7407. child = child._next;
  7408. }
  7409. },
  7410. _parseEase = function _parseEase(ease, defaultEase) {
  7411. return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase;
  7412. },
  7413. _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) {
  7414. if (easeOut === void 0) {
  7415. easeOut = function easeOut(p) {
  7416. return 1 - easeIn(1 - p);
  7417. };
  7418. }
  7419. if (easeInOut === void 0) {
  7420. easeInOut = function easeInOut(p) {
  7421. return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2;
  7422. };
  7423. }
  7424. var ease = {
  7425. easeIn: easeIn,
  7426. easeOut: easeOut,
  7427. easeInOut: easeInOut
  7428. },
  7429. lowercaseName;
  7430. _forEachName(names, function (name) {
  7431. _easeMap[name] = _globals[name] = ease;
  7432. _easeMap[lowercaseName = name.toLowerCase()] = easeOut;
  7433. for (var p in ease) {
  7434. _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p];
  7435. }
  7436. });
  7437. return ease;
  7438. },
  7439. _easeInOutFromOut = function _easeInOutFromOut(easeOut) {
  7440. return function (p) {
  7441. return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2;
  7442. };
  7443. },
  7444. _configElastic = function _configElastic(type, amplitude, period) {
  7445. var p1 = amplitude >= 1 ? amplitude : 1,
  7446. p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1),
  7447. p3 = p2 / _2PI * (Math.asin(1 / p1) || 0),
  7448. easeOut = function easeOut(p) {
  7449. return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1;
  7450. },
  7451. ease = type === "out" ? easeOut : type === "in" ? function (p) {
  7452. return 1 - easeOut(1 - p);
  7453. } : _easeInOutFromOut(easeOut);
  7454. p2 = _2PI / p2;
  7455. ease.config = function (amplitude, period) {
  7456. return _configElastic(type, amplitude, period);
  7457. };
  7458. return ease;
  7459. },
  7460. _configBack = function _configBack(type, overshoot) {
  7461. if (overshoot === void 0) {
  7462. overshoot = 1.70158;
  7463. }
  7464. var easeOut = function easeOut(p) {
  7465. return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0;
  7466. },
  7467. ease = type === "out" ? easeOut : type === "in" ? function (p) {
  7468. return 1 - easeOut(1 - p);
  7469. } : _easeInOutFromOut(easeOut);
  7470. ease.config = function (overshoot) {
  7471. return _configBack(type, overshoot);
  7472. };
  7473. return ease;
  7474. };
  7475. _forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) {
  7476. var power = i < 5 ? i + 1 : i;
  7477. _insertEase(name + ",Power" + (power - 1), i ? function (p) {
  7478. return Math.pow(p, power);
  7479. } : function (p) {
  7480. return p;
  7481. }, function (p) {
  7482. return 1 - Math.pow(1 - p, power);
  7483. }, function (p) {
  7484. return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2;
  7485. });
  7486. });
  7487. _easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn;
  7488. _insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic());
  7489. (function (n, c) {
  7490. var n1 = 1 / c,
  7491. n2 = 2 * n1,
  7492. n3 = 2.5 * n1,
  7493. easeOut = function easeOut(p) {
  7494. return p < n1 ? n * p * p : p < n2 ? n * Math.pow(p - 1.5 / c, 2) + .75 : p < n3 ? n * (p -= 2.25 / c) * p + .9375 : n * Math.pow(p - 2.625 / c, 2) + .984375;
  7495. };
  7496. _insertEase("Bounce", function (p) {
  7497. return 1 - easeOut(1 - p);
  7498. }, easeOut);
  7499. })(7.5625, 2.75);
  7500. _insertEase("Expo", function (p) {
  7501. return p ? Math.pow(2, 10 * (p - 1)) : 0;
  7502. });
  7503. _insertEase("Circ", function (p) {
  7504. return -(_sqrt(1 - p * p) - 1);
  7505. });
  7506. _insertEase("Sine", function (p) {
  7507. return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1;
  7508. });
  7509. _insertEase("Back", _configBack("in"), _configBack("out"), _configBack());
  7510. _easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = {
  7511. config: function config(steps, immediateStart) {
  7512. if (steps === void 0) {
  7513. steps = 1;
  7514. }
  7515. var p1 = 1 / steps,
  7516. p2 = steps + (immediateStart ? 0 : 1),
  7517. p3 = immediateStart ? 1 : 0,
  7518. max = 1 - _tinyNum;
  7519. return function (p) {
  7520. return ((p2 * _clamp(0, max, p) | 0) + p3) * p1;
  7521. };
  7522. }
  7523. };
  7524. _defaults.ease = _easeMap["quad.out"];
  7525. _forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) {
  7526. return _callbackNames += name + "," + name + "Params,";
  7527. });
  7528. var GSCache = function GSCache(target, harness) {
  7529. this.id = _gsID++;
  7530. target._gsap = this;
  7531. this.target = target;
  7532. this.harness = harness;
  7533. this.get = harness ? harness.get : _getProperty;
  7534. this.set = harness ? harness.getSetter : _getSetter;
  7535. };
  7536. var Animation = function () {
  7537. function Animation(vars) {
  7538. this.vars = vars;
  7539. this._delay = +vars.delay || 0;
  7540. if (this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0) {
  7541. this._rDelay = vars.repeatDelay || 0;
  7542. this._yoyo = !!vars.yoyo || !!vars.yoyoEase;
  7543. }
  7544. this._ts = 1;
  7545. _setDuration(this, +vars.duration, 1, 1);
  7546. this.data = vars.data;
  7547. if (_context) {
  7548. this._ctx = _context;
  7549. _context.data.push(this);
  7550. }
  7551. _tickerActive || _ticker.wake();
  7552. }
  7553. var _proto = Animation.prototype;
  7554. _proto.delay = function delay(value) {
  7555. if (value || value === 0) {
  7556. this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay);
  7557. this._delay = value;
  7558. return this;
  7559. }
  7560. return this._delay;
  7561. };
  7562. _proto.duration = function duration(value) {
  7563. return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur;
  7564. };
  7565. _proto.totalDuration = function totalDuration(value) {
  7566. if (!arguments.length) {
  7567. return this._tDur;
  7568. }
  7569. this._dirty = 0;
  7570. return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1));
  7571. };
  7572. _proto.totalTime = function totalTime(_totalTime, suppressEvents) {
  7573. _wake();
  7574. if (!arguments.length) {
  7575. return this._tTime;
  7576. }
  7577. var parent = this._dp;
  7578. if (parent && parent.smoothChildTiming && this._ts) {
  7579. _alignPlayhead(this, _totalTime);
  7580. !parent._dp || parent.parent || _postAddChecks(parent, this);
  7581. while (parent && parent.parent) {
  7582. if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) {
  7583. parent.totalTime(parent._tTime, true);
  7584. }
  7585. parent = parent.parent;
  7586. }
  7587. if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) {
  7588. _addToTimeline(this._dp, this, this._start - this._delay);
  7589. }
  7590. }
  7591. if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !_totalTime && !this._initted && (this.add || this._ptLookup)) {
  7592. this._ts || (this._pTime = _totalTime);
  7593. _lazySafeRender(this, _totalTime, suppressEvents);
  7594. }
  7595. return this;
  7596. };
  7597. _proto.time = function time(value, suppressEvents) {
  7598. return arguments.length ? this.totalTime(Math.min(this.totalDuration(), value + _elapsedCycleDuration(this)) % (this._dur + this._rDelay) || (value ? this._dur : 0), suppressEvents) : this._time;
  7599. };
  7600. _proto.totalProgress = function totalProgress(value, suppressEvents) {
  7601. return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.rawTime() > 0 ? 1 : 0;
  7602. };
  7603. _proto.progress = function progress(value, suppressEvents) {
  7604. return arguments.length ? this.totalTime(this.duration() * (this._yoyo && !(this.iteration() & 1) ? 1 - value : value) + _elapsedCycleDuration(this), suppressEvents) : this.duration() ? Math.min(1, this._time / this._dur) : this.rawTime() > 0 ? 1 : 0;
  7605. };
  7606. _proto.iteration = function iteration(value, suppressEvents) {
  7607. var cycleDuration = this.duration() + this._rDelay;
  7608. return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1;
  7609. };
  7610. _proto.timeScale = function timeScale(value, suppressEvents) {
  7611. if (!arguments.length) {
  7612. return this._rts === -_tinyNum ? 0 : this._rts;
  7613. }
  7614. if (this._rts === value) {
  7615. return this;
  7616. }
  7617. var tTime = this.parent && this._ts ? _parentToChildTotalTime(this.parent._time, this) : this._tTime;
  7618. this._rts = +value || 0;
  7619. this._ts = this._ps || value === -_tinyNum ? 0 : this._rts;
  7620. this.totalTime(_clamp(-Math.abs(this._delay), this._tDur, tTime), suppressEvents !== false);
  7621. _setEnd(this);
  7622. return _recacheAncestors(this);
  7623. };
  7624. _proto.paused = function paused(value) {
  7625. if (!arguments.length) {
  7626. return this._ps;
  7627. }
  7628. if (this._ps !== value) {
  7629. this._ps = value;
  7630. if (value) {
  7631. this._pTime = this._tTime || Math.max(-this._delay, this.rawTime());
  7632. this._ts = this._act = 0;
  7633. } else {
  7634. _wake();
  7635. this._ts = this._rts;
  7636. this.totalTime(this.parent && !this.parent.smoothChildTiming ? this.rawTime() : this._tTime || this._pTime, this.progress() === 1 && Math.abs(this._zTime) !== _tinyNum && (this._tTime -= _tinyNum));
  7637. }
  7638. }
  7639. return this;
  7640. };
  7641. _proto.startTime = function startTime(value) {
  7642. if (arguments.length) {
  7643. this._start = value;
  7644. var parent = this.parent || this._dp;
  7645. parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay);
  7646. return this;
  7647. }
  7648. return this._start;
  7649. };
  7650. _proto.endTime = function endTime(includeRepeats) {
  7651. return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts || 1);
  7652. };
  7653. _proto.rawTime = function rawTime(wrapRepeats) {
  7654. var parent = this.parent || this._dp;
  7655. return !parent ? this._tTime : wrapRepeats && (!this._ts || this._repeat && this._time && this.totalProgress() < 1) ? this._tTime % (this._dur + this._rDelay) : !this._ts ? this._tTime : _parentToChildTotalTime(parent.rawTime(wrapRepeats), this);
  7656. };
  7657. _proto.revert = function revert(config) {
  7658. if (config === void 0) {
  7659. config = _revertConfig;
  7660. }
  7661. var prevIsReverting = _reverting;
  7662. _reverting = config;
  7663. if (this._initted || this._startAt) {
  7664. this.timeline && this.timeline.revert(config);
  7665. this.totalTime(-0.01, config.suppressEvents);
  7666. }
  7667. this.data !== "nested" && config.kill !== false && this.kill();
  7668. _reverting = prevIsReverting;
  7669. return this;
  7670. };
  7671. _proto.globalTime = function globalTime(rawTime) {
  7672. var animation = this,
  7673. time = arguments.length ? rawTime : animation.rawTime();
  7674. while (animation) {
  7675. time = animation._start + time / (Math.abs(animation._ts) || 1);
  7676. animation = animation._dp;
  7677. }
  7678. return !this.parent && this._sat ? this._sat.globalTime(rawTime) : time;
  7679. };
  7680. _proto.repeat = function repeat(value) {
  7681. if (arguments.length) {
  7682. this._repeat = value === Infinity ? -2 : value;
  7683. return _onUpdateTotalDuration(this);
  7684. }
  7685. return this._repeat === -2 ? Infinity : this._repeat;
  7686. };
  7687. _proto.repeatDelay = function repeatDelay(value) {
  7688. if (arguments.length) {
  7689. var time = this._time;
  7690. this._rDelay = value;
  7691. _onUpdateTotalDuration(this);
  7692. return time ? this.time(time) : this;
  7693. }
  7694. return this._rDelay;
  7695. };
  7696. _proto.yoyo = function yoyo(value) {
  7697. if (arguments.length) {
  7698. this._yoyo = value;
  7699. return this;
  7700. }
  7701. return this._yoyo;
  7702. };
  7703. _proto.seek = function seek(position, suppressEvents) {
  7704. return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents));
  7705. };
  7706. _proto.restart = function restart(includeDelay, suppressEvents) {
  7707. return this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents));
  7708. };
  7709. _proto.play = function play(from, suppressEvents) {
  7710. from != null && this.seek(from, suppressEvents);
  7711. return this.reversed(false).paused(false);
  7712. };
  7713. _proto.reverse = function reverse(from, suppressEvents) {
  7714. from != null && this.seek(from || this.totalDuration(), suppressEvents);
  7715. return this.reversed(true).paused(false);
  7716. };
  7717. _proto.pause = function pause(atTime, suppressEvents) {
  7718. atTime != null && this.seek(atTime, suppressEvents);
  7719. return this.paused(true);
  7720. };
  7721. _proto.resume = function resume() {
  7722. return this.paused(false);
  7723. };
  7724. _proto.reversed = function reversed(value) {
  7725. if (arguments.length) {
  7726. !!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0));
  7727. return this;
  7728. }
  7729. return this._rts < 0;
  7730. };
  7731. _proto.invalidate = function invalidate() {
  7732. this._initted = this._act = 0;
  7733. this._zTime = -_tinyNum;
  7734. return this;
  7735. };
  7736. _proto.isActive = function isActive() {
  7737. var parent = this.parent || this._dp,
  7738. start = this._start,
  7739. rawTime;
  7740. return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum);
  7741. };
  7742. _proto.eventCallback = function eventCallback(type, callback, params) {
  7743. var vars = this.vars;
  7744. if (arguments.length > 1) {
  7745. if (!callback) {
  7746. delete vars[type];
  7747. } else {
  7748. vars[type] = callback;
  7749. params && (vars[type + "Params"] = params);
  7750. type === "onUpdate" && (this._onUpdate = callback);
  7751. }
  7752. return this;
  7753. }
  7754. return vars[type];
  7755. };
  7756. _proto.then = function then(onFulfilled) {
  7757. var self = this;
  7758. return new Promise(function (resolve) {
  7759. var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough,
  7760. _resolve = function _resolve() {
  7761. var _then = self.then;
  7762. self.then = null;
  7763. _isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then);
  7764. resolve(f);
  7765. self.then = _then;
  7766. };
  7767. if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) {
  7768. _resolve();
  7769. } else {
  7770. self._prom = _resolve;
  7771. }
  7772. });
  7773. };
  7774. _proto.kill = function kill() {
  7775. _interrupt(this);
  7776. };
  7777. return Animation;
  7778. }();
  7779. _setDefaults(Animation.prototype, {
  7780. _time: 0,
  7781. _start: 0,
  7782. _end: 0,
  7783. _tTime: 0,
  7784. _tDur: 0,
  7785. _dirty: 0,
  7786. _repeat: 0,
  7787. _yoyo: false,
  7788. parent: null,
  7789. _initted: false,
  7790. _rDelay: 0,
  7791. _ts: 1,
  7792. _dp: 0,
  7793. ratio: 0,
  7794. _zTime: -_tinyNum,
  7795. _prom: 0,
  7796. _ps: false,
  7797. _rts: 1
  7798. });
  7799. var Timeline = function (_Animation) {
  7800. _inheritsLoose(Timeline, _Animation);
  7801. function Timeline(vars, position) {
  7802. var _this;
  7803. if (vars === void 0) {
  7804. vars = {};
  7805. }
  7806. _this = _Animation.call(this, vars) || this;
  7807. _this.labels = {};
  7808. _this.smoothChildTiming = !!vars.smoothChildTiming;
  7809. _this.autoRemoveChildren = !!vars.autoRemoveChildren;
  7810. _this._sort = _isNotFalse(vars.sortChildren);
  7811. _globalTimeline && _addToTimeline(vars.parent || _globalTimeline, _assertThisInitialized(_this), position);
  7812. vars.reversed && _this.reverse();
  7813. vars.paused && _this.paused(true);
  7814. vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger);
  7815. return _this;
  7816. }
  7817. var _proto2 = Timeline.prototype;
  7818. _proto2.to = function to(targets, vars, position) {
  7819. _createTweenType(0, arguments, this);
  7820. return this;
  7821. };
  7822. _proto2.from = function from(targets, vars, position) {
  7823. _createTweenType(1, arguments, this);
  7824. return this;
  7825. };
  7826. _proto2.fromTo = function fromTo(targets, fromVars, toVars, position) {
  7827. _createTweenType(2, arguments, this);
  7828. return this;
  7829. };
  7830. _proto2.set = function set(targets, vars, position) {
  7831. vars.duration = 0;
  7832. vars.parent = this;
  7833. _inheritDefaults(vars).repeatDelay || (vars.repeat = 0);
  7834. vars.immediateRender = !!vars.immediateRender;
  7835. new Tween(targets, vars, _parsePosition(this, position), 1);
  7836. return this;
  7837. };
  7838. _proto2.call = function call(callback, params, position) {
  7839. return _addToTimeline(this, Tween.delayedCall(0, callback, params), position);
  7840. };
  7841. _proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
  7842. vars.duration = duration;
  7843. vars.stagger = vars.stagger || stagger;
  7844. vars.onComplete = onCompleteAll;
  7845. vars.onCompleteParams = onCompleteAllParams;
  7846. vars.parent = this;
  7847. new Tween(targets, vars, _parsePosition(this, position));
  7848. return this;
  7849. };
  7850. _proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {
  7851. vars.runBackwards = 1;
  7852. _inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender);
  7853. return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams);
  7854. };
  7855. _proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) {
  7856. toVars.startAt = fromVars;
  7857. _inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender);
  7858. return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams);
  7859. };
  7860. _proto2.render = function render(totalTime, suppressEvents, force) {
  7861. var prevTime = this._time,
  7862. tDur = this._dirty ? this.totalDuration() : this._tDur,
  7863. dur = this._dur,
  7864. tTime = totalTime <= 0 ? 0 : _roundPrecise(totalTime),
  7865. crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur),
  7866. time,
  7867. child,
  7868. next,
  7869. iteration,
  7870. cycleDuration,
  7871. prevPaused,
  7872. pauseTween,
  7873. timeScale,
  7874. prevStart,
  7875. prevIteration,
  7876. yoyo,
  7877. isYoyo;
  7878. this !== _globalTimeline && tTime > tDur && totalTime >= 0 && (tTime = tDur);
  7879. if (tTime !== this._tTime || force || crossingStart) {
  7880. if (prevTime !== this._time && dur) {
  7881. tTime += this._time - prevTime;
  7882. totalTime += this._time - prevTime;
  7883. }
  7884. time = tTime;
  7885. prevStart = this._start;
  7886. timeScale = this._ts;
  7887. prevPaused = !timeScale;
  7888. if (crossingStart) {
  7889. dur || (prevTime = this._zTime);
  7890. (totalTime || !suppressEvents) && (this._zTime = totalTime);
  7891. }
  7892. if (this._repeat) {
  7893. yoyo = this._yoyo;
  7894. cycleDuration = dur + this._rDelay;
  7895. if (this._repeat < -1 && totalTime < 0) {
  7896. return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);
  7897. }
  7898. time = _roundPrecise(tTime % cycleDuration);
  7899. if (tTime === tDur) {
  7900. iteration = this._repeat;
  7901. time = dur;
  7902. } else {
  7903. iteration = ~~(tTime / cycleDuration);
  7904. if (iteration && iteration === tTime / cycleDuration) {
  7905. time = dur;
  7906. iteration--;
  7907. }
  7908. time > dur && (time = dur);
  7909. }
  7910. prevIteration = _animationCycle(this._tTime, cycleDuration);
  7911. !prevTime && this._tTime && prevIteration !== iteration && this._tTime - prevIteration * cycleDuration - this._dur <= 0 && (prevIteration = iteration);
  7912. if (yoyo && iteration & 1) {
  7913. time = dur - time;
  7914. isYoyo = 1;
  7915. }
  7916. if (iteration !== prevIteration && !this._lock) {
  7917. var rewinding = yoyo && prevIteration & 1,
  7918. doesWrap = rewinding === (yoyo && iteration & 1);
  7919. iteration < prevIteration && (rewinding = !rewinding);
  7920. prevTime = rewinding ? 0 : tTime % dur ? dur : tTime;
  7921. this._lock = 1;
  7922. this.render(prevTime || (isYoyo ? 0 : _roundPrecise(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0;
  7923. this._tTime = tTime;
  7924. !suppressEvents && this.parent && _callback(this, "onRepeat");
  7925. this.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1);
  7926. if (prevTime && prevTime !== this._time || prevPaused !== !this._ts || this.vars.onRepeat && !this.parent && !this._act) {
  7927. return this;
  7928. }
  7929. dur = this._dur;
  7930. tDur = this._tDur;
  7931. if (doesWrap) {
  7932. this._lock = 2;
  7933. prevTime = rewinding ? dur : -0.0001;
  7934. this.render(prevTime, true);
  7935. this.vars.repeatRefresh && !isYoyo && this.invalidate();
  7936. }
  7937. this._lock = 0;
  7938. if (!this._ts && !prevPaused) {
  7939. return this;
  7940. }
  7941. _propagateYoyoEase(this, isYoyo);
  7942. }
  7943. }
  7944. if (this._hasPause && !this._forcing && this._lock < 2) {
  7945. pauseTween = _findNextPauseTween(this, _roundPrecise(prevTime), _roundPrecise(time));
  7946. if (pauseTween) {
  7947. tTime -= time - (time = pauseTween._start);
  7948. }
  7949. }
  7950. this._tTime = tTime;
  7951. this._time = time;
  7952. this._act = !timeScale;
  7953. if (!this._initted) {
  7954. this._onUpdate = this.vars.onUpdate;
  7955. this._initted = 1;
  7956. this._zTime = totalTime;
  7957. prevTime = 0;
  7958. }
  7959. if (!prevTime && time && !suppressEvents && !iteration) {
  7960. _callback(this, "onStart");
  7961. if (this._tTime !== tTime) {
  7962. return this;
  7963. }
  7964. }
  7965. if (time >= prevTime && totalTime >= 0) {
  7966. child = this._first;
  7967. while (child) {
  7968. next = child._next;
  7969. if ((child._act || time >= child._start) && child._ts && pauseTween !== child) {
  7970. if (child.parent !== this) {
  7971. return this.render(totalTime, suppressEvents, force);
  7972. }
  7973. child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force);
  7974. if (time !== this._time || !this._ts && !prevPaused) {
  7975. pauseTween = 0;
  7976. next && (tTime += this._zTime = -_tinyNum);
  7977. break;
  7978. }
  7979. }
  7980. child = next;
  7981. }
  7982. } else {
  7983. child = this._last;
  7984. var adjustedTime = totalTime < 0 ? totalTime : time;
  7985. while (child) {
  7986. next = child._prev;
  7987. if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) {
  7988. if (child.parent !== this) {
  7989. return this.render(totalTime, suppressEvents, force);
  7990. }
  7991. child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force || _reverting && (child._initted || child._startAt));
  7992. if (time !== this._time || !this._ts && !prevPaused) {
  7993. pauseTween = 0;
  7994. next && (tTime += this._zTime = adjustedTime ? -_tinyNum : _tinyNum);
  7995. break;
  7996. }
  7997. }
  7998. child = next;
  7999. }
  8000. }
  8001. if (pauseTween && !suppressEvents) {
  8002. this.pause();
  8003. pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1;
  8004. if (this._ts) {
  8005. this._start = prevStart;
  8006. _setEnd(this);
  8007. return this.render(totalTime, suppressEvents, force);
  8008. }
  8009. }
  8010. this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true);
  8011. if (tTime === tDur && this._tTime >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) {
  8012. (totalTime || !dur) && (tTime === tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
  8013. if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime || !tDur)) {
  8014. _callback(this, tTime === tDur && totalTime >= 0 ? "onComplete" : "onReverseComplete", true);
  8015. this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
  8016. }
  8017. }
  8018. }
  8019. return this;
  8020. };
  8021. _proto2.add = function add(child, position) {
  8022. var _this2 = this;
  8023. _isNumber(position) || (position = _parsePosition(this, position, child));
  8024. if (!(child instanceof Animation)) {
  8025. if (_isArray(child)) {
  8026. child.forEach(function (obj) {
  8027. return _this2.add(obj, position);
  8028. });
  8029. return this;
  8030. }
  8031. if (_isString(child)) {
  8032. return this.addLabel(child, position);
  8033. }
  8034. if (_isFunction(child)) {
  8035. child = Tween.delayedCall(0, child);
  8036. } else {
  8037. return this;
  8038. }
  8039. }
  8040. return this !== child ? _addToTimeline(this, child, position) : this;
  8041. };
  8042. _proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) {
  8043. if (nested === void 0) {
  8044. nested = true;
  8045. }
  8046. if (tweens === void 0) {
  8047. tweens = true;
  8048. }
  8049. if (timelines === void 0) {
  8050. timelines = true;
  8051. }
  8052. if (ignoreBeforeTime === void 0) {
  8053. ignoreBeforeTime = -_bigNum;
  8054. }
  8055. var a = [],
  8056. child = this._first;
  8057. while (child) {
  8058. if (child._start >= ignoreBeforeTime) {
  8059. if (child instanceof Tween) {
  8060. tweens && a.push(child);
  8061. } else {
  8062. timelines && a.push(child);
  8063. nested && a.push.apply(a, child.getChildren(true, tweens, timelines));
  8064. }
  8065. }
  8066. child = child._next;
  8067. }
  8068. return a;
  8069. };
  8070. _proto2.getById = function getById(id) {
  8071. var animations = this.getChildren(1, 1, 1),
  8072. i = animations.length;
  8073. while (i--) {
  8074. if (animations[i].vars.id === id) {
  8075. return animations[i];
  8076. }
  8077. }
  8078. };
  8079. _proto2.remove = function remove(child) {
  8080. if (_isString(child)) {
  8081. return this.removeLabel(child);
  8082. }
  8083. if (_isFunction(child)) {
  8084. return this.killTweensOf(child);
  8085. }
  8086. _removeLinkedListItem(this, child);
  8087. if (child === this._recent) {
  8088. this._recent = this._last;
  8089. }
  8090. return _uncache(this);
  8091. };
  8092. _proto2.totalTime = function totalTime(_totalTime2, suppressEvents) {
  8093. if (!arguments.length) {
  8094. return this._tTime;
  8095. }
  8096. this._forcing = 1;
  8097. if (!this._dp && this._ts) {
  8098. this._start = _roundPrecise(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts));
  8099. }
  8100. _Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents);
  8101. this._forcing = 0;
  8102. return this;
  8103. };
  8104. _proto2.addLabel = function addLabel(label, position) {
  8105. this.labels[label] = _parsePosition(this, position);
  8106. return this;
  8107. };
  8108. _proto2.removeLabel = function removeLabel(label) {
  8109. delete this.labels[label];
  8110. return this;
  8111. };
  8112. _proto2.addPause = function addPause(position, callback, params) {
  8113. var t = Tween.delayedCall(0, callback || _emptyFunc, params);
  8114. t.data = "isPause";
  8115. this._hasPause = 1;
  8116. return _addToTimeline(this, t, _parsePosition(this, position));
  8117. };
  8118. _proto2.removePause = function removePause(position) {
  8119. var child = this._first;
  8120. position = _parsePosition(this, position);
  8121. while (child) {
  8122. if (child._start === position && child.data === "isPause") {
  8123. _removeFromParent(child);
  8124. }
  8125. child = child._next;
  8126. }
  8127. };
  8128. _proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) {
  8129. var tweens = this.getTweensOf(targets, onlyActive),
  8130. i = tweens.length;
  8131. while (i--) {
  8132. _overwritingTween !== tweens[i] && tweens[i].kill(targets, props);
  8133. }
  8134. return this;
  8135. };
  8136. _proto2.getTweensOf = function getTweensOf(targets, onlyActive) {
  8137. var a = [],
  8138. parsedTargets = toArray(targets),
  8139. child = this._first,
  8140. isGlobalTime = _isNumber(onlyActive),
  8141. children;
  8142. while (child) {
  8143. if (child instanceof Tween) {
  8144. if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) {
  8145. a.push(child);
  8146. }
  8147. } else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) {
  8148. a.push.apply(a, children);
  8149. }
  8150. child = child._next;
  8151. }
  8152. return a;
  8153. };
  8154. _proto2.tweenTo = function tweenTo(position, vars) {
  8155. vars = vars || {};
  8156. var tl = this,
  8157. endTime = _parsePosition(tl, position),
  8158. _vars = vars,
  8159. startAt = _vars.startAt,
  8160. _onStart = _vars.onStart,
  8161. onStartParams = _vars.onStartParams,
  8162. immediateRender = _vars.immediateRender,
  8163. initted,
  8164. tween = Tween.to(tl, _setDefaults({
  8165. ease: vars.ease || "none",
  8166. lazy: false,
  8167. immediateRender: false,
  8168. time: endTime,
  8169. overwrite: "auto",
  8170. duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum,
  8171. onStart: function onStart() {
  8172. tl.pause();
  8173. if (!initted) {
  8174. var duration = vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale());
  8175. tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true);
  8176. initted = 1;
  8177. }
  8178. _onStart && _onStart.apply(tween, onStartParams || []);
  8179. }
  8180. }, vars));
  8181. return immediateRender ? tween.render(0) : tween;
  8182. };
  8183. _proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) {
  8184. return this.tweenTo(toPosition, _setDefaults({
  8185. startAt: {
  8186. time: _parsePosition(this, fromPosition)
  8187. }
  8188. }, vars));
  8189. };
  8190. _proto2.recent = function recent() {
  8191. return this._recent;
  8192. };
  8193. _proto2.nextLabel = function nextLabel(afterTime) {
  8194. if (afterTime === void 0) {
  8195. afterTime = this._time;
  8196. }
  8197. return _getLabelInDirection(this, _parsePosition(this, afterTime));
  8198. };
  8199. _proto2.previousLabel = function previousLabel(beforeTime) {
  8200. if (beforeTime === void 0) {
  8201. beforeTime = this._time;
  8202. }
  8203. return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1);
  8204. };
  8205. _proto2.currentLabel = function currentLabel(value) {
  8206. return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum);
  8207. };
  8208. _proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) {
  8209. if (ignoreBeforeTime === void 0) {
  8210. ignoreBeforeTime = 0;
  8211. }
  8212. var child = this._first,
  8213. labels = this.labels,
  8214. p;
  8215. while (child) {
  8216. if (child._start >= ignoreBeforeTime) {
  8217. child._start += amount;
  8218. child._end += amount;
  8219. }
  8220. child = child._next;
  8221. }
  8222. if (adjustLabels) {
  8223. for (p in labels) {
  8224. if (labels[p] >= ignoreBeforeTime) {
  8225. labels[p] += amount;
  8226. }
  8227. }
  8228. }
  8229. return _uncache(this);
  8230. };
  8231. _proto2.invalidate = function invalidate(soft) {
  8232. var child = this._first;
  8233. this._lock = 0;
  8234. while (child) {
  8235. child.invalidate(soft);
  8236. child = child._next;
  8237. }
  8238. return _Animation.prototype.invalidate.call(this, soft);
  8239. };
  8240. _proto2.clear = function clear(includeLabels) {
  8241. if (includeLabels === void 0) {
  8242. includeLabels = true;
  8243. }
  8244. var child = this._first,
  8245. next;
  8246. while (child) {
  8247. next = child._next;
  8248. this.remove(child);
  8249. child = next;
  8250. }
  8251. this._dp && (this._time = this._tTime = this._pTime = 0);
  8252. includeLabels && (this.labels = {});
  8253. return _uncache(this);
  8254. };
  8255. _proto2.totalDuration = function totalDuration(value) {
  8256. var max = 0,
  8257. self = this,
  8258. child = self._last,
  8259. prevStart = _bigNum,
  8260. prev,
  8261. start,
  8262. parent;
  8263. if (arguments.length) {
  8264. return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value));
  8265. }
  8266. if (self._dirty) {
  8267. parent = self.parent;
  8268. while (child) {
  8269. prev = child._prev;
  8270. child._dirty && child.totalDuration();
  8271. start = child._start;
  8272. if (start > prevStart && self._sort && child._ts && !self._lock) {
  8273. self._lock = 1;
  8274. _addToTimeline(self, child, start - child._delay, 1)._lock = 0;
  8275. } else {
  8276. prevStart = start;
  8277. }
  8278. if (start < 0 && child._ts) {
  8279. max -= start;
  8280. if (!parent && !self._dp || parent && parent.smoothChildTiming) {
  8281. self._start += start / self._ts;
  8282. self._time -= start;
  8283. self._tTime -= start;
  8284. }
  8285. self.shiftChildren(-start, false, -1e999);
  8286. prevStart = 0;
  8287. }
  8288. child._end > max && child._ts && (max = child._end);
  8289. child = prev;
  8290. }
  8291. _setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1);
  8292. self._dirty = 0;
  8293. }
  8294. return self._tDur;
  8295. };
  8296. Timeline.updateRoot = function updateRoot(time) {
  8297. if (_globalTimeline._ts) {
  8298. _lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline));
  8299. _lastRenderedFrame = _ticker.frame;
  8300. }
  8301. if (_ticker.frame >= _nextGCFrame) {
  8302. _nextGCFrame += _config.autoSleep || 120;
  8303. var child = _globalTimeline._first;
  8304. if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) {
  8305. while (child && !child._ts) {
  8306. child = child._next;
  8307. }
  8308. child || _ticker.sleep();
  8309. }
  8310. }
  8311. };
  8312. return Timeline;
  8313. }(Animation);
  8314. _setDefaults(Timeline.prototype, {
  8315. _lock: 0,
  8316. _hasPause: 0,
  8317. _forcing: 0
  8318. });
  8319. var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) {
  8320. var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter),
  8321. index = 0,
  8322. matchIndex = 0,
  8323. result,
  8324. startNums,
  8325. color,
  8326. endNum,
  8327. chunk,
  8328. startNum,
  8329. hasRandom,
  8330. a;
  8331. pt.b = start;
  8332. pt.e = end;
  8333. start += "";
  8334. end += "";
  8335. if (hasRandom = ~end.indexOf("random(")) {
  8336. end = _replaceRandom(end);
  8337. }
  8338. if (stringFilter) {
  8339. a = [start, end];
  8340. stringFilter(a, target, prop);
  8341. start = a[0];
  8342. end = a[1];
  8343. }
  8344. startNums = start.match(_complexStringNumExp) || [];
  8345. while (result = _complexStringNumExp.exec(end)) {
  8346. endNum = result[0];
  8347. chunk = end.substring(index, result.index);
  8348. if (color) {
  8349. color = (color + 1) % 5;
  8350. } else if (chunk.substr(-5) === "rgba(") {
  8351. color = 1;
  8352. }
  8353. if (endNum !== startNums[matchIndex++]) {
  8354. startNum = parseFloat(startNums[matchIndex - 1]) || 0;
  8355. pt._pt = {
  8356. _next: pt._pt,
  8357. p: chunk || matchIndex === 1 ? chunk : ",",
  8358. s: startNum,
  8359. c: endNum.charAt(1) === "=" ? _parseRelative(startNum, endNum) - startNum : parseFloat(endNum) - startNum,
  8360. m: color && color < 4 ? Math.round : 0
  8361. };
  8362. index = _complexStringNumExp.lastIndex;
  8363. }
  8364. }
  8365. pt.c = index < end.length ? end.substring(index, end.length) : "";
  8366. pt.fp = funcParam;
  8367. if (_relExp.test(end) || hasRandom) {
  8368. pt.e = 0;
  8369. }
  8370. this._pt = pt;
  8371. return pt;
  8372. },
  8373. _addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam, optional) {
  8374. _isFunction(end) && (end = end(index || 0, target, targets));
  8375. var currentValue = target[prop],
  8376. parsedStart = start !== "get" ? start : !_isFunction(currentValue) ? currentValue : funcParam ? target[prop.indexOf("set") || !_isFunction(target["get" + prop.substr(3)]) ? prop : "get" + prop.substr(3)](funcParam) : target[prop](),
  8377. setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc,
  8378. pt;
  8379. if (_isString(end)) {
  8380. if (~end.indexOf("random(")) {
  8381. end = _replaceRandom(end);
  8382. }
  8383. if (end.charAt(1) === "=") {
  8384. pt = _parseRelative(parsedStart, end) + (getUnit(parsedStart) || 0);
  8385. if (pt || pt === 0) {
  8386. end = pt;
  8387. }
  8388. }
  8389. }
  8390. if (!optional || parsedStart !== end || _forceAllPropTweens) {
  8391. if (!isNaN(parsedStart * end) && end !== "") {
  8392. pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter);
  8393. funcParam && (pt.fp = funcParam);
  8394. modifier && pt.modifier(modifier, this, target);
  8395. return this._pt = pt;
  8396. }
  8397. !currentValue && !(prop in target) && _missingPlugin(prop, end);
  8398. return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam);
  8399. }
  8400. },
  8401. _processVars = function _processVars(vars, index, target, targets, tween) {
  8402. _isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets));
  8403. if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) {
  8404. return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars;
  8405. }
  8406. var copy = {},
  8407. p;
  8408. for (p in vars) {
  8409. copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets);
  8410. }
  8411. return copy;
  8412. },
  8413. _checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) {
  8414. var plugin, pt, ptLookup, i;
  8415. if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) {
  8416. tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority);
  8417. if (tween !== _quickTween) {
  8418. ptLookup = tween._ptLookup[tween._targets.indexOf(target)];
  8419. i = plugin._props.length;
  8420. while (i--) {
  8421. ptLookup[plugin._props[i]] = pt;
  8422. }
  8423. }
  8424. }
  8425. return plugin;
  8426. },
  8427. _overwritingTween,
  8428. _forceAllPropTweens,
  8429. _initTween = function _initTween(tween, time, tTime) {
  8430. var vars = tween.vars,
  8431. ease = vars.ease,
  8432. startAt = vars.startAt,
  8433. immediateRender = vars.immediateRender,
  8434. lazy = vars.lazy,
  8435. onUpdate = vars.onUpdate,
  8436. runBackwards = vars.runBackwards,
  8437. yoyoEase = vars.yoyoEase,
  8438. keyframes = vars.keyframes,
  8439. autoRevert = vars.autoRevert,
  8440. dur = tween._dur,
  8441. prevStartAt = tween._startAt,
  8442. targets = tween._targets,
  8443. parent = tween.parent,
  8444. fullTargets = parent && parent.data === "nested" ? parent.vars.targets : targets,
  8445. autoOverwrite = tween._overwrite === "auto" && !_suppressOverwrites,
  8446. tl = tween.timeline,
  8447. cleanVars,
  8448. i,
  8449. p,
  8450. pt,
  8451. target,
  8452. hasPriority,
  8453. gsData,
  8454. harness,
  8455. plugin,
  8456. ptLookup,
  8457. index,
  8458. harnessVars,
  8459. overwritten;
  8460. tl && (!keyframes || !ease) && (ease = "none");
  8461. tween._ease = _parseEase(ease, _defaults.ease);
  8462. tween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0;
  8463. if (yoyoEase && tween._yoyo && !tween._repeat) {
  8464. yoyoEase = tween._yEase;
  8465. tween._yEase = tween._ease;
  8466. tween._ease = yoyoEase;
  8467. }
  8468. tween._from = !tl && !!vars.runBackwards;
  8469. if (!tl || keyframes && !vars.stagger) {
  8470. harness = targets[0] ? _getCache(targets[0]).harness : 0;
  8471. harnessVars = harness && vars[harness.prop];
  8472. cleanVars = _copyExcluding(vars, _reservedProps);
  8473. if (prevStartAt) {
  8474. prevStartAt._zTime < 0 && prevStartAt.progress(1);
  8475. time < 0 && runBackwards && immediateRender && !autoRevert ? prevStartAt.render(-1, true) : prevStartAt.revert(runBackwards && dur ? _revertConfigNoKill : _startAtRevertConfig);
  8476. prevStartAt._lazy = 0;
  8477. }
  8478. if (startAt) {
  8479. _removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({
  8480. data: "isStart",
  8481. overwrite: false,
  8482. parent: parent,
  8483. immediateRender: true,
  8484. lazy: !prevStartAt && _isNotFalse(lazy),
  8485. startAt: null,
  8486. delay: 0,
  8487. onUpdate: onUpdate && function () {
  8488. return _callback(tween, "onUpdate");
  8489. },
  8490. stagger: 0
  8491. }, startAt)));
  8492. tween._startAt._dp = 0;
  8493. tween._startAt._sat = tween;
  8494. time < 0 && (_reverting || !immediateRender && !autoRevert) && tween._startAt.revert(_revertConfigNoKill);
  8495. if (immediateRender) {
  8496. if (dur && time <= 0 && tTime <= 0) {
  8497. time && (tween._zTime = time);
  8498. return;
  8499. }
  8500. }
  8501. } else if (runBackwards && dur) {
  8502. if (!prevStartAt) {
  8503. time && (immediateRender = false);
  8504. p = _setDefaults({
  8505. overwrite: false,
  8506. data: "isFromStart",
  8507. lazy: immediateRender && !prevStartAt && _isNotFalse(lazy),
  8508. immediateRender: immediateRender,
  8509. stagger: 0,
  8510. parent: parent
  8511. }, cleanVars);
  8512. harnessVars && (p[harness.prop] = harnessVars);
  8513. _removeFromParent(tween._startAt = Tween.set(targets, p));
  8514. tween._startAt._dp = 0;
  8515. tween._startAt._sat = tween;
  8516. time < 0 && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween._startAt.render(-1, true));
  8517. tween._zTime = time;
  8518. if (!immediateRender) {
  8519. _initTween(tween._startAt, _tinyNum, _tinyNum);
  8520. } else if (!time) {
  8521. return;
  8522. }
  8523. }
  8524. }
  8525. tween._pt = tween._ptCache = 0;
  8526. lazy = dur && _isNotFalse(lazy) || lazy && !dur;
  8527. for (i = 0; i < targets.length; i++) {
  8528. target = targets[i];
  8529. gsData = target._gsap || _harness(targets)[i]._gsap;
  8530. tween._ptLookup[i] = ptLookup = {};
  8531. _lazyLookup[gsData.id] && _lazyTweens.length && _lazyRender();
  8532. index = fullTargets === targets ? i : fullTargets.indexOf(target);
  8533. if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) {
  8534. tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority);
  8535. plugin._props.forEach(function (name) {
  8536. ptLookup[name] = pt;
  8537. });
  8538. plugin.priority && (hasPriority = 1);
  8539. }
  8540. if (!harness || harnessVars) {
  8541. for (p in cleanVars) {
  8542. if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) {
  8543. plugin.priority && (hasPriority = 1);
  8544. } else {
  8545. ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter);
  8546. }
  8547. }
  8548. }
  8549. tween._op && tween._op[i] && tween.kill(target, tween._op[i]);
  8550. if (autoOverwrite && tween._pt) {
  8551. _overwritingTween = tween;
  8552. _globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(time));
  8553. overwritten = !tween.parent;
  8554. _overwritingTween = 0;
  8555. }
  8556. tween._pt && lazy && (_lazyLookup[gsData.id] = 1);
  8557. }
  8558. hasPriority && _sortPropTweensByPriority(tween);
  8559. tween._onInit && tween._onInit(tween);
  8560. }
  8561. tween._onUpdate = onUpdate;
  8562. tween._initted = (!tween._op || tween._pt) && !overwritten;
  8563. keyframes && time <= 0 && tl.render(_bigNum, true, true);
  8564. },
  8565. _updatePropTweens = function _updatePropTweens(tween, property, value, start, startIsRelative, ratio, time, skipRecursion) {
  8566. var ptCache = (tween._pt && tween._ptCache || (tween._ptCache = {}))[property],
  8567. pt,
  8568. rootPT,
  8569. lookup,
  8570. i;
  8571. if (!ptCache) {
  8572. ptCache = tween._ptCache[property] = [];
  8573. lookup = tween._ptLookup;
  8574. i = tween._targets.length;
  8575. while (i--) {
  8576. pt = lookup[i][property];
  8577. if (pt && pt.d && pt.d._pt) {
  8578. pt = pt.d._pt;
  8579. while (pt && pt.p !== property && pt.fp !== property) {
  8580. pt = pt._next;
  8581. }
  8582. }
  8583. if (!pt) {
  8584. _forceAllPropTweens = 1;
  8585. tween.vars[property] = "+=0";
  8586. _initTween(tween, time);
  8587. _forceAllPropTweens = 0;
  8588. return skipRecursion ? _warn(property + " not eligible for reset") : 1;
  8589. }
  8590. ptCache.push(pt);
  8591. }
  8592. }
  8593. i = ptCache.length;
  8594. while (i--) {
  8595. rootPT = ptCache[i];
  8596. pt = rootPT._pt || rootPT;
  8597. pt.s = (start || start === 0) && !startIsRelative ? start : pt.s + (start || 0) + ratio * pt.c;
  8598. pt.c = value - pt.s;
  8599. rootPT.e && (rootPT.e = _round(value) + getUnit(rootPT.e));
  8600. rootPT.b && (rootPT.b = pt.s + getUnit(rootPT.b));
  8601. }
  8602. },
  8603. _addAliasesToVars = function _addAliasesToVars(targets, vars) {
  8604. var harness = targets[0] ? _getCache(targets[0]).harness : 0,
  8605. propertyAliases = harness && harness.aliases,
  8606. copy,
  8607. p,
  8608. i,
  8609. aliases;
  8610. if (!propertyAliases) {
  8611. return vars;
  8612. }
  8613. copy = _merge({}, vars);
  8614. for (p in propertyAliases) {
  8615. if (p in copy) {
  8616. aliases = propertyAliases[p].split(",");
  8617. i = aliases.length;
  8618. while (i--) {
  8619. copy[aliases[i]] = copy[p];
  8620. }
  8621. }
  8622. }
  8623. return copy;
  8624. },
  8625. _parseKeyframe = function _parseKeyframe(prop, obj, allProps, easeEach) {
  8626. var ease = obj.ease || easeEach || "power1.inOut",
  8627. p,
  8628. a;
  8629. if (_isArray(obj)) {
  8630. a = allProps[prop] || (allProps[prop] = []);
  8631. obj.forEach(function (value, i) {
  8632. return a.push({
  8633. t: i / (obj.length - 1) * 100,
  8634. v: value,
  8635. e: ease
  8636. });
  8637. });
  8638. } else {
  8639. for (p in obj) {
  8640. a = allProps[p] || (allProps[p] = []);
  8641. p === "ease" || a.push({
  8642. t: parseFloat(prop),
  8643. v: obj[p],
  8644. e: ease
  8645. });
  8646. }
  8647. }
  8648. },
  8649. _parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) {
  8650. return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value;
  8651. },
  8652. _staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,autoRevert",
  8653. _staggerPropsToSkip = {};
  8654. _forEachName(_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger", function (name) {
  8655. return _staggerPropsToSkip[name] = 1;
  8656. });
  8657. var Tween = function (_Animation2) {
  8658. _inheritsLoose(Tween, _Animation2);
  8659. function Tween(targets, vars, position, skipInherit) {
  8660. var _this3;
  8661. if (typeof vars === "number") {
  8662. position.duration = vars;
  8663. vars = position;
  8664. position = null;
  8665. }
  8666. _this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars)) || this;
  8667. var _this3$vars = _this3.vars,
  8668. duration = _this3$vars.duration,
  8669. delay = _this3$vars.delay,
  8670. immediateRender = _this3$vars.immediateRender,
  8671. stagger = _this3$vars.stagger,
  8672. overwrite = _this3$vars.overwrite,
  8673. keyframes = _this3$vars.keyframes,
  8674. defaults = _this3$vars.defaults,
  8675. scrollTrigger = _this3$vars.scrollTrigger,
  8676. yoyoEase = _this3$vars.yoyoEase,
  8677. parent = vars.parent || _globalTimeline,
  8678. parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets),
  8679. tl,
  8680. i,
  8681. copy,
  8682. l,
  8683. p,
  8684. curTarget,
  8685. staggerFunc,
  8686. staggerVarsToMerge;
  8687. _this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://gsap.com", !_config.nullTargetWarn) || [];
  8688. _this3._ptLookup = [];
  8689. _this3._overwrite = overwrite;
  8690. if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {
  8691. vars = _this3.vars;
  8692. tl = _this3.timeline = new Timeline({
  8693. data: "nested",
  8694. defaults: defaults || {},
  8695. targets: parent && parent.data === "nested" ? parent.vars.targets : parsedTargets
  8696. });
  8697. tl.kill();
  8698. tl.parent = tl._dp = _assertThisInitialized(_this3);
  8699. tl._start = 0;
  8700. if (stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {
  8701. l = parsedTargets.length;
  8702. staggerFunc = stagger && distribute(stagger);
  8703. if (_isObject(stagger)) {
  8704. for (p in stagger) {
  8705. if (~_staggerTweenProps.indexOf(p)) {
  8706. staggerVarsToMerge || (staggerVarsToMerge = {});
  8707. staggerVarsToMerge[p] = stagger[p];
  8708. }
  8709. }
  8710. }
  8711. for (i = 0; i < l; i++) {
  8712. copy = _copyExcluding(vars, _staggerPropsToSkip);
  8713. copy.stagger = 0;
  8714. yoyoEase && (copy.yoyoEase = yoyoEase);
  8715. staggerVarsToMerge && _merge(copy, staggerVarsToMerge);
  8716. curTarget = parsedTargets[i];
  8717. copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets);
  8718. copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay;
  8719. if (!stagger && l === 1 && copy.delay) {
  8720. _this3._delay = delay = copy.delay;
  8721. _this3._start += delay;
  8722. copy.delay = 0;
  8723. }
  8724. tl.to(curTarget, copy, staggerFunc ? staggerFunc(i, curTarget, parsedTargets) : 0);
  8725. tl._ease = _easeMap.none;
  8726. }
  8727. tl.duration() ? duration = delay = 0 : _this3.timeline = 0;
  8728. } else if (keyframes) {
  8729. _inheritDefaults(_setDefaults(tl.vars.defaults, {
  8730. ease: "none"
  8731. }));
  8732. tl._ease = _parseEase(keyframes.ease || vars.ease || "none");
  8733. var time = 0,
  8734. a,
  8735. kf,
  8736. v;
  8737. if (_isArray(keyframes)) {
  8738. keyframes.forEach(function (frame) {
  8739. return tl.to(parsedTargets, frame, ">");
  8740. });
  8741. tl.duration();
  8742. } else {
  8743. copy = {};
  8744. for (p in keyframes) {
  8745. p === "ease" || p === "easeEach" || _parseKeyframe(p, keyframes[p], copy, keyframes.easeEach);
  8746. }
  8747. for (p in copy) {
  8748. a = copy[p].sort(function (a, b) {
  8749. return a.t - b.t;
  8750. });
  8751. time = 0;
  8752. for (i = 0; i < a.length; i++) {
  8753. kf = a[i];
  8754. v = {
  8755. ease: kf.e,
  8756. duration: (kf.t - (i ? a[i - 1].t : 0)) / 100 * duration
  8757. };
  8758. v[p] = kf.v;
  8759. tl.to(parsedTargets, v, time);
  8760. time += v.duration;
  8761. }
  8762. }
  8763. tl.duration() < duration && tl.to({}, {
  8764. duration: duration - tl.duration()
  8765. });
  8766. }
  8767. }
  8768. duration || _this3.duration(duration = tl.duration());
  8769. } else {
  8770. _this3.timeline = 0;
  8771. }
  8772. if (overwrite === true && !_suppressOverwrites) {
  8773. _overwritingTween = _assertThisInitialized(_this3);
  8774. _globalTimeline.killTweensOf(parsedTargets);
  8775. _overwritingTween = 0;
  8776. }
  8777. _addToTimeline(parent, _assertThisInitialized(_this3), position);
  8778. vars.reversed && _this3.reverse();
  8779. vars.paused && _this3.paused(true);
  8780. if (immediateRender || !duration && !keyframes && _this3._start === _roundPrecise(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") {
  8781. _this3._tTime = -_tinyNum;
  8782. _this3.render(Math.max(0, -delay) || 0);
  8783. }
  8784. scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger);
  8785. return _this3;
  8786. }
  8787. var _proto3 = Tween.prototype;
  8788. _proto3.render = function render(totalTime, suppressEvents, force) {
  8789. var prevTime = this._time,
  8790. tDur = this._tDur,
  8791. dur = this._dur,
  8792. isNegative = totalTime < 0,
  8793. tTime = totalTime > tDur - _tinyNum && !isNegative ? tDur : totalTime < _tinyNum ? 0 : totalTime,
  8794. time,
  8795. pt,
  8796. iteration,
  8797. cycleDuration,
  8798. prevIteration,
  8799. isYoyo,
  8800. ratio,
  8801. timeline,
  8802. yoyoEase;
  8803. if (!dur) {
  8804. _renderZeroDurationTween(this, totalTime, suppressEvents, force);
  8805. } else if (tTime !== this._tTime || !totalTime || force || !this._initted && this._tTime || this._startAt && this._zTime < 0 !== isNegative) {
  8806. time = tTime;
  8807. timeline = this.timeline;
  8808. if (this._repeat) {
  8809. cycleDuration = dur + this._rDelay;
  8810. if (this._repeat < -1 && isNegative) {
  8811. return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);
  8812. }
  8813. time = _roundPrecise(tTime % cycleDuration);
  8814. if (tTime === tDur) {
  8815. iteration = this._repeat;
  8816. time = dur;
  8817. } else {
  8818. iteration = ~~(tTime / cycleDuration);
  8819. if (iteration && iteration === _roundPrecise(tTime / cycleDuration)) {
  8820. time = dur;
  8821. iteration--;
  8822. }
  8823. time > dur && (time = dur);
  8824. }
  8825. isYoyo = this._yoyo && iteration & 1;
  8826. if (isYoyo) {
  8827. yoyoEase = this._yEase;
  8828. time = dur - time;
  8829. }
  8830. prevIteration = _animationCycle(this._tTime, cycleDuration);
  8831. if (time === prevTime && !force && this._initted && iteration === prevIteration) {
  8832. this._tTime = tTime;
  8833. return this;
  8834. }
  8835. if (iteration !== prevIteration) {
  8836. timeline && this._yEase && _propagateYoyoEase(timeline, isYoyo);
  8837. if (this.vars.repeatRefresh && !isYoyo && !this._lock && this._time !== dur && this._initted) {
  8838. this._lock = force = 1;
  8839. this.render(_roundPrecise(cycleDuration * iteration), true).invalidate()._lock = 0;
  8840. }
  8841. }
  8842. }
  8843. if (!this._initted) {
  8844. if (_attemptInitTween(this, isNegative ? totalTime : time, force, suppressEvents, tTime)) {
  8845. this._tTime = 0;
  8846. return this;
  8847. }
  8848. if (prevTime !== this._time && !(force && this.vars.repeatRefresh && iteration !== prevIteration)) {
  8849. return this;
  8850. }
  8851. if (dur !== this._dur) {
  8852. return this.render(totalTime, suppressEvents, force);
  8853. }
  8854. }
  8855. this._tTime = tTime;
  8856. this._time = time;
  8857. if (!this._act && this._ts) {
  8858. this._act = 1;
  8859. this._lazy = 0;
  8860. }
  8861. this.ratio = ratio = (yoyoEase || this._ease)(time / dur);
  8862. if (this._from) {
  8863. this.ratio = ratio = 1 - ratio;
  8864. }
  8865. if (time && !prevTime && !suppressEvents && !iteration) {
  8866. _callback(this, "onStart");
  8867. if (this._tTime !== tTime) {
  8868. return this;
  8869. }
  8870. }
  8871. pt = this._pt;
  8872. while (pt) {
  8873. pt.r(ratio, pt.d);
  8874. pt = pt._next;
  8875. }
  8876. timeline && timeline.render(totalTime < 0 ? totalTime : !time && isYoyo ? -_tinyNum : timeline._dur * timeline._ease(time / this._dur), suppressEvents, force) || this._startAt && (this._zTime = totalTime);
  8877. if (this._onUpdate && !suppressEvents) {
  8878. isNegative && _rewindStartAt(this, totalTime, suppressEvents, force);
  8879. _callback(this, "onUpdate");
  8880. }
  8881. this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat");
  8882. if ((tTime === this._tDur || !tTime) && this._tTime === tTime) {
  8883. isNegative && !this._onUpdate && _rewindStartAt(this, totalTime, true, true);
  8884. (totalTime || !dur) && (tTime === this._tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1);
  8885. if (!suppressEvents && !(isNegative && !prevTime) && (tTime || prevTime || isYoyo)) {
  8886. _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true);
  8887. this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();
  8888. }
  8889. }
  8890. }
  8891. return this;
  8892. };
  8893. _proto3.targets = function targets() {
  8894. return this._targets;
  8895. };
  8896. _proto3.invalidate = function invalidate(soft) {
  8897. (!soft || !this.vars.runBackwards) && (this._startAt = 0);
  8898. this._pt = this._op = this._onUpdate = this._lazy = this.ratio = 0;
  8899. this._ptLookup = [];
  8900. this.timeline && this.timeline.invalidate(soft);
  8901. return _Animation2.prototype.invalidate.call(this, soft);
  8902. };
  8903. _proto3.resetTo = function resetTo(property, value, start, startIsRelative, skipRecursion) {
  8904. _tickerActive || _ticker.wake();
  8905. this._ts || this.play();
  8906. var time = Math.min(this._dur, (this._dp._time - this._start) * this._ts),
  8907. ratio;
  8908. this._initted || _initTween(this, time);
  8909. ratio = this._ease(time / this._dur);
  8910. if (_updatePropTweens(this, property, value, start, startIsRelative, ratio, time, skipRecursion)) {
  8911. return this.resetTo(property, value, start, startIsRelative, 1);
  8912. }
  8913. _alignPlayhead(this, 0);
  8914. this.parent || _addLinkedListItem(this._dp, this, "_first", "_last", this._dp._sort ? "_start" : 0);
  8915. return this.render(0);
  8916. };
  8917. _proto3.kill = function kill(targets, vars) {
  8918. if (vars === void 0) {
  8919. vars = "all";
  8920. }
  8921. if (!targets && (!vars || vars === "all")) {
  8922. this._lazy = this._pt = 0;
  8923. return this.parent ? _interrupt(this) : this;
  8924. }
  8925. if (this.timeline) {
  8926. var tDur = this.timeline.totalDuration();
  8927. this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this);
  8928. this.parent && tDur !== this.timeline.totalDuration() && _setDuration(this, this._dur * this.timeline._tDur / tDur, 0, 1);
  8929. return this;
  8930. }
  8931. var parsedTargets = this._targets,
  8932. killingTargets = targets ? toArray(targets) : parsedTargets,
  8933. propTweenLookup = this._ptLookup,
  8934. firstPT = this._pt,
  8935. overwrittenProps,
  8936. curLookup,
  8937. curOverwriteProps,
  8938. props,
  8939. p,
  8940. pt,
  8941. i;
  8942. if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) {
  8943. vars === "all" && (this._pt = 0);
  8944. return _interrupt(this);
  8945. }
  8946. overwrittenProps = this._op = this._op || [];
  8947. if (vars !== "all") {
  8948. if (_isString(vars)) {
  8949. p = {};
  8950. _forEachName(vars, function (name) {
  8951. return p[name] = 1;
  8952. });
  8953. vars = p;
  8954. }
  8955. vars = _addAliasesToVars(parsedTargets, vars);
  8956. }
  8957. i = parsedTargets.length;
  8958. while (i--) {
  8959. if (~killingTargets.indexOf(parsedTargets[i])) {
  8960. curLookup = propTweenLookup[i];
  8961. if (vars === "all") {
  8962. overwrittenProps[i] = vars;
  8963. props = curLookup;
  8964. curOverwriteProps = {};
  8965. } else {
  8966. curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {};
  8967. props = vars;
  8968. }
  8969. for (p in props) {
  8970. pt = curLookup && curLookup[p];
  8971. if (pt) {
  8972. if (!("kill" in pt.d) || pt.d.kill(p) === true) {
  8973. _removeLinkedListItem(this, pt, "_pt");
  8974. }
  8975. delete curLookup[p];
  8976. }
  8977. if (curOverwriteProps !== "all") {
  8978. curOverwriteProps[p] = 1;
  8979. }
  8980. }
  8981. }
  8982. }
  8983. this._initted && !this._pt && firstPT && _interrupt(this);
  8984. return this;
  8985. };
  8986. Tween.to = function to(targets, vars) {
  8987. return new Tween(targets, vars, arguments[2]);
  8988. };
  8989. Tween.from = function from(targets, vars) {
  8990. return _createTweenType(1, arguments);
  8991. };
  8992. Tween.delayedCall = function delayedCall(delay, callback, params, scope) {
  8993. return new Tween(callback, 0, {
  8994. immediateRender: false,
  8995. lazy: false,
  8996. overwrite: false,
  8997. delay: delay,
  8998. onComplete: callback,
  8999. onReverseComplete: callback,
  9000. onCompleteParams: params,
  9001. onReverseCompleteParams: params,
  9002. callbackScope: scope
  9003. });
  9004. };
  9005. Tween.fromTo = function fromTo(targets, fromVars, toVars) {
  9006. return _createTweenType(2, arguments);
  9007. };
  9008. Tween.set = function set(targets, vars) {
  9009. vars.duration = 0;
  9010. vars.repeatDelay || (vars.repeat = 0);
  9011. return new Tween(targets, vars);
  9012. };
  9013. Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) {
  9014. return _globalTimeline.killTweensOf(targets, props, onlyActive);
  9015. };
  9016. return Tween;
  9017. }(Animation);
  9018. _setDefaults(Tween.prototype, {
  9019. _targets: [],
  9020. _lazy: 0,
  9021. _startAt: 0,
  9022. _op: 0,
  9023. _onInit: 0
  9024. });
  9025. _forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) {
  9026. Tween[name] = function () {
  9027. var tl = new Timeline(),
  9028. params = _slice.call(arguments, 0);
  9029. params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0);
  9030. return tl[name].apply(tl, params);
  9031. };
  9032. });
  9033. var _setterPlain = function _setterPlain(target, property, value) {
  9034. return target[property] = value;
  9035. },
  9036. _setterFunc = function _setterFunc(target, property, value) {
  9037. return target[property](value);
  9038. },
  9039. _setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) {
  9040. return target[property](data.fp, value);
  9041. },
  9042. _setterAttribute = function _setterAttribute(target, property, value) {
  9043. return target.setAttribute(property, value);
  9044. },
  9045. _getSetter = function _getSetter(target, property) {
  9046. return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain;
  9047. },
  9048. _renderPlain = function _renderPlain(ratio, data) {
  9049. return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 1000000) / 1000000, data);
  9050. },
  9051. _renderBoolean = function _renderBoolean(ratio, data) {
  9052. return data.set(data.t, data.p, !!(data.s + data.c * ratio), data);
  9053. },
  9054. _renderComplexString = function _renderComplexString(ratio, data) {
  9055. var pt = data._pt,
  9056. s = "";
  9057. if (!ratio && data.b) {
  9058. s = data.b;
  9059. } else if (ratio === 1 && data.e) {
  9060. s = data.e;
  9061. } else {
  9062. while (pt) {
  9063. s = pt.p + (pt.m ? pt.m(pt.s + pt.c * ratio) : Math.round((pt.s + pt.c * ratio) * 10000) / 10000) + s;
  9064. pt = pt._next;
  9065. }
  9066. s += data.c;
  9067. }
  9068. data.set(data.t, data.p, s, data);
  9069. },
  9070. _renderPropTweens = function _renderPropTweens(ratio, data) {
  9071. var pt = data._pt;
  9072. while (pt) {
  9073. pt.r(ratio, pt.d);
  9074. pt = pt._next;
  9075. }
  9076. },
  9077. _addPluginModifier = function _addPluginModifier(modifier, tween, target, property) {
  9078. var pt = this._pt,
  9079. next;
  9080. while (pt) {
  9081. next = pt._next;
  9082. pt.p === property && pt.modifier(modifier, tween, target);
  9083. pt = next;
  9084. }
  9085. },
  9086. _killPropTweensOf = function _killPropTweensOf(property) {
  9087. var pt = this._pt,
  9088. hasNonDependentRemaining,
  9089. next;
  9090. while (pt) {
  9091. next = pt._next;
  9092. if (pt.p === property && !pt.op || pt.op === property) {
  9093. _removeLinkedListItem(this, pt, "_pt");
  9094. } else if (!pt.dep) {
  9095. hasNonDependentRemaining = 1;
  9096. }
  9097. pt = next;
  9098. }
  9099. return !hasNonDependentRemaining;
  9100. },
  9101. _setterWithModifier = function _setterWithModifier(target, property, value, data) {
  9102. data.mSet(target, property, data.m.call(data.tween, value, data.mt), data);
  9103. },
  9104. _sortPropTweensByPriority = function _sortPropTweensByPriority(parent) {
  9105. var pt = parent._pt,
  9106. next,
  9107. pt2,
  9108. first,
  9109. last;
  9110. while (pt) {
  9111. next = pt._next;
  9112. pt2 = first;
  9113. while (pt2 && pt2.pr > pt.pr) {
  9114. pt2 = pt2._next;
  9115. }
  9116. if (pt._prev = pt2 ? pt2._prev : last) {
  9117. pt._prev._next = pt;
  9118. } else {
  9119. first = pt;
  9120. }
  9121. if (pt._next = pt2) {
  9122. pt2._prev = pt;
  9123. } else {
  9124. last = pt;
  9125. }
  9126. pt = next;
  9127. }
  9128. parent._pt = first;
  9129. };
  9130. var PropTween = function () {
  9131. function PropTween(next, target, prop, start, change, renderer, data, setter, priority) {
  9132. this.t = target;
  9133. this.s = start;
  9134. this.c = change;
  9135. this.p = prop;
  9136. this.r = renderer || _renderPlain;
  9137. this.d = data || this;
  9138. this.set = setter || _setterPlain;
  9139. this.pr = priority || 0;
  9140. this._next = next;
  9141. if (next) {
  9142. next._prev = this;
  9143. }
  9144. }
  9145. var _proto4 = PropTween.prototype;
  9146. _proto4.modifier = function modifier(func, tween, target) {
  9147. this.mSet = this.mSet || this.set;
  9148. this.set = _setterWithModifier;
  9149. this.m = func;
  9150. this.mt = target;
  9151. this.tween = tween;
  9152. };
  9153. return PropTween;
  9154. }();
  9155. _forEachName(_callbackNames + "parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger", function (name) {
  9156. return _reservedProps[name] = 1;
  9157. });
  9158. _globals.TweenMax = _globals.TweenLite = Tween;
  9159. _globals.TimelineLite = _globals.TimelineMax = Timeline;
  9160. _globalTimeline = new Timeline({
  9161. sortChildren: false,
  9162. defaults: _defaults,
  9163. autoRemoveChildren: true,
  9164. id: "root",
  9165. smoothChildTiming: true
  9166. });
  9167. _config.stringFilter = _colorStringFilter;
  9168. var _media = [],
  9169. _listeners = {},
  9170. _emptyArray = [],
  9171. _lastMediaTime = 0,
  9172. _contextID = 0,
  9173. _dispatch = function _dispatch(type) {
  9174. return (_listeners[type] || _emptyArray).map(function (f) {
  9175. return f();
  9176. });
  9177. },
  9178. _onMediaChange = function _onMediaChange() {
  9179. var time = Date.now(),
  9180. matches = [];
  9181. if (time - _lastMediaTime > 2) {
  9182. _dispatch("matchMediaInit");
  9183. _media.forEach(function (c) {
  9184. var queries = c.queries,
  9185. conditions = c.conditions,
  9186. match,
  9187. p,
  9188. anyMatch,
  9189. toggled;
  9190. for (p in queries) {
  9191. match = _win.matchMedia(queries[p]).matches;
  9192. match && (anyMatch = 1);
  9193. if (match !== conditions[p]) {
  9194. conditions[p] = match;
  9195. toggled = 1;
  9196. }
  9197. }
  9198. if (toggled) {
  9199. c.revert();
  9200. anyMatch && matches.push(c);
  9201. }
  9202. });
  9203. _dispatch("matchMediaRevert");
  9204. matches.forEach(function (c) {
  9205. return c.onMatch(c, function (func) {
  9206. return c.add(null, func);
  9207. });
  9208. });
  9209. _lastMediaTime = time;
  9210. _dispatch("matchMedia");
  9211. }
  9212. };
  9213. var Context = function () {
  9214. function Context(func, scope) {
  9215. this.selector = scope && selector(scope);
  9216. this.data = [];
  9217. this._r = [];
  9218. this.isReverted = false;
  9219. this.id = _contextID++;
  9220. func && this.add(func);
  9221. }
  9222. var _proto5 = Context.prototype;
  9223. _proto5.add = function add(name, func, scope) {
  9224. if (_isFunction(name)) {
  9225. scope = func;
  9226. func = name;
  9227. name = _isFunction;
  9228. }
  9229. var self = this,
  9230. f = function f() {
  9231. var prev = _context,
  9232. prevSelector = self.selector,
  9233. result;
  9234. prev && prev !== self && prev.data.push(self);
  9235. scope && (self.selector = selector(scope));
  9236. _context = self;
  9237. result = func.apply(self, arguments);
  9238. _isFunction(result) && self._r.push(result);
  9239. _context = prev;
  9240. self.selector = prevSelector;
  9241. self.isReverted = false;
  9242. return result;
  9243. };
  9244. self.last = f;
  9245. return name === _isFunction ? f(self, function (func) {
  9246. return self.add(null, func);
  9247. }) : name ? self[name] = f : f;
  9248. };
  9249. _proto5.ignore = function ignore(func) {
  9250. var prev = _context;
  9251. _context = null;
  9252. func(this);
  9253. _context = prev;
  9254. };
  9255. _proto5.getTweens = function getTweens() {
  9256. var a = [];
  9257. this.data.forEach(function (e) {
  9258. return e instanceof Context ? a.push.apply(a, e.getTweens()) : e instanceof Tween && !(e.parent && e.parent.data === "nested") && a.push(e);
  9259. });
  9260. return a;
  9261. };
  9262. _proto5.clear = function clear() {
  9263. this._r.length = this.data.length = 0;
  9264. };
  9265. _proto5.kill = function kill(revert, matchMedia) {
  9266. var _this4 = this;
  9267. if (revert) {
  9268. (function () {
  9269. var tweens = _this4.getTweens(),
  9270. i = _this4.data.length,
  9271. t;
  9272. while (i--) {
  9273. t = _this4.data[i];
  9274. if (t.data === "isFlip") {
  9275. t.revert();
  9276. t.getChildren(true, true, false).forEach(function (tween) {
  9277. return tweens.splice(tweens.indexOf(tween), 1);
  9278. });
  9279. }
  9280. }
  9281. tweens.map(function (t) {
  9282. return {
  9283. g: t._dur || t._delay || t._sat && !t._sat.vars.immediateRender ? t.globalTime(0) : -Infinity,
  9284. t: t
  9285. };
  9286. }).sort(function (a, b) {
  9287. return b.g - a.g || -Infinity;
  9288. }).forEach(function (o) {
  9289. return o.t.revert(revert);
  9290. });
  9291. i = _this4.data.length;
  9292. while (i--) {
  9293. t = _this4.data[i];
  9294. if (t instanceof Timeline) {
  9295. if (t.data !== "nested") {
  9296. t.scrollTrigger && t.scrollTrigger.revert();
  9297. t.kill();
  9298. }
  9299. } else {
  9300. !(t instanceof Tween) && t.revert && t.revert(revert);
  9301. }
  9302. }
  9303. _this4._r.forEach(function (f) {
  9304. return f(revert, _this4);
  9305. });
  9306. _this4.isReverted = true;
  9307. })();
  9308. } else {
  9309. this.data.forEach(function (e) {
  9310. return e.kill && e.kill();
  9311. });
  9312. }
  9313. this.clear();
  9314. if (matchMedia) {
  9315. var i = _media.length;
  9316. while (i--) {
  9317. _media[i].id === this.id && _media.splice(i, 1);
  9318. }
  9319. }
  9320. };
  9321. _proto5.revert = function revert(config) {
  9322. this.kill(config || {});
  9323. };
  9324. return Context;
  9325. }();
  9326. var MatchMedia = function () {
  9327. function MatchMedia(scope) {
  9328. this.contexts = [];
  9329. this.scope = scope;
  9330. }
  9331. var _proto6 = MatchMedia.prototype;
  9332. _proto6.add = function add(conditions, func, scope) {
  9333. _isObject(conditions) || (conditions = {
  9334. matches: conditions
  9335. });
  9336. var context = new Context(0, scope || this.scope),
  9337. cond = context.conditions = {},
  9338. mq,
  9339. p,
  9340. active;
  9341. _context && !context.selector && (context.selector = _context.selector);
  9342. this.contexts.push(context);
  9343. func = context.add("onMatch", func);
  9344. context.queries = conditions;
  9345. for (p in conditions) {
  9346. if (p === "all") {
  9347. active = 1;
  9348. } else {
  9349. mq = _win.matchMedia(conditions[p]);
  9350. if (mq) {
  9351. _media.indexOf(context) < 0 && _media.push(context);
  9352. (cond[p] = mq.matches) && (active = 1);
  9353. mq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener("change", _onMediaChange);
  9354. }
  9355. }
  9356. }
  9357. active && func(context, function (f) {
  9358. return context.add(null, f);
  9359. });
  9360. return this;
  9361. };
  9362. _proto6.revert = function revert(config) {
  9363. this.kill(config || {});
  9364. };
  9365. _proto6.kill = function kill(revert) {
  9366. this.contexts.forEach(function (c) {
  9367. return c.kill(revert, true);
  9368. });
  9369. };
  9370. return MatchMedia;
  9371. }();
  9372. var _gsap = {
  9373. registerPlugin: function registerPlugin() {
  9374. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  9375. args[_key2] = arguments[_key2];
  9376. }
  9377. args.forEach(function (config) {
  9378. return _createPlugin(config);
  9379. });
  9380. },
  9381. timeline: function timeline(vars) {
  9382. return new Timeline(vars);
  9383. },
  9384. getTweensOf: function getTweensOf(targets, onlyActive) {
  9385. return _globalTimeline.getTweensOf(targets, onlyActive);
  9386. },
  9387. getProperty: function getProperty(target, property, unit, uncache) {
  9388. _isString(target) && (target = toArray(target)[0]);
  9389. var getter = _getCache(target || {}).get,
  9390. format = unit ? _passThrough : _numericIfPossible;
  9391. unit === "native" && (unit = "");
  9392. return !target ? target : !property ? function (property, unit, uncache) {
  9393. return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
  9394. } : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache));
  9395. },
  9396. quickSetter: function quickSetter(target, property, unit) {
  9397. target = toArray(target);
  9398. if (target.length > 1) {
  9399. var setters = target.map(function (t) {
  9400. return gsap.quickSetter(t, property, unit);
  9401. }),
  9402. l = setters.length;
  9403. return function (value) {
  9404. var i = l;
  9405. while (i--) {
  9406. setters[i](value);
  9407. }
  9408. };
  9409. }
  9410. target = target[0] || {};
  9411. var Plugin = _plugins[property],
  9412. cache = _getCache(target),
  9413. p = cache.harness && (cache.harness.aliases || {})[property] || property,
  9414. setter = Plugin ? function (value) {
  9415. var p = new Plugin();
  9416. _quickTween._pt = 0;
  9417. p.init(target, unit ? value + unit : value, _quickTween, 0, [target]);
  9418. p.render(1, p);
  9419. _quickTween._pt && _renderPropTweens(1, _quickTween);
  9420. } : cache.set(target, p);
  9421. return Plugin ? setter : function (value) {
  9422. return setter(target, p, unit ? value + unit : value, cache, 1);
  9423. };
  9424. },
  9425. quickTo: function quickTo(target, property, vars) {
  9426. var _merge2;
  9427. var tween = gsap.to(target, _merge((_merge2 = {}, _merge2[property] = "+=0.1", _merge2.paused = true, _merge2), vars || {})),
  9428. func = function func(value, start, startIsRelative) {
  9429. return tween.resetTo(property, value, start, startIsRelative);
  9430. };
  9431. func.tween = tween;
  9432. return func;
  9433. },
  9434. isTweening: function isTweening(targets) {
  9435. return _globalTimeline.getTweensOf(targets, true).length > 0;
  9436. },
  9437. defaults: function defaults(value) {
  9438. value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease));
  9439. return _mergeDeep(_defaults, value || {});
  9440. },
  9441. config: function config(value) {
  9442. return _mergeDeep(_config, value || {});
  9443. },
  9444. registerEffect: function registerEffect(_ref3) {
  9445. var name = _ref3.name,
  9446. effect = _ref3.effect,
  9447. plugins = _ref3.plugins,
  9448. defaults = _ref3.defaults,
  9449. extendTimeline = _ref3.extendTimeline;
  9450. (plugins || "").split(",").forEach(function (pluginName) {
  9451. return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin.");
  9452. });
  9453. _effects[name] = function (targets, vars, tl) {
  9454. return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl);
  9455. };
  9456. if (extendTimeline) {
  9457. Timeline.prototype[name] = function (targets, vars, position) {
  9458. return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position);
  9459. };
  9460. }
  9461. },
  9462. registerEase: function registerEase(name, ease) {
  9463. _easeMap[name] = _parseEase(ease);
  9464. },
  9465. parseEase: function parseEase(ease, defaultEase) {
  9466. return arguments.length ? _parseEase(ease, defaultEase) : _easeMap;
  9467. },
  9468. getById: function getById(id) {
  9469. return _globalTimeline.getById(id);
  9470. },
  9471. exportRoot: function exportRoot(vars, includeDelayedCalls) {
  9472. if (vars === void 0) {
  9473. vars = {};
  9474. }
  9475. var tl = new Timeline(vars),
  9476. child,
  9477. next;
  9478. tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming);
  9479. _globalTimeline.remove(tl);
  9480. tl._dp = 0;
  9481. tl._time = tl._tTime = _globalTimeline._time;
  9482. child = _globalTimeline._first;
  9483. while (child) {
  9484. next = child._next;
  9485. if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) {
  9486. _addToTimeline(tl, child, child._start - child._delay);
  9487. }
  9488. child = next;
  9489. }
  9490. _addToTimeline(_globalTimeline, tl, 0);
  9491. return tl;
  9492. },
  9493. context: function context(func, scope) {
  9494. return func ? new Context(func, scope) : _context;
  9495. },
  9496. matchMedia: function matchMedia(scope) {
  9497. return new MatchMedia(scope);
  9498. },
  9499. matchMediaRefresh: function matchMediaRefresh() {
  9500. return _media.forEach(function (c) {
  9501. var cond = c.conditions,
  9502. found,
  9503. p;
  9504. for (p in cond) {
  9505. if (cond[p]) {
  9506. cond[p] = false;
  9507. found = 1;
  9508. }
  9509. }
  9510. found && c.revert();
  9511. }) || _onMediaChange();
  9512. },
  9513. addEventListener: function addEventListener(type, callback) {
  9514. var a = _listeners[type] || (_listeners[type] = []);
  9515. ~a.indexOf(callback) || a.push(callback);
  9516. },
  9517. removeEventListener: function removeEventListener(type, callback) {
  9518. var a = _listeners[type],
  9519. i = a && a.indexOf(callback);
  9520. i >= 0 && a.splice(i, 1);
  9521. },
  9522. utils: {
  9523. wrap: wrap,
  9524. wrapYoyo: wrapYoyo,
  9525. distribute: distribute,
  9526. random: random,
  9527. snap: snap,
  9528. normalize: normalize,
  9529. getUnit: getUnit,
  9530. clamp: clamp,
  9531. splitColor: splitColor,
  9532. toArray: toArray,
  9533. selector: selector,
  9534. mapRange: mapRange,
  9535. pipe: pipe,
  9536. unitize: unitize,
  9537. interpolate: interpolate,
  9538. shuffle: shuffle
  9539. },
  9540. install: _install,
  9541. effects: _effects,
  9542. ticker: _ticker,
  9543. updateRoot: Timeline.updateRoot,
  9544. plugins: _plugins,
  9545. globalTimeline: _globalTimeline,
  9546. core: {
  9547. PropTween: PropTween,
  9548. globals: _addGlobal,
  9549. Tween: Tween,
  9550. Timeline: Timeline,
  9551. Animation: Animation,
  9552. getCache: _getCache,
  9553. _removeLinkedListItem: _removeLinkedListItem,
  9554. reverting: function reverting() {
  9555. return _reverting;
  9556. },
  9557. context: function context(toAdd) {
  9558. if (toAdd && _context) {
  9559. _context.data.push(toAdd);
  9560. toAdd._ctx = _context;
  9561. }
  9562. return _context;
  9563. },
  9564. suppressOverwrites: function suppressOverwrites(value) {
  9565. return _suppressOverwrites = value;
  9566. }
  9567. }
  9568. };
  9569. _forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) {
  9570. return _gsap[name] = Tween[name];
  9571. });
  9572. _ticker.add(Timeline.updateRoot);
  9573. _quickTween = _gsap.to({}, {
  9574. duration: 0
  9575. });
  9576. var _getPluginPropTween = function _getPluginPropTween(plugin, prop) {
  9577. var pt = plugin._pt;
  9578. while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) {
  9579. pt = pt._next;
  9580. }
  9581. return pt;
  9582. },
  9583. _addModifiers = function _addModifiers(tween, modifiers) {
  9584. var targets = tween._targets,
  9585. p,
  9586. i,
  9587. pt;
  9588. for (p in modifiers) {
  9589. i = targets.length;
  9590. while (i--) {
  9591. pt = tween._ptLookup[i][p];
  9592. if (pt && (pt = pt.d)) {
  9593. if (pt._pt) {
  9594. pt = _getPluginPropTween(pt, p);
  9595. }
  9596. pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p);
  9597. }
  9598. }
  9599. }
  9600. },
  9601. _buildModifierPlugin = function _buildModifierPlugin(name, modifier) {
  9602. return {
  9603. name: name,
  9604. rawVars: 1,
  9605. init: function init(target, vars, tween) {
  9606. tween._onInit = function (tween) {
  9607. var temp, p;
  9608. if (_isString(vars)) {
  9609. temp = {};
  9610. _forEachName(vars, function (name) {
  9611. return temp[name] = 1;
  9612. });
  9613. vars = temp;
  9614. }
  9615. if (modifier) {
  9616. temp = {};
  9617. for (p in vars) {
  9618. temp[p] = modifier(vars[p]);
  9619. }
  9620. vars = temp;
  9621. }
  9622. _addModifiers(tween, vars);
  9623. };
  9624. }
  9625. };
  9626. };
  9627. var gsap = _gsap.registerPlugin({
  9628. name: "attr",
  9629. init: function init(target, vars, tween, index, targets) {
  9630. var p, pt, v;
  9631. this.tween = tween;
  9632. for (p in vars) {
  9633. v = target.getAttribute(p) || "";
  9634. pt = this.add(target, "setAttribute", (v || 0) + "", vars[p], index, targets, 0, 0, p);
  9635. pt.op = p;
  9636. pt.b = v;
  9637. this._props.push(p);
  9638. }
  9639. },
  9640. render: function render(ratio, data) {
  9641. var pt = data._pt;
  9642. while (pt) {
  9643. _reverting ? pt.set(pt.t, pt.p, pt.b, pt) : pt.r(ratio, pt.d);
  9644. pt = pt._next;
  9645. }
  9646. }
  9647. }, {
  9648. name: "endArray",
  9649. init: function init(target, value) {
  9650. var i = value.length;
  9651. while (i--) {
  9652. this.add(target, i, target[i] || 0, value[i], 0, 0, 0, 0, 0, 1);
  9653. }
  9654. }
  9655. }, _buildModifierPlugin("roundProps", _roundModifier), _buildModifierPlugin("modifiers"), _buildModifierPlugin("snap", snap)) || _gsap;
  9656. Tween.version = Timeline.version = gsap.version = "3.12.4";
  9657. _coreReady = 1;
  9658. _windowExists() && _wake();
  9659. var Power0 = _easeMap.Power0,
  9660. Power1 = _easeMap.Power1,
  9661. Power2 = _easeMap.Power2,
  9662. Power3 = _easeMap.Power3,
  9663. Power4 = _easeMap.Power4,
  9664. Linear = _easeMap.Linear,
  9665. Quad = _easeMap.Quad,
  9666. Cubic = _easeMap.Cubic,
  9667. Quart = _easeMap.Quart,
  9668. Quint = _easeMap.Quint,
  9669. Strong = _easeMap.Strong,
  9670. Elastic = _easeMap.Elastic,
  9671. Back = _easeMap.Back,
  9672. SteppedEase = _easeMap.SteppedEase,
  9673. Bounce = _easeMap.Bounce,
  9674. Sine = _easeMap.Sine,
  9675. Expo = _easeMap.Expo,
  9676. Circ = _easeMap.Circ;
  9677. var _win$1,
  9678. _doc$1,
  9679. _docElement,
  9680. _pluginInitted,
  9681. _tempDiv,
  9682. _tempDivStyler,
  9683. _recentSetterPlugin,
  9684. _reverting$1,
  9685. _windowExists$1 = function _windowExists() {
  9686. return typeof window !== "undefined";
  9687. },
  9688. _transformProps = {},
  9689. _RAD2DEG = 180 / Math.PI,
  9690. _DEG2RAD = Math.PI / 180,
  9691. _atan2 = Math.atan2,
  9692. _bigNum$1 = 1e8,
  9693. _capsExp = /([A-Z])/g,
  9694. _horizontalExp = /(left|right|width|margin|padding|x)/i,
  9695. _complexExp = /[\s,\(]\S/,
  9696. _propertyAliases = {
  9697. autoAlpha: "opacity,visibility",
  9698. scale: "scaleX,scaleY",
  9699. alpha: "opacity"
  9700. },
  9701. _renderCSSProp = function _renderCSSProp(ratio, data) {
  9702. return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
  9703. },
  9704. _renderPropWithEnd = function _renderPropWithEnd(ratio, data) {
  9705. return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data);
  9706. },
  9707. _renderCSSPropWithBeginning = function _renderCSSPropWithBeginning(ratio, data) {
  9708. return data.set(data.t, data.p, ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data);
  9709. },
  9710. _renderRoundedCSSProp = function _renderRoundedCSSProp(ratio, data) {
  9711. var value = data.s + data.c * ratio;
  9712. data.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data);
  9713. },
  9714. _renderNonTweeningValue = function _renderNonTweeningValue(ratio, data) {
  9715. return data.set(data.t, data.p, ratio ? data.e : data.b, data);
  9716. },
  9717. _renderNonTweeningValueOnlyAtEnd = function _renderNonTweeningValueOnlyAtEnd(ratio, data) {
  9718. return data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data);
  9719. },
  9720. _setterCSSStyle = function _setterCSSStyle(target, property, value) {
  9721. return target.style[property] = value;
  9722. },
  9723. _setterCSSProp = function _setterCSSProp(target, property, value) {
  9724. return target.style.setProperty(property, value);
  9725. },
  9726. _setterTransform = function _setterTransform(target, property, value) {
  9727. return target._gsap[property] = value;
  9728. },
  9729. _setterScale = function _setterScale(target, property, value) {
  9730. return target._gsap.scaleX = target._gsap.scaleY = value;
  9731. },
  9732. _setterScaleWithRender = function _setterScaleWithRender(target, property, value, data, ratio) {
  9733. var cache = target._gsap;
  9734. cache.scaleX = cache.scaleY = value;
  9735. cache.renderTransform(ratio, cache);
  9736. },
  9737. _setterTransformWithRender = function _setterTransformWithRender(target, property, value, data, ratio) {
  9738. var cache = target._gsap;
  9739. cache[property] = value;
  9740. cache.renderTransform(ratio, cache);
  9741. },
  9742. _transformProp = "transform",
  9743. _transformOriginProp = _transformProp + "Origin",
  9744. _saveStyle = function _saveStyle(property, isNotCSS) {
  9745. var _this = this;
  9746. var target = this.target,
  9747. style = target.style,
  9748. cache = target._gsap;
  9749. if (property in _transformProps && style) {
  9750. this.tfm = this.tfm || {};
  9751. if (property !== "transform") {
  9752. property = _propertyAliases[property] || property;
  9753. ~property.indexOf(",") ? property.split(",").forEach(function (a) {
  9754. return _this.tfm[a] = _get(target, a);
  9755. }) : this.tfm[property] = cache.x ? cache[property] : _get(target, property);
  9756. property === _transformOriginProp && (this.tfm.zOrigin = cache.zOrigin);
  9757. } else {
  9758. return _propertyAliases.transform.split(",").forEach(function (p) {
  9759. return _saveStyle.call(_this, p, isNotCSS);
  9760. });
  9761. }
  9762. if (this.props.indexOf(_transformProp) >= 0) {
  9763. return;
  9764. }
  9765. if (cache.svg) {
  9766. this.svgo = target.getAttribute("data-svg-origin");
  9767. this.props.push(_transformOriginProp, isNotCSS, "");
  9768. }
  9769. property = _transformProp;
  9770. }
  9771. (style || isNotCSS) && this.props.push(property, isNotCSS, style[property]);
  9772. },
  9773. _removeIndependentTransforms = function _removeIndependentTransforms(style) {
  9774. if (style.translate) {
  9775. style.removeProperty("translate");
  9776. style.removeProperty("scale");
  9777. style.removeProperty("rotate");
  9778. }
  9779. },
  9780. _revertStyle = function _revertStyle() {
  9781. var props = this.props,
  9782. target = this.target,
  9783. style = target.style,
  9784. cache = target._gsap,
  9785. i,
  9786. p;
  9787. for (i = 0; i < props.length; i += 3) {
  9788. props[i + 1] ? target[props[i]] = props[i + 2] : props[i + 2] ? style[props[i]] = props[i + 2] : style.removeProperty(props[i].substr(0, 2) === "--" ? props[i] : props[i].replace(_capsExp, "-$1").toLowerCase());
  9789. }
  9790. if (this.tfm) {
  9791. for (p in this.tfm) {
  9792. cache[p] = this.tfm[p];
  9793. }
  9794. if (cache.svg) {
  9795. cache.renderTransform();
  9796. target.setAttribute("data-svg-origin", this.svgo || "");
  9797. }
  9798. i = _reverting$1();
  9799. if ((!i || !i.isStart) && !style[_transformProp]) {
  9800. _removeIndependentTransforms(style);
  9801. if (cache.zOrigin && style[_transformOriginProp]) {
  9802. style[_transformOriginProp] += " " + cache.zOrigin + "px";
  9803. cache.zOrigin = 0;
  9804. cache.renderTransform();
  9805. }
  9806. cache.uncache = 1;
  9807. }
  9808. }
  9809. },
  9810. _getStyleSaver = function _getStyleSaver(target, properties) {
  9811. var saver = {
  9812. target: target,
  9813. props: [],
  9814. revert: _revertStyle,
  9815. save: _saveStyle
  9816. };
  9817. target._gsap || gsap.core.getCache(target);
  9818. properties && properties.split(",").forEach(function (p) {
  9819. return saver.save(p);
  9820. });
  9821. return saver;
  9822. },
  9823. _supports3D,
  9824. _createElement = function _createElement(type, ns) {
  9825. var e = _doc$1.createElementNS ? _doc$1.createElementNS((ns || "http://www.w3.org/1999/xhtml").replace(/^https/, "http"), type) : _doc$1.createElement(type);
  9826. return e && e.style ? e : _doc$1.createElement(type);
  9827. },
  9828. _getComputedProperty = function _getComputedProperty(target, property, skipPrefixFallback) {
  9829. var cs = getComputedStyle(target);
  9830. return cs[property] || cs.getPropertyValue(property.replace(_capsExp, "-$1").toLowerCase()) || cs.getPropertyValue(property) || !skipPrefixFallback && _getComputedProperty(target, _checkPropPrefix(property) || property, 1) || "";
  9831. },
  9832. _prefixes = "O,Moz,ms,Ms,Webkit".split(","),
  9833. _checkPropPrefix = function _checkPropPrefix(property, element, preferPrefix) {
  9834. var e = element || _tempDiv,
  9835. s = e.style,
  9836. i = 5;
  9837. if (property in s && !preferPrefix) {
  9838. return property;
  9839. }
  9840. property = property.charAt(0).toUpperCase() + property.substr(1);
  9841. while (i-- && !(_prefixes[i] + property in s)) {}
  9842. return i < 0 ? null : (i === 3 ? "ms" : i >= 0 ? _prefixes[i] : "") + property;
  9843. },
  9844. _initCore = function _initCore() {
  9845. if (_windowExists$1() && window.document) {
  9846. _win$1 = window;
  9847. _doc$1 = _win$1.document;
  9848. _docElement = _doc$1.documentElement;
  9849. _tempDiv = _createElement("div") || {
  9850. style: {}
  9851. };
  9852. _tempDivStyler = _createElement("div");
  9853. _transformProp = _checkPropPrefix(_transformProp);
  9854. _transformOriginProp = _transformProp + "Origin";
  9855. _tempDiv.style.cssText = "border-width:0;line-height:0;position:absolute;padding:0";
  9856. _supports3D = !!_checkPropPrefix("perspective");
  9857. _reverting$1 = gsap.core.reverting;
  9858. _pluginInitted = 1;
  9859. }
  9860. },
  9861. _getBBoxHack = function _getBBoxHack(swapIfPossible) {
  9862. var svg = _createElement("svg", this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns") || "http://www.w3.org/2000/svg"),
  9863. oldParent = this.parentNode,
  9864. oldSibling = this.nextSibling,
  9865. oldCSS = this.style.cssText,
  9866. bbox;
  9867. _docElement.appendChild(svg);
  9868. svg.appendChild(this);
  9869. this.style.display = "block";
  9870. if (swapIfPossible) {
  9871. try {
  9872. bbox = this.getBBox();
  9873. this._gsapBBox = this.getBBox;
  9874. this.getBBox = _getBBoxHack;
  9875. } catch (e) {}
  9876. } else if (this._gsapBBox) {
  9877. bbox = this._gsapBBox();
  9878. }
  9879. if (oldParent) {
  9880. if (oldSibling) {
  9881. oldParent.insertBefore(this, oldSibling);
  9882. } else {
  9883. oldParent.appendChild(this);
  9884. }
  9885. }
  9886. _docElement.removeChild(svg);
  9887. this.style.cssText = oldCSS;
  9888. return bbox;
  9889. },
  9890. _getAttributeFallbacks = function _getAttributeFallbacks(target, attributesArray) {
  9891. var i = attributesArray.length;
  9892. while (i--) {
  9893. if (target.hasAttribute(attributesArray[i])) {
  9894. return target.getAttribute(attributesArray[i]);
  9895. }
  9896. }
  9897. },
  9898. _getBBox = function _getBBox(target) {
  9899. var bounds;
  9900. try {
  9901. bounds = target.getBBox();
  9902. } catch (error) {
  9903. bounds = _getBBoxHack.call(target, true);
  9904. }
  9905. bounds && (bounds.width || bounds.height) || target.getBBox === _getBBoxHack || (bounds = _getBBoxHack.call(target, true));
  9906. return bounds && !bounds.width && !bounds.x && !bounds.y ? {
  9907. x: +_getAttributeFallbacks(target, ["x", "cx", "x1"]) || 0,
  9908. y: +_getAttributeFallbacks(target, ["y", "cy", "y1"]) || 0,
  9909. width: 0,
  9910. height: 0
  9911. } : bounds;
  9912. },
  9913. _isSVG = function _isSVG(e) {
  9914. return !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e));
  9915. },
  9916. _removeProperty = function _removeProperty(target, property) {
  9917. if (property) {
  9918. var style = target.style,
  9919. first2Chars;
  9920. if (property in _transformProps && property !== _transformOriginProp) {
  9921. property = _transformProp;
  9922. }
  9923. if (style.removeProperty) {
  9924. first2Chars = property.substr(0, 2);
  9925. if (first2Chars === "ms" || property.substr(0, 6) === "webkit") {
  9926. property = "-" + property;
  9927. }
  9928. style.removeProperty(first2Chars === "--" ? property : property.replace(_capsExp, "-$1").toLowerCase());
  9929. } else {
  9930. style.removeAttribute(property);
  9931. }
  9932. }
  9933. },
  9934. _addNonTweeningPT = function _addNonTweeningPT(plugin, target, property, beginning, end, onlySetAtEnd) {
  9935. var pt = new PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue);
  9936. plugin._pt = pt;
  9937. pt.b = beginning;
  9938. pt.e = end;
  9939. plugin._props.push(property);
  9940. return pt;
  9941. },
  9942. _nonConvertibleUnits = {
  9943. deg: 1,
  9944. rad: 1,
  9945. turn: 1
  9946. },
  9947. _nonStandardLayouts = {
  9948. grid: 1,
  9949. flex: 1
  9950. },
  9951. _convertToUnit = function _convertToUnit(target, property, value, unit) {
  9952. var curValue = parseFloat(value) || 0,
  9953. curUnit = (value + "").trim().substr((curValue + "").length) || "px",
  9954. style = _tempDiv.style,
  9955. horizontal = _horizontalExp.test(property),
  9956. isRootSVG = target.tagName.toLowerCase() === "svg",
  9957. measureProperty = (isRootSVG ? "client" : "offset") + (horizontal ? "Width" : "Height"),
  9958. amount = 100,
  9959. toPixels = unit === "px",
  9960. toPercent = unit === "%",
  9961. px,
  9962. parent,
  9963. cache,
  9964. isSVG;
  9965. if (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) {
  9966. return curValue;
  9967. }
  9968. curUnit !== "px" && !toPixels && (curValue = _convertToUnit(target, property, value, "px"));
  9969. isSVG = target.getCTM && _isSVG(target);
  9970. if ((toPercent || curUnit === "%") && (_transformProps[property] || ~property.indexOf("adius"))) {
  9971. px = isSVG ? target.getBBox()[horizontal ? "width" : "height"] : target[measureProperty];
  9972. return _round(toPercent ? curValue / px * amount : curValue / 100 * px);
  9973. }
  9974. style[horizontal ? "width" : "height"] = amount + (toPixels ? curUnit : unit);
  9975. parent = ~property.indexOf("adius") || unit === "em" && target.appendChild && !isRootSVG ? target : target.parentNode;
  9976. if (isSVG) {
  9977. parent = (target.ownerSVGElement || {}).parentNode;
  9978. }
  9979. if (!parent || parent === _doc$1 || !parent.appendChild) {
  9980. parent = _doc$1.body;
  9981. }
  9982. cache = parent._gsap;
  9983. if (cache && toPercent && cache.width && horizontal && cache.time === _ticker.time && !cache.uncache) {
  9984. return _round(curValue / cache.width * amount);
  9985. } else {
  9986. if (toPercent && (property === "height" || property === "width")) {
  9987. var v = target.style[property];
  9988. target.style[property] = amount + unit;
  9989. px = target[measureProperty];
  9990. v ? target.style[property] = v : _removeProperty(target, property);
  9991. } else {
  9992. (toPercent || curUnit === "%") && !_nonStandardLayouts[_getComputedProperty(parent, "display")] && (style.position = _getComputedProperty(target, "position"));
  9993. parent === target && (style.position = "static");
  9994. parent.appendChild(_tempDiv);
  9995. px = _tempDiv[measureProperty];
  9996. parent.removeChild(_tempDiv);
  9997. style.position = "absolute";
  9998. }
  9999. if (horizontal && toPercent) {
  10000. cache = _getCache(parent);
  10001. cache.time = _ticker.time;
  10002. cache.width = parent[measureProperty];
  10003. }
  10004. }
  10005. return _round(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0);
  10006. },
  10007. _get = function _get(target, property, unit, uncache) {
  10008. var value;
  10009. _pluginInitted || _initCore();
  10010. if (property in _propertyAliases && property !== "transform") {
  10011. property = _propertyAliases[property];
  10012. if (~property.indexOf(",")) {
  10013. property = property.split(",")[0];
  10014. }
  10015. }
  10016. if (_transformProps[property] && property !== "transform") {
  10017. value = _parseTransform(target, uncache);
  10018. value = property !== "transformOrigin" ? value[property] : value.svg ? value.origin : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + " " + value.zOrigin + "px";
  10019. } else {
  10020. value = target.style[property];
  10021. if (!value || value === "auto" || uncache || ~(value + "").indexOf("calc(")) {
  10022. value = _specialProps[property] && _specialProps[property](target, property, unit) || _getComputedProperty(target, property) || _getProperty(target, property) || (property === "opacity" ? 1 : 0);
  10023. }
  10024. }
  10025. return unit && !~(value + "").trim().indexOf(" ") ? _convertToUnit(target, property, value, unit) + unit : value;
  10026. },
  10027. _tweenComplexCSSString = function _tweenComplexCSSString(target, prop, start, end) {
  10028. if (!start || start === "none") {
  10029. var p = _checkPropPrefix(prop, target, 1),
  10030. s = p && _getComputedProperty(target, p, 1);
  10031. if (s && s !== start) {
  10032. prop = p;
  10033. start = s;
  10034. } else if (prop === "borderColor") {
  10035. start = _getComputedProperty(target, "borderTopColor");
  10036. }
  10037. }
  10038. var pt = new PropTween(this._pt, target.style, prop, 0, 1, _renderComplexString),
  10039. index = 0,
  10040. matchIndex = 0,
  10041. a,
  10042. result,
  10043. startValues,
  10044. startNum,
  10045. color,
  10046. startValue,
  10047. endValue,
  10048. endNum,
  10049. chunk,
  10050. endUnit,
  10051. startUnit,
  10052. endValues;
  10053. pt.b = start;
  10054. pt.e = end;
  10055. start += "";
  10056. end += "";
  10057. if (end === "auto") {
  10058. startValue = target.style[prop];
  10059. target.style[prop] = end;
  10060. end = _getComputedProperty(target, prop) || end;
  10061. startValue ? target.style[prop] = startValue : _removeProperty(target, prop);
  10062. }
  10063. a = [start, end];
  10064. _colorStringFilter(a);
  10065. start = a[0];
  10066. end = a[1];
  10067. startValues = start.match(_numWithUnitExp) || [];
  10068. endValues = end.match(_numWithUnitExp) || [];
  10069. if (endValues.length) {
  10070. while (result = _numWithUnitExp.exec(end)) {
  10071. endValue = result[0];
  10072. chunk = end.substring(index, result.index);
  10073. if (color) {
  10074. color = (color + 1) % 5;
  10075. } else if (chunk.substr(-5) === "rgba(" || chunk.substr(-5) === "hsla(") {
  10076. color = 1;
  10077. }
  10078. if (endValue !== (startValue = startValues[matchIndex++] || "")) {
  10079. startNum = parseFloat(startValue) || 0;
  10080. startUnit = startValue.substr((startNum + "").length);
  10081. endValue.charAt(1) === "=" && (endValue = _parseRelative(startNum, endValue) + startUnit);
  10082. endNum = parseFloat(endValue);
  10083. endUnit = endValue.substr((endNum + "").length);
  10084. index = _numWithUnitExp.lastIndex - endUnit.length;
  10085. if (!endUnit) {
  10086. endUnit = endUnit || _config.units[prop] || startUnit;
  10087. if (index === end.length) {
  10088. end += endUnit;
  10089. pt.e += endUnit;
  10090. }
  10091. }
  10092. if (startUnit !== endUnit) {
  10093. startNum = _convertToUnit(target, prop, startValue, endUnit) || 0;
  10094. }
  10095. pt._pt = {
  10096. _next: pt._pt,
  10097. p: chunk || matchIndex === 1 ? chunk : ",",
  10098. s: startNum,
  10099. c: endNum - startNum,
  10100. m: color && color < 4 || prop === "zIndex" ? Math.round : 0
  10101. };
  10102. }
  10103. }
  10104. pt.c = index < end.length ? end.substring(index, end.length) : "";
  10105. } else {
  10106. pt.r = prop === "display" && end === "none" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue;
  10107. }
  10108. _relExp.test(end) && (pt.e = 0);
  10109. this._pt = pt;
  10110. return pt;
  10111. },
  10112. _keywordToPercent = {
  10113. top: "0%",
  10114. bottom: "100%",
  10115. left: "0%",
  10116. right: "100%",
  10117. center: "50%"
  10118. },
  10119. _convertKeywordsToPercentages = function _convertKeywordsToPercentages(value) {
  10120. var split = value.split(" "),
  10121. x = split[0],
  10122. y = split[1] || "50%";
  10123. if (x === "top" || x === "bottom" || y === "left" || y === "right") {
  10124. value = x;
  10125. x = y;
  10126. y = value;
  10127. }
  10128. split[0] = _keywordToPercent[x] || x;
  10129. split[1] = _keywordToPercent[y] || y;
  10130. return split.join(" ");
  10131. },
  10132. _renderClearProps = function _renderClearProps(ratio, data) {
  10133. if (data.tween && data.tween._time === data.tween._dur) {
  10134. var target = data.t,
  10135. style = target.style,
  10136. props = data.u,
  10137. cache = target._gsap,
  10138. prop,
  10139. clearTransforms,
  10140. i;
  10141. if (props === "all" || props === true) {
  10142. style.cssText = "";
  10143. clearTransforms = 1;
  10144. } else {
  10145. props = props.split(",");
  10146. i = props.length;
  10147. while (--i > -1) {
  10148. prop = props[i];
  10149. if (_transformProps[prop]) {
  10150. clearTransforms = 1;
  10151. prop = prop === "transformOrigin" ? _transformOriginProp : _transformProp;
  10152. }
  10153. _removeProperty(target, prop);
  10154. }
  10155. }
  10156. if (clearTransforms) {
  10157. _removeProperty(target, _transformProp);
  10158. if (cache) {
  10159. cache.svg && target.removeAttribute("transform");
  10160. _parseTransform(target, 1);
  10161. cache.uncache = 1;
  10162. _removeIndependentTransforms(style);
  10163. }
  10164. }
  10165. }
  10166. },
  10167. _specialProps = {
  10168. clearProps: function clearProps(plugin, target, property, endValue, tween) {
  10169. if (tween.data !== "isFromStart") {
  10170. var pt = plugin._pt = new PropTween(plugin._pt, target, property, 0, 0, _renderClearProps);
  10171. pt.u = endValue;
  10172. pt.pr = -10;
  10173. pt.tween = tween;
  10174. plugin._props.push(property);
  10175. return 1;
  10176. }
  10177. }
  10178. },
  10179. _identity2DMatrix = [1, 0, 0, 1, 0, 0],
  10180. _rotationalProperties = {},
  10181. _isNullTransform = function _isNullTransform(value) {
  10182. return value === "matrix(1, 0, 0, 1, 0, 0)" || value === "none" || !value;
  10183. },
  10184. _getComputedTransformMatrixAsArray = function _getComputedTransformMatrixAsArray(target) {
  10185. var matrixString = _getComputedProperty(target, _transformProp);
  10186. return _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_numExp).map(_round);
  10187. },
  10188. _getMatrix = function _getMatrix(target, force2D) {
  10189. var cache = target._gsap || _getCache(target),
  10190. style = target.style,
  10191. matrix = _getComputedTransformMatrixAsArray(target),
  10192. parent,
  10193. nextSibling,
  10194. temp,
  10195. addedToDOM;
  10196. if (cache.svg && target.getAttribute("transform")) {
  10197. temp = target.transform.baseVal.consolidate().matrix;
  10198. matrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f];
  10199. return matrix.join(",") === "1,0,0,1,0,0" ? _identity2DMatrix : matrix;
  10200. } else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) {
  10201. temp = style.display;
  10202. style.display = "block";
  10203. parent = target.parentNode;
  10204. if (!parent || !target.offsetParent) {
  10205. addedToDOM = 1;
  10206. nextSibling = target.nextElementSibling;
  10207. _docElement.appendChild(target);
  10208. }
  10209. matrix = _getComputedTransformMatrixAsArray(target);
  10210. temp ? style.display = temp : _removeProperty(target, "display");
  10211. if (addedToDOM) {
  10212. nextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target);
  10213. }
  10214. }
  10215. return force2D && matrix.length > 6 ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix;
  10216. },
  10217. _applySVGOrigin = function _applySVGOrigin(target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) {
  10218. var cache = target._gsap,
  10219. matrix = matrixArray || _getMatrix(target, true),
  10220. xOriginOld = cache.xOrigin || 0,
  10221. yOriginOld = cache.yOrigin || 0,
  10222. xOffsetOld = cache.xOffset || 0,
  10223. yOffsetOld = cache.yOffset || 0,
  10224. a = matrix[0],
  10225. b = matrix[1],
  10226. c = matrix[2],
  10227. d = matrix[3],
  10228. tx = matrix[4],
  10229. ty = matrix[5],
  10230. originSplit = origin.split(" "),
  10231. xOrigin = parseFloat(originSplit[0]) || 0,
  10232. yOrigin = parseFloat(originSplit[1]) || 0,
  10233. bounds,
  10234. determinant,
  10235. x,
  10236. y;
  10237. if (!originIsAbsolute) {
  10238. bounds = _getBBox(target);
  10239. xOrigin = bounds.x + (~originSplit[0].indexOf("%") ? xOrigin / 100 * bounds.width : xOrigin);
  10240. yOrigin = bounds.y + (~(originSplit[1] || originSplit[0]).indexOf("%") ? yOrigin / 100 * bounds.height : yOrigin);
  10241. } else if (matrix !== _identity2DMatrix && (determinant = a * d - b * c)) {
  10242. x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + (c * ty - d * tx) / determinant;
  10243. y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - (a * ty - b * tx) / determinant;
  10244. xOrigin = x;
  10245. yOrigin = y;
  10246. }
  10247. if (smooth || smooth !== false && cache.smooth) {
  10248. tx = xOrigin - xOriginOld;
  10249. ty = yOrigin - yOriginOld;
  10250. cache.xOffset = xOffsetOld + (tx * a + ty * c) - tx;
  10251. cache.yOffset = yOffsetOld + (tx * b + ty * d) - ty;
  10252. } else {
  10253. cache.xOffset = cache.yOffset = 0;
  10254. }
  10255. cache.xOrigin = xOrigin;
  10256. cache.yOrigin = yOrigin;
  10257. cache.smooth = !!smooth;
  10258. cache.origin = origin;
  10259. cache.originIsAbsolute = !!originIsAbsolute;
  10260. target.style[_transformOriginProp] = "0px 0px";
  10261. if (pluginToAddPropTweensTo) {
  10262. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOrigin", xOriginOld, xOrigin);
  10263. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOrigin", yOriginOld, yOrigin);
  10264. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOffset", xOffsetOld, cache.xOffset);
  10265. _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOffset", yOffsetOld, cache.yOffset);
  10266. }
  10267. target.setAttribute("data-svg-origin", xOrigin + " " + yOrigin);
  10268. },
  10269. _parseTransform = function _parseTransform(target, uncache) {
  10270. var cache = target._gsap || new GSCache(target);
  10271. if ("x" in cache && !uncache && !cache.uncache) {
  10272. return cache;
  10273. }
  10274. var style = target.style,
  10275. invertedScaleX = cache.scaleX < 0,
  10276. px = "px",
  10277. deg = "deg",
  10278. cs = getComputedStyle(target),
  10279. origin = _getComputedProperty(target, _transformOriginProp) || "0",
  10280. x,
  10281. y,
  10282. z,
  10283. scaleX,
  10284. scaleY,
  10285. rotation,
  10286. rotationX,
  10287. rotationY,
  10288. skewX,
  10289. skewY,
  10290. perspective,
  10291. xOrigin,
  10292. yOrigin,
  10293. matrix,
  10294. angle,
  10295. cos,
  10296. sin,
  10297. a,
  10298. b,
  10299. c,
  10300. d,
  10301. a12,
  10302. a22,
  10303. t1,
  10304. t2,
  10305. t3,
  10306. a13,
  10307. a23,
  10308. a33,
  10309. a42,
  10310. a43,
  10311. a32;
  10312. x = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0;
  10313. scaleX = scaleY = 1;
  10314. cache.svg = !!(target.getCTM && _isSVG(target));
  10315. if (cs.translate) {
  10316. if (cs.translate !== "none" || cs.scale !== "none" || cs.rotate !== "none") {
  10317. style[_transformProp] = (cs.translate !== "none" ? "translate3d(" + (cs.translate + " 0 0").split(" ").slice(0, 3).join(", ") + ") " : "") + (cs.rotate !== "none" ? "rotate(" + cs.rotate + ") " : "") + (cs.scale !== "none" ? "scale(" + cs.scale.split(" ").join(",") + ") " : "") + (cs[_transformProp] !== "none" ? cs[_transformProp] : "");
  10318. }
  10319. style.scale = style.rotate = style.translate = "none";
  10320. }
  10321. matrix = _getMatrix(target, cache.svg);
  10322. if (cache.svg) {
  10323. if (cache.uncache) {
  10324. t2 = target.getBBox();
  10325. origin = cache.xOrigin - t2.x + "px " + (cache.yOrigin - t2.y) + "px";
  10326. t1 = "";
  10327. } else {
  10328. t1 = !uncache && target.getAttribute("data-svg-origin");
  10329. }
  10330. _applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix);
  10331. }
  10332. xOrigin = cache.xOrigin || 0;
  10333. yOrigin = cache.yOrigin || 0;
  10334. if (matrix !== _identity2DMatrix) {
  10335. a = matrix[0];
  10336. b = matrix[1];
  10337. c = matrix[2];
  10338. d = matrix[3];
  10339. x = a12 = matrix[4];
  10340. y = a22 = matrix[5];
  10341. if (matrix.length === 6) {
  10342. scaleX = Math.sqrt(a * a + b * b);
  10343. scaleY = Math.sqrt(d * d + c * c);
  10344. rotation = a || b ? _atan2(b, a) * _RAD2DEG : 0;
  10345. skewX = c || d ? _atan2(c, d) * _RAD2DEG + rotation : 0;
  10346. skewX && (scaleY *= Math.abs(Math.cos(skewX * _DEG2RAD)));
  10347. if (cache.svg) {
  10348. x -= xOrigin - (xOrigin * a + yOrigin * c);
  10349. y -= yOrigin - (xOrigin * b + yOrigin * d);
  10350. }
  10351. } else {
  10352. a32 = matrix[6];
  10353. a42 = matrix[7];
  10354. a13 = matrix[8];
  10355. a23 = matrix[9];
  10356. a33 = matrix[10];
  10357. a43 = matrix[11];
  10358. x = matrix[12];
  10359. y = matrix[13];
  10360. z = matrix[14];
  10361. angle = _atan2(a32, a33);
  10362. rotationX = angle * _RAD2DEG;
  10363. if (angle) {
  10364. cos = Math.cos(-angle);
  10365. sin = Math.sin(-angle);
  10366. t1 = a12 * cos + a13 * sin;
  10367. t2 = a22 * cos + a23 * sin;
  10368. t3 = a32 * cos + a33 * sin;
  10369. a13 = a12 * -sin + a13 * cos;
  10370. a23 = a22 * -sin + a23 * cos;
  10371. a33 = a32 * -sin + a33 * cos;
  10372. a43 = a42 * -sin + a43 * cos;
  10373. a12 = t1;
  10374. a22 = t2;
  10375. a32 = t3;
  10376. }
  10377. angle = _atan2(-c, a33);
  10378. rotationY = angle * _RAD2DEG;
  10379. if (angle) {
  10380. cos = Math.cos(-angle);
  10381. sin = Math.sin(-angle);
  10382. t1 = a * cos - a13 * sin;
  10383. t2 = b * cos - a23 * sin;
  10384. t3 = c * cos - a33 * sin;
  10385. a43 = d * sin + a43 * cos;
  10386. a = t1;
  10387. b = t2;
  10388. c = t3;
  10389. }
  10390. angle = _atan2(b, a);
  10391. rotation = angle * _RAD2DEG;
  10392. if (angle) {
  10393. cos = Math.cos(angle);
  10394. sin = Math.sin(angle);
  10395. t1 = a * cos + b * sin;
  10396. t2 = a12 * cos + a22 * sin;
  10397. b = b * cos - a * sin;
  10398. a22 = a22 * cos - a12 * sin;
  10399. a = t1;
  10400. a12 = t2;
  10401. }
  10402. if (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) {
  10403. rotationX = rotation = 0;
  10404. rotationY = 180 - rotationY;
  10405. }
  10406. scaleX = _round(Math.sqrt(a * a + b * b + c * c));
  10407. scaleY = _round(Math.sqrt(a22 * a22 + a32 * a32));
  10408. angle = _atan2(a12, a22);
  10409. skewX = Math.abs(angle) > 0.0002 ? angle * _RAD2DEG : 0;
  10410. perspective = a43 ? 1 / (a43 < 0 ? -a43 : a43) : 0;
  10411. }
  10412. if (cache.svg) {
  10413. t1 = target.getAttribute("transform");
  10414. cache.forceCSS = target.setAttribute("transform", "") || !_isNullTransform(_getComputedProperty(target, _transformProp));
  10415. t1 && target.setAttribute("transform", t1);
  10416. }
  10417. }
  10418. if (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) {
  10419. if (invertedScaleX) {
  10420. scaleX *= -1;
  10421. skewX += rotation <= 0 ? 180 : -180;
  10422. rotation += rotation <= 0 ? 180 : -180;
  10423. } else {
  10424. scaleY *= -1;
  10425. skewX += skewX <= 0 ? 180 : -180;
  10426. }
  10427. }
  10428. uncache = uncache || cache.uncache;
  10429. cache.x = x - ((cache.xPercent = x && (!uncache && cache.xPercent || (Math.round(target.offsetWidth / 2) === Math.round(-x) ? -50 : 0))) ? target.offsetWidth * cache.xPercent / 100 : 0) + px;
  10430. cache.y = y - ((cache.yPercent = y && (!uncache && cache.yPercent || (Math.round(target.offsetHeight / 2) === Math.round(-y) ? -50 : 0))) ? target.offsetHeight * cache.yPercent / 100 : 0) + px;
  10431. cache.z = z + px;
  10432. cache.scaleX = _round(scaleX);
  10433. cache.scaleY = _round(scaleY);
  10434. cache.rotation = _round(rotation) + deg;
  10435. cache.rotationX = _round(rotationX) + deg;
  10436. cache.rotationY = _round(rotationY) + deg;
  10437. cache.skewX = skewX + deg;
  10438. cache.skewY = skewY + deg;
  10439. cache.transformPerspective = perspective + px;
  10440. if (cache.zOrigin = parseFloat(origin.split(" ")[2]) || !uncache && cache.zOrigin || 0) {
  10441. style[_transformOriginProp] = _firstTwoOnly(origin);
  10442. }
  10443. cache.xOffset = cache.yOffset = 0;
  10444. cache.force3D = _config.force3D;
  10445. cache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms;
  10446. cache.uncache = 0;
  10447. return cache;
  10448. },
  10449. _firstTwoOnly = function _firstTwoOnly(value) {
  10450. return (value = value.split(" "))[0] + " " + value[1];
  10451. },
  10452. _addPxTranslate = function _addPxTranslate(target, start, value) {
  10453. var unit = getUnit(start);
  10454. return _round(parseFloat(start) + parseFloat(_convertToUnit(target, "x", value + "px", unit))) + unit;
  10455. },
  10456. _renderNon3DTransforms = function _renderNon3DTransforms(ratio, cache) {
  10457. cache.z = "0px";
  10458. cache.rotationY = cache.rotationX = "0deg";
  10459. cache.force3D = 0;
  10460. _renderCSSTransforms(ratio, cache);
  10461. },
  10462. _zeroDeg = "0deg",
  10463. _zeroPx = "0px",
  10464. _endParenthesis = ") ",
  10465. _renderCSSTransforms = function _renderCSSTransforms(ratio, cache) {
  10466. var _ref = cache || this,
  10467. xPercent = _ref.xPercent,
  10468. yPercent = _ref.yPercent,
  10469. x = _ref.x,
  10470. y = _ref.y,
  10471. z = _ref.z,
  10472. rotation = _ref.rotation,
  10473. rotationY = _ref.rotationY,
  10474. rotationX = _ref.rotationX,
  10475. skewX = _ref.skewX,
  10476. skewY = _ref.skewY,
  10477. scaleX = _ref.scaleX,
  10478. scaleY = _ref.scaleY,
  10479. transformPerspective = _ref.transformPerspective,
  10480. force3D = _ref.force3D,
  10481. target = _ref.target,
  10482. zOrigin = _ref.zOrigin,
  10483. transforms = "",
  10484. use3D = force3D === "auto" && ratio && ratio !== 1 || force3D === true;
  10485. if (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) {
  10486. var angle = parseFloat(rotationY) * _DEG2RAD,
  10487. a13 = Math.sin(angle),
  10488. a33 = Math.cos(angle),
  10489. cos;
  10490. angle = parseFloat(rotationX) * _DEG2RAD;
  10491. cos = Math.cos(angle);
  10492. x = _addPxTranslate(target, x, a13 * cos * -zOrigin);
  10493. y = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin);
  10494. z = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin);
  10495. }
  10496. if (transformPerspective !== _zeroPx) {
  10497. transforms += "perspective(" + transformPerspective + _endParenthesis;
  10498. }
  10499. if (xPercent || yPercent) {
  10500. transforms += "translate(" + xPercent + "%, " + yPercent + "%) ";
  10501. }
  10502. if (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) {
  10503. transforms += z !== _zeroPx || use3D ? "translate3d(" + x + ", " + y + ", " + z + ") " : "translate(" + x + ", " + y + _endParenthesis;
  10504. }
  10505. if (rotation !== _zeroDeg) {
  10506. transforms += "rotate(" + rotation + _endParenthesis;
  10507. }
  10508. if (rotationY !== _zeroDeg) {
  10509. transforms += "rotateY(" + rotationY + _endParenthesis;
  10510. }
  10511. if (rotationX !== _zeroDeg) {
  10512. transforms += "rotateX(" + rotationX + _endParenthesis;
  10513. }
  10514. if (skewX !== _zeroDeg || skewY !== _zeroDeg) {
  10515. transforms += "skew(" + skewX + ", " + skewY + _endParenthesis;
  10516. }
  10517. if (scaleX !== 1 || scaleY !== 1) {
  10518. transforms += "scale(" + scaleX + ", " + scaleY + _endParenthesis;
  10519. }
  10520. target.style[_transformProp] = transforms || "translate(0, 0)";
  10521. },
  10522. _renderSVGTransforms = function _renderSVGTransforms(ratio, cache) {
  10523. var _ref2 = cache || this,
  10524. xPercent = _ref2.xPercent,
  10525. yPercent = _ref2.yPercent,
  10526. x = _ref2.x,
  10527. y = _ref2.y,
  10528. rotation = _ref2.rotation,
  10529. skewX = _ref2.skewX,
  10530. skewY = _ref2.skewY,
  10531. scaleX = _ref2.scaleX,
  10532. scaleY = _ref2.scaleY,
  10533. target = _ref2.target,
  10534. xOrigin = _ref2.xOrigin,
  10535. yOrigin = _ref2.yOrigin,
  10536. xOffset = _ref2.xOffset,
  10537. yOffset = _ref2.yOffset,
  10538. forceCSS = _ref2.forceCSS,
  10539. tx = parseFloat(x),
  10540. ty = parseFloat(y),
  10541. a11,
  10542. a21,
  10543. a12,
  10544. a22,
  10545. temp;
  10546. rotation = parseFloat(rotation);
  10547. skewX = parseFloat(skewX);
  10548. skewY = parseFloat(skewY);
  10549. if (skewY) {
  10550. skewY = parseFloat(skewY);
  10551. skewX += skewY;
  10552. rotation += skewY;
  10553. }
  10554. if (rotation || skewX) {
  10555. rotation *= _DEG2RAD;
  10556. skewX *= _DEG2RAD;
  10557. a11 = Math.cos(rotation) * scaleX;
  10558. a21 = Math.sin(rotation) * scaleX;
  10559. a12 = Math.sin(rotation - skewX) * -scaleY;
  10560. a22 = Math.cos(rotation - skewX) * scaleY;
  10561. if (skewX) {
  10562. skewY *= _DEG2RAD;
  10563. temp = Math.tan(skewX - skewY);
  10564. temp = Math.sqrt(1 + temp * temp);
  10565. a12 *= temp;
  10566. a22 *= temp;
  10567. if (skewY) {
  10568. temp = Math.tan(skewY);
  10569. temp = Math.sqrt(1 + temp * temp);
  10570. a11 *= temp;
  10571. a21 *= temp;
  10572. }
  10573. }
  10574. a11 = _round(a11);
  10575. a21 = _round(a21);
  10576. a12 = _round(a12);
  10577. a22 = _round(a22);
  10578. } else {
  10579. a11 = scaleX;
  10580. a22 = scaleY;
  10581. a21 = a12 = 0;
  10582. }
  10583. if (tx && !~(x + "").indexOf("px") || ty && !~(y + "").indexOf("px")) {
  10584. tx = _convertToUnit(target, "x", x, "px");
  10585. ty = _convertToUnit(target, "y", y, "px");
  10586. }
  10587. if (xOrigin || yOrigin || xOffset || yOffset) {
  10588. tx = _round(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset);
  10589. ty = _round(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset);
  10590. }
  10591. if (xPercent || yPercent) {
  10592. temp = target.getBBox();
  10593. tx = _round(tx + xPercent / 100 * temp.width);
  10594. ty = _round(ty + yPercent / 100 * temp.height);
  10595. }
  10596. temp = "matrix(" + a11 + "," + a21 + "," + a12 + "," + a22 + "," + tx + "," + ty + ")";
  10597. target.setAttribute("transform", temp);
  10598. forceCSS && (target.style[_transformProp] = temp);
  10599. },
  10600. _addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue) {
  10601. var cap = 360,
  10602. isString = _isString(endValue),
  10603. endNum = parseFloat(endValue) * (isString && ~endValue.indexOf("rad") ? _RAD2DEG : 1),
  10604. change = endNum - startNum,
  10605. finalValue = startNum + change + "deg",
  10606. direction,
  10607. pt;
  10608. if (isString) {
  10609. direction = endValue.split("_")[1];
  10610. if (direction === "short") {
  10611. change %= cap;
  10612. if (change !== change % (cap / 2)) {
  10613. change += change < 0 ? cap : -cap;
  10614. }
  10615. }
  10616. if (direction === "cw" && change < 0) {
  10617. change = (change + cap * _bigNum$1) % cap - ~~(change / cap) * cap;
  10618. } else if (direction === "ccw" && change > 0) {
  10619. change = (change - cap * _bigNum$1) % cap - ~~(change / cap) * cap;
  10620. }
  10621. }
  10622. plugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);
  10623. pt.e = finalValue;
  10624. pt.u = "deg";
  10625. plugin._props.push(property);
  10626. return pt;
  10627. },
  10628. _assign = function _assign(target, source) {
  10629. for (var p in source) {
  10630. target[p] = source[p];
  10631. }
  10632. return target;
  10633. },
  10634. _addRawTransformPTs = function _addRawTransformPTs(plugin, transforms, target) {
  10635. var startCache = _assign({}, target._gsap),
  10636. exclude = "perspective,force3D,transformOrigin,svgOrigin",
  10637. style = target.style,
  10638. endCache,
  10639. p,
  10640. startValue,
  10641. endValue,
  10642. startNum,
  10643. endNum,
  10644. startUnit,
  10645. endUnit;
  10646. if (startCache.svg) {
  10647. startValue = target.getAttribute("transform");
  10648. target.setAttribute("transform", "");
  10649. style[_transformProp] = transforms;
  10650. endCache = _parseTransform(target, 1);
  10651. _removeProperty(target, _transformProp);
  10652. target.setAttribute("transform", startValue);
  10653. } else {
  10654. startValue = getComputedStyle(target)[_transformProp];
  10655. style[_transformProp] = transforms;
  10656. endCache = _parseTransform(target, 1);
  10657. style[_transformProp] = startValue;
  10658. }
  10659. for (p in _transformProps) {
  10660. startValue = startCache[p];
  10661. endValue = endCache[p];
  10662. if (startValue !== endValue && exclude.indexOf(p) < 0) {
  10663. startUnit = getUnit(startValue);
  10664. endUnit = getUnit(endValue);
  10665. startNum = startUnit !== endUnit ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue);
  10666. endNum = parseFloat(endValue);
  10667. plugin._pt = new PropTween(plugin._pt, endCache, p, startNum, endNum - startNum, _renderCSSProp);
  10668. plugin._pt.u = endUnit || 0;
  10669. plugin._props.push(p);
  10670. }
  10671. }
  10672. _assign(endCache, startCache);
  10673. };
  10674. _forEachName("padding,margin,Width,Radius", function (name, index) {
  10675. var t = "Top",
  10676. r = "Right",
  10677. b = "Bottom",
  10678. l = "Left",
  10679. props = (index < 3 ? [t, r, b, l] : [t + l, t + r, b + r, b + l]).map(function (side) {
  10680. return index < 2 ? name + side : "border" + side + name;
  10681. });
  10682. _specialProps[index > 1 ? "border" + name : name] = function (plugin, target, property, endValue, tween) {
  10683. var a, vars;
  10684. if (arguments.length < 4) {
  10685. a = props.map(function (prop) {
  10686. return _get(plugin, prop, property);
  10687. });
  10688. vars = a.join(" ");
  10689. return vars.split(a[0]).length === 5 ? a[0] : vars;
  10690. }
  10691. a = (endValue + "").split(" ");
  10692. vars = {};
  10693. props.forEach(function (prop, i) {
  10694. return vars[prop] = a[i] = a[i] || a[(i - 1) / 2 | 0];
  10695. });
  10696. plugin.init(target, vars, tween);
  10697. };
  10698. });
  10699. var CSSPlugin = {
  10700. name: "css",
  10701. register: _initCore,
  10702. targetTest: function targetTest(target) {
  10703. return target.style && target.nodeType;
  10704. },
  10705. init: function init(target, vars, tween, index, targets) {
  10706. var props = this._props,
  10707. style = target.style,
  10708. startAt = tween.vars.startAt,
  10709. startValue,
  10710. endValue,
  10711. endNum,
  10712. startNum,
  10713. type,
  10714. specialProp,
  10715. p,
  10716. startUnit,
  10717. endUnit,
  10718. relative,
  10719. isTransformRelated,
  10720. transformPropTween,
  10721. cache,
  10722. smooth,
  10723. hasPriority,
  10724. inlineProps;
  10725. _pluginInitted || _initCore();
  10726. this.styles = this.styles || _getStyleSaver(target);
  10727. inlineProps = this.styles.props;
  10728. this.tween = tween;
  10729. for (p in vars) {
  10730. if (p === "autoRound") {
  10731. continue;
  10732. }
  10733. endValue = vars[p];
  10734. if (_plugins[p] && _checkPlugin(p, vars, tween, index, target, targets)) {
  10735. continue;
  10736. }
  10737. type = typeof endValue;
  10738. specialProp = _specialProps[p];
  10739. if (type === "function") {
  10740. endValue = endValue.call(tween, index, target, targets);
  10741. type = typeof endValue;
  10742. }
  10743. if (type === "string" && ~endValue.indexOf("random(")) {
  10744. endValue = _replaceRandom(endValue);
  10745. }
  10746. if (specialProp) {
  10747. specialProp(this, target, p, endValue, tween) && (hasPriority = 1);
  10748. } else if (p.substr(0, 2) === "--") {
  10749. startValue = (getComputedStyle(target).getPropertyValue(p) + "").trim();
  10750. endValue += "";
  10751. _colorExp.lastIndex = 0;
  10752. if (!_colorExp.test(startValue)) {
  10753. startUnit = getUnit(startValue);
  10754. endUnit = getUnit(endValue);
  10755. }
  10756. endUnit ? startUnit !== endUnit && (startValue = _convertToUnit(target, p, startValue, endUnit) + endUnit) : startUnit && (endValue += startUnit);
  10757. this.add(style, "setProperty", startValue, endValue, index, targets, 0, 0, p);
  10758. props.push(p);
  10759. inlineProps.push(p, 0, style[p]);
  10760. } else if (type !== "undefined") {
  10761. if (startAt && p in startAt) {
  10762. startValue = typeof startAt[p] === "function" ? startAt[p].call(tween, index, target, targets) : startAt[p];
  10763. _isString(startValue) && ~startValue.indexOf("random(") && (startValue = _replaceRandom(startValue));
  10764. getUnit(startValue + "") || startValue === "auto" || (startValue += _config.units[p] || getUnit(_get(target, p)) || "");
  10765. (startValue + "").charAt(1) === "=" && (startValue = _get(target, p));
  10766. } else {
  10767. startValue = _get(target, p);
  10768. }
  10769. startNum = parseFloat(startValue);
  10770. relative = type === "string" && endValue.charAt(1) === "=" && endValue.substr(0, 2);
  10771. relative && (endValue = endValue.substr(2));
  10772. endNum = parseFloat(endValue);
  10773. if (p in _propertyAliases) {
  10774. if (p === "autoAlpha") {
  10775. if (startNum === 1 && _get(target, "visibility") === "hidden" && endNum) {
  10776. startNum = 0;
  10777. }
  10778. inlineProps.push("visibility", 0, style.visibility);
  10779. _addNonTweeningPT(this, style, "visibility", startNum ? "inherit" : "hidden", endNum ? "inherit" : "hidden", !endNum);
  10780. }
  10781. if (p !== "scale" && p !== "transform") {
  10782. p = _propertyAliases[p];
  10783. ~p.indexOf(",") && (p = p.split(",")[0]);
  10784. }
  10785. }
  10786. isTransformRelated = p in _transformProps;
  10787. if (isTransformRelated) {
  10788. this.styles.save(p);
  10789. if (!transformPropTween) {
  10790. cache = target._gsap;
  10791. cache.renderTransform && !vars.parseTransform || _parseTransform(target, vars.parseTransform);
  10792. smooth = vars.smoothOrigin !== false && cache.smooth;
  10793. transformPropTween = this._pt = new PropTween(this._pt, style, _transformProp, 0, 1, cache.renderTransform, cache, 0, -1);
  10794. transformPropTween.dep = 1;
  10795. }
  10796. if (p === "scale") {
  10797. this._pt = new PropTween(this._pt, cache, "scaleY", cache.scaleY, (relative ? _parseRelative(cache.scaleY, relative + endNum) : endNum) - cache.scaleY || 0, _renderCSSProp);
  10798. this._pt.u = 0;
  10799. props.push("scaleY", p);
  10800. p += "X";
  10801. } else if (p === "transformOrigin") {
  10802. inlineProps.push(_transformOriginProp, 0, style[_transformOriginProp]);
  10803. endValue = _convertKeywordsToPercentages(endValue);
  10804. if (cache.svg) {
  10805. _applySVGOrigin(target, endValue, 0, smooth, 0, this);
  10806. } else {
  10807. endUnit = parseFloat(endValue.split(" ")[2]) || 0;
  10808. endUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, "zOrigin", cache.zOrigin, endUnit);
  10809. _addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue));
  10810. }
  10811. continue;
  10812. } else if (p === "svgOrigin") {
  10813. _applySVGOrigin(target, endValue, 1, smooth, 0, this);
  10814. continue;
  10815. } else if (p in _rotationalProperties) {
  10816. _addRotationalPropTween(this, cache, p, startNum, relative ? _parseRelative(startNum, relative + endValue) : endValue);
  10817. continue;
  10818. } else if (p === "smoothOrigin") {
  10819. _addNonTweeningPT(this, cache, "smooth", cache.smooth, endValue);
  10820. continue;
  10821. } else if (p === "force3D") {
  10822. cache[p] = endValue;
  10823. continue;
  10824. } else if (p === "transform") {
  10825. _addRawTransformPTs(this, endValue, target);
  10826. continue;
  10827. }
  10828. } else if (!(p in style)) {
  10829. p = _checkPropPrefix(p) || p;
  10830. }
  10831. if (isTransformRelated || (endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && p in style) {
  10832. startUnit = (startValue + "").substr((startNum + "").length);
  10833. endNum || (endNum = 0);
  10834. endUnit = getUnit(endValue) || (p in _config.units ? _config.units[p] : startUnit);
  10835. startUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit));
  10836. this._pt = new PropTween(this._pt, isTransformRelated ? cache : style, p, startNum, (relative ? _parseRelative(startNum, relative + endNum) : endNum) - startNum, !isTransformRelated && (endUnit === "px" || p === "zIndex") && vars.autoRound !== false ? _renderRoundedCSSProp : _renderCSSProp);
  10837. this._pt.u = endUnit || 0;
  10838. if (startUnit !== endUnit && endUnit !== "%") {
  10839. this._pt.b = startValue;
  10840. this._pt.r = _renderCSSPropWithBeginning;
  10841. }
  10842. } else if (!(p in style)) {
  10843. if (p in target) {
  10844. this.add(target, p, startValue || target[p], relative ? relative + endValue : endValue, index, targets);
  10845. } else if (p !== "parseTransform") {
  10846. _missingPlugin(p, endValue);
  10847. continue;
  10848. }
  10849. } else {
  10850. _tweenComplexCSSString.call(this, target, p, startValue, relative ? relative + endValue : endValue);
  10851. }
  10852. isTransformRelated || (p in style ? inlineProps.push(p, 0, style[p]) : inlineProps.push(p, 1, startValue || target[p]));
  10853. props.push(p);
  10854. }
  10855. }
  10856. hasPriority && _sortPropTweensByPriority(this);
  10857. },
  10858. render: function render(ratio, data) {
  10859. if (data.tween._time || !_reverting$1()) {
  10860. var pt = data._pt;
  10861. while (pt) {
  10862. pt.r(ratio, pt.d);
  10863. pt = pt._next;
  10864. }
  10865. } else {
  10866. data.styles.revert();
  10867. }
  10868. },
  10869. get: _get,
  10870. aliases: _propertyAliases,
  10871. getSetter: function getSetter(target, property, plugin) {
  10872. var p = _propertyAliases[property];
  10873. p && p.indexOf(",") < 0 && (property = p);
  10874. return property in _transformProps && property !== _transformOriginProp && (target._gsap.x || _get(target, "x")) ? plugin && _recentSetterPlugin === plugin ? property === "scale" ? _setterScale : _setterTransform : (_recentSetterPlugin = plugin || {}) && (property === "scale" ? _setterScaleWithRender : _setterTransformWithRender) : target.style && !_isUndefined(target.style[property]) ? _setterCSSStyle : ~property.indexOf("-") ? _setterCSSProp : _getSetter(target, property);
  10875. },
  10876. core: {
  10877. _removeProperty: _removeProperty,
  10878. _getMatrix: _getMatrix
  10879. }
  10880. };
  10881. gsap.utils.checkPrefix = _checkPropPrefix;
  10882. gsap.core.getStyleSaver = _getStyleSaver;
  10883. (function (positionAndScale, rotation, others, aliases) {
  10884. var all = _forEachName(positionAndScale + "," + rotation + "," + others, function (name) {
  10885. _transformProps[name] = 1;
  10886. });
  10887. _forEachName(rotation, function (name) {
  10888. _config.units[name] = "deg";
  10889. _rotationalProperties[name] = 1;
  10890. });
  10891. _propertyAliases[all[13]] = positionAndScale + "," + rotation;
  10892. _forEachName(aliases, function (name) {
  10893. var split = name.split(":");
  10894. _propertyAliases[split[1]] = all[split[0]];
  10895. });
  10896. })("x,y,z,scale,scaleX,scaleY,xPercent,yPercent", "rotation,rotationX,rotationY,skewX,skewY", "transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective", "0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");
  10897. _forEachName("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective", function (name) {
  10898. _config.units[name] = "px";
  10899. });
  10900. gsap.registerPlugin(CSSPlugin);
  10901. var gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap,
  10902. TweenMaxWithCSS = gsapWithCSS.core.Tween;
  10903. exports.Back = Back;
  10904. exports.Bounce = Bounce;
  10905. exports.CSSPlugin = CSSPlugin;
  10906. exports.Circ = Circ;
  10907. exports.Cubic = Cubic;
  10908. exports.Elastic = Elastic;
  10909. exports.Expo = Expo;
  10910. exports.Linear = Linear;
  10911. exports.Power0 = Power0;
  10912. exports.Power1 = Power1;
  10913. exports.Power2 = Power2;
  10914. exports.Power3 = Power3;
  10915. exports.Power4 = Power4;
  10916. exports.Quad = Quad;
  10917. exports.Quart = Quart;
  10918. exports.Quint = Quint;
  10919. exports.Sine = Sine;
  10920. exports.SteppedEase = SteppedEase;
  10921. exports.Strong = Strong;
  10922. exports.TimelineLite = Timeline;
  10923. exports.TimelineMax = Timeline;
  10924. exports.TweenLite = Tween;
  10925. exports.TweenMax = TweenMaxWithCSS;
  10926. exports.default = gsapWithCSS;
  10927. exports.gsap = gsapWithCSS;
  10928. if (typeof(window) === 'undefined' || window !== exports) {Object.defineProperty(exports, '__esModule', { value: true });} else {delete window.default;}
  10929. })));
  10930. /*!
  10931. Images Loaded Packaged
  10932. Version: v5.0.0
  10933. Plugin URL: https://imagesloaded.desandro.com/
  10934. License: Copyright 2021-2024 | Released under the MIT License
  10935. !*/
  10936. /**
  10937. * EvEmitter v2.1.1
  10938. * Lil' event emitter
  10939. * MIT License
  10940. */
  10941. ( function( global, factory ) {
  10942. // universal module definition
  10943. if ( typeof module == 'object' && module.exports ) {
  10944. // CommonJS - Browserify, Webpack
  10945. module.exports = factory();
  10946. } else {
  10947. // Browser globals
  10948. global.EvEmitter = factory();
  10949. }
  10950. }( typeof window != 'undefined' ? window : this, function() {
  10951. function EvEmitter() {}
  10952. let proto = EvEmitter.prototype;
  10953. proto.on = function( eventName, listener ) {
  10954. if ( !eventName || !listener ) return this;
  10955. // set events hash
  10956. let events = this._events = this._events || {};
  10957. // set listeners array
  10958. let listeners = events[ eventName ] = events[ eventName ] || [];
  10959. // only add once
  10960. if ( !listeners.includes( listener ) ) {
  10961. listeners.push( listener );
  10962. }
  10963. return this;
  10964. };
  10965. proto.once = function( eventName, listener ) {
  10966. if ( !eventName || !listener ) return this;
  10967. // add event
  10968. this.on( eventName, listener );
  10969. // set once flag
  10970. // set onceEvents hash
  10971. let onceEvents = this._onceEvents = this._onceEvents || {};
  10972. // set onceListeners object
  10973. let onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
  10974. // set flag
  10975. onceListeners[ listener ] = true;
  10976. return this;
  10977. };
  10978. proto.off = function( eventName, listener ) {
  10979. let listeners = this._events && this._events[ eventName ];
  10980. if ( !listeners || !listeners.length ) return this;
  10981. let index = listeners.indexOf( listener );
  10982. if ( index != -1 ) {
  10983. listeners.splice( index, 1 );
  10984. }
  10985. return this;
  10986. };
  10987. proto.emitEvent = function( eventName, args ) {
  10988. let listeners = this._events && this._events[ eventName ];
  10989. if ( !listeners || !listeners.length ) return this;
  10990. // copy over to avoid interference if .off() in listener
  10991. listeners = listeners.slice( 0 );
  10992. args = args || [];
  10993. // once stuff
  10994. let onceListeners = this._onceEvents && this._onceEvents[ eventName ];
  10995. for ( let listener of listeners ) {
  10996. let isOnce = onceListeners && onceListeners[ listener ];
  10997. if ( isOnce ) {
  10998. // remove listener
  10999. // remove before trigger to prevent recursion
  11000. this.off( eventName, listener );
  11001. // unset once flag
  11002. delete onceListeners[ listener ];
  11003. }
  11004. // trigger listener
  11005. listener.apply( this, args );
  11006. }
  11007. return this;
  11008. };
  11009. proto.allOff = function() {
  11010. delete this._events;
  11011. delete this._onceEvents;
  11012. return this;
  11013. };
  11014. return EvEmitter;
  11015. } ) );
  11016. /*!
  11017. * imagesLoaded v5.0.0
  11018. * JavaScript is all like "You images are done yet or what?"
  11019. * MIT License
  11020. */
  11021. ( function( window, factory ) {
  11022. // universal module definition
  11023. if ( typeof module == 'object' && module.exports ) {
  11024. // CommonJS
  11025. module.exports = factory( window, require('ev-emitter') );
  11026. } else {
  11027. // browser global
  11028. window.imagesLoaded = factory( window, window.EvEmitter );
  11029. }
  11030. } )( typeof window !== 'undefined' ? window : this,
  11031. function factory( window, EvEmitter ) {
  11032. let $ = window.jQuery;
  11033. let console = window.console;
  11034. // -------------------------- helpers -------------------------- //
  11035. // turn element or nodeList into an array
  11036. function makeArray( obj ) {
  11037. // use object if already an array
  11038. if ( Array.isArray( obj ) ) return obj;
  11039. let isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
  11040. // convert nodeList to array
  11041. if ( isArrayLike ) return [ ...obj ];
  11042. // array of single index
  11043. return [ obj ];
  11044. }
  11045. // -------------------------- imagesLoaded -------------------------- //
  11046. /**
  11047. * @param {[Array, Element, NodeList, String]} elem
  11048. * @param {[Object, Function]} options - if function, use as callback
  11049. * @param {Function} onAlways - callback function
  11050. * @returns {ImagesLoaded}
  11051. */
  11052. function ImagesLoaded( elem, options, onAlways ) {
  11053. // coerce ImagesLoaded() without new, to be new ImagesLoaded()
  11054. if ( !( this instanceof ImagesLoaded ) ) {
  11055. return new ImagesLoaded( elem, options, onAlways );
  11056. }
  11057. // use elem as selector string
  11058. let queryElem = elem;
  11059. if ( typeof elem == 'string' ) {
  11060. queryElem = document.querySelectorAll( elem );
  11061. }
  11062. // bail if bad element
  11063. if ( !queryElem ) {
  11064. console.error(`Bad element for imagesLoaded ${queryElem || elem}`);
  11065. return;
  11066. }
  11067. this.elements = makeArray( queryElem );
  11068. this.options = {};
  11069. // shift arguments if no options set
  11070. if ( typeof options == 'function' ) {
  11071. onAlways = options;
  11072. } else {
  11073. Object.assign( this.options, options );
  11074. }
  11075. if ( onAlways ) this.on( 'always', onAlways );
  11076. this.getImages();
  11077. // add jQuery Deferred object
  11078. if ( $ ) this.jqDeferred = new $.Deferred();
  11079. // HACK check async to allow time to bind listeners
  11080. setTimeout( this.check.bind( this ) );
  11081. }
  11082. ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
  11083. ImagesLoaded.prototype.getImages = function() {
  11084. this.images = [];
  11085. // filter & find items if we have an item selector
  11086. this.elements.forEach( this.addElementImages, this );
  11087. };
  11088. const elementNodeTypes = [ 1, 9, 11 ];
  11089. /**
  11090. * @param {Node} elem
  11091. */
  11092. ImagesLoaded.prototype.addElementImages = function( elem ) {
  11093. // filter siblings
  11094. if ( elem.nodeName === 'IMG' ) {
  11095. this.addImage( elem );
  11096. }
  11097. // get background image on element
  11098. if ( this.options.background === true ) {
  11099. this.addElementBackgroundImages( elem );
  11100. }
  11101. // find children
  11102. // no non-element nodes, #143
  11103. let { nodeType } = elem;
  11104. if ( !nodeType || !elementNodeTypes.includes( nodeType ) ) return;
  11105. let childImgs = elem.querySelectorAll('img');
  11106. // concat childElems to filterFound array
  11107. for ( let img of childImgs ) {
  11108. this.addImage( img );
  11109. }
  11110. // get child background images
  11111. if ( typeof this.options.background == 'string' ) {
  11112. let children = elem.querySelectorAll( this.options.background );
  11113. for ( let child of children ) {
  11114. this.addElementBackgroundImages( child );
  11115. }
  11116. }
  11117. };
  11118. const reURL = /url\((['"])?(.*?)\1\)/gi;
  11119. ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
  11120. let style = getComputedStyle( elem );
  11121. // Firefox returns null if in a hidden iframe https://bugzil.la/548397
  11122. if ( !style ) return;
  11123. // get url inside url("...")
  11124. let matches = reURL.exec( style.backgroundImage );
  11125. while ( matches !== null ) {
  11126. let url = matches && matches[2];
  11127. if ( url ) {
  11128. this.addBackground( url, elem );
  11129. }
  11130. matches = reURL.exec( style.backgroundImage );
  11131. }
  11132. };
  11133. /**
  11134. * @param {Image} img
  11135. */
  11136. ImagesLoaded.prototype.addImage = function( img ) {
  11137. let loadingImage = new LoadingImage( img );
  11138. this.images.push( loadingImage );
  11139. };
  11140. ImagesLoaded.prototype.addBackground = function( url, elem ) {
  11141. let background = new Background( url, elem );
  11142. this.images.push( background );
  11143. };
  11144. ImagesLoaded.prototype.check = function() {
  11145. this.progressedCount = 0;
  11146. this.hasAnyBroken = false;
  11147. // complete if no images
  11148. if ( !this.images.length ) {
  11149. this.complete();
  11150. return;
  11151. }
  11152. /* eslint-disable-next-line func-style */
  11153. let onProgress = ( image, elem, message ) => {
  11154. // HACK - Chrome triggers event before object properties have changed. #83
  11155. setTimeout( () => {
  11156. this.progress( image, elem, message );
  11157. } );
  11158. };
  11159. this.images.forEach( function( loadingImage ) {
  11160. loadingImage.once( 'progress', onProgress );
  11161. loadingImage.check();
  11162. } );
  11163. };
  11164. ImagesLoaded.prototype.progress = function( image, elem, message ) {
  11165. this.progressedCount++;
  11166. this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
  11167. // progress event
  11168. this.emitEvent( 'progress', [ this, image, elem ] );
  11169. if ( this.jqDeferred && this.jqDeferred.notify ) {
  11170. this.jqDeferred.notify( this, image );
  11171. }
  11172. // check if completed
  11173. if ( this.progressedCount === this.images.length ) {
  11174. this.complete();
  11175. }
  11176. if ( this.options.debug && console ) {
  11177. console.log( `progress: ${message}`, image, elem );
  11178. }
  11179. };
  11180. ImagesLoaded.prototype.complete = function() {
  11181. let eventName = this.hasAnyBroken ? 'fail' : 'done';
  11182. this.isComplete = true;
  11183. this.emitEvent( eventName, [ this ] );
  11184. this.emitEvent( 'always', [ this ] );
  11185. if ( this.jqDeferred ) {
  11186. let jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
  11187. this.jqDeferred[ jqMethod ]( this );
  11188. }
  11189. };
  11190. // -------------------------- -------------------------- //
  11191. function LoadingImage( img ) {
  11192. this.img = img;
  11193. }
  11194. LoadingImage.prototype = Object.create( EvEmitter.prototype );
  11195. LoadingImage.prototype.check = function() {
  11196. // If complete is true and browser supports natural sizes,
  11197. // try to check for image status manually.
  11198. let isComplete = this.getIsImageComplete();
  11199. if ( isComplete ) {
  11200. // report based on naturalWidth
  11201. this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
  11202. return;
  11203. }
  11204. // If none of the checks above matched, simulate loading on detached element.
  11205. this.proxyImage = new Image();
  11206. // add crossOrigin attribute. #204
  11207. if ( this.img.crossOrigin ) {
  11208. this.proxyImage.crossOrigin = this.img.crossOrigin;
  11209. }
  11210. this.proxyImage.addEventListener( 'load', this );
  11211. this.proxyImage.addEventListener( 'error', this );
  11212. // bind to image as well for Firefox. #191
  11213. this.img.addEventListener( 'load', this );
  11214. this.img.addEventListener( 'error', this );
  11215. this.proxyImage.src = this.img.currentSrc || this.img.src;
  11216. };
  11217. LoadingImage.prototype.getIsImageComplete = function() {
  11218. // check for non-zero, non-undefined naturalWidth
  11219. // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
  11220. return this.img.complete && this.img.naturalWidth;
  11221. };
  11222. LoadingImage.prototype.confirm = function( isLoaded, message ) {
  11223. this.isLoaded = isLoaded;
  11224. let { parentNode } = this.img;
  11225. // emit progress with parent <picture> or self <img>
  11226. let elem = parentNode.nodeName === 'PICTURE' ? parentNode : this.img;
  11227. this.emitEvent( 'progress', [ this, elem, message ] );
  11228. };
  11229. // ----- events ----- //
  11230. // trigger specified handler for event type
  11231. LoadingImage.prototype.handleEvent = function( event ) {
  11232. let method = 'on' + event.type;
  11233. if ( this[ method ] ) {
  11234. this[ method ]( event );
  11235. }
  11236. };
  11237. LoadingImage.prototype.onload = function() {
  11238. this.confirm( true, 'onload' );
  11239. this.unbindEvents();
  11240. };
  11241. LoadingImage.prototype.onerror = function() {
  11242. this.confirm( false, 'onerror' );
  11243. this.unbindEvents();
  11244. };
  11245. LoadingImage.prototype.unbindEvents = function() {
  11246. this.proxyImage.removeEventListener( 'load', this );
  11247. this.proxyImage.removeEventListener( 'error', this );
  11248. this.img.removeEventListener( 'load', this );
  11249. this.img.removeEventListener( 'error', this );
  11250. };
  11251. // -------------------------- Background -------------------------- //
  11252. function Background( url, element ) {
  11253. this.url = url;
  11254. this.element = element;
  11255. this.img = new Image();
  11256. }
  11257. // inherit LoadingImage prototype
  11258. Background.prototype = Object.create( LoadingImage.prototype );
  11259. Background.prototype.check = function() {
  11260. this.img.addEventListener( 'load', this );
  11261. this.img.addEventListener( 'error', this );
  11262. this.img.src = this.url;
  11263. // check if image is already complete
  11264. let isComplete = this.getIsImageComplete();
  11265. if ( isComplete ) {
  11266. this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
  11267. this.unbindEvents();
  11268. }
  11269. };
  11270. Background.prototype.unbindEvents = function() {
  11271. this.img.removeEventListener( 'load', this );
  11272. this.img.removeEventListener( 'error', this );
  11273. };
  11274. Background.prototype.confirm = function( isLoaded, message ) {
  11275. this.isLoaded = isLoaded;
  11276. this.emitEvent( 'progress', [ this, this.element, message ] );
  11277. };
  11278. // -------------------------- jQuery -------------------------- //
  11279. ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
  11280. jQuery = jQuery || window.jQuery;
  11281. if ( !jQuery ) return;
  11282. // set local variable
  11283. $ = jQuery;
  11284. // $().imagesLoaded()
  11285. $.fn.imagesLoaded = function( options, onAlways ) {
  11286. let instance = new ImagesLoaded( this, options, onAlways );
  11287. return instance.jqDeferred.promise( $( this ) );
  11288. };
  11289. };
  11290. // try making plugin
  11291. ImagesLoaded.makeJQueryPlugin();
  11292. // -------------------------- -------------------------- //
  11293. return ImagesLoaded;
  11294. } );
  11295. /*!
  11296. Carto - Interactive portfolio
  11297. Created by ThemeZaa
  11298. !*/
  11299. $(function() {
  11300. "use strict";
  11301. const container = document.getElementById("stickyImgContainer");
  11302. if (typeof (container) != 'undefined' && container != null) {
  11303. const sliders = document.querySelector(".slides").querySelectorAll(".slide")
  11304. const slidesData = Array.from(sliders).map(item => {
  11305. return {
  11306. image: "",
  11307. title: "title1",
  11308. meta: ""
  11309. }
  11310. })
  11311. const createEleWithClass = (tag, className) => {
  11312. const ele = document.createElement(tag);
  11313. ele.className = className;
  11314. return ele;
  11315. };
  11316. class Slides {
  11317. constructor(data) {
  11318. this.data = document.querySelectorAll(".slide");
  11319. this.container = document.querySelector(".slides");
  11320. this.currentIdx = 0;
  11321. this.slides = document.querySelectorAll(".slide");
  11322. }
  11323. mount(container) {
  11324. container.appendChild(this.container);
  11325. let activeIndex = 0;
  11326. for (let i = 0; i < this.slides.length; i++) {
  11327. if (activeIndex === i) {
  11328. this.slides[i].classList.remove("next");
  11329. this.slides[i].classList.remove("prev");
  11330. this.slides[i].classList.add("show-meta");
  11331. document.querySelector(".bg-overlay").style.backgroundImage = `url("${this.slides[i].dataset.bg}")`
  11332. } else {
  11333. if (activeIndex > i) {
  11334. this.slides[i].classList.remove("next");
  11335. this.slides[i].classList.add("prev");
  11336. } else {
  11337. this.slides[i].classList.add("next");
  11338. this.slides[i].classList.remove("prev");
  11339. }
  11340. }
  11341. }
  11342. }
  11343. onActiveIndexChange(activeIndex) {
  11344. this.currentIdx = activeIndex;
  11345. for (let i = 0; i < this.slides.length; i++) {
  11346. if (activeIndex === i) {
  11347. this.slides[i].classList.remove("next");
  11348. this.slides[i].classList.remove("prev");
  11349. document.querySelector(".bg-overlay").style.backgroundImage = `url("${this.slides[i].dataset.bg}")`
  11350. } else {
  11351. if (activeIndex > i) {
  11352. this.slides[i].classList.remove("next");
  11353. this.slides[i].classList.add("prev");
  11354. } else {
  11355. this.slides[i].classList.add("next");
  11356. this.slides[i].classList.remove("prev");
  11357. }
  11358. }
  11359. }
  11360. }
  11361. onMove(indexFloat) {
  11362. this.container.style.transform = `translateY(${(indexFloat * 100) /
  11363. this.slides.length}%)`;
  11364. }
  11365. appear() {
  11366. this.container.classList.add("scrolling");
  11367. container.classList.add("scrolling");
  11368. this.slides[this.currentIdx].classList.remove("show-meta");
  11369. }
  11370. disperse(activeIndex) {
  11371. this.currentIdx = activeIndex;
  11372. this.slides[this.currentIdx].classList.add("show-meta");
  11373. this.container.classList.remove("scrolling");
  11374. container.classList.remove("scrolling");
  11375. for (let index = 0; index < this.data.length; index++) {
  11376. if (index > activeIndex) {
  11377. this.slides[index].classList.add("next");
  11378. this.slides[index].classList.remove("prev");
  11379. } else if (index < activeIndex) {
  11380. this.slides[index].classList.remove("next");
  11381. this.slides[index].classList.add("prev");
  11382. } else {
  11383. this.slides[index].classList.remove("next");
  11384. this.slides[index].classList.remove("prev");
  11385. }
  11386. }
  11387. }
  11388. }
  11389. class Grab {
  11390. constructor({
  11391. indexSize,
  11392. onIndexChange,
  11393. onGrabStart,
  11394. onGrabMove,
  11395. onGrabEnd
  11396. }) {
  11397. this.onGrabEnd = onGrabEnd;
  11398. this.onGrabStart = onGrabStart;
  11399. this.onGrabMove = onGrabMove;
  11400. this.scroll = {
  11401. start: 0,
  11402. current: 0,
  11403. initial: 0
  11404. };
  11405. this.listen("mousedown", this.onMouseDown.bind(this));
  11406. this.listen("mousemove", this.onMouseMove.bind(this));
  11407. this.listen("mouseup", this.onMouseUp.bind(this));
  11408. this.listen("touchstart", this.onMouseDown.bind(this), true);
  11409. this.listen("touchmove", this.onMouseMove.bind(this), true);
  11410. this.listen(["touchend", "touchcancel"], this.onMouseUp.bind(this), true);
  11411. }
  11412. listen(events, grabListener, isTouch) {
  11413. const _this = this;
  11414. let mouseListener = function (ev) {
  11415. if (ev.type === "mouseout" && ev.relatedTarget != null) return;
  11416. grabListener({
  11417. y: ev.clientY
  11418. });
  11419. };
  11420. let touchListener = function (ev) {
  11421. grabListener({
  11422. y: ev.targetTouches[0] ? ev.targetTouches[0].clientY : null
  11423. });
  11424. };
  11425. let listener = mouseListener;
  11426. if (isTouch) {
  11427. listener = touchListener;
  11428. }
  11429. if (Array.isArray(events)) {
  11430. for (let i = 0; i < events.length; i++) {
  11431. window.addEventListener(events[i], listener, false);
  11432. }
  11433. } else {
  11434. window.addEventListener(events, function (event) {
  11435. if (event.target.closest(".stickyImageContainer") === container) {
  11436. listener(event);
  11437. } else {
  11438. _this.onMouseUp()
  11439. }
  11440. }, false);
  11441. }
  11442. }
  11443. onMouseDown(position) {
  11444. this.scroll.inital = this.scroll.current;
  11445. this.scroll.start = position.y;
  11446. this.scroll.current = position.y;
  11447. this.scroll.delta = this.scroll.current - this.scroll.start;
  11448. this.onGrabStart({
  11449. delta: this.scroll.delta,
  11450. direction: Math.abs(this.scroll.delta),
  11451. current: this.scroll.current,
  11452. start: this.scroll.start
  11453. });
  11454. }
  11455. onMouseMove(position) {
  11456. if (this.scroll.start) {
  11457. this.scroll.current = position.y;
  11458. this.scroll.delta = this.scroll.current - this.scroll.start;
  11459. this.onGrabMove({
  11460. delta: this.scroll.delta,
  11461. direction: Math.abs(this.scroll.delta),
  11462. current: this.scroll.current,
  11463. start: this.scroll.start
  11464. });
  11465. }
  11466. }
  11467. onMouseUp() {
  11468. if (this.scroll.start) {
  11469. this.onGrabEnd({
  11470. delta: this.scroll.delta,
  11471. direction: Math.abs(this.scroll.delta),
  11472. current: this.scroll.current,
  11473. start: this.scroll.start
  11474. });
  11475. this.scroll.start = null;
  11476. this.scroll.current = null;
  11477. this.scroll.delta = null;
  11478. }
  11479. }
  11480. }
  11481. const reach = function ({ from, to, restDelta = 0.01 }) {
  11482. let current = Object.assign({}, from);
  11483. let keys = Object.keys(from);
  11484. let raf = {
  11485. current: null
  11486. };
  11487. let _update = function (update, complete) {
  11488. if (keys.length === 0) {
  11489. cancelAnimationFrame(raf.current);
  11490. raf.current = null;
  11491. complete(current);
  11492. return;
  11493. }
  11494. let cacheKeys = keys.slice();
  11495. for (var i = keys.length, val, key; i >= 0; i--) {
  11496. key = keys[i];
  11497. val = current[key] + (to[key] - current[key]) * 0.1;
  11498. if (Math.abs(to[key] - val) < restDelta) {
  11499. current[key] = to[key];
  11500. // Remove key
  11501. keys.splice(i, 1);
  11502. // Move i down by pne
  11503. i--;
  11504. } else {
  11505. current[key] = val;
  11506. }
  11507. }
  11508. update(current);
  11509. raf.current = requestAnimationFrame(_update);
  11510. };
  11511. return {
  11512. start: function ({
  11513. update,
  11514. complete
  11515. }) {
  11516. _update = _update.bind(null, update, complete);
  11517. raf.current = requestAnimationFrame(_update);
  11518. return {
  11519. stop: function () {
  11520. cancelAnimationFrame(raf.current);
  11521. raf.current = null;
  11522. }
  11523. };
  11524. }
  11525. };
  11526. };
  11527. function Showcase(data, options = {}) {
  11528. this.data = data;
  11529. this.progress = 0;
  11530. this.direction = 1;
  11531. this.waveIntensity = 0;
  11532. this.options = options;
  11533. this.index = {
  11534. target: 0,
  11535. current: 0,
  11536. initial: 0,
  11537. scrollSize: window.innerHeight / 6,
  11538. active: 0
  11539. };
  11540. this.follower = {
  11541. x: 0,
  11542. y: 0
  11543. };
  11544. this.followerSpring = null;
  11545. this.slidesSpring = null;
  11546. this.grab = new Grab({
  11547. onGrabStart: this.onGrabStart.bind(this),
  11548. onGrabMove: this.onGrabMove.bind(this),
  11549. onGrabEnd: this.onGrabEnd.bind(this)
  11550. });
  11551. }
  11552. function clamp(num, min, max) {
  11553. return Math.max(min, Math.min(num, max));
  11554. }
  11555. Showcase.prototype.onGrabMove = function (scroll) {
  11556. this.index.target = clamp(
  11557. this.index.initial + scroll.delta / this.index.scrollSize,
  11558. -this.data.length + 0.51,
  11559. 0.49
  11560. );
  11561. const index = clamp(Math.round(-this.index.target), 0, this.data.length - 1);
  11562. if (this.index.active !== index) {
  11563. this.index.active = index;
  11564. if (this.options.onActiveIndexChange) {
  11565. this.options.onActiveIndexChange(this.index.active);
  11566. }
  11567. }
  11568. if (this.slidesPop) {
  11569. this.slidesPop.stop();
  11570. }
  11571. this.slidesPop = reach({
  11572. from: {
  11573. index: this.index.current
  11574. },
  11575. to: {
  11576. index: this.index.target
  11577. },
  11578. restDelta: 0.001
  11579. }).start({
  11580. update: val => {
  11581. if (this.options.onIndexChange) {
  11582. this.options.onIndexChange(val.index);
  11583. }
  11584. this.index.current = val.index;
  11585. },
  11586. complete: val => {
  11587. if (this.options.onIndexChange) {
  11588. this.options.onIndexChange(val.index);
  11589. }
  11590. this.index.current = val.index;
  11591. }
  11592. });
  11593. };
  11594. Showcase.prototype.onGrabStart = function () {
  11595. if (this.options.onZoomOutStart) {
  11596. this.options.onZoomOutStart({
  11597. activeIndex: this.index.active
  11598. });
  11599. }
  11600. this.index.initial = this.index.current;
  11601. };
  11602. Showcase.prototype.snapCurrentToActiveIndex = function () {
  11603. if (this.slidesPop) {
  11604. this.slidesPop.stop();
  11605. }
  11606. this.slidesPop = reach({
  11607. from: {
  11608. index: this.index.current
  11609. },
  11610. to: {
  11611. index: Math.round(this.index.target)
  11612. },
  11613. restDelta: 0.001
  11614. }).start({
  11615. complete: () => { },
  11616. update: val => {
  11617. // this.slides.onMove(val);
  11618. if (this.options.onIndexChange) {
  11619. this.options.onIndexChange(val.index);
  11620. }
  11621. this.index.current = val.index;
  11622. }
  11623. });
  11624. };
  11625. Showcase.prototype.onGrabEnd = function () {
  11626. if (this.options.onFullscreenStart) {
  11627. this.options.onFullscreenStart({
  11628. activeIndex: this.index.active
  11629. });
  11630. this.snapCurrentToActiveIndex();
  11631. }
  11632. };
  11633. Showcase.prototype.onResize = function () {
  11634. };
  11635. const slides = new Slides();
  11636. const showcase = new Showcase(slidesData, {
  11637. onActiveIndexChange: activeIndex => {
  11638. slides.onActiveIndexChange(activeIndex);
  11639. },
  11640. onIndexChange: index => {
  11641. slides.onMove(index);
  11642. },
  11643. onZoomOutStart: ({ activeIndex }) => {
  11644. slides.appear();
  11645. },
  11646. onZoomOutFinish: ({ activeIndex }) => { },
  11647. onFullscreenStart: ({ activeIndex }) => {
  11648. slides.disperse(activeIndex);
  11649. },
  11650. onFullscreenFinish: ({ activeIndex }) => { }
  11651. });
  11652. slides.mount(container);
  11653. }
  11654. });
  11655. /*!
  11656. Isotope
  11657. Version: v3.0.6
  11658. Plugin URL: https://isotope.metafizzy.co
  11659. License: Copyright 2010-2018 Metafizzy | Licensed GPLv3 for open source use or Isotope Commercial License for commercial use
  11660. !*/
  11661. /**
  11662. * Bridget makes jQuery widgets
  11663. * v2.0.1
  11664. * MIT license
  11665. */
  11666. /* jshint browser: true, strict: true, undef: true, unused: true */
  11667. ( function( window, factory ) {
  11668. // universal module definition
  11669. /*jshint strict: false */ /* globals define, module, require */
  11670. if ( typeof define == 'function' && define.amd ) {
  11671. // AMD
  11672. define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) {
  11673. return factory( window, jQuery );
  11674. });
  11675. } else if ( typeof module == 'object' && module.exports ) {
  11676. // CommonJS
  11677. module.exports = factory(
  11678. window,
  11679. require('jquery')
  11680. );
  11681. } else {
  11682. // browser global
  11683. window.jQueryBridget = factory(
  11684. window,
  11685. window.jQuery
  11686. );
  11687. }
  11688. }( window, function factory( window, jQuery ) {
  11689. 'use strict';
  11690. // ----- utils ----- //
  11691. var arraySlice = Array.prototype.slice;
  11692. // helper function for logging errors
  11693. // $.error breaks jQuery chaining
  11694. var console = window.console;
  11695. var logError = typeof console == 'undefined' ? function() {} :
  11696. function( message ) {
  11697. console.error( message );
  11698. };
  11699. // ----- jQueryBridget ----- //
  11700. function jQueryBridget( namespace, PluginClass, $ ) {
  11701. $ = $ || jQuery || window.jQuery;
  11702. if ( !$ ) {
  11703. return;
  11704. }
  11705. // add option method -> $().plugin('option', {...})
  11706. if ( !PluginClass.prototype.option ) {
  11707. // option setter
  11708. PluginClass.prototype.option = function( opts ) {
  11709. // bail out if not an object
  11710. if ( !$.isPlainObject( opts ) ){
  11711. return;
  11712. }
  11713. this.options = $.extend( true, this.options, opts );
  11714. };
  11715. }
  11716. // make jQuery plugin
  11717. $.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
  11718. if ( typeof arg0 == 'string' ) {
  11719. // method call $().plugin( 'methodName', { options } )
  11720. // shift arguments by 1
  11721. var args = arraySlice.call( arguments, 1 );
  11722. return methodCall( this, arg0, args );
  11723. }
  11724. // just $().plugin({ options })
  11725. plainCall( this, arg0 );
  11726. return this;
  11727. };
  11728. // $().plugin('methodName')
  11729. function methodCall( $elems, methodName, args ) {
  11730. var returnValue;
  11731. var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
  11732. $elems.each( function( i, elem ) {
  11733. // get instance
  11734. var instance = $.data( elem, namespace );
  11735. if ( !instance ) {
  11736. logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
  11737. pluginMethodStr );
  11738. return;
  11739. }
  11740. var method = instance[ methodName ];
  11741. if ( !method || methodName.charAt(0) == '_' ) {
  11742. logError( pluginMethodStr + ' is not a valid method' );
  11743. return;
  11744. }
  11745. // apply method, get return value
  11746. var value = method.apply( instance, args );
  11747. // set return value if value is returned, use only first value
  11748. returnValue = returnValue === undefined ? value : returnValue;
  11749. });
  11750. return returnValue !== undefined ? returnValue : $elems;
  11751. }
  11752. function plainCall( $elems, options ) {
  11753. $elems.each( function( i, elem ) {
  11754. var instance = $.data( elem, namespace );
  11755. if ( instance ) {
  11756. // set options & init
  11757. instance.option( options );
  11758. instance._init();
  11759. } else {
  11760. // initialize new instance
  11761. instance = new PluginClass( elem, options );
  11762. $.data( elem, namespace, instance );
  11763. }
  11764. });
  11765. }
  11766. updateJQuery( $ );
  11767. }
  11768. // ----- updateJQuery ----- //
  11769. // set $.bridget for v1 backwards compatibility
  11770. function updateJQuery( $ ) {
  11771. if ( !$ || ( $ && $.bridget ) ) {
  11772. return;
  11773. }
  11774. $.bridget = jQueryBridget;
  11775. }
  11776. updateJQuery( jQuery || window.jQuery );
  11777. // ----- ----- //
  11778. return jQueryBridget;
  11779. }));
  11780. /**
  11781. * EvEmitter v1.1.0
  11782. * Lil' event emitter
  11783. * MIT License
  11784. */
  11785. /* jshint unused: true, undef: true, strict: true */
  11786. ( function( global, factory ) {
  11787. // universal module definition
  11788. /* jshint strict: false */ /* globals define, module, window */
  11789. if ( typeof define == 'function' && define.amd ) {
  11790. // AMD - RequireJS
  11791. define( 'ev-emitter/ev-emitter',factory );
  11792. } else if ( typeof module == 'object' && module.exports ) {
  11793. // CommonJS - Browserify, Webpack
  11794. module.exports = factory();
  11795. } else {
  11796. // Browser globals
  11797. global.EvEmitter = factory();
  11798. }
  11799. }( typeof window != 'undefined' ? window : this, function() {
  11800. function EvEmitter() {}
  11801. var proto = EvEmitter.prototype;
  11802. proto.on = function( eventName, listener ) {
  11803. if ( !eventName || !listener ) {
  11804. return;
  11805. }
  11806. // set events hash
  11807. var events = this._events = this._events || {};
  11808. // set listeners array
  11809. var listeners = events[ eventName ] = events[ eventName ] || [];
  11810. // only add once
  11811. if ( listeners.indexOf( listener ) == -1 ) {
  11812. listeners.push( listener );
  11813. }
  11814. return this;
  11815. };
  11816. proto.once = function( eventName, listener ) {
  11817. if ( !eventName || !listener ) {
  11818. return;
  11819. }
  11820. // add event
  11821. this.on( eventName, listener );
  11822. // set once flag
  11823. // set onceEvents hash
  11824. var onceEvents = this._onceEvents = this._onceEvents || {};
  11825. // set onceListeners object
  11826. var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
  11827. // set flag
  11828. onceListeners[ listener ] = true;
  11829. return this;
  11830. };
  11831. proto.off = function( eventName, listener ) {
  11832. var listeners = this._events && this._events[ eventName ];
  11833. if ( !listeners || !listeners.length ) {
  11834. return;
  11835. }
  11836. var index = listeners.indexOf( listener );
  11837. if ( index != -1 ) {
  11838. listeners.splice( index, 1 );
  11839. }
  11840. return this;
  11841. };
  11842. proto.emitEvent = function( eventName, args ) {
  11843. var listeners = this._events && this._events[ eventName ];
  11844. if ( !listeners || !listeners.length ) {
  11845. return;
  11846. }
  11847. // copy over to avoid interference if .off() in listener
  11848. listeners = listeners.slice(0);
  11849. args = args || [];
  11850. // once stuff
  11851. var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
  11852. for ( var i=0; i < listeners.length; i++ ) {
  11853. var listener = listeners[i]
  11854. var isOnce = onceListeners && onceListeners[ listener ];
  11855. if ( isOnce ) {
  11856. // remove listener
  11857. // remove before trigger to prevent recursion
  11858. this.off( eventName, listener );
  11859. // unset once flag
  11860. delete onceListeners[ listener ];
  11861. }
  11862. // trigger listener
  11863. listener.apply( this, args );
  11864. }
  11865. return this;
  11866. };
  11867. proto.allOff = function() {
  11868. delete this._events;
  11869. delete this._onceEvents;
  11870. };
  11871. return EvEmitter;
  11872. }));
  11873. /*!
  11874. * getSize v2.0.3
  11875. * measure size of elements
  11876. * MIT license
  11877. */
  11878. /* jshint browser: true, strict: true, undef: true, unused: true */
  11879. /* globals console: false */
  11880. ( function( window, factory ) {
  11881. /* jshint strict: false */ /* globals define, module */
  11882. if ( typeof define == 'function' && define.amd ) {
  11883. // AMD
  11884. define( 'get-size/get-size',factory );
  11885. } else if ( typeof module == 'object' && module.exports ) {
  11886. // CommonJS
  11887. module.exports = factory();
  11888. } else {
  11889. // browser global
  11890. window.getSize = factory();
  11891. }
  11892. })( window, function factory() {
  11893. 'use strict';
  11894. // -------------------------- helpers -------------------------- //
  11895. // get a number from a string, not a percentage
  11896. function getStyleSize( value ) {
  11897. var num = parseFloat( value );
  11898. // not a percent like '100%', and a number
  11899. var isValid = value.indexOf('%') == -1 && !isNaN( num );
  11900. return isValid && num;
  11901. }
  11902. function noop() {}
  11903. var logError = typeof console == 'undefined' ? noop :
  11904. function( message ) {
  11905. console.error( message );
  11906. };
  11907. // -------------------------- measurements -------------------------- //
  11908. var measurements = [
  11909. 'paddingLeft',
  11910. 'paddingRight',
  11911. 'paddingTop',
  11912. 'paddingBottom',
  11913. 'marginLeft',
  11914. 'marginRight',
  11915. 'marginTop',
  11916. 'marginBottom',
  11917. 'borderLeftWidth',
  11918. 'borderRightWidth',
  11919. 'borderTopWidth',
  11920. 'borderBottomWidth'
  11921. ];
  11922. var measurementsLength = measurements.length;
  11923. function getZeroSize() {
  11924. var size = {
  11925. width: 0,
  11926. height: 0,
  11927. innerWidth: 0,
  11928. innerHeight: 0,
  11929. outerWidth: 0,
  11930. outerHeight: 0
  11931. };
  11932. for ( var i=0; i < measurementsLength; i++ ) {
  11933. var measurement = measurements[i];
  11934. size[ measurement ] = 0;
  11935. }
  11936. return size;
  11937. }
  11938. // -------------------------- getStyle -------------------------- //
  11939. /**
  11940. * getStyle, get style of element, check for Firefox bug
  11941. * https://bugzilla.mozilla.org/show_bug.cgi?id=548397
  11942. */
  11943. function getStyle( elem ) {
  11944. var style = getComputedStyle( elem );
  11945. if ( !style ) {
  11946. logError( 'Style returned ' + style +
  11947. '. Are you running this code in a hidden iframe on Firefox? ' +
  11948. 'See https://bit.ly/getsizebug1' );
  11949. }
  11950. return style;
  11951. }
  11952. // -------------------------- setup -------------------------- //
  11953. var isSetup = false;
  11954. var isBoxSizeOuter;
  11955. /**
  11956. * setup
  11957. * check isBoxSizerOuter
  11958. * do on first getSize() rather than on page load for Firefox bug
  11959. */
  11960. function setup() {
  11961. // setup once
  11962. if ( isSetup ) {
  11963. return;
  11964. }
  11965. isSetup = true;
  11966. // -------------------------- box sizing -------------------------- //
  11967. /**
  11968. * Chrome & Safari measure the outer-width on style.width on border-box elems
  11969. * IE11 & Firefox<29 measures the inner-width
  11970. */
  11971. var div = document.createElement('div');
  11972. div.style.width = '200px';
  11973. div.style.padding = '1px 2px 3px 4px';
  11974. div.style.borderStyle = 'solid';
  11975. div.style.borderWidth = '1px 2px 3px 4px';
  11976. div.style.boxSizing = 'border-box';
  11977. var body = document.body || document.documentElement;
  11978. body.appendChild( div );
  11979. var style = getStyle( div );
  11980. // round value for browser zoom. desandro/masonry#928
  11981. isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
  11982. getSize.isBoxSizeOuter = isBoxSizeOuter;
  11983. body.removeChild( div );
  11984. }
  11985. // -------------------------- getSize -------------------------- //
  11986. function getSize( elem ) {
  11987. setup();
  11988. // use querySeletor if elem is string
  11989. if ( typeof elem == 'string' ) {
  11990. elem = document.querySelector( elem );
  11991. }
  11992. // do not proceed on non-objects
  11993. if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
  11994. return;
  11995. }
  11996. var style = getStyle( elem );
  11997. // if hidden, everything is 0
  11998. if ( style.display == 'none' ) {
  11999. return getZeroSize();
  12000. }
  12001. var size = {};
  12002. size.width = elem.offsetWidth;
  12003. size.height = elem.offsetHeight;
  12004. var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
  12005. // get all measurements
  12006. for ( var i=0; i < measurementsLength; i++ ) {
  12007. var measurement = measurements[i];
  12008. var value = style[ measurement ];
  12009. var num = parseFloat( value );
  12010. // any 'auto', 'medium' value will be 0
  12011. size[ measurement ] = !isNaN( num ) ? num : 0;
  12012. }
  12013. var paddingWidth = size.paddingLeft + size.paddingRight;
  12014. var paddingHeight = size.paddingTop + size.paddingBottom;
  12015. var marginWidth = size.marginLeft + size.marginRight;
  12016. var marginHeight = size.marginTop + size.marginBottom;
  12017. var borderWidth = size.borderLeftWidth + size.borderRightWidth;
  12018. var borderHeight = size.borderTopWidth + size.borderBottomWidth;
  12019. var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
  12020. // overwrite width and height if we can get it from style
  12021. var styleWidth = getStyleSize( style.width );
  12022. if ( styleWidth !== false ) {
  12023. size.width = styleWidth +
  12024. // add padding and border unless it's already including it
  12025. ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
  12026. }
  12027. var styleHeight = getStyleSize( style.height );
  12028. if ( styleHeight !== false ) {
  12029. size.height = styleHeight +
  12030. // add padding and border unless it's already including it
  12031. ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
  12032. }
  12033. size.innerWidth = size.width - ( paddingWidth + borderWidth );
  12034. size.innerHeight = size.height - ( paddingHeight + borderHeight );
  12035. size.outerWidth = size.width + marginWidth;
  12036. size.outerHeight = size.height + marginHeight;
  12037. return size;
  12038. }
  12039. return getSize;
  12040. });
  12041. /**
  12042. * matchesSelector v2.0.2
  12043. * matchesSelector( element, '.selector' )
  12044. * MIT license
  12045. */
  12046. /*jshint browser: true, strict: true, undef: true, unused: true */
  12047. ( function( window, factory ) {
  12048. /*global define: false, module: false */
  12049. 'use strict';
  12050. // universal module definition
  12051. if ( typeof define == 'function' && define.amd ) {
  12052. // AMD
  12053. define( 'desandro-matches-selector/matches-selector',factory );
  12054. } else if ( typeof module == 'object' && module.exports ) {
  12055. // CommonJS
  12056. module.exports = factory();
  12057. } else {
  12058. // browser global
  12059. window.matchesSelector = factory();
  12060. }
  12061. }( window, function factory() {
  12062. 'use strict';
  12063. var matchesMethod = ( function() {
  12064. var ElemProto = window.Element.prototype;
  12065. // check for the standard method name first
  12066. if ( ElemProto.matches ) {
  12067. return 'matches';
  12068. }
  12069. // check un-prefixed
  12070. if ( ElemProto.matchesSelector ) {
  12071. return 'matchesSelector';
  12072. }
  12073. // check vendor prefixes
  12074. var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
  12075. for ( var i=0; i < prefixes.length; i++ ) {
  12076. var prefix = prefixes[i];
  12077. var method = prefix + 'MatchesSelector';
  12078. if ( ElemProto[ method ] ) {
  12079. return method;
  12080. }
  12081. }
  12082. })();
  12083. return function matchesSelector( elem, selector ) {
  12084. return elem[ matchesMethod ]( selector );
  12085. };
  12086. }));
  12087. /**
  12088. * Fizzy UI utils v2.0.7
  12089. * MIT license
  12090. */
  12091. /*jshint browser: true, undef: true, unused: true, strict: true */
  12092. ( function( window, factory ) {
  12093. // universal module definition
  12094. /*jshint strict: false */ /*globals define, module, require */
  12095. if ( typeof define == 'function' && define.amd ) {
  12096. // AMD
  12097. define( 'fizzy-ui-utils/utils',[
  12098. 'desandro-matches-selector/matches-selector'
  12099. ], function( matchesSelector ) {
  12100. return factory( window, matchesSelector );
  12101. });
  12102. } else if ( typeof module == 'object' && module.exports ) {
  12103. // CommonJS
  12104. module.exports = factory(
  12105. window,
  12106. require('desandro-matches-selector')
  12107. );
  12108. } else {
  12109. // browser global
  12110. window.fizzyUIUtils = factory(
  12111. window,
  12112. window.matchesSelector
  12113. );
  12114. }
  12115. }( window, function factory( window, matchesSelector ) {
  12116. var utils = {};
  12117. // ----- extend ----- //
  12118. // extends objects
  12119. utils.extend = function( a, b ) {
  12120. for ( var prop in b ) {
  12121. a[ prop ] = b[ prop ];
  12122. }
  12123. return a;
  12124. };
  12125. // ----- modulo ----- //
  12126. utils.modulo = function( num, div ) {
  12127. return ( ( num % div ) + div ) % div;
  12128. };
  12129. // ----- makeArray ----- //
  12130. var arraySlice = Array.prototype.slice;
  12131. // turn element or nodeList into an array
  12132. utils.makeArray = function( obj ) {
  12133. if ( Array.isArray( obj ) ) {
  12134. // use object if already an array
  12135. return obj;
  12136. }
  12137. // return empty array if undefined or null. #6
  12138. if ( obj === null || obj === undefined ) {
  12139. return [];
  12140. }
  12141. var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
  12142. if ( isArrayLike ) {
  12143. // convert nodeList to array
  12144. return arraySlice.call( obj );
  12145. }
  12146. // array of single index
  12147. return [ obj ];
  12148. };
  12149. // ----- removeFrom ----- //
  12150. utils.removeFrom = function( ary, obj ) {
  12151. var index = ary.indexOf( obj );
  12152. if ( index != -1 ) {
  12153. ary.splice( index, 1 );
  12154. }
  12155. };
  12156. // ----- getParent ----- //
  12157. utils.getParent = function( elem, selector ) {
  12158. while ( elem.parentNode && elem != document.body ) {
  12159. elem = elem.parentNode;
  12160. if ( matchesSelector( elem, selector ) ) {
  12161. return elem;
  12162. }
  12163. }
  12164. };
  12165. // ----- getQueryElement ----- //
  12166. // use element as selector string
  12167. utils.getQueryElement = function( elem ) {
  12168. if ( typeof elem == 'string' ) {
  12169. return document.querySelector( elem );
  12170. }
  12171. return elem;
  12172. };
  12173. // ----- handleEvent ----- //
  12174. // enable .ontype to trigger from .addEventListener( elem, 'type' )
  12175. utils.handleEvent = function( event ) {
  12176. var method = 'on' + event.type;
  12177. if ( this[ method ] ) {
  12178. this[ method ]( event );
  12179. }
  12180. };
  12181. // ----- filterFindElements ----- //
  12182. utils.filterFindElements = function( elems, selector ) {
  12183. // make array of elems
  12184. elems = utils.makeArray( elems );
  12185. var ffElems = [];
  12186. elems.forEach( function( elem ) {
  12187. // check that elem is an actual element
  12188. if ( !( elem instanceof HTMLElement ) ) {
  12189. return;
  12190. }
  12191. // add elem if no selector
  12192. if ( !selector ) {
  12193. ffElems.push( elem );
  12194. return;
  12195. }
  12196. // filter & find items if we have a selector
  12197. // filter
  12198. if ( matchesSelector( elem, selector ) ) {
  12199. ffElems.push( elem );
  12200. }
  12201. // find children
  12202. var childElems = elem.querySelectorAll( selector );
  12203. // concat childElems to filterFound array
  12204. for ( var i=0; i < childElems.length; i++ ) {
  12205. ffElems.push( childElems[i] );
  12206. }
  12207. });
  12208. return ffElems;
  12209. };
  12210. // ----- debounceMethod ----- //
  12211. utils.debounceMethod = function( _class, methodName, threshold ) {
  12212. threshold = threshold || 100;
  12213. // original method
  12214. var method = _class.prototype[ methodName ];
  12215. var timeoutName = methodName + 'Timeout';
  12216. _class.prototype[ methodName ] = function() {
  12217. var timeout = this[ timeoutName ];
  12218. clearTimeout( timeout );
  12219. var args = arguments;
  12220. var _this = this;
  12221. this[ timeoutName ] = setTimeout( function() {
  12222. method.apply( _this, args );
  12223. delete _this[ timeoutName ];
  12224. }, threshold );
  12225. };
  12226. };
  12227. // ----- docReady ----- //
  12228. utils.docReady = function( callback ) {
  12229. var readyState = document.readyState;
  12230. if ( readyState == 'complete' || readyState == 'interactive' ) {
  12231. // do async to allow for other scripts to run. metafizzy/flickity#441
  12232. setTimeout( callback );
  12233. } else {
  12234. document.addEventListener( 'DOMContentLoaded', callback );
  12235. }
  12236. };
  12237. // ----- htmlInit ----- //
  12238. // http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
  12239. utils.toDashed = function( str ) {
  12240. return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
  12241. return $1 + '-' + $2;
  12242. }).toLowerCase();
  12243. };
  12244. var console = window.console;
  12245. /**
  12246. * allow user to initialize classes via [data-namespace] or .js-namespace class
  12247. * htmlInit( Widget, 'widgetName' )
  12248. * options are parsed from data-namespace-options
  12249. */
  12250. utils.htmlInit = function( WidgetClass, namespace ) {
  12251. utils.docReady( function() {
  12252. var dashedNamespace = utils.toDashed( namespace );
  12253. var dataAttr = 'data-' + dashedNamespace;
  12254. var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
  12255. var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
  12256. var elems = utils.makeArray( dataAttrElems )
  12257. .concat( utils.makeArray( jsDashElems ) );
  12258. var dataOptionsAttr = dataAttr + '-options';
  12259. var jQuery = window.jQuery;
  12260. elems.forEach( function( elem ) {
  12261. var attr = elem.getAttribute( dataAttr ) ||
  12262. elem.getAttribute( dataOptionsAttr );
  12263. var options;
  12264. try {
  12265. options = attr && JSON.parse( attr );
  12266. } catch ( error ) {
  12267. // log error, do not initialize
  12268. if ( console ) {
  12269. console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
  12270. ': ' + error );
  12271. }
  12272. return;
  12273. }
  12274. // initialize
  12275. var instance = new WidgetClass( elem, options );
  12276. // make available via $().data('namespace')
  12277. if ( jQuery ) {
  12278. jQuery.data( elem, namespace, instance );
  12279. }
  12280. });
  12281. });
  12282. };
  12283. // ----- ----- //
  12284. return utils;
  12285. }));
  12286. /**
  12287. * Outlayer Item
  12288. */
  12289. ( function( window, factory ) {
  12290. // universal module definition
  12291. /* jshint strict: false */ /* globals define, module, require */
  12292. if ( typeof define == 'function' && define.amd ) {
  12293. // AMD - RequireJS
  12294. define( 'outlayer/item',[
  12295. 'ev-emitter/ev-emitter',
  12296. 'get-size/get-size'
  12297. ],
  12298. factory
  12299. );
  12300. } else if ( typeof module == 'object' && module.exports ) {
  12301. // CommonJS - Browserify, Webpack
  12302. module.exports = factory(
  12303. require('ev-emitter'),
  12304. require('get-size')
  12305. );
  12306. } else {
  12307. // browser global
  12308. window.Outlayer = {};
  12309. window.Outlayer.Item = factory(
  12310. window.EvEmitter,
  12311. window.getSize
  12312. );
  12313. }
  12314. }( window, function factory( EvEmitter, getSize ) {
  12315. 'use strict';
  12316. // ----- helpers ----- //
  12317. function isEmptyObj( obj ) {
  12318. for ( var prop in obj ) {
  12319. return false;
  12320. }
  12321. prop = null;
  12322. return true;
  12323. }
  12324. // -------------------------- CSS3 support -------------------------- //
  12325. var docElemStyle = document.documentElement.style;
  12326. var transitionProperty = typeof docElemStyle.transition == 'string' ?
  12327. 'transition' : 'WebkitTransition';
  12328. var transformProperty = typeof docElemStyle.transform == 'string' ?
  12329. 'transform' : 'WebkitTransform';
  12330. var transitionEndEvent = {
  12331. WebkitTransition: 'webkitTransitionEnd',
  12332. transition: 'transitionend'
  12333. }[ transitionProperty ];
  12334. // cache all vendor properties that could have vendor prefix
  12335. var vendorProperties = {
  12336. transform: transformProperty,
  12337. transition: transitionProperty,
  12338. transitionDuration: transitionProperty + 'Duration',
  12339. transitionProperty: transitionProperty + 'Property',
  12340. transitionDelay: transitionProperty + 'Delay'
  12341. };
  12342. // -------------------------- Item -------------------------- //
  12343. function Item( element, layout ) {
  12344. if ( !element ) {
  12345. return;
  12346. }
  12347. this.element = element;
  12348. // parent layout class, i.e. Masonry, Isotope, or Packery
  12349. this.layout = layout;
  12350. this.position = {
  12351. x: 0,
  12352. y: 0
  12353. };
  12354. this._create();
  12355. }
  12356. // inherit EvEmitter
  12357. var proto = Item.prototype = Object.create( EvEmitter.prototype );
  12358. proto.constructor = Item;
  12359. proto._create = function() {
  12360. // transition objects
  12361. this._transn = {
  12362. ingProperties: {},
  12363. clean: {},
  12364. onEnd: {}
  12365. };
  12366. this.css({
  12367. position: 'absolute'
  12368. });
  12369. };
  12370. // trigger specified handler for event type
  12371. proto.handleEvent = function( event ) {
  12372. var method = 'on' + event.type;
  12373. if ( this[ method ] ) {
  12374. this[ method ]( event );
  12375. }
  12376. };
  12377. proto.getSize = function() {
  12378. this.size = getSize( this.element );
  12379. };
  12380. /**
  12381. * apply CSS styles to element
  12382. * @param {Object} style
  12383. */
  12384. proto.css = function( style ) {
  12385. var elemStyle = this.element.style;
  12386. for ( var prop in style ) {
  12387. // use vendor property if available
  12388. var supportedProp = vendorProperties[ prop ] || prop;
  12389. elemStyle[ supportedProp ] = style[ prop ];
  12390. }
  12391. };
  12392. // measure position, and sets it
  12393. proto.getPosition = function() {
  12394. var style = getComputedStyle( this.element );
  12395. var isOriginLeft = this.layout._getOption('originLeft');
  12396. var isOriginTop = this.layout._getOption('originTop');
  12397. var xValue = style[ isOriginLeft ? 'left' : 'right' ];
  12398. var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
  12399. var x = parseFloat( xValue );
  12400. var y = parseFloat( yValue );
  12401. // convert percent to pixels
  12402. var layoutSize = this.layout.size;
  12403. if ( xValue.indexOf('%') != -1 ) {
  12404. x = ( x / 100 ) * layoutSize.width;
  12405. }
  12406. if ( yValue.indexOf('%') != -1 ) {
  12407. y = ( y / 100 ) * layoutSize.height;
  12408. }
  12409. // clean up 'auto' or other non-integer values
  12410. x = isNaN( x ) ? 0 : x;
  12411. y = isNaN( y ) ? 0 : y;
  12412. // remove padding from measurement
  12413. x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
  12414. y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
  12415. this.position.x = x;
  12416. this.position.y = y;
  12417. };
  12418. // set settled position, apply padding
  12419. proto.layoutPosition = function() {
  12420. var layoutSize = this.layout.size;
  12421. var style = {};
  12422. var isOriginLeft = this.layout._getOption('originLeft');
  12423. var isOriginTop = this.layout._getOption('originTop');
  12424. // x
  12425. var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight';
  12426. var xProperty = isOriginLeft ? 'left' : 'right';
  12427. var xResetProperty = isOriginLeft ? 'right' : 'left';
  12428. var x = this.position.x + layoutSize[ xPadding ];
  12429. // set in percentage or pixels
  12430. style[ xProperty ] = this.getXValue( x );
  12431. // reset other property
  12432. style[ xResetProperty ] = '';
  12433. // y
  12434. var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom';
  12435. var yProperty = isOriginTop ? 'top' : 'bottom';
  12436. var yResetProperty = isOriginTop ? 'bottom' : 'top';
  12437. var y = this.position.y + layoutSize[ yPadding ];
  12438. // set in percentage or pixels
  12439. style[ yProperty ] = this.getYValue( y );
  12440. // reset other property
  12441. style[ yResetProperty ] = '';
  12442. this.css( style );
  12443. this.emitEvent( 'layout', [ this ] );
  12444. };
  12445. proto.getXValue = function( x ) {
  12446. var isHorizontal = this.layout._getOption('horizontal');
  12447. return this.layout.options.percentPosition && !isHorizontal ?
  12448. ( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px';
  12449. };
  12450. proto.getYValue = function( y ) {
  12451. var isHorizontal = this.layout._getOption('horizontal');
  12452. return this.layout.options.percentPosition && isHorizontal ?
  12453. ( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px';
  12454. };
  12455. proto._transitionTo = function( x, y ) {
  12456. this.getPosition();
  12457. // get current x & y from top/left
  12458. var curX = this.position.x;
  12459. var curY = this.position.y;
  12460. var didNotMove = x == this.position.x && y == this.position.y;
  12461. // save end position
  12462. this.setPosition( x, y );
  12463. // if did not move and not transitioning, just go to layout
  12464. if ( didNotMove && !this.isTransitioning ) {
  12465. this.layoutPosition();
  12466. return;
  12467. }
  12468. var transX = x - curX;
  12469. var transY = y - curY;
  12470. var transitionStyle = {};
  12471. transitionStyle.transform = this.getTranslate( transX, transY );
  12472. this.transition({
  12473. to: transitionStyle,
  12474. onTransitionEnd: {
  12475. transform: this.layoutPosition
  12476. },
  12477. isCleaning: true
  12478. });
  12479. };
  12480. proto.getTranslate = function( x, y ) {
  12481. // flip cooridinates if origin on right or bottom
  12482. var isOriginLeft = this.layout._getOption('originLeft');
  12483. var isOriginTop = this.layout._getOption('originTop');
  12484. x = isOriginLeft ? x : -x;
  12485. y = isOriginTop ? y : -y;
  12486. return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
  12487. };
  12488. // non transition + transform support
  12489. proto.goTo = function( x, y ) {
  12490. this.setPosition( x, y );
  12491. this.layoutPosition();
  12492. };
  12493. proto.moveTo = proto._transitionTo;
  12494. proto.setPosition = function( x, y ) {
  12495. this.position.x = parseFloat( x );
  12496. this.position.y = parseFloat( y );
  12497. };
  12498. // ----- transition ----- //
  12499. /**
  12500. * @param {Object} style - CSS
  12501. * @param {Function} onTransitionEnd
  12502. */
  12503. // non transition, just trigger callback
  12504. proto._nonTransition = function( args ) {
  12505. this.css( args.to );
  12506. if ( args.isCleaning ) {
  12507. this._removeStyles( args.to );
  12508. }
  12509. for ( var prop in args.onTransitionEnd ) {
  12510. args.onTransitionEnd[ prop ].call( this );
  12511. }
  12512. };
  12513. /**
  12514. * proper transition
  12515. * @param {Object} args - arguments
  12516. * @param {Object} to - style to transition to
  12517. * @param {Object} from - style to start transition from
  12518. * @param {Boolean} isCleaning - removes transition styles after transition
  12519. * @param {Function} onTransitionEnd - callback
  12520. */
  12521. proto.transition = function( args ) {
  12522. // redirect to nonTransition if no transition duration
  12523. if ( !parseFloat( this.layout.options.transitionDuration ) ) {
  12524. this._nonTransition( args );
  12525. return;
  12526. }
  12527. var _transition = this._transn;
  12528. // keep track of onTransitionEnd callback by css property
  12529. for ( var prop in args.onTransitionEnd ) {
  12530. _transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
  12531. }
  12532. // keep track of properties that are transitioning
  12533. for ( prop in args.to ) {
  12534. _transition.ingProperties[ prop ] = true;
  12535. // keep track of properties to clean up when transition is done
  12536. if ( args.isCleaning ) {
  12537. _transition.clean[ prop ] = true;
  12538. }
  12539. }
  12540. // set from styles
  12541. if ( args.from ) {
  12542. this.css( args.from );
  12543. // force redraw. http://blog.alexmaccaw.com/css-transitions
  12544. var h = this.element.offsetHeight;
  12545. // hack for JSHint to hush about unused var
  12546. h = null;
  12547. }
  12548. // enable transition
  12549. this.enableTransition( args.to );
  12550. // set styles that are transitioning
  12551. this.css( args.to );
  12552. this.isTransitioning = true;
  12553. };
  12554. // dash before all cap letters, including first for
  12555. // WebkitTransform => -webkit-transform
  12556. function toDashedAll( str ) {
  12557. return str.replace( /([A-Z])/g, function( $1 ) {
  12558. return '-' + $1.toLowerCase();
  12559. });
  12560. }
  12561. var transitionProps = 'opacity,' + toDashedAll( transformProperty );
  12562. proto.enableTransition = function(/* style */) {
  12563. // HACK changing transitionProperty during a transition
  12564. // will cause transition to jump
  12565. if ( this.isTransitioning ) {
  12566. return;
  12567. }
  12568. // make `transition: foo, bar, baz` from style object
  12569. // HACK un-comment this when enableTransition can work
  12570. // while a transition is happening
  12571. // var transitionValues = [];
  12572. // for ( var prop in style ) {
  12573. // // dash-ify camelCased properties like WebkitTransition
  12574. // prop = vendorProperties[ prop ] || prop;
  12575. // transitionValues.push( toDashedAll( prop ) );
  12576. // }
  12577. // munge number to millisecond, to match stagger
  12578. var duration = this.layout.options.transitionDuration;
  12579. duration = typeof duration == 'number' ? duration + 'ms' : duration;
  12580. // enable transition styles
  12581. this.css({
  12582. transitionProperty: transitionProps,
  12583. transitionDuration: duration,
  12584. transitionDelay: this.staggerDelay || 0
  12585. });
  12586. // listen for transition end event
  12587. this.element.addEventListener( transitionEndEvent, this, false );
  12588. };
  12589. // ----- events ----- //
  12590. proto.onwebkitTransitionEnd = function( event ) {
  12591. this.ontransitionend( event );
  12592. };
  12593. proto.onotransitionend = function( event ) {
  12594. this.ontransitionend( event );
  12595. };
  12596. // properties that I munge to make my life easier
  12597. var dashedVendorProperties = {
  12598. '-webkit-transform': 'transform'
  12599. };
  12600. proto.ontransitionend = function( event ) {
  12601. // disregard bubbled events from children
  12602. if ( event.target !== this.element ) {
  12603. return;
  12604. }
  12605. var _transition = this._transn;
  12606. // get property name of transitioned property, convert to prefix-free
  12607. var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
  12608. // remove property that has completed transitioning
  12609. delete _transition.ingProperties[ propertyName ];
  12610. // check if any properties are still transitioning
  12611. if ( isEmptyObj( _transition.ingProperties ) ) {
  12612. // all properties have completed transitioning
  12613. this.disableTransition();
  12614. }
  12615. // clean style
  12616. if ( propertyName in _transition.clean ) {
  12617. // clean up style
  12618. this.element.style[ event.propertyName ] = '';
  12619. delete _transition.clean[ propertyName ];
  12620. }
  12621. // trigger onTransitionEnd callback
  12622. if ( propertyName in _transition.onEnd ) {
  12623. var onTransitionEnd = _transition.onEnd[ propertyName ];
  12624. onTransitionEnd.call( this );
  12625. delete _transition.onEnd[ propertyName ];
  12626. }
  12627. this.emitEvent( 'transitionEnd', [ this ] );
  12628. };
  12629. proto.disableTransition = function() {
  12630. this.removeTransitionStyles();
  12631. this.element.removeEventListener( transitionEndEvent, this, false );
  12632. this.isTransitioning = false;
  12633. };
  12634. /**
  12635. * removes style property from element
  12636. * @param {Object} style
  12637. **/
  12638. proto._removeStyles = function( style ) {
  12639. // clean up transition styles
  12640. var cleanStyle = {};
  12641. for ( var prop in style ) {
  12642. cleanStyle[ prop ] = '';
  12643. }
  12644. this.css( cleanStyle );
  12645. };
  12646. var cleanTransitionStyle = {
  12647. transitionProperty: '',
  12648. transitionDuration: '',
  12649. transitionDelay: ''
  12650. };
  12651. proto.removeTransitionStyles = function() {
  12652. // remove transition
  12653. this.css( cleanTransitionStyle );
  12654. };
  12655. // ----- stagger ----- //
  12656. proto.stagger = function( delay ) {
  12657. delay = isNaN( delay ) ? 0 : delay;
  12658. this.staggerDelay = delay + 'ms';
  12659. };
  12660. // ----- show/hide/remove ----- //
  12661. // remove element from DOM
  12662. proto.removeElem = function() {
  12663. this.element.parentNode.removeChild( this.element );
  12664. // remove display: none
  12665. this.css({ display: '' });
  12666. this.emitEvent( 'remove', [ this ] );
  12667. };
  12668. proto.remove = function() {
  12669. // just remove element if no transition support or no transition
  12670. if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
  12671. this.removeElem();
  12672. return;
  12673. }
  12674. // start transition
  12675. this.once( 'transitionEnd', function() {
  12676. this.removeElem();
  12677. });
  12678. this.hide();
  12679. };
  12680. proto.reveal = function() {
  12681. delete this.isHidden;
  12682. // remove display: none
  12683. this.css({ display: '' });
  12684. var options = this.layout.options;
  12685. var onTransitionEnd = {};
  12686. var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
  12687. onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
  12688. this.transition({
  12689. from: options.hiddenStyle,
  12690. to: options.visibleStyle,
  12691. isCleaning: true,
  12692. onTransitionEnd: onTransitionEnd
  12693. });
  12694. };
  12695. proto.onRevealTransitionEnd = function() {
  12696. // check if still visible
  12697. // during transition, item may have been hidden
  12698. if ( !this.isHidden ) {
  12699. this.emitEvent('reveal');
  12700. }
  12701. };
  12702. /**
  12703. * get style property use for hide/reveal transition end
  12704. * @param {String} styleProperty - hiddenStyle/visibleStyle
  12705. * @returns {String}
  12706. */
  12707. proto.getHideRevealTransitionEndProperty = function( styleProperty ) {
  12708. var optionStyle = this.layout.options[ styleProperty ];
  12709. // use opacity
  12710. if ( optionStyle.opacity ) {
  12711. return 'opacity';
  12712. }
  12713. // get first property
  12714. for ( var prop in optionStyle ) {
  12715. return prop;
  12716. }
  12717. };
  12718. proto.hide = function() {
  12719. // set flag
  12720. this.isHidden = true;
  12721. // remove display: none
  12722. this.css({ display: '' });
  12723. var options = this.layout.options;
  12724. var onTransitionEnd = {};
  12725. var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
  12726. onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
  12727. this.transition({
  12728. from: options.visibleStyle,
  12729. to: options.hiddenStyle,
  12730. // keep hidden stuff hidden
  12731. isCleaning: true,
  12732. onTransitionEnd: onTransitionEnd
  12733. });
  12734. };
  12735. proto.onHideTransitionEnd = function() {
  12736. // check if still hidden
  12737. // during transition, item may have been un-hidden
  12738. if ( this.isHidden ) {
  12739. this.css({ display: 'none' });
  12740. this.emitEvent('hide');
  12741. }
  12742. };
  12743. proto.destroy = function() {
  12744. this.css({
  12745. position: '',
  12746. left: '',
  12747. right: '',
  12748. top: '',
  12749. bottom: '',
  12750. transition: '',
  12751. transform: ''
  12752. });
  12753. };
  12754. return Item;
  12755. }));
  12756. /*!
  12757. * Outlayer v2.1.1
  12758. * the brains and guts of a layout library
  12759. * MIT license
  12760. */
  12761. ( function( window, factory ) {
  12762. 'use strict';
  12763. // universal module definition
  12764. /* jshint strict: false */ /* globals define, module, require */
  12765. if ( typeof define == 'function' && define.amd ) {
  12766. // AMD - RequireJS
  12767. define( 'outlayer/outlayer',[
  12768. 'ev-emitter/ev-emitter',
  12769. 'get-size/get-size',
  12770. 'fizzy-ui-utils/utils',
  12771. './item'
  12772. ],
  12773. function( EvEmitter, getSize, utils, Item ) {
  12774. return factory( window, EvEmitter, getSize, utils, Item);
  12775. }
  12776. );
  12777. } else if ( typeof module == 'object' && module.exports ) {
  12778. // CommonJS - Browserify, Webpack
  12779. module.exports = factory(
  12780. window,
  12781. require('ev-emitter'),
  12782. require('get-size'),
  12783. require('fizzy-ui-utils'),
  12784. require('./item')
  12785. );
  12786. } else {
  12787. // browser global
  12788. window.Outlayer = factory(
  12789. window,
  12790. window.EvEmitter,
  12791. window.getSize,
  12792. window.fizzyUIUtils,
  12793. window.Outlayer.Item
  12794. );
  12795. }
  12796. }( window, function factory( window, EvEmitter, getSize, utils, Item ) {
  12797. 'use strict';
  12798. // ----- vars ----- //
  12799. var console = window.console;
  12800. var jQuery = window.jQuery;
  12801. var noop = function() {};
  12802. // -------------------------- Outlayer -------------------------- //
  12803. // globally unique identifiers
  12804. var GUID = 0;
  12805. // internal store of all Outlayer intances
  12806. var instances = {};
  12807. /**
  12808. * @param {Element, String} element
  12809. * @param {Object} options
  12810. * @constructor
  12811. */
  12812. function Outlayer( element, options ) {
  12813. var queryElement = utils.getQueryElement( element );
  12814. if ( !queryElement ) {
  12815. if ( console ) {
  12816. console.error( 'Bad element for ' + this.constructor.namespace +
  12817. ': ' + ( queryElement || element ) );
  12818. }
  12819. return;
  12820. }
  12821. this.element = queryElement;
  12822. // add jQuery
  12823. if ( jQuery ) {
  12824. this.$element = jQuery( this.element );
  12825. }
  12826. // options
  12827. this.options = utils.extend( {}, this.constructor.defaults );
  12828. this.option( options );
  12829. // add id for Outlayer.getFromElement
  12830. var id = ++GUID;
  12831. this.element.outlayerGUID = id; // expando
  12832. instances[ id ] = this; // associate via id
  12833. // kick it off
  12834. this._create();
  12835. var isInitLayout = this._getOption('initLayout');
  12836. if ( isInitLayout ) {
  12837. this.layout();
  12838. }
  12839. }
  12840. // settings are for internal use only
  12841. Outlayer.namespace = 'outlayer';
  12842. Outlayer.Item = Item;
  12843. // default options
  12844. Outlayer.defaults = {
  12845. containerStyle: {
  12846. position: 'relative'
  12847. },
  12848. initLayout: true,
  12849. originLeft: true,
  12850. originTop: true,
  12851. resize: true,
  12852. resizeContainer: true,
  12853. // item options
  12854. transitionDuration: '0.4s',
  12855. hiddenStyle: {
  12856. opacity: 0,
  12857. transform: 'scale(0.001)'
  12858. },
  12859. visibleStyle: {
  12860. opacity: 1,
  12861. transform: 'scale(1)'
  12862. }
  12863. };
  12864. var proto = Outlayer.prototype;
  12865. // inherit EvEmitter
  12866. utils.extend( proto, EvEmitter.prototype );
  12867. /**
  12868. * set options
  12869. * @param {Object} opts
  12870. */
  12871. proto.option = function( opts ) {
  12872. utils.extend( this.options, opts );
  12873. };
  12874. /**
  12875. * get backwards compatible option value, check old name
  12876. */
  12877. proto._getOption = function( option ) {
  12878. var oldOption = this.constructor.compatOptions[ option ];
  12879. return oldOption && this.options[ oldOption ] !== undefined ?
  12880. this.options[ oldOption ] : this.options[ option ];
  12881. };
  12882. Outlayer.compatOptions = {
  12883. // currentName: oldName
  12884. initLayout: 'isInitLayout',
  12885. horizontal: 'isHorizontal',
  12886. layoutInstant: 'isLayoutInstant',
  12887. originLeft: 'isOriginLeft',
  12888. originTop: 'isOriginTop',
  12889. resize: 'isResizeBound',
  12890. resizeContainer: 'isResizingContainer'
  12891. };
  12892. proto._create = function() {
  12893. // get items from children
  12894. this.reloadItems();
  12895. // elements that affect layout, but are not laid out
  12896. this.stamps = [];
  12897. this.stamp( this.options.stamp );
  12898. // set container style
  12899. utils.extend( this.element.style, this.options.containerStyle );
  12900. // bind resize method
  12901. var canBindResize = this._getOption('resize');
  12902. if ( canBindResize ) {
  12903. this.bindResize();
  12904. }
  12905. };
  12906. // goes through all children again and gets bricks in proper order
  12907. proto.reloadItems = function() {
  12908. // collection of item elements
  12909. this.items = this._itemize( this.element.children );
  12910. };
  12911. /**
  12912. * turn elements into Outlayer.Items to be used in layout
  12913. * @param {Array or NodeList or HTMLElement} elems
  12914. * @returns {Array} items - collection of new Outlayer Items
  12915. */
  12916. proto._itemize = function( elems ) {
  12917. var itemElems = this._filterFindItemElements( elems );
  12918. var Item = this.constructor.Item;
  12919. // create new Outlayer Items for collection
  12920. var items = [];
  12921. for ( var i=0; i < itemElems.length; i++ ) {
  12922. var elem = itemElems[i];
  12923. var item = new Item( elem, this );
  12924. items.push( item );
  12925. }
  12926. return items;
  12927. };
  12928. /**
  12929. * get item elements to be used in layout
  12930. * @param {Array or NodeList or HTMLElement} elems
  12931. * @returns {Array} items - item elements
  12932. */
  12933. proto._filterFindItemElements = function( elems ) {
  12934. return utils.filterFindElements( elems, this.options.itemSelector );
  12935. };
  12936. /**
  12937. * getter method for getting item elements
  12938. * @returns {Array} elems - collection of item elements
  12939. */
  12940. proto.getItemElements = function() {
  12941. return this.items.map( function( item ) {
  12942. return item.element;
  12943. });
  12944. };
  12945. // ----- init & layout ----- //
  12946. /**
  12947. * lays out all items
  12948. */
  12949. proto.layout = function() {
  12950. this._resetLayout();
  12951. this._manageStamps();
  12952. // don't animate first layout
  12953. var layoutInstant = this._getOption('layoutInstant');
  12954. var isInstant = layoutInstant !== undefined ?
  12955. layoutInstant : !this._isLayoutInited;
  12956. this.layoutItems( this.items, isInstant );
  12957. // flag for initalized
  12958. this._isLayoutInited = true;
  12959. };
  12960. // _init is alias for layout
  12961. proto._init = proto.layout;
  12962. /**
  12963. * logic before any new layout
  12964. */
  12965. proto._resetLayout = function() {
  12966. this.getSize();
  12967. };
  12968. proto.getSize = function() {
  12969. this.size = getSize( this.element );
  12970. };
  12971. /**
  12972. * get measurement from option, for columnWidth, rowHeight, gutter
  12973. * if option is String -> get element from selector string, & get size of element
  12974. * if option is Element -> get size of element
  12975. * else use option as a number
  12976. *
  12977. * @param {String} measurement
  12978. * @param {String} size - width or height
  12979. * @private
  12980. */
  12981. proto._getMeasurement = function( measurement, size ) {
  12982. var option = this.options[ measurement ];
  12983. var elem;
  12984. if ( !option ) {
  12985. // default to 0
  12986. this[ measurement ] = 0;
  12987. } else {
  12988. // use option as an element
  12989. if ( typeof option == 'string' ) {
  12990. elem = this.element.querySelector( option );
  12991. } else if ( option instanceof HTMLElement ) {
  12992. elem = option;
  12993. }
  12994. // use size of element, if element
  12995. this[ measurement ] = elem ? getSize( elem )[ size ] : option;
  12996. }
  12997. };
  12998. /**
  12999. * layout a collection of item elements
  13000. * @api public
  13001. */
  13002. proto.layoutItems = function( items, isInstant ) {
  13003. items = this._getItemsForLayout( items );
  13004. this._layoutItems( items, isInstant );
  13005. this._postLayout();
  13006. };
  13007. /**
  13008. * get the items to be laid out
  13009. * you may want to skip over some items
  13010. * @param {Array} items
  13011. * @returns {Array} items
  13012. */
  13013. proto._getItemsForLayout = function( items ) {
  13014. return items.filter( function( item ) {
  13015. return !item.isIgnored;
  13016. });
  13017. };
  13018. /**
  13019. * layout items
  13020. * @param {Array} items
  13021. * @param {Boolean} isInstant
  13022. */
  13023. proto._layoutItems = function( items, isInstant ) {
  13024. this._emitCompleteOnItems( 'layout', items );
  13025. if ( !items || !items.length ) {
  13026. // no items, emit event with empty array
  13027. return;
  13028. }
  13029. var queue = [];
  13030. items.forEach( function( item ) {
  13031. // get x/y object from method
  13032. var position = this._getItemLayoutPosition( item );
  13033. // enqueue
  13034. position.item = item;
  13035. position.isInstant = isInstant || item.isLayoutInstant;
  13036. queue.push( position );
  13037. }, this );
  13038. this._processLayoutQueue( queue );
  13039. };
  13040. /**
  13041. * get item layout position
  13042. * @param {Outlayer.Item} item
  13043. * @returns {Object} x and y position
  13044. */
  13045. proto._getItemLayoutPosition = function( /* item */ ) {
  13046. return {
  13047. x: 0,
  13048. y: 0
  13049. };
  13050. };
  13051. /**
  13052. * iterate over array and position each item
  13053. * Reason being - separating this logic prevents 'layout invalidation'
  13054. * thx @paul_irish
  13055. * @param {Array} queue
  13056. */
  13057. proto._processLayoutQueue = function( queue ) {
  13058. this.updateStagger();
  13059. queue.forEach( function( obj, i ) {
  13060. this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i );
  13061. }, this );
  13062. };
  13063. // set stagger from option in milliseconds number
  13064. proto.updateStagger = function() {
  13065. var stagger = this.options.stagger;
  13066. if ( stagger === null || stagger === undefined ) {
  13067. this.stagger = 0;
  13068. return;
  13069. }
  13070. this.stagger = getMilliseconds( stagger );
  13071. return this.stagger;
  13072. };
  13073. /**
  13074. * Sets position of item in DOM
  13075. * @param {Outlayer.Item} item
  13076. * @param {Number} x - horizontal position
  13077. * @param {Number} y - vertical position
  13078. * @param {Boolean} isInstant - disables transitions
  13079. */
  13080. proto._positionItem = function( item, x, y, isInstant, i ) {
  13081. if ( isInstant ) {
  13082. // if not transition, just set CSS
  13083. item.goTo( x, y );
  13084. } else {
  13085. item.stagger( i * this.stagger );
  13086. item.moveTo( x, y );
  13087. }
  13088. };
  13089. /**
  13090. * Any logic you want to do after each layout,
  13091. * i.e. size the container
  13092. */
  13093. proto._postLayout = function() {
  13094. this.resizeContainer();
  13095. };
  13096. proto.resizeContainer = function() {
  13097. var isResizingContainer = this._getOption('resizeContainer');
  13098. if ( !isResizingContainer ) {
  13099. return;
  13100. }
  13101. var size = this._getContainerSize();
  13102. if ( size ) {
  13103. this._setContainerMeasure( size.width, true );
  13104. this._setContainerMeasure( size.height, false );
  13105. }
  13106. };
  13107. /**
  13108. * Sets width or height of container if returned
  13109. * @returns {Object} size
  13110. * @param {Number} width
  13111. * @param {Number} height
  13112. */
  13113. proto._getContainerSize = noop;
  13114. /**
  13115. * @param {Number} measure - size of width or height
  13116. * @param {Boolean} isWidth
  13117. */
  13118. proto._setContainerMeasure = function( measure, isWidth ) {
  13119. if ( measure === undefined ) {
  13120. return;
  13121. }
  13122. var elemSize = this.size;
  13123. // add padding and border width if border box
  13124. if ( elemSize.isBorderBox ) {
  13125. measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
  13126. elemSize.borderLeftWidth + elemSize.borderRightWidth :
  13127. elemSize.paddingBottom + elemSize.paddingTop +
  13128. elemSize.borderTopWidth + elemSize.borderBottomWidth;
  13129. }
  13130. measure = Math.max( measure, 0 );
  13131. this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
  13132. };
  13133. /**
  13134. * emit eventComplete on a collection of items events
  13135. * @param {String} eventName
  13136. * @param {Array} items - Outlayer.Items
  13137. */
  13138. proto._emitCompleteOnItems = function( eventName, items ) {
  13139. var _this = this;
  13140. function onComplete() {
  13141. _this.dispatchEvent( eventName + 'Complete', null, [ items ] );
  13142. }
  13143. var count = items.length;
  13144. if ( !items || !count ) {
  13145. onComplete();
  13146. return;
  13147. }
  13148. var doneCount = 0;
  13149. function tick() {
  13150. doneCount++;
  13151. if ( doneCount == count ) {
  13152. onComplete();
  13153. }
  13154. }
  13155. // bind callback
  13156. items.forEach( function( item ) {
  13157. item.once( eventName, tick );
  13158. });
  13159. };
  13160. /**
  13161. * emits events via EvEmitter and jQuery events
  13162. * @param {String} type - name of event
  13163. * @param {Event} event - original event
  13164. * @param {Array} args - extra arguments
  13165. */
  13166. proto.dispatchEvent = function( type, event, args ) {
  13167. // add original event to arguments
  13168. var emitArgs = event ? [ event ].concat( args ) : args;
  13169. this.emitEvent( type, emitArgs );
  13170. if ( jQuery ) {
  13171. // set this.$element
  13172. this.$element = this.$element || jQuery( this.element );
  13173. if ( event ) {
  13174. // create jQuery event
  13175. var $event = jQuery.Event( event );
  13176. $event.type = type;
  13177. this.$element.trigger( $event, args );
  13178. } else {
  13179. // just trigger with type if no event available
  13180. this.$element.trigger( type, args );
  13181. }
  13182. }
  13183. };
  13184. // -------------------------- ignore & stamps -------------------------- //
  13185. /**
  13186. * keep item in collection, but do not lay it out
  13187. * ignored items do not get skipped in layout
  13188. * @param {Element} elem
  13189. */
  13190. proto.ignore = function( elem ) {
  13191. var item = this.getItem( elem );
  13192. if ( item ) {
  13193. item.isIgnored = true;
  13194. }
  13195. };
  13196. /**
  13197. * return item to layout collection
  13198. * @param {Element} elem
  13199. */
  13200. proto.unignore = function( elem ) {
  13201. var item = this.getItem( elem );
  13202. if ( item ) {
  13203. delete item.isIgnored;
  13204. }
  13205. };
  13206. /**
  13207. * adds elements to stamps
  13208. * @param {NodeList, Array, Element, or String} elems
  13209. */
  13210. proto.stamp = function( elems ) {
  13211. elems = this._find( elems );
  13212. if ( !elems ) {
  13213. return;
  13214. }
  13215. this.stamps = this.stamps.concat( elems );
  13216. // ignore
  13217. elems.forEach( this.ignore, this );
  13218. };
  13219. /**
  13220. * removes elements to stamps
  13221. * @param {NodeList, Array, or Element} elems
  13222. */
  13223. proto.unstamp = function( elems ) {
  13224. elems = this._find( elems );
  13225. if ( !elems ){
  13226. return;
  13227. }
  13228. elems.forEach( function( elem ) {
  13229. // filter out removed stamp elements
  13230. utils.removeFrom( this.stamps, elem );
  13231. this.unignore( elem );
  13232. }, this );
  13233. };
  13234. /**
  13235. * finds child elements
  13236. * @param {NodeList, Array, Element, or String} elems
  13237. * @returns {Array} elems
  13238. */
  13239. proto._find = function( elems ) {
  13240. if ( !elems ) {
  13241. return;
  13242. }
  13243. // if string, use argument as selector string
  13244. if ( typeof elems == 'string' ) {
  13245. elems = this.element.querySelectorAll( elems );
  13246. }
  13247. elems = utils.makeArray( elems );
  13248. return elems;
  13249. };
  13250. proto._manageStamps = function() {
  13251. if ( !this.stamps || !this.stamps.length ) {
  13252. return;
  13253. }
  13254. this._getBoundingRect();
  13255. this.stamps.forEach( this._manageStamp, this );
  13256. };
  13257. // update boundingLeft / Top
  13258. proto._getBoundingRect = function() {
  13259. // get bounding rect for container element
  13260. var boundingRect = this.element.getBoundingClientRect();
  13261. var size = this.size;
  13262. this._boundingRect = {
  13263. left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
  13264. top: boundingRect.top + size.paddingTop + size.borderTopWidth,
  13265. right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
  13266. bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
  13267. };
  13268. };
  13269. /**
  13270. * @param {Element} stamp
  13271. **/
  13272. proto._manageStamp = noop;
  13273. /**
  13274. * get x/y position of element relative to container element
  13275. * @param {Element} elem
  13276. * @returns {Object} offset - has left, top, right, bottom
  13277. */
  13278. proto._getElementOffset = function( elem ) {
  13279. var boundingRect = elem.getBoundingClientRect();
  13280. var thisRect = this._boundingRect;
  13281. var size = getSize( elem );
  13282. var offset = {
  13283. left: boundingRect.left - thisRect.left - size.marginLeft,
  13284. top: boundingRect.top - thisRect.top - size.marginTop,
  13285. right: thisRect.right - boundingRect.right - size.marginRight,
  13286. bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
  13287. };
  13288. return offset;
  13289. };
  13290. // -------------------------- resize -------------------------- //
  13291. // enable event handlers for listeners
  13292. // i.e. resize -> onresize
  13293. proto.handleEvent = utils.handleEvent;
  13294. /**
  13295. * Bind layout to window resizing
  13296. */
  13297. proto.bindResize = function() {
  13298. window.addEventListener( 'resize', this );
  13299. this.isResizeBound = true;
  13300. };
  13301. /**
  13302. * Unbind layout to window resizing
  13303. */
  13304. proto.unbindResize = function() {
  13305. window.removeEventListener( 'resize', this );
  13306. this.isResizeBound = false;
  13307. };
  13308. proto.onresize = function() {
  13309. this.resize();
  13310. };
  13311. utils.debounceMethod( Outlayer, 'onresize', 100 );
  13312. proto.resize = function() {
  13313. // don't trigger if size did not change
  13314. // or if resize was unbound. See #9
  13315. if ( !this.isResizeBound || !this.needsResizeLayout() ) {
  13316. return;
  13317. }
  13318. this.layout();
  13319. };
  13320. /**
  13321. * check if layout is needed post layout
  13322. * @returns Boolean
  13323. */
  13324. proto.needsResizeLayout = function() {
  13325. var size = getSize( this.element );
  13326. // check that this.size and size are there
  13327. // IE8 triggers resize on body size change, so they might not be
  13328. var hasSizes = this.size && size;
  13329. return hasSizes && size.innerWidth !== this.size.innerWidth;
  13330. };
  13331. // -------------------------- methods -------------------------- //
  13332. /**
  13333. * add items to Outlayer instance
  13334. * @param {Array or NodeList or Element} elems
  13335. * @returns {Array} items - Outlayer.Items
  13336. **/
  13337. proto.addItems = function( elems ) {
  13338. var items = this._itemize( elems );
  13339. // add items to collection
  13340. if ( items.length ) {
  13341. this.items = this.items.concat( items );
  13342. }
  13343. return items;
  13344. };
  13345. /**
  13346. * Layout newly-appended item elements
  13347. * @param {Array or NodeList or Element} elems
  13348. */
  13349. proto.appended = function( elems ) {
  13350. var items = this.addItems( elems );
  13351. if ( !items.length ) {
  13352. return;
  13353. }
  13354. // layout and reveal just the new items
  13355. this.layoutItems( items, true );
  13356. this.reveal( items );
  13357. };
  13358. /**
  13359. * Layout prepended elements
  13360. * @param {Array or NodeList or Element} elems
  13361. */
  13362. proto.prepended = function( elems ) {
  13363. var items = this._itemize( elems );
  13364. if ( !items.length ) {
  13365. return;
  13366. }
  13367. // add items to beginning of collection
  13368. var previousItems = this.items.slice(0);
  13369. this.items = items.concat( previousItems );
  13370. // start new layout
  13371. this._resetLayout();
  13372. this._manageStamps();
  13373. // layout new stuff without transition
  13374. this.layoutItems( items, true );
  13375. this.reveal( items );
  13376. // layout previous items
  13377. this.layoutItems( previousItems );
  13378. };
  13379. /**
  13380. * reveal a collection of items
  13381. * @param {Array of Outlayer.Items} items
  13382. */
  13383. proto.reveal = function( items ) {
  13384. this._emitCompleteOnItems( 'reveal', items );
  13385. if ( !items || !items.length ) {
  13386. return;
  13387. }
  13388. var stagger = this.updateStagger();
  13389. items.forEach( function( item, i ) {
  13390. item.stagger( i * stagger );
  13391. item.reveal();
  13392. });
  13393. };
  13394. /**
  13395. * hide a collection of items
  13396. * @param {Array of Outlayer.Items} items
  13397. */
  13398. proto.hide = function( items ) {
  13399. this._emitCompleteOnItems( 'hide', items );
  13400. if ( !items || !items.length ) {
  13401. return;
  13402. }
  13403. var stagger = this.updateStagger();
  13404. items.forEach( function( item, i ) {
  13405. item.stagger( i * stagger );
  13406. item.hide();
  13407. });
  13408. };
  13409. /**
  13410. * reveal item elements
  13411. * @param {Array}, {Element}, {NodeList} items
  13412. */
  13413. proto.revealItemElements = function( elems ) {
  13414. var items = this.getItems( elems );
  13415. this.reveal( items );
  13416. };
  13417. /**
  13418. * hide item elements
  13419. * @param {Array}, {Element}, {NodeList} items
  13420. */
  13421. proto.hideItemElements = function( elems ) {
  13422. var items = this.getItems( elems );
  13423. this.hide( items );
  13424. };
  13425. /**
  13426. * get Outlayer.Item, given an Element
  13427. * @param {Element} elem
  13428. * @param {Function} callback
  13429. * @returns {Outlayer.Item} item
  13430. */
  13431. proto.getItem = function( elem ) {
  13432. // loop through items to get the one that matches
  13433. for ( var i=0; i < this.items.length; i++ ) {
  13434. var item = this.items[i];
  13435. if ( item.element == elem ) {
  13436. // return item
  13437. return item;
  13438. }
  13439. }
  13440. };
  13441. /**
  13442. * get collection of Outlayer.Items, given Elements
  13443. * @param {Array} elems
  13444. * @returns {Array} items - Outlayer.Items
  13445. */
  13446. proto.getItems = function( elems ) {
  13447. elems = utils.makeArray( elems );
  13448. var items = [];
  13449. elems.forEach( function( elem ) {
  13450. var item = this.getItem( elem );
  13451. if ( item ) {
  13452. items.push( item );
  13453. }
  13454. }, this );
  13455. return items;
  13456. };
  13457. /**
  13458. * remove element(s) from instance and DOM
  13459. * @param {Array or NodeList or Element} elems
  13460. */
  13461. proto.remove = function( elems ) {
  13462. var removeItems = this.getItems( elems );
  13463. this._emitCompleteOnItems( 'remove', removeItems );
  13464. // bail if no items to remove
  13465. if ( !removeItems || !removeItems.length ) {
  13466. return;
  13467. }
  13468. removeItems.forEach( function( item ) {
  13469. item.remove();
  13470. // remove item from collection
  13471. utils.removeFrom( this.items, item );
  13472. }, this );
  13473. };
  13474. // ----- destroy ----- //
  13475. // remove and disable Outlayer instance
  13476. proto.destroy = function() {
  13477. // clean up dynamic styles
  13478. var style = this.element.style;
  13479. style.height = '';
  13480. style.position = '';
  13481. style.width = '';
  13482. // destroy items
  13483. this.items.forEach( function( item ) {
  13484. item.destroy();
  13485. });
  13486. this.unbindResize();
  13487. var id = this.element.outlayerGUID;
  13488. delete instances[ id ]; // remove reference to instance by id
  13489. delete this.element.outlayerGUID;
  13490. // remove data for jQuery
  13491. if ( jQuery ) {
  13492. jQuery.removeData( this.element, this.constructor.namespace );
  13493. }
  13494. };
  13495. // -------------------------- data -------------------------- //
  13496. /**
  13497. * get Outlayer instance from element
  13498. * @param {Element} elem
  13499. * @returns {Outlayer}
  13500. */
  13501. Outlayer.data = function( elem ) {
  13502. elem = utils.getQueryElement( elem );
  13503. var id = elem && elem.outlayerGUID;
  13504. return id && instances[ id ];
  13505. };
  13506. // -------------------------- create Outlayer class -------------------------- //
  13507. /**
  13508. * create a layout class
  13509. * @param {String} namespace
  13510. */
  13511. Outlayer.create = function( namespace, options ) {
  13512. // sub-class Outlayer
  13513. var Layout = subclass( Outlayer );
  13514. // apply new options and compatOptions
  13515. Layout.defaults = utils.extend( {}, Outlayer.defaults );
  13516. utils.extend( Layout.defaults, options );
  13517. Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions );
  13518. Layout.namespace = namespace;
  13519. Layout.data = Outlayer.data;
  13520. // sub-class Item
  13521. Layout.Item = subclass( Item );
  13522. // -------------------------- declarative -------------------------- //
  13523. utils.htmlInit( Layout, namespace );
  13524. // -------------------------- jQuery bridge -------------------------- //
  13525. // make into jQuery plugin
  13526. if ( jQuery && jQuery.bridget ) {
  13527. jQuery.bridget( namespace, Layout );
  13528. }
  13529. return Layout;
  13530. };
  13531. function subclass( Parent ) {
  13532. function SubClass() {
  13533. Parent.apply( this, arguments );
  13534. }
  13535. SubClass.prototype = Object.create( Parent.prototype );
  13536. SubClass.prototype.constructor = SubClass;
  13537. return SubClass;
  13538. }
  13539. // ----- helpers ----- //
  13540. // how many milliseconds are in each unit
  13541. var msUnits = {
  13542. ms: 1,
  13543. s: 1000
  13544. };
  13545. // munge time-like parameter into millisecond number
  13546. // '0.4s' -> 40
  13547. function getMilliseconds( time ) {
  13548. if ( typeof time == 'number' ) {
  13549. return time;
  13550. }
  13551. var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
  13552. var num = matches && matches[1];
  13553. var unit = matches && matches[2];
  13554. if ( !num.length ) {
  13555. return 0;
  13556. }
  13557. num = parseFloat( num );
  13558. var mult = msUnits[ unit ] || 1;
  13559. return num * mult;
  13560. }
  13561. // ----- fin ----- //
  13562. // back in global
  13563. Outlayer.Item = Item;
  13564. return Outlayer;
  13565. }));
  13566. /**
  13567. * Isotope Item
  13568. **/
  13569. ( function( window, factory ) {
  13570. // universal module definition
  13571. /* jshint strict: false */ /*globals define, module, require */
  13572. if ( typeof define == 'function' && define.amd ) {
  13573. // AMD
  13574. define( 'isotope-layout/js/item',[
  13575. 'outlayer/outlayer'
  13576. ],
  13577. factory );
  13578. } else if ( typeof module == 'object' && module.exports ) {
  13579. // CommonJS
  13580. module.exports = factory(
  13581. require('outlayer')
  13582. );
  13583. } else {
  13584. // browser global
  13585. window.Isotope = window.Isotope || {};
  13586. window.Isotope.Item = factory(
  13587. window.Outlayer
  13588. );
  13589. }
  13590. }( window, function factory( Outlayer ) {
  13591. 'use strict';
  13592. // -------------------------- Item -------------------------- //
  13593. // sub-class Outlayer Item
  13594. function Item() {
  13595. Outlayer.Item.apply( this, arguments );
  13596. }
  13597. var proto = Item.prototype = Object.create( Outlayer.Item.prototype );
  13598. var _create = proto._create;
  13599. proto._create = function() {
  13600. // assign id, used for original-order sorting
  13601. this.id = this.layout.itemGUID++;
  13602. _create.call( this );
  13603. this.sortData = {};
  13604. };
  13605. proto.updateSortData = function() {
  13606. if ( this.isIgnored ) {
  13607. return;
  13608. }
  13609. // default sorters
  13610. this.sortData.id = this.id;
  13611. // for backward compatibility
  13612. this.sortData['original-order'] = this.id;
  13613. this.sortData.random = Math.random();
  13614. // go thru getSortData obj and apply the sorters
  13615. var getSortData = this.layout.options.getSortData;
  13616. var sorters = this.layout._sorters;
  13617. for ( var key in getSortData ) {
  13618. var sorter = sorters[ key ];
  13619. this.sortData[ key ] = sorter( this.element, this );
  13620. }
  13621. };
  13622. var _destroy = proto.destroy;
  13623. proto.destroy = function() {
  13624. // call super
  13625. _destroy.apply( this, arguments );
  13626. // reset display, #741
  13627. this.css({
  13628. display: ''
  13629. });
  13630. };
  13631. return Item;
  13632. }));
  13633. /**
  13634. * Isotope LayoutMode
  13635. */
  13636. ( function( window, factory ) {
  13637. // universal module definition
  13638. /* jshint strict: false */ /*globals define, module, require */
  13639. if ( typeof define == 'function' && define.amd ) {
  13640. // AMD
  13641. define( 'isotope-layout/js/layout-mode',[
  13642. 'get-size/get-size',
  13643. 'outlayer/outlayer'
  13644. ],
  13645. factory );
  13646. } else if ( typeof module == 'object' && module.exports ) {
  13647. // CommonJS
  13648. module.exports = factory(
  13649. require('get-size'),
  13650. require('outlayer')
  13651. );
  13652. } else {
  13653. // browser global
  13654. window.Isotope = window.Isotope || {};
  13655. window.Isotope.LayoutMode = factory(
  13656. window.getSize,
  13657. window.Outlayer
  13658. );
  13659. }
  13660. }( window, function factory( getSize, Outlayer ) {
  13661. 'use strict';
  13662. // layout mode class
  13663. function LayoutMode( isotope ) {
  13664. this.isotope = isotope;
  13665. // link properties
  13666. if ( isotope ) {
  13667. this.options = isotope.options[ this.namespace ];
  13668. this.element = isotope.element;
  13669. this.items = isotope.filteredItems;
  13670. this.size = isotope.size;
  13671. }
  13672. }
  13673. var proto = LayoutMode.prototype;
  13674. /**
  13675. * some methods should just defer to default Outlayer method
  13676. * and reference the Isotope instance as `this`
  13677. **/
  13678. var facadeMethods = [
  13679. '_resetLayout',
  13680. '_getItemLayoutPosition',
  13681. '_manageStamp',
  13682. '_getContainerSize',
  13683. '_getElementOffset',
  13684. 'needsResizeLayout',
  13685. '_getOption'
  13686. ];
  13687. facadeMethods.forEach( function( methodName ) {
  13688. proto[ methodName ] = function() {
  13689. return Outlayer.prototype[ methodName ].apply( this.isotope, arguments );
  13690. };
  13691. });
  13692. // ----- ----- //
  13693. // for horizontal layout modes, check vertical size
  13694. proto.needsVerticalResizeLayout = function() {
  13695. // don't trigger if size did not change
  13696. var size = getSize( this.isotope.element );
  13697. // check that this.size and size are there
  13698. // IE8 triggers resize on body size change, so they might not be
  13699. var hasSizes = this.isotope.size && size;
  13700. return hasSizes && size.innerHeight != this.isotope.size.innerHeight;
  13701. };
  13702. // ----- measurements ----- //
  13703. proto._getMeasurement = function() {
  13704. this.isotope._getMeasurement.apply( this, arguments );
  13705. };
  13706. proto.getColumnWidth = function() {
  13707. this.getSegmentSize( 'column', 'Width' );
  13708. };
  13709. proto.getRowHeight = function() {
  13710. this.getSegmentSize( 'row', 'Height' );
  13711. };
  13712. /**
  13713. * get columnWidth or rowHeight
  13714. * segment: 'column' or 'row'
  13715. * size 'Width' or 'Height'
  13716. **/
  13717. proto.getSegmentSize = function( segment, size ) {
  13718. var segmentName = segment + size;
  13719. var outerSize = 'outer' + size;
  13720. // columnWidth / outerWidth // rowHeight / outerHeight
  13721. this._getMeasurement( segmentName, outerSize );
  13722. // got rowHeight or columnWidth, we can chill
  13723. if ( this[ segmentName ] ) {
  13724. return;
  13725. }
  13726. // fall back to item of first element
  13727. var firstItemSize = this.getFirstItemSize();
  13728. this[ segmentName ] = firstItemSize && firstItemSize[ outerSize ] ||
  13729. // or size of container
  13730. this.isotope.size[ 'inner' + size ];
  13731. };
  13732. proto.getFirstItemSize = function() {
  13733. var firstItem = this.isotope.filteredItems[0];
  13734. return firstItem && firstItem.element && getSize( firstItem.element );
  13735. };
  13736. // ----- methods that should reference isotope ----- //
  13737. proto.layout = function() {
  13738. this.isotope.layout.apply( this.isotope, arguments );
  13739. };
  13740. proto.getSize = function() {
  13741. this.isotope.getSize();
  13742. this.size = this.isotope.size;
  13743. };
  13744. // -------------------------- create -------------------------- //
  13745. LayoutMode.modes = {};
  13746. LayoutMode.create = function( namespace, options ) {
  13747. function Mode() {
  13748. LayoutMode.apply( this, arguments );
  13749. }
  13750. Mode.prototype = Object.create( proto );
  13751. Mode.prototype.constructor = Mode;
  13752. // default options
  13753. if ( options ) {
  13754. Mode.options = options;
  13755. }
  13756. Mode.prototype.namespace = namespace;
  13757. // register in Isotope
  13758. LayoutMode.modes[ namespace ] = Mode;
  13759. return Mode;
  13760. };
  13761. return LayoutMode;
  13762. }));
  13763. /*!
  13764. * Masonry v4.2.1
  13765. * Cascading grid layout library
  13766. * https://masonry.desandro.com
  13767. * MIT License
  13768. * by David DeSandro
  13769. */
  13770. ( function( window, factory ) {
  13771. // universal module definition
  13772. /* jshint strict: false */ /*globals define, module, require */
  13773. if ( typeof define == 'function' && define.amd ) {
  13774. // AMD
  13775. define( 'masonry-layout/masonry',[
  13776. 'outlayer/outlayer',
  13777. 'get-size/get-size'
  13778. ],
  13779. factory );
  13780. } else if ( typeof module == 'object' && module.exports ) {
  13781. // CommonJS
  13782. module.exports = factory(
  13783. require('outlayer'),
  13784. require('get-size')
  13785. );
  13786. } else {
  13787. // browser global
  13788. window.Masonry = factory(
  13789. window.Outlayer,
  13790. window.getSize
  13791. );
  13792. }
  13793. }( window, function factory( Outlayer, getSize ) {
  13794. // -------------------------- masonryDefinition -------------------------- //
  13795. // create an Outlayer layout class
  13796. var Masonry = Outlayer.create('masonry');
  13797. // isFitWidth -> fitWidth
  13798. Masonry.compatOptions.fitWidth = 'isFitWidth';
  13799. var proto = Masonry.prototype;
  13800. proto._resetLayout = function() {
  13801. this.getSize();
  13802. this._getMeasurement( 'columnWidth', 'outerWidth' );
  13803. this._getMeasurement( 'gutter', 'outerWidth' );
  13804. this.measureColumns();
  13805. // reset column Y
  13806. this.colYs = [];
  13807. for ( var i=0; i < this.cols; i++ ) {
  13808. this.colYs.push( 0 );
  13809. }
  13810. this.maxY = 0;
  13811. this.horizontalColIndex = 0;
  13812. };
  13813. proto.measureColumns = function() {
  13814. this.getContainerWidth();
  13815. // if columnWidth is 0, default to outerWidth of first item
  13816. if ( !this.columnWidth ) {
  13817. var firstItem = this.items[0];
  13818. var firstItemElem = firstItem && firstItem.element;
  13819. // columnWidth fall back to item of first element
  13820. this.columnWidth = firstItemElem && getSize( firstItemElem ).outerWidth ||
  13821. // if first elem has no width, default to size of container
  13822. this.containerWidth;
  13823. }
  13824. var columnWidth = this.columnWidth += this.gutter;
  13825. // calculate columns
  13826. var containerWidth = this.containerWidth + this.gutter;
  13827. var cols = containerWidth / columnWidth;
  13828. // fix rounding errors, typically with gutters
  13829. var excess = columnWidth - containerWidth % columnWidth;
  13830. // if overshoot is less than a pixel, round up, otherwise floor it
  13831. var mathMethod = excess && excess < 1 ? 'round' : 'floor';
  13832. cols = Math[ mathMethod ]( cols );
  13833. this.cols = Math.max( cols, 1 );
  13834. };
  13835. proto.getContainerWidth = function() {
  13836. // container is parent if fit width
  13837. var isFitWidth = this._getOption('fitWidth');
  13838. var container = isFitWidth ? this.element.parentNode : this.element;
  13839. // check that this.size and size are there
  13840. // IE8 triggers resize on body size change, so they might not be
  13841. var size = getSize( container );
  13842. this.containerWidth = size && size.innerWidth;
  13843. };
  13844. proto._getItemLayoutPosition = function( item ) {
  13845. item.getSize();
  13846. // how many columns does this brick span
  13847. var remainder = item.size.outerWidth % this.columnWidth;
  13848. var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
  13849. // round if off by 1 pixel, otherwise use ceil
  13850. var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
  13851. colSpan = Math.min( colSpan, this.cols );
  13852. // use horizontal or top column position
  13853. var colPosMethod = this.options.horizontalOrder ?
  13854. '_getHorizontalColPosition' : '_getTopColPosition';
  13855. var colPosition = this[ colPosMethod ]( colSpan, item );
  13856. // position the brick
  13857. var position = {
  13858. x: this.columnWidth * colPosition.col,
  13859. y: colPosition.y
  13860. };
  13861. // apply setHeight to necessary columns
  13862. var setHeight = colPosition.y + item.size.outerHeight;
  13863. var setMax = colSpan + colPosition.col;
  13864. for ( var i = colPosition.col; i < setMax; i++ ) {
  13865. this.colYs[i] = setHeight;
  13866. }
  13867. return position;
  13868. };
  13869. proto._getTopColPosition = function( colSpan ) {
  13870. var colGroup = this._getTopColGroup( colSpan );
  13871. // get the minimum Y value from the columns
  13872. var minimumY = Math.min.apply( Math, colGroup );
  13873. return {
  13874. col: colGroup.indexOf( minimumY ),
  13875. y: minimumY,
  13876. };
  13877. };
  13878. /**
  13879. * @param {Number} colSpan - number of columns the element spans
  13880. * @returns {Array} colGroup
  13881. */
  13882. proto._getTopColGroup = function( colSpan ) {
  13883. if ( colSpan < 2 ) {
  13884. // if brick spans only one column, use all the column Ys
  13885. return this.colYs;
  13886. }
  13887. var colGroup = [];
  13888. // how many different places could this brick fit horizontally
  13889. var groupCount = this.cols + 1 - colSpan;
  13890. // for each group potential horizontal position
  13891. for ( var i = 0; i < groupCount; i++ ) {
  13892. colGroup[i] = this._getColGroupY( i, colSpan );
  13893. }
  13894. return colGroup;
  13895. };
  13896. proto._getColGroupY = function( col, colSpan ) {
  13897. if ( colSpan < 2 ) {
  13898. return this.colYs[ col ];
  13899. }
  13900. // make an array of colY values for that one group
  13901. var groupColYs = this.colYs.slice( col, col + colSpan );
  13902. // and get the max value of the array
  13903. return Math.max.apply( Math, groupColYs );
  13904. };
  13905. // get column position based on horizontal index. #873
  13906. proto._getHorizontalColPosition = function( colSpan, item ) {
  13907. var col = this.horizontalColIndex % this.cols;
  13908. var isOver = colSpan > 1 && col + colSpan > this.cols;
  13909. // shift to next row if item can't fit on current row
  13910. col = isOver ? 0 : col;
  13911. // don't let zero-size items take up space
  13912. var hasSize = item.size.outerWidth && item.size.outerHeight;
  13913. this.horizontalColIndex = hasSize ? col + colSpan : this.horizontalColIndex;
  13914. return {
  13915. col: col,
  13916. y: this._getColGroupY( col, colSpan ),
  13917. };
  13918. };
  13919. proto._manageStamp = function( stamp ) {
  13920. var stampSize = getSize( stamp );
  13921. var offset = this._getElementOffset( stamp );
  13922. // get the columns that this stamp affects
  13923. var isOriginLeft = this._getOption('originLeft');
  13924. var firstX = isOriginLeft ? offset.left : offset.right;
  13925. var lastX = firstX + stampSize.outerWidth;
  13926. var firstCol = Math.floor( firstX / this.columnWidth );
  13927. firstCol = Math.max( 0, firstCol );
  13928. var lastCol = Math.floor( lastX / this.columnWidth );
  13929. // lastCol should not go over if multiple of columnWidth #425
  13930. lastCol -= lastX % this.columnWidth ? 0 : 1;
  13931. lastCol = Math.min( this.cols - 1, lastCol );
  13932. // set colYs to bottom of the stamp
  13933. var isOriginTop = this._getOption('originTop');
  13934. var stampMaxY = ( isOriginTop ? offset.top : offset.bottom ) +
  13935. stampSize.outerHeight;
  13936. for ( var i = firstCol; i <= lastCol; i++ ) {
  13937. this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
  13938. }
  13939. };
  13940. proto._getContainerSize = function() {
  13941. this.maxY = Math.max.apply( Math, this.colYs );
  13942. var size = {
  13943. height: this.maxY
  13944. };
  13945. if ( this._getOption('fitWidth') ) {
  13946. size.width = this._getContainerFitWidth();
  13947. }
  13948. return size;
  13949. };
  13950. proto._getContainerFitWidth = function() {
  13951. var unusedCols = 0;
  13952. // count unused columns
  13953. var i = this.cols;
  13954. while ( --i ) {
  13955. if ( this.colYs[i] !== 0 ) {
  13956. break;
  13957. }
  13958. unusedCols++;
  13959. }
  13960. // fit container to columns that have been used
  13961. return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
  13962. };
  13963. proto.needsResizeLayout = function() {
  13964. var previousWidth = this.containerWidth;
  13965. this.getContainerWidth();
  13966. return previousWidth != this.containerWidth;
  13967. };
  13968. return Masonry;
  13969. }));
  13970. /*!
  13971. * Masonry layout mode
  13972. * sub-classes Masonry
  13973. * https://masonry.desandro.com
  13974. */
  13975. ( function( window, factory ) {
  13976. // universal module definition
  13977. /* jshint strict: false */ /*globals define, module, require */
  13978. if ( typeof define == 'function' && define.amd ) {
  13979. // AMD
  13980. define( 'isotope-layout/js/layout-modes/masonry',[
  13981. '../layout-mode',
  13982. 'masonry-layout/masonry'
  13983. ],
  13984. factory );
  13985. } else if ( typeof module == 'object' && module.exports ) {
  13986. // CommonJS
  13987. module.exports = factory(
  13988. require('../layout-mode'),
  13989. require('masonry-layout')
  13990. );
  13991. } else {
  13992. // browser global
  13993. factory(
  13994. window.Isotope.LayoutMode,
  13995. window.Masonry
  13996. );
  13997. }
  13998. }( window, function factory( LayoutMode, Masonry ) {
  13999. 'use strict';
  14000. // -------------------------- masonryDefinition -------------------------- //
  14001. // create an Outlayer layout class
  14002. var MasonryMode = LayoutMode.create('masonry');
  14003. var proto = MasonryMode.prototype;
  14004. var keepModeMethods = {
  14005. _getElementOffset: true,
  14006. layout: true,
  14007. _getMeasurement: true
  14008. };
  14009. // inherit Masonry prototype
  14010. for ( var method in Masonry.prototype ) {
  14011. // do not inherit mode methods
  14012. if ( !keepModeMethods[ method ] ) {
  14013. proto[ method ] = Masonry.prototype[ method ];
  14014. }
  14015. }
  14016. var measureColumns = proto.measureColumns;
  14017. proto.measureColumns = function() {
  14018. // set items, used if measuring first item
  14019. this.items = this.isotope.filteredItems;
  14020. measureColumns.call( this );
  14021. };
  14022. // point to mode options for fitWidth
  14023. var _getOption = proto._getOption;
  14024. proto._getOption = function( option ) {
  14025. if ( option == 'fitWidth' ) {
  14026. return this.options.isFitWidth !== undefined ?
  14027. this.options.isFitWidth : this.options.fitWidth;
  14028. }
  14029. return _getOption.apply( this.isotope, arguments );
  14030. };
  14031. return MasonryMode;
  14032. }));
  14033. /**
  14034. * fitRows layout mode
  14035. */
  14036. ( function( window, factory ) {
  14037. // universal module definition
  14038. /* jshint strict: false */ /*globals define, module, require */
  14039. if ( typeof define == 'function' && define.amd ) {
  14040. // AMD
  14041. define( 'isotope-layout/js/layout-modes/fit-rows',[
  14042. '../layout-mode'
  14043. ],
  14044. factory );
  14045. } else if ( typeof exports == 'object' ) {
  14046. // CommonJS
  14047. module.exports = factory(
  14048. require('../layout-mode')
  14049. );
  14050. } else {
  14051. // browser global
  14052. factory(
  14053. window.Isotope.LayoutMode
  14054. );
  14055. }
  14056. }( window, function factory( LayoutMode ) {
  14057. 'use strict';
  14058. var FitRows = LayoutMode.create('fitRows');
  14059. var proto = FitRows.prototype;
  14060. proto._resetLayout = function() {
  14061. this.x = 0;
  14062. this.y = 0;
  14063. this.maxY = 0;
  14064. this._getMeasurement( 'gutter', 'outerWidth' );
  14065. };
  14066. proto._getItemLayoutPosition = function( item ) {
  14067. item.getSize();
  14068. var itemWidth = item.size.outerWidth + this.gutter;
  14069. // if this element cannot fit in the current row
  14070. var containerWidth = this.isotope.size.innerWidth + this.gutter;
  14071. if ( this.x !== 0 && itemWidth + this.x > containerWidth ) {
  14072. this.x = 0;
  14073. this.y = this.maxY;
  14074. }
  14075. var position = {
  14076. x: this.x,
  14077. y: this.y
  14078. };
  14079. this.maxY = Math.max( this.maxY, this.y + item.size.outerHeight );
  14080. this.x += itemWidth;
  14081. return position;
  14082. };
  14083. proto._getContainerSize = function() {
  14084. return { height: this.maxY };
  14085. };
  14086. return FitRows;
  14087. }));
  14088. /**
  14089. * vertical layout mode
  14090. */
  14091. ( function( window, factory ) {
  14092. // universal module definition
  14093. /* jshint strict: false */ /*globals define, module, require */
  14094. if ( typeof define == 'function' && define.amd ) {
  14095. // AMD
  14096. define( 'isotope-layout/js/layout-modes/vertical',[
  14097. '../layout-mode'
  14098. ],
  14099. factory );
  14100. } else if ( typeof module == 'object' && module.exports ) {
  14101. // CommonJS
  14102. module.exports = factory(
  14103. require('../layout-mode')
  14104. );
  14105. } else {
  14106. // browser global
  14107. factory(
  14108. window.Isotope.LayoutMode
  14109. );
  14110. }
  14111. }( window, function factory( LayoutMode ) {
  14112. 'use strict';
  14113. var Vertical = LayoutMode.create( 'vertical', {
  14114. horizontalAlignment: 0
  14115. });
  14116. var proto = Vertical.prototype;
  14117. proto._resetLayout = function() {
  14118. this.y = 0;
  14119. };
  14120. proto._getItemLayoutPosition = function( item ) {
  14121. item.getSize();
  14122. var x = ( this.isotope.size.innerWidth - item.size.outerWidth ) *
  14123. this.options.horizontalAlignment;
  14124. var y = this.y;
  14125. this.y += item.size.outerHeight;
  14126. return { x: x, y: y };
  14127. };
  14128. proto._getContainerSize = function() {
  14129. return { height: this.y };
  14130. };
  14131. return Vertical;
  14132. }));
  14133. /*!
  14134. * Isotope v3.0.6
  14135. *
  14136. * Licensed GPLv3 for open source use
  14137. * or Isotope Commercial License for commercial use
  14138. *
  14139. * https://isotope.metafizzy.co
  14140. * Copyright 2010-2018 Metafizzy
  14141. */
  14142. ( function( window, factory ) {
  14143. // universal module definition
  14144. /* jshint strict: false */ /*globals define, module, require */
  14145. if ( typeof define == 'function' && define.amd ) {
  14146. // AMD
  14147. define( [
  14148. 'outlayer/outlayer',
  14149. 'get-size/get-size',
  14150. 'desandro-matches-selector/matches-selector',
  14151. 'fizzy-ui-utils/utils',
  14152. 'isotope-layout/js/item',
  14153. 'isotope-layout/js/layout-mode',
  14154. // include default layout modes
  14155. 'isotope-layout/js/layout-modes/masonry',
  14156. 'isotope-layout/js/layout-modes/fit-rows',
  14157. 'isotope-layout/js/layout-modes/vertical'
  14158. ],
  14159. function( Outlayer, getSize, matchesSelector, utils, Item, LayoutMode ) {
  14160. return factory( window, Outlayer, getSize, matchesSelector, utils, Item, LayoutMode );
  14161. });
  14162. } else if ( typeof module == 'object' && module.exports ) {
  14163. // CommonJS
  14164. module.exports = factory(
  14165. window,
  14166. require('outlayer'),
  14167. require('get-size'),
  14168. require('desandro-matches-selector'),
  14169. require('fizzy-ui-utils'),
  14170. require('isotope-layout/js/item'),
  14171. require('isotope-layout/js/layout-mode'),
  14172. // include default layout modes
  14173. require('isotope-layout/js/layout-modes/masonry'),
  14174. require('isotope-layout/js/layout-modes/fit-rows'),
  14175. require('isotope-layout/js/layout-modes/vertical')
  14176. );
  14177. } else {
  14178. // browser global
  14179. window.Isotope = factory(
  14180. window,
  14181. window.Outlayer,
  14182. window.getSize,
  14183. window.matchesSelector,
  14184. window.fizzyUIUtils,
  14185. window.Isotope.Item,
  14186. window.Isotope.LayoutMode
  14187. );
  14188. }
  14189. }( window, function factory( window, Outlayer, getSize, matchesSelector, utils,
  14190. Item, LayoutMode ) {
  14191. // -------------------------- vars -------------------------- //
  14192. var jQuery = window.jQuery;
  14193. // -------------------------- helpers -------------------------- //
  14194. var trim = String.prototype.trim ?
  14195. function( str ) {
  14196. return str.trim();
  14197. } :
  14198. function( str ) {
  14199. return str.replace( /^\s+|\s+$/g, '' );
  14200. };
  14201. // -------------------------- isotopeDefinition -------------------------- //
  14202. // create an Outlayer layout class
  14203. var Isotope = Outlayer.create( 'isotope', {
  14204. layoutMode: 'masonry',
  14205. isJQueryFiltering: true,
  14206. sortAscending: true
  14207. });
  14208. Isotope.Item = Item;
  14209. Isotope.LayoutMode = LayoutMode;
  14210. var proto = Isotope.prototype;
  14211. proto._create = function() {
  14212. this.itemGUID = 0;
  14213. // functions that sort items
  14214. this._sorters = {};
  14215. this._getSorters();
  14216. // call super
  14217. Outlayer.prototype._create.call( this );
  14218. // create layout modes
  14219. this.modes = {};
  14220. // start filteredItems with all items
  14221. this.filteredItems = this.items;
  14222. // keep of track of sortBys
  14223. this.sortHistory = [ 'original-order' ];
  14224. // create from registered layout modes
  14225. for ( var name in LayoutMode.modes ) {
  14226. this._initLayoutMode( name );
  14227. }
  14228. };
  14229. proto.reloadItems = function() {
  14230. // reset item ID counter
  14231. this.itemGUID = 0;
  14232. // call super
  14233. Outlayer.prototype.reloadItems.call( this );
  14234. };
  14235. proto._itemize = function() {
  14236. var items = Outlayer.prototype._itemize.apply( this, arguments );
  14237. // assign ID for original-order
  14238. for ( var i=0; i < items.length; i++ ) {
  14239. var item = items[i];
  14240. item.id = this.itemGUID++;
  14241. }
  14242. this._updateItemsSortData( items );
  14243. return items;
  14244. };
  14245. // -------------------------- layout -------------------------- //
  14246. proto._initLayoutMode = function( name ) {
  14247. var Mode = LayoutMode.modes[ name ];
  14248. // set mode options
  14249. // HACK extend initial options, back-fill in default options
  14250. var initialOpts = this.options[ name ] || {};
  14251. this.options[ name ] = Mode.options ?
  14252. utils.extend( Mode.options, initialOpts ) : initialOpts;
  14253. // init layout mode instance
  14254. this.modes[ name ] = new Mode( this );
  14255. };
  14256. proto.layout = function() {
  14257. // if first time doing layout, do all magic
  14258. if ( !this._isLayoutInited && this._getOption('initLayout') ) {
  14259. this.arrange();
  14260. return;
  14261. }
  14262. this._layout();
  14263. };
  14264. // private method to be used in layout() & magic()
  14265. proto._layout = function() {
  14266. // don't animate first layout
  14267. var isInstant = this._getIsInstant();
  14268. // layout flow
  14269. this._resetLayout();
  14270. this._manageStamps();
  14271. this.layoutItems( this.filteredItems, isInstant );
  14272. // flag for initalized
  14273. this._isLayoutInited = true;
  14274. };
  14275. // filter + sort + layout
  14276. proto.arrange = function( opts ) {
  14277. // set any options pass
  14278. this.option( opts );
  14279. this._getIsInstant();
  14280. // filter, sort, and layout
  14281. // filter
  14282. var filtered = this._filter( this.items );
  14283. this.filteredItems = filtered.matches;
  14284. this._bindArrangeComplete();
  14285. if ( this._isInstant ) {
  14286. this._noTransition( this._hideReveal, [ filtered ] );
  14287. } else {
  14288. this._hideReveal( filtered );
  14289. }
  14290. this._sort();
  14291. this._layout();
  14292. };
  14293. // alias to _init for main plugin method
  14294. proto._init = proto.arrange;
  14295. proto._hideReveal = function( filtered ) {
  14296. this.reveal( filtered.needReveal );
  14297. this.hide( filtered.needHide );
  14298. };
  14299. // HACK
  14300. // Don't animate/transition first layout
  14301. // Or don't animate/transition other layouts
  14302. proto._getIsInstant = function() {
  14303. var isLayoutInstant = this._getOption('layoutInstant');
  14304. var isInstant = isLayoutInstant !== undefined ? isLayoutInstant :
  14305. !this._isLayoutInited;
  14306. this._isInstant = isInstant;
  14307. return isInstant;
  14308. };
  14309. // listen for layoutComplete, hideComplete and revealComplete
  14310. // to trigger arrangeComplete
  14311. proto._bindArrangeComplete = function() {
  14312. // listen for 3 events to trigger arrangeComplete
  14313. var isLayoutComplete, isHideComplete, isRevealComplete;
  14314. var _this = this;
  14315. function arrangeParallelCallback() {
  14316. if ( isLayoutComplete && isHideComplete && isRevealComplete ) {
  14317. _this.dispatchEvent( 'arrangeComplete', null, [ _this.filteredItems ] );
  14318. }
  14319. }
  14320. this.once( 'layoutComplete', function() {
  14321. isLayoutComplete = true;
  14322. arrangeParallelCallback();
  14323. });
  14324. this.once( 'hideComplete', function() {
  14325. isHideComplete = true;
  14326. arrangeParallelCallback();
  14327. });
  14328. this.once( 'revealComplete', function() {
  14329. isRevealComplete = true;
  14330. arrangeParallelCallback();
  14331. });
  14332. };
  14333. // -------------------------- filter -------------------------- //
  14334. proto._filter = function( items ) {
  14335. var filter = this.options.filter;
  14336. filter = filter || '*';
  14337. var matches = [];
  14338. var hiddenMatched = [];
  14339. var visibleUnmatched = [];
  14340. var test = this._getFilterTest( filter );
  14341. // test each item
  14342. for ( var i=0; i < items.length; i++ ) {
  14343. var item = items[i];
  14344. if ( item.isIgnored ) {
  14345. continue;
  14346. }
  14347. // add item to either matched or unmatched group
  14348. var isMatched = test( item );
  14349. // item.isFilterMatched = isMatched;
  14350. // add to matches if its a match
  14351. if ( isMatched ) {
  14352. matches.push( item );
  14353. }
  14354. // add to additional group if item needs to be hidden or revealed
  14355. if ( isMatched && item.isHidden ) {
  14356. hiddenMatched.push( item );
  14357. } else if ( !isMatched && !item.isHidden ) {
  14358. visibleUnmatched.push( item );
  14359. }
  14360. }
  14361. // return collections of items to be manipulated
  14362. return {
  14363. matches: matches,
  14364. needReveal: hiddenMatched,
  14365. needHide: visibleUnmatched
  14366. };
  14367. };
  14368. // get a jQuery, function, or a matchesSelector test given the filter
  14369. proto._getFilterTest = function( filter ) {
  14370. if ( jQuery && this.options.isJQueryFiltering ) {
  14371. // use jQuery
  14372. return function( item ) {
  14373. return jQuery( item.element ).is( filter );
  14374. };
  14375. }
  14376. if ( typeof filter == 'function' ) {
  14377. // use filter as function
  14378. return function( item ) {
  14379. return filter( item.element );
  14380. };
  14381. }
  14382. // default, use filter as selector string
  14383. return function( item ) {
  14384. return matchesSelector( item.element, filter );
  14385. };
  14386. };
  14387. // -------------------------- sorting -------------------------- //
  14388. /**
  14389. * @params {Array} elems
  14390. * @public
  14391. */
  14392. proto.updateSortData = function( elems ) {
  14393. // get items
  14394. var items;
  14395. if ( elems ) {
  14396. elems = utils.makeArray( elems );
  14397. items = this.getItems( elems );
  14398. } else {
  14399. // update all items if no elems provided
  14400. items = this.items;
  14401. }
  14402. this._getSorters();
  14403. this._updateItemsSortData( items );
  14404. };
  14405. proto._getSorters = function() {
  14406. var getSortData = this.options.getSortData;
  14407. for ( var key in getSortData ) {
  14408. var sorter = getSortData[ key ];
  14409. this._sorters[ key ] = mungeSorter( sorter );
  14410. }
  14411. };
  14412. /**
  14413. * @params {Array} items - of Isotope.Items
  14414. * @private
  14415. */
  14416. proto._updateItemsSortData = function( items ) {
  14417. // do not update if no items
  14418. var len = items && items.length;
  14419. for ( var i=0; len && i < len; i++ ) {
  14420. var item = items[i];
  14421. item.updateSortData();
  14422. }
  14423. };
  14424. // ----- munge sorter ----- //
  14425. // encapsulate this, as we just need mungeSorter
  14426. // other functions in here are just for munging
  14427. var mungeSorter = ( function() {
  14428. // add a magic layer to sorters for convienent shorthands
  14429. // `.foo-bar` will use the text of .foo-bar querySelector
  14430. // `[foo-bar]` will use attribute
  14431. // you can also add parser
  14432. // `.foo-bar parseInt` will parse that as a number
  14433. function mungeSorter( sorter ) {
  14434. // if not a string, return function or whatever it is
  14435. if ( typeof sorter != 'string' ) {
  14436. return sorter;
  14437. }
  14438. // parse the sorter string
  14439. var args = trim( sorter ).split(' ');
  14440. var query = args[0];
  14441. // check if query looks like [an-attribute]
  14442. var attrMatch = query.match( /^\[(.+)\]$/ );
  14443. var attr = attrMatch && attrMatch[1];
  14444. var getValue = getValueGetter( attr, query );
  14445. // use second argument as a parser
  14446. var parser = Isotope.sortDataParsers[ args[1] ];
  14447. // parse the value, if there was a parser
  14448. sorter = parser ? function( elem ) {
  14449. return elem && parser( getValue( elem ) );
  14450. } :
  14451. // otherwise just return value
  14452. function( elem ) {
  14453. return elem && getValue( elem );
  14454. };
  14455. return sorter;
  14456. }
  14457. // get an attribute getter, or get text of the querySelector
  14458. function getValueGetter( attr, query ) {
  14459. // if query looks like [foo-bar], get attribute
  14460. if ( attr ) {
  14461. return function getAttribute( elem ) {
  14462. return elem.getAttribute( attr );
  14463. };
  14464. }
  14465. // otherwise, assume its a querySelector, and get its text
  14466. return function getChildText( elem ) {
  14467. var child = elem.querySelector( query );
  14468. return child && child.textContent;
  14469. };
  14470. }
  14471. return mungeSorter;
  14472. })();
  14473. // parsers used in getSortData shortcut strings
  14474. Isotope.sortDataParsers = {
  14475. 'parseInt': function( val ) {
  14476. return parseInt( val, 10 );
  14477. },
  14478. 'parseFloat': function( val ) {
  14479. return parseFloat( val );
  14480. }
  14481. };
  14482. // ----- sort method ----- //
  14483. // sort filteredItem order
  14484. proto._sort = function() {
  14485. if ( !this.options.sortBy ) {
  14486. return;
  14487. }
  14488. // keep track of sortBy History
  14489. var sortBys = utils.makeArray( this.options.sortBy );
  14490. if ( !this._getIsSameSortBy( sortBys ) ) {
  14491. // concat all sortBy and sortHistory, add to front, oldest goes in last
  14492. this.sortHistory = sortBys.concat( this.sortHistory );
  14493. }
  14494. // sort magic
  14495. var itemSorter = getItemSorter( this.sortHistory, this.options.sortAscending );
  14496. this.filteredItems.sort( itemSorter );
  14497. };
  14498. // check if sortBys is same as start of sortHistory
  14499. proto._getIsSameSortBy = function( sortBys ) {
  14500. for ( var i=0; i < sortBys.length; i++ ) {
  14501. if ( sortBys[i] != this.sortHistory[i] ) {
  14502. return false;
  14503. }
  14504. }
  14505. return true;
  14506. };
  14507. // returns a function used for sorting
  14508. function getItemSorter( sortBys, sortAsc ) {
  14509. return function sorter( itemA, itemB ) {
  14510. // cycle through all sortKeys
  14511. for ( var i = 0; i < sortBys.length; i++ ) {
  14512. var sortBy = sortBys[i];
  14513. var a = itemA.sortData[ sortBy ];
  14514. var b = itemB.sortData[ sortBy ];
  14515. if ( a > b || a < b ) {
  14516. // if sortAsc is an object, use the value given the sortBy key
  14517. var isAscending = sortAsc[ sortBy ] !== undefined ? sortAsc[ sortBy ] : sortAsc;
  14518. var direction = isAscending ? 1 : -1;
  14519. return ( a > b ? 1 : -1 ) * direction;
  14520. }
  14521. }
  14522. return 0;
  14523. };
  14524. }
  14525. // -------------------------- methods -------------------------- //
  14526. // get layout mode
  14527. proto._mode = function() {
  14528. var layoutMode = this.options.layoutMode;
  14529. var mode = this.modes[ layoutMode ];
  14530. if ( !mode ) {
  14531. // TODO console.error
  14532. throw new Error( 'No layout mode: ' + layoutMode );
  14533. }
  14534. // HACK sync mode's options
  14535. // any options set after init for layout mode need to be synced
  14536. mode.options = this.options[ layoutMode ];
  14537. return mode;
  14538. };
  14539. proto._resetLayout = function() {
  14540. // trigger original reset layout
  14541. Outlayer.prototype._resetLayout.call( this );
  14542. this._mode()._resetLayout();
  14543. };
  14544. proto._getItemLayoutPosition = function( item ) {
  14545. return this._mode()._getItemLayoutPosition( item );
  14546. };
  14547. proto._manageStamp = function( stamp ) {
  14548. this._mode()._manageStamp( stamp );
  14549. };
  14550. proto._getContainerSize = function() {
  14551. return this._mode()._getContainerSize();
  14552. };
  14553. proto.needsResizeLayout = function() {
  14554. return this._mode().needsResizeLayout();
  14555. };
  14556. // -------------------------- adding & removing -------------------------- //
  14557. // HEADS UP overwrites default Outlayer appended
  14558. proto.appended = function( elems ) {
  14559. var items = this.addItems( elems );
  14560. if ( !items.length ) {
  14561. return;
  14562. }
  14563. // filter, layout, reveal new items
  14564. var filteredItems = this._filterRevealAdded( items );
  14565. // add to filteredItems
  14566. this.filteredItems = this.filteredItems.concat( filteredItems );
  14567. };
  14568. // HEADS UP overwrites default Outlayer prepended
  14569. proto.prepended = function( elems ) {
  14570. var items = this._itemize( elems );
  14571. if ( !items.length ) {
  14572. return;
  14573. }
  14574. // start new layout
  14575. this._resetLayout();
  14576. this._manageStamps();
  14577. // filter, layout, reveal new items
  14578. var filteredItems = this._filterRevealAdded( items );
  14579. // layout previous items
  14580. this.layoutItems( this.filteredItems );
  14581. // add to items and filteredItems
  14582. this.filteredItems = filteredItems.concat( this.filteredItems );
  14583. this.items = items.concat( this.items );
  14584. };
  14585. proto._filterRevealAdded = function( items ) {
  14586. var filtered = this._filter( items );
  14587. this.hide( filtered.needHide );
  14588. // reveal all new items
  14589. this.reveal( filtered.matches );
  14590. // layout new items, no transition
  14591. this.layoutItems( filtered.matches, true );
  14592. return filtered.matches;
  14593. };
  14594. /**
  14595. * Filter, sort, and layout newly-appended item elements
  14596. * @param {Array or NodeList or Element} elems
  14597. */
  14598. proto.insert = function( elems ) {
  14599. var items = this.addItems( elems );
  14600. if ( !items.length ) {
  14601. return;
  14602. }
  14603. // append item elements
  14604. var i, item;
  14605. var len = items.length;
  14606. for ( i=0; i < len; i++ ) {
  14607. item = items[i];
  14608. this.element.appendChild( item.element );
  14609. }
  14610. // filter new stuff
  14611. var filteredInsertItems = this._filter( items ).matches;
  14612. // set flag
  14613. for ( i=0; i < len; i++ ) {
  14614. items[i].isLayoutInstant = true;
  14615. }
  14616. this.arrange();
  14617. // reset flag
  14618. for ( i=0; i < len; i++ ) {
  14619. delete items[i].isLayoutInstant;
  14620. }
  14621. this.reveal( filteredInsertItems );
  14622. };
  14623. var _remove = proto.remove;
  14624. proto.remove = function( elems ) {
  14625. elems = utils.makeArray( elems );
  14626. var removeItems = this.getItems( elems );
  14627. // do regular thing
  14628. _remove.call( this, elems );
  14629. // bail if no items to remove
  14630. var len = removeItems && removeItems.length;
  14631. // remove elems from filteredItems
  14632. for ( var i=0; len && i < len; i++ ) {
  14633. var item = removeItems[i];
  14634. // remove item from collection
  14635. utils.removeFrom( this.filteredItems, item );
  14636. }
  14637. };
  14638. proto.shuffle = function() {
  14639. // update random sortData
  14640. for ( var i=0; i < this.items.length; i++ ) {
  14641. var item = this.items[i];
  14642. item.sortData.random = Math.random();
  14643. }
  14644. this.options.sortBy = 'random';
  14645. this._sort();
  14646. this._layout();
  14647. };
  14648. /**
  14649. * trigger fn without transition
  14650. * kind of hacky to have this in the first place
  14651. * @param {Function} fn
  14652. * @param {Array} args
  14653. * @returns ret
  14654. * @private
  14655. */
  14656. proto._noTransition = function( fn, args ) {
  14657. // save transitionDuration before disabling
  14658. var transitionDuration = this.options.transitionDuration;
  14659. // disable transition
  14660. this.options.transitionDuration = 0;
  14661. // do it
  14662. var returnValue = fn.apply( this, args );
  14663. // re-enable transition for reveal
  14664. this.options.transitionDuration = transitionDuration;
  14665. return returnValue;
  14666. };
  14667. // ----- helper methods ----- //
  14668. /**
  14669. * getter method for getting filtered item elements
  14670. * @returns {Array} elems - collection of item elements
  14671. */
  14672. proto.getFilteredItemElements = function() {
  14673. return this.filteredItems.map( function( item ) {
  14674. return item.element;
  14675. });
  14676. };
  14677. // ----- ----- //
  14678. return Isotope;
  14679. }));
  14680. /*!
  14681. jQuery Cookie Plugin
  14682. Version: v1.4.1
  14683. Plugin URL: https://github.com/carhartl/jquery-cookie
  14684. License: Copyright 2006, 2014 Klaus Hartl | Released under the MIT license
  14685. !*/
  14686. (function (factory) {
  14687. if (typeof define === 'function' && define.amd) {
  14688. // AMD (Register as an anonymous module)
  14689. define(['jquery'], factory);
  14690. } else if (typeof exports === 'object') {
  14691. // Node/CommonJS
  14692. module.exports = factory(require('jquery'));
  14693. } else {
  14694. // Browser globals
  14695. factory(jQuery);
  14696. }
  14697. }(function ($) {
  14698. var pluses = /\+/g;
  14699. function encode(s) {
  14700. return config.raw ? s : encodeURIComponent(s);
  14701. }
  14702. function decode(s) {
  14703. return config.raw ? s : decodeURIComponent(s);
  14704. }
  14705. function stringifyCookieValue(value) {
  14706. return encode(config.json ? JSON.stringify(value) : String(value));
  14707. }
  14708. function parseCookieValue(s) {
  14709. if (s.indexOf('"') === 0) {
  14710. // This is a quoted cookie as according to RFC2068, unescape...
  14711. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  14712. }
  14713. try {
  14714. // Replace server-side written pluses with spaces.
  14715. // If we can't decode the cookie, ignore it, it's unusable.
  14716. // If we can't parse the cookie, ignore it, it's unusable.
  14717. s = decodeURIComponent(s.replace(pluses, ' '));
  14718. return config.json ? JSON.parse(s) : s;
  14719. } catch(e) {}
  14720. }
  14721. function read(s, converter) {
  14722. var value = config.raw ? s : parseCookieValue(s);
  14723. return $.isFunction(converter) ? converter(value) : value;
  14724. }
  14725. var config = $.cookie = function (key, value, options) {
  14726. // Write
  14727. if (arguments.length > 1 && !$.isFunction(value)) {
  14728. options = $.extend({}, config.defaults, options);
  14729. if (typeof options.expires === 'number') {
  14730. var days = options.expires, t = options.expires = new Date();
  14731. t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
  14732. }
  14733. return (document.cookie = [
  14734. encode(key), '=', stringifyCookieValue(value),
  14735. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  14736. options.path ? '; path=' + options.path : '',
  14737. options.domain ? '; domain=' + options.domain : '',
  14738. options.secure ? '; secure' : ''
  14739. ].join(''));
  14740. }
  14741. // Read
  14742. var result = key ? undefined : {},
  14743. // To prevent the for loop in the first place assign an empty array
  14744. // in case there are no cookies at all. Also prevents odd result when
  14745. // calling $.cookie().
  14746. cookies = document.cookie ? document.cookie.split('; ') : [],
  14747. i = 0,
  14748. l = cookies.length;
  14749. for (; i < l; i++) {
  14750. var parts = cookies[i].split('='),
  14751. name = decode(parts.shift()),
  14752. cookie = parts.join('=');
  14753. if (key === name) {
  14754. // If second argument (value) is a function it's a converter...
  14755. result = read(cookie, value);
  14756. break;
  14757. }
  14758. // Prevent storing a cookie that we couldn't decode.
  14759. if (!key && (cookie = read(cookie)) !== undefined) {
  14760. result[name] = cookie;
  14761. }
  14762. }
  14763. return result;
  14764. };
  14765. config.defaults = {};
  14766. $.removeCookie = function (key, options) {
  14767. // Must not alter options, thus extending a fresh object...
  14768. $.cookie(key, '', $.extend({}, options, { expires: -1 }));
  14769. return !$.cookie(key);
  14770. };
  14771. }));
  14772. /*!
  14773. jQuery appear plugin
  14774. Version: 0.4
  14775. Plugin URL: https://github.com/morr/jquery.appear/
  14776. License: Copyright (c) 2012 Andrey Sidorov | Released under the MIT license
  14777. !*/
  14778. (function($) {
  14779. var selectors = [];
  14780. var check_binded = false;
  14781. var check_lock = false;
  14782. var defaults = {
  14783. interval: 250,
  14784. force_process: false
  14785. };
  14786. var $window = $(window);
  14787. var $prior_appeared = [];
  14788. function appeared(selector) {
  14789. return $(selector).filter(function() {
  14790. return $(this).is(':appeared');
  14791. });
  14792. }
  14793. function process() {
  14794. check_lock = false;
  14795. for (var index = 0, selectorsLength = selectors.length; index < selectorsLength; index++) {
  14796. var $appeared = appeared(selectors[index]);
  14797. $appeared.trigger('appear', [$appeared]);
  14798. if ($prior_appeared[index]) {
  14799. var $disappeared = $prior_appeared[index].not($appeared);
  14800. $disappeared.trigger('disappear', [$disappeared]);
  14801. }
  14802. $prior_appeared[index] = $appeared;
  14803. }
  14804. }
  14805. function add_selector(selector) {
  14806. selectors.push(selector);
  14807. $prior_appeared.push();
  14808. }
  14809. // ":appeared" custom filter
  14810. $.expr.pseudos.appeared = $.expr.createPseudo(function(arg) {
  14811. return function(element) {
  14812. var $element = $(element);
  14813. if (!$element.is(':visible')) {
  14814. return false;
  14815. }
  14816. var window_left = $window.scrollLeft();
  14817. var window_top = $window.scrollTop();
  14818. var offset = $element.offset();
  14819. var left = offset.left;
  14820. var top = offset.top;
  14821. if (top + $element.height() >= window_top &&
  14822. top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
  14823. left + $element.width() >= window_left &&
  14824. left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
  14825. return true;
  14826. } else {
  14827. return false;
  14828. }
  14829. };
  14830. });
  14831. $.fn.extend({
  14832. // watching for element's appearance in browser viewport
  14833. appear: function(selector, options) {
  14834. $.appear(this, options);
  14835. return this;
  14836. }
  14837. });
  14838. $.extend({
  14839. appear: function(selector, options) {
  14840. var opts = $.extend({}, defaults, options || {});
  14841. if (!check_binded) {
  14842. var on_check = function() {
  14843. if (check_lock) {
  14844. return;
  14845. }
  14846. check_lock = true;
  14847. setTimeout(process, opts.interval);
  14848. };
  14849. $(window).scroll(on_check).resize(on_check);
  14850. check_binded = true;
  14851. }
  14852. if (opts.force_process) {
  14853. setTimeout(process, opts.interval);
  14854. }
  14855. add_selector(selector);
  14856. },
  14857. // force elements's appearance check
  14858. force_appear: function() {
  14859. if (check_binded) {
  14860. process();
  14861. return true;
  14862. }
  14863. return false;
  14864. }
  14865. });
  14866. })(function() {
  14867. if (typeof module !== 'undefined') {
  14868. // Node
  14869. return require('jquery');
  14870. } else {
  14871. return jQuery;
  14872. }
  14873. }());
  14874. /*!
  14875. jQuery countTo Plugin
  14876. Version: v1.2.0
  14877. Plugin URL: https://github.com/mhuggins/jquery-countTo
  14878. License: Copyright (c) Matt Huggins | Released under the MIT license
  14879. !*/
  14880. (function (factory) {
  14881. if (typeof define === 'function' && define.amd) {
  14882. // AMD
  14883. define(['jquery'], factory);
  14884. } else if (typeof exports === 'object') {
  14885. // CommonJS
  14886. factory(require('jquery'));
  14887. } else {
  14888. // Browser globals
  14889. factory(jQuery);
  14890. }
  14891. }(function ($) {
  14892. var CountTo = function (element, options) {
  14893. this.$element = $(element);
  14894. this.options = $.extend({}, CountTo.DEFAULTS, this.dataOptions(), options);
  14895. this.init();
  14896. };
  14897. CountTo.DEFAULTS = {
  14898. from: 0, // the number the element should start at
  14899. to: 0, // the number the element should end at
  14900. speed: 1000, // how long it should take to count between the target numbers
  14901. refreshInterval: 100, // how often the element should be updated
  14902. decimals: 0, // the number of decimal places to show
  14903. formatter: formatter, // handler for formatting the value before rendering
  14904. onUpdate: null, // callback method for every time the element is updated
  14905. onComplete: null // callback method for when the element finishes updating
  14906. };
  14907. CountTo.prototype.init = function () {
  14908. this.value = this.options.from;
  14909. this.loops = Math.ceil(this.options.speed / this.options.refreshInterval);
  14910. this.loopCount = 0;
  14911. this.increment = (this.options.to - this.options.from) / this.loops;
  14912. };
  14913. CountTo.prototype.dataOptions = function () {
  14914. var options = {
  14915. from: this.$element.data('from'),
  14916. to: this.$element.data('to'),
  14917. speed: this.$element.data('speed'),
  14918. refreshInterval: this.$element.data('refresh-interval'),
  14919. decimals: this.$element.data('decimals')
  14920. };
  14921. var keys = Object.keys(options);
  14922. for (var i in keys) {
  14923. var key = keys[i];
  14924. if (typeof(options[key]) === 'undefined') {
  14925. delete options[key];
  14926. }
  14927. }
  14928. return options;
  14929. };
  14930. CountTo.prototype.update = function () {
  14931. this.value += this.increment;
  14932. this.loopCount++;
  14933. this.render();
  14934. if (typeof(this.options.onUpdate) == 'function') {
  14935. this.options.onUpdate.call(this.$element, this.value);
  14936. }
  14937. if (this.loopCount >= this.loops) {
  14938. clearInterval(this.interval);
  14939. this.value = this.options.to;
  14940. if (typeof(this.options.onComplete) == 'function') {
  14941. this.options.onComplete.call(this.$element, this.value);
  14942. }
  14943. }
  14944. };
  14945. CountTo.prototype.render = function () {
  14946. var formattedValue = this.options.formatter.call(this.$element, this.value, this.options);
  14947. this.$element.text(formattedValue);
  14948. };
  14949. CountTo.prototype.restart = function () {
  14950. this.stop();
  14951. this.init();
  14952. this.start();
  14953. };
  14954. CountTo.prototype.start = function () {
  14955. this.stop();
  14956. this.render();
  14957. this.interval = setInterval(this.update.bind(this), this.options.refreshInterval);
  14958. };
  14959. CountTo.prototype.stop = function () {
  14960. if (this.interval) {
  14961. clearInterval(this.interval);
  14962. }
  14963. };
  14964. CountTo.prototype.toggle = function () {
  14965. if (this.interval) {
  14966. this.stop();
  14967. } else {
  14968. this.start();
  14969. }
  14970. };
  14971. function formatter(value, options) {
  14972. return value.toFixed(options.decimals);
  14973. }
  14974. $.fn.countTo = function (option) {
  14975. return this.each(function () {
  14976. var $this = $(this);
  14977. var data = $this.data('countTo');
  14978. var init = !data || typeof(option) === 'object';
  14979. var options = typeof(option) === 'object' ? option : {};
  14980. var method = typeof(option) === 'string' ? option : 'start';
  14981. if (init) {
  14982. if (data) data.stop();
  14983. $this.data('countTo', data = new CountTo(this, options));
  14984. }
  14985. data[method].call(data);
  14986. });
  14987. };
  14988. }));
  14989. /*!
  14990. The Final Countdown
  14991. Version: 2.2.0
  14992. Plugin URL: http://hilios.github.io/jQuery.countdown/
  14993. License: Copyright (c) 2016 Edson Hilios
  14994. !*/
  14995. (function(factory) {
  14996. "use strict";
  14997. if (typeof define === "function" && define.amd) {
  14998. define([ "jquery" ], factory);
  14999. } else {
  15000. factory(jQuery);
  15001. }
  15002. })(function($) {
  15003. "use strict";
  15004. var instances = [], matchers = [], defaultOptions = {
  15005. precision: 100,
  15006. elapse: false,
  15007. defer: false
  15008. };
  15009. matchers.push(/^[0-9]*$/.source);
  15010. matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
  15011. matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);
  15012. matchers = new RegExp(matchers.join("|"));
  15013. function parseDateString(dateString) {
  15014. if (dateString instanceof Date) {
  15015. return dateString;
  15016. }
  15017. if (String(dateString).match(matchers)) {
  15018. if (String(dateString).match(/^[0-9]*$/)) {
  15019. dateString = Number(dateString);
  15020. }
  15021. if (String(dateString).match(/\-/)) {
  15022. dateString = String(dateString).replace(/\-/g, "/");
  15023. }
  15024. return new Date(dateString);
  15025. } else {
  15026. throw new Error("Couldn't cast `" + dateString + "` to a date object.");
  15027. }
  15028. }
  15029. var DIRECTIVE_KEY_MAP = {
  15030. Y: "years",
  15031. m: "months",
  15032. n: "daysToMonth",
  15033. d: "daysToWeek",
  15034. w: "weeks",
  15035. W: "weeksToMonth",
  15036. H: "hours",
  15037. M: "minutes",
  15038. S: "seconds",
  15039. D: "totalDays",
  15040. I: "totalHours",
  15041. N: "totalMinutes",
  15042. T: "totalSeconds"
  15043. };
  15044. function escapedRegExp(str) {
  15045. var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
  15046. return new RegExp(sanitize);
  15047. }
  15048. function strftime(offsetObject) {
  15049. return function(format) {
  15050. var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);
  15051. if (directives) {
  15052. for (var i = 0, len = directives.length; i < len; ++i) {
  15053. var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/), regexp = escapedRegExp(directive[0]), modifier = directive[1] || "", plural = directive[3] || "", value = null;
  15054. directive = directive[2];
  15055. if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
  15056. value = DIRECTIVE_KEY_MAP[directive];
  15057. value = Number(offsetObject[value]);
  15058. }
  15059. if (value !== null) {
  15060. if (modifier === "!") {
  15061. value = pluralize(plural, value);
  15062. }
  15063. if (modifier === "") {
  15064. if (value < 10) {
  15065. value = "0" + value.toString();
  15066. }
  15067. }
  15068. format = format.replace(regexp, value.toString());
  15069. }
  15070. }
  15071. }
  15072. format = format.replace(/%%/, "%");
  15073. return format;
  15074. };
  15075. }
  15076. function pluralize(format, count) {
  15077. var plural = "s", singular = "";
  15078. if (format) {
  15079. format = format.replace(/(:|;|\s)/gi, "").split(/\,/);
  15080. if (format.length === 1) {
  15081. plural = format[0];
  15082. } else {
  15083. singular = format[0];
  15084. plural = format[1];
  15085. }
  15086. }
  15087. if (Math.abs(count) > 1) {
  15088. return plural;
  15089. } else {
  15090. return singular;
  15091. }
  15092. }
  15093. var Countdown = function(el, finalDate, options) {
  15094. this.el = el;
  15095. this.$el = $(el);
  15096. this.interval = null;
  15097. this.offset = {};
  15098. this.options = $.extend({}, defaultOptions);
  15099. this.instanceNumber = instances.length;
  15100. instances.push(this);
  15101. this.$el.data("countdown-instance", this.instanceNumber);
  15102. if (options) {
  15103. if (typeof options === "function") {
  15104. this.$el.on("update.countdown", options);
  15105. this.$el.on("stoped.countdown", options);
  15106. this.$el.on("finish.countdown", options);
  15107. } else {
  15108. this.options = $.extend({}, defaultOptions, options);
  15109. }
  15110. }
  15111. this.setFinalDate(finalDate);
  15112. if (this.options.defer === false) {
  15113. this.start();
  15114. }
  15115. };
  15116. $.extend(Countdown.prototype, {
  15117. start: function() {
  15118. if (this.interval !== null) {
  15119. clearInterval(this.interval);
  15120. }
  15121. var self = this;
  15122. this.update();
  15123. this.interval = setInterval(function() {
  15124. self.update.call(self);
  15125. }, this.options.precision);
  15126. },
  15127. stop: function() {
  15128. clearInterval(this.interval);
  15129. this.interval = null;
  15130. this.dispatchEvent("stoped");
  15131. },
  15132. toggle: function() {
  15133. if (this.interval) {
  15134. this.stop();
  15135. } else {
  15136. this.start();
  15137. }
  15138. },
  15139. pause: function() {
  15140. this.stop();
  15141. },
  15142. resume: function() {
  15143. this.start();
  15144. },
  15145. remove: function() {
  15146. this.stop.call(this);
  15147. instances[this.instanceNumber] = null;
  15148. delete this.$el.data().countdownInstance;
  15149. },
  15150. setFinalDate: function(value) {
  15151. this.finalDate = parseDateString(value);
  15152. },
  15153. update: function() {
  15154. if (this.$el.closest("html").length === 0) {
  15155. this.remove();
  15156. return;
  15157. }
  15158. var hasEventsAttached = $._data(this.el, "events") !== undefined, now = new Date(), newTotalSecsLeft;
  15159. newTotalSecsLeft = this.finalDate.getTime() - now.getTime();
  15160. newTotalSecsLeft = Math.ceil(newTotalSecsLeft / 1e3);
  15161. newTotalSecsLeft = !this.options.elapse && newTotalSecsLeft < 0 ? 0 : Math.abs(newTotalSecsLeft);
  15162. if (this.totalSecsLeft === newTotalSecsLeft || !hasEventsAttached) {
  15163. return;
  15164. } else {
  15165. this.totalSecsLeft = newTotalSecsLeft;
  15166. }
  15167. this.elapsed = now >= this.finalDate;
  15168. this.offset = {
  15169. seconds: this.totalSecsLeft % 60,
  15170. minutes: Math.floor(this.totalSecsLeft / 60) % 60,
  15171. hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24,
  15172. days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
  15173. daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
  15174. daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368),
  15175. weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7),
  15176. weeksToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7) % 4,
  15177. months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368),
  15178. years: Math.abs(this.finalDate.getFullYear() - now.getFullYear()),
  15179. totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24),
  15180. totalHours: Math.floor(this.totalSecsLeft / 60 / 60),
  15181. totalMinutes: Math.floor(this.totalSecsLeft / 60),
  15182. totalSeconds: this.totalSecsLeft
  15183. };
  15184. if (!this.options.elapse && this.totalSecsLeft === 0) {
  15185. this.stop();
  15186. this.dispatchEvent("finish");
  15187. } else {
  15188. this.dispatchEvent("update");
  15189. }
  15190. },
  15191. dispatchEvent: function(eventName) {
  15192. var event = $.Event(eventName + ".countdown");
  15193. event.finalDate = this.finalDate;
  15194. event.elapsed = this.elapsed;
  15195. event.offset = $.extend({}, this.offset);
  15196. event.strftime = strftime(this.offset);
  15197. this.$el.trigger(event);
  15198. }
  15199. });
  15200. $.fn.countdown = function() {
  15201. var argumentsArray = Array.prototype.slice.call(arguments, 0);
  15202. return this.each(function() {
  15203. var instanceNumber = $(this).data("countdown-instance");
  15204. if (instanceNumber !== undefined) {
  15205. var instance = instances[instanceNumber], method = argumentsArray[0];
  15206. if (Countdown.prototype.hasOwnProperty(method)) {
  15207. instance[method].apply(instance, argumentsArray.slice(1));
  15208. } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) {
  15209. instance.setFinalDate.call(instance, method);
  15210. instance.start();
  15211. } else {
  15212. $.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, method));
  15213. }
  15214. } else {
  15215. new Countdown(this, argumentsArray[0], argumentsArray[1]);
  15216. }
  15217. });
  15218. };
  15219. });
  15220. /*!
  15221. Easy pie chart
  15222. Version: 2.1.7
  15223. Plugin URL: https://github.com/rendro/easy-pie-chart
  15224. License: Copyright | Robert Fleischmann
  15225. !*/
  15226. (function (root, factory) {
  15227. if (typeof define === 'function' && define.amd) {
  15228. // AMD. Register as an anonymous module unless amdModuleId is set
  15229. define(["jquery"], function (a0) {
  15230. return (factory(a0));
  15231. });
  15232. } else if (typeof exports === 'object') {
  15233. // Node. Does not work with strict CommonJS, but
  15234. // only CommonJS-like environments that support module.exports,
  15235. // like Node.
  15236. module.exports = factory(require("jquery"));
  15237. } else {
  15238. factory(jQuery);
  15239. }
  15240. }(this, function ($) {
  15241. /**
  15242. * Renderer to render the chart on a canvas object
  15243. * @param {DOMElement} el DOM element to host the canvas (root of the plugin)
  15244. * @param {object} options options object of the plugin
  15245. */
  15246. var CanvasRenderer = function(el, options) {
  15247. var cachedBackground;
  15248. var canvas = document.createElement('canvas');
  15249. el.appendChild(canvas);
  15250. if (typeof(G_vmlCanvasManager) === 'object') {
  15251. G_vmlCanvasManager.initElement(canvas);
  15252. }
  15253. var ctx = canvas.getContext('2d');
  15254. canvas.width = canvas.height = options.size;
  15255. // canvas on retina devices
  15256. var scaleBy = 1;
  15257. if (window.devicePixelRatio > 1) {
  15258. scaleBy = window.devicePixelRatio;
  15259. canvas.style.width = canvas.style.height = [options.size, 'px'].join('');
  15260. canvas.width = canvas.height = options.size * scaleBy;
  15261. ctx.scale(scaleBy, scaleBy);
  15262. }
  15263. // move 0,0 coordinates to the center
  15264. ctx.translate(options.size / 2, options.size / 2);
  15265. // rotate canvas -90deg
  15266. ctx.rotate((-1 / 2 + options.rotate / 180) * Math.PI);
  15267. var radius = (options.size - options.lineWidth) / 2;
  15268. if (options.scaleColor && options.scaleLength) {
  15269. radius -= options.scaleLength + 2; // 2 is the distance between scale and bar
  15270. }
  15271. // IE polyfill for Date
  15272. Date.now = Date.now || function() {
  15273. return +(new Date());
  15274. };
  15275. /**
  15276. * Draw a circle around the center of the canvas
  15277. * @param {strong} color Valid CSS color string
  15278. * @param {number} lineWidth Width of the line in px
  15279. * @param {number} percent Percentage to draw (float between -1 and 1)
  15280. */
  15281. var drawCircle = function(color, lineWidth, percent) {
  15282. percent = Math.min(Math.max(-1, percent || 0), 1);
  15283. var isNegative = percent <= 0 ? true : false;
  15284. ctx.beginPath();
  15285. ctx.arc(0, 0, radius, 0, Math.PI * 2 * percent, isNegative);
  15286. ctx.strokeStyle = color;
  15287. ctx.lineWidth = lineWidth;
  15288. ctx.stroke();
  15289. };
  15290. /**
  15291. * Draw the scale of the chart
  15292. */
  15293. var drawScale = function() {
  15294. var offset;
  15295. var length;
  15296. ctx.lineWidth = 1;
  15297. ctx.fillStyle = options.scaleColor;
  15298. ctx.save();
  15299. for (var i = 24; i > 0; --i) {
  15300. if (i % 6 === 0) {
  15301. length = options.scaleLength;
  15302. offset = 0;
  15303. } else {
  15304. length = options.scaleLength * 0.6;
  15305. offset = options.scaleLength - length;
  15306. }
  15307. ctx.fillRect(-options.size/2 + offset, 0, length, 1);
  15308. ctx.rotate(Math.PI / 12);
  15309. }
  15310. ctx.restore();
  15311. };
  15312. /**
  15313. * Request animation frame wrapper with polyfill
  15314. * @return {function} Request animation frame method or timeout fallback
  15315. */
  15316. var reqAnimationFrame = (function() {
  15317. return window.requestAnimationFrame ||
  15318. window.webkitRequestAnimationFrame ||
  15319. window.mozRequestAnimationFrame ||
  15320. function(callback) {
  15321. window.setTimeout(callback, 1000 / 60);
  15322. };
  15323. }());
  15324. /**
  15325. * Draw the background of the plugin including the scale and the track
  15326. */
  15327. var drawBackground = function() {
  15328. if(options.scaleColor) drawScale();
  15329. if(options.trackColor) drawCircle(options.trackColor, options.trackWidth || options.lineWidth, 1);
  15330. };
  15331. /**
  15332. * Canvas accessor
  15333. */
  15334. this.getCanvas = function() {
  15335. return canvas;
  15336. };
  15337. /**
  15338. * Canvas 2D context 'ctx' accessor
  15339. */
  15340. this.getCtx = function() {
  15341. return ctx;
  15342. };
  15343. /**
  15344. * Clear the complete canvas
  15345. */
  15346. this.clear = function() {
  15347. ctx.clearRect(options.size / -2, options.size / -2, options.size, options.size);
  15348. };
  15349. /**
  15350. * Draw the complete chart
  15351. * @param {number} percent Percent shown by the chart between -100 and 100
  15352. */
  15353. this.draw = function(percent) {
  15354. // do we need to render a background
  15355. if (!!options.scaleColor || !!options.trackColor) {
  15356. // getImageData and putImageData are supported
  15357. if (ctx.getImageData && ctx.putImageData) {
  15358. if (!cachedBackground) {
  15359. drawBackground();
  15360. cachedBackground = ctx.getImageData(0, 0, options.size * scaleBy, options.size * scaleBy);
  15361. } else {
  15362. ctx.putImageData(cachedBackground, 0, 0);
  15363. }
  15364. } else {
  15365. this.clear();
  15366. drawBackground();
  15367. }
  15368. } else {
  15369. this.clear();
  15370. }
  15371. ctx.lineCap = options.lineCap;
  15372. // if barcolor is a function execute it and pass the percent as a value
  15373. var color;
  15374. if (typeof(options.barColor) === 'function') {
  15375. color = options.barColor(percent);
  15376. } else {
  15377. color = options.barColor;
  15378. }
  15379. // draw bar
  15380. drawCircle(color, options.lineWidth, percent / 100);
  15381. }.bind(this);
  15382. /**
  15383. * Animate from some percent to some other percentage
  15384. * @param {number} from Starting percentage
  15385. * @param {number} to Final percentage
  15386. */
  15387. this.animate = function(from, to) {
  15388. var startTime = Date.now();
  15389. options.onStart(from, to);
  15390. var animation = function() {
  15391. var process = Math.min(Date.now() - startTime, options.animate.duration);
  15392. var currentValue = options.easing(this, process, from, to - from, options.animate.duration);
  15393. this.draw(currentValue);
  15394. options.onStep(from, to, currentValue);
  15395. if (process >= options.animate.duration) {
  15396. options.onStop(from, to);
  15397. } else {
  15398. reqAnimationFrame(animation);
  15399. }
  15400. }.bind(this);
  15401. reqAnimationFrame(animation);
  15402. }.bind(this);
  15403. };
  15404. var EasyPieChart = function(el, opts) {
  15405. var defaultOptions = {
  15406. barColor: '#ef1e25',
  15407. trackColor: '#f9f9f9',
  15408. scaleColor: '#dfe0e0',
  15409. scaleLength: 5,
  15410. lineCap: 'round',
  15411. lineWidth: 3,
  15412. trackWidth: undefined,
  15413. size: 110,
  15414. rotate: 0,
  15415. animate: {
  15416. duration: 1000,
  15417. enabled: true
  15418. },
  15419. easing: function (x, t, b, c, d) { // more can be found here: http://gsgd.co.uk/sandbox/jquery/easing/
  15420. t = t / (d/2);
  15421. if (t < 1) {
  15422. return c / 2 * t * t + b;
  15423. }
  15424. return -c/2 * ((--t)*(t-2) - 1) + b;
  15425. },
  15426. onStart: function(from, to) {
  15427. return;
  15428. },
  15429. onStep: function(from, to, currentValue) {
  15430. return;
  15431. },
  15432. onStop: function(from, to) {
  15433. return;
  15434. }
  15435. };
  15436. // detect present renderer
  15437. if (typeof(CanvasRenderer) !== 'undefined') {
  15438. defaultOptions.renderer = CanvasRenderer;
  15439. } else if (typeof(SVGRenderer) !== 'undefined') {
  15440. defaultOptions.renderer = SVGRenderer;
  15441. } else {
  15442. throw new Error('Please load either the SVG- or the CanvasRenderer');
  15443. }
  15444. var options = {};
  15445. var currentValue = 0;
  15446. /**
  15447. * Initialize the plugin by creating the options object and initialize rendering
  15448. */
  15449. var init = function() {
  15450. this.el = el;
  15451. this.options = options;
  15452. // merge user options into default options
  15453. for (var i in defaultOptions) {
  15454. if (defaultOptions.hasOwnProperty(i)) {
  15455. options[i] = opts && typeof(opts[i]) !== 'undefined' ? opts[i] : defaultOptions[i];
  15456. if (typeof(options[i]) === 'function') {
  15457. options[i] = options[i].bind(this);
  15458. }
  15459. }
  15460. }
  15461. // check for jQuery easing
  15462. if (typeof(options.easing) === 'string' && typeof(jQuery) !== 'undefined' && jQuery.isFunction(jQuery.easing[options.easing])) {
  15463. options.easing = jQuery.easing[options.easing];
  15464. } else {
  15465. options.easing = defaultOptions.easing;
  15466. }
  15467. // process earlier animate option to avoid bc breaks
  15468. if (typeof(options.animate) === 'number') {
  15469. options.animate = {
  15470. duration: options.animate,
  15471. enabled: true
  15472. };
  15473. }
  15474. if (typeof(options.animate) === 'boolean' && !options.animate) {
  15475. options.animate = {
  15476. duration: 1000,
  15477. enabled: options.animate
  15478. };
  15479. }
  15480. // create renderer
  15481. this.renderer = new options.renderer(el, options);
  15482. // initial draw
  15483. this.renderer.draw(currentValue);
  15484. // initial update
  15485. if (el.dataset && el.dataset.percent) {
  15486. this.update(parseFloat(el.dataset.percent));
  15487. } else if (el.getAttribute && el.getAttribute('data-percent')) {
  15488. this.update(parseFloat(el.getAttribute('data-percent')));
  15489. }
  15490. }.bind(this);
  15491. /**
  15492. * Update the value of the chart
  15493. * @param {number} newValue Number between 0 and 100
  15494. * @return {object} Instance of the plugin for method chaining
  15495. */
  15496. this.update = function(newValue) {
  15497. newValue = parseFloat(newValue);
  15498. if (options.animate.enabled) {
  15499. this.renderer.animate(currentValue, newValue);
  15500. } else {
  15501. this.renderer.draw(newValue);
  15502. }
  15503. currentValue = newValue;
  15504. return this;
  15505. }.bind(this);
  15506. /**
  15507. * Disable animation
  15508. * @return {object} Instance of the plugin for method chaining
  15509. */
  15510. this.disableAnimation = function() {
  15511. options.animate.enabled = false;
  15512. return this;
  15513. };
  15514. /**
  15515. * Enable animation
  15516. * @return {object} Instance of the plugin for method chaining
  15517. */
  15518. this.enableAnimation = function() {
  15519. options.animate.enabled = true;
  15520. return this;
  15521. };
  15522. init();
  15523. };
  15524. $.fn.easyPieChart = function(options) {
  15525. return this.each(function() {
  15526. var instanceOptions;
  15527. if (!$.data(this, 'easyPieChart')) {
  15528. instanceOptions = $.extend({}, options, $(this).data());
  15529. $.data(this, 'easyPieChart', new EasyPieChart(this, instanceOptions));
  15530. }
  15531. });
  15532. };
  15533. }));
  15534. /*!
  15535. FitVids
  15536. Version: 1.1
  15537. Plugin URI: http://fitvidsjs.com/
  15538. License: Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com | Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ | Released under the WTFPL license - http://sam.zoy.org/wtfpl/
  15539. !*/
  15540. (function( $ ){
  15541. 'use strict';
  15542. $.fn.fitVids = function( options ) {
  15543. var settings = {
  15544. customSelector: null,
  15545. ignore: null
  15546. };
  15547. if(!document.getElementById('fit-vids-style')) {
  15548. // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
  15549. var head = document.head || document.getElementsByTagName('head')[0];
  15550. var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
  15551. var div = document.createElement("div");
  15552. div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
  15553. head.appendChild(div.childNodes[1]);
  15554. }
  15555. if ( options ) {
  15556. $.extend( settings, options );
  15557. }
  15558. return this.each(function(){
  15559. var selectors = [
  15560. 'iframe[src*="player.vimeo.com"]',
  15561. 'iframe[src*="youtube.com"]',
  15562. 'iframe[src*="youtube-nocookie.com"]',
  15563. 'iframe[src*="kickstarter.com"][src*="video.html"]',
  15564. 'object',
  15565. 'embed'
  15566. ];
  15567. if (settings.customSelector) {
  15568. selectors.push(settings.customSelector);
  15569. }
  15570. var ignoreList = '.fitvidsignore';
  15571. if(settings.ignore) {
  15572. ignoreList = ignoreList + ', ' + settings.ignore;
  15573. }
  15574. var $allVideos = $(this).find(selectors.join(','));
  15575. $allVideos = $allVideos.not('object object'); // SwfObj conflict patch
  15576. $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
  15577. $allVideos.each(function(){
  15578. var $this = $(this);
  15579. if($this.parents(ignoreList).length > 0) {
  15580. return; // Disable FitVids on this video.
  15581. }
  15582. if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
  15583. if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
  15584. {
  15585. $this.attr('height', 9);
  15586. $this.attr('width', 16);
  15587. }
  15588. var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
  15589. width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
  15590. aspectRatio = height / width;
  15591. if(!$this.attr('name')){
  15592. var videoName = 'fitvid' + $.fn.fitVids._count;
  15593. $this.attr('name', videoName);
  15594. $.fn.fitVids._count++;
  15595. }
  15596. $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
  15597. $this.removeAttr('height').removeAttr('width');
  15598. });
  15599. });
  15600. };
  15601. // Internal counter for unique video names.
  15602. $.fn.fitVids._count = 0;
  15603. // Works with either jQuery or Zepto
  15604. })( window.jQuery || window.Zepto );
  15605. /*!
  15606. Magnific Popup
  15607. Version: 1.1.0 - 2016-02-20
  15608. Plugin URL: http://dimsemenov.com/plugins/magnific-popup/
  15609. License: Copyright (c) 2016 Dmitry Semenov
  15610. !*/
  15611. (function (factory) {
  15612. if (typeof define === 'function' && define.amd) {
  15613. // AMD. Register as an anonymous module.
  15614. define(['jquery'], factory);
  15615. } else if (typeof exports === 'object') {
  15616. // Node/CommonJS
  15617. factory(require('jquery'));
  15618. } else {
  15619. // Browser globals
  15620. factory(window.jQuery || window.Zepto);
  15621. }
  15622. }(function($) {
  15623. /*>>core*/
  15624. /**
  15625. *
  15626. * Magnific Popup Core JS file
  15627. *
  15628. */
  15629. /**
  15630. * Private static constants
  15631. */
  15632. var CLOSE_EVENT = 'Close',
  15633. BEFORE_CLOSE_EVENT = 'BeforeClose',
  15634. AFTER_CLOSE_EVENT = 'AfterClose',
  15635. BEFORE_APPEND_EVENT = 'BeforeAppend',
  15636. MARKUP_PARSE_EVENT = 'MarkupParse',
  15637. OPEN_EVENT = 'Open',
  15638. CHANGE_EVENT = 'Change',
  15639. NS = 'mfp',
  15640. EVENT_NS = '.' + NS,
  15641. READY_CLASS = 'mfp-ready',
  15642. REMOVING_CLASS = 'mfp-removing',
  15643. PREVENT_CLOSE_CLASS = 'mfp-prevent-close';
  15644. /**
  15645. * Private vars
  15646. */
  15647. /*jshint -W079 */
  15648. var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this'
  15649. MagnificPopup = function(){},
  15650. _isJQ = !!(window.jQuery),
  15651. _prevStatus,
  15652. _window = $(window),
  15653. _document,
  15654. _prevContentType,
  15655. _wrapClasses,
  15656. _currPopupType;
  15657. /**
  15658. * Private functions
  15659. */
  15660. var _mfpOn = function(name, f) {
  15661. mfp.ev.on(NS + name + EVENT_NS, f);
  15662. },
  15663. _getEl = function(className, appendTo, html, raw) {
  15664. var el = document.createElement('div');
  15665. el.className = 'mfp-'+className;
  15666. if(html) {
  15667. el.innerHTML = html;
  15668. }
  15669. if(!raw) {
  15670. el = $(el);
  15671. if(appendTo) {
  15672. el.appendTo(appendTo);
  15673. }
  15674. } else if(appendTo) {
  15675. appendTo.appendChild(el);
  15676. }
  15677. return el;
  15678. },
  15679. _mfpTrigger = function(e, data) {
  15680. mfp.ev.triggerHandler(NS + e, data);
  15681. if(mfp.st.callbacks) {
  15682. // converts "mfpEventName" to "eventName" callback and triggers it if it's present
  15683. e = e.charAt(0).toLowerCase() + e.slice(1);
  15684. if(mfp.st.callbacks[e]) {
  15685. mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]);
  15686. }
  15687. }
  15688. },
  15689. _getCloseBtn = function(type) {
  15690. if(type !== _currPopupType || !mfp.currTemplate.closeBtn) {
  15691. mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) );
  15692. _currPopupType = type;
  15693. }
  15694. return mfp.currTemplate.closeBtn;
  15695. },
  15696. // Initialize Magnific Popup only when called at least once
  15697. _checkInstance = function() {
  15698. if(!$.magnificPopup.instance) {
  15699. /*jshint -W020 */
  15700. mfp = new MagnificPopup();
  15701. mfp.init();
  15702. $.magnificPopup.instance = mfp;
  15703. }
  15704. },
  15705. // CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
  15706. supportsTransitions = function() {
  15707. var s = document.createElement('p').style, // 's' for style. better to create an element if body yet to exist
  15708. v = ['ms','O','Moz','Webkit']; // 'v' for vendor
  15709. if( s['transition'] !== undefined ) {
  15710. return true;
  15711. }
  15712. while( v.length ) {
  15713. if( v.pop() + 'Transition' in s ) {
  15714. return true;
  15715. }
  15716. }
  15717. return false;
  15718. };
  15719. /**
  15720. * Public functions
  15721. */
  15722. MagnificPopup.prototype = {
  15723. constructor: MagnificPopup,
  15724. /**
  15725. * Initializes Magnific Popup plugin.
  15726. * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed
  15727. */
  15728. init: function() {
  15729. var appVersion = navigator.appVersion;
  15730. mfp.isLowIE = mfp.isIE8 = document.all && !document.addEventListener;
  15731. mfp.isAndroid = (/android/gi).test(appVersion);
  15732. mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
  15733. mfp.supportsTransition = supportsTransitions();
  15734. // We disable fixed positioned lightbox on devices that don't handle it nicely.
  15735. // If you know a better way of detecting this - let me know.
  15736. mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) );
  15737. _document = $(document);
  15738. mfp.popupsCache = {};
  15739. },
  15740. /**
  15741. * Opens popup
  15742. * @param data [description]
  15743. */
  15744. open: function(data) {
  15745. var i;
  15746. if(data.isObj === false) {
  15747. // convert jQuery collection to array to avoid conflicts later
  15748. mfp.items = data.items.toArray();
  15749. mfp.index = 0;
  15750. var items = data.items,
  15751. item;
  15752. for(i = 0; i < items.length; i++) {
  15753. item = items[i];
  15754. if(item.parsed) {
  15755. item = item.el[0];
  15756. }
  15757. if(item === data.el[0]) {
  15758. mfp.index = i;
  15759. break;
  15760. }
  15761. }
  15762. } else {
  15763. mfp.items = $.isArray(data.items) ? data.items : [data.items];
  15764. mfp.index = data.index || 0;
  15765. }
  15766. // if popup is already opened - we just update the content
  15767. if(mfp.isOpen) {
  15768. mfp.updateItemHTML();
  15769. return;
  15770. }
  15771. mfp.types = [];
  15772. _wrapClasses = '';
  15773. if(data.mainEl && data.mainEl.length) {
  15774. mfp.ev = data.mainEl.eq(0);
  15775. } else {
  15776. mfp.ev = _document;
  15777. }
  15778. if(data.key) {
  15779. if(!mfp.popupsCache[data.key]) {
  15780. mfp.popupsCache[data.key] = {};
  15781. }
  15782. mfp.currTemplate = mfp.popupsCache[data.key];
  15783. } else {
  15784. mfp.currTemplate = {};
  15785. }
  15786. mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data );
  15787. mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos;
  15788. if(mfp.st.modal) {
  15789. mfp.st.closeOnContentClick = false;
  15790. mfp.st.closeOnBgClick = false;
  15791. mfp.st.showCloseBtn = false;
  15792. mfp.st.enableEscapeKey = false;
  15793. }
  15794. // Building markup
  15795. // main containers are created only once
  15796. if(!mfp.bgOverlay) {
  15797. // Dark overlay
  15798. mfp.bgOverlay = _getEl('bg').on('click'+EVENT_NS, function() {
  15799. mfp.close();
  15800. });
  15801. mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) {
  15802. if(mfp._checkIfClose(e.target)) {
  15803. mfp.close();
  15804. }
  15805. });
  15806. mfp.container = _getEl('container', mfp.wrap);
  15807. }
  15808. mfp.contentContainer = _getEl('content');
  15809. if(mfp.st.preloader) {
  15810. mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading);
  15811. }
  15812. // Initializing modules
  15813. var modules = $.magnificPopup.modules;
  15814. for(i = 0; i < modules.length; i++) {
  15815. var n = modules[i];
  15816. n = n.charAt(0).toUpperCase() + n.slice(1);
  15817. mfp['init'+n].call(mfp);
  15818. }
  15819. _mfpTrigger('BeforeOpen');
  15820. if(mfp.st.showCloseBtn) {
  15821. // Close button
  15822. if(!mfp.st.closeBtnInside) {
  15823. mfp.wrap.append( _getCloseBtn() );
  15824. } else {
  15825. _mfpOn(MARKUP_PARSE_EVENT, function(e, template, values, item) {
  15826. values.close_replaceWith = _getCloseBtn(item.type);
  15827. });
  15828. _wrapClasses += ' mfp-close-btn-in';
  15829. }
  15830. }
  15831. if(mfp.st.alignTop) {
  15832. _wrapClasses += ' mfp-align-top';
  15833. }
  15834. if(mfp.fixedContentPos) {
  15835. mfp.wrap.css({
  15836. overflow: mfp.st.overflowY,
  15837. overflowX: 'hidden',
  15838. overflowY: mfp.st.overflowY
  15839. });
  15840. } else {
  15841. mfp.wrap.css({
  15842. top: _window.scrollTop(),
  15843. position: 'absolute'
  15844. });
  15845. }
  15846. if( mfp.st.fixedBgPos === false || (mfp.st.fixedBgPos === 'auto' && !mfp.fixedContentPos) ) {
  15847. mfp.bgOverlay.css({
  15848. height: _document.height(),
  15849. position: 'absolute'
  15850. });
  15851. }
  15852. if(mfp.st.enableEscapeKey) {
  15853. // Close on ESC key
  15854. _document.on('keyup' + EVENT_NS, function(e) {
  15855. if(e.keyCode === 27) {
  15856. mfp.close();
  15857. }
  15858. });
  15859. }
  15860. _window.on('resize' + EVENT_NS, function() {
  15861. mfp.updateSize();
  15862. });
  15863. if(!mfp.st.closeOnContentClick) {
  15864. _wrapClasses += ' mfp-auto-cursor';
  15865. }
  15866. if(_wrapClasses)
  15867. mfp.wrap.addClass(_wrapClasses);
  15868. // this triggers recalculation of layout, so we get it once to not to trigger twice
  15869. var windowHeight = mfp.wH = _window.height();
  15870. var windowStyles = {};
  15871. if( mfp.fixedContentPos ) {
  15872. if(mfp._hasScrollBar(windowHeight)){
  15873. var s = mfp._getScrollbarSize();
  15874. if(s) {
  15875. windowStyles.marginRight = s;
  15876. }
  15877. }
  15878. }
  15879. if(mfp.fixedContentPos) {
  15880. if(!mfp.isIE7) {
  15881. windowStyles.overflow = 'hidden';
  15882. } else {
  15883. // ie7 double-scroll bug
  15884. $('body, html').css('overflow', 'hidden');
  15885. }
  15886. }
  15887. var classesToadd = mfp.st.mainClass;
  15888. if(mfp.isIE7) {
  15889. classesToadd += ' mfp-ie7';
  15890. }
  15891. if(classesToadd) {
  15892. mfp._addClassToMFP( classesToadd );
  15893. }
  15894. // add content
  15895. mfp.updateItemHTML();
  15896. _mfpTrigger('BuildControls');
  15897. // remove scrollbar, add margin e.t.c
  15898. $('html').css(windowStyles);
  15899. // add everything to DOM
  15900. mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) );
  15901. // Save last focused element
  15902. mfp._lastFocusedEl = document.activeElement;
  15903. // Wait for next cycle to allow CSS transition
  15904. setTimeout(function() {
  15905. if(mfp.content) {
  15906. mfp._addClassToMFP(READY_CLASS);
  15907. mfp._setFocus();
  15908. } else {
  15909. // if content is not defined (not loaded e.t.c) we add class only for BG
  15910. mfp.bgOverlay.addClass(READY_CLASS);
  15911. }
  15912. // Trap the focus in popup
  15913. _document.on('focusin' + EVENT_NS, mfp._onFocusIn);
  15914. }, 16);
  15915. mfp.isOpen = true;
  15916. mfp.updateSize(windowHeight);
  15917. _mfpTrigger(OPEN_EVENT);
  15918. return data;
  15919. },
  15920. /**
  15921. * Closes the popup
  15922. */
  15923. close: function() {
  15924. if(!mfp.isOpen) return;
  15925. _mfpTrigger(BEFORE_CLOSE_EVENT);
  15926. mfp.isOpen = false;
  15927. // for CSS3 animation
  15928. if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition ) {
  15929. mfp._addClassToMFP(REMOVING_CLASS);
  15930. setTimeout(function() {
  15931. mfp._close();
  15932. }, mfp.st.removalDelay);
  15933. } else {
  15934. mfp._close();
  15935. }
  15936. },
  15937. /**
  15938. * Helper for close() function
  15939. */
  15940. _close: function() {
  15941. _mfpTrigger(CLOSE_EVENT);
  15942. var classesToRemove = REMOVING_CLASS + ' ' + READY_CLASS + ' ';
  15943. mfp.bgOverlay.detach();
  15944. mfp.wrap.detach();
  15945. mfp.container.empty();
  15946. if(mfp.st.mainClass) {
  15947. classesToRemove += mfp.st.mainClass + ' ';
  15948. }
  15949. mfp._removeClassFromMFP(classesToRemove);
  15950. if(mfp.fixedContentPos) {
  15951. var windowStyles = {marginRight: ''};
  15952. if(mfp.isIE7) {
  15953. $('body, html').css('overflow', '');
  15954. } else {
  15955. windowStyles.overflow = '';
  15956. }
  15957. $('html').css(windowStyles);
  15958. }
  15959. _document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS);
  15960. mfp.ev.off(EVENT_NS);
  15961. // clean up DOM elements that aren't removed
  15962. mfp.wrap.attr('class', 'mfp-wrap').removeAttr('style');
  15963. mfp.bgOverlay.attr('class', 'mfp-bg');
  15964. mfp.container.attr('class', 'mfp-container');
  15965. // remove close button from target element
  15966. if(mfp.st.showCloseBtn &&
  15967. (!mfp.st.closeBtnInside || mfp.currTemplate[mfp.currItem.type] === true)) {
  15968. if(mfp.currTemplate.closeBtn)
  15969. mfp.currTemplate.closeBtn.detach();
  15970. }
  15971. if(mfp.st.autoFocusLast && mfp._lastFocusedEl) {
  15972. $(mfp._lastFocusedEl).focus(); // put tab focus back
  15973. }
  15974. mfp.currItem = null;
  15975. mfp.content = null;
  15976. mfp.currTemplate = null;
  15977. mfp.prevHeight = 0;
  15978. _mfpTrigger(AFTER_CLOSE_EVENT);
  15979. },
  15980. updateSize: function(winHeight) {
  15981. if(mfp.isIOS) {
  15982. // fixes iOS nav bars https://github.com/dimsemenov/Magnific-Popup/issues/2
  15983. var zoomLevel = document.documentElement.clientWidth / window.innerWidth;
  15984. var height = window.innerHeight * zoomLevel;
  15985. mfp.wrap.css('height', height);
  15986. mfp.wH = height;
  15987. } else {
  15988. mfp.wH = winHeight || _window.height();
  15989. }
  15990. // Fixes #84: popup incorrectly positioned with position:relative on body
  15991. if(!mfp.fixedContentPos) {
  15992. mfp.wrap.css('height', mfp.wH);
  15993. }
  15994. _mfpTrigger('Resize');
  15995. },
  15996. /**
  15997. * Set content of popup based on current index
  15998. */
  15999. updateItemHTML: function() {
  16000. var item = mfp.items[mfp.index];
  16001. // Detach and perform modifications
  16002. mfp.contentContainer.detach();
  16003. if(mfp.content)
  16004. mfp.content.detach();
  16005. if(!item.parsed) {
  16006. item = mfp.parseEl( mfp.index );
  16007. }
  16008. var type = item.type;
  16009. _mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : '', type]);
  16010. // BeforeChange event works like so:
  16011. // _mfpOn('BeforeChange', function(e, prevType, newType) { });
  16012. mfp.currItem = item;
  16013. if(!mfp.currTemplate[type]) {
  16014. var markup = mfp.st[type] ? mfp.st[type].markup : false;
  16015. // allows to modify markup
  16016. _mfpTrigger('FirstMarkupParse', markup);
  16017. if(markup) {
  16018. mfp.currTemplate[type] = $(markup);
  16019. } else {
  16020. // if there is no markup found we just define that template is parsed
  16021. mfp.currTemplate[type] = true;
  16022. }
  16023. }
  16024. if(_prevContentType && _prevContentType !== item.type) {
  16025. mfp.container.removeClass('mfp-'+_prevContentType+'-holder');
  16026. }
  16027. var newContent = mfp['get' + type.charAt(0).toUpperCase() + type.slice(1)](item, mfp.currTemplate[type]);
  16028. mfp.appendContent(newContent, type);
  16029. item.preloaded = true;
  16030. _mfpTrigger(CHANGE_EVENT, item);
  16031. _prevContentType = item.type;
  16032. // Append container back after its content changed
  16033. mfp.container.prepend(mfp.contentContainer);
  16034. _mfpTrigger('AfterChange');
  16035. },
  16036. /**
  16037. * Set HTML content of popup
  16038. */
  16039. appendContent: function(newContent, type) {
  16040. mfp.content = newContent;
  16041. if(newContent) {
  16042. if(mfp.st.showCloseBtn && mfp.st.closeBtnInside &&
  16043. mfp.currTemplate[type] === true) {
  16044. // if there is no markup, we just append close button element inside
  16045. if(!mfp.content.find('.mfp-close').length) {
  16046. mfp.content.append(_getCloseBtn());
  16047. }
  16048. } else {
  16049. mfp.content = newContent;
  16050. }
  16051. } else {
  16052. mfp.content = '';
  16053. }
  16054. _mfpTrigger(BEFORE_APPEND_EVENT);
  16055. mfp.container.addClass('mfp-'+type+'-holder');
  16056. mfp.contentContainer.append(mfp.content);
  16057. },
  16058. /**
  16059. * Creates Magnific Popup data object based on given data
  16060. * @param {int} index Index of item to parse
  16061. */
  16062. parseEl: function(index) {
  16063. var item = mfp.items[index],
  16064. type;
  16065. if(item.tagName) {
  16066. item = { el: $(item) };
  16067. } else {
  16068. type = item.type;
  16069. item = { data: item, src: item.src };
  16070. }
  16071. if(item.el) {
  16072. var types = mfp.types;
  16073. // check for 'mfp-TYPE' class
  16074. for(var i = 0; i < types.length; i++) {
  16075. if( item.el.hasClass('mfp-'+types[i]) ) {
  16076. type = types[i];
  16077. break;
  16078. }
  16079. }
  16080. item.src = item.el.attr('data-mfp-src');
  16081. if(!item.src) {
  16082. item.src = item.el.attr('href');
  16083. }
  16084. }
  16085. item.type = type || mfp.st.type || 'inline';
  16086. item.index = index;
  16087. item.parsed = true;
  16088. mfp.items[index] = item;
  16089. _mfpTrigger('ElementParse', item);
  16090. return mfp.items[index];
  16091. },
  16092. /**
  16093. * Initializes single popup or a group of popups
  16094. */
  16095. addGroup: function(el, options) {
  16096. var eHandler = function(e) {
  16097. e.mfpEl = this;
  16098. mfp._openClick(e, el, options);
  16099. };
  16100. if(!options) {
  16101. options = {};
  16102. }
  16103. var eName = 'click.magnificPopup';
  16104. options.mainEl = el;
  16105. if(options.items) {
  16106. options.isObj = true;
  16107. el.off(eName).on(eName, eHandler);
  16108. } else {
  16109. options.isObj = false;
  16110. if(options.delegate) {
  16111. el.off(eName).on(eName, options.delegate , eHandler);
  16112. } else {
  16113. options.items = el;
  16114. el.off(eName).on(eName, eHandler);
  16115. }
  16116. }
  16117. },
  16118. _openClick: function(e, el, options) {
  16119. var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick;
  16120. if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey ) ) {
  16121. return;
  16122. }
  16123. var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
  16124. if(disableOn) {
  16125. if($.isFunction(disableOn)) {
  16126. if( !disableOn.call(mfp) ) {
  16127. return true;
  16128. }
  16129. } else { // else it's number
  16130. if( _window.width() < disableOn ) {
  16131. return true;
  16132. }
  16133. }
  16134. }
  16135. if(e.type) {
  16136. e.preventDefault();
  16137. // This will prevent popup from closing if element is inside and popup is already opened
  16138. if(mfp.isOpen) {
  16139. e.stopPropagation();
  16140. }
  16141. }
  16142. options.el = $(e.mfpEl);
  16143. if(options.delegate) {
  16144. options.items = el.find(options.delegate);
  16145. }
  16146. mfp.open(options);
  16147. },
  16148. /**
  16149. * Updates text on preloader
  16150. */
  16151. updateStatus: function(status, text) {
  16152. if(mfp.preloader) {
  16153. if(_prevStatus !== status) {
  16154. mfp.container.removeClass('mfp-s-'+_prevStatus);
  16155. }
  16156. if(!text && status === 'loading') {
  16157. text = mfp.st.tLoading;
  16158. }
  16159. var data = {
  16160. status: status,
  16161. text: text
  16162. };
  16163. // allows to modify status
  16164. _mfpTrigger('UpdateStatus', data);
  16165. status = data.status;
  16166. text = data.text;
  16167. mfp.preloader.html(text);
  16168. mfp.preloader.find('a').on('click', function(e) {
  16169. e.stopImmediatePropagation();
  16170. });
  16171. mfp.container.addClass('mfp-s-'+status);
  16172. _prevStatus = status;
  16173. }
  16174. },
  16175. /*
  16176. "Private" helpers that aren't private at all
  16177. */
  16178. // Check to close popup or not
  16179. // "target" is an element that was clicked
  16180. _checkIfClose: function(target) {
  16181. if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
  16182. return;
  16183. }
  16184. var closeOnContent = mfp.st.closeOnContentClick;
  16185. var closeOnBg = mfp.st.closeOnBgClick;
  16186. if(closeOnContent && closeOnBg) {
  16187. return true;
  16188. } else {
  16189. // We close the popup if click is on close button or on preloader. Or if there is no content.
  16190. if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
  16191. return true;
  16192. }
  16193. // if click is outside the content
  16194. if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
  16195. if(closeOnBg) {
  16196. // last check, if the clicked element is in DOM, (in case it's removed onclick)
  16197. if( $.contains(document, target) ) {
  16198. return true;
  16199. }
  16200. }
  16201. } else if(closeOnContent) {
  16202. return true;
  16203. }
  16204. }
  16205. return false;
  16206. },
  16207. _addClassToMFP: function(cName) {
  16208. mfp.bgOverlay.addClass(cName);
  16209. mfp.wrap.addClass(cName);
  16210. },
  16211. _removeClassFromMFP: function(cName) {
  16212. this.bgOverlay.removeClass(cName);
  16213. mfp.wrap.removeClass(cName);
  16214. },
  16215. _hasScrollBar: function(winHeight) {
  16216. return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) );
  16217. },
  16218. _setFocus: function() {
  16219. (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
  16220. },
  16221. _onFocusIn: function(e) {
  16222. if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
  16223. mfp._setFocus();
  16224. return false;
  16225. }
  16226. },
  16227. _parseMarkup: function(template, values, item) {
  16228. var arr;
  16229. if(item.data) {
  16230. values = $.extend(item.data, values);
  16231. }
  16232. _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] );
  16233. $.each(values, function(key, value) {
  16234. if(value === undefined || value === false) {
  16235. return true;
  16236. }
  16237. arr = key.split('_');
  16238. if(arr.length > 1) {
  16239. var el = template.find(EVENT_NS + '-'+arr[0]);
  16240. if(el.length > 0) {
  16241. var attr = arr[1];
  16242. if(attr === 'replaceWith') {
  16243. if(el[0] !== value[0]) {
  16244. el.replaceWith(value);
  16245. }
  16246. } else if(attr === 'img') {
  16247. if(el.is('img')) {
  16248. el.attr('src', value);
  16249. } else {
  16250. el.replaceWith( $('<img>').attr('src', value).attr('class', el.attr('class')) );
  16251. }
  16252. } else {
  16253. el.attr(arr[1], value);
  16254. }
  16255. }
  16256. } else {
  16257. template.find(EVENT_NS + '-'+key).html(value);
  16258. }
  16259. });
  16260. },
  16261. _getScrollbarSize: function() {
  16262. // thx David
  16263. if(mfp.scrollbarSize === undefined) {
  16264. var scrollDiv = document.createElement("div");
  16265. scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
  16266. document.body.appendChild(scrollDiv);
  16267. mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
  16268. document.body.removeChild(scrollDiv);
  16269. }
  16270. return mfp.scrollbarSize;
  16271. }
  16272. }; /* MagnificPopup core prototype end */
  16273. /**
  16274. * Public static functions
  16275. */
  16276. $.magnificPopup = {
  16277. instance: null,
  16278. proto: MagnificPopup.prototype,
  16279. modules: [],
  16280. open: function(options, index) {
  16281. _checkInstance();
  16282. if(!options) {
  16283. options = {};
  16284. } else {
  16285. options = $.extend(true, {}, options);
  16286. }
  16287. options.isObj = true;
  16288. options.index = index || 0;
  16289. return this.instance.open(options);
  16290. },
  16291. close: function() {
  16292. return $.magnificPopup.instance && $.magnificPopup.instance.close();
  16293. },
  16294. registerModule: function(name, module) {
  16295. if(module.options) {
  16296. $.magnificPopup.defaults[name] = module.options;
  16297. }
  16298. $.extend(this.proto, module.proto);
  16299. this.modules.push(name);
  16300. },
  16301. defaults: {
  16302. // Info about options is in docs:
  16303. // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
  16304. disableOn: 0,
  16305. key: null,
  16306. midClick: false,
  16307. mainClass: '',
  16308. preloader: true,
  16309. focus: '', // CSS selector of input to focus after popup is opened
  16310. closeOnContentClick: false,
  16311. closeOnBgClick: true,
  16312. closeBtnInside: true,
  16313. showCloseBtn: true,
  16314. enableEscapeKey: true,
  16315. modal: false,
  16316. alignTop: false,
  16317. removalDelay: 0,
  16318. prependTo: null,
  16319. fixedContentPos: 'auto',
  16320. fixedBgPos: 'auto',
  16321. overflowY: 'auto',
  16322. closeMarkup: '<button title="%title%" type="button" class="mfp-close">&#215;</button>',
  16323. tClose: 'Close (Esc)',
  16324. tLoading: 'Loading...',
  16325. autoFocusLast: true
  16326. }
  16327. };
  16328. $.fn.magnificPopup = function(options) {
  16329. _checkInstance();
  16330. var jqEl = $(this);
  16331. // We call some API method of first param is a string
  16332. if (typeof options === "string" ) {
  16333. if(options === 'open') {
  16334. var items,
  16335. itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
  16336. index = parseInt(arguments[1], 10) || 0;
  16337. if(itemOpts.items) {
  16338. items = itemOpts.items[index];
  16339. } else {
  16340. items = jqEl;
  16341. if(itemOpts.delegate) {
  16342. items = items.find(itemOpts.delegate);
  16343. }
  16344. items = items.eq( index );
  16345. }
  16346. mfp._openClick({mfpEl:items}, jqEl, itemOpts);
  16347. } else {
  16348. if(mfp.isOpen)
  16349. mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
  16350. }
  16351. } else {
  16352. // clone options obj
  16353. options = $.extend(true, {}, options);
  16354. /*
  16355. * As Zepto doesn't support .data() method for objects
  16356. * and it works only in normal browsers
  16357. * we assign "options" object directly to the DOM element. FTW!
  16358. */
  16359. if(_isJQ) {
  16360. jqEl.data('magnificPopup', options);
  16361. } else {
  16362. jqEl[0].magnificPopup = options;
  16363. }
  16364. mfp.addGroup(jqEl, options);
  16365. }
  16366. return jqEl;
  16367. };
  16368. /*>>core*/
  16369. /*>>inline*/
  16370. var INLINE_NS = 'inline',
  16371. _hiddenClass,
  16372. _inlinePlaceholder,
  16373. _lastInlineElement,
  16374. _putInlineElementsBack = function() {
  16375. if(_lastInlineElement) {
  16376. _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
  16377. _lastInlineElement = null;
  16378. }
  16379. };
  16380. $.magnificPopup.registerModule(INLINE_NS, {
  16381. options: {
  16382. hiddenClass: 'hide', // will be appended with `mfp-` prefix
  16383. markup: '',
  16384. tNotFound: 'Content not found'
  16385. },
  16386. proto: {
  16387. initInline: function() {
  16388. mfp.types.push(INLINE_NS);
  16389. _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
  16390. _putInlineElementsBack();
  16391. });
  16392. },
  16393. getInline: function(item, template) {
  16394. _putInlineElementsBack();
  16395. if(item.src) {
  16396. var inlineSt = mfp.st.inline,
  16397. el = $(item.src);
  16398. if(el.length) {
  16399. // If target element has parent - we replace it with placeholder and put it back after popup is closed
  16400. var parent = el[0].parentNode;
  16401. if(parent && parent.tagName) {
  16402. if(!_inlinePlaceholder) {
  16403. _hiddenClass = inlineSt.hiddenClass;
  16404. _inlinePlaceholder = _getEl(_hiddenClass);
  16405. _hiddenClass = 'mfp-'+_hiddenClass;
  16406. }
  16407. // replace target inline element with placeholder
  16408. _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
  16409. }
  16410. mfp.updateStatus('ready');
  16411. } else {
  16412. mfp.updateStatus('error', inlineSt.tNotFound);
  16413. el = $('<div>');
  16414. }
  16415. item.inlineElement = el;
  16416. return el;
  16417. }
  16418. mfp.updateStatus('ready');
  16419. mfp._parseMarkup(template, {}, item);
  16420. return template;
  16421. }
  16422. }
  16423. });
  16424. /*>>inline*/
  16425. /*>>ajax*/
  16426. var AJAX_NS = 'ajax',
  16427. _ajaxCur,
  16428. _removeAjaxCursor = function() {
  16429. if(_ajaxCur) {
  16430. $(document.body).removeClass(_ajaxCur);
  16431. }
  16432. },
  16433. _destroyAjaxRequest = function() {
  16434. _removeAjaxCursor();
  16435. if(mfp.req) {
  16436. mfp.req.abort();
  16437. }
  16438. };
  16439. $.magnificPopup.registerModule(AJAX_NS, {
  16440. options: {
  16441. settings: null,
  16442. cursor: 'mfp-ajax-cur',
  16443. tError: '<a href="%url%">The content</a> could not be loaded.'
  16444. },
  16445. proto: {
  16446. initAjax: function() {
  16447. mfp.types.push(AJAX_NS);
  16448. _ajaxCur = mfp.st.ajax.cursor;
  16449. _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest);
  16450. _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest);
  16451. },
  16452. getAjax: function(item) {
  16453. if(_ajaxCur) {
  16454. $(document.body).addClass(_ajaxCur);
  16455. }
  16456. mfp.updateStatus('loading');
  16457. var opts = $.extend({
  16458. url: item.src,
  16459. success: function(data, textStatus, jqXHR) {
  16460. var temp = {
  16461. data:data,
  16462. xhr:jqXHR
  16463. };
  16464. _mfpTrigger('ParseAjax', temp);
  16465. mfp.appendContent( $(temp.data), AJAX_NS );
  16466. item.finished = true;
  16467. _removeAjaxCursor();
  16468. mfp._setFocus();
  16469. setTimeout(function() {
  16470. mfp.wrap.addClass(READY_CLASS);
  16471. }, 16);
  16472. mfp.updateStatus('ready');
  16473. _mfpTrigger('AjaxContentAdded');
  16474. },
  16475. error: function() {
  16476. _removeAjaxCursor();
  16477. item.finished = item.loadError = true;
  16478. mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src));
  16479. }
  16480. }, mfp.st.ajax.settings);
  16481. mfp.req = $.ajax(opts);
  16482. return '';
  16483. }
  16484. }
  16485. });
  16486. /*>>ajax*/
  16487. /*>>image*/
  16488. var _imgInterval,
  16489. _getTitle = function(item) {
  16490. if(item.data && item.data.title !== undefined)
  16491. return item.data.title;
  16492. var src = mfp.st.image.titleSrc;
  16493. if(src) {
  16494. if($.isFunction(src)) {
  16495. return src.call(mfp, item);
  16496. } else if(item.el) {
  16497. return item.el.attr(src) || '';
  16498. }
  16499. }
  16500. return '';
  16501. };
  16502. $.magnificPopup.registerModule('image', {
  16503. options: {
  16504. markup: '<div class="mfp-figure">'+
  16505. '<div class="mfp-close"></div>'+
  16506. '<figure>'+
  16507. '<div class="mfp-img"></div>'+
  16508. '<figcaption>'+
  16509. '<div class="mfp-bottom-bar">'+
  16510. '<div class="mfp-title"></div>'+
  16511. '<div class="mfp-counter"></div>'+
  16512. '</div>'+
  16513. '</figcaption>'+
  16514. '</figure>'+
  16515. '</div>',
  16516. cursor: 'mfp-zoom-out-cur',
  16517. titleSrc: 'title',
  16518. verticalFit: true,
  16519. tError: '<a href="%url%">The image</a> could not be loaded.'
  16520. },
  16521. proto: {
  16522. initImage: function() {
  16523. var imgSt = mfp.st.image,
  16524. ns = '.image';
  16525. mfp.types.push('image');
  16526. _mfpOn(OPEN_EVENT+ns, function() {
  16527. if(mfp.currItem.type === 'image' && imgSt.cursor) {
  16528. $(document.body).addClass(imgSt.cursor);
  16529. }
  16530. });
  16531. _mfpOn(CLOSE_EVENT+ns, function() {
  16532. if(imgSt.cursor) {
  16533. $(document.body).removeClass(imgSt.cursor);
  16534. }
  16535. _window.off('resize' + EVENT_NS);
  16536. });
  16537. _mfpOn('Resize'+ns, mfp.resizeImage);
  16538. if(mfp.isLowIE) {
  16539. _mfpOn('AfterChange', mfp.resizeImage);
  16540. }
  16541. },
  16542. resizeImage: function() {
  16543. var item = mfp.currItem;
  16544. if(!item || !item.img) return;
  16545. if(mfp.st.image.verticalFit) {
  16546. var decr = 0;
  16547. // fix box-sizing in ie7/8
  16548. if(mfp.isLowIE) {
  16549. decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10);
  16550. }
  16551. item.img.css('max-height', mfp.wH-decr);
  16552. }
  16553. },
  16554. _onImageHasSize: function(item) {
  16555. if(item.img) {
  16556. item.hasSize = true;
  16557. if(_imgInterval) {
  16558. clearInterval(_imgInterval);
  16559. }
  16560. item.isCheckingImgSize = false;
  16561. _mfpTrigger('ImageHasSize', item);
  16562. if(item.imgHidden) {
  16563. if(mfp.content)
  16564. mfp.content.removeClass('mfp-loading');
  16565. item.imgHidden = false;
  16566. }
  16567. }
  16568. },
  16569. /**
  16570. * Function that loops until the image has size to display elements that rely on it asap
  16571. */
  16572. findImageSize: function(item) {
  16573. var counter = 0,
  16574. img = item.img[0],
  16575. mfpSetInterval = function(delay) {
  16576. if(_imgInterval) {
  16577. clearInterval(_imgInterval);
  16578. }
  16579. // decelerating interval that checks for size of an image
  16580. _imgInterval = setInterval(function() {
  16581. if(img.naturalWidth > 0) {
  16582. mfp._onImageHasSize(item);
  16583. return;
  16584. }
  16585. if(counter > 200) {
  16586. clearInterval(_imgInterval);
  16587. }
  16588. counter++;
  16589. if(counter === 3) {
  16590. mfpSetInterval(10);
  16591. } else if(counter === 40) {
  16592. mfpSetInterval(50);
  16593. } else if(counter === 100) {
  16594. mfpSetInterval(500);
  16595. }
  16596. }, delay);
  16597. };
  16598. mfpSetInterval(1);
  16599. },
  16600. getImage: function(item, template) {
  16601. var guard = 0,
  16602. // image load complete handler
  16603. onLoadComplete = function() {
  16604. if(item) {
  16605. if (item.img[0].complete) {
  16606. item.img.off('.mfploader');
  16607. if(item === mfp.currItem){
  16608. mfp._onImageHasSize(item);
  16609. mfp.updateStatus('ready');
  16610. }
  16611. item.hasSize = true;
  16612. item.loaded = true;
  16613. _mfpTrigger('ImageLoadComplete');
  16614. }
  16615. else {
  16616. // if image complete check fails 200 times (20 sec), we assume that there was an error.
  16617. guard++;
  16618. if(guard < 200) {
  16619. setTimeout(onLoadComplete,100);
  16620. } else {
  16621. onLoadError();
  16622. }
  16623. }
  16624. }
  16625. },
  16626. // image error handler
  16627. onLoadError = function() {
  16628. if(item) {
  16629. item.img.off('.mfploader');
  16630. if(item === mfp.currItem){
  16631. mfp._onImageHasSize(item);
  16632. mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
  16633. }
  16634. item.hasSize = true;
  16635. item.loaded = true;
  16636. item.loadError = true;
  16637. }
  16638. },
  16639. imgSt = mfp.st.image;
  16640. var el = template.find('.mfp-img');
  16641. if(el.length) {
  16642. var img = document.createElement('img');
  16643. img.className = 'mfp-img';
  16644. if(item.el && item.el.find('img').length) {
  16645. img.alt = item.el.find('img').attr('alt');
  16646. }
  16647. item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError);
  16648. img.src = item.src;
  16649. // without clone() "error" event is not firing when IMG is replaced by new IMG
  16650. // TODO: find a way to avoid such cloning
  16651. if(el.is('img')) {
  16652. item.img = item.img.clone();
  16653. }
  16654. img = item.img[0];
  16655. if(img.naturalWidth > 0) {
  16656. item.hasSize = true;
  16657. } else if(!img.width) {
  16658. item.hasSize = false;
  16659. }
  16660. }
  16661. mfp._parseMarkup(template, {
  16662. title: _getTitle(item),
  16663. img_replaceWith: item.img
  16664. }, item);
  16665. mfp.resizeImage();
  16666. if(item.hasSize) {
  16667. if(_imgInterval) clearInterval(_imgInterval);
  16668. if(item.loadError) {
  16669. template.addClass('mfp-loading');
  16670. mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
  16671. } else {
  16672. template.removeClass('mfp-loading');
  16673. mfp.updateStatus('ready');
  16674. }
  16675. return template;
  16676. }
  16677. mfp.updateStatus('loading');
  16678. item.loading = true;
  16679. if(!item.hasSize) {
  16680. item.imgHidden = true;
  16681. template.addClass('mfp-loading');
  16682. mfp.findImageSize(item);
  16683. }
  16684. return template;
  16685. }
  16686. }
  16687. });
  16688. /*>>image*/
  16689. /*>>zoom*/
  16690. var hasMozTransform,
  16691. getHasMozTransform = function() {
  16692. if(hasMozTransform === undefined) {
  16693. hasMozTransform = document.createElement('p').style.MozTransform !== undefined;
  16694. }
  16695. return hasMozTransform;
  16696. };
  16697. $.magnificPopup.registerModule('zoom', {
  16698. options: {
  16699. enabled: false,
  16700. easing: 'ease-in-out',
  16701. duration: 300,
  16702. opener: function(element) {
  16703. return element.is('img') ? element : element.find('img');
  16704. }
  16705. },
  16706. proto: {
  16707. initZoom: function() {
  16708. var zoomSt = mfp.st.zoom,
  16709. ns = '.zoom',
  16710. image;
  16711. if(!zoomSt.enabled || !mfp.supportsTransition) {
  16712. return;
  16713. }
  16714. var duration = zoomSt.duration,
  16715. getElToAnimate = function(image) {
  16716. var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'),
  16717. transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing,
  16718. cssObj = {
  16719. position: 'fixed',
  16720. zIndex: 9999,
  16721. left: 0,
  16722. top: 0,
  16723. '-webkit-backface-visibility': 'hidden'
  16724. },
  16725. t = 'transition';
  16726. cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition;
  16727. newImg.css(cssObj);
  16728. return newImg;
  16729. },
  16730. showMainContent = function() {
  16731. mfp.content.css('visibility', 'visible');
  16732. },
  16733. openTimeout,
  16734. animatedImg;
  16735. _mfpOn('BuildControls'+ns, function() {
  16736. if(mfp._allowZoom()) {
  16737. clearTimeout(openTimeout);
  16738. mfp.content.css('visibility', 'hidden');
  16739. // Basically, all code below does is clones existing image, puts in on top of the current one and animated it
  16740. image = mfp._getItemToZoom();
  16741. if(!image) {
  16742. showMainContent();
  16743. return;
  16744. }
  16745. animatedImg = getElToAnimate(image);
  16746. animatedImg.css( mfp._getOffset() );
  16747. mfp.wrap.append(animatedImg);
  16748. openTimeout = setTimeout(function() {
  16749. animatedImg.css( mfp._getOffset( true ) );
  16750. openTimeout = setTimeout(function() {
  16751. showMainContent();
  16752. setTimeout(function() {
  16753. animatedImg.remove();
  16754. image = animatedImg = null;
  16755. _mfpTrigger('ZoomAnimationEnded');
  16756. }, 16); // avoid blink when switching images
  16757. }, duration); // this timeout equals animation duration
  16758. }, 16); // by adding this timeout we avoid short glitch at the beginning of animation
  16759. // Lots of timeouts...
  16760. }
  16761. });
  16762. _mfpOn(BEFORE_CLOSE_EVENT+ns, function() {
  16763. if(mfp._allowZoom()) {
  16764. clearTimeout(openTimeout);
  16765. mfp.st.removalDelay = duration;
  16766. if(!image) {
  16767. image = mfp._getItemToZoom();
  16768. if(!image) {
  16769. return;
  16770. }
  16771. animatedImg = getElToAnimate(image);
  16772. }
  16773. animatedImg.css( mfp._getOffset(true) );
  16774. mfp.wrap.append(animatedImg);
  16775. mfp.content.css('visibility', 'hidden');
  16776. setTimeout(function() {
  16777. animatedImg.css( mfp._getOffset() );
  16778. }, 16);
  16779. }
  16780. });
  16781. _mfpOn(CLOSE_EVENT+ns, function() {
  16782. if(mfp._allowZoom()) {
  16783. showMainContent();
  16784. if(animatedImg) {
  16785. animatedImg.remove();
  16786. }
  16787. image = null;
  16788. }
  16789. });
  16790. },
  16791. _allowZoom: function() {
  16792. return mfp.currItem.type === 'image';
  16793. },
  16794. _getItemToZoom: function() {
  16795. if(mfp.currItem.hasSize) {
  16796. return mfp.currItem.img;
  16797. } else {
  16798. return false;
  16799. }
  16800. },
  16801. // Get element postion relative to viewport
  16802. _getOffset: function(isLarge) {
  16803. var el;
  16804. if(isLarge) {
  16805. el = mfp.currItem.img;
  16806. } else {
  16807. el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
  16808. }
  16809. var offset = el.offset();
  16810. var paddingTop = parseInt(el.css('padding-top'),10);
  16811. var paddingBottom = parseInt(el.css('padding-bottom'),10);
  16812. offset.top -= ( $(window).scrollTop() - paddingTop );
  16813. /*
  16814. Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
  16815. */
  16816. var obj = {
  16817. width: el.width(),
  16818. // fix Zepto height+padding issue
  16819. height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
  16820. };
  16821. // I hate to do this, but there is no another option
  16822. if( getHasMozTransform() ) {
  16823. obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
  16824. } else {
  16825. obj.left = offset.left;
  16826. obj.top = offset.top;
  16827. }
  16828. return obj;
  16829. }
  16830. }
  16831. });
  16832. /*>>zoom*/
  16833. /*>>iframe*/
  16834. var IFRAME_NS = 'iframe',
  16835. _emptyPage = '//about:blank',
  16836. _fixIframeBugs = function(isShowing) {
  16837. if(mfp.currTemplate[IFRAME_NS]) {
  16838. var el = mfp.currTemplate[IFRAME_NS].find('iframe');
  16839. if(el.length) {
  16840. // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug
  16841. if(!isShowing) {
  16842. el[0].src = _emptyPage;
  16843. }
  16844. // IE8 black screen bug fix
  16845. if(mfp.isIE8) {
  16846. el.css('display', isShowing ? 'block' : 'none');
  16847. }
  16848. }
  16849. }
  16850. };
  16851. $.magnificPopup.registerModule(IFRAME_NS, {
  16852. options: {
  16853. markup: '<div class="mfp-iframe-scaler">'+
  16854. '<div class="mfp-close"></div>'+
  16855. '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
  16856. '</div>',
  16857. srcAction: 'iframe_src',
  16858. // we don't care and support only one default type of URL by default
  16859. patterns: {
  16860. youtube: {
  16861. index: 'youtube.com',
  16862. id: 'v=',
  16863. src: '//www.youtube.com/embed/%id%?autoplay=1'
  16864. },
  16865. vimeo: {
  16866. index: 'vimeo.com/',
  16867. id: '/',
  16868. src: '//player.vimeo.com/video/%id%?autoplay=1'
  16869. },
  16870. gmaps: {
  16871. index: '//maps.google.',
  16872. src: '%id%&output=embed'
  16873. }
  16874. }
  16875. },
  16876. proto: {
  16877. initIframe: function() {
  16878. mfp.types.push(IFRAME_NS);
  16879. _mfpOn('BeforeChange', function(e, prevType, newType) {
  16880. if(prevType !== newType) {
  16881. if(prevType === IFRAME_NS) {
  16882. _fixIframeBugs(); // iframe if removed
  16883. } else if(newType === IFRAME_NS) {
  16884. _fixIframeBugs(true); // iframe is showing
  16885. }
  16886. }// else {
  16887. // iframe source is switched, don't do anything
  16888. //}
  16889. });
  16890. _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
  16891. _fixIframeBugs();
  16892. });
  16893. },
  16894. getIframe: function(item, template) {
  16895. var embedSrc = item.src;
  16896. var iframeSt = mfp.st.iframe;
  16897. $.each(iframeSt.patterns, function() {
  16898. if(embedSrc.indexOf( this.index ) > -1) {
  16899. if(this.id) {
  16900. if(typeof this.id === 'string') {
  16901. embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);
  16902. } else {
  16903. embedSrc = this.id.call( this, embedSrc );
  16904. }
  16905. }
  16906. embedSrc = this.src.replace('%id%', embedSrc );
  16907. return false; // break;
  16908. }
  16909. });
  16910. var dataObj = {};
  16911. if(iframeSt.srcAction) {
  16912. dataObj[iframeSt.srcAction] = embedSrc;
  16913. }
  16914. mfp._parseMarkup(template, dataObj, item);
  16915. mfp.updateStatus('ready');
  16916. return template;
  16917. }
  16918. }
  16919. });
  16920. /*>>iframe*/
  16921. /*>>gallery*/
  16922. /**
  16923. * Get looped index depending on number of slides
  16924. */
  16925. var _getLoopedId = function(index) {
  16926. var numSlides = mfp.items.length;
  16927. if(index > numSlides - 1) {
  16928. return index - numSlides;
  16929. } else if(index < 0) {
  16930. return numSlides + index;
  16931. }
  16932. return index;
  16933. },
  16934. _replaceCurrTotal = function(text, curr, total) {
  16935. return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total);
  16936. };
  16937. $.magnificPopup.registerModule('gallery', {
  16938. options: {
  16939. enabled: false,
  16940. arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
  16941. preload: [0,2],
  16942. navigateByImgClick: true,
  16943. arrows: true,
  16944. tPrev: 'Previous (Left arrow key)',
  16945. tNext: 'Next (Right arrow key)',
  16946. tCounter: '%curr% of %total%'
  16947. },
  16948. proto: {
  16949. initGallery: function() {
  16950. var gSt = mfp.st.gallery,
  16951. ns = '.mfp-gallery';
  16952. mfp.direction = true; // true - next, false - prev
  16953. if(!gSt || !gSt.enabled ) return false;
  16954. _wrapClasses += ' mfp-gallery';
  16955. _mfpOn(OPEN_EVENT+ns, function() {
  16956. if(gSt.navigateByImgClick) {
  16957. mfp.wrap.on('click'+ns, '.mfp-img', function() {
  16958. if(mfp.items.length > 1) {
  16959. mfp.next();
  16960. return false;
  16961. }
  16962. });
  16963. }
  16964. _document.on('keydown'+ns, function(e) {
  16965. if (e.keyCode === 37) {
  16966. mfp.prev();
  16967. } else if (e.keyCode === 39) {
  16968. mfp.next();
  16969. }
  16970. });
  16971. });
  16972. _mfpOn('UpdateStatus'+ns, function(e, data) {
  16973. if(data.text) {
  16974. data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length);
  16975. }
  16976. });
  16977. _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
  16978. var l = mfp.items.length;
  16979. values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
  16980. });
  16981. _mfpOn('BuildControls' + ns, function() {
  16982. if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
  16983. var markup = gSt.arrowMarkup,
  16984. arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS),
  16985. arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS);
  16986. arrowLeft.click(function() {
  16987. mfp.prev();
  16988. });
  16989. arrowRight.click(function() {
  16990. mfp.next();
  16991. });
  16992. mfp.container.append(arrowLeft.add(arrowRight));
  16993. }
  16994. });
  16995. _mfpOn(CHANGE_EVENT+ns, function() {
  16996. if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout);
  16997. mfp._preloadTimeout = setTimeout(function() {
  16998. mfp.preloadNearbyImages();
  16999. mfp._preloadTimeout = null;
  17000. }, 16);
  17001. });
  17002. _mfpOn(CLOSE_EVENT+ns, function() {
  17003. _document.off(ns);
  17004. mfp.wrap.off('click'+ns);
  17005. mfp.arrowRight = mfp.arrowLeft = null;
  17006. });
  17007. },
  17008. next: function() {
  17009. mfp.direction = true;
  17010. mfp.index = _getLoopedId(mfp.index + 1);
  17011. mfp.updateItemHTML();
  17012. },
  17013. prev: function() {
  17014. mfp.direction = false;
  17015. mfp.index = _getLoopedId(mfp.index - 1);
  17016. mfp.updateItemHTML();
  17017. },
  17018. goTo: function(newIndex) {
  17019. mfp.direction = (newIndex >= mfp.index);
  17020. mfp.index = newIndex;
  17021. mfp.updateItemHTML();
  17022. },
  17023. preloadNearbyImages: function() {
  17024. var p = mfp.st.gallery.preload,
  17025. preloadBefore = Math.min(p[0], mfp.items.length),
  17026. preloadAfter = Math.min(p[1], mfp.items.length),
  17027. i;
  17028. for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) {
  17029. mfp._preloadItem(mfp.index+i);
  17030. }
  17031. for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) {
  17032. mfp._preloadItem(mfp.index-i);
  17033. }
  17034. },
  17035. _preloadItem: function(index) {
  17036. index = _getLoopedId(index);
  17037. if(mfp.items[index].preloaded) {
  17038. return;
  17039. }
  17040. var item = mfp.items[index];
  17041. if(!item.parsed) {
  17042. item = mfp.parseEl( index );
  17043. }
  17044. _mfpTrigger('LazyLoad', item);
  17045. if(item.type === 'image') {
  17046. item.img = $('<img class="mfp-img" />').on('load.mfploader', function() {
  17047. item.hasSize = true;
  17048. }).on('error.mfploader', function() {
  17049. item.hasSize = true;
  17050. item.loadError = true;
  17051. _mfpTrigger('LazyLoadError', item);
  17052. }).attr('src', item.src);
  17053. }
  17054. item.preloaded = true;
  17055. }
  17056. }
  17057. });
  17058. /*>>gallery*/
  17059. /*>>retina*/
  17060. var RETINA_NS = 'retina';
  17061. $.magnificPopup.registerModule(RETINA_NS, {
  17062. options: {
  17063. replaceSrc: function(item) {
  17064. return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; });
  17065. },
  17066. ratio: 1 // Function or number. Set to 1 to disable.
  17067. },
  17068. proto: {
  17069. initRetina: function() {
  17070. if(window.devicePixelRatio > 1) {
  17071. var st = mfp.st.retina,
  17072. ratio = st.ratio;
  17073. ratio = !isNaN(ratio) ? ratio : ratio();
  17074. if(ratio > 1) {
  17075. _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
  17076. item.img.css({
  17077. 'max-width': item.img[0].naturalWidth / ratio,
  17078. 'width': '100%'
  17079. });
  17080. });
  17081. _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
  17082. item.src = st.replaceSrc(item, ratio);
  17083. });
  17084. }
  17085. }
  17086. }
  17087. }
  17088. });
  17089. /*>>retina*/
  17090. _checkInstance(); }));
  17091. /*!
  17092. Custom scrollbar
  17093. Version: 3.1.13
  17094. Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
  17095. License: Copyright Manos Malihutsakis | Released under the MIT license
  17096. !*/
  17097. !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
  17098. /*!
  17099. Custom scrollbar
  17100. Version: 3.1.5
  17101. Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller
  17102. License: Copyright Manos Malihutsakis | Released under the MIT license
  17103. !*/
  17104. !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e:e(jQuery,window,document)}(function(e){!function(t){var o="function"==typeof define&&define.amd,a="undefined"!=typeof module&&module.exports,n="https:"==document.location.protocol?"https:":"http:",i="cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js";o||(a?require("jquery-mousewheel")(e):e.event.special.mousewheel||e("head").append(decodeURI("%3Cscript src="+n+"//"+i+"%3E%3C/script%3E"))),t()}(function(){var t,o="mCustomScrollbar",a="mCS",n=".mCustomScrollbar",i={setTop:0,setLeft:0,axis:"y",scrollbarPosition:"inside",scrollInertia:950,autoDraggerLength:!0,alwaysShowScrollbar:0,snapOffset:0,mouseWheel:{enable:!0,scrollAmount:"auto",axis:"y",deltaFactor:"auto",disableOver:["select","option","keygen","datalist","textarea"]},scrollButtons:{scrollType:"stepless",scrollAmount:"auto"},keyboard:{enable:!0,scrollType:"stepless",scrollAmount:"auto"},contentTouchScroll:25,documentTouchScroll:!0,advanced:{autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",updateOnContentResize:!0,updateOnImageLoad:"auto",autoUpdateTimeout:60},theme:"light",callbacks:{onTotalScrollOffset:0,onTotalScrollBackOffset:0,alwaysTriggerOffsets:!0}},r=0,l={},s=window.attachEvent&&!window.addEventListener?1:0,c=!1,d=["mCSB_dragger_onDrag","mCSB_scrollTools_onDrag","mCS_img_loaded","mCS_disabled","mCS_destroyed","mCS_no_scrollbar","mCS-autoHide","mCS-dir-rtl","mCS_no_scrollbar_y","mCS_no_scrollbar_x","mCS_y_hidden","mCS_x_hidden","mCSB_draggerContainer","mCSB_buttonUp","mCSB_buttonDown","mCSB_buttonLeft","mCSB_buttonRight"],u={init:function(t){var t=e.extend(!0,{},i,t),o=f.call(this);if(t.live){var s=t.liveSelector||this.selector||n,c=e(s);if("off"===t.live)return void m(s);l[s]=setTimeout(function(){c.mCustomScrollbar(t),"once"===t.live&&c.length&&m(s)},500)}else m(s);return t.setWidth=t.set_width?t.set_width:t.setWidth,t.setHeight=t.set_height?t.set_height:t.setHeight,t.axis=t.horizontalScroll?"x":p(t.axis),t.scrollInertia=t.scrollInertia>0&&t.scrollInertia<17?17:t.scrollInertia,"object"!=typeof t.mouseWheel&&1==t.mouseWheel&&(t.mouseWheel={enable:!0,scrollAmount:"auto",axis:"y",preventDefault:!1,deltaFactor:"auto",normalizeDelta:!1,invert:!1}),t.mouseWheel.scrollAmount=t.mouseWheelPixels?t.mouseWheelPixels:t.mouseWheel.scrollAmount,t.mouseWheel.normalizeDelta=t.advanced.normalizeMouseWheelDelta?t.advanced.normalizeMouseWheelDelta:t.mouseWheel.normalizeDelta,t.scrollButtons.scrollType=g(t.scrollButtons.scrollType),h(t),e(o).each(function(){var o=e(this);if(!o.data(a)){o.data(a,{idx:++r,opt:t,scrollRatio:{y:null,x:null},overflowed:null,contentReset:{y:null,x:null},bindEvents:!1,tweenRunning:!1,sequential:{},langDir:o.css("direction"),cbOffsets:null,trigger:null,poll:{size:{o:0,n:0},img:{o:0,n:0},change:{o:0,n:0}}});var n=o.data(a),i=n.opt,l=o.data("mcs-axis"),s=o.data("mcs-scrollbar-position"),c=o.data("mcs-theme");l&&(i.axis=l),s&&(i.scrollbarPosition=s),c&&(i.theme=c,h(i)),v.call(this),n&&i.callbacks.onCreate&&"function"==typeof i.callbacks.onCreate&&i.callbacks.onCreate.call(this),e("#mCSB_"+n.idx+"_container img:not(."+d[2]+")").addClass(d[2]),u.update.call(null,o)}})},update:function(t,o){var n=t||f.call(this);return e(n).each(function(){var t=e(this);if(t.data(a)){var n=t.data(a),i=n.opt,r=e("#mCSB_"+n.idx+"_container"),l=e("#mCSB_"+n.idx),s=[e("#mCSB_"+n.idx+"_dragger_vertical"),e("#mCSB_"+n.idx+"_dragger_horizontal")];if(!r.length)return;n.tweenRunning&&Q(t),o&&n&&i.callbacks.onBeforeUpdate&&"function"==typeof i.callbacks.onBeforeUpdate&&i.callbacks.onBeforeUpdate.call(this),t.hasClass(d[3])&&t.removeClass(d[3]),t.hasClass(d[4])&&t.removeClass(d[4]),l.css("max-height","none"),l.height()!==t.height()&&l.css("max-height",t.height()),_.call(this),"y"===i.axis||i.advanced.autoExpandHorizontalScroll||r.css("width",x(r)),n.overflowed=y.call(this),M.call(this),i.autoDraggerLength&&S.call(this),b.call(this),T.call(this);var c=[Math.abs(r[0].offsetTop),Math.abs(r[0].offsetLeft)];"x"!==i.axis&&(n.overflowed[0]?s[0].height()>s[0].parent().height()?B.call(this):(G(t,c[0].toString(),{dir:"y",dur:0,overwrite:"none"}),n.contentReset.y=null):(B.call(this),"y"===i.axis?k.call(this):"yx"===i.axis&&n.overflowed[1]&&G(t,c[1].toString(),{dir:"x",dur:0,overwrite:"none"}))),"y"!==i.axis&&(n.overflowed[1]?s[1].width()>s[1].parent().width()?B.call(this):(G(t,c[1].toString(),{dir:"x",dur:0,overwrite:"none"}),n.contentReset.x=null):(B.call(this),"x"===i.axis?k.call(this):"yx"===i.axis&&n.overflowed[0]&&G(t,c[0].toString(),{dir:"y",dur:0,overwrite:"none"}))),o&&n&&(2===o&&i.callbacks.onImageLoad&&"function"==typeof i.callbacks.onImageLoad?i.callbacks.onImageLoad.call(this):3===o&&i.callbacks.onSelectorChange&&"function"==typeof i.callbacks.onSelectorChange?i.callbacks.onSelectorChange.call(this):i.callbacks.onUpdate&&"function"==typeof i.callbacks.onUpdate&&i.callbacks.onUpdate.call(this)),N.call(this)}})},scrollTo:function(t,o){if("undefined"!=typeof t&&null!=t){var n=f.call(this);return e(n).each(function(){var n=e(this);if(n.data(a)){var i=n.data(a),r=i.opt,l={trigger:"external",scrollInertia:r.scrollInertia,scrollEasing:"mcsEaseInOut",moveDragger:!1,timeout:60,callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},s=e.extend(!0,{},l,o),c=Y.call(this,t),d=s.scrollInertia>0&&s.scrollInertia<17?17:s.scrollInertia;c[0]=X.call(this,c[0],"y"),c[1]=X.call(this,c[1],"x"),s.moveDragger&&(c[0]*=i.scrollRatio.y,c[1]*=i.scrollRatio.x),s.dur=ne()?0:d,setTimeout(function(){null!==c[0]&&"undefined"!=typeof c[0]&&"x"!==r.axis&&i.overflowed[0]&&(s.dir="y",s.overwrite="all",G(n,c[0].toString(),s)),null!==c[1]&&"undefined"!=typeof c[1]&&"y"!==r.axis&&i.overflowed[1]&&(s.dir="x",s.overwrite="none",G(n,c[1].toString(),s))},s.timeout)}})}},stop:function(){var t=f.call(this);return e(t).each(function(){var t=e(this);t.data(a)&&Q(t)})},disable:function(t){var o=f.call(this);return e(o).each(function(){var o=e(this);if(o.data(a)){o.data(a);N.call(this,"remove"),k.call(this),t&&B.call(this),M.call(this,!0),o.addClass(d[3])}})},destroy:function(){var t=f.call(this);return e(t).each(function(){var n=e(this);if(n.data(a)){var i=n.data(a),r=i.opt,l=e("#mCSB_"+i.idx),s=e("#mCSB_"+i.idx+"_container"),c=e(".mCSB_"+i.idx+"_scrollbar");r.live&&m(r.liveSelector||e(t).selector),N.call(this,"remove"),k.call(this),B.call(this),n.removeData(a),$(this,"mcs"),c.remove(),s.find("img."+d[2]).removeClass(d[2]),l.replaceWith(s.contents()),n.removeClass(o+" _"+a+"_"+i.idx+" "+d[6]+" "+d[7]+" "+d[5]+" "+d[3]).addClass(d[4])}})}},f=function(){return"object"!=typeof e(this)||e(this).length<1?n:this},h=function(t){var o=["rounded","rounded-dark","rounded-dots","rounded-dots-dark"],a=["rounded-dots","rounded-dots-dark","3d","3d-dark","3d-thick","3d-thick-dark","inset","inset-dark","inset-2","inset-2-dark","inset-3","inset-3-dark"],n=["minimal","minimal-dark"],i=["minimal","minimal-dark"],r=["minimal","minimal-dark"];t.autoDraggerLength=e.inArray(t.theme,o)>-1?!1:t.autoDraggerLength,t.autoExpandScrollbar=e.inArray(t.theme,a)>-1?!1:t.autoExpandScrollbar,t.scrollButtons.enable=e.inArray(t.theme,n)>-1?!1:t.scrollButtons.enable,t.autoHideScrollbar=e.inArray(t.theme,i)>-1?!0:t.autoHideScrollbar,t.scrollbarPosition=e.inArray(t.theme,r)>-1?"outside":t.scrollbarPosition},m=function(e){l[e]&&(clearTimeout(l[e]),$(l,e))},p=function(e){return"yx"===e||"xy"===e||"auto"===e?"yx":"x"===e||"horizontal"===e?"x":"y"},g=function(e){return"stepped"===e||"pixels"===e||"step"===e||"click"===e?"stepped":"stepless"},v=function(){var t=e(this),n=t.data(a),i=n.opt,r=i.autoExpandScrollbar?" "+d[1]+"_expand":"",l=["<div id='mCSB_"+n.idx+"_scrollbar_vertical' class='mCSB_scrollTools mCSB_"+n.idx+"_scrollbar mCS-"+i.theme+" mCSB_scrollTools_vertical"+r+"'><div class='"+d[12]+"'><div id='mCSB_"+n.idx+"_dragger_vertical' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div></div><div class='mCSB_draggerRail' /></div>","<div id='mCSB_"+n.idx+"_scrollbar_horizontal' class='mCSB_scrollTools mCSB_"+n.idx+"_scrollbar mCS-"+i.theme+" mCSB_scrollTools_horizontal"+r+"'><div class='"+d[12]+"'><div id='mCSB_"+n.idx+"_dragger_horizontal' class='mCSB_dragger' style='position:absolute;'><div class='mCSB_dragger_bar' /></div></div><div class='mCSB_draggerRail' /></div>"],s="yx"===i.axis?"mCSB_vertical_horizontal":"x"===i.axis?"mCSB_horizontal":"mCSB_vertical",c="yx"===i.axis?l[0]+l[1]:"x"===i.axis?l[1]:l[0],u="yx"===i.axis?"<div id='mCSB_"+n.idx+"_container_wrapper' class='mCSB_container_wrapper' />":"",f=i.autoHideScrollbar?" "+d[6]:"",h="x"!==i.axis&&"rtl"===n.langDir?" "+d[7]:"";i.setWidth&&t.css("width",i.setWidth),i.setHeight&&t.css("height",i.setHeight),i.setLeft="y"!==i.axis&&"rtl"===n.langDir?"989999px":i.setLeft,t.addClass(o+" _"+a+"_"+n.idx+f+h).wrapInner("<div id='mCSB_"+n.idx+"' class='mCustomScrollBox mCS-"+i.theme+" "+s+"'><div id='mCSB_"+n.idx+"_container' class='mCSB_container' style='position:relative; top:"+i.setTop+"; left:"+i.setLeft+";' dir='"+n.langDir+"' /></div>");var m=e("#mCSB_"+n.idx),p=e("#mCSB_"+n.idx+"_container");"y"===i.axis||i.advanced.autoExpandHorizontalScroll||p.css("width",x(p)),"outside"===i.scrollbarPosition?("static"===t.css("position")&&t.css("position","relative"),t.css("overflow","visible"),m.addClass("mCSB_outside").after(c)):(m.addClass("mCSB_inside").append(c),p.wrap(u)),w.call(this);var g=[e("#mCSB_"+n.idx+"_dragger_vertical"),e("#mCSB_"+n.idx+"_dragger_horizontal")];g[0].css("min-height",g[0].height()),g[1].css("min-width",g[1].width())},x=function(t){var o=[t[0].scrollWidth,Math.max.apply(Math,t.children().map(function(){return e(this).outerWidth(!0)}).get())],a=t.parent().width();return o[0]>a?o[0]:o[1]>a?o[1]:"100%"},_=function(){var t=e(this),o=t.data(a),n=o.opt,i=e("#mCSB_"+o.idx+"_container");if(n.advanced.autoExpandHorizontalScroll&&"y"!==n.axis){i.css({width:"auto","min-width":0,"overflow-x":"scroll"});var r=Math.ceil(i[0].scrollWidth);3===n.advanced.autoExpandHorizontalScroll||2!==n.advanced.autoExpandHorizontalScroll&&r>i.parent().width()?i.css({width:r,"min-width":"100%","overflow-x":"inherit"}):i.css({"overflow-x":"inherit",position:"absolute"}).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({width:Math.ceil(i[0].getBoundingClientRect().right+.4)-Math.floor(i[0].getBoundingClientRect().left),"min-width":"100%",position:"relative"}).unwrap()}},w=function(){var t=e(this),o=t.data(a),n=o.opt,i=e(".mCSB_"+o.idx+"_scrollbar:first"),r=oe(n.scrollButtons.tabindex)?"tabindex='"+n.scrollButtons.tabindex+"'":"",l=["<a href='#' class='"+d[13]+"' "+r+" />","<a href='#' class='"+d[14]+"' "+r+" />","<a href='#' class='"+d[15]+"' "+r+" />","<a href='#' class='"+d[16]+"' "+r+" />"],s=["x"===n.axis?l[2]:l[0],"x"===n.axis?l[3]:l[1],l[2],l[3]];n.scrollButtons.enable&&i.prepend(s[0]).append(s[1]).next(".mCSB_scrollTools").prepend(s[2]).append(s[3])},S=function(){var t=e(this),o=t.data(a),n=e("#mCSB_"+o.idx),i=e("#mCSB_"+o.idx+"_container"),r=[e("#mCSB_"+o.idx+"_dragger_vertical"),e("#mCSB_"+o.idx+"_dragger_horizontal")],l=[n.height()/i.outerHeight(!1),n.width()/i.outerWidth(!1)],c=[parseInt(r[0].css("min-height")),Math.round(l[0]*r[0].parent().height()),parseInt(r[1].css("min-width")),Math.round(l[1]*r[1].parent().width())],d=s&&c[1]<c[0]?c[0]:c[1],u=s&&c[3]<c[2]?c[2]:c[3];r[0].css({height:d,"max-height":r[0].parent().height()-10}).find(".mCSB_dragger_bar").css({"line-height":c[0]+"px"}),r[1].css({width:u,"max-width":r[1].parent().width()-10})},b=function(){var t=e(this),o=t.data(a),n=e("#mCSB_"+o.idx),i=e("#mCSB_"+o.idx+"_container"),r=[e("#mCSB_"+o.idx+"_dragger_vertical"),e("#mCSB_"+o.idx+"_dragger_horizontal")],l=[i.outerHeight(!1)-n.height(),i.outerWidth(!1)-n.width()],s=[l[0]/(r[0].parent().height()-r[0].height()),l[1]/(r[1].parent().width()-r[1].width())];o.scrollRatio={y:s[0],x:s[1]}},C=function(e,t,o){var a=o?d[0]+"_expanded":"",n=e.closest(".mCSB_scrollTools");"active"===t?(e.toggleClass(d[0]+" "+a),n.toggleClass(d[1]),e[0]._draggable=e[0]._draggable?0:1):e[0]._draggable||("hide"===t?(e.removeClass(d[0]),n.removeClass(d[1])):(e.addClass(d[0]),n.addClass(d[1])))},y=function(){var t=e(this),o=t.data(a),n=e("#mCSB_"+o.idx),i=e("#mCSB_"+o.idx+"_container"),r=null==o.overflowed?i.height():i.outerHeight(!1),l=null==o.overflowed?i.width():i.outerWidth(!1),s=i[0].scrollHeight,c=i[0].scrollWidth;return s>r&&(r=s),c>l&&(l=c),[r>n.height(),l>n.width()]},B=function(){var t=e(this),o=t.data(a),n=o.opt,i=e("#mCSB_"+o.idx),r=e("#mCSB_"+o.idx+"_container"),l=[e("#mCSB_"+o.idx+"_dragger_vertical"),e("#mCSB_"+o.idx+"_dragger_horizontal")];if(Q(t),("x"!==n.axis&&!o.overflowed[0]||"y"===n.axis&&o.overflowed[0])&&(l[0].add(r).css("top",0),G(t,"_resetY")),"y"!==n.axis&&!o.overflowed[1]||"x"===n.axis&&o.overflowed[1]){var s=dx=0;"rtl"===o.langDir&&(s=i.width()-r.outerWidth(!1),dx=Math.abs(s/o.scrollRatio.x)),r.css("left",s),l[1].css("left",dx),G(t,"_resetX")}},T=function(){function t(){r=setTimeout(function(){e.event.special.mousewheel?(clearTimeout(r),W.call(o[0])):t()},100)}var o=e(this),n=o.data(a),i=n.opt;if(!n.bindEvents){if(I.call(this),i.contentTouchScroll&&D.call(this),E.call(this),i.mouseWheel.enable){var r;t()}P.call(this),U.call(this),i.advanced.autoScrollOnFocus&&H.call(this),i.scrollButtons.enable&&F.call(this),i.keyboard.enable&&q.call(this),n.bindEvents=!0}},k=function(){var t=e(this),o=t.data(a),n=o.opt,i=a+"_"+o.idx,r=".mCSB_"+o.idx+"_scrollbar",l=e("#mCSB_"+o.idx+",#mCSB_"+o.idx+"_container,#mCSB_"+o.idx+"_container_wrapper,"+r+" ."+d[12]+",#mCSB_"+o.idx+"_dragger_vertical,#mCSB_"+o.idx+"_dragger_horizontal,"+r+">a"),s=e("#mCSB_"+o.idx+"_container");n.advanced.releaseDraggableSelectors&&l.add(e(n.advanced.releaseDraggableSelectors)),n.advanced.extraDraggableSelectors&&l.add(e(n.advanced.extraDraggableSelectors)),o.bindEvents&&(e(document).add(e(!A()||top.document)).unbind("."+i),l.each(function(){e(this).unbind("."+i)}),clearTimeout(t[0]._focusTimeout),$(t[0],"_focusTimeout"),clearTimeout(o.sequential.step),$(o.sequential,"step"),clearTimeout(s[0].onCompleteTimeout),$(s[0],"onCompleteTimeout"),o.bindEvents=!1)},M=function(t){var o=e(this),n=o.data(a),i=n.opt,r=e("#mCSB_"+n.idx+"_container_wrapper"),l=r.length?r:e("#mCSB_"+n.idx+"_container"),s=[e("#mCSB_"+n.idx+"_scrollbar_vertical"),e("#mCSB_"+n.idx+"_scrollbar_horizontal")],c=[s[0].find(".mCSB_dragger"),s[1].find(".mCSB_dragger")];"x"!==i.axis&&(n.overflowed[0]&&!t?(s[0].add(c[0]).add(s[0].children("a")).css("display","block"),l.removeClass(d[8]+" "+d[10])):(i.alwaysShowScrollbar?(2!==i.alwaysShowScrollbar&&c[0].css("display","none"),l.removeClass(d[10])):(s[0].css("display","none"),l.addClass(d[10])),l.addClass(d[8]))),"y"!==i.axis&&(n.overflowed[1]&&!t?(s[1].add(c[1]).add(s[1].children("a")).css("display","block"),l.removeClass(d[9]+" "+d[11])):(i.alwaysShowScrollbar?(2!==i.alwaysShowScrollbar&&c[1].css("display","none"),l.removeClass(d[11])):(s[1].css("display","none"),l.addClass(d[11])),l.addClass(d[9]))),n.overflowed[0]||n.overflowed[1]?o.removeClass(d[5]):o.addClass(d[5])},O=function(t){var o=t.type,a=t.target.ownerDocument!==document&&null!==frameElement?[e(frameElement).offset().top,e(frameElement).offset().left]:null,n=A()&&t.target.ownerDocument!==top.document&&null!==frameElement?[e(t.view.frameElement).offset().top,e(t.view.frameElement).offset().left]:[0,0];switch(o){case"pointerdown":case"MSPointerDown":case"pointermove":case"MSPointerMove":case"pointerup":case"MSPointerUp":return a?[t.originalEvent.pageY-a[0]+n[0],t.originalEvent.pageX-a[1]+n[1],!1]:[t.originalEvent.pageY,t.originalEvent.pageX,!1];case"touchstart":case"touchmove":case"touchend":var i=t.originalEvent.touches[0]||t.originalEvent.changedTouches[0],r=t.originalEvent.touches.length||t.originalEvent.changedTouches.length;return t.target.ownerDocument!==document?[i.screenY,i.screenX,r>1]:[i.pageY,i.pageX,r>1];default:return a?[t.pageY-a[0]+n[0],t.pageX-a[1]+n[1],!1]:[t.pageY,t.pageX,!1]}},I=function(){function t(e,t,a,n){if(h[0].idleTimer=d.scrollInertia<233?250:0,o.attr("id")===f[1])var i="x",s=(o[0].offsetLeft-t+n)*l.scrollRatio.x;else var i="y",s=(o[0].offsetTop-e+a)*l.scrollRatio.y;G(r,s.toString(),{dir:i,drag:!0})}var o,n,i,r=e(this),l=r.data(a),d=l.opt,u=a+"_"+l.idx,f=["mCSB_"+l.idx+"_dragger_vertical","mCSB_"+l.idx+"_dragger_horizontal"],h=e("#mCSB_"+l.idx+"_container"),m=e("#"+f[0]+",#"+f[1]),p=d.advanced.releaseDraggableSelectors?m.add(e(d.advanced.releaseDraggableSelectors)):m,g=d.advanced.extraDraggableSelectors?e(!A()||top.document).add(e(d.advanced.extraDraggableSelectors)):e(!A()||top.document);m.bind("contextmenu."+u,function(e){e.preventDefault()}).bind("mousedown."+u+" touchstart."+u+" pointerdown."+u+" MSPointerDown."+u,function(t){if(t.stopImmediatePropagation(),t.preventDefault(),ee(t)){c=!0,s&&(document.onselectstart=function(){return!1}),L.call(h,!1),Q(r),o=e(this);var a=o.offset(),l=O(t)[0]-a.top,u=O(t)[1]-a.left,f=o.height()+a.top,m=o.width()+a.left;f>l&&l>0&&m>u&&u>0&&(n=l,i=u),C(o,"active",d.autoExpandScrollbar)}}).bind("touchmove."+u,function(e){e.stopImmediatePropagation(),e.preventDefault();var a=o.offset(),r=O(e)[0]-a.top,l=O(e)[1]-a.left;t(n,i,r,l)}),e(document).add(g).bind("mousemove."+u+" pointermove."+u+" MSPointerMove."+u,function(e){if(o){var a=o.offset(),r=O(e)[0]-a.top,l=O(e)[1]-a.left;if(n===r&&i===l)return;t(n,i,r,l)}}).add(p).bind("mouseup."+u+" touchend."+u+" pointerup."+u+" MSPointerUp."+u,function(){o&&(C(o,"active",d.autoExpandScrollbar),o=null),c=!1,s&&(document.onselectstart=null),L.call(h,!0)})},D=function(){function o(e){if(!te(e)||c||O(e)[2])return void(t=0);t=1,b=0,C=0,d=1,y.removeClass("mCS_touch_action");var o=I.offset();u=O(e)[0]-o.top,f=O(e)[1]-o.left,z=[O(e)[0],O(e)[1]]}function n(e){if(te(e)&&!c&&!O(e)[2]&&(T.documentTouchScroll||e.preventDefault(),e.stopImmediatePropagation(),(!C||b)&&d)){g=K();var t=M.offset(),o=O(e)[0]-t.top,a=O(e)[1]-t.left,n="mcsLinearOut";if(E.push(o),W.push(a),z[2]=Math.abs(O(e)[0]-z[0]),z[3]=Math.abs(O(e)[1]-z[1]),B.overflowed[0])var i=D[0].parent().height()-D[0].height(),r=u-o>0&&o-u>-(i*B.scrollRatio.y)&&(2*z[3]<z[2]||"yx"===T.axis);if(B.overflowed[1])var l=D[1].parent().width()-D[1].width(),h=f-a>0&&a-f>-(l*B.scrollRatio.x)&&(2*z[2]<z[3]||"yx"===T.axis);r||h?(U||e.preventDefault(),b=1):(C=1,y.addClass("mCS_touch_action")),U&&e.preventDefault(),w="yx"===T.axis?[u-o,f-a]:"x"===T.axis?[null,f-a]:[u-o,null],I[0].idleTimer=250,B.overflowed[0]&&s(w[0],R,n,"y","all",!0),B.overflowed[1]&&s(w[1],R,n,"x",L,!0)}}function i(e){if(!te(e)||c||O(e)[2])return void(t=0);t=1,e.stopImmediatePropagation(),Q(y),p=K();var o=M.offset();h=O(e)[0]-o.top,m=O(e)[1]-o.left,E=[],W=[]}function r(e){if(te(e)&&!c&&!O(e)[2]){d=0,e.stopImmediatePropagation(),b=0,C=0,v=K();var t=M.offset(),o=O(e)[0]-t.top,a=O(e)[1]-t.left;if(!(v-g>30)){_=1e3/(v-p);var n="mcsEaseOut",i=2.5>_,r=i?[E[E.length-2],W[W.length-2]]:[0,0];x=i?[o-r[0],a-r[1]]:[o-h,a-m];var u=[Math.abs(x[0]),Math.abs(x[1])];_=i?[Math.abs(x[0]/4),Math.abs(x[1]/4)]:[_,_];var f=[Math.abs(I[0].offsetTop)-x[0]*l(u[0]/_[0],_[0]),Math.abs(I[0].offsetLeft)-x[1]*l(u[1]/_[1],_[1])];w="yx"===T.axis?[f[0],f[1]]:"x"===T.axis?[null,f[1]]:[f[0],null],S=[4*u[0]+T.scrollInertia,4*u[1]+T.scrollInertia];var y=parseInt(T.contentTouchScroll)||0;w[0]=u[0]>y?w[0]:0,w[1]=u[1]>y?w[1]:0,B.overflowed[0]&&s(w[0],S[0],n,"y",L,!1),B.overflowed[1]&&s(w[1],S[1],n,"x",L,!1)}}}function l(e,t){var o=[1.5*t,2*t,t/1.5,t/2];return e>90?t>4?o[0]:o[3]:e>60?t>3?o[3]:o[2]:e>30?t>8?o[1]:t>6?o[0]:t>4?t:o[2]:t>8?t:o[3]}function s(e,t,o,a,n,i){e&&G(y,e.toString(),{dur:t,scrollEasing:o,dir:a,overwrite:n,drag:i})}var d,u,f,h,m,p,g,v,x,_,w,S,b,C,y=e(this),B=y.data(a),T=B.opt,k=a+"_"+B.idx,M=e("#mCSB_"+B.idx),I=e("#mCSB_"+B.idx+"_container"),D=[e("#mCSB_"+B.idx+"_dragger_vertical"),e("#mCSB_"+B.idx+"_dragger_horizontal")],E=[],W=[],R=0,L="yx"===T.axis?"none":"all",z=[],P=I.find("iframe"),H=["touchstart."+k+" pointerdown."+k+" MSPointerDown."+k,"touchmove."+k+" pointermove."+k+" MSPointerMove."+k,"touchend."+k+" pointerup."+k+" MSPointerUp."+k],U=void 0!==document.body.style.touchAction&&""!==document.body.style.touchAction;I.bind(H[0],function(e){o(e)}).bind(H[1],function(e){n(e)}),M.bind(H[0],function(e){i(e)}).bind(H[2],function(e){r(e)}),P.length&&P.each(function(){e(this).bind("load",function(){A(this)&&e(this.contentDocument||this.contentWindow.document).bind(H[0],function(e){o(e),i(e)}).bind(H[1],function(e){n(e)}).bind(H[2],function(e){r(e)})})})},E=function(){function o(){return window.getSelection?window.getSelection().toString():document.selection&&"Control"!=document.selection.type?document.selection.createRange().text:0}function n(e,t,o){d.type=o&&i?"stepped":"stepless",d.scrollAmount=10,j(r,e,t,"mcsLinearOut",o?60:null)}var i,r=e(this),l=r.data(a),s=l.opt,d=l.sequential,u=a+"_"+l.idx,f=e("#mCSB_"+l.idx+"_container"),h=f.parent();f.bind("mousedown."+u,function(){t||i||(i=1,c=!0)}).add(document).bind("mousemove."+u,function(e){if(!t&&i&&o()){var a=f.offset(),r=O(e)[0]-a.top+f[0].offsetTop,c=O(e)[1]-a.left+f[0].offsetLeft;r>0&&r<h.height()&&c>0&&c<h.width()?d.step&&n("off",null,"stepped"):("x"!==s.axis&&l.overflowed[0]&&(0>r?n("on",38):r>h.height()&&n("on",40)),"y"!==s.axis&&l.overflowed[1]&&(0>c?n("on",37):c>h.width()&&n("on",39)))}}).bind("mouseup."+u+" dragend."+u,function(){t||(i&&(i=0,n("off",null)),c=!1)})},W=function(){function t(t,a){if(Q(o),!z(o,t.target)){var r="auto"!==i.mouseWheel.deltaFactor?parseInt(i.mouseWheel.deltaFactor):s&&t.deltaFactor<100?100:t.deltaFactor||100,d=i.scrollInertia;if("x"===i.axis||"x"===i.mouseWheel.axis)var u="x",f=[Math.round(r*n.scrollRatio.x),parseInt(i.mouseWheel.scrollAmount)],h="auto"!==i.mouseWheel.scrollAmount?f[1]:f[0]>=l.width()?.9*l.width():f[0],m=Math.abs(e("#mCSB_"+n.idx+"_container")[0].offsetLeft),p=c[1][0].offsetLeft,g=c[1].parent().width()-c[1].width(),v="y"===i.mouseWheel.axis?t.deltaY||a:t.deltaX;else var u="y",f=[Math.round(r*n.scrollRatio.y),parseInt(i.mouseWheel.scrollAmount)],h="auto"!==i.mouseWheel.scrollAmount?f[1]:f[0]>=l.height()?.9*l.height():f[0],m=Math.abs(e("#mCSB_"+n.idx+"_container")[0].offsetTop),p=c[0][0].offsetTop,g=c[0].parent().height()-c[0].height(),v=t.deltaY||a;"y"===u&&!n.overflowed[0]||"x"===u&&!n.overflowed[1]||((i.mouseWheel.invert||t.webkitDirectionInvertedFromDevice)&&(v=-v),i.mouseWheel.normalizeDelta&&(v=0>v?-1:1),(v>0&&0!==p||0>v&&p!==g||i.mouseWheel.preventDefault)&&(t.stopImmediatePropagation(),t.preventDefault()),t.deltaFactor<5&&!i.mouseWheel.normalizeDelta&&(h=t.deltaFactor,d=17),G(o,(m-v*h).toString(),{dir:u,dur:d}))}}if(e(this).data(a)){var o=e(this),n=o.data(a),i=n.opt,r=a+"_"+n.idx,l=e("#mCSB_"+n.idx),c=[e("#mCSB_"+n.idx+"_dragger_vertical"),e("#mCSB_"+n.idx+"_dragger_horizontal")],d=e("#mCSB_"+n.idx+"_container").find("iframe");d.length&&d.each(function(){e(this).bind("load",function(){A(this)&&e(this.contentDocument||this.contentWindow.document).bind("mousewheel."+r,function(e,o){t(e,o)})})}),l.bind("mousewheel."+r,function(e,o){t(e,o)})}},R=new Object,A=function(t){var o=!1,a=!1,n=null;if(void 0===t?a="#empty":void 0!==e(t).attr("id")&&(a=e(t).attr("id")),a!==!1&&void 0!==R[a])return R[a];if(t){try{var i=t.contentDocument||t.contentWindow.document;n=i.body.innerHTML}catch(r){}o=null!==n}else{try{var i=top.document;n=i.body.innerHTML}catch(r){}o=null!==n}return a!==!1&&(R[a]=o),o},L=function(e){var t=this.find("iframe");if(t.length){var o=e?"auto":"none";t.css("pointer-events",o)}},z=function(t,o){var n=o.nodeName.toLowerCase(),i=t.data(a).opt.mouseWheel.disableOver,r=["select","textarea"];return e.inArray(n,i)>-1&&!(e.inArray(n,r)>-1&&!e(o).is(":focus"))},P=function(){var t,o=e(this),n=o.data(a),i=a+"_"+n.idx,r=e("#mCSB_"+n.idx+"_container"),l=r.parent(),s=e(".mCSB_"+n.idx+"_scrollbar ."+d[12]);s.bind("mousedown."+i+" touchstart."+i+" pointerdown."+i+" MSPointerDown."+i,function(o){c=!0,e(o.target).hasClass("mCSB_dragger")||(t=1)}).bind("touchend."+i+" pointerup."+i+" MSPointerUp."+i,function(){c=!1}).bind("click."+i,function(a){if(t&&(t=0,e(a.target).hasClass(d[12])||e(a.target).hasClass("mCSB_draggerRail"))){Q(o);var i=e(this),s=i.find(".mCSB_dragger");if(i.parent(".mCSB_scrollTools_horizontal").length>0){if(!n.overflowed[1])return;var c="x",u=a.pageX>s.offset().left?-1:1,f=Math.abs(r[0].offsetLeft)-u*(.9*l.width())}else{if(!n.overflowed[0])return;var c="y",u=a.pageY>s.offset().top?-1:1,f=Math.abs(r[0].offsetTop)-u*(.9*l.height())}G(o,f.toString(),{dir:c,scrollEasing:"mcsEaseInOut"})}})},H=function(){var t=e(this),o=t.data(a),n=o.opt,i=a+"_"+o.idx,r=e("#mCSB_"+o.idx+"_container"),l=r.parent();r.bind("focusin."+i,function(){var o=e(document.activeElement),a=r.find(".mCustomScrollBox").length,i=0;o.is(n.advanced.autoScrollOnFocus)&&(Q(t),clearTimeout(t[0]._focusTimeout),t[0]._focusTimer=a?(i+17)*a:0,t[0]._focusTimeout=setTimeout(function(){var e=[ae(o)[0],ae(o)[1]],a=[r[0].offsetTop,r[0].offsetLeft],s=[a[0]+e[0]>=0&&a[0]+e[0]<l.height()-o.outerHeight(!1),a[1]+e[1]>=0&&a[0]+e[1]<l.width()-o.outerWidth(!1)],c="yx"!==n.axis||s[0]||s[1]?"all":"none";"x"===n.axis||s[0]||G(t,e[0].toString(),{dir:"y",scrollEasing:"mcsEaseInOut",overwrite:c,dur:i}),"y"===n.axis||s[1]||G(t,e[1].toString(),{dir:"x",scrollEasing:"mcsEaseInOut",overwrite:c,dur:i})},t[0]._focusTimer))})},U=function(){var t=e(this),o=t.data(a),n=a+"_"+o.idx,i=e("#mCSB_"+o.idx+"_container").parent();i.bind("scroll."+n,function(){0===i.scrollTop()&&0===i.scrollLeft()||e(".mCSB_"+o.idx+"_scrollbar").css("visibility","hidden")})},F=function(){var t=e(this),o=t.data(a),n=o.opt,i=o.sequential,r=a+"_"+o.idx,l=".mCSB_"+o.idx+"_scrollbar",s=e(l+">a");s.bind("contextmenu."+r,function(e){e.preventDefault()}).bind("mousedown."+r+" touchstart."+r+" pointerdown."+r+" MSPointerDown."+r+" mouseup."+r+" touchend."+r+" pointerup."+r+" MSPointerUp."+r+" mouseout."+r+" pointerout."+r+" MSPointerOut."+r+" click."+r,function(a){function r(e,o){i.scrollAmount=n.scrollButtons.scrollAmount,j(t,e,o)}if(a.preventDefault(),ee(a)){var l=e(this).attr("class");switch(i.type=n.scrollButtons.scrollType,a.type){case"mousedown":case"touchstart":case"pointerdown":case"MSPointerDown":if("stepped"===i.type)return;c=!0,o.tweenRunning=!1,r("on",l);break;case"mouseup":case"touchend":case"pointerup":case"MSPointerUp":case"mouseout":case"pointerout":case"MSPointerOut":if("stepped"===i.type)return;c=!1,i.dir&&r("off",l);break;case"click":if("stepped"!==i.type||o.tweenRunning)return;r("on",l)}}})},q=function(){function t(t){function a(e,t){r.type=i.keyboard.scrollType,r.scrollAmount=i.keyboard.scrollAmount,"stepped"===r.type&&n.tweenRunning||j(o,e,t)}switch(t.type){case"blur":n.tweenRunning&&r.dir&&a("off",null);break;case"keydown":case"keyup":var l=t.keyCode?t.keyCode:t.which,s="on";if("x"!==i.axis&&(38===l||40===l)||"y"!==i.axis&&(37===l||39===l)){if((38===l||40===l)&&!n.overflowed[0]||(37===l||39===l)&&!n.overflowed[1])return;"keyup"===t.type&&(s="off"),e(document.activeElement).is(u)||(t.preventDefault(),t.stopImmediatePropagation(),a(s,l))}else if(33===l||34===l){if((n.overflowed[0]||n.overflowed[1])&&(t.preventDefault(),t.stopImmediatePropagation()),"keyup"===t.type){Q(o);var f=34===l?-1:1;if("x"===i.axis||"yx"===i.axis&&n.overflowed[1]&&!n.overflowed[0])var h="x",m=Math.abs(c[0].offsetLeft)-f*(.9*d.width());else var h="y",m=Math.abs(c[0].offsetTop)-f*(.9*d.height());G(o,m.toString(),{dir:h,scrollEasing:"mcsEaseInOut"})}}else if((35===l||36===l)&&!e(document.activeElement).is(u)&&((n.overflowed[0]||n.overflowed[1])&&(t.preventDefault(),t.stopImmediatePropagation()),"keyup"===t.type)){if("x"===i.axis||"yx"===i.axis&&n.overflowed[1]&&!n.overflowed[0])var h="x",m=35===l?Math.abs(d.width()-c.outerWidth(!1)):0;else var h="y",m=35===l?Math.abs(d.height()-c.outerHeight(!1)):0;G(o,m.toString(),{dir:h,scrollEasing:"mcsEaseInOut"})}}}var o=e(this),n=o.data(a),i=n.opt,r=n.sequential,l=a+"_"+n.idx,s=e("#mCSB_"+n.idx),c=e("#mCSB_"+n.idx+"_container"),d=c.parent(),u="input,textarea,select,datalist,keygen,[contenteditable='true']",f=c.find("iframe"),h=["blur."+l+" keydown."+l+" keyup."+l];f.length&&f.each(function(){e(this).bind("load",function(){A(this)&&e(this.contentDocument||this.contentWindow.document).bind(h[0],function(e){t(e)})})}),s.attr("tabindex","0").bind(h[0],function(e){t(e)})},j=function(t,o,n,i,r){function l(e){u.snapAmount&&(f.scrollAmount=u.snapAmount instanceof Array?"x"===f.dir[0]?u.snapAmount[1]:u.snapAmount[0]:u.snapAmount);var o="stepped"!==f.type,a=r?r:e?o?p/1.5:g:1e3/60,n=e?o?7.5:40:2.5,s=[Math.abs(h[0].offsetTop),Math.abs(h[0].offsetLeft)],d=[c.scrollRatio.y>10?10:c.scrollRatio.y,c.scrollRatio.x>10?10:c.scrollRatio.x],m="x"===f.dir[0]?s[1]+f.dir[1]*(d[1]*n):s[0]+f.dir[1]*(d[0]*n),v="x"===f.dir[0]?s[1]+f.dir[1]*parseInt(f.scrollAmount):s[0]+f.dir[1]*parseInt(f.scrollAmount),x="auto"!==f.scrollAmount?v:m,_=i?i:e?o?"mcsLinearOut":"mcsEaseInOut":"mcsLinear",w=!!e;return e&&17>a&&(x="x"===f.dir[0]?s[1]:s[0]),G(t,x.toString(),{dir:f.dir[0],scrollEasing:_,dur:a,onComplete:w}),e?void(f.dir=!1):(clearTimeout(f.step),void(f.step=setTimeout(function(){l()},a)))}function s(){clearTimeout(f.step),$(f,"step"),Q(t)}var c=t.data(a),u=c.opt,f=c.sequential,h=e("#mCSB_"+c.idx+"_container"),m="stepped"===f.type,p=u.scrollInertia<26?26:u.scrollInertia,g=u.scrollInertia<1?17:u.scrollInertia;switch(o){case"on":if(f.dir=[n===d[16]||n===d[15]||39===n||37===n?"x":"y",n===d[13]||n===d[15]||38===n||37===n?-1:1],Q(t),oe(n)&&"stepped"===f.type)return;l(m);break;case"off":s(),(m||c.tweenRunning&&f.dir)&&l(!0)}},Y=function(t){var o=e(this).data(a).opt,n=[];return"function"==typeof t&&(t=t()),t instanceof Array?n=t.length>1?[t[0],t[1]]:"x"===o.axis?[null,t[0]]:[t[0],null]:(n[0]=t.y?t.y:t.x||"x"===o.axis?null:t,n[1]=t.x?t.x:t.y||"y"===o.axis?null:t),"function"==typeof n[0]&&(n[0]=n[0]()),"function"==typeof n[1]&&(n[1]=n[1]()),n},X=function(t,o){if(null!=t&&"undefined"!=typeof t){var n=e(this),i=n.data(a),r=i.opt,l=e("#mCSB_"+i.idx+"_container"),s=l.parent(),c=typeof t;o||(o="x"===r.axis?"x":"y");var d="x"===o?l.outerWidth(!1)-s.width():l.outerHeight(!1)-s.height(),f="x"===o?l[0].offsetLeft:l[0].offsetTop,h="x"===o?"left":"top";switch(c){case"function":return t();case"object":var m=t.jquery?t:e(t);if(!m.length)return;return"x"===o?ae(m)[1]:ae(m)[0];case"string":case"number":if(oe(t))return Math.abs(t);if(-1!==t.indexOf("%"))return Math.abs(d*parseInt(t)/100);if(-1!==t.indexOf("-="))return Math.abs(f-parseInt(t.split("-=")[1]));if(-1!==t.indexOf("+=")){var p=f+parseInt(t.split("+=")[1]);return p>=0?0:Math.abs(p)}if(-1!==t.indexOf("px")&&oe(t.split("px")[0]))return Math.abs(t.split("px")[0]);if("top"===t||"left"===t)return 0;if("bottom"===t)return Math.abs(s.height()-l.outerHeight(!1));if("right"===t)return Math.abs(s.width()-l.outerWidth(!1));if("first"===t||"last"===t){var m=l.find(":"+t);return"x"===o?ae(m)[1]:ae(m)[0]}return e(t).length?"x"===o?ae(e(t))[1]:ae(e(t))[0]:(l.css(h,t),void u.update.call(null,n[0]))}}},N=function(t){function o(){return clearTimeout(f[0].autoUpdate),0===l.parents("html").length?void(l=null):void(f[0].autoUpdate=setTimeout(function(){return c.advanced.updateOnSelectorChange&&(s.poll.change.n=i(),s.poll.change.n!==s.poll.change.o)?(s.poll.change.o=s.poll.change.n,void r(3)):c.advanced.updateOnContentResize&&(s.poll.size.n=l[0].scrollHeight+l[0].scrollWidth+f[0].offsetHeight+l[0].offsetHeight+l[0].offsetWidth,s.poll.size.n!==s.poll.size.o)?(s.poll.size.o=s.poll.size.n,void r(1)):!c.advanced.updateOnImageLoad||"auto"===c.advanced.updateOnImageLoad&&"y"===c.axis||(s.poll.img.n=f.find("img").length,s.poll.img.n===s.poll.img.o)?void((c.advanced.updateOnSelectorChange||c.advanced.updateOnContentResize||c.advanced.updateOnImageLoad)&&o()):(s.poll.img.o=s.poll.img.n,void f.find("img").each(function(){n(this)}))},c.advanced.autoUpdateTimeout))}function n(t){function o(e,t){return function(){
  17105. return t.apply(e,arguments)}}function a(){this.onload=null,e(t).addClass(d[2]),r(2)}if(e(t).hasClass(d[2]))return void r();var n=new Image;n.onload=o(n,a),n.src=t.src}function i(){c.advanced.updateOnSelectorChange===!0&&(c.advanced.updateOnSelectorChange="*");var e=0,t=f.find(c.advanced.updateOnSelectorChange);return c.advanced.updateOnSelectorChange&&t.length>0&&t.each(function(){e+=this.offsetHeight+this.offsetWidth}),e}function r(e){clearTimeout(f[0].autoUpdate),u.update.call(null,l[0],e)}var l=e(this),s=l.data(a),c=s.opt,f=e("#mCSB_"+s.idx+"_container");return t?(clearTimeout(f[0].autoUpdate),void $(f[0],"autoUpdate")):void o()},V=function(e,t,o){return Math.round(e/t)*t-o},Q=function(t){var o=t.data(a),n=e("#mCSB_"+o.idx+"_container,#mCSB_"+o.idx+"_container_wrapper,#mCSB_"+o.idx+"_dragger_vertical,#mCSB_"+o.idx+"_dragger_horizontal");n.each(function(){Z.call(this)})},G=function(t,o,n){function i(e){return s&&c.callbacks[e]&&"function"==typeof c.callbacks[e]}function r(){return[c.callbacks.alwaysTriggerOffsets||w>=S[0]+y,c.callbacks.alwaysTriggerOffsets||-B>=w]}function l(){var e=[h[0].offsetTop,h[0].offsetLeft],o=[x[0].offsetTop,x[0].offsetLeft],a=[h.outerHeight(!1),h.outerWidth(!1)],i=[f.height(),f.width()];t[0].mcs={content:h,top:e[0],left:e[1],draggerTop:o[0],draggerLeft:o[1],topPct:Math.round(100*Math.abs(e[0])/(Math.abs(a[0])-i[0])),leftPct:Math.round(100*Math.abs(e[1])/(Math.abs(a[1])-i[1])),direction:n.dir}}var s=t.data(a),c=s.opt,d={trigger:"internal",dir:"y",scrollEasing:"mcsEaseOut",drag:!1,dur:c.scrollInertia,overwrite:"all",callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},n=e.extend(d,n),u=[n.dur,n.drag?0:n.dur],f=e("#mCSB_"+s.idx),h=e("#mCSB_"+s.idx+"_container"),m=h.parent(),p=c.callbacks.onTotalScrollOffset?Y.call(t,c.callbacks.onTotalScrollOffset):[0,0],g=c.callbacks.onTotalScrollBackOffset?Y.call(t,c.callbacks.onTotalScrollBackOffset):[0,0];if(s.trigger=n.trigger,0===m.scrollTop()&&0===m.scrollLeft()||(e(".mCSB_"+s.idx+"_scrollbar").css("visibility","visible"),m.scrollTop(0).scrollLeft(0)),"_resetY"!==o||s.contentReset.y||(i("onOverflowYNone")&&c.callbacks.onOverflowYNone.call(t[0]),s.contentReset.y=1),"_resetX"!==o||s.contentReset.x||(i("onOverflowXNone")&&c.callbacks.onOverflowXNone.call(t[0]),s.contentReset.x=1),"_resetY"!==o&&"_resetX"!==o){if(!s.contentReset.y&&t[0].mcs||!s.overflowed[0]||(i("onOverflowY")&&c.callbacks.onOverflowY.call(t[0]),s.contentReset.x=null),!s.contentReset.x&&t[0].mcs||!s.overflowed[1]||(i("onOverflowX")&&c.callbacks.onOverflowX.call(t[0]),s.contentReset.x=null),c.snapAmount){var v=c.snapAmount instanceof Array?"x"===n.dir?c.snapAmount[1]:c.snapAmount[0]:c.snapAmount;o=V(o,v,c.snapOffset)}switch(n.dir){case"x":var x=e("#mCSB_"+s.idx+"_dragger_horizontal"),_="left",w=h[0].offsetLeft,S=[f.width()-h.outerWidth(!1),x.parent().width()-x.width()],b=[o,0===o?0:o/s.scrollRatio.x],y=p[1],B=g[1],T=y>0?y/s.scrollRatio.x:0,k=B>0?B/s.scrollRatio.x:0;break;case"y":var x=e("#mCSB_"+s.idx+"_dragger_vertical"),_="top",w=h[0].offsetTop,S=[f.height()-h.outerHeight(!1),x.parent().height()-x.height()],b=[o,0===o?0:o/s.scrollRatio.y],y=p[0],B=g[0],T=y>0?y/s.scrollRatio.y:0,k=B>0?B/s.scrollRatio.y:0}b[1]<0||0===b[0]&&0===b[1]?b=[0,0]:b[1]>=S[1]?b=[S[0],S[1]]:b[0]=-b[0],t[0].mcs||(l(),i("onInit")&&c.callbacks.onInit.call(t[0])),clearTimeout(h[0].onCompleteTimeout),J(x[0],_,Math.round(b[1]),u[1],n.scrollEasing),!s.tweenRunning&&(0===w&&b[0]>=0||w===S[0]&&b[0]<=S[0])||J(h[0],_,Math.round(b[0]),u[0],n.scrollEasing,n.overwrite,{onStart:function(){n.callbacks&&n.onStart&&!s.tweenRunning&&(i("onScrollStart")&&(l(),c.callbacks.onScrollStart.call(t[0])),s.tweenRunning=!0,C(x),s.cbOffsets=r())},onUpdate:function(){n.callbacks&&n.onUpdate&&i("whileScrolling")&&(l(),c.callbacks.whileScrolling.call(t[0]))},onComplete:function(){if(n.callbacks&&n.onComplete){"yx"===c.axis&&clearTimeout(h[0].onCompleteTimeout);var e=h[0].idleTimer||0;h[0].onCompleteTimeout=setTimeout(function(){i("onScroll")&&(l(),c.callbacks.onScroll.call(t[0])),i("onTotalScroll")&&b[1]>=S[1]-T&&s.cbOffsets[0]&&(l(),c.callbacks.onTotalScroll.call(t[0])),i("onTotalScrollBack")&&b[1]<=k&&s.cbOffsets[1]&&(l(),c.callbacks.onTotalScrollBack.call(t[0])),s.tweenRunning=!1,h[0].idleTimer=0,C(x,"hide")},e)}}})}},J=function(e,t,o,a,n,i,r){function l(){S.stop||(x||m.call(),x=K()-v,s(),x>=S.time&&(S.time=x>S.time?x+f-(x-S.time):x+f-1,S.time<x+1&&(S.time=x+1)),S.time<a?S.id=h(l):g.call())}function s(){a>0?(S.currVal=u(S.time,_,b,a,n),w[t]=Math.round(S.currVal)+"px"):w[t]=o+"px",p.call()}function c(){f=1e3/60,S.time=x+f,h=window.requestAnimationFrame?window.requestAnimationFrame:function(e){return s(),setTimeout(e,.01)},S.id=h(l)}function d(){null!=S.id&&(window.requestAnimationFrame?window.cancelAnimationFrame(S.id):clearTimeout(S.id),S.id=null)}function u(e,t,o,a,n){switch(n){case"linear":case"mcsLinear":return o*e/a+t;case"mcsLinearOut":return e/=a,e--,o*Math.sqrt(1-e*e)+t;case"easeInOutSmooth":return e/=a/2,1>e?o/2*e*e+t:(e--,-o/2*(e*(e-2)-1)+t);case"easeInOutStrong":return e/=a/2,1>e?o/2*Math.pow(2,10*(e-1))+t:(e--,o/2*(-Math.pow(2,-10*e)+2)+t);case"easeInOut":case"mcsEaseInOut":return e/=a/2,1>e?o/2*e*e*e+t:(e-=2,o/2*(e*e*e+2)+t);case"easeOutSmooth":return e/=a,e--,-o*(e*e*e*e-1)+t;case"easeOutStrong":return o*(-Math.pow(2,-10*e/a)+1)+t;case"easeOut":case"mcsEaseOut":default:var i=(e/=a)*e,r=i*e;return t+o*(.499999999999997*r*i+-2.5*i*i+5.5*r+-6.5*i+4*e)}}e._mTween||(e._mTween={top:{},left:{}});var f,h,r=r||{},m=r.onStart||function(){},p=r.onUpdate||function(){},g=r.onComplete||function(){},v=K(),x=0,_=e.offsetTop,w=e.style,S=e._mTween[t];"left"===t&&(_=e.offsetLeft);var b=o-_;S.stop=0,"none"!==i&&d(),c()},K=function(){return window.performance&&window.performance.now?window.performance.now():window.performance&&window.performance.webkitNow?window.performance.webkitNow():Date.now?Date.now():(new Date).getTime()},Z=function(){var e=this;e._mTween||(e._mTween={top:{},left:{}});for(var t=["top","left"],o=0;o<t.length;o++){var a=t[o];e._mTween[a].id&&(window.requestAnimationFrame?window.cancelAnimationFrame(e._mTween[a].id):clearTimeout(e._mTween[a].id),e._mTween[a].id=null,e._mTween[a].stop=1)}},$=function(e,t){try{delete e[t]}catch(o){e[t]=null}},ee=function(e){return!(e.which&&1!==e.which)},te=function(e){var t=e.originalEvent.pointerType;return!(t&&"touch"!==t&&2!==t)},oe=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},ae=function(e){var t=e.parents(".mCSB_container");return[e.offset().top-t.offset().top,e.offset().left-t.offset().left]},ne=function(){function e(){var e=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var t=0;t<e.length;t++)if(e[t]+"Hidden"in document)return e[t]+"Hidden";return null}var t=e();return t?document[t]:!1};e.fn[o]=function(t){return u[t]?u[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist"):u.init.apply(this,arguments)},e[o]=function(t){return u[t]?u[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist"):u.init.apply(this,arguments)},e[o].defaults=i,window[o]=!0,e(window).bind("load",function(){e(n)[o](),e.extend(e.expr[":"],{mcsInView:e.expr[":"].mcsInView||function(t){var o,a,n=e(t),i=n.parents(".mCSB_container");if(i.length)return o=i.parent(),a=[i[0].offsetTop,i[0].offsetLeft],a[0]+ae(n)[0]>=0&&a[0]+ae(n)[0]<o.height()-n.outerHeight(!1)&&a[1]+ae(n)[1]>=0&&a[1]+ae(n)[1]<o.width()-n.outerWidth(!1)},mcsInSight:e.expr[":"].mcsInSight||function(t,o,a){var n,i,r,l,s=e(t),c=s.parents(".mCSB_container"),d="exact"===a[3]?[[1,0],[1,0]]:[[.9,.1],[.6,.4]];if(c.length)return n=[s.outerHeight(!1),s.outerWidth(!1)],r=[c[0].offsetTop+ae(s)[0],c[0].offsetLeft+ae(s)[1]],i=[c.parent()[0].offsetHeight,c.parent()[0].offsetWidth],l=[n[0]<i[0]?d[0]:d[1],n[1]<i[1]?d[0]:d[1]],r[0]-i[0]*l[0][0]<0&&r[0]+n[0]-i[0]*l[0][1]>=0&&r[1]-i[1]*l[1][0]<0&&r[1]+n[1]-i[1]*l[1][1]>=0},mcsOverflow:e.expr[":"].mcsOverflow||function(t){var o=e(t).data(a);if(o)return o.overflowed[0]||o.overflowed[1]}})})})});
  17106. /*!
  17107. Justified Gallery
  17108. Version: 3.8.1
  17109. Plugin URL: http://miromannino.github.io/Justified-Gallery/
  17110. License: Copyright (c) 2020 Miro Mannino | Released under the MIT License
  17111. !*/
  17112. (function (factory) {
  17113. if (typeof define === 'function' && define.amd) {
  17114. // AMD. Register as an anonymous module.
  17115. define(['jquery'], factory);
  17116. } else if (typeof module === 'object' && module.exports) {
  17117. // Node/CommonJS
  17118. module.exports = function (root, jQuery) {
  17119. if (jQuery === undefined) {
  17120. // require('jQuery') returns a factory that requires window to
  17121. // build a jQuery instance, we normalize how we use modules
  17122. // that require this pattern but the window provided is a noop
  17123. // if it's defined (how jquery works)
  17124. if (typeof window !== 'undefined') {
  17125. jQuery = require('jquery');
  17126. }
  17127. else {
  17128. jQuery = require('jquery')(root);
  17129. }
  17130. }
  17131. factory(jQuery);
  17132. return jQuery;
  17133. };
  17134. } else {
  17135. // Browser globals
  17136. factory(jQuery);
  17137. }
  17138. }(function ($) {
  17139. /**
  17140. * Justified Gallery controller constructor
  17141. *
  17142. * @param $gallery the gallery to build
  17143. * @param settings the settings (the defaults are in JustifiedGallery.defaults)
  17144. * @constructor
  17145. */
  17146. var JustifiedGallery = function ($gallery, settings) {
  17147. this.settings = settings;
  17148. this.checkSettings();
  17149. this.imgAnalyzerTimeout = null;
  17150. this.entries = null;
  17151. this.buildingRow = {
  17152. entriesBuff: [],
  17153. width: 0,
  17154. height: 0,
  17155. aspectRatio: 0
  17156. };
  17157. this.lastFetchedEntry = null;
  17158. this.lastAnalyzedIndex = -1;
  17159. this.yield = {
  17160. every: 2, // do a flush every n flushes (must be greater than 1)
  17161. flushed: 0 // flushed rows without a yield
  17162. };
  17163. this.border = settings.border >= 0 ? settings.border : settings.margins;
  17164. this.maxRowHeight = this.retrieveMaxRowHeight();
  17165. this.suffixRanges = this.retrieveSuffixRanges();
  17166. this.offY = this.border;
  17167. this.rows = 0;
  17168. this.spinner = {
  17169. phase: 0,
  17170. timeSlot: 150,
  17171. $el: $('<div class="jg-spinner"><span></span><span></span><span></span></div>'),
  17172. intervalId: null
  17173. };
  17174. this.scrollBarOn = false;
  17175. this.checkWidthIntervalId = null;
  17176. this.galleryWidth = $gallery.width();
  17177. this.$gallery = $gallery;
  17178. };
  17179. /** @returns {String} the best suffix given the width and the height */
  17180. JustifiedGallery.prototype.getSuffix = function (width, height) {
  17181. var longestSide, i;
  17182. longestSide = (width > height) ? width : height;
  17183. for (i = 0; i < this.suffixRanges.length; i++) {
  17184. if (longestSide <= this.suffixRanges[i]) {
  17185. return this.settings.sizeRangeSuffixes[this.suffixRanges[i]];
  17186. }
  17187. }
  17188. return this.settings.sizeRangeSuffixes[this.suffixRanges[i - 1]];
  17189. };
  17190. /**
  17191. * Remove the suffix from the string
  17192. *
  17193. * @returns {string} a new string without the suffix
  17194. */
  17195. JustifiedGallery.prototype.removeSuffix = function (str, suffix) {
  17196. return str.substring(0, str.length - suffix.length);
  17197. };
  17198. /**
  17199. * @returns {boolean} a boolean to say if the suffix is contained in the str or not
  17200. */
  17201. JustifiedGallery.prototype.endsWith = function (str, suffix) {
  17202. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  17203. };
  17204. /**
  17205. * Get the used suffix of a particular url
  17206. *
  17207. * @param str
  17208. * @returns {String} return the used suffix
  17209. */
  17210. JustifiedGallery.prototype.getUsedSuffix = function (str) {
  17211. for (var si in this.settings.sizeRangeSuffixes) {
  17212. if (this.settings.sizeRangeSuffixes.hasOwnProperty(si)) {
  17213. if (this.settings.sizeRangeSuffixes[si].length === 0) continue;
  17214. if (this.endsWith(str, this.settings.sizeRangeSuffixes[si])) return this.settings.sizeRangeSuffixes[si];
  17215. }
  17216. }
  17217. return '';
  17218. };
  17219. /**
  17220. * Given an image src, with the width and the height, returns the new image src with the
  17221. * best suffix to show the best quality thumbnail.
  17222. *
  17223. * @returns {String} the suffix to use
  17224. */
  17225. JustifiedGallery.prototype.newSrc = function (imageSrc, imgWidth, imgHeight, image) {
  17226. var newImageSrc;
  17227. if (this.settings.thumbnailPath) {
  17228. newImageSrc = this.settings.thumbnailPath(imageSrc, imgWidth, imgHeight, image);
  17229. } else {
  17230. var matchRes = imageSrc.match(this.settings.extension);
  17231. var ext = (matchRes !== null) ? matchRes[0] : '';
  17232. newImageSrc = imageSrc.replace(this.settings.extension, '');
  17233. newImageSrc = this.removeSuffix(newImageSrc, this.getUsedSuffix(newImageSrc));
  17234. newImageSrc += this.getSuffix(imgWidth, imgHeight) + ext;
  17235. }
  17236. return newImageSrc;
  17237. };
  17238. /**
  17239. * Shows the images that is in the given entry
  17240. *
  17241. * @param $entry the entry
  17242. * @param callback the callback that is called when the show animation is finished
  17243. */
  17244. JustifiedGallery.prototype.showImg = function ($entry, callback) {
  17245. if (this.settings.cssAnimation) {
  17246. $entry.addClass('jg-entry-visible');
  17247. if (callback) callback();
  17248. } else {
  17249. $entry.stop().fadeTo(this.settings.imagesAnimationDuration, 1.0, callback);
  17250. $entry.find(this.settings.imgSelector).stop().fadeTo(this.settings.imagesAnimationDuration, 1.0, callback);
  17251. }
  17252. };
  17253. /**
  17254. * Extract the image src form the image, looking from the 'safe-src', and if it can't be found, from the
  17255. * 'src' attribute. It saves in the image data the 'jg.originalSrc' field, with the extracted src.
  17256. *
  17257. * @param $image the image to analyze
  17258. * @returns {String} the extracted src
  17259. */
  17260. JustifiedGallery.prototype.extractImgSrcFromImage = function ($image) {
  17261. var imageSrc = $image.data('safe-src');
  17262. var imageSrcLoc = 'data-safe-src';
  17263. if (typeof imageSrc === 'undefined') {
  17264. imageSrc = $image.attr('src');
  17265. imageSrcLoc = 'src';
  17266. }
  17267. $image.data('jg.originalSrc', imageSrc); // this is saved for the destroy method
  17268. $image.data('jg.src', imageSrc); // this will change overtime
  17269. $image.data('jg.originalSrcLoc', imageSrcLoc); // this is saved for the destroy method
  17270. return imageSrc;
  17271. };
  17272. /** @returns {jQuery} the image in the given entry */
  17273. JustifiedGallery.prototype.imgFromEntry = function ($entry) {
  17274. var $img = $entry.find(this.settings.imgSelector);
  17275. return $img.length === 0 ? null : $img;
  17276. };
  17277. /** @returns {jQuery} the caption in the given entry */
  17278. JustifiedGallery.prototype.captionFromEntry = function ($entry) {
  17279. var $caption = $entry.find('> .jg-caption');
  17280. return $caption.length === 0 ? null : $caption;
  17281. };
  17282. /**
  17283. * Display the entry
  17284. *
  17285. * @param {jQuery} $entry the entry to display
  17286. * @param {int} x the x position where the entry must be positioned
  17287. * @param y the y position where the entry must be positioned
  17288. * @param imgWidth the image width
  17289. * @param imgHeight the image height
  17290. * @param rowHeight the row height of the row that owns the entry
  17291. */
  17292. JustifiedGallery.prototype.displayEntry = function ($entry, x, y, imgWidth, imgHeight, rowHeight) {
  17293. $entry.width(imgWidth);
  17294. $entry.height(rowHeight);
  17295. $entry.css('top', y);
  17296. $entry.css('left', x);
  17297. var $image = this.imgFromEntry($entry);
  17298. if ($image !== null) {
  17299. $image.css('width', imgWidth);
  17300. $image.css('height', imgHeight);
  17301. $image.css('margin-left', - imgWidth / 2);
  17302. $image.css('margin-top', - imgHeight / 2);
  17303. // Image reloading for an high quality of thumbnails
  17304. var imageSrc = $image.data('jg.src');
  17305. if (imageSrc) {
  17306. imageSrc = this.newSrc(imageSrc, imgWidth, imgHeight, $image[0]);
  17307. $image.one('error', function () {
  17308. this.resetImgSrc($image); //revert to the original thumbnail
  17309. });
  17310. var loadNewImage = function () {
  17311. // if (imageSrc !== newImageSrc) {
  17312. $image.attr('src', imageSrc);
  17313. // }
  17314. };
  17315. if ($entry.data('jg.loaded') === 'skipped' && imageSrc) {
  17316. this.onImageEvent(imageSrc, (function() {
  17317. this.showImg($entry, loadNewImage); //load the new image after the fadeIn
  17318. $entry.data('jg.loaded', true);
  17319. }).bind(this));
  17320. } else {
  17321. this.showImg($entry, loadNewImage); //load the new image after the fadeIn
  17322. }
  17323. }
  17324. } else {
  17325. this.showImg($entry);
  17326. }
  17327. this.displayEntryCaption($entry);
  17328. };
  17329. /**
  17330. * Display the entry caption. If the caption element doesn't exists, it creates the caption using the 'alt'
  17331. * or the 'title' attributes.
  17332. *
  17333. * @param {jQuery} $entry the entry to process
  17334. */
  17335. JustifiedGallery.prototype.displayEntryCaption = function ($entry) {
  17336. var $image = this.imgFromEntry($entry);
  17337. if ($image !== null && this.settings.captions) {
  17338. var $imgCaption = this.captionFromEntry($entry);
  17339. // Create it if it doesn't exists
  17340. if ($imgCaption === null) {
  17341. var caption = $image.attr('alt');
  17342. if (!this.isValidCaption(caption)) caption = $entry.attr('title');
  17343. if (this.isValidCaption(caption)) { // Create only we found something
  17344. $imgCaption = $('<div class="jg-caption">' + caption + '</div>');
  17345. $entry.append($imgCaption);
  17346. $entry.data('jg.createdCaption', true);
  17347. }
  17348. }
  17349. // Create events (we check again the $imgCaption because it can be still inexistent)
  17350. if ($imgCaption !== null) {
  17351. if (!this.settings.cssAnimation) $imgCaption.stop().fadeTo(0, this.settings.captionSettings.nonVisibleOpacity);
  17352. this.addCaptionEventsHandlers($entry);
  17353. }
  17354. } else {
  17355. this.removeCaptionEventsHandlers($entry);
  17356. }
  17357. };
  17358. /**
  17359. * Validates the caption
  17360. *
  17361. * @param caption The caption that should be validated
  17362. * @return {boolean} Validation result
  17363. */
  17364. JustifiedGallery.prototype.isValidCaption = function (caption) {
  17365. return (typeof caption !== 'undefined' && caption.length > 0);
  17366. };
  17367. /**
  17368. * The callback for the event 'mouseenter'. It assumes that the event currentTarget is an entry.
  17369. * It shows the caption using jQuery (or using CSS if it is configured so)
  17370. *
  17371. * @param {Event} eventObject the event object
  17372. */
  17373. JustifiedGallery.prototype.onEntryMouseEnterForCaption = function (eventObject) {
  17374. var $caption = this.captionFromEntry($(eventObject.currentTarget));
  17375. if (this.settings.cssAnimation) {
  17376. $caption.addClass('jg-caption-visible').removeClass('jg-caption-hidden');
  17377. } else {
  17378. $caption.stop().fadeTo(this.settings.captionSettings.animationDuration,
  17379. this.settings.captionSettings.visibleOpacity);
  17380. }
  17381. };
  17382. /**
  17383. * The callback for the event 'mouseleave'. It assumes that the event currentTarget is an entry.
  17384. * It hides the caption using jQuery (or using CSS if it is configured so)
  17385. *
  17386. * @param {Event} eventObject the event object
  17387. */
  17388. JustifiedGallery.prototype.onEntryMouseLeaveForCaption = function (eventObject) {
  17389. var $caption = this.captionFromEntry($(eventObject.currentTarget));
  17390. if (this.settings.cssAnimation) {
  17391. $caption.removeClass('jg-caption-visible').removeClass('jg-caption-hidden');
  17392. } else {
  17393. $caption.stop().fadeTo(this.settings.captionSettings.animationDuration,
  17394. this.settings.captionSettings.nonVisibleOpacity);
  17395. }
  17396. };
  17397. /**
  17398. * Add the handlers of the entry for the caption
  17399. *
  17400. * @param $entry the entry to modify
  17401. */
  17402. JustifiedGallery.prototype.addCaptionEventsHandlers = function ($entry) {
  17403. var captionMouseEvents = $entry.data('jg.captionMouseEvents');
  17404. if (typeof captionMouseEvents === 'undefined') {
  17405. captionMouseEvents = {
  17406. mouseenter: $.proxy(this.onEntryMouseEnterForCaption, this),
  17407. mouseleave: $.proxy(this.onEntryMouseLeaveForCaption, this)
  17408. };
  17409. $entry.on('mouseenter', undefined, undefined, captionMouseEvents.mouseenter);
  17410. $entry.on('mouseleave', undefined, undefined, captionMouseEvents.mouseleave);
  17411. $entry.data('jg.captionMouseEvents', captionMouseEvents);
  17412. }
  17413. };
  17414. /**
  17415. * Remove the handlers of the entry for the caption
  17416. *
  17417. * @param $entry the entry to modify
  17418. */
  17419. JustifiedGallery.prototype.removeCaptionEventsHandlers = function ($entry) {
  17420. var captionMouseEvents = $entry.data('jg.captionMouseEvents');
  17421. if (typeof captionMouseEvents !== 'undefined') {
  17422. $entry.off('mouseenter', undefined, captionMouseEvents.mouseenter);
  17423. $entry.off('mouseleave', undefined, captionMouseEvents.mouseleave);
  17424. $entry.removeData('jg.captionMouseEvents');
  17425. }
  17426. };
  17427. /**
  17428. * Clear the building row data to be used for a new row
  17429. */
  17430. JustifiedGallery.prototype.clearBuildingRow = function () {
  17431. this.buildingRow.entriesBuff = [];
  17432. this.buildingRow.aspectRatio = 0;
  17433. this.buildingRow.width = 0;
  17434. };
  17435. /**
  17436. * Justify the building row, preparing it to
  17437. *
  17438. * @param isLastRow
  17439. * @param hiddenRow undefined or false for normal behavior. hiddenRow = true to hide the row.
  17440. * @returns a boolean to know if the row has been justified or not
  17441. */
  17442. JustifiedGallery.prototype.prepareBuildingRow = function (isLastRow, hiddenRow) {
  17443. var i, $entry, imgAspectRatio, newImgW, newImgH, justify = true;
  17444. var minHeight = 0;
  17445. var availableWidth = this.galleryWidth - 2 * this.border - (
  17446. (this.buildingRow.entriesBuff.length - 1) * this.settings.margins);
  17447. var rowHeight = availableWidth / this.buildingRow.aspectRatio;
  17448. var defaultRowHeight = this.settings.rowHeight;
  17449. var justifiable = this.buildingRow.width / availableWidth > this.settings.justifyThreshold;
  17450. //Skip the last row if we can't justify it and the lastRow == 'hide'
  17451. if (hiddenRow || (isLastRow && this.settings.lastRow === 'hide' && !justifiable)) {
  17452. for (i = 0; i < this.buildingRow.entriesBuff.length; i++) {
  17453. $entry = this.buildingRow.entriesBuff[i];
  17454. if (this.settings.cssAnimation)
  17455. $entry.removeClass('jg-entry-visible');
  17456. else {
  17457. $entry.stop().fadeTo(0, 0.1);
  17458. $entry.find('> img, > a > img').fadeTo(0, 0);
  17459. }
  17460. }
  17461. return -1;
  17462. }
  17463. // With lastRow = nojustify, justify if is justificable (the images will not become too big)
  17464. if (isLastRow && !justifiable && this.settings.lastRow !== 'justify' && this.settings.lastRow !== 'hide') {
  17465. justify = false;
  17466. if (this.rows > 0) {
  17467. defaultRowHeight = (this.offY - this.border - this.settings.margins * this.rows) / this.rows;
  17468. justify = defaultRowHeight * this.buildingRow.aspectRatio / availableWidth > this.settings.justifyThreshold;
  17469. }
  17470. }
  17471. for (i = 0; i < this.buildingRow.entriesBuff.length; i++) {
  17472. $entry = this.buildingRow.entriesBuff[i];
  17473. imgAspectRatio = $entry.data('jg.width') / $entry.data('jg.height');
  17474. if (justify) {
  17475. newImgW = (i === this.buildingRow.entriesBuff.length - 1) ? availableWidth : rowHeight * imgAspectRatio;
  17476. newImgH = rowHeight;
  17477. } else {
  17478. newImgW = defaultRowHeight * imgAspectRatio;
  17479. newImgH = defaultRowHeight;
  17480. }
  17481. availableWidth -= Math.round(newImgW);
  17482. $entry.data('jg.jwidth', Math.round(newImgW));
  17483. $entry.data('jg.jheight', Math.ceil(newImgH));
  17484. if (i === 0 || minHeight > newImgH) minHeight = newImgH;
  17485. }
  17486. this.buildingRow.height = minHeight;
  17487. return justify;
  17488. };
  17489. /**
  17490. * Flush a row: justify it, modify the gallery height accordingly to the row height
  17491. *
  17492. * @param isLastRow
  17493. * @param hiddenRow undefined or false for normal behavior. hiddenRow = true to hide the row.
  17494. */
  17495. JustifiedGallery.prototype.flushRow = function (isLastRow, hiddenRow) {
  17496. var settings = this.settings;
  17497. var $entry, buildingRowRes, offX = this.border, i;
  17498. buildingRowRes = this.prepareBuildingRow(isLastRow, hiddenRow);
  17499. if (hiddenRow || (isLastRow && settings.lastRow === 'hide' && buildingRowRes === -1)) {
  17500. this.clearBuildingRow();
  17501. return;
  17502. }
  17503. if (this.maxRowHeight) {
  17504. if (this.maxRowHeight < this.buildingRow.height) this.buildingRow.height = this.maxRowHeight;
  17505. }
  17506. //Align last (unjustified) row
  17507. if (isLastRow && (settings.lastRow === 'center' || settings.lastRow === 'right')) {
  17508. var availableWidth = this.galleryWidth - 2 * this.border - (this.buildingRow.entriesBuff.length - 1) * settings.margins;
  17509. for (i = 0; i < this.buildingRow.entriesBuff.length; i++) {
  17510. $entry = this.buildingRow.entriesBuff[i];
  17511. availableWidth -= $entry.data('jg.jwidth');
  17512. }
  17513. if (settings.lastRow === 'center')
  17514. offX += Math.round(availableWidth / 2);
  17515. else if (settings.lastRow === 'right')
  17516. offX += availableWidth;
  17517. }
  17518. var lastEntryIdx = this.buildingRow.entriesBuff.length - 1;
  17519. for (i = 0; i <= lastEntryIdx; i++) {
  17520. $entry = this.buildingRow.entriesBuff[this.settings.rtl ? lastEntryIdx - i : i];
  17521. this.displayEntry($entry, offX, this.offY, $entry.data('jg.jwidth'), $entry.data('jg.jheight'), this.buildingRow.height);
  17522. offX += $entry.data('jg.jwidth') + settings.margins;
  17523. }
  17524. //Gallery Height
  17525. this.galleryHeightToSet = this.offY + this.buildingRow.height + this.border;
  17526. this.setGalleryTempHeight(this.galleryHeightToSet + this.getSpinnerHeight());
  17527. if (!isLastRow || (this.buildingRow.height <= settings.rowHeight && buildingRowRes)) {
  17528. //Ready for a new row
  17529. this.offY += this.buildingRow.height + settings.margins;
  17530. this.rows += 1;
  17531. this.clearBuildingRow();
  17532. this.settings.triggerEvent.call(this, 'jg.rowflush');
  17533. }
  17534. };
  17535. // Scroll position not restoring: https://github.com/miromannino/Justified-Gallery/issues/221
  17536. var galleryPrevStaticHeight = 0;
  17537. JustifiedGallery.prototype.rememberGalleryHeight = function () {
  17538. galleryPrevStaticHeight = this.$gallery.height();
  17539. this.$gallery.height(galleryPrevStaticHeight);
  17540. };
  17541. // grow only
  17542. JustifiedGallery.prototype.setGalleryTempHeight = function (height) {
  17543. galleryPrevStaticHeight = Math.max(height, galleryPrevStaticHeight);
  17544. this.$gallery.height(galleryPrevStaticHeight);
  17545. };
  17546. JustifiedGallery.prototype.setGalleryFinalHeight = function (height) {
  17547. galleryPrevStaticHeight = height;
  17548. this.$gallery.height(height);
  17549. };
  17550. /**
  17551. * Checks the width of the gallery container, to know if a new justification is needed
  17552. */
  17553. JustifiedGallery.prototype.checkWidth = function () {
  17554. this.checkWidthIntervalId = setInterval($.proxy(function () {
  17555. // if the gallery is not currently visible, abort.
  17556. if (!this.$gallery.is(":visible")) return;
  17557. var galleryWidth = parseFloat(this.$gallery.width());
  17558. if (Math.abs(galleryWidth - this.galleryWidth) > this.settings.refreshSensitivity) {
  17559. this.galleryWidth = galleryWidth;
  17560. this.rewind();
  17561. this.rememberGalleryHeight();
  17562. // Restart to analyze
  17563. this.startImgAnalyzer(true);
  17564. }
  17565. }, this), this.settings.refreshTime);
  17566. };
  17567. /**
  17568. * @returns {boolean} a boolean saying if the spinner is active or not
  17569. */
  17570. JustifiedGallery.prototype.isSpinnerActive = function () {
  17571. return this.spinner.intervalId !== null;
  17572. };
  17573. /**
  17574. * @returns {int} the spinner height
  17575. */
  17576. JustifiedGallery.prototype.getSpinnerHeight = function () {
  17577. return this.spinner.$el.innerHeight();
  17578. };
  17579. /**
  17580. * Stops the spinner animation and modify the gallery height to exclude the spinner
  17581. */
  17582. JustifiedGallery.prototype.stopLoadingSpinnerAnimation = function () {
  17583. clearInterval(this.spinner.intervalId);
  17584. this.spinner.intervalId = null;
  17585. this.setGalleryTempHeight(this.$gallery.height() - this.getSpinnerHeight());
  17586. this.spinner.$el.detach();
  17587. };
  17588. /**
  17589. * Starts the spinner animation
  17590. */
  17591. JustifiedGallery.prototype.startLoadingSpinnerAnimation = function () {
  17592. var spinnerContext = this.spinner;
  17593. var $spinnerPoints = spinnerContext.$el.find('span');
  17594. clearInterval(spinnerContext.intervalId);
  17595. this.$gallery.append(spinnerContext.$el);
  17596. this.setGalleryTempHeight(this.offY + this.buildingRow.height + this.getSpinnerHeight());
  17597. spinnerContext.intervalId = setInterval(function () {
  17598. if (spinnerContext.phase < $spinnerPoints.length) {
  17599. $spinnerPoints.eq(spinnerContext.phase).fadeTo(spinnerContext.timeSlot, 1);
  17600. } else {
  17601. $spinnerPoints.eq(spinnerContext.phase - $spinnerPoints.length).fadeTo(spinnerContext.timeSlot, 0);
  17602. }
  17603. spinnerContext.phase = (spinnerContext.phase + 1) % ($spinnerPoints.length * 2);
  17604. }, spinnerContext.timeSlot);
  17605. };
  17606. /**
  17607. * Rewind the image analysis to start from the first entry.
  17608. */
  17609. JustifiedGallery.prototype.rewind = function () {
  17610. this.lastFetchedEntry = null;
  17611. this.lastAnalyzedIndex = -1;
  17612. this.offY = this.border;
  17613. this.rows = 0;
  17614. this.clearBuildingRow();
  17615. };
  17616. /**
  17617. * @returns {String} `settings.selector` rejecting spinner element
  17618. */
  17619. JustifiedGallery.prototype.getSelectorWithoutSpinner = function () {
  17620. return this.settings.selector + ', div:not(.jg-spinner)';
  17621. };
  17622. /**
  17623. * @returns {Array} all entries matched by `settings.selector`
  17624. */
  17625. JustifiedGallery.prototype.getAllEntries = function () {
  17626. var selector = this.getSelectorWithoutSpinner();
  17627. return this.$gallery.children(selector).toArray();
  17628. };
  17629. /**
  17630. * Update the entries searching it from the justified gallery HTML element
  17631. *
  17632. * @param norewind if norewind only the new entries will be changed (i.e. randomized, sorted or filtered)
  17633. * @returns {boolean} true if some entries has been founded
  17634. */
  17635. JustifiedGallery.prototype.updateEntries = function (norewind) {
  17636. var newEntries;
  17637. if (norewind && this.lastFetchedEntry != null) {
  17638. var selector = this.getSelectorWithoutSpinner();
  17639. newEntries = $(this.lastFetchedEntry).nextAll(selector).toArray();
  17640. } else {
  17641. this.entries = [];
  17642. newEntries = this.getAllEntries();
  17643. }
  17644. if (newEntries.length > 0) {
  17645. // Sort or randomize
  17646. if ($.isFunction(this.settings.sort)) {
  17647. newEntries = this.sortArray(newEntries);
  17648. } else if (this.settings.randomize) {
  17649. newEntries = this.shuffleArray(newEntries);
  17650. }
  17651. this.lastFetchedEntry = newEntries[newEntries.length - 1];
  17652. // Filter
  17653. if (this.settings.filter) {
  17654. newEntries = this.filterArray(newEntries);
  17655. } else {
  17656. this.resetFilters(newEntries);
  17657. }
  17658. }
  17659. this.entries = this.entries.concat(newEntries);
  17660. return true;
  17661. };
  17662. /**
  17663. * Apply the entries order to the DOM, iterating the entries and appending the images
  17664. *
  17665. * @param entries the entries that has been modified and that must be re-ordered in the DOM
  17666. */
  17667. JustifiedGallery.prototype.insertToGallery = function (entries) {
  17668. var that = this;
  17669. $.each(entries, function () {
  17670. $(this).appendTo(that.$gallery);
  17671. });
  17672. };
  17673. /**
  17674. * Shuffle the array using the Fisher-Yates shuffle algorithm
  17675. *
  17676. * @param a the array to shuffle
  17677. * @return the shuffled array
  17678. */
  17679. JustifiedGallery.prototype.shuffleArray = function (a) {
  17680. var i, j, temp;
  17681. for (i = a.length - 1; i > 0; i--) {
  17682. j = Math.floor(Math.random() * (i + 1));
  17683. temp = a[i];
  17684. a[i] = a[j];
  17685. a[j] = temp;
  17686. }
  17687. this.insertToGallery(a);
  17688. return a;
  17689. };
  17690. /**
  17691. * Sort the array using settings.comparator as comparator
  17692. *
  17693. * @param a the array to sort (it is sorted)
  17694. * @return the sorted array
  17695. */
  17696. JustifiedGallery.prototype.sortArray = function (a) {
  17697. a.sort(this.settings.sort);
  17698. this.insertToGallery(a);
  17699. return a;
  17700. };
  17701. /**
  17702. * Reset the filters removing the 'jg-filtered' class from all the entries
  17703. *
  17704. * @param a the array to reset
  17705. */
  17706. JustifiedGallery.prototype.resetFilters = function (a) {
  17707. for (var i = 0; i < a.length; i++) $(a[i]).removeClass('jg-filtered');
  17708. };
  17709. /**
  17710. * Filter the entries considering theirs classes (if a string has been passed) or using a function for filtering.
  17711. *
  17712. * @param a the array to filter
  17713. * @return the filtered array
  17714. */
  17715. JustifiedGallery.prototype.filterArray = function (a) {
  17716. var settings = this.settings;
  17717. if ($.type(settings.filter) === 'string') {
  17718. // Filter only keeping the entries passed in the string
  17719. return a.filter(function (el) {
  17720. var $el = $(el);
  17721. if ($el.is(settings.filter)) {
  17722. $el.removeClass('jg-filtered');
  17723. return true;
  17724. } else {
  17725. $el.addClass('jg-filtered').removeClass('jg-visible');
  17726. return false;
  17727. }
  17728. });
  17729. } else if ($.isFunction(settings.filter)) {
  17730. // Filter using the passed function
  17731. var filteredArr = a.filter(settings.filter);
  17732. for (var i = 0; i < a.length; i++) {
  17733. if (filteredArr.indexOf(a[i]) === -1) {
  17734. $(a[i]).addClass('jg-filtered').removeClass('jg-visible');
  17735. } else {
  17736. $(a[i]).removeClass('jg-filtered');
  17737. }
  17738. }
  17739. return filteredArr;
  17740. }
  17741. };
  17742. /**
  17743. * Revert the image src to the default value.
  17744. */
  17745. JustifiedGallery.prototype.resetImgSrc = function ($img) {
  17746. if ($img.data('jg.originalSrcLoc') === 'src') {
  17747. $img.attr('src', $img.data('jg.originalSrc'));
  17748. } else {
  17749. $img.attr('src', '');
  17750. }
  17751. };
  17752. /**
  17753. * Destroy the Justified Gallery instance.
  17754. *
  17755. * It clears all the css properties added in the style attributes. We doesn't backup the original
  17756. * values for those css attributes, because it costs (performance) and because in general one
  17757. * shouldn't use the style attribute for an uniform set of images (where we suppose the use of
  17758. * classes). Creating a backup is also difficult because JG could be called multiple times and
  17759. * with different style attributes.
  17760. */
  17761. JustifiedGallery.prototype.destroy = function () {
  17762. clearInterval(this.checkWidthIntervalId);
  17763. this.stopImgAnalyzerStarter();
  17764. // Get fresh entries list since filtered entries are absent in `this.entries`
  17765. $.each(this.getAllEntries(), $.proxy(function (_, entry) {
  17766. var $entry = $(entry);
  17767. // Reset entry style
  17768. $entry.css('width', '');
  17769. $entry.css('height', '');
  17770. $entry.css('top', '');
  17771. $entry.css('left', '');
  17772. $entry.data('jg.loaded', undefined);
  17773. $entry.removeClass('jg-entry jg-filtered jg-entry-visible');
  17774. // Reset image style
  17775. var $img = this.imgFromEntry($entry);
  17776. if ($img) {
  17777. $img.css('width', '');
  17778. $img.css('height', '');
  17779. $img.css('margin-left', '');
  17780. $img.css('margin-top', '');
  17781. this.resetImgSrc($img);
  17782. $img.data('jg.originalSrc', undefined);
  17783. $img.data('jg.originalSrcLoc', undefined);
  17784. $img.data('jg.src', undefined);
  17785. }
  17786. // Remove caption
  17787. this.removeCaptionEventsHandlers($entry);
  17788. var $caption = this.captionFromEntry($entry);
  17789. if ($entry.data('jg.createdCaption')) {
  17790. // remove also the caption element (if created by jg)
  17791. $entry.data('jg.createdCaption', undefined);
  17792. if ($caption !== null) $caption.remove();
  17793. } else {
  17794. if ($caption !== null) $caption.fadeTo(0, 1);
  17795. }
  17796. }, this));
  17797. this.$gallery.css('height', '');
  17798. this.$gallery.removeClass('justified-gallery');
  17799. this.$gallery.data('jg.controller', undefined);
  17800. this.settings.triggerEvent.call(this, 'jg.destroy');
  17801. };
  17802. /**
  17803. * Analyze the images and builds the rows. It returns if it found an image that is not loaded.
  17804. *
  17805. * @param isForResize if the image analyzer is called for resizing or not, to call a different callback at the end
  17806. */
  17807. JustifiedGallery.prototype.analyzeImages = function (isForResize) {
  17808. for (var i = this.lastAnalyzedIndex + 1; i < this.entries.length; i++) {
  17809. var $entry = $(this.entries[i]);
  17810. if ($entry.data('jg.loaded') === true || $entry.data('jg.loaded') === 'skipped') {
  17811. var availableWidth = this.galleryWidth - 2 * this.border - (
  17812. (this.buildingRow.entriesBuff.length - 1) * this.settings.margins);
  17813. var imgAspectRatio = $entry.data('jg.width') / $entry.data('jg.height');
  17814. this.buildingRow.entriesBuff.push($entry);
  17815. this.buildingRow.aspectRatio += imgAspectRatio;
  17816. this.buildingRow.width += imgAspectRatio * this.settings.rowHeight;
  17817. this.lastAnalyzedIndex = i;
  17818. if (availableWidth / (this.buildingRow.aspectRatio + imgAspectRatio) < this.settings.rowHeight) {
  17819. this.flushRow(false, this.settings.maxRowsCount > 0 && this.rows === this.settings.maxRowsCount);
  17820. if (++this.yield.flushed >= this.yield.every) {
  17821. this.startImgAnalyzer(isForResize);
  17822. return;
  17823. }
  17824. }
  17825. } else if ($entry.data('jg.loaded') !== 'error') {
  17826. return;
  17827. }
  17828. }
  17829. // Last row flush (the row is not full)
  17830. if (this.buildingRow.entriesBuff.length > 0) {
  17831. this.flushRow(true, this.settings.maxRowsCount > 0 && this.rows === this.settings.maxRowsCount);
  17832. }
  17833. if (this.isSpinnerActive()) {
  17834. this.stopLoadingSpinnerAnimation();
  17835. }
  17836. /* Stop, if there is, the timeout to start the analyzeImages.
  17837. This is because an image can be set loaded, and the timeout can be set,
  17838. but this image can be analyzed yet.
  17839. */
  17840. this.stopImgAnalyzerStarter();
  17841. this.setGalleryFinalHeight(this.galleryHeightToSet);
  17842. //On complete callback
  17843. this.settings.triggerEvent.call(this, isForResize ? 'jg.resize' : 'jg.complete');
  17844. };
  17845. /**
  17846. * Stops any ImgAnalyzer starter (that has an assigned timeout)
  17847. */
  17848. JustifiedGallery.prototype.stopImgAnalyzerStarter = function () {
  17849. this.yield.flushed = 0;
  17850. if (this.imgAnalyzerTimeout !== null) {
  17851. clearTimeout(this.imgAnalyzerTimeout);
  17852. this.imgAnalyzerTimeout = null;
  17853. }
  17854. };
  17855. /**
  17856. * Starts the image analyzer. It is not immediately called to let the browser to update the view
  17857. *
  17858. * @param isForResize specifies if the image analyzer must be called for resizing or not
  17859. */
  17860. JustifiedGallery.prototype.startImgAnalyzer = function (isForResize) {
  17861. var that = this;
  17862. this.stopImgAnalyzerStarter();
  17863. this.imgAnalyzerTimeout = setTimeout(function () {
  17864. that.analyzeImages(isForResize);
  17865. }, 0.001); // we can't start it immediately due to a IE different behaviour
  17866. };
  17867. /**
  17868. * Checks if the image is loaded or not using another image object. We cannot use the 'complete' image property,
  17869. * because some browsers, with a 404 set complete = true.
  17870. *
  17871. * @param imageSrc the image src to load
  17872. * @param onLoad callback that is called when the image has been loaded
  17873. * @param onError callback that is called in case of an error
  17874. */
  17875. JustifiedGallery.prototype.onImageEvent = function (imageSrc, onLoad, onError) {
  17876. if (!onLoad && !onError) return;
  17877. var memImage = new Image();
  17878. var $memImage = $(memImage);
  17879. if (onLoad) {
  17880. $memImage.one('load', function () {
  17881. $memImage.off('load error');
  17882. onLoad(memImage);
  17883. });
  17884. }
  17885. if (onError) {
  17886. $memImage.one('error', function () {
  17887. $memImage.off('load error');
  17888. onError(memImage);
  17889. });
  17890. }
  17891. memImage.src = imageSrc;
  17892. };
  17893. /**
  17894. * Init of Justified Gallery controlled
  17895. * It analyzes all the entries starting theirs loading and calling the image analyzer (that works with loaded images)
  17896. */
  17897. JustifiedGallery.prototype.init = function () {
  17898. var imagesToLoad = false, skippedImages = false, that = this;
  17899. $.each(this.entries, function (index, entry) {
  17900. var $entry = $(entry);
  17901. var $image = that.imgFromEntry($entry);
  17902. $entry.addClass('jg-entry');
  17903. if ($entry.data('jg.loaded') !== true && $entry.data('jg.loaded') !== 'skipped') {
  17904. // Link Rel global overwrite
  17905. if (that.settings.rel !== null) $entry.attr('rel', that.settings.rel);
  17906. // Link Target global overwrite
  17907. if (that.settings.target !== null) $entry.attr('target', that.settings.target);
  17908. if ($image !== null) {
  17909. // Image src
  17910. var imageSrc = that.extractImgSrcFromImage($image);
  17911. /* If we have the height and the width, we don't wait that the image is loaded,
  17912. but we start directly with the justification */
  17913. if (that.settings.waitThumbnailsLoad === false || !imageSrc) {
  17914. var width = parseFloat($image.attr('width'));
  17915. var height = parseFloat($image.attr('height'));
  17916. if ($image.prop('tagName') === 'svg') {
  17917. width = parseFloat($image[0].getBBox().width);
  17918. height = parseFloat($image[0].getBBox().height);
  17919. }
  17920. if (!isNaN(width) && !isNaN(height)) {
  17921. $entry.data('jg.width', width);
  17922. $entry.data('jg.height', height);
  17923. $entry.data('jg.loaded', 'skipped');
  17924. skippedImages = true;
  17925. that.startImgAnalyzer(false);
  17926. return true; // continue
  17927. }
  17928. }
  17929. $entry.data('jg.loaded', false);
  17930. imagesToLoad = true;
  17931. // Spinner start
  17932. if (!that.isSpinnerActive()) that.startLoadingSpinnerAnimation();
  17933. that.onImageEvent(imageSrc, function (loadImg) { // image loaded
  17934. $entry.data('jg.width', loadImg.width);
  17935. $entry.data('jg.height', loadImg.height);
  17936. $entry.data('jg.loaded', true);
  17937. that.startImgAnalyzer(false);
  17938. }, function () { // image load error
  17939. $entry.data('jg.loaded', 'error');
  17940. that.startImgAnalyzer(false);
  17941. });
  17942. } else {
  17943. $entry.data('jg.loaded', true);
  17944. $entry.data('jg.width', $entry.width() | parseFloat($entry.css('width')) | 1);
  17945. $entry.data('jg.height', $entry.height() | parseFloat($entry.css('height')) | 1);
  17946. }
  17947. }
  17948. });
  17949. if (!imagesToLoad && !skippedImages) this.startImgAnalyzer(false);
  17950. this.checkWidth();
  17951. };
  17952. /**
  17953. * Checks that it is a valid number. If a string is passed it is converted to a number
  17954. *
  17955. * @param settingContainer the object that contains the setting (to allow the conversion)
  17956. * @param settingName the setting name
  17957. */
  17958. JustifiedGallery.prototype.checkOrConvertNumber = function (settingContainer, settingName) {
  17959. if ($.type(settingContainer[settingName]) === 'string') {
  17960. settingContainer[settingName] = parseFloat(settingContainer[settingName]);
  17961. }
  17962. if ($.type(settingContainer[settingName]) === 'number') {
  17963. if (isNaN(settingContainer[settingName])) throw 'invalid number for ' + settingName;
  17964. } else {
  17965. throw settingName + ' must be a number';
  17966. }
  17967. };
  17968. /**
  17969. * Checks the sizeRangeSuffixes and, if necessary, converts
  17970. * its keys from string (e.g. old settings with 'lt100') to int.
  17971. */
  17972. JustifiedGallery.prototype.checkSizeRangesSuffixes = function () {
  17973. if ($.type(this.settings.sizeRangeSuffixes) !== 'object') {
  17974. throw 'sizeRangeSuffixes must be defined and must be an object';
  17975. }
  17976. var suffixRanges = [];
  17977. for (var rangeIdx in this.settings.sizeRangeSuffixes) {
  17978. if (this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(rangeIdx);
  17979. }
  17980. var newSizeRngSuffixes = { 0: '' };
  17981. for (var i = 0; i < suffixRanges.length; i++) {
  17982. if ($.type(suffixRanges[i]) === 'string') {
  17983. try {
  17984. var numIdx = parseInt(suffixRanges[i].replace(/^[a-z]+/, ''), 10);
  17985. newSizeRngSuffixes[numIdx] = this.settings.sizeRangeSuffixes[suffixRanges[i]];
  17986. } catch (e) {
  17987. throw 'sizeRangeSuffixes keys must contains correct numbers (' + e + ')';
  17988. }
  17989. } else {
  17990. newSizeRngSuffixes[suffixRanges[i]] = this.settings.sizeRangeSuffixes[suffixRanges[i]];
  17991. }
  17992. }
  17993. this.settings.sizeRangeSuffixes = newSizeRngSuffixes;
  17994. };
  17995. /**
  17996. * check and convert the maxRowHeight setting
  17997. * requires rowHeight to be already set
  17998. * TODO: should be always called when only rowHeight is changed
  17999. * @return number or null
  18000. */
  18001. JustifiedGallery.prototype.retrieveMaxRowHeight = function () {
  18002. var newMaxRowHeight = null;
  18003. var rowHeight = this.settings.rowHeight;
  18004. if ($.type(this.settings.maxRowHeight) === 'string') {
  18005. if (this.settings.maxRowHeight.match(/^[0-9]+%$/)) {
  18006. newMaxRowHeight = rowHeight * parseFloat(this.settings.maxRowHeight.match(/^([0-9]+)%$/)[1]) / 100;
  18007. } else {
  18008. newMaxRowHeight = parseFloat(this.settings.maxRowHeight);
  18009. }
  18010. } else if ($.type(this.settings.maxRowHeight) === 'number') {
  18011. newMaxRowHeight = this.settings.maxRowHeight;
  18012. } else if (this.settings.maxRowHeight === false || this.settings.maxRowHeight == null) {
  18013. return null;
  18014. } else {
  18015. throw 'maxRowHeight must be a number or a percentage';
  18016. }
  18017. // check if the converted value is not a number
  18018. if (isNaN(newMaxRowHeight)) throw 'invalid number for maxRowHeight';
  18019. // check values, maxRowHeight must be >= rowHeight
  18020. if (newMaxRowHeight < rowHeight) newMaxRowHeight = rowHeight;
  18021. return newMaxRowHeight;
  18022. };
  18023. /**
  18024. * Checks the settings
  18025. */
  18026. JustifiedGallery.prototype.checkSettings = function () {
  18027. this.checkSizeRangesSuffixes();
  18028. this.checkOrConvertNumber(this.settings, 'rowHeight');
  18029. this.checkOrConvertNumber(this.settings, 'margins');
  18030. this.checkOrConvertNumber(this.settings, 'border');
  18031. this.checkOrConvertNumber(this.settings, 'maxRowsCount');
  18032. var lastRowModes = [
  18033. 'justify',
  18034. 'nojustify',
  18035. 'left',
  18036. 'center',
  18037. 'right',
  18038. 'hide'
  18039. ];
  18040. if (lastRowModes.indexOf(this.settings.lastRow) === -1) {
  18041. throw 'lastRow must be one of: ' + lastRowModes.join(', ');
  18042. }
  18043. this.checkOrConvertNumber(this.settings, 'justifyThreshold');
  18044. if (this.settings.justifyThreshold < 0 || this.settings.justifyThreshold > 1) {
  18045. throw 'justifyThreshold must be in the interval [0,1]';
  18046. }
  18047. if ($.type(this.settings.cssAnimation) !== 'boolean') {
  18048. throw 'cssAnimation must be a boolean';
  18049. }
  18050. if ($.type(this.settings.captions) !== 'boolean') throw 'captions must be a boolean';
  18051. this.checkOrConvertNumber(this.settings.captionSettings, 'animationDuration');
  18052. this.checkOrConvertNumber(this.settings.captionSettings, 'visibleOpacity');
  18053. if (this.settings.captionSettings.visibleOpacity < 0 ||
  18054. this.settings.captionSettings.visibleOpacity > 1) {
  18055. throw 'captionSettings.visibleOpacity must be in the interval [0, 1]';
  18056. }
  18057. this.checkOrConvertNumber(this.settings.captionSettings, 'nonVisibleOpacity');
  18058. if (this.settings.captionSettings.nonVisibleOpacity < 0 ||
  18059. this.settings.captionSettings.nonVisibleOpacity > 1) {
  18060. throw 'captionSettings.nonVisibleOpacity must be in the interval [0, 1]';
  18061. }
  18062. this.checkOrConvertNumber(this.settings, 'imagesAnimationDuration');
  18063. this.checkOrConvertNumber(this.settings, 'refreshTime');
  18064. this.checkOrConvertNumber(this.settings, 'refreshSensitivity');
  18065. if ($.type(this.settings.randomize) !== 'boolean') throw 'randomize must be a boolean';
  18066. if ($.type(this.settings.selector) !== 'string') throw 'selector must be a string';
  18067. if (this.settings.sort !== false && !$.isFunction(this.settings.sort)) {
  18068. throw 'sort must be false or a comparison function';
  18069. }
  18070. if (this.settings.filter !== false && !$.isFunction(this.settings.filter) &&
  18071. $.type(this.settings.filter) !== 'string') {
  18072. throw 'filter must be false, a string or a filter function';
  18073. }
  18074. };
  18075. /**
  18076. * It brings all the indexes from the sizeRangeSuffixes and it orders them. They are then sorted and returned.
  18077. * @returns {Array} sorted suffix ranges
  18078. */
  18079. JustifiedGallery.prototype.retrieveSuffixRanges = function () {
  18080. var suffixRanges = [];
  18081. for (var rangeIdx in this.settings.sizeRangeSuffixes) {
  18082. if (this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(parseInt(rangeIdx, 10));
  18083. }
  18084. suffixRanges.sort(function (a, b) { return a > b ? 1 : a < b ? -1 : 0; });
  18085. return suffixRanges;
  18086. };
  18087. /**
  18088. * Update the existing settings only changing some of them
  18089. *
  18090. * @param newSettings the new settings (or a subgroup of them)
  18091. */
  18092. JustifiedGallery.prototype.updateSettings = function (newSettings) {
  18093. // In this case Justified Gallery has been called again changing only some options
  18094. this.settings = $.extend({}, this.settings, newSettings);
  18095. this.checkSettings();
  18096. // As reported in the settings: negative value = same as margins, 0 = disabled
  18097. this.border = this.settings.border >= 0 ? this.settings.border : this.settings.margins;
  18098. this.maxRowHeight = this.retrieveMaxRowHeight();
  18099. this.suffixRanges = this.retrieveSuffixRanges();
  18100. };
  18101. JustifiedGallery.prototype.defaults = {
  18102. sizeRangeSuffixes: {}, /* e.g. Flickr configuration
  18103. {
  18104. 100: '_t', // used when longest is less than 100px
  18105. 240: '_m', // used when longest is between 101px and 240px
  18106. 320: '_n', // ...
  18107. 500: '',
  18108. 640: '_z',
  18109. 1024: '_b' // used as else case because it is the last
  18110. }
  18111. */
  18112. thumbnailPath: undefined, /* If defined, sizeRangeSuffixes is not used, and this function is used to determine the
  18113. path relative to a specific thumbnail size. The function should accept respectively three arguments:
  18114. current path, width and height */
  18115. rowHeight: 120, // required? required to be > 0?
  18116. maxRowHeight: false, // false or negative value to deactivate. Positive number to express the value in pixels,
  18117. // A string '[0-9]+%' to express in percentage (e.g. 300% means that the row height
  18118. // can't exceed 3 * rowHeight)
  18119. maxRowsCount: 0, // maximum number of rows to be displayed (0 = disabled)
  18120. margins: 1,
  18121. border: -1, // negative value = same as margins, 0 = disabled, any other value to set the border
  18122. lastRow: 'nojustify', // … which is the same as 'left', or can be 'justify', 'center', 'right' or 'hide'
  18123. justifyThreshold: 0.90, /* if row width / available space > 0.90 it will be always justified
  18124. * (i.e. lastRow setting is not considered) */
  18125. waitThumbnailsLoad: true,
  18126. captions: true,
  18127. cssAnimation: true,
  18128. imagesAnimationDuration: 500, // ignored with css animations
  18129. captionSettings: { // ignored with css animations
  18130. animationDuration: 500,
  18131. visibleOpacity: 0.7,
  18132. nonVisibleOpacity: 0.0
  18133. },
  18134. rel: null, // rewrite the rel of each analyzed links
  18135. target: null, // rewrite the target of all links
  18136. extension: /\.[^.\\/]+$/, // regexp to capture the extension of an image
  18137. refreshTime: 200, // time interval (in ms) to check if the page changes its width
  18138. refreshSensitivity: 0, // change in width allowed (in px) without re-building the gallery
  18139. randomize: false,
  18140. rtl: false, // right-to-left mode
  18141. sort: false, /*
  18142. - false: to do not sort
  18143. - function: to sort them using the function as comparator (see Array.prototype.sort())
  18144. */
  18145. filter: false, /*
  18146. - false, null or undefined: for a disabled filter
  18147. - a string: an entry is kept if entry.is(filter string) returns true
  18148. see jQuery's .is() function for further information
  18149. - a function: invoked with arguments (entry, index, array). Return true to keep the entry, false otherwise.
  18150. It follows the specifications of the Array.prototype.filter() function of JavaScript.
  18151. */
  18152. selector: 'a', // The selector that is used to know what are the entries of the gallery
  18153. imgSelector: '> img, > a > img, > svg, > a > svg', // The selector that is used to know what are the images of each entry
  18154. triggerEvent: function (event) { // This is called to trigger events, the default behavior is to call $.trigger
  18155. this.$gallery.trigger(event); // Consider that 'this' is this set to the JustifiedGallery object, so it can
  18156. } // access to fields such as $gallery, useful to trigger events with jQuery.
  18157. };
  18158. /**
  18159. * Justified Gallery plugin for jQuery
  18160. *
  18161. * Events
  18162. * - jg.complete : called when all the gallery has been created
  18163. * - jg.resize : called when the gallery has been resized
  18164. * - jg.rowflush : when a new row appears
  18165. *
  18166. * @param arg the action (or the settings) passed when the plugin is called
  18167. * @returns {*} the object itself
  18168. */
  18169. $.fn.justifiedGallery = function (arg) {
  18170. return this.each(function (index, gallery) {
  18171. var $gallery = $(gallery);
  18172. $gallery.addClass('justified-gallery');
  18173. var controller = $gallery.data('jg.controller');
  18174. if (typeof controller === 'undefined') {
  18175. // Create controller and assign it to the object data
  18176. if (typeof arg !== 'undefined' && arg !== null && $.type(arg) !== 'object') {
  18177. if (arg === 'destroy') return; // Just a call to an unexisting object
  18178. throw 'The argument must be an object';
  18179. }
  18180. controller = new JustifiedGallery($gallery, $.extend({}, JustifiedGallery.prototype.defaults, arg));
  18181. $gallery.data('jg.controller', controller);
  18182. } else if (arg === 'norewind') {
  18183. // In this case we don't rewind: we analyze only the latest images (e.g. to complete the last unfinished row
  18184. // ... left to be more readable
  18185. } else if (arg === 'destroy') {
  18186. controller.destroy();
  18187. return;
  18188. } else {
  18189. // In this case Justified Gallery has been called again changing only some options
  18190. controller.updateSettings(arg);
  18191. controller.rewind();
  18192. }
  18193. // Update the entries list
  18194. if (!controller.updateEntries(arg === 'norewind')) return;
  18195. // Init justified gallery
  18196. controller.init();
  18197. });
  18198. };
  18199. }));
  18200. /*!
  18201. Google Map Style
  18202. !*/
  18203. const Retro = [
  18204. {
  18205. "elementType": "geometry",
  18206. "stylers": [
  18207. {
  18208. "color": "#ebe3cd"
  18209. }
  18210. ]
  18211. },
  18212. {
  18213. "elementType": "labels.text.fill",
  18214. "stylers": [
  18215. {
  18216. "color": "#523735"
  18217. }
  18218. ]
  18219. },
  18220. {
  18221. "elementType": "labels.text.stroke",
  18222. "stylers": [
  18223. {
  18224. "color": "#f5f1e6"
  18225. }
  18226. ]
  18227. },
  18228. {
  18229. "featureType": "administrative",
  18230. "elementType": "geometry",
  18231. "stylers": [
  18232. {
  18233. "visibility": "off"
  18234. }
  18235. ]
  18236. },
  18237. {
  18238. "featureType": "administrative",
  18239. "elementType": "geometry.stroke",
  18240. "stylers": [
  18241. {
  18242. "color": "#c9b2a6"
  18243. }
  18244. ]
  18245. },
  18246. {
  18247. "featureType": "administrative.land_parcel",
  18248. "elementType": "geometry.stroke",
  18249. "stylers": [
  18250. {
  18251. "color": "#dcd2be"
  18252. }
  18253. ]
  18254. },
  18255. {
  18256. "featureType": "administrative.land_parcel",
  18257. "elementType": "labels.text.fill",
  18258. "stylers": [
  18259. {
  18260. "color": "#ae9e90"
  18261. }
  18262. ]
  18263. },
  18264. {
  18265. "featureType": "landscape.natural",
  18266. "elementType": "geometry",
  18267. "stylers": [
  18268. {
  18269. "color": "#dfd2ae"
  18270. }
  18271. ]
  18272. },
  18273. {
  18274. "featureType": "poi",
  18275. "stylers": [
  18276. {
  18277. "visibility": "off"
  18278. }
  18279. ]
  18280. },
  18281. {
  18282. "featureType": "poi",
  18283. "elementType": "geometry",
  18284. "stylers": [
  18285. {
  18286. "color": "#dfd2ae"
  18287. }
  18288. ]
  18289. },
  18290. {
  18291. "featureType": "poi",
  18292. "elementType": "labels.text.fill",
  18293. "stylers": [
  18294. {
  18295. "color": "#93817c"
  18296. }
  18297. ]
  18298. },
  18299. {
  18300. "featureType": "poi.park",
  18301. "elementType": "geometry.fill",
  18302. "stylers": [
  18303. {
  18304. "color": "#a5b076"
  18305. }
  18306. ]
  18307. },
  18308. {
  18309. "featureType": "poi.park",
  18310. "elementType": "labels.text.fill",
  18311. "stylers": [
  18312. {
  18313. "color": "#447530"
  18314. }
  18315. ]
  18316. },
  18317. {
  18318. "featureType": "road",
  18319. "elementType": "geometry",
  18320. "stylers": [
  18321. {
  18322. "color": "#f5f1e6"
  18323. }
  18324. ]
  18325. },
  18326. {
  18327. "featureType": "road",
  18328. "elementType": "labels.icon",
  18329. "stylers": [
  18330. {
  18331. "visibility": "off"
  18332. }
  18333. ]
  18334. },
  18335. {
  18336. "featureType": "road.arterial",
  18337. "elementType": "geometry",
  18338. "stylers": [
  18339. {
  18340. "color": "#fdfcf8"
  18341. }
  18342. ]
  18343. },
  18344. {
  18345. "featureType": "road.highway",
  18346. "elementType": "geometry",
  18347. "stylers": [
  18348. {
  18349. "color": "#f8c967"
  18350. }
  18351. ]
  18352. },
  18353. {
  18354. "featureType": "road.highway",
  18355. "elementType": "geometry.stroke",
  18356. "stylers": [
  18357. {
  18358. "color": "#e9bc62"
  18359. }
  18360. ]
  18361. },
  18362. {
  18363. "featureType": "road.highway.controlled_access",
  18364. "elementType": "geometry",
  18365. "stylers": [
  18366. {
  18367. "color": "#e98d58"
  18368. }
  18369. ]
  18370. },
  18371. {
  18372. "featureType": "road.highway.controlled_access",
  18373. "elementType": "geometry.stroke",
  18374. "stylers": [
  18375. {
  18376. "color": "#db8555"
  18377. }
  18378. ]
  18379. },
  18380. {
  18381. "featureType": "road.local",
  18382. "elementType": "labels.text.fill",
  18383. "stylers": [
  18384. {
  18385. "color": "#806b63"
  18386. }
  18387. ]
  18388. },
  18389. {
  18390. "featureType": "transit",
  18391. "stylers": [
  18392. {
  18393. "visibility": "off"
  18394. }
  18395. ]
  18396. },
  18397. {
  18398. "featureType": "transit.line",
  18399. "elementType": "geometry",
  18400. "stylers": [
  18401. {
  18402. "color": "#dfd2ae"
  18403. }
  18404. ]
  18405. },
  18406. {
  18407. "featureType": "transit.line",
  18408. "elementType": "labels.text.fill",
  18409. "stylers": [
  18410. {
  18411. "color": "#8f7d77"
  18412. }
  18413. ]
  18414. },
  18415. {
  18416. "featureType": "transit.line",
  18417. "elementType": "labels.text.stroke",
  18418. "stylers": [
  18419. {
  18420. "color": "#ebe3cd"
  18421. }
  18422. ]
  18423. },
  18424. {
  18425. "featureType": "transit.station",
  18426. "elementType": "geometry",
  18427. "stylers": [
  18428. {
  18429. "color": "#dfd2ae"
  18430. }
  18431. ]
  18432. },
  18433. {
  18434. "featureType": "water",
  18435. "elementType": "geometry.fill",
  18436. "stylers": [
  18437. {
  18438. "color": "#b9d3c2"
  18439. }
  18440. ]
  18441. },
  18442. {
  18443. "featureType": "water",
  18444. "elementType": "labels.text.fill",
  18445. "stylers": [
  18446. {
  18447. "color": "#92998d"
  18448. }
  18449. ]
  18450. }
  18451. ]
  18452. // Standard Style
  18453. const Standard = []
  18454. // Silver Style
  18455. const Silver = [
  18456. {
  18457. "elementType": "geometry",
  18458. "stylers": [
  18459. {
  18460. "color": "#f5f5f5"
  18461. }
  18462. ]
  18463. },
  18464. {
  18465. "elementType": "labels.icon",
  18466. "stylers": [
  18467. {
  18468. "visibility": "off"
  18469. }
  18470. ]
  18471. },
  18472. {
  18473. "elementType": "labels.text.fill",
  18474. "stylers": [
  18475. {
  18476. "color": "#616161"
  18477. }
  18478. ]
  18479. },
  18480. {
  18481. "elementType": "labels.text.stroke",
  18482. "stylers": [
  18483. {
  18484. "color": "#f5f5f5"
  18485. }
  18486. ]
  18487. },
  18488. {
  18489. "featureType": "administrative.land_parcel",
  18490. "elementType": "labels.text.fill",
  18491. "stylers": [
  18492. {
  18493. "color": "#bdbdbd"
  18494. }
  18495. ]
  18496. },
  18497. {
  18498. "featureType": "poi",
  18499. "elementType": "geometry",
  18500. "stylers": [
  18501. {
  18502. "color": "#eeeeee"
  18503. }
  18504. ]
  18505. },
  18506. {
  18507. "featureType": "poi",
  18508. "elementType": "labels.text.fill",
  18509. "stylers": [
  18510. {
  18511. "color": "#757575"
  18512. }
  18513. ]
  18514. },
  18515. {
  18516. "featureType": "poi.park",
  18517. "elementType": "geometry",
  18518. "stylers": [
  18519. {
  18520. "color": "#e5e5e5"
  18521. }
  18522. ]
  18523. },
  18524. {
  18525. "featureType": "poi.park",
  18526. "elementType": "labels.text.fill",
  18527. "stylers": [
  18528. {
  18529. "color": "#9e9e9e"
  18530. }
  18531. ]
  18532. },
  18533. {
  18534. "featureType": "road",
  18535. "elementType": "geometry",
  18536. "stylers": [
  18537. {
  18538. "color": "#ffffff"
  18539. }
  18540. ]
  18541. },
  18542. {
  18543. "featureType": "road.arterial",
  18544. "elementType": "labels.text.fill",
  18545. "stylers": [
  18546. {
  18547. "color": "#757575"
  18548. }
  18549. ]
  18550. },
  18551. {
  18552. "featureType": "road.highway",
  18553. "elementType": "geometry",
  18554. "stylers": [
  18555. {
  18556. "color": "#dadada"
  18557. }
  18558. ]
  18559. },
  18560. {
  18561. "featureType": "road.highway",
  18562. "elementType": "labels.text.fill",
  18563. "stylers": [
  18564. {
  18565. "color": "#616161"
  18566. }
  18567. ]
  18568. },
  18569. {
  18570. "featureType": "road.local",
  18571. "elementType": "labels.text.fill",
  18572. "stylers": [
  18573. {
  18574. "color": "#9e9e9e"
  18575. }
  18576. ]
  18577. },
  18578. {
  18579. "featureType": "transit.line",
  18580. "elementType": "geometry",
  18581. "stylers": [
  18582. {
  18583. "color": "#e5e5e5"
  18584. }
  18585. ]
  18586. },
  18587. {
  18588. "featureType": "transit.station",
  18589. "elementType": "geometry",
  18590. "stylers": [
  18591. {
  18592. "color": "#eeeeee"
  18593. }
  18594. ]
  18595. },
  18596. {
  18597. "featureType": "water",
  18598. "elementType": "geometry",
  18599. "stylers": [
  18600. {
  18601. "color": "#c9c9c9"
  18602. }
  18603. ]
  18604. },
  18605. {
  18606. "featureType": "water",
  18607. "elementType": "labels.text.fill",
  18608. "stylers": [
  18609. {
  18610. "color": "#9e9e9e"
  18611. }
  18612. ]
  18613. }
  18614. ]
  18615. // Dark Style
  18616. const Dark = [
  18617. {
  18618. "elementType": "geometry",
  18619. "stylers": [
  18620. {
  18621. "color": "#212121"
  18622. }
  18623. ]
  18624. },
  18625. {
  18626. "elementType": "labels.icon",
  18627. "stylers": [
  18628. {
  18629. "visibility": "off"
  18630. }
  18631. ]
  18632. },
  18633. {
  18634. "elementType": "labels.text.fill",
  18635. "stylers": [
  18636. {
  18637. "color": "#757575"
  18638. }
  18639. ]
  18640. },
  18641. {
  18642. "elementType": "labels.text.stroke",
  18643. "stylers": [
  18644. {
  18645. "color": "#212121"
  18646. }
  18647. ]
  18648. },
  18649. {
  18650. "featureType": "administrative",
  18651. "elementType": "geometry",
  18652. "stylers": [
  18653. {
  18654. "color": "#757575"
  18655. },
  18656. {
  18657. "visibility": "off"
  18658. }
  18659. ]
  18660. },
  18661. {
  18662. "featureType": "administrative.country",
  18663. "elementType": "labels.text.fill",
  18664. "stylers": [
  18665. {
  18666. "color": "#9e9e9e"
  18667. }
  18668. ]
  18669. },
  18670. {
  18671. "featureType": "administrative.land_parcel",
  18672. "stylers": [
  18673. {
  18674. "visibility": "off"
  18675. }
  18676. ]
  18677. },
  18678. {
  18679. "featureType": "administrative.locality",
  18680. "elementType": "labels.text.fill",
  18681. "stylers": [
  18682. {
  18683. "color": "#bdbdbd"
  18684. }
  18685. ]
  18686. },
  18687. {
  18688. "featureType": "poi",
  18689. "stylers": [
  18690. {
  18691. "visibility": "off"
  18692. }
  18693. ]
  18694. },
  18695. {
  18696. "featureType": "poi",
  18697. "elementType": "labels.text.fill",
  18698. "stylers": [
  18699. {
  18700. "color": "#757575"
  18701. }
  18702. ]
  18703. },
  18704. {
  18705. "featureType": "poi.park",
  18706. "elementType": "geometry",
  18707. "stylers": [
  18708. {
  18709. "color": "#181818"
  18710. }
  18711. ]
  18712. },
  18713. {
  18714. "featureType": "poi.park",
  18715. "elementType": "labels.text.fill",
  18716. "stylers": [
  18717. {
  18718. "color": "#616161"
  18719. }
  18720. ]
  18721. },
  18722. {
  18723. "featureType": "poi.park",
  18724. "elementType": "labels.text.stroke",
  18725. "stylers": [
  18726. {
  18727. "color": "#1b1b1b"
  18728. }
  18729. ]
  18730. },
  18731. {
  18732. "featureType": "road",
  18733. "elementType": "geometry.fill",
  18734. "stylers": [
  18735. {
  18736. "color": "#2c2c2c"
  18737. }
  18738. ]
  18739. },
  18740. {
  18741. "featureType": "road",
  18742. "elementType": "labels.icon",
  18743. "stylers": [
  18744. {
  18745. "visibility": "off"
  18746. }
  18747. ]
  18748. },
  18749. {
  18750. "featureType": "road",
  18751. "elementType": "labels.text.fill",
  18752. "stylers": [
  18753. {
  18754. "color": "#8a8a8a"
  18755. }
  18756. ]
  18757. },
  18758. {
  18759. "featureType": "road.arterial",
  18760. "elementType": "geometry",
  18761. "stylers": [
  18762. {
  18763. "color": "#373737"
  18764. }
  18765. ]
  18766. },
  18767. {
  18768. "featureType": "road.highway",
  18769. "elementType": "geometry",
  18770. "stylers": [
  18771. {
  18772. "color": "#3c3c3c"
  18773. }
  18774. ]
  18775. },
  18776. {
  18777. "featureType": "road.highway.controlled_access",
  18778. "elementType": "geometry",
  18779. "stylers": [
  18780. {
  18781. "color": "#4e4e4e"
  18782. }
  18783. ]
  18784. },
  18785. {
  18786. "featureType": "road.local",
  18787. "elementType": "labels.text.fill",
  18788. "stylers": [
  18789. {
  18790. "color": "#616161"
  18791. }
  18792. ]
  18793. },
  18794. {
  18795. "featureType": "transit",
  18796. "stylers": [
  18797. {
  18798. "visibility": "off"
  18799. }
  18800. ]
  18801. },
  18802. {
  18803. "featureType": "transit",
  18804. "elementType": "labels.text.fill",
  18805. "stylers": [
  18806. {
  18807. "color": "#757575"
  18808. }
  18809. ]
  18810. },
  18811. {
  18812. "featureType": "water",
  18813. "elementType": "geometry",
  18814. "stylers": [
  18815. {
  18816. "color": "#000000"
  18817. }
  18818. ]
  18819. },
  18820. {
  18821. "featureType": "water",
  18822. "elementType": "labels.text.fill",
  18823. "stylers": [
  18824. {
  18825. "color": "#3d3d3d"
  18826. }
  18827. ]
  18828. }
  18829. ]
  18830. // Night Style
  18831. const Night = [
  18832. {
  18833. "elementType": "geometry",
  18834. "stylers": [
  18835. {
  18836. "color": "#242f3e"
  18837. }
  18838. ]
  18839. },
  18840. {
  18841. "elementType": "labels.text.fill",
  18842. "stylers": [
  18843. {
  18844. "color": "#746855"
  18845. }
  18846. ]
  18847. },
  18848. {
  18849. "elementType": "labels.text.stroke",
  18850. "stylers": [
  18851. {
  18852. "color": "#242f3e"
  18853. }
  18854. ]
  18855. },
  18856. {
  18857. "featureType": "administrative",
  18858. "elementType": "geometry",
  18859. "stylers": [
  18860. {
  18861. "visibility": "off"
  18862. }
  18863. ]
  18864. },
  18865. {
  18866. "featureType": "administrative.locality",
  18867. "elementType": "labels.text.fill",
  18868. "stylers": [
  18869. {
  18870. "color": "#d59563"
  18871. }
  18872. ]
  18873. },
  18874. {
  18875. "featureType": "poi",
  18876. "stylers": [
  18877. {
  18878. "visibility": "off"
  18879. }
  18880. ]
  18881. },
  18882. {
  18883. "featureType": "poi",
  18884. "elementType": "labels.text.fill",
  18885. "stylers": [
  18886. {
  18887. "color": "#d59563"
  18888. }
  18889. ]
  18890. },
  18891. {
  18892. "featureType": "poi.park",
  18893. "elementType": "geometry",
  18894. "stylers": [
  18895. {
  18896. "color": "#263c3f"
  18897. }
  18898. ]
  18899. },
  18900. {
  18901. "featureType": "poi.park",
  18902. "elementType": "labels.text.fill",
  18903. "stylers": [
  18904. {
  18905. "color": "#6b9a76"
  18906. }
  18907. ]
  18908. },
  18909. {
  18910. "featureType": "road",
  18911. "elementType": "geometry",
  18912. "stylers": [
  18913. {
  18914. "color": "#38414e"
  18915. }
  18916. ]
  18917. },
  18918. {
  18919. "featureType": "road",
  18920. "elementType": "geometry.stroke",
  18921. "stylers": [
  18922. {
  18923. "color": "#212a37"
  18924. }
  18925. ]
  18926. },
  18927. {
  18928. "featureType": "road",
  18929. "elementType": "labels.icon",
  18930. "stylers": [
  18931. {
  18932. "visibility": "off"
  18933. }
  18934. ]
  18935. },
  18936. {
  18937. "featureType": "road",
  18938. "elementType": "labels.text.fill",
  18939. "stylers": [
  18940. {
  18941. "color": "#9ca5b3"
  18942. }
  18943. ]
  18944. },
  18945. {
  18946. "featureType": "road.highway",
  18947. "elementType": "geometry",
  18948. "stylers": [
  18949. {
  18950. "color": "#746855"
  18951. }
  18952. ]
  18953. },
  18954. {
  18955. "featureType": "road.highway",
  18956. "elementType": "geometry.stroke",
  18957. "stylers": [
  18958. {
  18959. "color": "#1f2835"
  18960. }
  18961. ]
  18962. },
  18963. {
  18964. "featureType": "road.highway",
  18965. "elementType": "labels.text.fill",
  18966. "stylers": [
  18967. {
  18968. "color": "#f3d19c"
  18969. }
  18970. ]
  18971. },
  18972. {
  18973. "featureType": "transit",
  18974. "stylers": [
  18975. {
  18976. "visibility": "off"
  18977. }
  18978. ]
  18979. },
  18980. {
  18981. "featureType": "transit",
  18982. "elementType": "geometry",
  18983. "stylers": [
  18984. {
  18985. "color": "#2f3948"
  18986. }
  18987. ]
  18988. },
  18989. {
  18990. "featureType": "transit.station",
  18991. "elementType": "labels.text.fill",
  18992. "stylers": [
  18993. {
  18994. "color": "#d59563"
  18995. }
  18996. ]
  18997. },
  18998. {
  18999. "featureType": "water",
  19000. "elementType": "geometry",
  19001. "stylers": [
  19002. {
  19003. "color": "#17263c"
  19004. }
  19005. ]
  19006. },
  19007. {
  19008. "featureType": "water",
  19009. "elementType": "labels.text.fill",
  19010. "stylers": [
  19011. {
  19012. "color": "#515c6d"
  19013. }
  19014. ]
  19015. },
  19016. {
  19017. "featureType": "water",
  19018. "elementType": "labels.text.stroke",
  19019. "stylers": [
  19020. {
  19021. "color": "#17263c"
  19022. }
  19023. ]
  19024. }
  19025. ]
  19026. // Aubergine Style
  19027. const Aubergine = [
  19028. {
  19029. "elementType": "geometry",
  19030. "stylers": [
  19031. {
  19032. "color": "#1d2c4d"
  19033. }
  19034. ]
  19035. },
  19036. {
  19037. "elementType": "labels.text.fill",
  19038. "stylers": [
  19039. {
  19040. "color": "#8ec3b9"
  19041. }
  19042. ]
  19043. },
  19044. {
  19045. "elementType": "labels.text.stroke",
  19046. "stylers": [
  19047. {
  19048. "color": "#1a3646"
  19049. }
  19050. ]
  19051. },
  19052. {
  19053. "featureType": "administrative",
  19054. "elementType": "geometry",
  19055. "stylers": [
  19056. {
  19057. "visibility": "off"
  19058. }
  19059. ]
  19060. },
  19061. {
  19062. "featureType": "administrative.country",
  19063. "elementType": "geometry.stroke",
  19064. "stylers": [
  19065. {
  19066. "color": "#4b6878"
  19067. }
  19068. ]
  19069. },
  19070. {
  19071. "featureType": "administrative.land_parcel",
  19072. "elementType": "labels.text.fill",
  19073. "stylers": [
  19074. {
  19075. "color": "#64779e"
  19076. }
  19077. ]
  19078. },
  19079. {
  19080. "featureType": "administrative.province",
  19081. "elementType": "geometry.stroke",
  19082. "stylers": [
  19083. {
  19084. "color": "#4b6878"
  19085. }
  19086. ]
  19087. },
  19088. {
  19089. "featureType": "landscape.man_made",
  19090. "elementType": "geometry.stroke",
  19091. "stylers": [
  19092. {
  19093. "color": "#334e87"
  19094. }
  19095. ]
  19096. },
  19097. {
  19098. "featureType": "landscape.natural",
  19099. "elementType": "geometry",
  19100. "stylers": [
  19101. {
  19102. "color": "#023e58"
  19103. }
  19104. ]
  19105. },
  19106. {
  19107. "featureType": "poi",
  19108. "stylers": [
  19109. {
  19110. "visibility": "off"
  19111. }
  19112. ]
  19113. },
  19114. {
  19115. "featureType": "poi",
  19116. "elementType": "geometry",
  19117. "stylers": [
  19118. {
  19119. "color": "#283d6a"
  19120. }
  19121. ]
  19122. },
  19123. {
  19124. "featureType": "poi",
  19125. "elementType": "labels.text.fill",
  19126. "stylers": [
  19127. {
  19128. "color": "#6f9ba5"
  19129. }
  19130. ]
  19131. },
  19132. {
  19133. "featureType": "poi",
  19134. "elementType": "labels.text.stroke",
  19135. "stylers": [
  19136. {
  19137. "color": "#1d2c4d"
  19138. }
  19139. ]
  19140. },
  19141. {
  19142. "featureType": "poi.park",
  19143. "elementType": "geometry.fill",
  19144. "stylers": [
  19145. {
  19146. "color": "#023e58"
  19147. }
  19148. ]
  19149. },
  19150. {
  19151. "featureType": "poi.park",
  19152. "elementType": "labels.text.fill",
  19153. "stylers": [
  19154. {
  19155. "color": "#3C7680"
  19156. }
  19157. ]
  19158. },
  19159. {
  19160. "featureType": "road",
  19161. "elementType": "geometry",
  19162. "stylers": [
  19163. {
  19164. "color": "#304a7d"
  19165. }
  19166. ]
  19167. },
  19168. {
  19169. "featureType": "road",
  19170. "elementType": "labels.icon",
  19171. "stylers": [
  19172. {
  19173. "visibility": "off"
  19174. }
  19175. ]
  19176. },
  19177. {
  19178. "featureType": "road",
  19179. "elementType": "labels.text.fill",
  19180. "stylers": [
  19181. {
  19182. "color": "#98a5be"
  19183. }
  19184. ]
  19185. },
  19186. {
  19187. "featureType": "road",
  19188. "elementType": "labels.text.stroke",
  19189. "stylers": [
  19190. {
  19191. "color": "#1d2c4d"
  19192. }
  19193. ]
  19194. },
  19195. {
  19196. "featureType": "road.highway",
  19197. "elementType": "geometry",
  19198. "stylers": [
  19199. {
  19200. "color": "#2c6675"
  19201. }
  19202. ]
  19203. },
  19204. {
  19205. "featureType": "road.highway",
  19206. "elementType": "geometry.stroke",
  19207. "stylers": [
  19208. {
  19209. "color": "#255763"
  19210. }
  19211. ]
  19212. },
  19213. {
  19214. "featureType": "road.highway",
  19215. "elementType": "labels.text.fill",
  19216. "stylers": [
  19217. {
  19218. "color": "#b0d5ce"
  19219. }
  19220. ]
  19221. },
  19222. {
  19223. "featureType": "road.highway",
  19224. "elementType": "labels.text.stroke",
  19225. "stylers": [
  19226. {
  19227. "color": "#023e58"
  19228. }
  19229. ]
  19230. },
  19231. {
  19232. "featureType": "transit",
  19233. "stylers": [
  19234. {
  19235. "visibility": "off"
  19236. }
  19237. ]
  19238. },
  19239. {
  19240. "featureType": "transit",
  19241. "elementType": "labels.text.fill",
  19242. "stylers": [
  19243. {
  19244. "color": "#98a5be"
  19245. }
  19246. ]
  19247. },
  19248. {
  19249. "featureType": "transit",
  19250. "elementType": "labels.text.stroke",
  19251. "stylers": [
  19252. {
  19253. "color": "#1d2c4d"
  19254. }
  19255. ]
  19256. },
  19257. {
  19258. "featureType": "transit.line",
  19259. "elementType": "geometry.fill",
  19260. "stylers": [
  19261. {
  19262. "color": "#283d6a"
  19263. }
  19264. ]
  19265. },
  19266. {
  19267. "featureType": "transit.station",
  19268. "elementType": "geometry",
  19269. "stylers": [
  19270. {
  19271. "color": "#3a4762"
  19272. }
  19273. ]
  19274. },
  19275. {
  19276. "featureType": "water",
  19277. "elementType": "geometry",
  19278. "stylers": [
  19279. {
  19280. "color": "#0e1626"
  19281. }
  19282. ]
  19283. },
  19284. {
  19285. "featureType": "water",
  19286. "elementType": "labels.text.fill",
  19287. "stylers": [
  19288. {
  19289. "color": "#4e6d70"
  19290. }
  19291. ]
  19292. }
  19293. ]
  19294. /*!
  19295. Crafto - Parallax
  19296. Created by ThemeZaa
  19297. !*/
  19298. !function(n){var t=n(window),o=t.height();t.resize(function(){o=t.height()}),n.fn.parallax=function(i,e,l){var r,u=n(this);function c(){var l=t.scrollTop();u.each(function(){var t=n(this),c=t.offset().top;c+r(t)<l||c>l+o||(n(window).width()>1050?u.css("backgroundPosition",i+" "+(c-l)*e+"px"):u.css("backgroundPosition",""))})}u.each(function(n){u.offset().top}),(arguments.length<1||null===i)&&(i="50%"),(arguments.length<2||null===e)&&(e=.5),(arguments.length<3||null===l)&&(l=!0),(arguments.length<4||null===pos)&&(pos=0),r=l?function(n){return n.outerHeight(!0)}:function(n){return n.height()},t.bind("scroll",c).resize(c),c()},n.fn.parallaxImg=function(i,e){var l,r=n(this);function u(){var e=t.scrollTop();r.each(function(){var t=n(this),u=t.offset().top;u+l(t)<e||u>e+o||(n(window).width()>1050?r.css("bottom",i/10*-(u-e)+"px"):r.css("bottom",""))})}(arguments.length<1||null===i)&&(i=1),(arguments.length<2||null===e)&&(e=!0),l=e?function(n){return n.outerHeight(!0)}:function(n){return n.height()},t.bind("scroll",u).resize(u),u()}}(jQuery);
  19299. /*!
  19300. Crafto - Parallax Liquid Image
  19301. Created by ThemeZaa
  19302. !*/
  19303. ! function(n) {
  19304. var t = n(window),
  19305. o = t.height();
  19306. t.resize(function() {
  19307. o = t.height()
  19308. }), n.fn.parallaxLiquidImg = function(i, scale, scaleFraction, reverse, e) {
  19309. var l, r = n(this);
  19310. var canScale = scale ? 1 : 0;
  19311. var scale = scale ? scale : 1.2;
  19312. var scaleFraction = scaleFraction ? scaleFraction : 0.001;
  19313. var lastScrollPos = 0;
  19314. var scrollDir = '';
  19315. function u() {
  19316. var e = t.scrollTop();
  19317. r.each(function() {
  19318. var t = n(this),
  19319. u = t.offset().top,
  19320. tHeight = t.outerHeight(),
  19321. uOffesetBottom = u + tHeight;
  19322. if(e > lastScrollPos) {
  19323. scrollDir = 'forward';
  19324. } else{
  19325. scrollDir = 'reverse';
  19326. }
  19327. lastScrollPos = e;
  19328. if (u < n(window).height()+e && uOffesetBottom > e) {
  19329. if (scrollDir == 'forward') {
  19330. scale = scale + scaleFraction;
  19331. } else {
  19332. scale = scale - scaleFraction;
  19333. }
  19334. }
  19335. if (reverse) {
  19336. if (t.attr('data-parallax-scale')) {
  19337. u + l(t) < e || u > e + o || (
  19338. n(window).width() > 1050
  19339. ? (anime({targets: r[0], translateY: i / 6 * (u - e) + "px", scale: canScale ? scale : 1}))
  19340. : r.css("transform", "translateY(0px)")
  19341. )
  19342. } else {
  19343. u + l(t) < e || u > e + o || (
  19344. n(window).width() > 1050
  19345. ? (anime({targets: r[0], translateY: i / 20 * -(u - e) + "px", scale: canScale ? scale : 1}))
  19346. : r.css("transform", "translateY(0px)")
  19347. )
  19348. }
  19349. } else {
  19350. if (t.attr('data-parallax-scale')) {
  19351. u + l(t) < e || u > e + o || (
  19352. n(window).width() > 1050
  19353. ? (anime({targets: r[0], translateY: i / 6 * -(u - e) + "px", scale: canScale ? scale : 1}))
  19354. : r.css("transform", "translateY(0px)")
  19355. )
  19356. } else {
  19357. u + l(t) < e || u > e + o || (
  19358. n(window).width() > 1050
  19359. ? (anime({targets: r[0], translateY: i / 20 * (u - e) + "px", scale: canScale ? scale : 1}))
  19360. : r.css("transform", "translateY(0px)")
  19361. )
  19362. }
  19363. }
  19364. })
  19365. }(arguments.length < 1 || null === i) && (i = 1), (arguments.length < 2 || null === e) && (e = !0), l = e ? function(n) {
  19366. return n.outerHeight(!0)
  19367. } : function(n) {
  19368. return n.height()
  19369. }, t.bind("scroll", u).resize(u), u()
  19370. }
  19371. }(jQuery);
  19372. /*!
  19373. Particles
  19374. Version: 2.0.0
  19375. Plugin URL: https://vincentgarreau.com/particles.js/
  19376. License: Copyright Vincent Garreau - vincentgarreau.com | Licensed under MIT
  19377. !*/
  19378. var pJS = function(tag_id, params){
  19379. var canvas_el = document.querySelector('#'+tag_id+' > .particles-js-canvas-el');
  19380. /* particles.js variables with default values */
  19381. this.pJS = {
  19382. canvas: {
  19383. el: canvas_el,
  19384. w: canvas_el.offsetWidth,
  19385. h: canvas_el.offsetHeight
  19386. },
  19387. particles: {
  19388. number: {
  19389. value: 400,
  19390. density: {
  19391. enable: true,
  19392. value_area: 800
  19393. }
  19394. },
  19395. color: {
  19396. value: '#fff'
  19397. },
  19398. shape: {
  19399. type: 'circle',
  19400. stroke: {
  19401. width: 0,
  19402. color: '#ff0000'
  19403. },
  19404. polygon: {
  19405. nb_sides: 5
  19406. },
  19407. image: {
  19408. src: '',
  19409. width: 100,
  19410. height: 100
  19411. }
  19412. },
  19413. opacity: {
  19414. value: 1,
  19415. random: false,
  19416. anim: {
  19417. enable: false,
  19418. speed: 2,
  19419. opacity_min: 0,
  19420. sync: false
  19421. }
  19422. },
  19423. size: {
  19424. value: 20,
  19425. random: false,
  19426. anim: {
  19427. enable: false,
  19428. speed: 20,
  19429. size_min: 0,
  19430. sync: false
  19431. }
  19432. },
  19433. line_linked: {
  19434. enable: true,
  19435. distance: 100,
  19436. color: '#fff',
  19437. opacity: 1,
  19438. width: 1
  19439. },
  19440. move: {
  19441. enable: true,
  19442. speed: 2,
  19443. direction: 'none',
  19444. random: false,
  19445. straight: false,
  19446. out_mode: 'out',
  19447. bounce: false,
  19448. attract: {
  19449. enable: false,
  19450. rotateX: 3000,
  19451. rotateY: 3000
  19452. }
  19453. },
  19454. array: []
  19455. },
  19456. interactivity: {
  19457. detect_on: 'canvas',
  19458. events: {
  19459. onhover: {
  19460. enable: true,
  19461. mode: 'grab'
  19462. },
  19463. onclick: {
  19464. enable: true,
  19465. mode: 'push'
  19466. },
  19467. resize: true
  19468. },
  19469. modes: {
  19470. grab:{
  19471. distance: 100,
  19472. line_linked:{
  19473. opacity: 1
  19474. }
  19475. },
  19476. bubble:{
  19477. distance: 200,
  19478. size: 80,
  19479. duration: 0.4
  19480. },
  19481. repulse:{
  19482. distance: 200,
  19483. duration: 0.4
  19484. },
  19485. push:{
  19486. particles_nb: 4
  19487. },
  19488. remove:{
  19489. particles_nb: 2
  19490. }
  19491. },
  19492. mouse:{}
  19493. },
  19494. retina_detect: false,
  19495. fn: {
  19496. interact: {},
  19497. modes: {},
  19498. vendors:{}
  19499. },
  19500. tmp: {}
  19501. };
  19502. var pJS = this.pJS;
  19503. /* params settings */
  19504. if(params){
  19505. Object.deepExtend(pJS, params);
  19506. }
  19507. pJS.tmp.obj = {
  19508. size_value: pJS.particles.size.value,
  19509. size_anim_speed: pJS.particles.size.anim.speed,
  19510. move_speed: pJS.particles.move.speed,
  19511. line_linked_distance: pJS.particles.line_linked.distance,
  19512. line_linked_width: pJS.particles.line_linked.width,
  19513. mode_grab_distance: pJS.interactivity.modes.grab.distance,
  19514. mode_bubble_distance: pJS.interactivity.modes.bubble.distance,
  19515. mode_bubble_size: pJS.interactivity.modes.bubble.size,
  19516. mode_repulse_distance: pJS.interactivity.modes.repulse.distance
  19517. };
  19518. pJS.fn.retinaInit = function(){
  19519. if(pJS.retina_detect && window.devicePixelRatio > 1){
  19520. pJS.canvas.pxratio = window.devicePixelRatio;
  19521. pJS.tmp.retina = true;
  19522. }
  19523. else{
  19524. pJS.canvas.pxratio = 1;
  19525. pJS.tmp.retina = false;
  19526. }
  19527. pJS.canvas.w = pJS.canvas.el.offsetWidth * pJS.canvas.pxratio;
  19528. pJS.canvas.h = pJS.canvas.el.offsetHeight * pJS.canvas.pxratio;
  19529. pJS.particles.size.value = pJS.tmp.obj.size_value * pJS.canvas.pxratio;
  19530. pJS.particles.size.anim.speed = pJS.tmp.obj.size_anim_speed * pJS.canvas.pxratio;
  19531. pJS.particles.move.speed = pJS.tmp.obj.move_speed * pJS.canvas.pxratio;
  19532. pJS.particles.line_linked.distance = pJS.tmp.obj.line_linked_distance * pJS.canvas.pxratio;
  19533. pJS.interactivity.modes.grab.distance = pJS.tmp.obj.mode_grab_distance * pJS.canvas.pxratio;
  19534. pJS.interactivity.modes.bubble.distance = pJS.tmp.obj.mode_bubble_distance * pJS.canvas.pxratio;
  19535. pJS.particles.line_linked.width = pJS.tmp.obj.line_linked_width * pJS.canvas.pxratio;
  19536. pJS.interactivity.modes.bubble.size = pJS.tmp.obj.mode_bubble_size * pJS.canvas.pxratio;
  19537. pJS.interactivity.modes.repulse.distance = pJS.tmp.obj.mode_repulse_distance * pJS.canvas.pxratio;
  19538. };
  19539. /* ---------- pJS functions - canvas ------------ */
  19540. pJS.fn.canvasInit = function(){
  19541. pJS.canvas.ctx = pJS.canvas.el.getContext('2d');
  19542. };
  19543. pJS.fn.canvasSize = function(){
  19544. pJS.canvas.el.width = pJS.canvas.w;
  19545. pJS.canvas.el.height = pJS.canvas.h;
  19546. if(pJS && pJS.interactivity.events.resize){
  19547. window.addEventListener('resize', function(){
  19548. pJS.canvas.w = pJS.canvas.el.offsetWidth;
  19549. pJS.canvas.h = pJS.canvas.el.offsetHeight;
  19550. /* resize canvas */
  19551. if(pJS.tmp.retina){
  19552. pJS.canvas.w *= pJS.canvas.pxratio;
  19553. pJS.canvas.h *= pJS.canvas.pxratio;
  19554. }
  19555. pJS.canvas.el.width = pJS.canvas.w;
  19556. pJS.canvas.el.height = pJS.canvas.h;
  19557. /* repaint canvas on anim disabled */
  19558. if(!pJS.particles.move.enable){
  19559. pJS.fn.particlesEmpty();
  19560. pJS.fn.particlesCreate();
  19561. pJS.fn.particlesDraw();
  19562. pJS.fn.vendors.densityAutoParticles();
  19563. }
  19564. /* density particles enabled */
  19565. pJS.fn.vendors.densityAutoParticles();
  19566. });
  19567. }
  19568. };
  19569. pJS.fn.canvasPaint = function(){
  19570. pJS.canvas.ctx.fillRect(0, 0, pJS.canvas.w, pJS.canvas.h);
  19571. };
  19572. pJS.fn.canvasClear = function(){
  19573. pJS.canvas.ctx.clearRect(0, 0, pJS.canvas.w, pJS.canvas.h);
  19574. };
  19575. /* --------- pJS functions - particles ----------- */
  19576. pJS.fn.particle = function(color, opacity, position){
  19577. /* size */
  19578. this.radius = (pJS.particles.size.random ? Math.random() : 1) * pJS.particles.size.value;
  19579. if(pJS.particles.size.anim.enable){
  19580. this.size_status = false;
  19581. this.vs = pJS.particles.size.anim.speed / 100;
  19582. if(!pJS.particles.size.anim.sync){
  19583. this.vs = this.vs * Math.random();
  19584. }
  19585. }
  19586. /* position */
  19587. this.x = position ? position.x : Math.random() * pJS.canvas.w;
  19588. this.y = position ? position.y : Math.random() * pJS.canvas.h;
  19589. /* check position - into the canvas */
  19590. if(this.x > pJS.canvas.w - this.radius*2) this.x = this.x - this.radius;
  19591. else if(this.x < this.radius*2) this.x = this.x + this.radius;
  19592. if(this.y > pJS.canvas.h - this.radius*2) this.y = this.y - this.radius;
  19593. else if(this.y < this.radius*2) this.y = this.y + this.radius;
  19594. /* check position - avoid overlap */
  19595. if(pJS.particles.move.bounce){
  19596. pJS.fn.vendors.checkOverlap(this, position);
  19597. }
  19598. /* color */
  19599. this.color = {};
  19600. if(typeof(color.value) == 'object'){
  19601. if(color.value instanceof Array){
  19602. var color_selected = color.value[Math.floor(Math.random() * pJS.particles.color.value.length)];
  19603. this.color.rgb = hexToRgb(color_selected);
  19604. }else{
  19605. if(color.value.r != undefined && color.value.g != undefined && color.value.b != undefined){
  19606. this.color.rgb = {
  19607. r: color.value.r,
  19608. g: color.value.g,
  19609. b: color.value.b
  19610. }
  19611. }
  19612. if(color.value.h != undefined && color.value.s != undefined && color.value.l != undefined){
  19613. this.color.hsl = {
  19614. h: color.value.h,
  19615. s: color.value.s,
  19616. l: color.value.l
  19617. }
  19618. }
  19619. }
  19620. }
  19621. else if(color.value == 'random'){
  19622. this.color.rgb = {
  19623. r: (Math.floor(Math.random() * (255 - 0 + 1)) + 0),
  19624. g: (Math.floor(Math.random() * (255 - 0 + 1)) + 0),
  19625. b: (Math.floor(Math.random() * (255 - 0 + 1)) + 0)
  19626. }
  19627. }
  19628. else if(typeof(color.value) == 'string'){
  19629. this.color = color;
  19630. this.color.rgb = hexToRgb(this.color.value);
  19631. }
  19632. /* opacity */
  19633. this.opacity = (pJS.particles.opacity.random ? Math.random() : 1) * pJS.particles.opacity.value;
  19634. if(pJS.particles.opacity.anim.enable){
  19635. this.opacity_status = false;
  19636. this.vo = pJS.particles.opacity.anim.speed / 100;
  19637. if(!pJS.particles.opacity.anim.sync){
  19638. this.vo = this.vo * Math.random();
  19639. }
  19640. }
  19641. /* animation - velocity for speed */
  19642. var velbase = {}
  19643. switch(pJS.particles.move.direction){
  19644. case 'top':
  19645. velbase = { x:0, y:-1 };
  19646. break;
  19647. case 'top-right':
  19648. velbase = { x:0.5, y:-0.5 };
  19649. break;
  19650. case 'right':
  19651. velbase = { x:1, y:-0 };
  19652. break;
  19653. case 'bottom-right':
  19654. velbase = { x:0.5, y:0.5 };
  19655. break;
  19656. case 'bottom':
  19657. velbase = { x:0, y:1 };
  19658. break;
  19659. case 'bottom-left':
  19660. velbase = { x:-0.5, y:1 };
  19661. break;
  19662. case 'left':
  19663. velbase = { x:-1, y:0 };
  19664. break;
  19665. case 'top-left':
  19666. velbase = { x:-0.5, y:-0.5 };
  19667. break;
  19668. default:
  19669. velbase = { x:0, y:0 };
  19670. break;
  19671. }
  19672. if(pJS.particles.move.straight){
  19673. this.vx = velbase.x;
  19674. this.vy = velbase.y;
  19675. if(pJS.particles.move.random){
  19676. this.vx = this.vx * (Math.random());
  19677. this.vy = this.vy * (Math.random());
  19678. }
  19679. }else{
  19680. this.vx = velbase.x + Math.random()-0.5;
  19681. this.vy = velbase.y + Math.random()-0.5;
  19682. }
  19683. // var theta = 2.0 * Math.PI * Math.random();
  19684. // this.vx = Math.cos(theta);
  19685. // this.vy = Math.sin(theta);
  19686. this.vx_i = this.vx;
  19687. this.vy_i = this.vy;
  19688. /* if shape is image */
  19689. var shape_type = pJS.particles.shape.type;
  19690. if(typeof(shape_type) == 'object'){
  19691. if(shape_type instanceof Array){
  19692. var shape_selected = shape_type[Math.floor(Math.random() * shape_type.length)];
  19693. this.shape = shape_selected;
  19694. }
  19695. }else{
  19696. this.shape = shape_type;
  19697. }
  19698. if(this.shape == 'image'){
  19699. var sh = pJS.particles.shape;
  19700. this.img = {
  19701. src: sh.image.src,
  19702. ratio: sh.image.width / sh.image.height
  19703. }
  19704. if(!this.img.ratio) this.img.ratio = 1;
  19705. if(pJS.tmp.img_type == 'svg' && pJS.tmp.source_svg != undefined){
  19706. pJS.fn.vendors.createSvgImg(this);
  19707. if(pJS.tmp.pushing){
  19708. this.img.loaded = false;
  19709. }
  19710. }
  19711. }
  19712. };
  19713. pJS.fn.particle.prototype.draw = function() {
  19714. var p = this;
  19715. if(p.radius_bubble != undefined){
  19716. var radius = p.radius_bubble;
  19717. }else{
  19718. var radius = p.radius;
  19719. }
  19720. if(p.opacity_bubble != undefined){
  19721. var opacity = p.opacity_bubble;
  19722. }else{
  19723. var opacity = p.opacity;
  19724. }
  19725. if(p.color.rgb){
  19726. var color_value = 'rgba('+p.color.rgb.r+','+p.color.rgb.g+','+p.color.rgb.b+','+opacity+')';
  19727. }else{
  19728. var color_value = 'hsla('+p.color.hsl.h+','+p.color.hsl.s+'%,'+p.color.hsl.l+'%,'+opacity+')';
  19729. }
  19730. pJS.canvas.ctx.fillStyle = color_value;
  19731. pJS.canvas.ctx.beginPath();
  19732. switch(p.shape){
  19733. case 'circle':
  19734. pJS.canvas.ctx.arc(p.x, p.y, radius, 0, Math.PI * 2, false);
  19735. break;
  19736. case 'edge':
  19737. pJS.canvas.ctx.rect(p.x-radius, p.y-radius, radius*2, radius*2);
  19738. break;
  19739. case 'triangle':
  19740. pJS.fn.vendors.drawShape(pJS.canvas.ctx, p.x-radius, p.y+radius / 1.66, radius*2, 3, 2);
  19741. break;
  19742. case 'polygon':
  19743. pJS.fn.vendors.drawShape(
  19744. pJS.canvas.ctx,
  19745. p.x - radius / (pJS.particles.shape.polygon.nb_sides/3.5), // startX
  19746. p.y - radius / (2.66/3.5), // startY
  19747. radius*2.66 / (pJS.particles.shape.polygon.nb_sides/3), // sideLength
  19748. pJS.particles.shape.polygon.nb_sides, // sideCountNumerator
  19749. 1 // sideCountDenominator
  19750. );
  19751. break;
  19752. case 'star':
  19753. pJS.fn.vendors.drawShape(
  19754. pJS.canvas.ctx,
  19755. p.x - radius*2 / (pJS.particles.shape.polygon.nb_sides/4), // startX
  19756. p.y - radius / (2*2.66/3.5), // startY
  19757. radius*2*2.66 / (pJS.particles.shape.polygon.nb_sides/3), // sideLength
  19758. pJS.particles.shape.polygon.nb_sides, // sideCountNumerator
  19759. 2 // sideCountDenominator
  19760. );
  19761. break;
  19762. case 'image':
  19763. function draw(){
  19764. pJS.canvas.ctx.drawImage(
  19765. img_obj,
  19766. p.x-radius,
  19767. p.y-radius,
  19768. radius*2,
  19769. radius*2 / p.img.ratio
  19770. );
  19771. }
  19772. if(pJS.tmp.img_type == 'svg'){
  19773. var img_obj = p.img.obj;
  19774. }else{
  19775. var img_obj = pJS.tmp.img_obj;
  19776. }
  19777. if(img_obj){
  19778. draw();
  19779. }
  19780. break;
  19781. }
  19782. pJS.canvas.ctx.closePath();
  19783. if(pJS.particles.shape.stroke.width > 0){
  19784. pJS.canvas.ctx.strokeStyle = pJS.particles.shape.stroke.color;
  19785. pJS.canvas.ctx.lineWidth = pJS.particles.shape.stroke.width;
  19786. pJS.canvas.ctx.stroke();
  19787. }
  19788. pJS.canvas.ctx.fill();
  19789. };
  19790. pJS.fn.particlesCreate = function(){
  19791. for(var i = 0; i < pJS.particles.number.value; i++) {
  19792. pJS.particles.array.push(new pJS.fn.particle(pJS.particles.color, pJS.particles.opacity.value));
  19793. }
  19794. };
  19795. pJS.fn.particlesUpdate = function(){
  19796. for(var i = 0; i < pJS.particles.array.length; i++){
  19797. /* the particle */
  19798. var p = pJS.particles.array[i];
  19799. // var d = ( dx = pJS.interactivity.mouse.click_pos_x - p.x ) * dx + ( dy = pJS.interactivity.mouse.click_pos_y - p.y ) * dy;
  19800. // var f = -BANG_SIZE / d;
  19801. // if ( d < BANG_SIZE ) {
  19802. // var t = Math.atan2( dy, dx );
  19803. // p.vx = f * Math.cos(t);
  19804. // p.vy = f * Math.sin(t);
  19805. // }
  19806. /* move the particle */
  19807. if(pJS.particles.move.enable){
  19808. var ms = pJS.particles.move.speed/2;
  19809. p.x += p.vx * ms;
  19810. p.y += p.vy * ms;
  19811. }
  19812. /* change opacity status */
  19813. if(pJS.particles.opacity.anim.enable) {
  19814. if(p.opacity_status == true) {
  19815. if(p.opacity >= pJS.particles.opacity.value) p.opacity_status = false;
  19816. p.opacity += p.vo;
  19817. }else {
  19818. if(p.opacity <= pJS.particles.opacity.anim.opacity_min) p.opacity_status = true;
  19819. p.opacity -= p.vo;
  19820. }
  19821. if(p.opacity < 0) p.opacity = 0;
  19822. }
  19823. /* change size */
  19824. if(pJS.particles.size.anim.enable){
  19825. if(p.size_status == true){
  19826. if(p.radius >= pJS.particles.size.value) p.size_status = false;
  19827. p.radius += p.vs;
  19828. }else{
  19829. if(p.radius <= pJS.particles.size.anim.size_min) p.size_status = true;
  19830. p.radius -= p.vs;
  19831. }
  19832. if(p.radius < 0) p.radius = 0;
  19833. }
  19834. /* change particle position if it is out of canvas */
  19835. if(pJS.particles.move.out_mode == 'bounce'){
  19836. var new_pos = {
  19837. x_left: p.radius,
  19838. x_right: pJS.canvas.w,
  19839. y_top: p.radius,
  19840. y_bottom: pJS.canvas.h
  19841. }
  19842. }else{
  19843. var new_pos = {
  19844. x_left: -p.radius,
  19845. x_right: pJS.canvas.w + p.radius,
  19846. y_top: -p.radius,
  19847. y_bottom: pJS.canvas.h + p.radius
  19848. }
  19849. }
  19850. if(p.x - p.radius > pJS.canvas.w){
  19851. p.x = new_pos.x_left;
  19852. p.y = Math.random() * pJS.canvas.h;
  19853. }
  19854. else if(p.x + p.radius < 0){
  19855. p.x = new_pos.x_right;
  19856. p.y = Math.random() * pJS.canvas.h;
  19857. }
  19858. if(p.y - p.radius > pJS.canvas.h){
  19859. p.y = new_pos.y_top;
  19860. p.x = Math.random() * pJS.canvas.w;
  19861. }
  19862. else if(p.y + p.radius < 0){
  19863. p.y = new_pos.y_bottom;
  19864. p.x = Math.random() * pJS.canvas.w;
  19865. }
  19866. /* out of canvas modes */
  19867. switch(pJS.particles.move.out_mode){
  19868. case 'bounce':
  19869. if (p.x + p.radius > pJS.canvas.w) p.vx = -p.vx;
  19870. else if (p.x - p.radius < 0) p.vx = -p.vx;
  19871. if (p.y + p.radius > pJS.canvas.h) p.vy = -p.vy;
  19872. else if (p.y - p.radius < 0) p.vy = -p.vy;
  19873. break;
  19874. }
  19875. /* events */
  19876. if(isInArray('grab', pJS.interactivity.events.onhover.mode)){
  19877. pJS.fn.modes.grabParticle(p);
  19878. }
  19879. if(isInArray('bubble', pJS.interactivity.events.onhover.mode) || isInArray('bubble', pJS.interactivity.events.onclick.mode)){
  19880. pJS.fn.modes.bubbleParticle(p);
  19881. }
  19882. if(isInArray('repulse', pJS.interactivity.events.onhover.mode) || isInArray('repulse', pJS.interactivity.events.onclick.mode)){
  19883. pJS.fn.modes.repulseParticle(p);
  19884. }
  19885. /* interaction auto between particles */
  19886. if(pJS.particles.line_linked.enable || pJS.particles.move.attract.enable){
  19887. for(var j = i + 1; j < pJS.particles.array.length; j++){
  19888. var p2 = pJS.particles.array[j];
  19889. /* link particles */
  19890. if(pJS.particles.line_linked.enable){
  19891. pJS.fn.interact.linkParticles(p,p2);
  19892. }
  19893. /* attract particles */
  19894. if(pJS.particles.move.attract.enable){
  19895. pJS.fn.interact.attractParticles(p,p2);
  19896. }
  19897. /* bounce particles */
  19898. if(pJS.particles.move.bounce){
  19899. pJS.fn.interact.bounceParticles(p,p2);
  19900. }
  19901. }
  19902. }
  19903. }
  19904. };
  19905. pJS.fn.particlesDraw = function(){
  19906. /* clear canvas */
  19907. pJS.canvas.ctx.clearRect(0, 0, pJS.canvas.w, pJS.canvas.h);
  19908. /* update each particles param */
  19909. pJS.fn.particlesUpdate();
  19910. /* draw each particle */
  19911. for(var i = 0; i < pJS.particles.array.length; i++){
  19912. var p = pJS.particles.array[i];
  19913. p.draw();
  19914. }
  19915. };
  19916. pJS.fn.particlesEmpty = function(){
  19917. pJS.particles.array = [];
  19918. };
  19919. pJS.fn.particlesRefresh = function(){
  19920. /* init all */
  19921. cancelRequestAnimFrame(pJS.fn.checkAnimFrame);
  19922. cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  19923. pJS.tmp.source_svg = undefined;
  19924. pJS.tmp.img_obj = undefined;
  19925. pJS.tmp.count_svg = 0;
  19926. pJS.fn.particlesEmpty();
  19927. pJS.fn.canvasClear();
  19928. /* restart */
  19929. pJS.fn.vendors.start();
  19930. };
  19931. /* ---------- pJS functions - particles interaction ------------ */
  19932. pJS.fn.interact.linkParticles = function(p1, p2){
  19933. var dx = p1.x - p2.x,
  19934. dy = p1.y - p2.y,
  19935. dist = Math.sqrt(dx*dx + dy*dy);
  19936. /* draw a line between p1 and p2 if the distance between them is under the config distance */
  19937. if(dist <= pJS.particles.line_linked.distance){
  19938. var opacity_line = pJS.particles.line_linked.opacity - (dist / (1/pJS.particles.line_linked.opacity)) / pJS.particles.line_linked.distance;
  19939. if(opacity_line > 0){
  19940. /* style */
  19941. var color_line = pJS.particles.line_linked.color_rgb_line;
  19942. pJS.canvas.ctx.strokeStyle = 'rgba('+color_line.r+','+color_line.g+','+color_line.b+','+opacity_line+')';
  19943. pJS.canvas.ctx.lineWidth = pJS.particles.line_linked.width;
  19944. //pJS.canvas.ctx.lineCap = 'round'; /* performance issue */
  19945. /* path */
  19946. pJS.canvas.ctx.beginPath();
  19947. pJS.canvas.ctx.moveTo(p1.x, p1.y);
  19948. pJS.canvas.ctx.lineTo(p2.x, p2.y);
  19949. pJS.canvas.ctx.stroke();
  19950. pJS.canvas.ctx.closePath();
  19951. }
  19952. }
  19953. };
  19954. pJS.fn.interact.attractParticles = function(p1, p2){
  19955. /* condensed particles */
  19956. var dx = p1.x - p2.x,
  19957. dy = p1.y - p2.y,
  19958. dist = Math.sqrt(dx*dx + dy*dy);
  19959. if(dist <= pJS.particles.line_linked.distance){
  19960. var ax = dx/(pJS.particles.move.attract.rotateX*1000),
  19961. ay = dy/(pJS.particles.move.attract.rotateY*1000);
  19962. p1.vx -= ax;
  19963. p1.vy -= ay;
  19964. p2.vx += ax;
  19965. p2.vy += ay;
  19966. }
  19967. }
  19968. pJS.fn.interact.bounceParticles = function(p1, p2){
  19969. var dx = p1.x - p2.x,
  19970. dy = p1.y - p2.y,
  19971. dist = Math.sqrt(dx*dx + dy*dy),
  19972. dist_p = p1.radius+p2.radius;
  19973. if(dist <= dist_p){
  19974. p1.vx = -p1.vx;
  19975. p1.vy = -p1.vy;
  19976. p2.vx = -p2.vx;
  19977. p2.vy = -p2.vy;
  19978. }
  19979. }
  19980. /* ---------- pJS functions - modes events ------------ */
  19981. pJS.fn.modes.pushParticles = function(nb, pos){
  19982. pJS.tmp.pushing = true;
  19983. for(var i = 0; i < nb; i++){
  19984. pJS.particles.array.push(
  19985. new pJS.fn.particle(
  19986. pJS.particles.color,
  19987. pJS.particles.opacity.value,
  19988. {
  19989. 'x': pos ? pos.pos_x : Math.random() * pJS.canvas.w,
  19990. 'y': pos ? pos.pos_y : Math.random() * pJS.canvas.h
  19991. }
  19992. )
  19993. )
  19994. if(i == nb-1){
  19995. if(!pJS.particles.move.enable){
  19996. pJS.fn.particlesDraw();
  19997. }
  19998. pJS.tmp.pushing = false;
  19999. }
  20000. }
  20001. };
  20002. pJS.fn.modes.removeParticles = function(nb){
  20003. pJS.particles.array.splice(0, nb);
  20004. if(!pJS.particles.move.enable){
  20005. pJS.fn.particlesDraw();
  20006. }
  20007. };
  20008. pJS.fn.modes.bubbleParticle = function(p){
  20009. /* on hover event */
  20010. if(pJS.interactivity.events.onhover.enable && isInArray('bubble', pJS.interactivity.events.onhover.mode)){
  20011. var dx_mouse = p.x - pJS.interactivity.mouse.pos_x,
  20012. dy_mouse = p.y - pJS.interactivity.mouse.pos_y,
  20013. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse),
  20014. ratio = 1 - dist_mouse / pJS.interactivity.modes.bubble.distance;
  20015. function init(){
  20016. p.opacity_bubble = p.opacity;
  20017. p.radius_bubble = p.radius;
  20018. }
  20019. /* mousemove - check ratio */
  20020. if(dist_mouse <= pJS.interactivity.modes.bubble.distance){
  20021. if(ratio >= 0 && pJS.interactivity.status == 'mousemove'){
  20022. /* size */
  20023. if(pJS.interactivity.modes.bubble.size != pJS.particles.size.value){
  20024. if(pJS.interactivity.modes.bubble.size > pJS.particles.size.value){
  20025. var size = p.radius + (pJS.interactivity.modes.bubble.size*ratio);
  20026. if(size >= 0){
  20027. p.radius_bubble = size;
  20028. }
  20029. }else{
  20030. var dif = p.radius - pJS.interactivity.modes.bubble.size,
  20031. size = p.radius - (dif*ratio);
  20032. if(size > 0){
  20033. p.radius_bubble = size;
  20034. }else{
  20035. p.radius_bubble = 0;
  20036. }
  20037. }
  20038. }
  20039. /* opacity */
  20040. if(pJS.interactivity.modes.bubble.opacity != pJS.particles.opacity.value){
  20041. if(pJS.interactivity.modes.bubble.opacity > pJS.particles.opacity.value){
  20042. var opacity = pJS.interactivity.modes.bubble.opacity*ratio;
  20043. if(opacity > p.opacity && opacity <= pJS.interactivity.modes.bubble.opacity){
  20044. p.opacity_bubble = opacity;
  20045. }
  20046. }else{
  20047. var opacity = p.opacity - (pJS.particles.opacity.value-pJS.interactivity.modes.bubble.opacity)*ratio;
  20048. if(opacity < p.opacity && opacity >= pJS.interactivity.modes.bubble.opacity){
  20049. p.opacity_bubble = opacity;
  20050. }
  20051. }
  20052. }
  20053. }
  20054. }else{
  20055. init();
  20056. }
  20057. /* mouseleave */
  20058. if(pJS.interactivity.status == 'mouseleave'){
  20059. init();
  20060. }
  20061. }
  20062. /* on click event */
  20063. else if(pJS.interactivity.events.onclick.enable && isInArray('bubble', pJS.interactivity.events.onclick.mode)){
  20064. if(pJS.tmp.bubble_clicking){
  20065. var dx_mouse = p.x - pJS.interactivity.mouse.click_pos_x,
  20066. dy_mouse = p.y - pJS.interactivity.mouse.click_pos_y,
  20067. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse),
  20068. time_spent = (new Date().getTime() - pJS.interactivity.mouse.click_time)/1000;
  20069. if(time_spent > pJS.interactivity.modes.bubble.duration){
  20070. pJS.tmp.bubble_duration_end = true;
  20071. }
  20072. if(time_spent > pJS.interactivity.modes.bubble.duration*2){
  20073. pJS.tmp.bubble_clicking = false;
  20074. pJS.tmp.bubble_duration_end = false;
  20075. }
  20076. }
  20077. function process(bubble_param, particles_param, p_obj_bubble, p_obj, id){
  20078. if(bubble_param != particles_param){
  20079. if(!pJS.tmp.bubble_duration_end){
  20080. if(dist_mouse <= pJS.interactivity.modes.bubble.distance){
  20081. if(p_obj_bubble != undefined) var obj = p_obj_bubble;
  20082. else var obj = p_obj;
  20083. if(obj != bubble_param){
  20084. var value = p_obj - (time_spent * (p_obj - bubble_param) / pJS.interactivity.modes.bubble.duration);
  20085. if(id == 'size') p.radius_bubble = value;
  20086. if(id == 'opacity') p.opacity_bubble = value;
  20087. }
  20088. }else{
  20089. if(id == 'size') p.radius_bubble = undefined;
  20090. if(id == 'opacity') p.opacity_bubble = undefined;
  20091. }
  20092. }else{
  20093. if(p_obj_bubble != undefined){
  20094. var value_tmp = p_obj - (time_spent * (p_obj - bubble_param) / pJS.interactivity.modes.bubble.duration),
  20095. dif = bubble_param - value_tmp;
  20096. value = bubble_param + dif;
  20097. if(id == 'size') p.radius_bubble = value;
  20098. if(id == 'opacity') p.opacity_bubble = value;
  20099. }
  20100. }
  20101. }
  20102. }
  20103. if(pJS.tmp.bubble_clicking){
  20104. /* size */
  20105. process(pJS.interactivity.modes.bubble.size, pJS.particles.size.value, p.radius_bubble, p.radius, 'size');
  20106. /* opacity */
  20107. process(pJS.interactivity.modes.bubble.opacity, pJS.particles.opacity.value, p.opacity_bubble, p.opacity, 'opacity');
  20108. }
  20109. }
  20110. };
  20111. pJS.fn.modes.repulseParticle = function(p){
  20112. if(pJS.interactivity.events.onhover.enable && isInArray('repulse', pJS.interactivity.events.onhover.mode) && pJS.interactivity.status == 'mousemove') {
  20113. var dx_mouse = p.x - pJS.interactivity.mouse.pos_x,
  20114. dy_mouse = p.y - pJS.interactivity.mouse.pos_y,
  20115. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse);
  20116. var normVec = {x: dx_mouse/dist_mouse, y: dy_mouse/dist_mouse},
  20117. repulseRadius = pJS.interactivity.modes.repulse.distance,
  20118. velocity = 100,
  20119. repulseFactor = clamp((1/repulseRadius)*(-1*Math.pow(dist_mouse/repulseRadius,2)+1)*repulseRadius*velocity, 0, 50);
  20120. var pos = {
  20121. x: p.x + normVec.x * repulseFactor,
  20122. y: p.y + normVec.y * repulseFactor
  20123. }
  20124. if(pJS.particles.move.out_mode == 'bounce'){
  20125. if(pos.x - p.radius > 0 && pos.x + p.radius < pJS.canvas.w) p.x = pos.x;
  20126. if(pos.y - p.radius > 0 && pos.y + p.radius < pJS.canvas.h) p.y = pos.y;
  20127. }else{
  20128. p.x = pos.x;
  20129. p.y = pos.y;
  20130. }
  20131. }
  20132. else if(pJS.interactivity.events.onclick.enable && isInArray('repulse', pJS.interactivity.events.onclick.mode)) {
  20133. if(!pJS.tmp.repulse_finish){
  20134. pJS.tmp.repulse_count++;
  20135. if(pJS.tmp.repulse_count == pJS.particles.array.length){
  20136. pJS.tmp.repulse_finish = true;
  20137. }
  20138. }
  20139. if(pJS.tmp.repulse_clicking){
  20140. var repulseRadius = Math.pow(pJS.interactivity.modes.repulse.distance/6, 3);
  20141. var dx = pJS.interactivity.mouse.click_pos_x - p.x,
  20142. dy = pJS.interactivity.mouse.click_pos_y - p.y,
  20143. d = dx*dx + dy*dy;
  20144. var force = -repulseRadius / d * 1;
  20145. function process(){
  20146. var f = Math.atan2(dy,dx);
  20147. p.vx = force * Math.cos(f);
  20148. p.vy = force * Math.sin(f);
  20149. if(pJS.particles.move.out_mode == 'bounce'){
  20150. var pos = {
  20151. x: p.x + p.vx,
  20152. y: p.y + p.vy
  20153. }
  20154. if (pos.x + p.radius > pJS.canvas.w) p.vx = -p.vx;
  20155. else if (pos.x - p.radius < 0) p.vx = -p.vx;
  20156. if (pos.y + p.radius > pJS.canvas.h) p.vy = -p.vy;
  20157. else if (pos.y - p.radius < 0) p.vy = -p.vy;
  20158. }
  20159. }
  20160. // default
  20161. if(d <= repulseRadius){
  20162. process();
  20163. }
  20164. // bang - slow motion mode
  20165. // if(!pJS.tmp.repulse_finish){
  20166. // if(d <= repulseRadius){
  20167. // process();
  20168. // }
  20169. // }else{
  20170. // process();
  20171. // }
  20172. }else{
  20173. if(pJS.tmp.repulse_clicking == false){
  20174. p.vx = p.vx_i;
  20175. p.vy = p.vy_i;
  20176. }
  20177. }
  20178. }
  20179. }
  20180. pJS.fn.modes.grabParticle = function(p){
  20181. if(pJS.interactivity.events.onhover.enable && pJS.interactivity.status == 'mousemove'){
  20182. var dx_mouse = p.x - pJS.interactivity.mouse.pos_x,
  20183. dy_mouse = p.y - pJS.interactivity.mouse.pos_y,
  20184. dist_mouse = Math.sqrt(dx_mouse*dx_mouse + dy_mouse*dy_mouse);
  20185. /* draw a line between the cursor and the particle if the distance between them is under the config distance */
  20186. if(dist_mouse <= pJS.interactivity.modes.grab.distance){
  20187. var opacity_line = pJS.interactivity.modes.grab.line_linked.opacity - (dist_mouse / (1/pJS.interactivity.modes.grab.line_linked.opacity)) / pJS.interactivity.modes.grab.distance;
  20188. if(opacity_line > 0){
  20189. /* style */
  20190. var color_line = pJS.particles.line_linked.color_rgb_line;
  20191. pJS.canvas.ctx.strokeStyle = 'rgba('+color_line.r+','+color_line.g+','+color_line.b+','+opacity_line+')';
  20192. pJS.canvas.ctx.lineWidth = pJS.particles.line_linked.width;
  20193. //pJS.canvas.ctx.lineCap = 'round'; /* performance issue */
  20194. /* path */
  20195. pJS.canvas.ctx.beginPath();
  20196. pJS.canvas.ctx.moveTo(p.x, p.y);
  20197. pJS.canvas.ctx.lineTo(pJS.interactivity.mouse.pos_x, pJS.interactivity.mouse.pos_y);
  20198. pJS.canvas.ctx.stroke();
  20199. pJS.canvas.ctx.closePath();
  20200. }
  20201. }
  20202. }
  20203. };
  20204. /* ---------- pJS functions - vendors ------------ */
  20205. pJS.fn.vendors.eventsListeners = function(){
  20206. /* events target element */
  20207. if(pJS.interactivity.detect_on == 'window'){
  20208. pJS.interactivity.el = window;
  20209. }else{
  20210. pJS.interactivity.el = pJS.canvas.el;
  20211. }
  20212. /* detect mouse pos - on hover / click event */
  20213. if(pJS.interactivity.events.onhover.enable || pJS.interactivity.events.onclick.enable){
  20214. /* el on mousemove */
  20215. pJS.interactivity.el.addEventListener('mousemove', function(e){
  20216. if(pJS.interactivity.el == window){
  20217. var pos_x = e.clientX,
  20218. pos_y = e.clientY;
  20219. }
  20220. else{
  20221. var pos_x = e.offsetX || e.clientX,
  20222. pos_y = e.offsetY || e.clientY;
  20223. }
  20224. pJS.interactivity.mouse.pos_x = pos_x;
  20225. pJS.interactivity.mouse.pos_y = pos_y;
  20226. if(pJS.tmp.retina){
  20227. pJS.interactivity.mouse.pos_x *= pJS.canvas.pxratio;
  20228. pJS.interactivity.mouse.pos_y *= pJS.canvas.pxratio;
  20229. }
  20230. pJS.interactivity.status = 'mousemove';
  20231. });
  20232. /* el on onmouseleave */
  20233. pJS.interactivity.el.addEventListener('mouseleave', function(e){
  20234. pJS.interactivity.mouse.pos_x = null;
  20235. pJS.interactivity.mouse.pos_y = null;
  20236. pJS.interactivity.status = 'mouseleave';
  20237. });
  20238. }
  20239. /* on click event */
  20240. if(pJS.interactivity.events.onclick.enable){
  20241. pJS.interactivity.el.addEventListener('click', function(){
  20242. pJS.interactivity.mouse.click_pos_x = pJS.interactivity.mouse.pos_x;
  20243. pJS.interactivity.mouse.click_pos_y = pJS.interactivity.mouse.pos_y;
  20244. pJS.interactivity.mouse.click_time = new Date().getTime();
  20245. if(pJS.interactivity.events.onclick.enable){
  20246. switch(pJS.interactivity.events.onclick.mode){
  20247. case 'push':
  20248. if(pJS.particles.move.enable){
  20249. pJS.fn.modes.pushParticles(pJS.interactivity.modes.push.particles_nb, pJS.interactivity.mouse);
  20250. }else{
  20251. if(pJS.interactivity.modes.push.particles_nb == 1){
  20252. pJS.fn.modes.pushParticles(pJS.interactivity.modes.push.particles_nb, pJS.interactivity.mouse);
  20253. }
  20254. else if(pJS.interactivity.modes.push.particles_nb > 1){
  20255. pJS.fn.modes.pushParticles(pJS.interactivity.modes.push.particles_nb);
  20256. }
  20257. }
  20258. break;
  20259. case 'remove':
  20260. pJS.fn.modes.removeParticles(pJS.interactivity.modes.remove.particles_nb);
  20261. break;
  20262. case 'bubble':
  20263. pJS.tmp.bubble_clicking = true;
  20264. break;
  20265. case 'repulse':
  20266. pJS.tmp.repulse_clicking = true;
  20267. pJS.tmp.repulse_count = 0;
  20268. pJS.tmp.repulse_finish = false;
  20269. setTimeout(function(){
  20270. pJS.tmp.repulse_clicking = false;
  20271. }, pJS.interactivity.modes.repulse.duration*1000)
  20272. break;
  20273. }
  20274. }
  20275. });
  20276. }
  20277. };
  20278. pJS.fn.vendors.densityAutoParticles = function(){
  20279. if(pJS.particles.number.density.enable){
  20280. /* calc area */
  20281. var area = pJS.canvas.el.width * pJS.canvas.el.height / 1000;
  20282. if(pJS.tmp.retina){
  20283. area = area/(pJS.canvas.pxratio*2);
  20284. }
  20285. /* calc number of particles based on density area */
  20286. var nb_particles = area * pJS.particles.number.value / pJS.particles.number.density.value_area;
  20287. /* add or remove X particles */
  20288. var missing_particles = pJS.particles.array.length - nb_particles;
  20289. if(missing_particles < 0) pJS.fn.modes.pushParticles(Math.abs(missing_particles));
  20290. else pJS.fn.modes.removeParticles(missing_particles);
  20291. }
  20292. };
  20293. pJS.fn.vendors.checkOverlap = function(p1, position){
  20294. for(var i = 0; i < pJS.particles.array.length; i++){
  20295. var p2 = pJS.particles.array[i];
  20296. var dx = p1.x - p2.x,
  20297. dy = p1.y - p2.y,
  20298. dist = Math.sqrt(dx*dx + dy*dy);
  20299. if(dist <= p1.radius + p2.radius){
  20300. p1.x = position ? position.x : Math.random() * pJS.canvas.w;
  20301. p1.y = position ? position.y : Math.random() * pJS.canvas.h;
  20302. pJS.fn.vendors.checkOverlap(p1);
  20303. }
  20304. }
  20305. };
  20306. pJS.fn.vendors.createSvgImg = function(p){
  20307. /* set color to svg element */
  20308. var svgXml = pJS.tmp.source_svg,
  20309. rgbHex = /#([0-9A-F]{3,6})/gi,
  20310. coloredSvgXml = svgXml.replace(rgbHex, function (m, r, g, b) {
  20311. if(p.color.rgb){
  20312. var color_value = 'rgba('+p.color.rgb.r+','+p.color.rgb.g+','+p.color.rgb.b+','+p.opacity+')';
  20313. }else{
  20314. var color_value = 'hsla('+p.color.hsl.h+','+p.color.hsl.s+'%,'+p.color.hsl.l+'%,'+p.opacity+')';
  20315. }
  20316. return color_value;
  20317. });
  20318. /* prepare to create img with colored svg */
  20319. var svg = new Blob([coloredSvgXml], {type: 'image/svg+xml;charset=utf-8'}),
  20320. DOMURL = window.URL || window.webkitURL || window,
  20321. url = DOMURL.createObjectURL(svg);
  20322. /* create particle img obj */
  20323. var img = new Image();
  20324. img.addEventListener('load', function(){
  20325. p.img.obj = img;
  20326. p.img.loaded = true;
  20327. DOMURL.revokeObjectURL(url);
  20328. pJS.tmp.count_svg++;
  20329. });
  20330. img.src = url;
  20331. };
  20332. pJS.fn.vendors.destroypJS = function(){
  20333. cancelAnimationFrame(pJS.fn.drawAnimFrame);
  20334. canvas_el.remove();
  20335. pJSDom = null;
  20336. };
  20337. pJS.fn.vendors.drawShape = function(c, startX, startY, sideLength, sideCountNumerator, sideCountDenominator){
  20338. // By Programming Thomas - https://programmingthomas.wordpress.com/2013/04/03/n-sided-shapes/
  20339. var sideCount = sideCountNumerator * sideCountDenominator;
  20340. var decimalSides = sideCountNumerator / sideCountDenominator;
  20341. var interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides;
  20342. var interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180; // convert to radians
  20343. c.save();
  20344. c.beginPath();
  20345. c.translate(startX, startY);
  20346. c.moveTo(0,0);
  20347. for (var i = 0; i < sideCount; i++) {
  20348. c.lineTo(sideLength,0);
  20349. c.translate(sideLength,0);
  20350. c.rotate(interiorAngle);
  20351. }
  20352. //c.stroke();
  20353. c.fill();
  20354. c.restore();
  20355. };
  20356. pJS.fn.vendors.exportImg = function(){
  20357. window.open(pJS.canvas.el.toDataURL('image/png'), '_blank');
  20358. };
  20359. pJS.fn.vendors.loadImg = function(type){
  20360. pJS.tmp.img_error = undefined;
  20361. if(pJS.particles.shape.image.src != ''){
  20362. if(type == 'svg'){
  20363. var xhr = new XMLHttpRequest();
  20364. xhr.open('GET', pJS.particles.shape.image.src);
  20365. xhr.onreadystatechange = function (data) {
  20366. if(xhr.readyState == 4){
  20367. if(xhr.status == 200){
  20368. pJS.tmp.source_svg = data.currentTarget.response;
  20369. pJS.fn.vendors.checkBeforeDraw();
  20370. }else{
  20371. console.log('Error pJS - Image not found');
  20372. pJS.tmp.img_error = true;
  20373. }
  20374. }
  20375. }
  20376. xhr.send();
  20377. }else{
  20378. var img = new Image();
  20379. img.addEventListener('load', function(){
  20380. pJS.tmp.img_obj = img;
  20381. pJS.fn.vendors.checkBeforeDraw();
  20382. });
  20383. img.src = pJS.particles.shape.image.src;
  20384. }
  20385. }else{
  20386. console.log('Error pJS - No image.src');
  20387. pJS.tmp.img_error = true;
  20388. }
  20389. };
  20390. pJS.fn.vendors.draw = function(){
  20391. if(pJS.particles.shape.type == 'image'){
  20392. if(pJS.tmp.img_type == 'svg'){
  20393. if(pJS.tmp.count_svg >= pJS.particles.number.value){
  20394. pJS.fn.particlesDraw();
  20395. if(!pJS.particles.move.enable) cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20396. else pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20397. }else{
  20398. //console.log('still loading...');
  20399. if(!pJS.tmp.img_error) pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20400. }
  20401. }else{
  20402. if(pJS.tmp.img_obj != undefined){
  20403. pJS.fn.particlesDraw();
  20404. if(!pJS.particles.move.enable) cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20405. else pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20406. }else{
  20407. if(!pJS.tmp.img_error) pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20408. }
  20409. }
  20410. }else{
  20411. pJS.fn.particlesDraw();
  20412. if(!pJS.particles.move.enable) cancelRequestAnimFrame(pJS.fn.drawAnimFrame);
  20413. else pJS.fn.drawAnimFrame = requestAnimFrame(pJS.fn.vendors.draw);
  20414. }
  20415. };
  20416. pJS.fn.vendors.checkBeforeDraw = function(){
  20417. // if shape is image
  20418. if(pJS.particles.shape.type == 'image'){
  20419. if(pJS.tmp.img_type == 'svg' && pJS.tmp.source_svg == undefined){
  20420. pJS.tmp.checkAnimFrame = requestAnimFrame(check);
  20421. }else{
  20422. //console.log('images loaded! cancel check');
  20423. cancelRequestAnimFrame(pJS.tmp.checkAnimFrame);
  20424. if(!pJS.tmp.img_error){
  20425. pJS.fn.vendors.init();
  20426. pJS.fn.vendors.draw();
  20427. }
  20428. }
  20429. }else{
  20430. pJS.fn.vendors.init();
  20431. pJS.fn.vendors.draw();
  20432. }
  20433. };
  20434. pJS.fn.vendors.init = function(){
  20435. /* init canvas + particles */
  20436. pJS.fn.retinaInit();
  20437. pJS.fn.canvasInit();
  20438. pJS.fn.canvasSize();
  20439. pJS.fn.canvasPaint();
  20440. pJS.fn.particlesCreate();
  20441. pJS.fn.vendors.densityAutoParticles();
  20442. /* particles.line_linked - convert hex colors to rgb */
  20443. pJS.particles.line_linked.color_rgb_line = hexToRgb(pJS.particles.line_linked.color);
  20444. };
  20445. pJS.fn.vendors.start = function(){
  20446. if(isInArray('image', pJS.particles.shape.type)){
  20447. pJS.tmp.img_type = pJS.particles.shape.image.src.substr(pJS.particles.shape.image.src.length - 3);
  20448. pJS.fn.vendors.loadImg(pJS.tmp.img_type);
  20449. }else{
  20450. pJS.fn.vendors.checkBeforeDraw();
  20451. }
  20452. };
  20453. /* ---------- pJS - start ------------ */
  20454. pJS.fn.vendors.eventsListeners();
  20455. pJS.fn.vendors.start();
  20456. };
  20457. /* ---------- global functions - vendors ------------ */
  20458. Object.deepExtend = function(destination, source) {
  20459. for (var property in source) {
  20460. if (source[property] && source[property].constructor &&
  20461. source[property].constructor === Object) {
  20462. destination[property] = destination[property] || {};
  20463. arguments.callee(destination[property], source[property]);
  20464. } else {
  20465. destination[property] = source[property];
  20466. }
  20467. }
  20468. return destination;
  20469. };
  20470. window.requestAnimFrame = (function(){
  20471. return window.requestAnimationFrame ||
  20472. window.webkitRequestAnimationFrame ||
  20473. window.mozRequestAnimationFrame ||
  20474. window.oRequestAnimationFrame ||
  20475. window.msRequestAnimationFrame ||
  20476. function(callback){
  20477. window.setTimeout(callback, 1000 / 60);
  20478. };
  20479. })();
  20480. window.cancelRequestAnimFrame = ( function() {
  20481. return window.cancelAnimationFrame ||
  20482. window.webkitCancelRequestAnimationFrame ||
  20483. window.mozCancelRequestAnimationFrame ||
  20484. window.oCancelRequestAnimationFrame ||
  20485. window.msCancelRequestAnimationFrame ||
  20486. clearTimeout
  20487. } )();
  20488. function hexToRgb(hex){
  20489. // By Tim Down - http://stackoverflow.com/a/5624139/3493650
  20490. // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
  20491. var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  20492. hex = hex.replace(shorthandRegex, function(m, r, g, b) {
  20493. return r + r + g + g + b + b;
  20494. });
  20495. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  20496. return result ? {
  20497. r: parseInt(result[1], 16),
  20498. g: parseInt(result[2], 16),
  20499. b: parseInt(result[3], 16)
  20500. } : null;
  20501. };
  20502. function clamp(number, min, max) {
  20503. return Math.min(Math.max(number, min), max);
  20504. };
  20505. function isInArray(value, array) {
  20506. return array.indexOf(value) > -1;
  20507. }
  20508. /* ---------- particles.js functions - start ------------ */
  20509. window.pJSDom = [];
  20510. window.particlesJS = function(tag_id, params){
  20511. //console.log(params);
  20512. /* no string id? so it's object params, and set the id with default id */
  20513. if(typeof(tag_id) != 'string'){
  20514. params = tag_id;
  20515. tag_id = 'particles-js';
  20516. }
  20517. /* no id? set the id to default id */
  20518. if(!tag_id){
  20519. tag_id = 'particles-js';
  20520. }
  20521. /* pJS elements */
  20522. var pJS_tag = document.getElementById(tag_id),
  20523. pJS_canvas_class = 'particles-js-canvas-el',
  20524. exist_canvas = pJS_tag.getElementsByClassName(pJS_canvas_class);
  20525. /* remove canvas if exists into the pJS target tag */
  20526. if(exist_canvas.length){
  20527. while(exist_canvas.length > 0){
  20528. pJS_tag.removeChild(exist_canvas[0]);
  20529. }
  20530. }
  20531. /* create canvas element */
  20532. var canvas_el = document.createElement('canvas');
  20533. canvas_el.className = pJS_canvas_class;
  20534. /* set size canvas */
  20535. canvas_el.style.width = "100%";
  20536. canvas_el.style.height = "100%";
  20537. /* append canvas */
  20538. var canvas = document.getElementById(tag_id).appendChild(canvas_el);
  20539. /* launch particle.js */
  20540. if(canvas != null){
  20541. pJSDom.push(new pJS(tag_id, params));
  20542. }
  20543. };
  20544. window.particlesJS.load = function(tag_id, path_config_json, callback){
  20545. /* load json config */
  20546. var xhr = new XMLHttpRequest();
  20547. xhr.open('GET', path_config_json);
  20548. xhr.onreadystatechange = function (data) {
  20549. if(xhr.readyState == 4){
  20550. if(xhr.status == 200){
  20551. var params = JSON.parse(data.currentTarget.response);
  20552. window.particlesJS(tag_id, params);
  20553. if(callback) callback();
  20554. }else{
  20555. console.log('Error pJS - XMLHttpRequest status: '+xhr.status);
  20556. console.log('Error pJS - File config not found');
  20557. }
  20558. }
  20559. };
  20560. xhr.send();
  20561. };
  20562. /*!
  20563. Retina
  20564. Version: 1.3.0
  20565. Plugin URL: http://imulus.github.io/retinajs/
  20566. License: Copyright 2014 Imulus, LLC | Released under the MIT license
  20567. !*/
  20568. !function(){function a(){}function b(a){return f.retinaImageSuffix+a}function c(a,c){if(this.path=a||"","undefined"!=typeof c&&null!==c)this.at_2x_path=c,this.perform_check=!1;else{if(void 0!==document.createElement){var d=document.createElement("a");d.href=this.path,d.pathname=d.pathname.replace(g,b),this.at_2x_path=d.href}else{var e=this.path.split("?");e[0]=e[0].replace(g,b),this.at_2x_path=e.join("?")}this.perform_check=!0}}function d(a){this.el=a,this.path=new c(this.el.getAttribute("src"),this.el.getAttribute("data-at2x"));var b=this;this.path.check_2x_variant(function(a){a&&b.swap()})}var e="undefined"==typeof exports?window:exports,f={retinaImageSuffix:"@2x",check_mime_type:!0,force_original_dimensions:!0};e.Retina=a,a.configure=function(a){null===a&&(a={});for(var b in a)a.hasOwnProperty(b)&&(f[b]=a[b])},a.init=function(a){null===a&&(a=e);var b=a.onload||function(){};a.onload=function(){var a,c,e=document.getElementsByTagName("img"),f=[];for(a=0;a<e.length;a+=1)c=e[a],c.getAttributeNode("data-no-retina")||f.push(new d(c));b()}},a.isRetina=function(){var a="(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)";return e.devicePixelRatio>1?!0:e.matchMedia&&e.matchMedia(a).matches?!0:!1};var g=/\.\w+$/;e.RetinaImagePath=c,c.confirmed_paths=[],c.prototype.is_external=function(){return!(!this.path.match(/^https?\:/i)||this.path.match("//"+document.domain))},c.prototype.check_2x_variant=function(a){var b,d=this;return this.is_external()?a(!1):this.perform_check||"undefined"==typeof this.at_2x_path||null===this.at_2x_path?this.at_2x_path in c.confirmed_paths?a(!0):(b=new XMLHttpRequest,b.open("HEAD",this.at_2x_path),b.onreadystatechange=function(){if(4!==b.readyState)return a(!1);if(b.status>=200&&b.status<=399){if(f.check_mime_type){var e=b.getResponseHeader("Content-Type");if(null===e||!e.match(/^image/i))return a(!1)}return c.confirmed_paths.push(d.at_2x_path),a(!0)}return a(!1)},b.send(),void 0):a(!0)},e.RetinaImage=d,d.prototype.swap=function(a){function b(){c.el.complete?(f.force_original_dimensions&&(c.el.setAttribute("width",c.el.offsetWidth),c.el.setAttribute("height",c.el.offsetHeight)),c.el.setAttribute("src",a)):setTimeout(b,5)}"undefined"==typeof a&&(a=this.path.at_2x_path);var c=this;b()},a.isRetina()&&a.init(e)}();
  20569. /*!
  20570. Skrollr
  20571. Plugin URL: https://github.com/Prinzhorn/skrollr
  20572. License: Copyright Alexander Prinzhorn | Free to use under terms of MIT license
  20573. !*/
  20574. (function(window, document, undefined) {
  20575. 'use strict';
  20576. /*
  20577. * Global api.
  20578. */
  20579. var skrollr = {
  20580. get: function() {
  20581. return _instance;
  20582. },
  20583. //Main entry point.
  20584. init: function(options) {
  20585. return _instance || new Skrollr(options);
  20586. },
  20587. VERSION: '0.6.30'
  20588. };
  20589. //Minify optimization.
  20590. var hasProp = Object.prototype.hasOwnProperty;
  20591. var Math = window.Math;
  20592. var getStyle = window.getComputedStyle;
  20593. //They will be filled when skrollr gets initialized.
  20594. var documentElement;
  20595. var body;
  20596. var EVENT_TOUCHSTART = 'touchstart';
  20597. var EVENT_TOUCHMOVE = 'touchmove';
  20598. var EVENT_TOUCHCANCEL = 'touchcancel';
  20599. var EVENT_TOUCHEND = 'touchend';
  20600. var SKROLLABLE_CLASS = 'skrollable';
  20601. var SKROLLABLE_BEFORE_CLASS = SKROLLABLE_CLASS + '-before';
  20602. var SKROLLABLE_BETWEEN_CLASS = SKROLLABLE_CLASS + '-between';
  20603. var SKROLLABLE_AFTER_CLASS = SKROLLABLE_CLASS + '-after';
  20604. var SKROLLR_CLASS = 'skrollr';
  20605. var NO_SKROLLR_CLASS = 'no-' + SKROLLR_CLASS;
  20606. var SKROLLR_DESKTOP_CLASS = SKROLLR_CLASS + '-desktop';
  20607. var SKROLLR_MOBILE_CLASS = SKROLLR_CLASS + '-mobile';
  20608. var DEFAULT_EASING = 'linear';
  20609. var DEFAULT_DURATION = 1000;//ms
  20610. var DEFAULT_MOBILE_DECELERATION = 0.004;//pixel/ms²
  20611. var DEFAULT_SKROLLRBODY = 'skrollr-body';
  20612. var DEFAULT_SMOOTH_SCROLLING_DURATION = 200;//ms
  20613. var ANCHOR_START = 'start';
  20614. var ANCHOR_END = 'end';
  20615. var ANCHOR_CENTER = 'center';
  20616. var ANCHOR_BOTTOM = 'bottom';
  20617. //The property which will be added to the DOM element to hold the ID of the skrollable.
  20618. var SKROLLABLE_ID_DOM_PROPERTY = '___skrollable_id';
  20619. var rxTouchIgnoreTags = /^(?:input|textarea|button|select)$/i;
  20620. var rxTrim = /^\s+|\s+$/g;
  20621. //Find all data-attributes. data-[_constant]-[offset]-[anchor]-[anchor].
  20622. var rxKeyframeAttribute = /^data(?:-(_\w+))?(?:-?(-?\d*\.?\d+p?))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/;
  20623. var rxPropValue = /\s*(@?[\w\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi;
  20624. //Easing function names follow the property in square brackets.
  20625. var rxPropEasing = /^(@?[a-z\-]+)\[(\w+)\]$/;
  20626. var rxCamelCase = /-([a-z0-9_])/g;
  20627. var rxCamelCaseFn = function(str, letter) {
  20628. return letter.toUpperCase();
  20629. };
  20630. //Numeric values with optional sign.
  20631. var rxNumericValue = /[\-+]?[\d]*\.?[\d]+/g;
  20632. //Used to replace occurences of {?} with a number.
  20633. var rxInterpolateString = /\{\?\}/g;
  20634. //Finds rgb(a) colors, which don't use the percentage notation.
  20635. var rxRGBAIntegerColor = /rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g;
  20636. //Finds all gradients.
  20637. var rxGradient = /[a-z\-]+-gradient/g;
  20638. //Vendor prefix. Will be set once skrollr gets initialized.
  20639. var theCSSPrefix = '';
  20640. var theDashedCSSPrefix = '';
  20641. //Will be called once (when skrollr gets initialized).
  20642. var detectCSSPrefix = function() {
  20643. //Only relevant prefixes. May be extended.
  20644. //Could be dangerous if there will ever be a CSS property which actually starts with "ms". Don't hope so.
  20645. var rxPrefixes = /^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;
  20646. //Detect prefix for current browser by finding the first property using a prefix.
  20647. if(!getStyle) {
  20648. return;
  20649. }
  20650. var style = getStyle(body, null);
  20651. for(var k in style) {
  20652. //We check the key and if the key is a number, we check the value as well, because safari's getComputedStyle returns some weird array-like thingy.
  20653. theCSSPrefix = (k.match(rxPrefixes) || (+k == k && style[k].match(rxPrefixes)));
  20654. if(theCSSPrefix) {
  20655. break;
  20656. }
  20657. }
  20658. //Did we even detect a prefix?
  20659. if(!theCSSPrefix) {
  20660. theCSSPrefix = theDashedCSSPrefix = '';
  20661. return;
  20662. }
  20663. theCSSPrefix = theCSSPrefix[0];
  20664. //We could have detected either a dashed prefix or this camelCaseish-inconsistent stuff.
  20665. if(theCSSPrefix.slice(0,1) === '-') {
  20666. theDashedCSSPrefix = theCSSPrefix;
  20667. //There's no logic behind these. Need a look up.
  20668. theCSSPrefix = ({
  20669. '-webkit-': 'webkit',
  20670. '-moz-': 'Moz',
  20671. '-ms-': 'ms',
  20672. '-o-': 'O'
  20673. })[theCSSPrefix];
  20674. } else {
  20675. theDashedCSSPrefix = '-' + theCSSPrefix.toLowerCase() + '-';
  20676. }
  20677. };
  20678. var polyfillRAF = function() {
  20679. var requestAnimFrame = window.requestAnimationFrame || window[theCSSPrefix.toLowerCase() + 'RequestAnimationFrame'];
  20680. var lastTime = _now();
  20681. if(_isMobile || !requestAnimFrame) {
  20682. requestAnimFrame = function(callback) {
  20683. //How long did it take to render?
  20684. var deltaTime = _now() - lastTime;
  20685. var delay = Math.max(0, 1000 / 60 - deltaTime);
  20686. return window.setTimeout(function() {
  20687. lastTime = _now();
  20688. callback();
  20689. }, delay);
  20690. };
  20691. }
  20692. return requestAnimFrame;
  20693. };
  20694. var polyfillCAF = function() {
  20695. var cancelAnimFrame = window.cancelAnimationFrame || window[theCSSPrefix.toLowerCase() + 'CancelAnimationFrame'];
  20696. if(_isMobile || !cancelAnimFrame) {
  20697. cancelAnimFrame = function(timeout) {
  20698. return window.clearTimeout(timeout);
  20699. };
  20700. }
  20701. return cancelAnimFrame;
  20702. };
  20703. //Built-in easing functions.
  20704. var easings = {
  20705. begin: function() {
  20706. return 0;
  20707. },
  20708. end: function() {
  20709. return 1;
  20710. },
  20711. linear: function(p) {
  20712. return p;
  20713. },
  20714. quadratic: function(p) {
  20715. return p * p;
  20716. },
  20717. cubic: function(p) {
  20718. return p * p * p;
  20719. },
  20720. swing: function(p) {
  20721. return (-Math.cos(p * Math.PI) / 2) + 0.5;
  20722. },
  20723. sqrt: function(p) {
  20724. return Math.sqrt(p);
  20725. },
  20726. outCubic: function(p) {
  20727. return (Math.pow((p - 1), 3) + 1);
  20728. },
  20729. //see https://www.desmos.com/calculator/tbr20s8vd2 for how I did this
  20730. bounce: function(p) {
  20731. var a;
  20732. if(p <= 0.5083) {
  20733. a = 3;
  20734. } else if(p <= 0.8489) {
  20735. a = 9;
  20736. } else if(p <= 0.96208) {
  20737. a = 27;
  20738. } else if(p <= 0.99981) {
  20739. a = 91;
  20740. } else {
  20741. return 1;
  20742. }
  20743. return 1 - Math.abs(3 * Math.cos(p * a * 1.028) / a);
  20744. }
  20745. };
  20746. /**
  20747. * Constructor.
  20748. */
  20749. function Skrollr(options) {
  20750. documentElement = document.documentElement;
  20751. body = document.body;
  20752. detectCSSPrefix();
  20753. _instance = this;
  20754. options = options || {};
  20755. _constants = options.constants || {};
  20756. //We allow defining custom easings or overwrite existing.
  20757. if(options.easing) {
  20758. for(var e in options.easing) {
  20759. easings[e] = options.easing[e];
  20760. }
  20761. }
  20762. _edgeStrategy = options.edgeStrategy || 'set';
  20763. _listeners = {
  20764. //Function to be called right before rendering.
  20765. beforerender: options.beforerender,
  20766. //Function to be called right after finishing rendering.
  20767. render: options.render,
  20768. //Function to be called whenever an element with the `data-emit-events` attribute passes a keyframe.
  20769. keyframe: options.keyframe
  20770. };
  20771. //forceHeight is true by default
  20772. _forceHeight = options.forceHeight !== false;
  20773. if(_forceHeight) {
  20774. _scale = options.scale || 1;
  20775. }
  20776. _mobileDeceleration = options.mobileDeceleration || DEFAULT_MOBILE_DECELERATION;
  20777. _smoothScrollingEnabled = options.smoothScrolling !== false;
  20778. _smoothScrollingDuration = options.smoothScrollingDuration || DEFAULT_SMOOTH_SCROLLING_DURATION;
  20779. //Dummy object. Will be overwritten in the _render method when smooth scrolling is calculated.
  20780. _smoothScrolling = {
  20781. targetTop: _instance.getScrollTop()
  20782. };
  20783. //A custom check function may be passed.
  20784. _isMobile = ((options.mobileCheck || function() {
  20785. return (/Android|iPhone|iPad|iPod|BlackBerry/i).test(navigator.userAgent || navigator.vendor || window.opera);
  20786. })());
  20787. if(_isMobile) {
  20788. _skrollrBody = document.getElementById(options.skrollrBody || DEFAULT_SKROLLRBODY);
  20789. //Detect 3d transform if there's a skrollr-body (only needed for #skrollr-body).
  20790. if(_skrollrBody) {
  20791. _detect3DTransforms();
  20792. }
  20793. _initMobile();
  20794. _updateClass(documentElement, [SKROLLR_CLASS, SKROLLR_MOBILE_CLASS], [NO_SKROLLR_CLASS]);
  20795. } else {
  20796. _updateClass(documentElement, [SKROLLR_CLASS, SKROLLR_DESKTOP_CLASS], [NO_SKROLLR_CLASS]);
  20797. }
  20798. //Triggers parsing of elements and a first reflow.
  20799. _instance.refresh();
  20800. _addEvent(window, 'resize orientationchange', function() {
  20801. var width = documentElement.clientWidth;
  20802. var height = documentElement.clientHeight;
  20803. //Only reflow if the size actually changed (#271).
  20804. if(height !== _lastViewportHeight || width !== _lastViewportWidth) {
  20805. _lastViewportHeight = height;
  20806. _lastViewportWidth = width;
  20807. _requestReflow = true;
  20808. }
  20809. });
  20810. var requestAnimFrame = polyfillRAF();
  20811. //Let's go.
  20812. (function animloop(){
  20813. _render();
  20814. _animFrame = requestAnimFrame(animloop);
  20815. }());
  20816. return _instance;
  20817. }
  20818. /**
  20819. * (Re)parses some or all elements.
  20820. */
  20821. Skrollr.prototype.refresh = function(elements) {
  20822. var elementIndex;
  20823. var elementsLength;
  20824. var ignoreID = false;
  20825. //Completely reparse anything without argument.
  20826. if(elements === undefined) {
  20827. //Ignore that some elements may already have a skrollable ID.
  20828. ignoreID = true;
  20829. _skrollables = [];
  20830. _skrollableIdCounter = 0;
  20831. elements = document.getElementsByTagName('*');
  20832. } else if(elements.length === undefined) {
  20833. //We also accept a single element as parameter.
  20834. elements = [elements];
  20835. }
  20836. elementIndex = 0;
  20837. elementsLength = elements.length;
  20838. for(; elementIndex < elementsLength; elementIndex++) {
  20839. var el = elements[elementIndex];
  20840. var anchorTarget = el;
  20841. var keyFrames = [];
  20842. //If this particular element should be smooth scrolled.
  20843. var smoothScrollThis = _smoothScrollingEnabled;
  20844. //The edge strategy for this particular element.
  20845. var edgeStrategy = _edgeStrategy;
  20846. //If this particular element should emit keyframe events.
  20847. var emitEvents = false;
  20848. //If we're reseting the counter, remove any old element ids that may be hanging around.
  20849. if(ignoreID && SKROLLABLE_ID_DOM_PROPERTY in el) {
  20850. delete el[SKROLLABLE_ID_DOM_PROPERTY];
  20851. }
  20852. if(!el.attributes) {
  20853. continue;
  20854. }
  20855. //Iterate over all attributes and search for key frame attributes.
  20856. var attributeIndex = 0;
  20857. var attributesLength = el.attributes.length;
  20858. for (; attributeIndex < attributesLength; attributeIndex++) {
  20859. var attr = el.attributes[attributeIndex];
  20860. if(attr.name === 'data-anchor-target') {
  20861. anchorTarget = document.querySelector(attr.value);
  20862. if(anchorTarget === null) {
  20863. throw 'Unable to find anchor target "' + attr.value + '"';
  20864. }
  20865. continue;
  20866. }
  20867. //Global smooth scrolling can be overridden by the element attribute.
  20868. if(attr.name === 'data-smooth-scrolling') {
  20869. smoothScrollThis = attr.value !== 'off';
  20870. continue;
  20871. }
  20872. //Global edge strategy can be overridden by the element attribute.
  20873. if(attr.name === 'data-edge-strategy') {
  20874. edgeStrategy = attr.value;
  20875. continue;
  20876. }
  20877. //Is this element tagged with the `data-emit-events` attribute?
  20878. if(attr.name === 'data-emit-events') {
  20879. emitEvents = true;
  20880. continue;
  20881. }
  20882. var match = attr.name.match(rxKeyframeAttribute);
  20883. if(match === null) {
  20884. continue;
  20885. }
  20886. var kf = {
  20887. props: attr.value,
  20888. //Point back to the element as well.
  20889. element: el,
  20890. //The name of the event which this keyframe will fire, if emitEvents is
  20891. eventType: attr.name.replace(rxCamelCase, rxCamelCaseFn)
  20892. };
  20893. keyFrames.push(kf);
  20894. var constant = match[1];
  20895. if(constant) {
  20896. //Strip the underscore prefix.
  20897. kf.constant = constant.substr(1);
  20898. }
  20899. //Get the key frame offset.
  20900. var offset = match[2];
  20901. //Is it a percentage offset?
  20902. if(/p$/.test(offset)) {
  20903. kf.isPercentage = true;
  20904. kf.offset = (offset.slice(0, -1) | 0) / 100;
  20905. } else {
  20906. kf.offset = (offset | 0);
  20907. }
  20908. var anchor1 = match[3];
  20909. //If second anchor is not set, the first will be taken for both.
  20910. var anchor2 = match[4] || anchor1;
  20911. //"absolute" (or "classic") mode, where numbers mean absolute scroll offset.
  20912. if(!anchor1 || anchor1 === ANCHOR_START || anchor1 === ANCHOR_END) {
  20913. kf.mode = 'absolute';
  20914. //data-end needs to be calculated after all key frames are known.
  20915. if(anchor1 === ANCHOR_END) {
  20916. kf.isEnd = true;
  20917. } else if(!kf.isPercentage) {
  20918. //For data-start we can already set the key frame w/o calculations.
  20919. //#59: "scale" options should only affect absolute mode.
  20920. kf.offset = kf.offset * _scale;
  20921. }
  20922. }
  20923. //"relative" mode, where numbers are relative to anchors.
  20924. else {
  20925. kf.mode = 'relative';
  20926. kf.anchors = [anchor1, anchor2];
  20927. }
  20928. }
  20929. //Does this element have key frames?
  20930. if(!keyFrames.length) {
  20931. continue;
  20932. }
  20933. //Will hold the original style and class attributes before we controlled the element (see #80).
  20934. var styleAttr, classAttr;
  20935. var id;
  20936. if(!ignoreID && SKROLLABLE_ID_DOM_PROPERTY in el) {
  20937. //We already have this element under control. Grab the corresponding skrollable id.
  20938. id = el[SKROLLABLE_ID_DOM_PROPERTY];
  20939. styleAttr = _skrollables[id].styleAttr;
  20940. classAttr = _skrollables[id].classAttr;
  20941. } else {
  20942. //It's an unknown element. Asign it a new skrollable id.
  20943. id = (el[SKROLLABLE_ID_DOM_PROPERTY] = _skrollableIdCounter++);
  20944. styleAttr = el.style.cssText;
  20945. classAttr = _getClass(el);
  20946. }
  20947. _skrollables[id] = {
  20948. element: el,
  20949. styleAttr: styleAttr,
  20950. classAttr: classAttr,
  20951. anchorTarget: anchorTarget,
  20952. keyFrames: keyFrames,
  20953. smoothScrolling: smoothScrollThis,
  20954. edgeStrategy: edgeStrategy,
  20955. emitEvents: emitEvents,
  20956. lastFrameIndex: -1
  20957. };
  20958. _updateClass(el, [SKROLLABLE_CLASS], []);
  20959. }
  20960. //Reflow for the first time.
  20961. _reflow();
  20962. //Now that we got all key frame numbers right, actually parse the properties.
  20963. elementIndex = 0;
  20964. elementsLength = elements.length;
  20965. for(; elementIndex < elementsLength; elementIndex++) {
  20966. var sk = _skrollables[elements[elementIndex][SKROLLABLE_ID_DOM_PROPERTY]];
  20967. if(sk === undefined) {
  20968. continue;
  20969. }
  20970. //Parse the property string to objects
  20971. _parseProps(sk);
  20972. //Fill key frames with missing properties from left and right
  20973. _fillProps(sk);
  20974. }
  20975. return _instance;
  20976. };
  20977. /**
  20978. * Transform "relative" mode to "absolute" mode.
  20979. * That is, calculate anchor position and offset of element.
  20980. */
  20981. Skrollr.prototype.relativeToAbsolute = function(element, viewportAnchor, elementAnchor) {
  20982. var viewportHeight = documentElement.clientHeight;
  20983. var box = element.getBoundingClientRect();
  20984. var absolute = box.top;
  20985. //#100: IE doesn't supply "height" with getBoundingClientRect.
  20986. var boxHeight = box.bottom - box.top;
  20987. if(viewportAnchor === ANCHOR_BOTTOM) {
  20988. absolute -= viewportHeight;
  20989. } else if(viewportAnchor === ANCHOR_CENTER) {
  20990. absolute -= viewportHeight / 2;
  20991. }
  20992. if(elementAnchor === ANCHOR_BOTTOM) {
  20993. absolute += boxHeight;
  20994. } else if(elementAnchor === ANCHOR_CENTER) {
  20995. absolute += boxHeight / 2;
  20996. }
  20997. //Compensate scrolling since getBoundingClientRect is relative to viewport.
  20998. absolute += _instance.getScrollTop();
  20999. return (absolute + 0.5) | 0;
  21000. };
  21001. /**
  21002. * Animates scroll top to new position.
  21003. */
  21004. Skrollr.prototype.animateTo = function(top, options) {
  21005. options = options || {};
  21006. var now = _now();
  21007. var scrollTop = _instance.getScrollTop();
  21008. var duration = options.duration === undefined ? DEFAULT_DURATION : options.duration;
  21009. //Setting this to a new value will automatically cause the current animation to stop, if any.
  21010. _scrollAnimation = {
  21011. startTop: scrollTop,
  21012. topDiff: top - scrollTop,
  21013. targetTop: top,
  21014. duration: duration,
  21015. startTime: now,
  21016. endTime: now + duration,
  21017. easing: easings[options.easing || DEFAULT_EASING],
  21018. done: options.done
  21019. };
  21020. //Don't queue the animation if there's nothing to animate.
  21021. if(!_scrollAnimation.topDiff) {
  21022. if(_scrollAnimation.done) {
  21023. _scrollAnimation.done.call(_instance, false);
  21024. }
  21025. _scrollAnimation = undefined;
  21026. }
  21027. return _instance;
  21028. };
  21029. /**
  21030. * Stops animateTo animation.
  21031. */
  21032. Skrollr.prototype.stopAnimateTo = function() {
  21033. if(_scrollAnimation && _scrollAnimation.done) {
  21034. _scrollAnimation.done.call(_instance, true);
  21035. }
  21036. _scrollAnimation = undefined;
  21037. };
  21038. /**
  21039. * Returns if an animation caused by animateTo is currently running.
  21040. */
  21041. Skrollr.prototype.isAnimatingTo = function() {
  21042. return !!_scrollAnimation;
  21043. };
  21044. Skrollr.prototype.isMobile = function() {
  21045. return _isMobile;
  21046. };
  21047. Skrollr.prototype.setScrollTop = function(top, force) {
  21048. _forceRender = (force === true);
  21049. if(_isMobile) {
  21050. _mobileOffset = Math.min(Math.max(top, 0), _maxKeyFrame);
  21051. } else {
  21052. window.scrollTo(0, top);
  21053. }
  21054. return _instance;
  21055. };
  21056. Skrollr.prototype.getScrollTop = function() {
  21057. if(_isMobile) {
  21058. return _mobileOffset;
  21059. } else {
  21060. return window.pageYOffset || documentElement.scrollTop || body.scrollTop || 0;
  21061. }
  21062. };
  21063. Skrollr.prototype.getMaxScrollTop = function() {
  21064. return _maxKeyFrame;
  21065. };
  21066. Skrollr.prototype.on = function(name, fn) {
  21067. _listeners[name] = fn;
  21068. return _instance;
  21069. };
  21070. Skrollr.prototype.off = function(name) {
  21071. delete _listeners[name];
  21072. return _instance;
  21073. };
  21074. Skrollr.prototype.destroy = function() {
  21075. var cancelAnimFrame = polyfillCAF();
  21076. cancelAnimFrame(_animFrame);
  21077. _removeAllEvents();
  21078. _updateClass(documentElement, [NO_SKROLLR_CLASS], [SKROLLR_CLASS, SKROLLR_DESKTOP_CLASS, SKROLLR_MOBILE_CLASS]);
  21079. var skrollableIndex = 0;
  21080. var skrollablesLength = _skrollables.length;
  21081. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21082. _reset(_skrollables[skrollableIndex].element);
  21083. }
  21084. documentElement.style.overflow = body.style.overflow = '';
  21085. documentElement.style.height = body.style.height = '';
  21086. if(_skrollrBody) {
  21087. skrollr.setStyle(_skrollrBody, 'transform', 'none');
  21088. }
  21089. _instance = undefined;
  21090. _skrollrBody = undefined;
  21091. _listeners = undefined;
  21092. _forceHeight = undefined;
  21093. _maxKeyFrame = 0;
  21094. _scale = 1;
  21095. _constants = undefined;
  21096. _mobileDeceleration = undefined;
  21097. _direction = 'down';
  21098. _lastTop = -1;
  21099. _lastViewportWidth = 0;
  21100. _lastViewportHeight = 0;
  21101. _requestReflow = false;
  21102. _scrollAnimation = undefined;
  21103. _smoothScrollingEnabled = undefined;
  21104. _smoothScrollingDuration = undefined;
  21105. _smoothScrolling = undefined;
  21106. _forceRender = undefined;
  21107. _skrollableIdCounter = 0;
  21108. _edgeStrategy = undefined;
  21109. _isMobile = false;
  21110. _mobileOffset = 0;
  21111. _translateZ = undefined;
  21112. };
  21113. /*
  21114. Private methods.
  21115. */
  21116. var _initMobile = function() {
  21117. var initialElement;
  21118. var initialTouchY;
  21119. var initialTouchX;
  21120. var currentElement;
  21121. var currentTouchY;
  21122. var currentTouchX;
  21123. var lastTouchY;
  21124. var deltaY;
  21125. var initialTouchTime;
  21126. var currentTouchTime;
  21127. var lastTouchTime;
  21128. var deltaTime;
  21129. _addEvent(documentElement, [EVENT_TOUCHSTART, EVENT_TOUCHMOVE, EVENT_TOUCHCANCEL, EVENT_TOUCHEND].join(' '), function(e) {
  21130. var touch = e.changedTouches[0];
  21131. currentElement = e.target;
  21132. //We don't want text nodes.
  21133. while(currentElement.nodeType === 3) {
  21134. currentElement = currentElement.parentNode;
  21135. }
  21136. currentTouchY = touch.clientY;
  21137. currentTouchX = touch.clientX;
  21138. currentTouchTime = e.timeStamp;
  21139. if(!rxTouchIgnoreTags.test(currentElement.tagName)) {
  21140. e.preventDefault();
  21141. }
  21142. switch(e.type) {
  21143. case EVENT_TOUCHSTART:
  21144. //The last element we tapped on.
  21145. if(initialElement) {
  21146. initialElement.blur();
  21147. }
  21148. _instance.stopAnimateTo();
  21149. initialElement = currentElement;
  21150. initialTouchY = lastTouchY = currentTouchY;
  21151. initialTouchX = currentTouchX;
  21152. initialTouchTime = currentTouchTime;
  21153. break;
  21154. case EVENT_TOUCHMOVE:
  21155. //Prevent default event on touchIgnore elements in case they don't have focus yet.
  21156. if(rxTouchIgnoreTags.test(currentElement.tagName) && document.activeElement !== currentElement) {
  21157. e.preventDefault();
  21158. }
  21159. deltaY = currentTouchY - lastTouchY;
  21160. deltaTime = currentTouchTime - lastTouchTime;
  21161. _instance.setScrollTop(_mobileOffset - deltaY, true);
  21162. lastTouchY = currentTouchY;
  21163. lastTouchTime = currentTouchTime;
  21164. break;
  21165. default:
  21166. case EVENT_TOUCHCANCEL:
  21167. case EVENT_TOUCHEND:
  21168. var distanceY = initialTouchY - currentTouchY;
  21169. var distanceX = initialTouchX - currentTouchX;
  21170. var distance2 = distanceX * distanceX + distanceY * distanceY;
  21171. //Check if it was more like a tap (moved less than 7px).
  21172. if(distance2 < 49) {
  21173. if(!rxTouchIgnoreTags.test(initialElement.tagName)) {
  21174. initialElement.focus();
  21175. //It was a tap, click the element.
  21176. var clickEvent = document.createEvent('MouseEvents');
  21177. clickEvent.initMouseEvent('click', true, true, e.view, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 0, null);
  21178. initialElement.dispatchEvent(clickEvent);
  21179. }
  21180. return;
  21181. }
  21182. initialElement = undefined;
  21183. var speed = deltaY / deltaTime;
  21184. //Cap speed at 3 pixel/ms.
  21185. speed = Math.max(Math.min(speed, 3), -3);
  21186. var duration = Math.abs(speed / _mobileDeceleration);
  21187. var targetOffset = speed * duration + 0.5 * _mobileDeceleration * duration * duration;
  21188. var targetTop = _instance.getScrollTop() - targetOffset;
  21189. //Relative duration change for when scrolling above bounds.
  21190. var targetRatio = 0;
  21191. //Change duration proportionally when scrolling would leave bounds.
  21192. if(targetTop > _maxKeyFrame) {
  21193. targetRatio = (_maxKeyFrame - targetTop) / targetOffset;
  21194. targetTop = _maxKeyFrame;
  21195. } else if(targetTop < 0) {
  21196. targetRatio = -targetTop / targetOffset;
  21197. targetTop = 0;
  21198. }
  21199. duration = duration * (1 - targetRatio);
  21200. _instance.animateTo((targetTop + 0.5) | 0, {easing: 'outCubic', duration: duration});
  21201. break;
  21202. }
  21203. });
  21204. //Just in case there has already been some native scrolling, reset it.
  21205. window.scrollTo(0, 0);
  21206. documentElement.style.overflow = body.style.overflow = 'hidden';
  21207. };
  21208. /**
  21209. * Updates key frames which depend on others / need to be updated on resize.
  21210. * That is "end" in "absolute" mode and all key frames in "relative" mode.
  21211. * Also handles constants, because they may change on resize.
  21212. */
  21213. var _updateDependentKeyFrames = function() {
  21214. var viewportHeight = documentElement.clientHeight;
  21215. var processedConstants = _processConstants();
  21216. var skrollable;
  21217. var element;
  21218. var anchorTarget;
  21219. var keyFrames;
  21220. var keyFrameIndex;
  21221. var keyFramesLength;
  21222. var kf;
  21223. var skrollableIndex;
  21224. var skrollablesLength;
  21225. var offset;
  21226. var constantValue;
  21227. //First process all relative-mode elements and find the max key frame.
  21228. skrollableIndex = 0;
  21229. skrollablesLength = _skrollables.length;
  21230. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21231. skrollable = _skrollables[skrollableIndex];
  21232. element = skrollable.element;
  21233. anchorTarget = skrollable.anchorTarget;
  21234. keyFrames = skrollable.keyFrames;
  21235. keyFrameIndex = 0;
  21236. keyFramesLength = keyFrames.length;
  21237. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21238. kf = keyFrames[keyFrameIndex];
  21239. offset = kf.offset;
  21240. constantValue = processedConstants[kf.constant] || 0;
  21241. kf.frame = offset;
  21242. if(kf.isPercentage) {
  21243. //Convert the offset to percentage of the viewport height.
  21244. offset = offset * viewportHeight;
  21245. //Absolute + percentage mode.
  21246. kf.frame = offset;
  21247. }
  21248. if(kf.mode === 'relative') {
  21249. _reset(element);
  21250. kf.frame = _instance.relativeToAbsolute(anchorTarget, kf.anchors[0], kf.anchors[1]) - offset;
  21251. _reset(element, true);
  21252. }
  21253. kf.frame += constantValue;
  21254. //Only search for max key frame when forceHeight is enabled.
  21255. if(_forceHeight) {
  21256. //Find the max key frame, but don't use one of the data-end ones for comparison.
  21257. if(!kf.isEnd && kf.frame > _maxKeyFrame) {
  21258. _maxKeyFrame = kf.frame;
  21259. }
  21260. }
  21261. }
  21262. }
  21263. //#133: The document can be larger than the maxKeyFrame we found.
  21264. _maxKeyFrame = Math.max(_maxKeyFrame, _getDocumentHeight());
  21265. //Now process all data-end keyframes.
  21266. skrollableIndex = 0;
  21267. skrollablesLength = _skrollables.length;
  21268. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21269. skrollable = _skrollables[skrollableIndex];
  21270. keyFrames = skrollable.keyFrames;
  21271. keyFrameIndex = 0;
  21272. keyFramesLength = keyFrames.length;
  21273. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21274. kf = keyFrames[keyFrameIndex];
  21275. constantValue = processedConstants[kf.constant] || 0;
  21276. if(kf.isEnd) {
  21277. kf.frame = _maxKeyFrame - kf.offset + constantValue;
  21278. }
  21279. }
  21280. skrollable.keyFrames.sort(_keyFrameComparator);
  21281. }
  21282. };
  21283. /**
  21284. * Calculates and sets the style properties for the element at the given frame.
  21285. * @param fakeFrame The frame to render at when smooth scrolling is enabled.
  21286. * @param actualFrame The actual frame we are at.
  21287. */
  21288. var _calcSteps = function(fakeFrame, actualFrame) {
  21289. //Iterate over all skrollables.
  21290. var skrollableIndex = 0;
  21291. var skrollablesLength = _skrollables.length;
  21292. for(; skrollableIndex < skrollablesLength; skrollableIndex++) {
  21293. var skrollable = _skrollables[skrollableIndex];
  21294. var element = skrollable.element;
  21295. var frame = skrollable.smoothScrolling ? fakeFrame : actualFrame;
  21296. var frames = skrollable.keyFrames;
  21297. var framesLength = frames.length;
  21298. var firstFrame = frames[0];
  21299. var lastFrame = frames[frames.length - 1];
  21300. var beforeFirst = frame < firstFrame.frame;
  21301. var afterLast = frame > lastFrame.frame;
  21302. var firstOrLastFrame = beforeFirst ? firstFrame : lastFrame;
  21303. var emitEvents = skrollable.emitEvents;
  21304. var lastFrameIndex = skrollable.lastFrameIndex;
  21305. var key;
  21306. var value;
  21307. //If we are before/after the first/last frame, set the styles according to the given edge strategy.
  21308. if(beforeFirst || afterLast) {
  21309. //Check if we already handled this edge case last time.
  21310. //Note: using setScrollTop it's possible that we jumped from one edge to the other.
  21311. if(beforeFirst && skrollable.edge === -1 || afterLast && skrollable.edge === 1) {
  21312. continue;
  21313. }
  21314. //Add the skrollr-before or -after class.
  21315. if(beforeFirst) {
  21316. _updateClass(element, [SKROLLABLE_BEFORE_CLASS], [SKROLLABLE_AFTER_CLASS, SKROLLABLE_BETWEEN_CLASS]);
  21317. //This handles the special case where we exit the first keyframe.
  21318. if(emitEvents && lastFrameIndex > -1) {
  21319. _emitEvent(element, firstFrame.eventType, _direction);
  21320. skrollable.lastFrameIndex = -1;
  21321. }
  21322. } else {
  21323. _updateClass(element, [SKROLLABLE_AFTER_CLASS], [SKROLLABLE_BEFORE_CLASS, SKROLLABLE_BETWEEN_CLASS]);
  21324. //This handles the special case where we exit the last keyframe.
  21325. if(emitEvents && lastFrameIndex < framesLength) {
  21326. _emitEvent(element, lastFrame.eventType, _direction);
  21327. skrollable.lastFrameIndex = framesLength;
  21328. }
  21329. }
  21330. //Remember that we handled the edge case (before/after the first/last keyframe).
  21331. skrollable.edge = beforeFirst ? -1 : 1;
  21332. switch(skrollable.edgeStrategy) {
  21333. case 'reset':
  21334. _reset(element);
  21335. continue;
  21336. case 'ease':
  21337. //Handle this case like it would be exactly at first/last keyframe and just pass it on.
  21338. frame = firstOrLastFrame.frame;
  21339. break;
  21340. default:
  21341. case 'set':
  21342. var props = firstOrLastFrame.props;
  21343. for(key in props) {
  21344. if(hasProp.call(props, key)) {
  21345. value = _interpolateString(props[key].value);
  21346. //Set style or attribute.
  21347. if(key.indexOf('@') === 0) {
  21348. element.setAttribute(key.substr(1), value);
  21349. } else {
  21350. skrollr.setStyle(element, key, value);
  21351. }
  21352. }
  21353. }
  21354. continue;
  21355. }
  21356. } else {
  21357. //Did we handle an edge last time?
  21358. if(skrollable.edge !== 0) {
  21359. _updateClass(element, [SKROLLABLE_CLASS, SKROLLABLE_BETWEEN_CLASS], [SKROLLABLE_BEFORE_CLASS, SKROLLABLE_AFTER_CLASS]);
  21360. skrollable.edge = 0;
  21361. }
  21362. }
  21363. //Find out between which two key frames we are right now.
  21364. var keyFrameIndex = 0;
  21365. for(; keyFrameIndex < framesLength - 1; keyFrameIndex++) {
  21366. if(frame >= frames[keyFrameIndex].frame && frame <= frames[keyFrameIndex + 1].frame) {
  21367. var left = frames[keyFrameIndex];
  21368. var right = frames[keyFrameIndex + 1];
  21369. for(key in left.props) {
  21370. if(hasProp.call(left.props, key)) {
  21371. var progress = (frame - left.frame) / (right.frame - left.frame);
  21372. //Transform the current progress using the given easing function.
  21373. progress = left.props[key].easing(progress);
  21374. //Interpolate between the two values
  21375. value = _calcInterpolation(left.props[key].value, right.props[key].value, progress);
  21376. value = _interpolateString(value);
  21377. //Set style or attribute.
  21378. if(key.indexOf('@') === 0) {
  21379. element.setAttribute(key.substr(1), value);
  21380. } else {
  21381. skrollr.setStyle(element, key, value);
  21382. }
  21383. }
  21384. }
  21385. //Are events enabled on this element?
  21386. //This code handles the usual cases of scrolling through different keyframes.
  21387. //The special cases of before first and after last keyframe are handled above.
  21388. if(emitEvents) {
  21389. //Did we pass a new keyframe?
  21390. if(lastFrameIndex !== keyFrameIndex) {
  21391. if(_direction === 'down') {
  21392. _emitEvent(element, left.eventType, _direction);
  21393. } else {
  21394. _emitEvent(element, right.eventType, _direction);
  21395. }
  21396. skrollable.lastFrameIndex = keyFrameIndex;
  21397. }
  21398. }
  21399. break;
  21400. }
  21401. }
  21402. }
  21403. };
  21404. /**
  21405. * Renders all elements.
  21406. */
  21407. var _render = function() {
  21408. if(_requestReflow) {
  21409. _requestReflow = false;
  21410. _reflow();
  21411. }
  21412. //We may render something else than the actual scrollbar position.
  21413. var renderTop = _instance.getScrollTop();
  21414. //If there's an animation, which ends in current render call, call the callback after rendering.
  21415. var afterAnimationCallback;
  21416. var now = _now();
  21417. var progress;
  21418. //Before actually rendering handle the scroll animation, if any.
  21419. if(_scrollAnimation) {
  21420. //It's over
  21421. if(now >= _scrollAnimation.endTime) {
  21422. renderTop = _scrollAnimation.targetTop;
  21423. afterAnimationCallback = _scrollAnimation.done;
  21424. _scrollAnimation = undefined;
  21425. } else {
  21426. //Map the current progress to the new progress using given easing function.
  21427. progress = _scrollAnimation.easing((now - _scrollAnimation.startTime) / _scrollAnimation.duration);
  21428. renderTop = (_scrollAnimation.startTop + progress * _scrollAnimation.topDiff) | 0;
  21429. }
  21430. _instance.setScrollTop(renderTop, true);
  21431. }
  21432. //Smooth scrolling only if there's no animation running and if we're not forcing the rendering.
  21433. else if(!_forceRender) {
  21434. var smoothScrollingDiff = _smoothScrolling.targetTop - renderTop;
  21435. //The user scrolled, start new smooth scrolling.
  21436. if(smoothScrollingDiff) {
  21437. _smoothScrolling = {
  21438. startTop: _lastTop,
  21439. topDiff: renderTop - _lastTop,
  21440. targetTop: renderTop,
  21441. startTime: _lastRenderCall,
  21442. endTime: _lastRenderCall + _smoothScrollingDuration
  21443. };
  21444. }
  21445. //Interpolate the internal scroll position (not the actual scrollbar).
  21446. if(now <= _smoothScrolling.endTime) {
  21447. //Map the current progress to the new progress using easing function.
  21448. progress = easings.sqrt((now - _smoothScrolling.startTime) / _smoothScrollingDuration);
  21449. renderTop = (_smoothScrolling.startTop + progress * _smoothScrolling.topDiff) | 0;
  21450. }
  21451. }
  21452. //Did the scroll position even change?
  21453. if(_forceRender || _lastTop !== renderTop) {
  21454. //Remember in which direction are we scrolling?
  21455. _direction = (renderTop > _lastTop) ? 'down' : (renderTop < _lastTop ? 'up' : _direction);
  21456. _forceRender = false;
  21457. var listenerParams = {
  21458. curTop: renderTop,
  21459. lastTop: _lastTop,
  21460. maxTop: _maxKeyFrame,
  21461. direction: _direction
  21462. };
  21463. //Tell the listener we are about to render.
  21464. var continueRendering = _listeners.beforerender && _listeners.beforerender.call(_instance, listenerParams);
  21465. //The beforerender listener function is able the cancel rendering.
  21466. if(continueRendering !== false) {
  21467. //Now actually interpolate all the styles.
  21468. _calcSteps(renderTop, _instance.getScrollTop());
  21469. //That's were we actually "scroll" on mobile.
  21470. if(_isMobile && _skrollrBody) {
  21471. //Set the transform ("scroll it").
  21472. skrollr.setStyle(_skrollrBody, 'transform', 'translate(0, ' + -(_mobileOffset) + 'px) ' + _translateZ);
  21473. }
  21474. //Remember when we last rendered.
  21475. _lastTop = renderTop;
  21476. if(_listeners.render) {
  21477. _listeners.render.call(_instance, listenerParams);
  21478. }
  21479. }
  21480. if(afterAnimationCallback) {
  21481. afterAnimationCallback.call(_instance, false);
  21482. }
  21483. }
  21484. _lastRenderCall = now;
  21485. };
  21486. /**
  21487. * Parses the properties for each key frame of the given skrollable.
  21488. */
  21489. var _parseProps = function(skrollable) {
  21490. //Iterate over all key frames
  21491. var keyFrameIndex = 0;
  21492. var keyFramesLength = skrollable.keyFrames.length;
  21493. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21494. var frame = skrollable.keyFrames[keyFrameIndex];
  21495. var easing;
  21496. var value;
  21497. var prop;
  21498. var props = {};
  21499. var match;
  21500. while((match = rxPropValue.exec(frame.props)) !== null) {
  21501. prop = match[1];
  21502. value = match[2];
  21503. easing = prop.match(rxPropEasing);
  21504. //Is there an easing specified for this prop?
  21505. if(easing !== null) {
  21506. prop = easing[1];
  21507. easing = easing[2];
  21508. } else {
  21509. easing = DEFAULT_EASING;
  21510. }
  21511. //Exclamation point at first position forces the value to be taken literal.
  21512. value = value.indexOf('!') ? _parseProp(value) : [value.slice(1)];
  21513. //Save the prop for this key frame with his value and easing function
  21514. props[prop] = {
  21515. value: value,
  21516. easing: easings[easing]
  21517. };
  21518. }
  21519. frame.props = props;
  21520. }
  21521. };
  21522. /**
  21523. * Parses a value extracting numeric values and generating a format string
  21524. * for later interpolation of the new values in old string.
  21525. *
  21526. * @param val The CSS value to be parsed.
  21527. * @return Something like ["rgba(?%,?%, ?%,?)", 100, 50, 0, .7]
  21528. * where the first element is the format string later used
  21529. * and all following elements are the numeric value.
  21530. */
  21531. var _parseProp = function(val) {
  21532. var numbers = [];
  21533. //One special case, where floats don't work.
  21534. //We replace all occurences of rgba colors
  21535. //which don't use percentage notation with the percentage notation.
  21536. rxRGBAIntegerColor.lastIndex = 0;
  21537. val = val.replace(rxRGBAIntegerColor, function(rgba) {
  21538. return rgba.replace(rxNumericValue, function(n) {
  21539. return n / 255 * 100 + '%';
  21540. });
  21541. });
  21542. //Handle prefixing of "gradient" values.
  21543. //For now only the prefixed value will be set. Unprefixed isn't supported anyway.
  21544. if(theDashedCSSPrefix) {
  21545. rxGradient.lastIndex = 0;
  21546. val = val.replace(rxGradient, function(s) {
  21547. return theDashedCSSPrefix + s;
  21548. });
  21549. }
  21550. //Now parse ANY number inside this string and create a format string.
  21551. val = val.replace(rxNumericValue, function(n) {
  21552. numbers.push(+n);
  21553. return '{?}';
  21554. });
  21555. //Add the formatstring as first value.
  21556. numbers.unshift(val);
  21557. return numbers;
  21558. };
  21559. /**
  21560. * Fills the key frames with missing left and right hand properties.
  21561. * If key frame 1 has property X and key frame 2 is missing X,
  21562. * but key frame 3 has X again, then we need to assign X to key frame 2 too.
  21563. *
  21564. * @param sk A skrollable.
  21565. */
  21566. var _fillProps = function(sk) {
  21567. //Will collect the properties key frame by key frame
  21568. var propList = {};
  21569. var keyFrameIndex;
  21570. var keyFramesLength;
  21571. //Iterate over all key frames from left to right
  21572. keyFrameIndex = 0;
  21573. keyFramesLength = sk.keyFrames.length;
  21574. for(; keyFrameIndex < keyFramesLength; keyFrameIndex++) {
  21575. _fillPropForFrame(sk.keyFrames[keyFrameIndex], propList);
  21576. }
  21577. //Now do the same from right to fill the last gaps
  21578. propList = {};
  21579. //Iterate over all key frames from right to left
  21580. keyFrameIndex = sk.keyFrames.length - 1;
  21581. for(; keyFrameIndex >= 0; keyFrameIndex--) {
  21582. _fillPropForFrame(sk.keyFrames[keyFrameIndex], propList);
  21583. }
  21584. };
  21585. var _fillPropForFrame = function(frame, propList) {
  21586. var key;
  21587. //For each key frame iterate over all right hand properties and assign them,
  21588. //but only if the current key frame doesn't have the property by itself
  21589. for(key in propList) {
  21590. //The current frame misses this property, so assign it.
  21591. if(!hasProp.call(frame.props, key)) {
  21592. frame.props[key] = propList[key];
  21593. }
  21594. }
  21595. //Iterate over all props of the current frame and collect them
  21596. for(key in frame.props) {
  21597. propList[key] = frame.props[key];
  21598. }
  21599. };
  21600. /**
  21601. * Calculates the new values for two given values array.
  21602. */
  21603. var _calcInterpolation = function(val1, val2, progress) {
  21604. var valueIndex;
  21605. var val1Length = val1.length;
  21606. //They both need to have the same length
  21607. if(val1Length !== val2.length) {
  21608. throw 'Can\'t interpolate between "' + val1[0] + '" and "' + val2[0] + '"';
  21609. }
  21610. //Add the format string as first element.
  21611. var interpolated = [val1[0]];
  21612. valueIndex = 1;
  21613. for(; valueIndex < val1Length; valueIndex++) {
  21614. //That's the line where the two numbers are actually interpolated.
  21615. interpolated[valueIndex] = val1[valueIndex] + ((val2[valueIndex] - val1[valueIndex]) * progress);
  21616. }
  21617. return interpolated;
  21618. };
  21619. /**
  21620. * Interpolates the numeric values into the format string.
  21621. */
  21622. var _interpolateString = function(val) {
  21623. var valueIndex = 1;
  21624. rxInterpolateString.lastIndex = 0;
  21625. return val[0].replace(rxInterpolateString, function() {
  21626. return val[valueIndex++];
  21627. });
  21628. };
  21629. /**
  21630. * Resets the class and style attribute to what it was before skrollr manipulated the element.
  21631. * Also remembers the values it had before reseting, in order to undo the reset.
  21632. */
  21633. var _reset = function(elements, undo) {
  21634. //We accept a single element or an array of elements.
  21635. elements = [].concat(elements);
  21636. var skrollable;
  21637. var element;
  21638. var elementsIndex = 0;
  21639. var elementsLength = elements.length;
  21640. for(; elementsIndex < elementsLength; elementsIndex++) {
  21641. element = elements[elementsIndex];
  21642. skrollable = _skrollables[element[SKROLLABLE_ID_DOM_PROPERTY]];
  21643. //Couldn't find the skrollable for this DOM element.
  21644. if(!skrollable) {
  21645. continue;
  21646. }
  21647. if(undo) {
  21648. //Reset class and style to the "dirty" (set by skrollr) values.
  21649. element.style.cssText = skrollable.dirtyStyleAttr;
  21650. _updateClass(element, skrollable.dirtyClassAttr);
  21651. } else {
  21652. //Remember the "dirty" (set by skrollr) class and style.
  21653. skrollable.dirtyStyleAttr = element.style.cssText;
  21654. skrollable.dirtyClassAttr = _getClass(element);
  21655. //Reset class and style to what it originally was.
  21656. element.style.cssText = skrollable.styleAttr;
  21657. _updateClass(element, skrollable.classAttr);
  21658. }
  21659. }
  21660. };
  21661. /**
  21662. * Detects support for 3d transforms by applying it to the skrollr-body.
  21663. */
  21664. var _detect3DTransforms = function() {
  21665. _translateZ = 'translateZ(0)';
  21666. skrollr.setStyle(_skrollrBody, 'transform', _translateZ);
  21667. var computedStyle = getStyle(_skrollrBody);
  21668. var computedTransform = computedStyle.getPropertyValue('transform');
  21669. var computedTransformWithPrefix = computedStyle.getPropertyValue(theDashedCSSPrefix + 'transform');
  21670. var has3D = (computedTransform && computedTransform !== 'none') || (computedTransformWithPrefix && computedTransformWithPrefix !== 'none');
  21671. if(!has3D) {
  21672. _translateZ = '';
  21673. }
  21674. };
  21675. /**
  21676. * Set the CSS property on the given element. Sets prefixed properties as well.
  21677. */
  21678. skrollr.setStyle = function(el, prop, val) {
  21679. var style = el.style;
  21680. //Camel case.
  21681. prop = prop.replace(rxCamelCase, rxCamelCaseFn).replace('-', '');
  21682. //Make sure z-index gets a <integer>.
  21683. //This is the only <integer> case we need to handle.
  21684. if(prop === 'zIndex') {
  21685. if(isNaN(val)) {
  21686. //If it's not a number, don't touch it.
  21687. //It could for example be "auto" (#351).
  21688. style[prop] = val;
  21689. } else {
  21690. //Floor the number.
  21691. style[prop] = '' + (val | 0);
  21692. }
  21693. }
  21694. //#64: "float" can't be set across browsers. Needs to use "cssFloat" for all except IE.
  21695. else if(prop === 'float') {
  21696. style.styleFloat = style.cssFloat = val;
  21697. }
  21698. else {
  21699. //Need try-catch for old IE.
  21700. try {
  21701. //Set prefixed property if there's a prefix.
  21702. if(theCSSPrefix) {
  21703. style[theCSSPrefix + prop.slice(0,1).toUpperCase() + prop.slice(1)] = val;
  21704. }
  21705. //Set unprefixed.
  21706. style[prop] = val;
  21707. } catch(ignore) {}
  21708. }
  21709. };
  21710. /**
  21711. * Cross browser event handling.
  21712. */
  21713. var _addEvent = skrollr.addEvent = function(element, names, callback) {
  21714. var intermediate = function(e) {
  21715. //Normalize IE event stuff.
  21716. e = e || window.event;
  21717. if(!e.target) {
  21718. e.target = e.srcElement;
  21719. }
  21720. if(!e.preventDefault) {
  21721. e.preventDefault = function() {
  21722. e.returnValue = false;
  21723. e.defaultPrevented = true;
  21724. };
  21725. }
  21726. return callback.call(this, e);
  21727. };
  21728. names = names.split(' ');
  21729. var name;
  21730. var nameCounter = 0;
  21731. var namesLength = names.length;
  21732. for(; nameCounter < namesLength; nameCounter++) {
  21733. name = names[nameCounter];
  21734. if(element.addEventListener) {
  21735. element.addEventListener(name, callback, false);
  21736. } else {
  21737. element.attachEvent('on' + name, intermediate);
  21738. }
  21739. //Remember the events to be able to flush them later.
  21740. _registeredEvents.push({
  21741. element: element,
  21742. name: name,
  21743. listener: callback
  21744. });
  21745. }
  21746. };
  21747. var _removeEvent = skrollr.removeEvent = function(element, names, callback) {
  21748. names = names.split(' ');
  21749. var nameCounter = 0;
  21750. var namesLength = names.length;
  21751. for(; nameCounter < namesLength; nameCounter++) {
  21752. if(element.removeEventListener) {
  21753. element.removeEventListener(names[nameCounter], callback, false);
  21754. } else {
  21755. element.detachEvent('on' + names[nameCounter], callback);
  21756. }
  21757. }
  21758. };
  21759. var _removeAllEvents = function() {
  21760. var eventData;
  21761. var eventCounter = 0;
  21762. var eventsLength = _registeredEvents.length;
  21763. for(; eventCounter < eventsLength; eventCounter++) {
  21764. eventData = _registeredEvents[eventCounter];
  21765. _removeEvent(eventData.element, eventData.name, eventData.listener);
  21766. }
  21767. _registeredEvents = [];
  21768. };
  21769. var _emitEvent = function(element, name, direction) {
  21770. if(_listeners.keyframe) {
  21771. _listeners.keyframe.call(_instance, element, name, direction);
  21772. }
  21773. };
  21774. var _reflow = function() {
  21775. var pos = _instance.getScrollTop();
  21776. //Will be recalculated by _updateDependentKeyFrames.
  21777. _maxKeyFrame = 0;
  21778. if(_forceHeight && !_isMobile) {
  21779. //un-"force" the height to not mess with the calculations in _updateDependentKeyFrames (#216).
  21780. body.style.height = '';
  21781. }
  21782. _updateDependentKeyFrames();
  21783. if(_forceHeight && !_isMobile) {
  21784. //"force" the height.
  21785. body.style.height = (_maxKeyFrame + documentElement.clientHeight) + 'px';
  21786. }
  21787. //The scroll offset may now be larger than needed (on desktop the browser/os prevents scrolling farther than the bottom).
  21788. if(_isMobile) {
  21789. _instance.setScrollTop(Math.min(_instance.getScrollTop(), _maxKeyFrame));
  21790. } else {
  21791. //Remember and reset the scroll pos (#217).
  21792. _instance.setScrollTop(pos, true);
  21793. }
  21794. _forceRender = true;
  21795. };
  21796. /*
  21797. * Returns a copy of the constants object where all functions and strings have been evaluated.
  21798. */
  21799. var _processConstants = function() {
  21800. var viewportHeight = documentElement.clientHeight;
  21801. var copy = {};
  21802. var prop;
  21803. var value;
  21804. for(prop in _constants) {
  21805. value = _constants[prop];
  21806. if(typeof value === 'function') {
  21807. value = value.call(_instance);
  21808. }
  21809. //Percentage offset.
  21810. else if((/p$/).test(value)) {
  21811. value = (value.slice(0, -1) / 100) * viewportHeight;
  21812. }
  21813. copy[prop] = value;
  21814. }
  21815. return copy;
  21816. };
  21817. /*
  21818. * Returns the height of the document.
  21819. */
  21820. var _getDocumentHeight = function() {
  21821. var skrollrBodyHeight = 0;
  21822. var bodyHeight;
  21823. if(_skrollrBody) {
  21824. skrollrBodyHeight = Math.max(_skrollrBody.offsetHeight, _skrollrBody.scrollHeight);
  21825. }
  21826. bodyHeight = Math.max(skrollrBodyHeight, body.scrollHeight, body.offsetHeight, documentElement.scrollHeight, documentElement.offsetHeight, documentElement.clientHeight);
  21827. return bodyHeight - documentElement.clientHeight;
  21828. };
  21829. /**
  21830. * Returns a string of space separated classnames for the current element.
  21831. * Works with SVG as well.
  21832. */
  21833. var _getClass = function(element) {
  21834. var prop = 'className';
  21835. //SVG support by using className.baseVal instead of just className.
  21836. if(window.SVGElement && element instanceof window.SVGElement) {
  21837. element = element[prop];
  21838. prop = 'baseVal';
  21839. }
  21840. return element[prop];
  21841. };
  21842. /**
  21843. * Adds and removes a CSS classes.
  21844. * Works with SVG as well.
  21845. * add and remove are arrays of strings,
  21846. * or if remove is ommited add is a string and overwrites all classes.
  21847. */
  21848. var _updateClass = function(element, add, remove) {
  21849. var prop = 'className';
  21850. //SVG support by using className.baseVal instead of just className.
  21851. if(window.SVGElement && element instanceof window.SVGElement) {
  21852. element = element[prop];
  21853. prop = 'baseVal';
  21854. }
  21855. //When remove is ommited, we want to overwrite/set the classes.
  21856. if(remove === undefined) {
  21857. element[prop] = add;
  21858. return;
  21859. }
  21860. //Cache current classes. We will work on a string before passing back to DOM.
  21861. var val = element[prop];
  21862. //All classes to be removed.
  21863. var classRemoveIndex = 0;
  21864. var removeLength = remove.length;
  21865. for(; classRemoveIndex < removeLength; classRemoveIndex++) {
  21866. val = _untrim(val).replace(_untrim(remove[classRemoveIndex]), ' ');
  21867. }
  21868. val = _trim(val);
  21869. //All classes to be added.
  21870. var classAddIndex = 0;
  21871. var addLength = add.length;
  21872. for(; classAddIndex < addLength; classAddIndex++) {
  21873. //Only add if el not already has class.
  21874. if(_untrim(val).indexOf(_untrim(add[classAddIndex])) === -1) {
  21875. val += ' ' + add[classAddIndex];
  21876. }
  21877. }
  21878. element[prop] = _trim(val);
  21879. };
  21880. var _trim = function(a) {
  21881. return a.replace(rxTrim, '');
  21882. };
  21883. /**
  21884. * Adds a space before and after the string.
  21885. */
  21886. var _untrim = function(a) {
  21887. return ' ' + a + ' ';
  21888. };
  21889. var _now = Date.now || function() {
  21890. return +new Date();
  21891. };
  21892. var _keyFrameComparator = function(a, b) {
  21893. return a.frame - b.frame;
  21894. };
  21895. /*
  21896. * Private variables.
  21897. */
  21898. //Singleton
  21899. var _instance;
  21900. /*
  21901. A list of all elements which should be animated associated with their the metadata.
  21902. Exmaple skrollable with two key frames animating from 100px width to 20px:
  21903. skrollable = {
  21904. element: <the DOM element>,
  21905. styleAttr: <style attribute of the element before skrollr>,
  21906. classAttr: <class attribute of the element before skrollr>,
  21907. keyFrames: [
  21908. {
  21909. frame: 100,
  21910. props: {
  21911. width: {
  21912. value: ['{?}px', 100],
  21913. easing: <reference to easing function>
  21914. }
  21915. },
  21916. mode: "absolute"
  21917. },
  21918. {
  21919. frame: 200,
  21920. props: {
  21921. width: {
  21922. value: ['{?}px', 20],
  21923. easing: <reference to easing function>
  21924. }
  21925. },
  21926. mode: "absolute"
  21927. }
  21928. ]
  21929. };
  21930. */
  21931. var _skrollables;
  21932. var _skrollrBody;
  21933. var _listeners;
  21934. var _forceHeight;
  21935. var _maxKeyFrame = 0;
  21936. var _scale = 1;
  21937. var _constants;
  21938. var _mobileDeceleration;
  21939. //Current direction (up/down).
  21940. var _direction = 'down';
  21941. //The last top offset value. Needed to determine direction.
  21942. var _lastTop = -1;
  21943. //The last time we called the render method (doesn't mean we rendered!).
  21944. var _lastRenderCall = _now();
  21945. //For detecting if it actually resized (#271).
  21946. var _lastViewportWidth = 0;
  21947. var _lastViewportHeight = 0;
  21948. var _requestReflow = false;
  21949. //Will contain data about a running scrollbar animation, if any.
  21950. var _scrollAnimation;
  21951. var _smoothScrollingEnabled;
  21952. var _smoothScrollingDuration;
  21953. //Will contain settins for smooth scrolling if enabled.
  21954. var _smoothScrolling;
  21955. //Can be set by any operation/event to force rendering even if the scrollbar didn't move.
  21956. var _forceRender;
  21957. //Each skrollable gets an unique ID incremented for each skrollable.
  21958. //The ID is the index in the _skrollables array.
  21959. var _skrollableIdCounter = 0;
  21960. var _edgeStrategy;
  21961. //Mobile specific vars. Will be stripped by UglifyJS when not in use.
  21962. var _isMobile = false;
  21963. //The virtual scroll offset when using mobile scrolling.
  21964. var _mobileOffset = 0;
  21965. //If the browser supports 3d transforms, this will be filled with 'translateZ(0)' (empty string otherwise).
  21966. var _translateZ;
  21967. //Will contain data about registered events by skrollr.
  21968. var _registeredEvents = [];
  21969. //Animation frame id returned by RequestAnimationFrame (or timeout when RAF is not supported).
  21970. var _animFrame;
  21971. //Expose skrollr as either a global variable or a require.js module.
  21972. if(typeof define === 'function' && define.amd) {
  21973. define([], function () {
  21974. return skrollr;
  21975. });
  21976. } else if (typeof module !== 'undefined' && module.exports) {
  21977. module.exports = skrollr;
  21978. } else {
  21979. window.skrollr = skrollr;
  21980. }
  21981. }(window, document));
  21982. /*!
  21983. jQuery Smooth Scroll
  21984. Version: 2.2.0
  21985. Plugin URL: https://github.com/kswedberg/jquery-smooth-scroll
  21986. License: Copyright (c) 2017 Karl Swedberg | Licensed under MIT
  21987. !*/
  21988. (function(factory) {
  21989. if (typeof define === 'function' && define.amd) {
  21990. // AMD. Register as an anonymous module.
  21991. define(['jquery'], factory);
  21992. } else if (typeof module === 'object' && module.exports) {
  21993. // CommonJS
  21994. factory(require('jquery'));
  21995. } else {
  21996. // Browser globals
  21997. factory(jQuery);
  21998. }
  21999. }(function($) {
  22000. var version = '2.2.0';
  22001. var optionOverrides = {};
  22002. var defaults = {
  22003. exclude: [],
  22004. excludeWithin: [],
  22005. offset: 0,
  22006. // one of 'top' or 'left'
  22007. direction: 'top',
  22008. // if set, bind click events through delegation
  22009. // supported since jQuery 1.4.2
  22010. delegateSelector: null,
  22011. // jQuery set of elements you wish to scroll (for $.smoothScroll).
  22012. // if null (default), $('html, body').firstScrollable() is used.
  22013. scrollElement: null,
  22014. // only use if you want to override default behavior
  22015. scrollTarget: null,
  22016. // automatically focus the target element after scrolling to it
  22017. autoFocus: false,
  22018. // fn(opts) function to be called before scrolling occurs.
  22019. // `this` is the element(s) being scrolled
  22020. beforeScroll: function() {},
  22021. // fn(opts) function to be called after scrolling occurs.
  22022. // `this` is the triggering element
  22023. afterScroll: function() {},
  22024. // easing name. jQuery comes with "swing" and "linear." For others, you'll need an easing plugin
  22025. // from jQuery UI or elsewhere
  22026. easing: 'swing',
  22027. // speed can be a number or 'auto'
  22028. // if 'auto', the speed will be calculated based on the formula:
  22029. // (current scroll position - target scroll position) / autoCoeffic
  22030. speed: 400,
  22031. // coefficient for "auto" speed
  22032. autoCoefficient: 2,
  22033. // $.fn.smoothScroll only: whether to prevent the default click action
  22034. preventDefault: true
  22035. };
  22036. var getScrollable = function(opts) {
  22037. var scrollable = [];
  22038. var scrolled = false;
  22039. var dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
  22040. this.each(function() {
  22041. var el = $(this);
  22042. if (this === document || this === window) {
  22043. return;
  22044. }
  22045. if (document.scrollingElement && (this === document.documentElement || this === document.body)) {
  22046. scrollable.push(document.scrollingElement);
  22047. return false;
  22048. }
  22049. if (el[dir]() > 0) {
  22050. scrollable.push(this);
  22051. } else {
  22052. // if scroll(Top|Left) === 0, nudge the element 1px and see if it moves
  22053. el[dir](1);
  22054. scrolled = el[dir]() > 0;
  22055. if (scrolled) {
  22056. scrollable.push(this);
  22057. }
  22058. // then put it back, of course
  22059. el[dir](0);
  22060. }
  22061. });
  22062. if (!scrollable.length) {
  22063. this.each(function() {
  22064. // If no scrollable elements and <html> has scroll-behavior:smooth because
  22065. // "When this property is specified on the root element, it applies to the viewport instead."
  22066. // and "The scroll-behavior property of the … body element is *not* propagated to the viewport."
  22067. // → https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior
  22068. if (this === document.documentElement && $(this).css('scrollBehavior') === 'smooth') {
  22069. scrollable = [this];
  22070. }
  22071. // If still no scrollable elements, fall back to <body>,
  22072. // if it's in the jQuery collection
  22073. // (doing this because Safari sets scrollTop async,
  22074. // so can't set it to 1 and immediately get the value.)
  22075. if (!scrollable.length && this.nodeName === 'BODY') {
  22076. scrollable = [this];
  22077. }
  22078. });
  22079. }
  22080. // Use the first scrollable element if we're calling firstScrollable()
  22081. if (opts.el === 'first' && scrollable.length > 1) {
  22082. scrollable = [scrollable[0]];
  22083. }
  22084. return scrollable;
  22085. };
  22086. var rRelative = /^([\-\+]=)(\d+)/;
  22087. $.fn.extend({
  22088. scrollable: function(dir) {
  22089. var scrl = getScrollable.call(this, {dir: dir});
  22090. return this.pushStack(scrl);
  22091. },
  22092. firstScrollable: function(dir) {
  22093. var scrl = getScrollable.call(this, {el: 'first', dir: dir});
  22094. return this.pushStack(scrl);
  22095. },
  22096. smoothScroll: function(options, extra) {
  22097. options = options || {};
  22098. if (options === 'options') {
  22099. if (!extra) {
  22100. return this.first().data('ssOpts');
  22101. }
  22102. return this.each(function() {
  22103. var $this = $(this);
  22104. var opts = $.extend($this.data('ssOpts') || {}, extra);
  22105. $(this).data('ssOpts', opts);
  22106. });
  22107. }
  22108. var opts = $.extend({}, $.fn.smoothScroll.defaults, options);
  22109. var clickHandler = function(event) {
  22110. var escapeSelector = function(str) {
  22111. return str.replace(/(:|\.|\/)/g, '\\$1');
  22112. };
  22113. var link = this;
  22114. var $link = $(this);
  22115. var thisOpts = $.extend({}, opts, $link.data('ssOpts') || {});
  22116. var exclude = opts.exclude;
  22117. var excludeWithin = thisOpts.excludeWithin;
  22118. var elCounter = 0;
  22119. var ewlCounter = 0;
  22120. var include = true;
  22121. var clickOpts = {};
  22122. var locationPath = $.smoothScroll.filterPath(location.pathname);
  22123. var linkPath = $.smoothScroll.filterPath(link.pathname);
  22124. var hostMatch = location.hostname === link.hostname || !link.hostname;
  22125. var pathMatch = thisOpts.scrollTarget || (linkPath === locationPath);
  22126. var thisHash = escapeSelector(link.hash);
  22127. if (thisHash && !$(thisHash).length) {
  22128. include = false;
  22129. }
  22130. if (!thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash)) {
  22131. include = false;
  22132. } else {
  22133. while (include && elCounter < exclude.length) {
  22134. if ($link.is(escapeSelector(exclude[elCounter++]))) {
  22135. include = false;
  22136. }
  22137. }
  22138. while (include && ewlCounter < excludeWithin.length) {
  22139. if ($link.closest(excludeWithin[ewlCounter++]).length) {
  22140. include = false;
  22141. }
  22142. }
  22143. }
  22144. if (include) {
  22145. if (thisOpts.preventDefault) {
  22146. event.preventDefault();
  22147. }
  22148. $.extend(clickOpts, thisOpts, {
  22149. scrollTarget: thisOpts.scrollTarget || thisHash,
  22150. link: link
  22151. });
  22152. $.smoothScroll(clickOpts);
  22153. }
  22154. };
  22155. if (options.delegateSelector !== null) {
  22156. this
  22157. .off('click.smoothscroll', options.delegateSelector)
  22158. .on('click.smoothscroll', options.delegateSelector, clickHandler);
  22159. } else {
  22160. this
  22161. .off('click.smoothscroll')
  22162. .on('click.smoothscroll', clickHandler);
  22163. }
  22164. return this;
  22165. }
  22166. });
  22167. var getExplicitOffset = function(val) {
  22168. var explicit = {relative: ''};
  22169. var parts = typeof val === 'string' && rRelative.exec(val);
  22170. if (typeof val === 'number') {
  22171. explicit.px = val;
  22172. } else if (parts) {
  22173. explicit.relative = parts[1];
  22174. explicit.px = parseFloat(parts[2]) || 0;
  22175. }
  22176. return explicit;
  22177. };
  22178. var onAfterScroll = function(opts) {
  22179. var $tgt = $(opts.scrollTarget);
  22180. if (opts.autoFocus && $tgt.length) {
  22181. $tgt[0].focus();
  22182. if (!$tgt.is(document.activeElement)) {
  22183. $tgt.prop({tabIndex: -1});
  22184. $tgt[0].focus();
  22185. }
  22186. }
  22187. opts.afterScroll.call(opts.link, opts);
  22188. };
  22189. $.smoothScroll = function(options, px) {
  22190. if (options === 'options' && typeof px === 'object') {
  22191. return $.extend(optionOverrides, px);
  22192. }
  22193. var opts, $scroller, speed, delta;
  22194. var explicitOffset = getExplicitOffset(options);
  22195. var scrollTargetOffset = {};
  22196. var scrollerOffset = 0;
  22197. var offPos = 'offset';
  22198. var scrollDir = 'scrollTop';
  22199. var aniProps = {};
  22200. var aniOpts = {};
  22201. if (explicitOffset.px) {
  22202. opts = $.extend({link: null}, $.fn.smoothScroll.defaults, optionOverrides);
  22203. } else {
  22204. opts = $.extend({link: null}, $.fn.smoothScroll.defaults, options || {}, optionOverrides);
  22205. if (opts.scrollElement) {
  22206. offPos = 'position';
  22207. if (opts.scrollElement.css('position') === 'static') {
  22208. opts.scrollElement.css('position', 'relative');
  22209. }
  22210. }
  22211. if (px) {
  22212. explicitOffset = getExplicitOffset(px);
  22213. }
  22214. }
  22215. scrollDir = opts.direction === 'left' ? 'scrollLeft' : scrollDir;
  22216. if (opts.scrollElement) {
  22217. $scroller = opts.scrollElement;
  22218. if (!explicitOffset.px && !(/^(?:HTML|BODY)$/).test($scroller[0].nodeName)) {
  22219. scrollerOffset = $scroller[scrollDir]();
  22220. }
  22221. } else {
  22222. $scroller = $('html, body').firstScrollable(opts.direction);
  22223. }
  22224. // beforeScroll callback function must fire before calculating offset
  22225. opts.beforeScroll.call($scroller, opts);
  22226. scrollTargetOffset = explicitOffset.px ? explicitOffset : {
  22227. relative: '',
  22228. px: ($(opts.scrollTarget)[offPos]() && $(opts.scrollTarget)[offPos]()[opts.direction]) || 0
  22229. };
  22230. aniProps[scrollDir] = scrollTargetOffset.relative + (scrollTargetOffset.px + scrollerOffset + opts.offset);
  22231. speed = opts.speed;
  22232. // automatically calculate the speed of the scroll based on distance / coefficient
  22233. if (speed === 'auto') {
  22234. // $scroller[scrollDir]() is position before scroll, aniProps[scrollDir] is position after
  22235. // When delta is greater, speed will be greater.
  22236. delta = Math.abs(aniProps[scrollDir] - $scroller[scrollDir]());
  22237. // Divide the delta by the coefficient
  22238. speed = delta / opts.autoCoefficient;
  22239. }
  22240. aniOpts = {
  22241. duration: speed,
  22242. easing: opts.easing,
  22243. complete: function() {
  22244. onAfterScroll(opts);
  22245. }
  22246. };
  22247. if (opts.step) {
  22248. aniOpts.step = opts.step;
  22249. }
  22250. if ($scroller.length) {
  22251. $scroller.stop().animate(aniProps, aniOpts);
  22252. } else {
  22253. onAfterScroll(opts);
  22254. }
  22255. };
  22256. $.smoothScroll.version = version;
  22257. $.smoothScroll.filterPath = function(string) {
  22258. string = string || '';
  22259. return string
  22260. .replace(/^\//, '')
  22261. .replace(/(?:index|default).[a-zA-Z]{3,4}$/, '')
  22262. .replace(/\/$/, '');
  22263. };
  22264. // default options
  22265. $.fn.smoothScroll.defaults = defaults;
  22266. }));
  22267. /*!
  22268. Splitting
  22269. Version: 1.0.5
  22270. Plugin URL: https://splitting.js.org/
  22271. License: Copyright © 2018-present Stephen Shaw | Licensed under the MIT license
  22272. !*/
  22273. (function (global, factory) {
  22274. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  22275. typeof define === 'function' && define.amd ? define(factory) :
  22276. (global.Splitting = factory());
  22277. }(this, (function () { 'use strict';
  22278. var root = document;
  22279. var createText = root.createTextNode.bind(root);
  22280. /**
  22281. * # setProperty
  22282. * Apply a CSS var
  22283. * @param {HTMLElement} el
  22284. * @param {string} varName
  22285. * @param {string|number} value
  22286. */
  22287. function setProperty(el, varName, value) {
  22288. el.style.setProperty(varName, value);
  22289. }
  22290. /**
  22291. *
  22292. * @param {!HTMLElement} el
  22293. * @param {!HTMLElement} child
  22294. */
  22295. function appendChild(el, child) {
  22296. return el.appendChild(child);
  22297. }
  22298. /**
  22299. *
  22300. * @param {!HTMLElement} parent
  22301. * @param {string} key
  22302. * @param {string} text
  22303. * @param {boolean} whitespace
  22304. */
  22305. function createElement(parent, key, text, whitespace) {
  22306. var el = root.createElement('span');
  22307. key && (el.className = key);
  22308. if (text) {
  22309. !whitespace && el.setAttribute("data-" + key, text);
  22310. el.textContent = text;
  22311. }
  22312. return (parent && appendChild(parent, el)) || el;
  22313. }
  22314. /**
  22315. *
  22316. * @param {!HTMLElement} el
  22317. * @param {string} key
  22318. */
  22319. function getData(el, key) {
  22320. return el.getAttribute("data-" + key)
  22321. }
  22322. /**
  22323. *
  22324. * @param {import('../types').Target} e
  22325. * @param {!HTMLElement} parent
  22326. * @returns {!Array<!HTMLElement>}
  22327. */
  22328. function $(e, parent) {
  22329. return !e || e.length == 0
  22330. ? // null or empty string returns empty array
  22331. []
  22332. : e.nodeName
  22333. ? // a single element is wrapped in an array
  22334. [e]
  22335. : // selector and NodeList are converted to Element[]
  22336. [].slice.call(e[0].nodeName ? e : (parent || root).querySelectorAll(e));
  22337. }
  22338. /**
  22339. * Creates and fills an array with the value provided
  22340. * @param {number} len
  22341. * @param {() => T} valueProvider
  22342. * @return {T}
  22343. * @template T
  22344. */
  22345. function Array2D(len) {
  22346. var a = [];
  22347. for (; len--; ) {
  22348. a[len] = [];
  22349. }
  22350. return a;
  22351. }
  22352. /**
  22353. * A for loop wrapper used to reduce js minified size.
  22354. * @param {!Array<T>} items
  22355. * @param {function(T):void} consumer
  22356. * @template T
  22357. */
  22358. function each(items, consumer) {
  22359. items && items.some(consumer);
  22360. }
  22361. /**
  22362. * @param {T} obj
  22363. * @return {function(string):*}
  22364. * @template T
  22365. */
  22366. function selectFrom(obj) {
  22367. return function (key) {
  22368. return obj[key];
  22369. }
  22370. }
  22371. /**
  22372. * # Splitting.index
  22373. * Index split elements and add them to a Splitting instance.
  22374. *
  22375. * @param {HTMLElement} element
  22376. * @param {string} key
  22377. * @param {!Array<!HTMLElement> | !Array<!Array<!HTMLElement>>} items
  22378. */
  22379. function index(element, key, items) {
  22380. var prefix = '--' + key;
  22381. var cssVar = prefix + "-index";
  22382. each(items, function (items, i) {
  22383. if (Array.isArray(items)) {
  22384. each(items, function(item) {
  22385. setProperty(item, cssVar, i);
  22386. });
  22387. } else {
  22388. setProperty(items, cssVar, i);
  22389. }
  22390. });
  22391. setProperty(element, prefix + "-total", items.length);
  22392. }
  22393. /**
  22394. * @type {Record<string, import('./types').ISplittingPlugin>}
  22395. */
  22396. var plugins = {};
  22397. /**
  22398. * @param {string} by
  22399. * @param {string} parent
  22400. * @param {!Array<string>} deps
  22401. * @return {!Array<string>}
  22402. */
  22403. function resolvePlugins(by, parent, deps) {
  22404. // skip if already visited this dependency
  22405. var index = deps.indexOf(by);
  22406. if (index == -1) {
  22407. // if new to dependency array, add to the beginning
  22408. deps.unshift(by);
  22409. // recursively call this function for all dependencies
  22410. var plugin = plugins[by];
  22411. if (!plugin) {
  22412. throw new Error("plugin not loaded: " + by);
  22413. }
  22414. each(plugin.depends, function(p) {
  22415. resolvePlugins(p, by, deps);
  22416. });
  22417. } else {
  22418. // if this dependency was added already move to the left of
  22419. // the parent dependency so it gets loaded in order
  22420. var indexOfParent = deps.indexOf(parent);
  22421. deps.splice(index, 1);
  22422. deps.splice(indexOfParent, 0, by);
  22423. }
  22424. return deps;
  22425. }
  22426. /**
  22427. * Internal utility for creating plugins... essentially to reduce
  22428. * the size of the library
  22429. * @param {string} by
  22430. * @param {string} key
  22431. * @param {string[]} depends
  22432. * @param {Function} split
  22433. * @returns {import('./types').ISplittingPlugin}
  22434. */
  22435. function createPlugin(by, depends, key, split) {
  22436. return {
  22437. by: by,
  22438. depends: depends,
  22439. key: key,
  22440. split: split
  22441. }
  22442. }
  22443. /**
  22444. *
  22445. * @param {string} by
  22446. * @returns {import('./types').ISplittingPlugin[]}
  22447. */
  22448. function resolve(by) {
  22449. return resolvePlugins(by, 0, []).map(selectFrom(plugins));
  22450. }
  22451. /**
  22452. * Adds a new plugin to splitting
  22453. * @param {import('./types').ISplittingPlugin} opts
  22454. */
  22455. function add(opts) {
  22456. plugins[opts.by] = opts;
  22457. }
  22458. /**
  22459. * # Splitting.split
  22460. * Split an element's textContent into individual elements
  22461. * @param {!HTMLElement} el Element to split
  22462. * @param {string} key
  22463. * @param {string} splitOn
  22464. * @param {boolean} includePrevious
  22465. * @param {boolean} preserveWhitespace
  22466. * @return {!Array<!HTMLElement>}
  22467. */
  22468. function splitText(el, key, splitOn, includePrevious, preserveWhitespace) {
  22469. // Combine any strange text nodes or empty whitespace.
  22470. el.normalize();
  22471. // Use fragment to prevent unnecessary DOM thrashing.
  22472. var elements = [];
  22473. var F = document.createDocumentFragment();
  22474. if (includePrevious) {
  22475. elements.push(el.previousSibling);
  22476. }
  22477. var allElements = [];
  22478. $(el.childNodes).some(function(next) {
  22479. if (next.tagName && !next.hasChildNodes()) {
  22480. // keep elements without child nodes (no text and no children)
  22481. allElements.push(next);
  22482. return;
  22483. }
  22484. // Recursively run through child nodes
  22485. if (next.childNodes && next.childNodes.length) {
  22486. allElements.push(next);
  22487. elements.push.apply(elements, splitText(next, key, splitOn, includePrevious, preserveWhitespace));
  22488. return;
  22489. }
  22490. // Get the text to split, trimming out the whitespace
  22491. /** @type {string} */
  22492. var wholeText = next.wholeText || '';
  22493. var contents = wholeText.trim();
  22494. // If there's no text left after trimming whitespace, continue the loop
  22495. if (contents.length) {
  22496. // insert leading space if there was one
  22497. if (wholeText[0] === ' ') {
  22498. allElements.push(createText(' '));
  22499. }
  22500. // Concatenate the split text children back into the full array
  22501. each(contents.split(splitOn), function(splitText, i) {
  22502. if (i && preserveWhitespace) {
  22503. allElements.push(createElement(F, "whitespace", " ", preserveWhitespace));
  22504. }
  22505. var splitEl = createElement(F, key, splitText);
  22506. elements.push(splitEl);
  22507. allElements.push(splitEl);
  22508. });
  22509. // insert trailing space if there was one
  22510. if (wholeText[wholeText.length - 1] === ' ') {
  22511. allElements.push(createText(' '));
  22512. }
  22513. }
  22514. });
  22515. each(allElements, function(el) {
  22516. appendChild(F, el);
  22517. });
  22518. // Clear out the existing element
  22519. el.innerHTML = "";
  22520. appendChild(el, F);
  22521. return elements;
  22522. }
  22523. /** an empty value */
  22524. var _ = 0;
  22525. function copy(dest, src) {
  22526. for (var k in src) {
  22527. dest[k] = src[k];
  22528. }
  22529. return dest;
  22530. }
  22531. var WORDS = 'words';
  22532. var wordPlugin = createPlugin(
  22533. /* by= */ WORDS,
  22534. /* depends= */ _,
  22535. /* key= */ 'word',
  22536. /* split= */ function(el) {
  22537. return splitText(el, 'word', /\s+/, 0, 1)
  22538. }
  22539. );
  22540. var CHARS = "chars";
  22541. var charPlugin = createPlugin(
  22542. /* by= */ CHARS,
  22543. /* depends= */ [WORDS],
  22544. /* key= */ "char",
  22545. /* split= */ function(el, options, ctx) {
  22546. var results = [];
  22547. each(ctx[WORDS], function(word, i) {
  22548. results.push.apply(results, splitText(word, "char", "", options.whitespace && i));
  22549. });
  22550. return results;
  22551. }
  22552. );
  22553. /**
  22554. * # Splitting
  22555. *
  22556. * @param {import('./types').ISplittingOptions} opts
  22557. * @return {!Array<*>}
  22558. */
  22559. function Splitting (opts) {
  22560. opts = opts || {};
  22561. var key = opts.key;
  22562. return $(opts.target || '[data-splitting]').map(function(el) {
  22563. var ctx = el['🍌'];
  22564. if (!opts.force && ctx) {
  22565. return ctx;
  22566. }
  22567. ctx = el['🍌'] = { el: el };
  22568. var by = opts.by || getData(el, 'splitting');
  22569. if (!by || by == 'true') {
  22570. by = CHARS;
  22571. }
  22572. var items = resolve(by);
  22573. var opts2 = copy({}, opts);
  22574. each(items, function(plugin) {
  22575. if (plugin.split) {
  22576. var pluginBy = plugin.by;
  22577. var key2 = (key ? '-' + key : '') + plugin.key;
  22578. var results = plugin.split(el, opts2, ctx);
  22579. key2 && index(el, key2, results);
  22580. ctx[pluginBy] = results;
  22581. el.classList.add(pluginBy);
  22582. }
  22583. });
  22584. el.classList.add('splitting');
  22585. return ctx;
  22586. })
  22587. }
  22588. /**
  22589. * # Splitting.html
  22590. *
  22591. * @param {import('./types').ISplittingOptions} opts
  22592. */
  22593. function html(opts) {
  22594. opts = opts || {};
  22595. var parent = opts.target = createElement();
  22596. parent.innerHTML = opts.content;
  22597. Splitting(opts);
  22598. return parent.outerHTML
  22599. }
  22600. Splitting.html = html;
  22601. Splitting.add = add;
  22602. /**
  22603. * Detects the grid by measuring which elements align to a side of it.
  22604. * @param {!HTMLElement} el
  22605. * @param {import('../core/types').ISplittingOptions} options
  22606. * @param {*} side
  22607. */
  22608. function detectGrid(el, options, side) {
  22609. var items = $(options.matching || el.children, el);
  22610. var c = {};
  22611. each(items, function(w) {
  22612. var val = Math.round(w[side]);
  22613. (c[val] || (c[val] = [])).push(w);
  22614. });
  22615. return Object.keys(c).map(Number).sort(byNumber).map(selectFrom(c));
  22616. }
  22617. /**
  22618. * Sorting function for numbers.
  22619. * @param {number} a
  22620. * @param {number} b
  22621. * @return {number}
  22622. */
  22623. function byNumber(a, b) {
  22624. return a - b;
  22625. }
  22626. var linePlugin = createPlugin(
  22627. /* by= */ 'lines',
  22628. /* depends= */ [WORDS],
  22629. /* key= */ 'line',
  22630. /* split= */ function(el, options, ctx) {
  22631. return detectGrid(el, { matching: ctx[WORDS] }, 'offsetTop')
  22632. }
  22633. );
  22634. var itemPlugin = createPlugin(
  22635. /* by= */ 'items',
  22636. /* depends= */ _,
  22637. /* key= */ 'item',
  22638. /* split= */ function(el, options) {
  22639. return $(options.matching || el.children, el)
  22640. }
  22641. );
  22642. var rowPlugin = createPlugin(
  22643. /* by= */ 'rows',
  22644. /* depends= */ _,
  22645. /* key= */ 'row',
  22646. /* split= */ function(el, options) {
  22647. return detectGrid(el, options, "offsetTop");
  22648. }
  22649. );
  22650. var columnPlugin = createPlugin(
  22651. /* by= */ 'cols',
  22652. /* depends= */ _,
  22653. /* key= */ "col",
  22654. /* split= */ function(el, options) {
  22655. return detectGrid(el, options, "offsetLeft");
  22656. }
  22657. );
  22658. var gridPlugin = createPlugin(
  22659. /* by= */ 'grid',
  22660. /* depends= */ ['rows', 'cols']
  22661. );
  22662. var LAYOUT = "layout";
  22663. var layoutPlugin = createPlugin(
  22664. /* by= */ LAYOUT,
  22665. /* depends= */ _,
  22666. /* key= */ _,
  22667. /* split= */ function(el, opts) {
  22668. // detect and set options
  22669. var rows = opts.rows = +(opts.rows || getData(el, 'rows') || 1);
  22670. var columns = opts.columns = +(opts.columns || getData(el, 'columns') || 1);
  22671. // Seek out the first <img> if the value is true
  22672. opts.image = opts.image || getData(el, 'image') || el.currentSrc || el.src;
  22673. if (opts.image) {
  22674. var img = $("img", el)[0];
  22675. opts.image = img && (img.currentSrc || img.src);
  22676. }
  22677. // add optional image to background
  22678. if (opts.image) {
  22679. setProperty(el, "background-image", "url(" + opts.image + ")");
  22680. }
  22681. var totalCells = rows * columns;
  22682. var elements = [];
  22683. var container = createElement(_, "cell-grid");
  22684. while (totalCells--) {
  22685. // Create a span
  22686. var cell = createElement(container, "cell");
  22687. createElement(cell, "cell-inner");
  22688. elements.push(cell);
  22689. }
  22690. // Append elements back into the parent
  22691. appendChild(el, container);
  22692. return elements;
  22693. }
  22694. );
  22695. var cellRowPlugin = createPlugin(
  22696. /* by= */ "cellRows",
  22697. /* depends= */ [LAYOUT],
  22698. /* key= */ "row",
  22699. /* split= */ function(el, opts, ctx) {
  22700. var rowCount = opts.rows;
  22701. var result = Array2D(rowCount);
  22702. each(ctx[LAYOUT], function(cell, i, src) {
  22703. result[Math.floor(i / (src.length / rowCount))].push(cell);
  22704. });
  22705. return result;
  22706. }
  22707. );
  22708. var cellColumnPlugin = createPlugin(
  22709. /* by= */ "cellColumns",
  22710. /* depends= */ [LAYOUT],
  22711. /* key= */ "col",
  22712. /* split= */ function(el, opts, ctx) {
  22713. var columnCount = opts.columns;
  22714. var result = Array2D(columnCount);
  22715. each(ctx[LAYOUT], function(cell, i) {
  22716. result[i % columnCount].push(cell);
  22717. });
  22718. return result;
  22719. }
  22720. );
  22721. var cellPlugin = createPlugin(
  22722. /* by= */ "cells",
  22723. /* depends= */ ['cellRows', 'cellColumns'],
  22724. /* key= */ "cell",
  22725. /* split= */ function(el, opt, ctx) {
  22726. // re-index the layout as the cells
  22727. return ctx[LAYOUT];
  22728. }
  22729. );
  22730. // install plugins
  22731. // word/char plugins
  22732. add(wordPlugin);
  22733. add(charPlugin);
  22734. add(linePlugin);
  22735. // grid plugins
  22736. add(itemPlugin);
  22737. add(rowPlugin);
  22738. add(columnPlugin);
  22739. add(gridPlugin);
  22740. // cell-layout plugins
  22741. add(layoutPlugin);
  22742. add(cellRowPlugin);
  22743. add(cellColumnPlugin);
  22744. add(cellPlugin);
  22745. return Splitting;
  22746. })));
  22747. /*!
  22748. Sticky-kit
  22749. Version: 1.1.3
  22750. Plugin URL: https://github.com/leafo/sticky-kit
  22751. License: Leaf Corcoran 2015 | Licensed under MIT
  22752. !*/
  22753. (function() {
  22754. var $, win;
  22755. $ = window.jQuery;
  22756. win = $(window);
  22757. $.fn.stick_in_parent = function(opts) {
  22758. var doc, elm, enable_bottoming, fn, i, inner_scrolling, len, manual_spacer, offset_top, outer_width, parent_selector, recalc_every, sticky_class;
  22759. if (opts == null) {
  22760. opts = {};
  22761. }
  22762. sticky_class = opts.sticky_class, inner_scrolling = opts.inner_scrolling, recalc_every = opts.recalc_every, parent_selector = opts.parent, offset_top = opts.offset_top, manual_spacer = opts.spacer, enable_bottoming = opts.bottoming;
  22763. if (offset_top == null) {
  22764. offset_top = 0;
  22765. }
  22766. if (parent_selector == null) {
  22767. parent_selector = void 0;
  22768. }
  22769. if (inner_scrolling == null) {
  22770. inner_scrolling = true;
  22771. }
  22772. if (sticky_class == null) {
  22773. sticky_class = "is_stuck";
  22774. }
  22775. doc = $(document);
  22776. if (enable_bottoming == null) {
  22777. enable_bottoming = true;
  22778. }
  22779. outer_width = function(el) {
  22780. var _el, computed, w;
  22781. if (window.getComputedStyle) {
  22782. _el = el[0];
  22783. computed = window.getComputedStyle(el[0]);
  22784. w = parseFloat(computed.getPropertyValue("width")) + parseFloat(computed.getPropertyValue("margin-left")) + parseFloat(computed.getPropertyValue("margin-right"));
  22785. if (computed.getPropertyValue("box-sizing") !== "border-box") {
  22786. w += parseFloat(computed.getPropertyValue("border-left-width")) + parseFloat(computed.getPropertyValue("border-right-width")) + parseFloat(computed.getPropertyValue("padding-left")) + parseFloat(computed.getPropertyValue("padding-right"));
  22787. }
  22788. return w;
  22789. } else {
  22790. return el.outerWidth(true);
  22791. }
  22792. };
  22793. fn = function(elm, padding_bottom, parent_top, parent_height, top, height, el_float, detached) {
  22794. var bottomed, detach, fixed, last_pos, last_scroll_height, offset, parent, recalc, recalc_and_tick, recalc_counter, spacer, tick;
  22795. if (elm.data("sticky_kit")) {
  22796. return;
  22797. }
  22798. elm.data("sticky_kit", true);
  22799. last_scroll_height = doc.height();
  22800. parent = elm.parent();
  22801. if (parent_selector != null) {
  22802. parent = parent.closest(parent_selector);
  22803. }
  22804. if (!parent.length) {
  22805. throw "failed to find stick parent";
  22806. }
  22807. fixed = false;
  22808. bottomed = false;
  22809. spacer = manual_spacer != null ? manual_spacer && elm.closest(manual_spacer) : $("<div />");
  22810. if (spacer) {
  22811. spacer.css('position', elm.css('position'));
  22812. }
  22813. recalc = function() {
  22814. var border_top, padding_top, restore;
  22815. if (detached) {
  22816. return;
  22817. }
  22818. last_scroll_height = doc.height();
  22819. border_top = parseInt(parent.css("border-top-width"), 10);
  22820. padding_top = parseInt(parent.css("padding-top"), 10);
  22821. padding_bottom = parseInt(parent.css("padding-bottom"), 10);
  22822. parent_top = parent.offset().top + border_top + padding_top;
  22823. parent_height = parent.height();
  22824. if (fixed) {
  22825. fixed = false;
  22826. bottomed = false;
  22827. if (manual_spacer == null) {
  22828. elm.insertAfter(spacer);
  22829. spacer.detach();
  22830. }
  22831. elm.css({
  22832. position: "",
  22833. top: "",
  22834. width: "",
  22835. bottom: ""
  22836. }).removeClass(sticky_class);
  22837. restore = true;
  22838. }
  22839. top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) || 0) - offset_top;
  22840. height = elm.outerHeight(true);
  22841. el_float = elm.css("float");
  22842. if (spacer) {
  22843. spacer.css({
  22844. width: outer_width(elm),
  22845. height: height,
  22846. display: elm.css("display"),
  22847. "vertical-align": elm.css("vertical-align"),
  22848. "float": el_float
  22849. });
  22850. }
  22851. if (restore) {
  22852. return tick();
  22853. }
  22854. };
  22855. recalc();
  22856. if (height === parent_height) {
  22857. return;
  22858. }
  22859. last_pos = void 0;
  22860. offset = offset_top;
  22861. recalc_counter = recalc_every;
  22862. tick = function() {
  22863. var css, delta, recalced, scroll, will_bottom, win_height;
  22864. if (detached) {
  22865. return;
  22866. }
  22867. recalced = false;
  22868. if (recalc_counter != null) {
  22869. recalc_counter -= 1;
  22870. if (recalc_counter <= 0) {
  22871. recalc_counter = recalc_every;
  22872. recalc();
  22873. recalced = true;
  22874. }
  22875. }
  22876. if (!recalced && doc.height() !== last_scroll_height) {
  22877. recalc();
  22878. recalced = true;
  22879. }
  22880. scroll = win.scrollTop();
  22881. if (last_pos != null) {
  22882. delta = scroll - last_pos;
  22883. }
  22884. last_pos = scroll;
  22885. if (fixed) {
  22886. if (enable_bottoming) {
  22887. will_bottom = scroll + height + offset > parent_height + parent_top;
  22888. if (bottomed && !will_bottom) {
  22889. bottomed = false;
  22890. elm.css({
  22891. position: "fixed",
  22892. bottom: "",
  22893. top: offset
  22894. }).trigger("sticky_kit:unbottom");
  22895. }
  22896. }
  22897. if (scroll < top) {
  22898. fixed = false;
  22899. offset = offset_top;
  22900. if (manual_spacer == null) {
  22901. if (el_float === "left" || el_float === "right") {
  22902. elm.insertAfter(spacer);
  22903. }
  22904. spacer.detach();
  22905. }
  22906. css = {
  22907. position: "",
  22908. width: "",
  22909. top: ""
  22910. };
  22911. elm.css(css).removeClass(sticky_class).trigger("sticky_kit:unstick");
  22912. }
  22913. if (inner_scrolling) {
  22914. win_height = win.height();
  22915. if (height + offset_top > win_height) {
  22916. if (!bottomed) {
  22917. offset -= delta;
  22918. offset = Math.max(win_height - height, offset);
  22919. offset = Math.min(offset_top, offset);
  22920. if (fixed) {
  22921. elm.css({
  22922. top: offset + "px"
  22923. });
  22924. }
  22925. }
  22926. }
  22927. }
  22928. } else {
  22929. if (scroll > top) {
  22930. fixed = true;
  22931. css = {
  22932. position: "fixed",
  22933. top: offset
  22934. };
  22935. css.width = elm.css("box-sizing") === "border-box" ? elm.outerWidth() + "px" : elm.width() + "px";
  22936. elm.css(css).addClass(sticky_class);
  22937. if (manual_spacer == null) {
  22938. elm.after(spacer);
  22939. if (el_float === "left" || el_float === "right") {
  22940. spacer.append(elm);
  22941. }
  22942. }
  22943. elm.trigger("sticky_kit:stick");
  22944. }
  22945. }
  22946. if (fixed && enable_bottoming) {
  22947. if (will_bottom == null) {
  22948. will_bottom = scroll + height + offset > parent_height + parent_top;
  22949. }
  22950. if (!bottomed && will_bottom) {
  22951. bottomed = true;
  22952. if (parent.css("position") === "static") {
  22953. parent.css({
  22954. position: "relative"
  22955. });
  22956. }
  22957. return elm.css({
  22958. position: "absolute",
  22959. bottom: padding_bottom,
  22960. top: "auto"
  22961. }).trigger("sticky_kit:bottom");
  22962. }
  22963. }
  22964. };
  22965. recalc_and_tick = function() {
  22966. recalc();
  22967. return tick();
  22968. };
  22969. detach = function() {
  22970. detached = true;
  22971. win.off("touchmove", tick);
  22972. win.off("scroll", tick);
  22973. win.off("resize", recalc_and_tick);
  22974. $(document.body).off("sticky_kit:recalc", recalc_and_tick);
  22975. elm.off("sticky_kit:detach", detach);
  22976. elm.removeData("sticky_kit");
  22977. elm.css({
  22978. position: "",
  22979. bottom: "",
  22980. top: "",
  22981. width: ""
  22982. });
  22983. parent.position("position", "");
  22984. if (fixed) {
  22985. if (manual_spacer == null) {
  22986. if (el_float === "left" || el_float === "right") {
  22987. elm.insertAfter(spacer);
  22988. }
  22989. spacer.remove();
  22990. }
  22991. return elm.removeClass(sticky_class);
  22992. }
  22993. };
  22994. win.on("touchmove", tick);
  22995. win.on("scroll", tick);
  22996. win.on("resize", recalc_and_tick);
  22997. $(document.body).on("sticky_kit:recalc", recalc_and_tick);
  22998. elm.on("sticky_kit:detach", detach);
  22999. return setTimeout(tick, 0);
  23000. };
  23001. for (i = 0, len = this.length; i < len; i++) {
  23002. elm = this[i];
  23003. fn($(elm));
  23004. }
  23005. return this;
  23006. };
  23007. }).call(this);
  23008. /*!
  23009. Swiper
  23010. Version: 11.0.5
  23011. Plugin URL: https://swiperjs.com
  23012. License: Copyright 2014-2023 Vladimir Kharlampidi | Released under the MIT License
  23013. !*/
  23014. var Swiper = (function () {
  23015. 'use strict';
  23016. /**
  23017. * SSR Window 4.0.2
  23018. * Better handling for window object in SSR environment
  23019. * https://github.com/nolimits4web/ssr-window
  23020. *
  23021. * Copyright 2021, Vladimir Kharlampidi
  23022. *
  23023. * Licensed under MIT
  23024. *
  23025. * Released on: December 13, 2021
  23026. */
  23027. /* eslint-disable no-param-reassign */
  23028. function isObject$1(obj) {
  23029. return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object;
  23030. }
  23031. function extend$1(target, src) {
  23032. if (target === void 0) {
  23033. target = {};
  23034. }
  23035. if (src === void 0) {
  23036. src = {};
  23037. }
  23038. Object.keys(src).forEach(key => {
  23039. if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) {
  23040. extend$1(target[key], src[key]);
  23041. }
  23042. });
  23043. }
  23044. const ssrDocument = {
  23045. body: {},
  23046. addEventListener() {},
  23047. removeEventListener() {},
  23048. activeElement: {
  23049. blur() {},
  23050. nodeName: ''
  23051. },
  23052. querySelector() {
  23053. return null;
  23054. },
  23055. querySelectorAll() {
  23056. return [];
  23057. },
  23058. getElementById() {
  23059. return null;
  23060. },
  23061. createEvent() {
  23062. return {
  23063. initEvent() {}
  23064. };
  23065. },
  23066. createElement() {
  23067. return {
  23068. children: [],
  23069. childNodes: [],
  23070. style: {},
  23071. setAttribute() {},
  23072. getElementsByTagName() {
  23073. return [];
  23074. }
  23075. };
  23076. },
  23077. createElementNS() {
  23078. return {};
  23079. },
  23080. importNode() {
  23081. return null;
  23082. },
  23083. location: {
  23084. hash: '',
  23085. host: '',
  23086. hostname: '',
  23087. href: '',
  23088. origin: '',
  23089. pathname: '',
  23090. protocol: '',
  23091. search: ''
  23092. }
  23093. };
  23094. function getDocument() {
  23095. const doc = typeof document !== 'undefined' ? document : {};
  23096. extend$1(doc, ssrDocument);
  23097. return doc;
  23098. }
  23099. const ssrWindow = {
  23100. document: ssrDocument,
  23101. navigator: {
  23102. userAgent: ''
  23103. },
  23104. location: {
  23105. hash: '',
  23106. host: '',
  23107. hostname: '',
  23108. href: '',
  23109. origin: '',
  23110. pathname: '',
  23111. protocol: '',
  23112. search: ''
  23113. },
  23114. history: {
  23115. replaceState() {},
  23116. pushState() {},
  23117. go() {},
  23118. back() {}
  23119. },
  23120. CustomEvent: function CustomEvent() {
  23121. return this;
  23122. },
  23123. addEventListener() {},
  23124. removeEventListener() {},
  23125. getComputedStyle() {
  23126. return {
  23127. getPropertyValue() {
  23128. return '';
  23129. }
  23130. };
  23131. },
  23132. Image() {},
  23133. Date() {},
  23134. screen: {},
  23135. setTimeout() {},
  23136. clearTimeout() {},
  23137. matchMedia() {
  23138. return {};
  23139. },
  23140. requestAnimationFrame(callback) {
  23141. if (typeof setTimeout === 'undefined') {
  23142. callback();
  23143. return null;
  23144. }
  23145. return setTimeout(callback, 0);
  23146. },
  23147. cancelAnimationFrame(id) {
  23148. if (typeof setTimeout === 'undefined') {
  23149. return;
  23150. }
  23151. clearTimeout(id);
  23152. }
  23153. };
  23154. function getWindow() {
  23155. const win = typeof window !== 'undefined' ? window : {};
  23156. extend$1(win, ssrWindow);
  23157. return win;
  23158. }
  23159. function classesToTokens(classes) {
  23160. if (classes === void 0) {
  23161. classes = '';
  23162. }
  23163. return classes.trim().split(' ').filter(c => !!c.trim());
  23164. }
  23165. function deleteProps(obj) {
  23166. const object = obj;
  23167. Object.keys(object).forEach(key => {
  23168. try {
  23169. object[key] = null;
  23170. } catch (e) {
  23171. // no getter for object
  23172. }
  23173. try {
  23174. delete object[key];
  23175. } catch (e) {
  23176. // something got wrong
  23177. }
  23178. });
  23179. }
  23180. function nextTick(callback, delay) {
  23181. if (delay === void 0) {
  23182. delay = 0;
  23183. }
  23184. return setTimeout(callback, delay);
  23185. }
  23186. function now() {
  23187. return Date.now();
  23188. }
  23189. function getComputedStyle$1(el) {
  23190. const window = getWindow();
  23191. let style;
  23192. if (window.getComputedStyle) {
  23193. style = window.getComputedStyle(el, null);
  23194. }
  23195. if (!style && el.currentStyle) {
  23196. style = el.currentStyle;
  23197. }
  23198. if (!style) {
  23199. style = el.style;
  23200. }
  23201. return style;
  23202. }
  23203. function getTranslate(el, axis) {
  23204. if (axis === void 0) {
  23205. axis = 'x';
  23206. }
  23207. const window = getWindow();
  23208. let matrix;
  23209. let curTransform;
  23210. let transformMatrix;
  23211. const curStyle = getComputedStyle$1(el);
  23212. if (window.WebKitCSSMatrix) {
  23213. curTransform = curStyle.transform || curStyle.webkitTransform;
  23214. if (curTransform.split(',').length > 6) {
  23215. curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
  23216. }
  23217. // Some old versions of Webkit choke when 'none' is passed; pass
  23218. // empty string instead in this case
  23219. transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
  23220. } else {
  23221. transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
  23222. matrix = transformMatrix.toString().split(',');
  23223. }
  23224. if (axis === 'x') {
  23225. // Latest Chrome and webkits Fix
  23226. if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
  23227. // Crazy IE10 Matrix
  23228. else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
  23229. // Normal Browsers
  23230. else curTransform = parseFloat(matrix[4]);
  23231. }
  23232. if (axis === 'y') {
  23233. // Latest Chrome and webkits Fix
  23234. if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
  23235. // Crazy IE10 Matrix
  23236. else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
  23237. // Normal Browsers
  23238. else curTransform = parseFloat(matrix[5]);
  23239. }
  23240. return curTransform || 0;
  23241. }
  23242. function isObject(o) {
  23243. return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
  23244. }
  23245. function isNode(node) {
  23246. // eslint-disable-next-line
  23247. if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
  23248. return node instanceof HTMLElement;
  23249. }
  23250. return node && (node.nodeType === 1 || node.nodeType === 11);
  23251. }
  23252. function extend() {
  23253. const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
  23254. const noExtend = ['__proto__', 'constructor', 'prototype'];
  23255. for (let i = 1; i < arguments.length; i += 1) {
  23256. const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
  23257. if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
  23258. const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
  23259. for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
  23260. const nextKey = keysArray[nextIndex];
  23261. const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
  23262. if (desc !== undefined && desc.enumerable) {
  23263. if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
  23264. if (nextSource[nextKey].__swiper__) {
  23265. to[nextKey] = nextSource[nextKey];
  23266. } else {
  23267. extend(to[nextKey], nextSource[nextKey]);
  23268. }
  23269. } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
  23270. to[nextKey] = {};
  23271. if (nextSource[nextKey].__swiper__) {
  23272. to[nextKey] = nextSource[nextKey];
  23273. } else {
  23274. extend(to[nextKey], nextSource[nextKey]);
  23275. }
  23276. } else {
  23277. to[nextKey] = nextSource[nextKey];
  23278. }
  23279. }
  23280. }
  23281. }
  23282. }
  23283. return to;
  23284. }
  23285. function setCSSProperty(el, varName, varValue) {
  23286. el.style.setProperty(varName, varValue);
  23287. }
  23288. function animateCSSModeScroll(_ref) {
  23289. let {
  23290. swiper,
  23291. targetPosition,
  23292. side
  23293. } = _ref;
  23294. const window = getWindow();
  23295. const startPosition = -swiper.translate;
  23296. let startTime = null;
  23297. let time;
  23298. const duration = swiper.params.speed;
  23299. swiper.wrapperEl.style.scrollSnapType = 'none';
  23300. window.cancelAnimationFrame(swiper.cssModeFrameID);
  23301. const dir = targetPosition > startPosition ? 'next' : 'prev';
  23302. const isOutOfBound = (current, target) => {
  23303. return dir === 'next' && current >= target || dir === 'prev' && current <= target;
  23304. };
  23305. const animate = () => {
  23306. time = new Date().getTime();
  23307. if (startTime === null) {
  23308. startTime = time;
  23309. }
  23310. const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
  23311. const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
  23312. let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
  23313. if (isOutOfBound(currentPosition, targetPosition)) {
  23314. currentPosition = targetPosition;
  23315. }
  23316. swiper.wrapperEl.scrollTo({
  23317. [side]: currentPosition
  23318. });
  23319. if (isOutOfBound(currentPosition, targetPosition)) {
  23320. swiper.wrapperEl.style.overflow = 'hidden';
  23321. swiper.wrapperEl.style.scrollSnapType = '';
  23322. setTimeout(() => {
  23323. swiper.wrapperEl.style.overflow = '';
  23324. swiper.wrapperEl.scrollTo({
  23325. [side]: currentPosition
  23326. });
  23327. });
  23328. window.cancelAnimationFrame(swiper.cssModeFrameID);
  23329. return;
  23330. }
  23331. swiper.cssModeFrameID = window.requestAnimationFrame(animate);
  23332. };
  23333. animate();
  23334. }
  23335. function getSlideTransformEl(slideEl) {
  23336. return slideEl.querySelector('.swiper-slide-transform') || slideEl.shadowRoot && slideEl.shadowRoot.querySelector('.swiper-slide-transform') || slideEl;
  23337. }
  23338. function elementChildren(element, selector) {
  23339. if (selector === void 0) {
  23340. selector = '';
  23341. }
  23342. return [...element.children].filter(el => el.matches(selector));
  23343. }
  23344. function showWarning(text) {
  23345. try {
  23346. console.warn(text);
  23347. return;
  23348. } catch (err) {
  23349. // err
  23350. }
  23351. }
  23352. function createElement(tag, classes) {
  23353. if (classes === void 0) {
  23354. classes = [];
  23355. }
  23356. const el = document.createElement(tag);
  23357. el.classList.add(...(Array.isArray(classes) ? classes : classesToTokens(classes)));
  23358. return el;
  23359. }
  23360. function elementOffset(el) {
  23361. const window = getWindow();
  23362. const document = getDocument();
  23363. const box = el.getBoundingClientRect();
  23364. const body = document.body;
  23365. const clientTop = el.clientTop || body.clientTop || 0;
  23366. const clientLeft = el.clientLeft || body.clientLeft || 0;
  23367. const scrollTop = el === window ? window.scrollY : el.scrollTop;
  23368. const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
  23369. return {
  23370. top: box.top + scrollTop - clientTop,
  23371. left: box.left + scrollLeft - clientLeft
  23372. };
  23373. }
  23374. function elementPrevAll(el, selector) {
  23375. const prevEls = [];
  23376. while (el.previousElementSibling) {
  23377. const prev = el.previousElementSibling; // eslint-disable-line
  23378. if (selector) {
  23379. if (prev.matches(selector)) prevEls.push(prev);
  23380. } else prevEls.push(prev);
  23381. el = prev;
  23382. }
  23383. return prevEls;
  23384. }
  23385. function elementNextAll(el, selector) {
  23386. const nextEls = [];
  23387. while (el.nextElementSibling) {
  23388. const next = el.nextElementSibling; // eslint-disable-line
  23389. if (selector) {
  23390. if (next.matches(selector)) nextEls.push(next);
  23391. } else nextEls.push(next);
  23392. el = next;
  23393. }
  23394. return nextEls;
  23395. }
  23396. function elementStyle(el, prop) {
  23397. const window = getWindow();
  23398. return window.getComputedStyle(el, null).getPropertyValue(prop);
  23399. }
  23400. function elementIndex(el) {
  23401. let child = el;
  23402. let i;
  23403. if (child) {
  23404. i = 0;
  23405. // eslint-disable-next-line
  23406. while ((child = child.previousSibling) !== null) {
  23407. if (child.nodeType === 1) i += 1;
  23408. }
  23409. return i;
  23410. }
  23411. return undefined;
  23412. }
  23413. function elementParents(el, selector) {
  23414. const parents = []; // eslint-disable-line
  23415. let parent = el.parentElement; // eslint-disable-line
  23416. while (parent) {
  23417. if (selector) {
  23418. if (parent.matches(selector)) parents.push(parent);
  23419. } else {
  23420. parents.push(parent);
  23421. }
  23422. parent = parent.parentElement;
  23423. }
  23424. return parents;
  23425. }
  23426. function elementTransitionEnd(el, callback) {
  23427. function fireCallBack(e) {
  23428. if (e.target !== el) return;
  23429. callback.call(el, e);
  23430. el.removeEventListener('transitionend', fireCallBack);
  23431. }
  23432. if (callback) {
  23433. el.addEventListener('transitionend', fireCallBack);
  23434. }
  23435. }
  23436. function elementOuterSize(el, size, includeMargins) {
  23437. const window = getWindow();
  23438. if (includeMargins) {
  23439. return el[size === 'width' ? 'offsetWidth' : 'offsetHeight'] + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-right' : 'margin-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-left' : 'margin-bottom'));
  23440. }
  23441. return el.offsetWidth;
  23442. }
  23443. let support;
  23444. function calcSupport() {
  23445. const window = getWindow();
  23446. const document = getDocument();
  23447. return {
  23448. smoothScroll: document.documentElement && document.documentElement.style && 'scrollBehavior' in document.documentElement.style,
  23449. touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
  23450. };
  23451. }
  23452. function getSupport() {
  23453. if (!support) {
  23454. support = calcSupport();
  23455. }
  23456. return support;
  23457. }
  23458. let deviceCached;
  23459. function calcDevice(_temp) {
  23460. let {
  23461. userAgent
  23462. } = _temp === void 0 ? {} : _temp;
  23463. const support = getSupport();
  23464. const window = getWindow();
  23465. const platform = window.navigator.platform;
  23466. const ua = userAgent || window.navigator.userAgent;
  23467. const device = {
  23468. ios: false,
  23469. android: false
  23470. };
  23471. const screenWidth = window.screen.width;
  23472. const screenHeight = window.screen.height;
  23473. const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
  23474. let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  23475. const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  23476. const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
  23477. const windows = platform === 'Win32';
  23478. let macos = platform === 'MacIntel';
  23479. // iPadOs 13 fix
  23480. const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
  23481. if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
  23482. ipad = ua.match(/(Version)\/([\d.]+)/);
  23483. if (!ipad) ipad = [0, 1, '13_0_0'];
  23484. macos = false;
  23485. }
  23486. // Android
  23487. if (android && !windows) {
  23488. device.os = 'android';
  23489. device.android = true;
  23490. }
  23491. if (ipad || iphone || ipod) {
  23492. device.os = 'ios';
  23493. device.ios = true;
  23494. }
  23495. // Export object
  23496. return device;
  23497. }
  23498. function getDevice(overrides) {
  23499. if (overrides === void 0) {
  23500. overrides = {};
  23501. }
  23502. if (!deviceCached) {
  23503. deviceCached = calcDevice(overrides);
  23504. }
  23505. return deviceCached;
  23506. }
  23507. let browser;
  23508. function calcBrowser() {
  23509. const window = getWindow();
  23510. let needPerspectiveFix = false;
  23511. function isSafari() {
  23512. const ua = window.navigator.userAgent.toLowerCase();
  23513. return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
  23514. }
  23515. if (isSafari()) {
  23516. const ua = String(window.navigator.userAgent);
  23517. if (ua.includes('Version/')) {
  23518. const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
  23519. needPerspectiveFix = major < 16 || major === 16 && minor < 2;
  23520. }
  23521. }
  23522. return {
  23523. isSafari: needPerspectiveFix || isSafari(),
  23524. needPerspectiveFix,
  23525. isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
  23526. };
  23527. }
  23528. function getBrowser() {
  23529. if (!browser) {
  23530. browser = calcBrowser();
  23531. }
  23532. return browser;
  23533. }
  23534. function Resize(_ref) {
  23535. let {
  23536. swiper,
  23537. on,
  23538. emit
  23539. } = _ref;
  23540. const window = getWindow();
  23541. let observer = null;
  23542. let animationFrame = null;
  23543. const resizeHandler = () => {
  23544. if (!swiper || swiper.destroyed || !swiper.initialized) return;
  23545. emit('beforeResize');
  23546. emit('resize');
  23547. };
  23548. const createObserver = () => {
  23549. if (!swiper || swiper.destroyed || !swiper.initialized) return;
  23550. observer = new ResizeObserver(entries => {
  23551. animationFrame = window.requestAnimationFrame(() => {
  23552. const {
  23553. width,
  23554. height
  23555. } = swiper;
  23556. let newWidth = width;
  23557. let newHeight = height;
  23558. entries.forEach(_ref2 => {
  23559. let {
  23560. contentBoxSize,
  23561. contentRect,
  23562. target
  23563. } = _ref2;
  23564. if (target && target !== swiper.el) return;
  23565. newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
  23566. newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
  23567. });
  23568. if (newWidth !== width || newHeight !== height) {
  23569. resizeHandler();
  23570. }
  23571. });
  23572. });
  23573. observer.observe(swiper.el);
  23574. };
  23575. const removeObserver = () => {
  23576. if (animationFrame) {
  23577. window.cancelAnimationFrame(animationFrame);
  23578. }
  23579. if (observer && observer.unobserve && swiper.el) {
  23580. observer.unobserve(swiper.el);
  23581. observer = null;
  23582. }
  23583. };
  23584. const orientationChangeHandler = () => {
  23585. if (!swiper || swiper.destroyed || !swiper.initialized) return;
  23586. emit('orientationchange');
  23587. };
  23588. on('init', () => {
  23589. if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
  23590. createObserver();
  23591. return;
  23592. }
  23593. window.addEventListener('resize', resizeHandler);
  23594. window.addEventListener('orientationchange', orientationChangeHandler);
  23595. });
  23596. on('destroy', () => {
  23597. removeObserver();
  23598. window.removeEventListener('resize', resizeHandler);
  23599. window.removeEventListener('orientationchange', orientationChangeHandler);
  23600. });
  23601. }
  23602. function Observer(_ref) {
  23603. let {
  23604. swiper,
  23605. extendParams,
  23606. on,
  23607. emit
  23608. } = _ref;
  23609. const observers = [];
  23610. const window = getWindow();
  23611. const attach = function (target, options) {
  23612. if (options === void 0) {
  23613. options = {};
  23614. }
  23615. const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
  23616. const observer = new ObserverFunc(mutations => {
  23617. // The observerUpdate event should only be triggered
  23618. // once despite the number of mutations. Additional
  23619. // triggers are redundant and are very costly
  23620. if (swiper.__preventObserver__) return;
  23621. if (mutations.length === 1) {
  23622. emit('observerUpdate', mutations[0]);
  23623. return;
  23624. }
  23625. const observerUpdate = function observerUpdate() {
  23626. emit('observerUpdate', mutations[0]);
  23627. };
  23628. if (window.requestAnimationFrame) {
  23629. window.requestAnimationFrame(observerUpdate);
  23630. } else {
  23631. window.setTimeout(observerUpdate, 0);
  23632. }
  23633. });
  23634. observer.observe(target, {
  23635. attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
  23636. childList: typeof options.childList === 'undefined' ? true : options.childList,
  23637. characterData: typeof options.characterData === 'undefined' ? true : options.characterData
  23638. });
  23639. observers.push(observer);
  23640. };
  23641. const init = () => {
  23642. if (!swiper.params.observer) return;
  23643. if (swiper.params.observeParents) {
  23644. const containerParents = elementParents(swiper.hostEl);
  23645. for (let i = 0; i < containerParents.length; i += 1) {
  23646. attach(containerParents[i]);
  23647. }
  23648. }
  23649. // Observe container
  23650. attach(swiper.hostEl, {
  23651. childList: swiper.params.observeSlideChildren
  23652. });
  23653. // Observe wrapper
  23654. attach(swiper.wrapperEl, {
  23655. attributes: false
  23656. });
  23657. };
  23658. const destroy = () => {
  23659. observers.forEach(observer => {
  23660. observer.disconnect();
  23661. });
  23662. observers.splice(0, observers.length);
  23663. };
  23664. extendParams({
  23665. observer: false,
  23666. observeParents: false,
  23667. observeSlideChildren: false
  23668. });
  23669. on('init', init);
  23670. on('destroy', destroy);
  23671. }
  23672. /* eslint-disable no-underscore-dangle */
  23673. var eventsEmitter = {
  23674. on(events, handler, priority) {
  23675. const self = this;
  23676. if (!self.eventsListeners || self.destroyed) return self;
  23677. if (typeof handler !== 'function') return self;
  23678. const method = priority ? 'unshift' : 'push';
  23679. events.split(' ').forEach(event => {
  23680. if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
  23681. self.eventsListeners[event][method](handler);
  23682. });
  23683. return self;
  23684. },
  23685. once(events, handler, priority) {
  23686. const self = this;
  23687. if (!self.eventsListeners || self.destroyed) return self;
  23688. if (typeof handler !== 'function') return self;
  23689. function onceHandler() {
  23690. self.off(events, onceHandler);
  23691. if (onceHandler.__emitterProxy) {
  23692. delete onceHandler.__emitterProxy;
  23693. }
  23694. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  23695. args[_key] = arguments[_key];
  23696. }
  23697. handler.apply(self, args);
  23698. }
  23699. onceHandler.__emitterProxy = handler;
  23700. return self.on(events, onceHandler, priority);
  23701. },
  23702. onAny(handler, priority) {
  23703. const self = this;
  23704. if (!self.eventsListeners || self.destroyed) return self;
  23705. if (typeof handler !== 'function') return self;
  23706. const method = priority ? 'unshift' : 'push';
  23707. if (self.eventsAnyListeners.indexOf(handler) < 0) {
  23708. self.eventsAnyListeners[method](handler);
  23709. }
  23710. return self;
  23711. },
  23712. offAny(handler) {
  23713. const self = this;
  23714. if (!self.eventsListeners || self.destroyed) return self;
  23715. if (!self.eventsAnyListeners) return self;
  23716. const index = self.eventsAnyListeners.indexOf(handler);
  23717. if (index >= 0) {
  23718. self.eventsAnyListeners.splice(index, 1);
  23719. }
  23720. return self;
  23721. },
  23722. off(events, handler) {
  23723. const self = this;
  23724. if (!self.eventsListeners || self.destroyed) return self;
  23725. if (!self.eventsListeners) return self;
  23726. events.split(' ').forEach(event => {
  23727. if (typeof handler === 'undefined') {
  23728. self.eventsListeners[event] = [];
  23729. } else if (self.eventsListeners[event]) {
  23730. self.eventsListeners[event].forEach((eventHandler, index) => {
  23731. if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
  23732. self.eventsListeners[event].splice(index, 1);
  23733. }
  23734. });
  23735. }
  23736. });
  23737. return self;
  23738. },
  23739. emit() {
  23740. const self = this;
  23741. if (!self.eventsListeners || self.destroyed) return self;
  23742. if (!self.eventsListeners) return self;
  23743. let events;
  23744. let data;
  23745. let context;
  23746. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  23747. args[_key2] = arguments[_key2];
  23748. }
  23749. if (typeof args[0] === 'string' || Array.isArray(args[0])) {
  23750. events = args[0];
  23751. data = args.slice(1, args.length);
  23752. context = self;
  23753. } else {
  23754. events = args[0].events;
  23755. data = args[0].data;
  23756. context = args[0].context || self;
  23757. }
  23758. data.unshift(context);
  23759. const eventsArray = Array.isArray(events) ? events : events.split(' ');
  23760. eventsArray.forEach(event => {
  23761. if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
  23762. self.eventsAnyListeners.forEach(eventHandler => {
  23763. eventHandler.apply(context, [event, ...data]);
  23764. });
  23765. }
  23766. if (self.eventsListeners && self.eventsListeners[event]) {
  23767. self.eventsListeners[event].forEach(eventHandler => {
  23768. eventHandler.apply(context, data);
  23769. });
  23770. }
  23771. });
  23772. return self;
  23773. }
  23774. };
  23775. function updateSize() {
  23776. const swiper = this;
  23777. let width;
  23778. let height;
  23779. const el = swiper.el;
  23780. if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
  23781. width = swiper.params.width;
  23782. } else {
  23783. width = el.clientWidth;
  23784. }
  23785. if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
  23786. height = swiper.params.height;
  23787. } else {
  23788. height = el.clientHeight;
  23789. }
  23790. if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
  23791. return;
  23792. }
  23793. // Subtract paddings
  23794. width = width - parseInt(elementStyle(el, 'padding-left') || 0, 10) - parseInt(elementStyle(el, 'padding-right') || 0, 10);
  23795. height = height - parseInt(elementStyle(el, 'padding-top') || 0, 10) - parseInt(elementStyle(el, 'padding-bottom') || 0, 10);
  23796. if (Number.isNaN(width)) width = 0;
  23797. if (Number.isNaN(height)) height = 0;
  23798. Object.assign(swiper, {
  23799. width,
  23800. height,
  23801. size: swiper.isHorizontal() ? width : height
  23802. });
  23803. }
  23804. function updateSlides() {
  23805. const swiper = this;
  23806. function getDirectionPropertyValue(node, label) {
  23807. return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
  23808. }
  23809. const params = swiper.params;
  23810. const {
  23811. wrapperEl,
  23812. slidesEl,
  23813. size: swiperSize,
  23814. rtlTranslate: rtl,
  23815. wrongRTL
  23816. } = swiper;
  23817. const isVirtual = swiper.virtual && params.virtual.enabled;
  23818. const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
  23819. const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
  23820. const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
  23821. let snapGrid = [];
  23822. const slidesGrid = [];
  23823. const slidesSizesGrid = [];
  23824. let offsetBefore = params.slidesOffsetBefore;
  23825. if (typeof offsetBefore === 'function') {
  23826. offsetBefore = params.slidesOffsetBefore.call(swiper);
  23827. }
  23828. let offsetAfter = params.slidesOffsetAfter;
  23829. if (typeof offsetAfter === 'function') {
  23830. offsetAfter = params.slidesOffsetAfter.call(swiper);
  23831. }
  23832. const previousSnapGridLength = swiper.snapGrid.length;
  23833. const previousSlidesGridLength = swiper.slidesGrid.length;
  23834. let spaceBetween = params.spaceBetween;
  23835. let slidePosition = -offsetBefore;
  23836. let prevSlideSize = 0;
  23837. let index = 0;
  23838. if (typeof swiperSize === 'undefined') {
  23839. return;
  23840. }
  23841. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  23842. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
  23843. } else if (typeof spaceBetween === 'string') {
  23844. spaceBetween = parseFloat(spaceBetween);
  23845. }
  23846. swiper.virtualSize = -spaceBetween;
  23847. // reset margins
  23848. slides.forEach(slideEl => {
  23849. if (rtl) {
  23850. slideEl.style.marginLeft = '';
  23851. } else {
  23852. slideEl.style.marginRight = '';
  23853. }
  23854. slideEl.style.marginBottom = '';
  23855. slideEl.style.marginTop = '';
  23856. });
  23857. // reset cssMode offsets
  23858. if (params.centeredSlides && params.cssMode) {
  23859. setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
  23860. setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
  23861. }
  23862. const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
  23863. if (gridEnabled) {
  23864. swiper.grid.initSlides(slides);
  23865. } else if (swiper.grid) {
  23866. swiper.grid.unsetSlides();
  23867. }
  23868. // Calc slides
  23869. let slideSize;
  23870. const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
  23871. return typeof params.breakpoints[key].slidesPerView !== 'undefined';
  23872. }).length > 0;
  23873. for (let i = 0; i < slidesLength; i += 1) {
  23874. slideSize = 0;
  23875. let slide;
  23876. if (slides[i]) slide = slides[i];
  23877. if (gridEnabled) {
  23878. swiper.grid.updateSlide(i, slide, slides);
  23879. }
  23880. if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
  23881. if (params.slidesPerView === 'auto') {
  23882. if (shouldResetSlideSize) {
  23883. slides[i].style[swiper.getDirectionLabel('width')] = ``;
  23884. }
  23885. const slideStyles = getComputedStyle(slide);
  23886. const currentTransform = slide.style.transform;
  23887. const currentWebKitTransform = slide.style.webkitTransform;
  23888. if (currentTransform) {
  23889. slide.style.transform = 'none';
  23890. }
  23891. if (currentWebKitTransform) {
  23892. slide.style.webkitTransform = 'none';
  23893. }
  23894. if (params.roundLengths) {
  23895. slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
  23896. } else {
  23897. // eslint-disable-next-line
  23898. const width = getDirectionPropertyValue(slideStyles, 'width');
  23899. const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
  23900. const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
  23901. const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
  23902. const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
  23903. const boxSizing = slideStyles.getPropertyValue('box-sizing');
  23904. if (boxSizing && boxSizing === 'border-box') {
  23905. slideSize = width + marginLeft + marginRight;
  23906. } else {
  23907. const {
  23908. clientWidth,
  23909. offsetWidth
  23910. } = slide;
  23911. slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
  23912. }
  23913. }
  23914. if (currentTransform) {
  23915. slide.style.transform = currentTransform;
  23916. }
  23917. if (currentWebKitTransform) {
  23918. slide.style.webkitTransform = currentWebKitTransform;
  23919. }
  23920. if (params.roundLengths) slideSize = Math.floor(slideSize);
  23921. } else {
  23922. slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
  23923. if (params.roundLengths) slideSize = Math.floor(slideSize);
  23924. if (slides[i]) {
  23925. slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
  23926. }
  23927. }
  23928. if (slides[i]) {
  23929. slides[i].swiperSlideSize = slideSize;
  23930. }
  23931. slidesSizesGrid.push(slideSize);
  23932. if (params.centeredSlides) {
  23933. slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
  23934. if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
  23935. if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
  23936. if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
  23937. if (params.roundLengths) slidePosition = Math.floor(slidePosition);
  23938. if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
  23939. slidesGrid.push(slidePosition);
  23940. } else {
  23941. if (params.roundLengths) slidePosition = Math.floor(slidePosition);
  23942. if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
  23943. slidesGrid.push(slidePosition);
  23944. slidePosition = slidePosition + slideSize + spaceBetween;
  23945. }
  23946. swiper.virtualSize += slideSize + spaceBetween;
  23947. prevSlideSize = slideSize;
  23948. index += 1;
  23949. }
  23950. swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
  23951. if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
  23952. wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
  23953. }
  23954. if (params.setWrapperSize) {
  23955. wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
  23956. }
  23957. if (gridEnabled) {
  23958. swiper.grid.updateWrapperSize(slideSize, snapGrid);
  23959. }
  23960. // Remove last grid elements depending on width
  23961. if (!params.centeredSlides) {
  23962. const newSlidesGrid = [];
  23963. for (let i = 0; i < snapGrid.length; i += 1) {
  23964. let slidesGridItem = snapGrid[i];
  23965. if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
  23966. if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
  23967. newSlidesGrid.push(slidesGridItem);
  23968. }
  23969. }
  23970. snapGrid = newSlidesGrid;
  23971. if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
  23972. snapGrid.push(swiper.virtualSize - swiperSize);
  23973. }
  23974. }
  23975. if (isVirtual && params.loop) {
  23976. const size = slidesSizesGrid[0] + spaceBetween;
  23977. if (params.slidesPerGroup > 1) {
  23978. const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
  23979. const groupSize = size * params.slidesPerGroup;
  23980. for (let i = 0; i < groups; i += 1) {
  23981. snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
  23982. }
  23983. }
  23984. for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
  23985. if (params.slidesPerGroup === 1) {
  23986. snapGrid.push(snapGrid[snapGrid.length - 1] + size);
  23987. }
  23988. slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
  23989. swiper.virtualSize += size;
  23990. }
  23991. }
  23992. if (snapGrid.length === 0) snapGrid = [0];
  23993. if (spaceBetween !== 0) {
  23994. const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
  23995. slides.filter((_, slideIndex) => {
  23996. if (!params.cssMode || params.loop) return true;
  23997. if (slideIndex === slides.length - 1) {
  23998. return false;
  23999. }
  24000. return true;
  24001. }).forEach(slideEl => {
  24002. slideEl.style[key] = `${spaceBetween}px`;
  24003. });
  24004. }
  24005. if (params.centeredSlides && params.centeredSlidesBounds) {
  24006. let allSlidesSize = 0;
  24007. slidesSizesGrid.forEach(slideSizeValue => {
  24008. allSlidesSize += slideSizeValue + (spaceBetween || 0);
  24009. });
  24010. allSlidesSize -= spaceBetween;
  24011. const maxSnap = allSlidesSize - swiperSize;
  24012. snapGrid = snapGrid.map(snap => {
  24013. if (snap <= 0) return -offsetBefore;
  24014. if (snap > maxSnap) return maxSnap + offsetAfter;
  24015. return snap;
  24016. });
  24017. }
  24018. if (params.centerInsufficientSlides) {
  24019. let allSlidesSize = 0;
  24020. slidesSizesGrid.forEach(slideSizeValue => {
  24021. allSlidesSize += slideSizeValue + (spaceBetween || 0);
  24022. });
  24023. allSlidesSize -= spaceBetween;
  24024. if (allSlidesSize < swiperSize) {
  24025. const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
  24026. snapGrid.forEach((snap, snapIndex) => {
  24027. snapGrid[snapIndex] = snap - allSlidesOffset;
  24028. });
  24029. slidesGrid.forEach((snap, snapIndex) => {
  24030. slidesGrid[snapIndex] = snap + allSlidesOffset;
  24031. });
  24032. }
  24033. }
  24034. Object.assign(swiper, {
  24035. slides,
  24036. snapGrid,
  24037. slidesGrid,
  24038. slidesSizesGrid
  24039. });
  24040. if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
  24041. setCSSProperty(wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
  24042. setCSSProperty(wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
  24043. const addToSnapGrid = -swiper.snapGrid[0];
  24044. const addToSlidesGrid = -swiper.slidesGrid[0];
  24045. swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
  24046. swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
  24047. }
  24048. if (slidesLength !== previousSlidesLength) {
  24049. swiper.emit('slidesLengthChange');
  24050. }
  24051. if (snapGrid.length !== previousSnapGridLength) {
  24052. if (swiper.params.watchOverflow) swiper.checkOverflow();
  24053. swiper.emit('snapGridLengthChange');
  24054. }
  24055. if (slidesGrid.length !== previousSlidesGridLength) {
  24056. swiper.emit('slidesGridLengthChange');
  24057. }
  24058. if (params.watchSlidesProgress) {
  24059. swiper.updateSlidesOffset();
  24060. }
  24061. swiper.emit('slidesUpdated');
  24062. if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
  24063. const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
  24064. const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
  24065. if (slidesLength <= params.maxBackfaceHiddenSlides) {
  24066. if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass);
  24067. } else if (hasClassBackfaceClassAdded) {
  24068. swiper.el.classList.remove(backFaceHiddenClass);
  24069. }
  24070. }
  24071. }
  24072. function updateAutoHeight(speed) {
  24073. const swiper = this;
  24074. const activeSlides = [];
  24075. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  24076. let newHeight = 0;
  24077. let i;
  24078. if (typeof speed === 'number') {
  24079. swiper.setTransition(speed);
  24080. } else if (speed === true) {
  24081. swiper.setTransition(swiper.params.speed);
  24082. }
  24083. const getSlideByIndex = index => {
  24084. if (isVirtual) {
  24085. return swiper.slides[swiper.getSlideIndexByData(index)];
  24086. }
  24087. return swiper.slides[index];
  24088. };
  24089. // Find slides currently in view
  24090. if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
  24091. if (swiper.params.centeredSlides) {
  24092. (swiper.visibleSlides || []).forEach(slide => {
  24093. activeSlides.push(slide);
  24094. });
  24095. } else {
  24096. for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
  24097. const index = swiper.activeIndex + i;
  24098. if (index > swiper.slides.length && !isVirtual) break;
  24099. activeSlides.push(getSlideByIndex(index));
  24100. }
  24101. }
  24102. } else {
  24103. activeSlides.push(getSlideByIndex(swiper.activeIndex));
  24104. }
  24105. // Find new height from highest slide in view
  24106. for (i = 0; i < activeSlides.length; i += 1) {
  24107. if (typeof activeSlides[i] !== 'undefined') {
  24108. const height = activeSlides[i].offsetHeight;
  24109. newHeight = height > newHeight ? height : newHeight;
  24110. }
  24111. }
  24112. // Update Height
  24113. if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
  24114. }
  24115. function updateSlidesOffset() {
  24116. const swiper = this;
  24117. const slides = swiper.slides;
  24118. // eslint-disable-next-line
  24119. const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0;
  24120. for (let i = 0; i < slides.length; i += 1) {
  24121. slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
  24122. }
  24123. }
  24124. function updateSlidesProgress(translate) {
  24125. if (translate === void 0) {
  24126. translate = this && this.translate || 0;
  24127. }
  24128. const swiper = this;
  24129. const params = swiper.params;
  24130. const {
  24131. slides,
  24132. rtlTranslate: rtl,
  24133. snapGrid
  24134. } = swiper;
  24135. if (slides.length === 0) return;
  24136. if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
  24137. let offsetCenter = -translate;
  24138. if (rtl) offsetCenter = translate;
  24139. // Visible Slides
  24140. slides.forEach(slideEl => {
  24141. slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass);
  24142. });
  24143. swiper.visibleSlidesIndexes = [];
  24144. swiper.visibleSlides = [];
  24145. let spaceBetween = params.spaceBetween;
  24146. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  24147. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
  24148. } else if (typeof spaceBetween === 'string') {
  24149. spaceBetween = parseFloat(spaceBetween);
  24150. }
  24151. for (let i = 0; i < slides.length; i += 1) {
  24152. const slide = slides[i];
  24153. let slideOffset = slide.swiperSlideOffset;
  24154. if (params.cssMode && params.centeredSlides) {
  24155. slideOffset -= slides[0].swiperSlideOffset;
  24156. }
  24157. const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
  24158. const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
  24159. const slideBefore = -(offsetCenter - slideOffset);
  24160. const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
  24161. const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
  24162. const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
  24163. if (isVisible) {
  24164. swiper.visibleSlides.push(slide);
  24165. swiper.visibleSlidesIndexes.push(i);
  24166. slides[i].classList.add(params.slideVisibleClass);
  24167. }
  24168. if (isFullyVisible) {
  24169. slides[i].classList.add(params.slideFullyVisibleClass);
  24170. }
  24171. slide.progress = rtl ? -slideProgress : slideProgress;
  24172. slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
  24173. }
  24174. }
  24175. function updateProgress(translate) {
  24176. const swiper = this;
  24177. if (typeof translate === 'undefined') {
  24178. const multiplier = swiper.rtlTranslate ? -1 : 1;
  24179. // eslint-disable-next-line
  24180. translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
  24181. }
  24182. const params = swiper.params;
  24183. const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  24184. let {
  24185. progress,
  24186. isBeginning,
  24187. isEnd,
  24188. progressLoop
  24189. } = swiper;
  24190. const wasBeginning = isBeginning;
  24191. const wasEnd = isEnd;
  24192. if (translatesDiff === 0) {
  24193. progress = 0;
  24194. isBeginning = true;
  24195. isEnd = true;
  24196. } else {
  24197. progress = (translate - swiper.minTranslate()) / translatesDiff;
  24198. const isBeginningRounded = Math.abs(translate - swiper.minTranslate()) < 1;
  24199. const isEndRounded = Math.abs(translate - swiper.maxTranslate()) < 1;
  24200. isBeginning = isBeginningRounded || progress <= 0;
  24201. isEnd = isEndRounded || progress >= 1;
  24202. if (isBeginningRounded) progress = 0;
  24203. if (isEndRounded) progress = 1;
  24204. }
  24205. if (params.loop) {
  24206. const firstSlideIndex = swiper.getSlideIndexByData(0);
  24207. const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1);
  24208. const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex];
  24209. const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex];
  24210. const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1];
  24211. const translateAbs = Math.abs(translate);
  24212. if (translateAbs >= firstSlideTranslate) {
  24213. progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
  24214. } else {
  24215. progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
  24216. }
  24217. if (progressLoop > 1) progressLoop -= 1;
  24218. }
  24219. Object.assign(swiper, {
  24220. progress,
  24221. progressLoop,
  24222. isBeginning,
  24223. isEnd
  24224. });
  24225. if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
  24226. if (isBeginning && !wasBeginning) {
  24227. swiper.emit('reachBeginning toEdge');
  24228. }
  24229. if (isEnd && !wasEnd) {
  24230. swiper.emit('reachEnd toEdge');
  24231. }
  24232. if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
  24233. swiper.emit('fromEdge');
  24234. }
  24235. swiper.emit('progress', progress);
  24236. }
  24237. function updateSlidesClasses() {
  24238. const swiper = this;
  24239. const {
  24240. slides,
  24241. params,
  24242. slidesEl,
  24243. activeIndex
  24244. } = swiper;
  24245. const isVirtual = swiper.virtual && params.virtual.enabled;
  24246. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  24247. const getFilteredSlide = selector => {
  24248. return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
  24249. };
  24250. slides.forEach(slideEl => {
  24251. slideEl.classList.remove(params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
  24252. });
  24253. let activeSlide;
  24254. let prevSlide;
  24255. let nextSlide;
  24256. if (isVirtual) {
  24257. if (params.loop) {
  24258. let slideIndex = activeIndex - swiper.virtual.slidesBefore;
  24259. if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
  24260. if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
  24261. activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
  24262. } else {
  24263. activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
  24264. }
  24265. } else {
  24266. if (gridEnabled) {
  24267. activeSlide = slides.filter(slideEl => slideEl.column === activeIndex)[0];
  24268. nextSlide = slides.filter(slideEl => slideEl.column === activeIndex + 1)[0];
  24269. prevSlide = slides.filter(slideEl => slideEl.column === activeIndex - 1)[0];
  24270. } else {
  24271. activeSlide = slides[activeIndex];
  24272. }
  24273. }
  24274. if (activeSlide) {
  24275. // Active classes
  24276. activeSlide.classList.add(params.slideActiveClass);
  24277. if (gridEnabled) {
  24278. if (nextSlide) {
  24279. nextSlide.classList.add(params.slideNextClass);
  24280. }
  24281. if (prevSlide) {
  24282. prevSlide.classList.add(params.slidePrevClass);
  24283. }
  24284. } else {
  24285. // Next Slide
  24286. nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
  24287. if (params.loop && !nextSlide) {
  24288. nextSlide = slides[0];
  24289. }
  24290. if (nextSlide) {
  24291. nextSlide.classList.add(params.slideNextClass);
  24292. }
  24293. // Prev Slide
  24294. prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
  24295. if (params.loop && !prevSlide === 0) {
  24296. prevSlide = slides[slides.length - 1];
  24297. }
  24298. if (prevSlide) {
  24299. prevSlide.classList.add(params.slidePrevClass);
  24300. }
  24301. }
  24302. }
  24303. swiper.emitSlidesClasses();
  24304. }
  24305. const processLazyPreloader = (swiper, imageEl) => {
  24306. if (!swiper || swiper.destroyed || !swiper.params) return;
  24307. const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
  24308. const slideEl = imageEl.closest(slideSelector());
  24309. if (slideEl) {
  24310. let lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
  24311. if (!lazyEl && swiper.isElement) {
  24312. if (slideEl.shadowRoot) {
  24313. lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
  24314. } else {
  24315. // init later
  24316. requestAnimationFrame(() => {
  24317. if (slideEl.shadowRoot) {
  24318. lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
  24319. if (lazyEl) lazyEl.remove();
  24320. }
  24321. });
  24322. }
  24323. }
  24324. if (lazyEl) lazyEl.remove();
  24325. }
  24326. };
  24327. const unlazy = (swiper, index) => {
  24328. if (!swiper.slides[index]) return;
  24329. const imageEl = swiper.slides[index].querySelector('[loading="lazy"]');
  24330. if (imageEl) imageEl.removeAttribute('loading');
  24331. };
  24332. const preload = swiper => {
  24333. if (!swiper || swiper.destroyed || !swiper.params) return;
  24334. let amount = swiper.params.lazyPreloadPrevNext;
  24335. const len = swiper.slides.length;
  24336. if (!len || !amount || amount < 0) return;
  24337. amount = Math.min(amount, len);
  24338. const slidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(swiper.params.slidesPerView);
  24339. const activeIndex = swiper.activeIndex;
  24340. if (swiper.params.grid && swiper.params.grid.rows > 1) {
  24341. const activeColumn = activeIndex;
  24342. const preloadColumns = [activeColumn - amount];
  24343. preloadColumns.push(...Array.from({
  24344. length: amount
  24345. }).map((_, i) => {
  24346. return activeColumn + slidesPerView + i;
  24347. }));
  24348. swiper.slides.forEach((slideEl, i) => {
  24349. if (preloadColumns.includes(slideEl.column)) unlazy(swiper, i);
  24350. });
  24351. return;
  24352. }
  24353. const slideIndexLastInView = activeIndex + slidesPerView - 1;
  24354. if (swiper.params.rewind || swiper.params.loop) {
  24355. for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) {
  24356. const realIndex = (i % len + len) % len;
  24357. if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper, realIndex);
  24358. }
  24359. } else {
  24360. for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) {
  24361. if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) {
  24362. unlazy(swiper, i);
  24363. }
  24364. }
  24365. }
  24366. };
  24367. function getActiveIndexByTranslate(swiper) {
  24368. const {
  24369. slidesGrid,
  24370. params
  24371. } = swiper;
  24372. const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  24373. let activeIndex;
  24374. for (let i = 0; i < slidesGrid.length; i += 1) {
  24375. if (typeof slidesGrid[i + 1] !== 'undefined') {
  24376. if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
  24377. activeIndex = i;
  24378. } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
  24379. activeIndex = i + 1;
  24380. }
  24381. } else if (translate >= slidesGrid[i]) {
  24382. activeIndex = i;
  24383. }
  24384. }
  24385. // Normalize slideIndex
  24386. if (params.normalizeSlideIndex) {
  24387. if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
  24388. }
  24389. return activeIndex;
  24390. }
  24391. function updateActiveIndex(newActiveIndex) {
  24392. const swiper = this;
  24393. const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  24394. const {
  24395. snapGrid,
  24396. params,
  24397. activeIndex: previousIndex,
  24398. realIndex: previousRealIndex,
  24399. snapIndex: previousSnapIndex
  24400. } = swiper;
  24401. let activeIndex = newActiveIndex;
  24402. let snapIndex;
  24403. const getVirtualRealIndex = aIndex => {
  24404. let realIndex = aIndex - swiper.virtual.slidesBefore;
  24405. if (realIndex < 0) {
  24406. realIndex = swiper.virtual.slides.length + realIndex;
  24407. }
  24408. if (realIndex >= swiper.virtual.slides.length) {
  24409. realIndex -= swiper.virtual.slides.length;
  24410. }
  24411. return realIndex;
  24412. };
  24413. if (typeof activeIndex === 'undefined') {
  24414. activeIndex = getActiveIndexByTranslate(swiper);
  24415. }
  24416. if (snapGrid.indexOf(translate) >= 0) {
  24417. snapIndex = snapGrid.indexOf(translate);
  24418. } else {
  24419. const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
  24420. snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
  24421. }
  24422. if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
  24423. if (activeIndex === previousIndex && !swiper.params.loop) {
  24424. if (snapIndex !== previousSnapIndex) {
  24425. swiper.snapIndex = snapIndex;
  24426. swiper.emit('snapIndexChange');
  24427. }
  24428. return;
  24429. }
  24430. if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
  24431. swiper.realIndex = getVirtualRealIndex(activeIndex);
  24432. return;
  24433. }
  24434. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  24435. // Get real index
  24436. let realIndex;
  24437. if (swiper.virtual && params.virtual.enabled && params.loop) {
  24438. realIndex = getVirtualRealIndex(activeIndex);
  24439. } else if (gridEnabled) {
  24440. const firstSlideInColumn = swiper.slides.filter(slideEl => slideEl.column === activeIndex)[0];
  24441. let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
  24442. if (Number.isNaN(activeSlideIndex)) {
  24443. activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
  24444. }
  24445. realIndex = Math.floor(activeSlideIndex / params.grid.rows);
  24446. } else if (swiper.slides[activeIndex]) {
  24447. const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
  24448. if (slideIndex) {
  24449. realIndex = parseInt(slideIndex, 10);
  24450. } else {
  24451. realIndex = activeIndex;
  24452. }
  24453. } else {
  24454. realIndex = activeIndex;
  24455. }
  24456. Object.assign(swiper, {
  24457. previousSnapIndex,
  24458. snapIndex,
  24459. previousRealIndex,
  24460. realIndex,
  24461. previousIndex,
  24462. activeIndex
  24463. });
  24464. if (swiper.initialized) {
  24465. preload(swiper);
  24466. }
  24467. swiper.emit('activeIndexChange');
  24468. swiper.emit('snapIndexChange');
  24469. if (swiper.initialized || swiper.params.runCallbacksOnInit) {
  24470. if (previousRealIndex !== realIndex) {
  24471. swiper.emit('realIndexChange');
  24472. }
  24473. swiper.emit('slideChange');
  24474. }
  24475. }
  24476. function updateClickedSlide(el, path) {
  24477. const swiper = this;
  24478. const params = swiper.params;
  24479. let slide = el.closest(`.${params.slideClass}, swiper-slide`);
  24480. if (!slide && swiper.isElement && path && path.length > 1 && path.includes(el)) {
  24481. [...path.slice(path.indexOf(el) + 1, path.length)].forEach(pathEl => {
  24482. if (!slide && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) {
  24483. slide = pathEl;
  24484. }
  24485. });
  24486. }
  24487. let slideFound = false;
  24488. let slideIndex;
  24489. if (slide) {
  24490. for (let i = 0; i < swiper.slides.length; i += 1) {
  24491. if (swiper.slides[i] === slide) {
  24492. slideFound = true;
  24493. slideIndex = i;
  24494. break;
  24495. }
  24496. }
  24497. }
  24498. if (slide && slideFound) {
  24499. swiper.clickedSlide = slide;
  24500. if (swiper.virtual && swiper.params.virtual.enabled) {
  24501. swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
  24502. } else {
  24503. swiper.clickedIndex = slideIndex;
  24504. }
  24505. } else {
  24506. swiper.clickedSlide = undefined;
  24507. swiper.clickedIndex = undefined;
  24508. return;
  24509. }
  24510. if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
  24511. swiper.slideToClickedSlide();
  24512. }
  24513. }
  24514. var update = {
  24515. updateSize,
  24516. updateSlides,
  24517. updateAutoHeight,
  24518. updateSlidesOffset,
  24519. updateSlidesProgress,
  24520. updateProgress,
  24521. updateSlidesClasses,
  24522. updateActiveIndex,
  24523. updateClickedSlide
  24524. };
  24525. function getSwiperTranslate(axis) {
  24526. if (axis === void 0) {
  24527. axis = this.isHorizontal() ? 'x' : 'y';
  24528. }
  24529. const swiper = this;
  24530. const {
  24531. params,
  24532. rtlTranslate: rtl,
  24533. translate,
  24534. wrapperEl
  24535. } = swiper;
  24536. if (params.virtualTranslate) {
  24537. return rtl ? -translate : translate;
  24538. }
  24539. if (params.cssMode) {
  24540. return translate;
  24541. }
  24542. let currentTranslate = getTranslate(wrapperEl, axis);
  24543. currentTranslate += swiper.cssOverflowAdjustment();
  24544. if (rtl) currentTranslate = -currentTranslate;
  24545. return currentTranslate || 0;
  24546. }
  24547. function setTranslate(translate, byController) {
  24548. const swiper = this;
  24549. const {
  24550. rtlTranslate: rtl,
  24551. params,
  24552. wrapperEl,
  24553. progress
  24554. } = swiper;
  24555. let x = 0;
  24556. let y = 0;
  24557. const z = 0;
  24558. if (swiper.isHorizontal()) {
  24559. x = rtl ? -translate : translate;
  24560. } else {
  24561. y = translate;
  24562. }
  24563. if (params.roundLengths) {
  24564. x = Math.floor(x);
  24565. y = Math.floor(y);
  24566. }
  24567. swiper.previousTranslate = swiper.translate;
  24568. swiper.translate = swiper.isHorizontal() ? x : y;
  24569. if (params.cssMode) {
  24570. wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
  24571. } else if (!params.virtualTranslate) {
  24572. if (swiper.isHorizontal()) {
  24573. x -= swiper.cssOverflowAdjustment();
  24574. } else {
  24575. y -= swiper.cssOverflowAdjustment();
  24576. }
  24577. wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
  24578. }
  24579. // Check if we need to update progress
  24580. let newProgress;
  24581. const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  24582. if (translatesDiff === 0) {
  24583. newProgress = 0;
  24584. } else {
  24585. newProgress = (translate - swiper.minTranslate()) / translatesDiff;
  24586. }
  24587. if (newProgress !== progress) {
  24588. swiper.updateProgress(translate);
  24589. }
  24590. swiper.emit('setTranslate', swiper.translate, byController);
  24591. }
  24592. function minTranslate() {
  24593. return -this.snapGrid[0];
  24594. }
  24595. function maxTranslate() {
  24596. return -this.snapGrid[this.snapGrid.length - 1];
  24597. }
  24598. function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
  24599. if (translate === void 0) {
  24600. translate = 0;
  24601. }
  24602. if (speed === void 0) {
  24603. speed = this.params.speed;
  24604. }
  24605. if (runCallbacks === void 0) {
  24606. runCallbacks = true;
  24607. }
  24608. if (translateBounds === void 0) {
  24609. translateBounds = true;
  24610. }
  24611. const swiper = this;
  24612. const {
  24613. params,
  24614. wrapperEl
  24615. } = swiper;
  24616. if (swiper.animating && params.preventInteractionOnTransition) {
  24617. return false;
  24618. }
  24619. const minTranslate = swiper.minTranslate();
  24620. const maxTranslate = swiper.maxTranslate();
  24621. let newTranslate;
  24622. if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
  24623. // Update progress
  24624. swiper.updateProgress(newTranslate);
  24625. if (params.cssMode) {
  24626. const isH = swiper.isHorizontal();
  24627. if (speed === 0) {
  24628. wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
  24629. } else {
  24630. if (!swiper.support.smoothScroll) {
  24631. animateCSSModeScroll({
  24632. swiper,
  24633. targetPosition: -newTranslate,
  24634. side: isH ? 'left' : 'top'
  24635. });
  24636. return true;
  24637. }
  24638. wrapperEl.scrollTo({
  24639. [isH ? 'left' : 'top']: -newTranslate,
  24640. behavior: 'smooth'
  24641. });
  24642. }
  24643. return true;
  24644. }
  24645. if (speed === 0) {
  24646. swiper.setTransition(0);
  24647. swiper.setTranslate(newTranslate);
  24648. if (runCallbacks) {
  24649. swiper.emit('beforeTransitionStart', speed, internal);
  24650. swiper.emit('transitionEnd');
  24651. }
  24652. } else {
  24653. swiper.setTransition(speed);
  24654. swiper.setTranslate(newTranslate);
  24655. if (runCallbacks) {
  24656. swiper.emit('beforeTransitionStart', speed, internal);
  24657. swiper.emit('transitionStart');
  24658. }
  24659. if (!swiper.animating) {
  24660. swiper.animating = true;
  24661. if (!swiper.onTranslateToWrapperTransitionEnd) {
  24662. swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
  24663. if (!swiper || swiper.destroyed) return;
  24664. if (e.target !== this) return;
  24665. swiper.wrapperEl.removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
  24666. swiper.onTranslateToWrapperTransitionEnd = null;
  24667. delete swiper.onTranslateToWrapperTransitionEnd;
  24668. if (runCallbacks) {
  24669. swiper.emit('transitionEnd');
  24670. }
  24671. };
  24672. }
  24673. swiper.wrapperEl.addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
  24674. }
  24675. }
  24676. return true;
  24677. }
  24678. var translate = {
  24679. getTranslate: getSwiperTranslate,
  24680. setTranslate,
  24681. minTranslate,
  24682. maxTranslate,
  24683. translateTo
  24684. };
  24685. function setTransition(duration, byController) {
  24686. const swiper = this;
  24687. if (!swiper.params.cssMode) {
  24688. swiper.wrapperEl.style.transitionDuration = `${duration}ms`;
  24689. swiper.wrapperEl.style.transitionDelay = duration === 0 ? `0ms` : '';
  24690. }
  24691. swiper.emit('setTransition', duration, byController);
  24692. }
  24693. function transitionEmit(_ref) {
  24694. let {
  24695. swiper,
  24696. runCallbacks,
  24697. direction,
  24698. step
  24699. } = _ref;
  24700. const {
  24701. activeIndex,
  24702. previousIndex
  24703. } = swiper;
  24704. let dir = direction;
  24705. if (!dir) {
  24706. if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
  24707. }
  24708. swiper.emit(`transition${step}`);
  24709. if (runCallbacks && activeIndex !== previousIndex) {
  24710. if (dir === 'reset') {
  24711. swiper.emit(`slideResetTransition${step}`);
  24712. return;
  24713. }
  24714. swiper.emit(`slideChangeTransition${step}`);
  24715. if (dir === 'next') {
  24716. swiper.emit(`slideNextTransition${step}`);
  24717. } else {
  24718. swiper.emit(`slidePrevTransition${step}`);
  24719. }
  24720. }
  24721. }
  24722. function transitionStart(runCallbacks, direction) {
  24723. if (runCallbacks === void 0) {
  24724. runCallbacks = true;
  24725. }
  24726. const swiper = this;
  24727. const {
  24728. params
  24729. } = swiper;
  24730. if (params.cssMode) return;
  24731. if (params.autoHeight) {
  24732. swiper.updateAutoHeight();
  24733. }
  24734. transitionEmit({
  24735. swiper,
  24736. runCallbacks,
  24737. direction,
  24738. step: 'Start'
  24739. });
  24740. }
  24741. function transitionEnd(runCallbacks, direction) {
  24742. if (runCallbacks === void 0) {
  24743. runCallbacks = true;
  24744. }
  24745. const swiper = this;
  24746. const {
  24747. params
  24748. } = swiper;
  24749. swiper.animating = false;
  24750. if (params.cssMode) return;
  24751. swiper.setTransition(0);
  24752. transitionEmit({
  24753. swiper,
  24754. runCallbacks,
  24755. direction,
  24756. step: 'End'
  24757. });
  24758. }
  24759. var transition = {
  24760. setTransition,
  24761. transitionStart,
  24762. transitionEnd
  24763. };
  24764. function slideTo(index, speed, runCallbacks, internal, initial) {
  24765. if (index === void 0) {
  24766. index = 0;
  24767. }
  24768. if (speed === void 0) {
  24769. speed = this.params.speed;
  24770. }
  24771. if (runCallbacks === void 0) {
  24772. runCallbacks = true;
  24773. }
  24774. if (typeof index === 'string') {
  24775. index = parseInt(index, 10);
  24776. }
  24777. const swiper = this;
  24778. let slideIndex = index;
  24779. if (slideIndex < 0) slideIndex = 0;
  24780. const {
  24781. params,
  24782. snapGrid,
  24783. slidesGrid,
  24784. previousIndex,
  24785. activeIndex,
  24786. rtlTranslate: rtl,
  24787. wrapperEl,
  24788. enabled
  24789. } = swiper;
  24790. if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
  24791. return false;
  24792. }
  24793. const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
  24794. let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
  24795. if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
  24796. const translate = -snapGrid[snapIndex];
  24797. // Normalize slideIndex
  24798. if (params.normalizeSlideIndex) {
  24799. for (let i = 0; i < slidesGrid.length; i += 1) {
  24800. const normalizedTranslate = -Math.floor(translate * 100);
  24801. const normalizedGrid = Math.floor(slidesGrid[i] * 100);
  24802. const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
  24803. if (typeof slidesGrid[i + 1] !== 'undefined') {
  24804. if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
  24805. slideIndex = i;
  24806. } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
  24807. slideIndex = i + 1;
  24808. }
  24809. } else if (normalizedTranslate >= normalizedGrid) {
  24810. slideIndex = i;
  24811. }
  24812. }
  24813. }
  24814. // Directions locks
  24815. if (swiper.initialized && slideIndex !== activeIndex) {
  24816. if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
  24817. return false;
  24818. }
  24819. if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
  24820. if ((activeIndex || 0) !== slideIndex) {
  24821. return false;
  24822. }
  24823. }
  24824. }
  24825. if (slideIndex !== (previousIndex || 0) && runCallbacks) {
  24826. swiper.emit('beforeSlideChangeStart');
  24827. }
  24828. // Update progress
  24829. swiper.updateProgress(translate);
  24830. let direction;
  24831. if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
  24832. // Update Index
  24833. if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
  24834. swiper.updateActiveIndex(slideIndex);
  24835. // Update Height
  24836. if (params.autoHeight) {
  24837. swiper.updateAutoHeight();
  24838. }
  24839. swiper.updateSlidesClasses();
  24840. if (params.effect !== 'slide') {
  24841. swiper.setTranslate(translate);
  24842. }
  24843. if (direction !== 'reset') {
  24844. swiper.transitionStart(runCallbacks, direction);
  24845. swiper.transitionEnd(runCallbacks, direction);
  24846. }
  24847. return false;
  24848. }
  24849. if (params.cssMode) {
  24850. const isH = swiper.isHorizontal();
  24851. const t = rtl ? translate : -translate;
  24852. if (speed === 0) {
  24853. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  24854. if (isVirtual) {
  24855. swiper.wrapperEl.style.scrollSnapType = 'none';
  24856. swiper._immediateVirtual = true;
  24857. }
  24858. if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
  24859. swiper._cssModeVirtualInitialSet = true;
  24860. requestAnimationFrame(() => {
  24861. wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
  24862. });
  24863. } else {
  24864. wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
  24865. }
  24866. if (isVirtual) {
  24867. requestAnimationFrame(() => {
  24868. swiper.wrapperEl.style.scrollSnapType = '';
  24869. swiper._immediateVirtual = false;
  24870. });
  24871. }
  24872. } else {
  24873. if (!swiper.support.smoothScroll) {
  24874. animateCSSModeScroll({
  24875. swiper,
  24876. targetPosition: t,
  24877. side: isH ? 'left' : 'top'
  24878. });
  24879. return true;
  24880. }
  24881. wrapperEl.scrollTo({
  24882. [isH ? 'left' : 'top']: t,
  24883. behavior: 'smooth'
  24884. });
  24885. }
  24886. return true;
  24887. }
  24888. swiper.setTransition(speed);
  24889. swiper.setTranslate(translate);
  24890. swiper.updateActiveIndex(slideIndex);
  24891. swiper.updateSlidesClasses();
  24892. swiper.emit('beforeTransitionStart', speed, internal);
  24893. swiper.transitionStart(runCallbacks, direction);
  24894. if (speed === 0) {
  24895. swiper.transitionEnd(runCallbacks, direction);
  24896. } else if (!swiper.animating) {
  24897. swiper.animating = true;
  24898. if (!swiper.onSlideToWrapperTransitionEnd) {
  24899. swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
  24900. if (!swiper || swiper.destroyed) return;
  24901. if (e.target !== this) return;
  24902. swiper.wrapperEl.removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
  24903. swiper.onSlideToWrapperTransitionEnd = null;
  24904. delete swiper.onSlideToWrapperTransitionEnd;
  24905. swiper.transitionEnd(runCallbacks, direction);
  24906. };
  24907. }
  24908. swiper.wrapperEl.addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
  24909. }
  24910. return true;
  24911. }
  24912. function slideToLoop(index, speed, runCallbacks, internal) {
  24913. if (index === void 0) {
  24914. index = 0;
  24915. }
  24916. if (speed === void 0) {
  24917. speed = this.params.speed;
  24918. }
  24919. if (runCallbacks === void 0) {
  24920. runCallbacks = true;
  24921. }
  24922. if (typeof index === 'string') {
  24923. const indexAsNumber = parseInt(index, 10);
  24924. index = indexAsNumber;
  24925. }
  24926. const swiper = this;
  24927. const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
  24928. let newIndex = index;
  24929. if (swiper.params.loop) {
  24930. if (swiper.virtual && swiper.params.virtual.enabled) {
  24931. // eslint-disable-next-line
  24932. newIndex = newIndex + swiper.virtual.slidesBefore;
  24933. } else {
  24934. let targetSlideIndex;
  24935. if (gridEnabled) {
  24936. const slideIndex = newIndex * swiper.params.grid.rows;
  24937. targetSlideIndex = swiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex)[0].column;
  24938. } else {
  24939. targetSlideIndex = swiper.getSlideIndexByData(newIndex);
  24940. }
  24941. const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
  24942. const {
  24943. centeredSlides
  24944. } = swiper.params;
  24945. let slidesPerView = swiper.params.slidesPerView;
  24946. if (slidesPerView === 'auto') {
  24947. slidesPerView = swiper.slidesPerViewDynamic();
  24948. } else {
  24949. slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
  24950. if (centeredSlides && slidesPerView % 2 === 0) {
  24951. slidesPerView = slidesPerView + 1;
  24952. }
  24953. }
  24954. let needLoopFix = cols - targetSlideIndex < slidesPerView;
  24955. if (centeredSlides) {
  24956. needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
  24957. }
  24958. if (needLoopFix) {
  24959. const direction = centeredSlides ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
  24960. swiper.loopFix({
  24961. direction,
  24962. slideTo: true,
  24963. activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
  24964. slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
  24965. });
  24966. }
  24967. if (gridEnabled) {
  24968. const slideIndex = newIndex * swiper.params.grid.rows;
  24969. newIndex = swiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex)[0].column;
  24970. } else {
  24971. newIndex = swiper.getSlideIndexByData(newIndex);
  24972. }
  24973. }
  24974. }
  24975. requestAnimationFrame(() => {
  24976. swiper.slideTo(newIndex, speed, runCallbacks, internal);
  24977. });
  24978. return swiper;
  24979. }
  24980. /* eslint no-unused-vars: "off" */
  24981. function slideNext(speed, runCallbacks, internal) {
  24982. if (speed === void 0) {
  24983. speed = this.params.speed;
  24984. }
  24985. if (runCallbacks === void 0) {
  24986. runCallbacks = true;
  24987. }
  24988. const swiper = this;
  24989. const {
  24990. enabled,
  24991. params,
  24992. animating
  24993. } = swiper;
  24994. if (!enabled) return swiper;
  24995. let perGroup = params.slidesPerGroup;
  24996. if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
  24997. perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
  24998. }
  24999. const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
  25000. const isVirtual = swiper.virtual && params.virtual.enabled;
  25001. if (params.loop) {
  25002. if (animating && !isVirtual && params.loopPreventsSliding) return false;
  25003. swiper.loopFix({
  25004. direction: 'next'
  25005. });
  25006. // eslint-disable-next-line
  25007. swiper._clientLeft = swiper.wrapperEl.clientLeft;
  25008. if (swiper.activeIndex === swiper.slides.length - 1 && params.cssMode) {
  25009. requestAnimationFrame(() => {
  25010. swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
  25011. });
  25012. return true;
  25013. }
  25014. }
  25015. if (params.rewind && swiper.isEnd) {
  25016. return swiper.slideTo(0, speed, runCallbacks, internal);
  25017. }
  25018. return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
  25019. }
  25020. /* eslint no-unused-vars: "off" */
  25021. function slidePrev(speed, runCallbacks, internal) {
  25022. if (speed === void 0) {
  25023. speed = this.params.speed;
  25024. }
  25025. if (runCallbacks === void 0) {
  25026. runCallbacks = true;
  25027. }
  25028. const swiper = this;
  25029. const {
  25030. params,
  25031. snapGrid,
  25032. slidesGrid,
  25033. rtlTranslate,
  25034. enabled,
  25035. animating
  25036. } = swiper;
  25037. if (!enabled) return swiper;
  25038. const isVirtual = swiper.virtual && params.virtual.enabled;
  25039. if (params.loop) {
  25040. if (animating && !isVirtual && params.loopPreventsSliding) return false;
  25041. swiper.loopFix({
  25042. direction: 'prev'
  25043. });
  25044. // eslint-disable-next-line
  25045. swiper._clientLeft = swiper.wrapperEl.clientLeft;
  25046. }
  25047. const translate = rtlTranslate ? swiper.translate : -swiper.translate;
  25048. function normalize(val) {
  25049. if (val < 0) return -Math.floor(Math.abs(val));
  25050. return Math.floor(val);
  25051. }
  25052. const normalizedTranslate = normalize(translate);
  25053. const normalizedSnapGrid = snapGrid.map(val => normalize(val));
  25054. let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
  25055. if (typeof prevSnap === 'undefined' && params.cssMode) {
  25056. let prevSnapIndex;
  25057. snapGrid.forEach((snap, snapIndex) => {
  25058. if (normalizedTranslate >= snap) {
  25059. // prevSnap = snap;
  25060. prevSnapIndex = snapIndex;
  25061. }
  25062. });
  25063. if (typeof prevSnapIndex !== 'undefined') {
  25064. prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
  25065. }
  25066. }
  25067. let prevIndex = 0;
  25068. if (typeof prevSnap !== 'undefined') {
  25069. prevIndex = slidesGrid.indexOf(prevSnap);
  25070. if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
  25071. if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
  25072. prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
  25073. prevIndex = Math.max(prevIndex, 0);
  25074. }
  25075. }
  25076. if (params.rewind && swiper.isBeginning) {
  25077. const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
  25078. return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
  25079. } else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
  25080. requestAnimationFrame(() => {
  25081. swiper.slideTo(prevIndex, speed, runCallbacks, internal);
  25082. });
  25083. return true;
  25084. }
  25085. return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
  25086. }
  25087. /* eslint no-unused-vars: "off" */
  25088. function slideReset(speed, runCallbacks, internal) {
  25089. if (speed === void 0) {
  25090. speed = this.params.speed;
  25091. }
  25092. if (runCallbacks === void 0) {
  25093. runCallbacks = true;
  25094. }
  25095. const swiper = this;
  25096. return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
  25097. }
  25098. /* eslint no-unused-vars: "off" */
  25099. function slideToClosest(speed, runCallbacks, internal, threshold) {
  25100. if (speed === void 0) {
  25101. speed = this.params.speed;
  25102. }
  25103. if (runCallbacks === void 0) {
  25104. runCallbacks = true;
  25105. }
  25106. if (threshold === void 0) {
  25107. threshold = 0.5;
  25108. }
  25109. const swiper = this;
  25110. let index = swiper.activeIndex;
  25111. const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
  25112. const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
  25113. const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
  25114. if (translate >= swiper.snapGrid[snapIndex]) {
  25115. // The current translate is on or after the current snap index, so the choice
  25116. // is between the current index and the one after it.
  25117. const currentSnap = swiper.snapGrid[snapIndex];
  25118. const nextSnap = swiper.snapGrid[snapIndex + 1];
  25119. if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
  25120. index += swiper.params.slidesPerGroup;
  25121. }
  25122. } else {
  25123. // The current translate is before the current snap index, so the choice
  25124. // is between the current index and the one before it.
  25125. const prevSnap = swiper.snapGrid[snapIndex - 1];
  25126. const currentSnap = swiper.snapGrid[snapIndex];
  25127. if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
  25128. index -= swiper.params.slidesPerGroup;
  25129. }
  25130. }
  25131. index = Math.max(index, 0);
  25132. index = Math.min(index, swiper.slidesGrid.length - 1);
  25133. return swiper.slideTo(index, speed, runCallbacks, internal);
  25134. }
  25135. function slideToClickedSlide() {
  25136. const swiper = this;
  25137. const {
  25138. params,
  25139. slidesEl
  25140. } = swiper;
  25141. const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
  25142. let slideToIndex = swiper.clickedIndex;
  25143. let realIndex;
  25144. const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
  25145. if (params.loop) {
  25146. if (swiper.animating) return;
  25147. realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
  25148. if (params.centeredSlides) {
  25149. if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
  25150. swiper.loopFix();
  25151. slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
  25152. nextTick(() => {
  25153. swiper.slideTo(slideToIndex);
  25154. });
  25155. } else {
  25156. swiper.slideTo(slideToIndex);
  25157. }
  25158. } else if (slideToIndex > swiper.slides.length - slidesPerView) {
  25159. swiper.loopFix();
  25160. slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
  25161. nextTick(() => {
  25162. swiper.slideTo(slideToIndex);
  25163. });
  25164. } else {
  25165. swiper.slideTo(slideToIndex);
  25166. }
  25167. } else {
  25168. swiper.slideTo(slideToIndex);
  25169. }
  25170. }
  25171. var slide = {
  25172. slideTo,
  25173. slideToLoop,
  25174. slideNext,
  25175. slidePrev,
  25176. slideReset,
  25177. slideToClosest,
  25178. slideToClickedSlide
  25179. };
  25180. function loopCreate(slideRealIndex) {
  25181. const swiper = this;
  25182. const {
  25183. params,
  25184. slidesEl
  25185. } = swiper;
  25186. if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
  25187. const initSlides = () => {
  25188. const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
  25189. slides.forEach((el, index) => {
  25190. el.setAttribute('data-swiper-slide-index', index);
  25191. });
  25192. };
  25193. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  25194. const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
  25195. const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
  25196. const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
  25197. const addBlankSlides = amountOfSlides => {
  25198. for (let i = 0; i < amountOfSlides; i += 1) {
  25199. const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
  25200. swiper.slidesEl.append(slideEl);
  25201. }
  25202. };
  25203. if (shouldFillGroup) {
  25204. if (params.loopAddBlankSlides) {
  25205. const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
  25206. addBlankSlides(slidesToAdd);
  25207. swiper.recalcSlides();
  25208. swiper.updateSlides();
  25209. } else {
  25210. showWarning('Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
  25211. }
  25212. initSlides();
  25213. } else if (shouldFillGrid) {
  25214. if (params.loopAddBlankSlides) {
  25215. const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
  25216. addBlankSlides(slidesToAdd);
  25217. swiper.recalcSlides();
  25218. swiper.updateSlides();
  25219. } else {
  25220. showWarning('Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
  25221. }
  25222. initSlides();
  25223. } else {
  25224. initSlides();
  25225. }
  25226. swiper.loopFix({
  25227. slideRealIndex,
  25228. direction: params.centeredSlides ? undefined : 'next'
  25229. });
  25230. }
  25231. function loopFix(_temp) {
  25232. let {
  25233. slideRealIndex,
  25234. slideTo = true,
  25235. direction,
  25236. setTranslate,
  25237. activeSlideIndex,
  25238. byController,
  25239. byMousewheel
  25240. } = _temp === void 0 ? {} : _temp;
  25241. const swiper = this;
  25242. if (!swiper.params.loop) return;
  25243. swiper.emit('beforeLoopFix');
  25244. const {
  25245. slides,
  25246. allowSlidePrev,
  25247. allowSlideNext,
  25248. slidesEl,
  25249. params
  25250. } = swiper;
  25251. const {
  25252. centeredSlides
  25253. } = params;
  25254. swiper.allowSlidePrev = true;
  25255. swiper.allowSlideNext = true;
  25256. if (swiper.virtual && params.virtual.enabled) {
  25257. if (slideTo) {
  25258. if (!params.centeredSlides && swiper.snapIndex === 0) {
  25259. swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
  25260. } else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
  25261. swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
  25262. } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
  25263. swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
  25264. }
  25265. }
  25266. swiper.allowSlidePrev = allowSlidePrev;
  25267. swiper.allowSlideNext = allowSlideNext;
  25268. swiper.emit('loopFix');
  25269. return;
  25270. }
  25271. let slidesPerView = params.slidesPerView;
  25272. if (slidesPerView === 'auto') {
  25273. slidesPerView = swiper.slidesPerViewDynamic();
  25274. } else {
  25275. slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
  25276. if (centeredSlides && slidesPerView % 2 === 0) {
  25277. slidesPerView = slidesPerView + 1;
  25278. }
  25279. }
  25280. const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
  25281. let loopedSlides = slidesPerGroup;
  25282. if (loopedSlides % slidesPerGroup !== 0) {
  25283. loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
  25284. }
  25285. loopedSlides += params.loopAdditionalSlides;
  25286. swiper.loopedSlides = loopedSlides;
  25287. const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
  25288. if (slides.length < slidesPerView + loopedSlides) {
  25289. showWarning('Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters');
  25290. } else if (gridEnabled && params.grid.fill === 'row') {
  25291. showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
  25292. }
  25293. const prependSlidesIndexes = [];
  25294. const appendSlidesIndexes = [];
  25295. let activeIndex = swiper.activeIndex;
  25296. if (typeof activeSlideIndex === 'undefined') {
  25297. activeSlideIndex = swiper.getSlideIndex(slides.filter(el => el.classList.contains(params.slideActiveClass))[0]);
  25298. } else {
  25299. activeIndex = activeSlideIndex;
  25300. }
  25301. const isNext = direction === 'next' || !direction;
  25302. const isPrev = direction === 'prev' || !direction;
  25303. let slidesPrepended = 0;
  25304. let slidesAppended = 0;
  25305. const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
  25306. const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
  25307. const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
  25308. // prepend last slides before start
  25309. if (activeColIndexWithShift < loopedSlides) {
  25310. slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
  25311. for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
  25312. const index = i - Math.floor(i / cols) * cols;
  25313. if (gridEnabled) {
  25314. const colIndexToPrepend = cols - index - 1;
  25315. for (let i = slides.length - 1; i >= 0; i -= 1) {
  25316. if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
  25317. }
  25318. // slides.forEach((slide, slideIndex) => {
  25319. // if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
  25320. // });
  25321. } else {
  25322. prependSlidesIndexes.push(cols - index - 1);
  25323. }
  25324. }
  25325. } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
  25326. slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
  25327. for (let i = 0; i < slidesAppended; i += 1) {
  25328. const index = i - Math.floor(i / cols) * cols;
  25329. if (gridEnabled) {
  25330. slides.forEach((slide, slideIndex) => {
  25331. if (slide.column === index) appendSlidesIndexes.push(slideIndex);
  25332. });
  25333. } else {
  25334. appendSlidesIndexes.push(index);
  25335. }
  25336. }
  25337. }
  25338. swiper.__preventObserver__ = true;
  25339. requestAnimationFrame(() => {
  25340. swiper.__preventObserver__ = false;
  25341. });
  25342. if (isPrev) {
  25343. prependSlidesIndexes.forEach(index => {
  25344. slides[index].swiperLoopMoveDOM = true;
  25345. slidesEl.prepend(slides[index]);
  25346. slides[index].swiperLoopMoveDOM = false;
  25347. });
  25348. }
  25349. if (isNext) {
  25350. appendSlidesIndexes.forEach(index => {
  25351. slides[index].swiperLoopMoveDOM = true;
  25352. slidesEl.append(slides[index]);
  25353. slides[index].swiperLoopMoveDOM = false;
  25354. });
  25355. }
  25356. swiper.recalcSlides();
  25357. if (params.slidesPerView === 'auto') {
  25358. swiper.updateSlides();
  25359. } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
  25360. swiper.slides.forEach((slide, slideIndex) => {
  25361. swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
  25362. });
  25363. }
  25364. if (params.watchSlidesProgress) {
  25365. swiper.updateSlidesOffset();
  25366. }
  25367. if (slideTo) {
  25368. if (prependSlidesIndexes.length > 0 && isPrev) {
  25369. if (typeof slideRealIndex === 'undefined') {
  25370. const currentSlideTranslate = swiper.slidesGrid[activeIndex];
  25371. const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended];
  25372. const diff = newSlideTranslate - currentSlideTranslate;
  25373. if (byMousewheel) {
  25374. swiper.setTranslate(swiper.translate - diff);
  25375. } else {
  25376. swiper.slideTo(activeIndex + slidesPrepended, 0, false, true);
  25377. if (setTranslate) {
  25378. swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
  25379. swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
  25380. }
  25381. }
  25382. } else {
  25383. if (setTranslate) {
  25384. const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
  25385. swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
  25386. swiper.touchEventsData.currentTranslate = swiper.translate;
  25387. }
  25388. }
  25389. } else if (appendSlidesIndexes.length > 0 && isNext) {
  25390. if (typeof slideRealIndex === 'undefined') {
  25391. const currentSlideTranslate = swiper.slidesGrid[activeIndex];
  25392. const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended];
  25393. const diff = newSlideTranslate - currentSlideTranslate;
  25394. if (byMousewheel) {
  25395. swiper.setTranslate(swiper.translate - diff);
  25396. } else {
  25397. swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
  25398. if (setTranslate) {
  25399. swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
  25400. swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
  25401. }
  25402. }
  25403. } else {
  25404. const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
  25405. swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
  25406. }
  25407. }
  25408. }
  25409. swiper.allowSlidePrev = allowSlidePrev;
  25410. swiper.allowSlideNext = allowSlideNext;
  25411. if (swiper.controller && swiper.controller.control && !byController) {
  25412. const loopParams = {
  25413. slideRealIndex,
  25414. direction,
  25415. setTranslate,
  25416. activeSlideIndex,
  25417. byController: true
  25418. };
  25419. if (Array.isArray(swiper.controller.control)) {
  25420. swiper.controller.control.forEach(c => {
  25421. if (!c.destroyed && c.params.loop) c.loopFix({
  25422. ...loopParams,
  25423. slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
  25424. });
  25425. });
  25426. } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
  25427. swiper.controller.control.loopFix({
  25428. ...loopParams,
  25429. slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
  25430. });
  25431. }
  25432. }
  25433. swiper.emit('loopFix');
  25434. }
  25435. function loopDestroy() {
  25436. const swiper = this;
  25437. const {
  25438. params,
  25439. slidesEl
  25440. } = swiper;
  25441. if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
  25442. swiper.recalcSlides();
  25443. const newSlidesOrder = [];
  25444. swiper.slides.forEach(slideEl => {
  25445. const index = typeof slideEl.swiperSlideIndex === 'undefined' ? slideEl.getAttribute('data-swiper-slide-index') * 1 : slideEl.swiperSlideIndex;
  25446. newSlidesOrder[index] = slideEl;
  25447. });
  25448. swiper.slides.forEach(slideEl => {
  25449. slideEl.removeAttribute('data-swiper-slide-index');
  25450. });
  25451. newSlidesOrder.forEach(slideEl => {
  25452. slidesEl.append(slideEl);
  25453. });
  25454. swiper.recalcSlides();
  25455. swiper.slideTo(swiper.realIndex, 0);
  25456. }
  25457. var loop = {
  25458. loopCreate,
  25459. loopFix,
  25460. loopDestroy
  25461. };
  25462. function setGrabCursor(moving) {
  25463. const swiper = this;
  25464. if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
  25465. const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
  25466. if (swiper.isElement) {
  25467. swiper.__preventObserver__ = true;
  25468. }
  25469. el.style.cursor = 'move';
  25470. el.style.cursor = moving ? 'grabbing' : 'grab';
  25471. if (swiper.isElement) {
  25472. requestAnimationFrame(() => {
  25473. swiper.__preventObserver__ = false;
  25474. });
  25475. }
  25476. }
  25477. function unsetGrabCursor() {
  25478. const swiper = this;
  25479. if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
  25480. return;
  25481. }
  25482. if (swiper.isElement) {
  25483. swiper.__preventObserver__ = true;
  25484. }
  25485. swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
  25486. if (swiper.isElement) {
  25487. requestAnimationFrame(() => {
  25488. swiper.__preventObserver__ = false;
  25489. });
  25490. }
  25491. }
  25492. var grabCursor = {
  25493. setGrabCursor,
  25494. unsetGrabCursor
  25495. };
  25496. // Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
  25497. function closestElement(selector, base) {
  25498. if (base === void 0) {
  25499. base = this;
  25500. }
  25501. function __closestFrom(el) {
  25502. if (!el || el === getDocument() || el === getWindow()) return null;
  25503. if (el.assignedSlot) el = el.assignedSlot;
  25504. const found = el.closest(selector);
  25505. if (!found && !el.getRootNode) {
  25506. return null;
  25507. }
  25508. return found || __closestFrom(el.getRootNode().host);
  25509. }
  25510. return __closestFrom(base);
  25511. }
  25512. function preventEdgeSwipe(swiper, event, startX) {
  25513. const window = getWindow();
  25514. const {
  25515. params
  25516. } = swiper;
  25517. const edgeSwipeDetection = params.edgeSwipeDetection;
  25518. const edgeSwipeThreshold = params.edgeSwipeThreshold;
  25519. if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
  25520. if (edgeSwipeDetection === 'prevent') {
  25521. event.preventDefault();
  25522. return true;
  25523. }
  25524. return false;
  25525. }
  25526. return true;
  25527. }
  25528. function onTouchStart(event) {
  25529. const swiper = this;
  25530. const document = getDocument();
  25531. let e = event;
  25532. if (e.originalEvent) e = e.originalEvent;
  25533. const data = swiper.touchEventsData;
  25534. if (e.type === 'pointerdown') {
  25535. if (data.pointerId !== null && data.pointerId !== e.pointerId) {
  25536. return;
  25537. }
  25538. data.pointerId = e.pointerId;
  25539. } else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
  25540. data.touchId = e.targetTouches[0].identifier;
  25541. }
  25542. if (e.type === 'touchstart') {
  25543. // don't proceed touch event
  25544. preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
  25545. return;
  25546. }
  25547. const {
  25548. params,
  25549. touches,
  25550. enabled
  25551. } = swiper;
  25552. if (!enabled) return;
  25553. if (!params.simulateTouch && e.pointerType === 'mouse') return;
  25554. if (swiper.animating && params.preventInteractionOnTransition) {
  25555. return;
  25556. }
  25557. if (!swiper.animating && params.cssMode && params.loop) {
  25558. swiper.loopFix();
  25559. }
  25560. let targetEl = e.target;
  25561. if (params.touchEventsTarget === 'wrapper') {
  25562. if (!swiper.wrapperEl.contains(targetEl)) return;
  25563. }
  25564. if ('which' in e && e.which === 3) return;
  25565. if ('button' in e && e.button > 0) return;
  25566. if (data.isTouched && data.isMoved) return;
  25567. // change target el for shadow root component
  25568. const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
  25569. // eslint-disable-next-line
  25570. const eventPath = e.composedPath ? e.composedPath() : e.path;
  25571. if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
  25572. targetEl = eventPath[0];
  25573. }
  25574. const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
  25575. const isTargetShadow = !!(e.target && e.target.shadowRoot);
  25576. // use closestElement for shadow root element to get the actual closest for nested shadow root element
  25577. if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
  25578. swiper.allowClick = true;
  25579. return;
  25580. }
  25581. if (params.swipeHandler) {
  25582. if (!targetEl.closest(params.swipeHandler)) return;
  25583. }
  25584. touches.currentX = e.pageX;
  25585. touches.currentY = e.pageY;
  25586. const startX = touches.currentX;
  25587. const startY = touches.currentY;
  25588. // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
  25589. if (!preventEdgeSwipe(swiper, e, startX)) {
  25590. return;
  25591. }
  25592. Object.assign(data, {
  25593. isTouched: true,
  25594. isMoved: false,
  25595. allowTouchCallbacks: true,
  25596. isScrolling: undefined,
  25597. startMoving: undefined
  25598. });
  25599. touches.startX = startX;
  25600. touches.startY = startY;
  25601. data.touchStartTime = now();
  25602. swiper.allowClick = true;
  25603. swiper.updateSize();
  25604. swiper.swipeDirection = undefined;
  25605. if (params.threshold > 0) data.allowThresholdMove = false;
  25606. let preventDefault = true;
  25607. if (targetEl.matches(data.focusableElements)) {
  25608. preventDefault = false;
  25609. if (targetEl.nodeName === 'SELECT') {
  25610. data.isTouched = false;
  25611. }
  25612. }
  25613. if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== targetEl) {
  25614. document.activeElement.blur();
  25615. }
  25616. const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
  25617. if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
  25618. e.preventDefault();
  25619. }
  25620. if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
  25621. swiper.freeMode.onTouchStart();
  25622. }
  25623. swiper.emit('touchStart', e);
  25624. }
  25625. function onTouchMove(event) {
  25626. const document = getDocument();
  25627. const swiper = this;
  25628. const data = swiper.touchEventsData;
  25629. const {
  25630. params,
  25631. touches,
  25632. rtlTranslate: rtl,
  25633. enabled
  25634. } = swiper;
  25635. if (!enabled) return;
  25636. if (!params.simulateTouch && event.pointerType === 'mouse') return;
  25637. let e = event;
  25638. if (e.originalEvent) e = e.originalEvent;
  25639. if (e.type === 'pointermove') {
  25640. if (data.touchId !== null) return; // return from pointer if we use touch
  25641. const id = e.pointerId;
  25642. if (id !== data.pointerId) return;
  25643. }
  25644. let targetTouch;
  25645. if (e.type === 'touchmove') {
  25646. targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
  25647. if (!targetTouch || targetTouch.identifier !== data.touchId) return;
  25648. } else {
  25649. targetTouch = e;
  25650. }
  25651. if (!data.isTouched) {
  25652. if (data.startMoving && data.isScrolling) {
  25653. swiper.emit('touchMoveOpposite', e);
  25654. }
  25655. return;
  25656. }
  25657. const pageX = targetTouch.pageX;
  25658. const pageY = targetTouch.pageY;
  25659. if (e.preventedByNestedSwiper) {
  25660. touches.startX = pageX;
  25661. touches.startY = pageY;
  25662. return;
  25663. }
  25664. if (!swiper.allowTouchMove) {
  25665. if (!e.target.matches(data.focusableElements)) {
  25666. swiper.allowClick = false;
  25667. }
  25668. if (data.isTouched) {
  25669. Object.assign(touches, {
  25670. startX: pageX,
  25671. startY: pageY,
  25672. currentX: pageX,
  25673. currentY: pageY
  25674. });
  25675. data.touchStartTime = now();
  25676. }
  25677. return;
  25678. }
  25679. if (params.touchReleaseOnEdges && !params.loop) {
  25680. if (swiper.isVertical()) {
  25681. // Vertical
  25682. if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
  25683. data.isTouched = false;
  25684. data.isMoved = false;
  25685. return;
  25686. }
  25687. } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
  25688. return;
  25689. }
  25690. }
  25691. if (document.activeElement) {
  25692. if (e.target === document.activeElement && e.target.matches(data.focusableElements)) {
  25693. data.isMoved = true;
  25694. swiper.allowClick = false;
  25695. return;
  25696. }
  25697. }
  25698. if (data.allowTouchCallbacks) {
  25699. swiper.emit('touchMove', e);
  25700. }
  25701. touches.previousX = touches.currentX;
  25702. touches.previousY = touches.currentY;
  25703. touches.currentX = pageX;
  25704. touches.currentY = pageY;
  25705. const diffX = touches.currentX - touches.startX;
  25706. const diffY = touches.currentY - touches.startY;
  25707. if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
  25708. if (typeof data.isScrolling === 'undefined') {
  25709. let touchAngle;
  25710. if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
  25711. data.isScrolling = false;
  25712. } else {
  25713. // eslint-disable-next-line
  25714. if (diffX * diffX + diffY * diffY >= 25) {
  25715. touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
  25716. data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
  25717. }
  25718. }
  25719. }
  25720. if (data.isScrolling) {
  25721. swiper.emit('touchMoveOpposite', e);
  25722. }
  25723. if (typeof data.startMoving === 'undefined') {
  25724. if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
  25725. data.startMoving = true;
  25726. }
  25727. }
  25728. if (data.isScrolling) {
  25729. data.isTouched = false;
  25730. return;
  25731. }
  25732. if (!data.startMoving) {
  25733. return;
  25734. }
  25735. swiper.allowClick = false;
  25736. if (!params.cssMode && e.cancelable) {
  25737. e.preventDefault();
  25738. }
  25739. if (params.touchMoveStopPropagation && !params.nested) {
  25740. e.stopPropagation();
  25741. }
  25742. let diff = swiper.isHorizontal() ? diffX : diffY;
  25743. let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
  25744. if (params.oneWayMovement) {
  25745. diff = Math.abs(diff) * (rtl ? 1 : -1);
  25746. touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
  25747. }
  25748. touches.diff = diff;
  25749. diff *= params.touchRatio;
  25750. if (rtl) {
  25751. diff = -diff;
  25752. touchesDiff = -touchesDiff;
  25753. }
  25754. const prevTouchesDirection = swiper.touchesDirection;
  25755. swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
  25756. swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
  25757. const isLoop = swiper.params.loop && !params.cssMode;
  25758. const allowLoopFix = swiper.touchesDirection === 'next' && swiper.allowSlideNext || swiper.touchesDirection === 'prev' && swiper.allowSlidePrev;
  25759. if (!data.isMoved) {
  25760. if (isLoop && allowLoopFix) {
  25761. swiper.loopFix({
  25762. direction: swiper.swipeDirection
  25763. });
  25764. }
  25765. data.startTranslate = swiper.getTranslate();
  25766. swiper.setTransition(0);
  25767. if (swiper.animating) {
  25768. const evt = new window.CustomEvent('transitionend', {
  25769. bubbles: true,
  25770. cancelable: true
  25771. });
  25772. swiper.wrapperEl.dispatchEvent(evt);
  25773. }
  25774. data.allowMomentumBounce = false;
  25775. // Grab Cursor
  25776. if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
  25777. swiper.setGrabCursor(true);
  25778. }
  25779. swiper.emit('sliderFirstMove', e);
  25780. }
  25781. let loopFixed;
  25782. new Date().getTime();
  25783. if (data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
  25784. Object.assign(touches, {
  25785. startX: pageX,
  25786. startY: pageY,
  25787. currentX: pageX,
  25788. currentY: pageY,
  25789. startTranslate: data.currentTranslate
  25790. });
  25791. data.loopSwapReset = true;
  25792. data.startTranslate = data.currentTranslate;
  25793. return;
  25794. }
  25795. swiper.emit('sliderMove', e);
  25796. data.isMoved = true;
  25797. data.currentTranslate = diff + data.startTranslate;
  25798. let disableParentSwiper = true;
  25799. let resistanceRatio = params.resistanceRatio;
  25800. if (params.touchReleaseOnEdges) {
  25801. resistanceRatio = 0;
  25802. }
  25803. if (diff > 0) {
  25804. if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] : swiper.minTranslate())) {
  25805. swiper.loopFix({
  25806. direction: 'prev',
  25807. setTranslate: true,
  25808. activeSlideIndex: 0
  25809. });
  25810. }
  25811. if (data.currentTranslate > swiper.minTranslate()) {
  25812. disableParentSwiper = false;
  25813. if (params.resistance) {
  25814. data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
  25815. }
  25816. }
  25817. } else if (diff < 0) {
  25818. if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] : swiper.maxTranslate())) {
  25819. swiper.loopFix({
  25820. direction: 'next',
  25821. setTranslate: true,
  25822. activeSlideIndex: swiper.slides.length - (params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
  25823. });
  25824. }
  25825. if (data.currentTranslate < swiper.maxTranslate()) {
  25826. disableParentSwiper = false;
  25827. if (params.resistance) {
  25828. data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
  25829. }
  25830. }
  25831. }
  25832. if (disableParentSwiper) {
  25833. e.preventedByNestedSwiper = true;
  25834. }
  25835. // Directions locks
  25836. if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
  25837. data.currentTranslate = data.startTranslate;
  25838. }
  25839. if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
  25840. data.currentTranslate = data.startTranslate;
  25841. }
  25842. if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
  25843. data.currentTranslate = data.startTranslate;
  25844. }
  25845. // Threshold
  25846. if (params.threshold > 0) {
  25847. if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
  25848. if (!data.allowThresholdMove) {
  25849. data.allowThresholdMove = true;
  25850. touches.startX = touches.currentX;
  25851. touches.startY = touches.currentY;
  25852. data.currentTranslate = data.startTranslate;
  25853. touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
  25854. return;
  25855. }
  25856. } else {
  25857. data.currentTranslate = data.startTranslate;
  25858. return;
  25859. }
  25860. }
  25861. if (!params.followFinger || params.cssMode) return;
  25862. // Update active index in free mode
  25863. if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
  25864. swiper.updateActiveIndex();
  25865. swiper.updateSlidesClasses();
  25866. }
  25867. if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
  25868. swiper.freeMode.onTouchMove();
  25869. }
  25870. // Update progress
  25871. swiper.updateProgress(data.currentTranslate);
  25872. // Update translate
  25873. swiper.setTranslate(data.currentTranslate);
  25874. }
  25875. function onTouchEnd(event) {
  25876. const swiper = this;
  25877. const data = swiper.touchEventsData;
  25878. let e = event;
  25879. if (e.originalEvent) e = e.originalEvent;
  25880. let targetTouch;
  25881. const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
  25882. if (!isTouchEvent) {
  25883. if (data.touchId !== null) return; // return from pointer if we use touch
  25884. if (e.pointerId !== data.pointerId) return;
  25885. targetTouch = e;
  25886. } else {
  25887. targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
  25888. if (!targetTouch || targetTouch.identifier !== data.touchId) return;
  25889. }
  25890. if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
  25891. const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
  25892. if (!proceed) {
  25893. return;
  25894. }
  25895. }
  25896. data.pointerId = null;
  25897. data.touchId = null;
  25898. const {
  25899. params,
  25900. touches,
  25901. rtlTranslate: rtl,
  25902. slidesGrid,
  25903. enabled
  25904. } = swiper;
  25905. if (!enabled) return;
  25906. if (!params.simulateTouch && e.pointerType === 'mouse') return;
  25907. if (data.allowTouchCallbacks) {
  25908. swiper.emit('touchEnd', e);
  25909. }
  25910. data.allowTouchCallbacks = false;
  25911. if (!data.isTouched) {
  25912. if (data.isMoved && params.grabCursor) {
  25913. swiper.setGrabCursor(false);
  25914. }
  25915. data.isMoved = false;
  25916. data.startMoving = false;
  25917. return;
  25918. }
  25919. // Return Grab Cursor
  25920. if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
  25921. swiper.setGrabCursor(false);
  25922. }
  25923. // Time diff
  25924. const touchEndTime = now();
  25925. const timeDiff = touchEndTime - data.touchStartTime;
  25926. // Tap, doubleTap, Click
  25927. if (swiper.allowClick) {
  25928. const pathTree = e.path || e.composedPath && e.composedPath();
  25929. swiper.updateClickedSlide(pathTree && pathTree[0] || e.target, pathTree);
  25930. swiper.emit('tap click', e);
  25931. if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
  25932. swiper.emit('doubleTap doubleClick', e);
  25933. }
  25934. }
  25935. data.lastClickTime = now();
  25936. nextTick(() => {
  25937. if (!swiper.destroyed) swiper.allowClick = true;
  25938. });
  25939. if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
  25940. data.isTouched = false;
  25941. data.isMoved = false;
  25942. data.startMoving = false;
  25943. return;
  25944. }
  25945. data.isTouched = false;
  25946. data.isMoved = false;
  25947. data.startMoving = false;
  25948. let currentPos;
  25949. if (params.followFinger) {
  25950. currentPos = rtl ? swiper.translate : -swiper.translate;
  25951. } else {
  25952. currentPos = -data.currentTranslate;
  25953. }
  25954. if (params.cssMode) {
  25955. return;
  25956. }
  25957. if (params.freeMode && params.freeMode.enabled) {
  25958. swiper.freeMode.onTouchEnd({
  25959. currentPos
  25960. });
  25961. return;
  25962. }
  25963. // Find current slide
  25964. const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
  25965. let stopIndex = 0;
  25966. let groupSize = swiper.slidesSizesGrid[0];
  25967. for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
  25968. const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
  25969. if (typeof slidesGrid[i + increment] !== 'undefined') {
  25970. if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
  25971. stopIndex = i;
  25972. groupSize = slidesGrid[i + increment] - slidesGrid[i];
  25973. }
  25974. } else if (swipeToLast || currentPos >= slidesGrid[i]) {
  25975. stopIndex = i;
  25976. groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
  25977. }
  25978. }
  25979. let rewindFirstIndex = null;
  25980. let rewindLastIndex = null;
  25981. if (params.rewind) {
  25982. if (swiper.isBeginning) {
  25983. rewindLastIndex = params.virtual && params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
  25984. } else if (swiper.isEnd) {
  25985. rewindFirstIndex = 0;
  25986. }
  25987. }
  25988. // Find current slide size
  25989. const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
  25990. const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
  25991. if (timeDiff > params.longSwipesMs) {
  25992. // Long touches
  25993. if (!params.longSwipes) {
  25994. swiper.slideTo(swiper.activeIndex);
  25995. return;
  25996. }
  25997. if (swiper.swipeDirection === 'next') {
  25998. if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
  25999. }
  26000. if (swiper.swipeDirection === 'prev') {
  26001. if (ratio > 1 - params.longSwipesRatio) {
  26002. swiper.slideTo(stopIndex + increment);
  26003. } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
  26004. swiper.slideTo(rewindLastIndex);
  26005. } else {
  26006. swiper.slideTo(stopIndex);
  26007. }
  26008. }
  26009. } else {
  26010. // Short swipes
  26011. if (!params.shortSwipes) {
  26012. swiper.slideTo(swiper.activeIndex);
  26013. return;
  26014. }
  26015. const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
  26016. if (!isNavButtonTarget) {
  26017. if (swiper.swipeDirection === 'next') {
  26018. swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
  26019. }
  26020. if (swiper.swipeDirection === 'prev') {
  26021. swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
  26022. }
  26023. } else if (e.target === swiper.navigation.nextEl) {
  26024. swiper.slideTo(stopIndex + increment);
  26025. } else {
  26026. swiper.slideTo(stopIndex);
  26027. }
  26028. }
  26029. }
  26030. function onResize() {
  26031. const swiper = this;
  26032. const {
  26033. params,
  26034. el
  26035. } = swiper;
  26036. if (el && el.offsetWidth === 0) return;
  26037. // Breakpoints
  26038. if (params.breakpoints) {
  26039. swiper.setBreakpoint();
  26040. }
  26041. // Save locks
  26042. const {
  26043. allowSlideNext,
  26044. allowSlidePrev,
  26045. snapGrid
  26046. } = swiper;
  26047. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  26048. // Disable locks on resize
  26049. swiper.allowSlideNext = true;
  26050. swiper.allowSlidePrev = true;
  26051. swiper.updateSize();
  26052. swiper.updateSlides();
  26053. swiper.updateSlidesClasses();
  26054. const isVirtualLoop = isVirtual && params.loop;
  26055. if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
  26056. swiper.slideTo(swiper.slides.length - 1, 0, false, true);
  26057. } else {
  26058. if (swiper.params.loop && !isVirtual) {
  26059. swiper.slideToLoop(swiper.realIndex, 0, false, true);
  26060. } else {
  26061. swiper.slideTo(swiper.activeIndex, 0, false, true);
  26062. }
  26063. }
  26064. if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
  26065. clearTimeout(swiper.autoplay.resizeTimeout);
  26066. swiper.autoplay.resizeTimeout = setTimeout(() => {
  26067. if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
  26068. swiper.autoplay.resume();
  26069. }
  26070. }, 500);
  26071. }
  26072. // Return locks after resize
  26073. swiper.allowSlidePrev = allowSlidePrev;
  26074. swiper.allowSlideNext = allowSlideNext;
  26075. if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
  26076. swiper.checkOverflow();
  26077. }
  26078. }
  26079. function onClick(e) {
  26080. const swiper = this;
  26081. if (!swiper.enabled) return;
  26082. if (!swiper.allowClick) {
  26083. if (swiper.params.preventClicks) e.preventDefault();
  26084. if (swiper.params.preventClicksPropagation && swiper.animating) {
  26085. e.stopPropagation();
  26086. e.stopImmediatePropagation();
  26087. }
  26088. }
  26089. }
  26090. function onScroll() {
  26091. const swiper = this;
  26092. const {
  26093. wrapperEl,
  26094. rtlTranslate,
  26095. enabled
  26096. } = swiper;
  26097. if (!enabled) return;
  26098. swiper.previousTranslate = swiper.translate;
  26099. if (swiper.isHorizontal()) {
  26100. swiper.translate = -wrapperEl.scrollLeft;
  26101. } else {
  26102. swiper.translate = -wrapperEl.scrollTop;
  26103. }
  26104. // eslint-disable-next-line
  26105. if (swiper.translate === 0) swiper.translate = 0;
  26106. swiper.updateActiveIndex();
  26107. swiper.updateSlidesClasses();
  26108. let newProgress;
  26109. const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
  26110. if (translatesDiff === 0) {
  26111. newProgress = 0;
  26112. } else {
  26113. newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
  26114. }
  26115. if (newProgress !== swiper.progress) {
  26116. swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
  26117. }
  26118. swiper.emit('setTranslate', swiper.translate, false);
  26119. }
  26120. function onLoad(e) {
  26121. const swiper = this;
  26122. processLazyPreloader(swiper, e.target);
  26123. if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
  26124. return;
  26125. }
  26126. swiper.update();
  26127. }
  26128. function onDocumentTouchStart() {
  26129. const swiper = this;
  26130. if (swiper.documentTouchHandlerProceeded) return;
  26131. swiper.documentTouchHandlerProceeded = true;
  26132. if (swiper.params.touchReleaseOnEdges) {
  26133. swiper.el.style.touchAction = 'auto';
  26134. }
  26135. }
  26136. const events = (swiper, method) => {
  26137. const document = getDocument();
  26138. const {
  26139. params,
  26140. el,
  26141. wrapperEl,
  26142. device
  26143. } = swiper;
  26144. const capture = !!params.nested;
  26145. const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
  26146. const swiperMethod = method;
  26147. // Touch Events
  26148. document[domMethod]('touchstart', swiper.onDocumentTouchStart, {
  26149. passive: false,
  26150. capture
  26151. });
  26152. el[domMethod]('touchstart', swiper.onTouchStart, {
  26153. passive: false
  26154. });
  26155. el[domMethod]('pointerdown', swiper.onTouchStart, {
  26156. passive: false
  26157. });
  26158. document[domMethod]('touchmove', swiper.onTouchMove, {
  26159. passive: false,
  26160. capture
  26161. });
  26162. document[domMethod]('pointermove', swiper.onTouchMove, {
  26163. passive: false,
  26164. capture
  26165. });
  26166. document[domMethod]('touchend', swiper.onTouchEnd, {
  26167. passive: true
  26168. });
  26169. document[domMethod]('pointerup', swiper.onTouchEnd, {
  26170. passive: true
  26171. });
  26172. document[domMethod]('pointercancel', swiper.onTouchEnd, {
  26173. passive: true
  26174. });
  26175. document[domMethod]('touchcancel', swiper.onTouchEnd, {
  26176. passive: true
  26177. });
  26178. document[domMethod]('pointerout', swiper.onTouchEnd, {
  26179. passive: true
  26180. });
  26181. document[domMethod]('pointerleave', swiper.onTouchEnd, {
  26182. passive: true
  26183. });
  26184. document[domMethod]('contextmenu', swiper.onTouchEnd, {
  26185. passive: true
  26186. });
  26187. // Prevent Links Clicks
  26188. if (params.preventClicks || params.preventClicksPropagation) {
  26189. el[domMethod]('click', swiper.onClick, true);
  26190. }
  26191. if (params.cssMode) {
  26192. wrapperEl[domMethod]('scroll', swiper.onScroll);
  26193. }
  26194. // Resize handler
  26195. if (params.updateOnWindowResize) {
  26196. swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
  26197. } else {
  26198. swiper[swiperMethod]('observerUpdate', onResize, true);
  26199. }
  26200. // Images loader
  26201. el[domMethod]('load', swiper.onLoad, {
  26202. capture: true
  26203. });
  26204. };
  26205. function attachEvents() {
  26206. const swiper = this;
  26207. const {
  26208. params
  26209. } = swiper;
  26210. swiper.onTouchStart = onTouchStart.bind(swiper);
  26211. swiper.onTouchMove = onTouchMove.bind(swiper);
  26212. swiper.onTouchEnd = onTouchEnd.bind(swiper);
  26213. swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
  26214. if (params.cssMode) {
  26215. swiper.onScroll = onScroll.bind(swiper);
  26216. }
  26217. swiper.onClick = onClick.bind(swiper);
  26218. swiper.onLoad = onLoad.bind(swiper);
  26219. events(swiper, 'on');
  26220. }
  26221. function detachEvents() {
  26222. const swiper = this;
  26223. events(swiper, 'off');
  26224. }
  26225. var events$1 = {
  26226. attachEvents,
  26227. detachEvents
  26228. };
  26229. const isGridEnabled = (swiper, params) => {
  26230. return swiper.grid && params.grid && params.grid.rows > 1;
  26231. };
  26232. function setBreakpoint() {
  26233. const swiper = this;
  26234. const {
  26235. realIndex,
  26236. initialized,
  26237. params,
  26238. el
  26239. } = swiper;
  26240. const breakpoints = params.breakpoints;
  26241. if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
  26242. // Get breakpoint for window width and update parameters
  26243. const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
  26244. if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
  26245. const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
  26246. const breakpointParams = breakpointOnlyParams || swiper.originalParams;
  26247. const wasMultiRow = isGridEnabled(swiper, params);
  26248. const isMultiRow = isGridEnabled(swiper, breakpointParams);
  26249. const wasEnabled = params.enabled;
  26250. if (wasMultiRow && !isMultiRow) {
  26251. el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
  26252. swiper.emitContainerClasses();
  26253. } else if (!wasMultiRow && isMultiRow) {
  26254. el.classList.add(`${params.containerModifierClass}grid`);
  26255. if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
  26256. el.classList.add(`${params.containerModifierClass}grid-column`);
  26257. }
  26258. swiper.emitContainerClasses();
  26259. }
  26260. // Toggle navigation, pagination, scrollbar
  26261. ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
  26262. if (typeof breakpointParams[prop] === 'undefined') return;
  26263. const wasModuleEnabled = params[prop] && params[prop].enabled;
  26264. const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
  26265. if (wasModuleEnabled && !isModuleEnabled) {
  26266. swiper[prop].disable();
  26267. }
  26268. if (!wasModuleEnabled && isModuleEnabled) {
  26269. swiper[prop].enable();
  26270. }
  26271. });
  26272. const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
  26273. const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
  26274. const wasLoop = params.loop;
  26275. if (directionChanged && initialized) {
  26276. swiper.changeDirection();
  26277. }
  26278. extend(swiper.params, breakpointParams);
  26279. const isEnabled = swiper.params.enabled;
  26280. const hasLoop = swiper.params.loop;
  26281. Object.assign(swiper, {
  26282. allowTouchMove: swiper.params.allowTouchMove,
  26283. allowSlideNext: swiper.params.allowSlideNext,
  26284. allowSlidePrev: swiper.params.allowSlidePrev
  26285. });
  26286. if (wasEnabled && !isEnabled) {
  26287. swiper.disable();
  26288. } else if (!wasEnabled && isEnabled) {
  26289. swiper.enable();
  26290. }
  26291. swiper.currentBreakpoint = breakpoint;
  26292. swiper.emit('_beforeBreakpoint', breakpointParams);
  26293. if (initialized) {
  26294. if (needsReLoop) {
  26295. swiper.loopDestroy();
  26296. swiper.loopCreate(realIndex);
  26297. swiper.updateSlides();
  26298. } else if (!wasLoop && hasLoop) {
  26299. swiper.loopCreate(realIndex);
  26300. swiper.updateSlides();
  26301. } else if (wasLoop && !hasLoop) {
  26302. swiper.loopDestroy();
  26303. }
  26304. }
  26305. swiper.emit('breakpoint', breakpointParams);
  26306. }
  26307. function getBreakpoint(breakpoints, base, containerEl) {
  26308. if (base === void 0) {
  26309. base = 'window';
  26310. }
  26311. if (!breakpoints || base === 'container' && !containerEl) return undefined;
  26312. let breakpoint = false;
  26313. const window = getWindow();
  26314. const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
  26315. const points = Object.keys(breakpoints).map(point => {
  26316. if (typeof point === 'string' && point.indexOf('@') === 0) {
  26317. const minRatio = parseFloat(point.substr(1));
  26318. const value = currentHeight * minRatio;
  26319. return {
  26320. value,
  26321. point
  26322. };
  26323. }
  26324. return {
  26325. value: point,
  26326. point
  26327. };
  26328. });
  26329. points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
  26330. for (let i = 0; i < points.length; i += 1) {
  26331. const {
  26332. point,
  26333. value
  26334. } = points[i];
  26335. if (base === 'window') {
  26336. if (window.matchMedia(`(min-width: ${value}px)`).matches) {
  26337. breakpoint = point;
  26338. }
  26339. } else if (value <= containerEl.clientWidth) {
  26340. breakpoint = point;
  26341. }
  26342. }
  26343. return breakpoint || 'max';
  26344. }
  26345. var breakpoints = {
  26346. setBreakpoint,
  26347. getBreakpoint
  26348. };
  26349. function prepareClasses(entries, prefix) {
  26350. const resultClasses = [];
  26351. entries.forEach(item => {
  26352. if (typeof item === 'object') {
  26353. Object.keys(item).forEach(classNames => {
  26354. if (item[classNames]) {
  26355. resultClasses.push(prefix + classNames);
  26356. }
  26357. });
  26358. } else if (typeof item === 'string') {
  26359. resultClasses.push(prefix + item);
  26360. }
  26361. });
  26362. return resultClasses;
  26363. }
  26364. function addClasses() {
  26365. const swiper = this;
  26366. const {
  26367. classNames,
  26368. params,
  26369. rtl,
  26370. el,
  26371. device
  26372. } = swiper;
  26373. // prettier-ignore
  26374. const suffixes = prepareClasses(['initialized', params.direction, {
  26375. 'free-mode': swiper.params.freeMode && params.freeMode.enabled
  26376. }, {
  26377. 'autoheight': params.autoHeight
  26378. }, {
  26379. 'rtl': rtl
  26380. }, {
  26381. 'grid': params.grid && params.grid.rows > 1
  26382. }, {
  26383. 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
  26384. }, {
  26385. 'android': device.android
  26386. }, {
  26387. 'ios': device.ios
  26388. }, {
  26389. 'css-mode': params.cssMode
  26390. }, {
  26391. 'centered': params.cssMode && params.centeredSlides
  26392. }, {
  26393. 'watch-progress': params.watchSlidesProgress
  26394. }], params.containerModifierClass);
  26395. classNames.push(...suffixes);
  26396. el.classList.add(...classNames);
  26397. swiper.emitContainerClasses();
  26398. }
  26399. function removeClasses() {
  26400. const swiper = this;
  26401. const {
  26402. el,
  26403. classNames
  26404. } = swiper;
  26405. el.classList.remove(...classNames);
  26406. swiper.emitContainerClasses();
  26407. }
  26408. var classes = {
  26409. addClasses,
  26410. removeClasses
  26411. };
  26412. function checkOverflow() {
  26413. const swiper = this;
  26414. const {
  26415. isLocked: wasLocked,
  26416. params
  26417. } = swiper;
  26418. const {
  26419. slidesOffsetBefore
  26420. } = params;
  26421. if (slidesOffsetBefore) {
  26422. const lastSlideIndex = swiper.slides.length - 1;
  26423. const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
  26424. swiper.isLocked = swiper.size > lastSlideRightEdge;
  26425. } else {
  26426. swiper.isLocked = swiper.snapGrid.length === 1;
  26427. }
  26428. if (params.allowSlideNext === true) {
  26429. swiper.allowSlideNext = !swiper.isLocked;
  26430. }
  26431. if (params.allowSlidePrev === true) {
  26432. swiper.allowSlidePrev = !swiper.isLocked;
  26433. }
  26434. if (wasLocked && wasLocked !== swiper.isLocked) {
  26435. swiper.isEnd = false;
  26436. }
  26437. if (wasLocked !== swiper.isLocked) {
  26438. swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
  26439. }
  26440. }
  26441. var checkOverflow$1 = {
  26442. checkOverflow
  26443. };
  26444. var defaults = {
  26445. init: true,
  26446. direction: 'horizontal',
  26447. oneWayMovement: false,
  26448. touchEventsTarget: 'wrapper',
  26449. initialSlide: 0,
  26450. speed: 300,
  26451. cssMode: false,
  26452. updateOnWindowResize: true,
  26453. resizeObserver: true,
  26454. nested: false,
  26455. createElements: false,
  26456. eventsPrefix: 'swiper',
  26457. enabled: true,
  26458. focusableElements: 'input, select, option, textarea, button, video, label',
  26459. // Overrides
  26460. width: null,
  26461. height: null,
  26462. //
  26463. preventInteractionOnTransition: false,
  26464. // ssr
  26465. userAgent: null,
  26466. url: null,
  26467. // To support iOS's swipe-to-go-back gesture (when being used in-app).
  26468. edgeSwipeDetection: false,
  26469. edgeSwipeThreshold: 20,
  26470. // Autoheight
  26471. autoHeight: false,
  26472. // Set wrapper width
  26473. setWrapperSize: false,
  26474. // Virtual Translate
  26475. virtualTranslate: false,
  26476. // Effects
  26477. effect: 'slide',
  26478. // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
  26479. // Breakpoints
  26480. breakpoints: undefined,
  26481. breakpointsBase: 'window',
  26482. // Slides grid
  26483. spaceBetween: 0,
  26484. slidesPerView: 1,
  26485. slidesPerGroup: 1,
  26486. slidesPerGroupSkip: 0,
  26487. slidesPerGroupAuto: false,
  26488. centeredSlides: false,
  26489. centeredSlidesBounds: false,
  26490. slidesOffsetBefore: 0,
  26491. // in px
  26492. slidesOffsetAfter: 0,
  26493. // in px
  26494. normalizeSlideIndex: true,
  26495. centerInsufficientSlides: false,
  26496. // Disable swiper and hide navigation when container not overflow
  26497. watchOverflow: true,
  26498. // Round length
  26499. roundLengths: false,
  26500. // Touches
  26501. touchRatio: 1,
  26502. touchAngle: 45,
  26503. simulateTouch: true,
  26504. shortSwipes: true,
  26505. longSwipes: true,
  26506. longSwipesRatio: 0.5,
  26507. longSwipesMs: 300,
  26508. followFinger: true,
  26509. allowTouchMove: true,
  26510. threshold: 5,
  26511. touchMoveStopPropagation: false,
  26512. touchStartPreventDefault: true,
  26513. touchStartForcePreventDefault: false,
  26514. touchReleaseOnEdges: false,
  26515. // Unique Navigation Elements
  26516. uniqueNavElements: true,
  26517. // Resistance
  26518. resistance: true,
  26519. resistanceRatio: 0.85,
  26520. // Progress
  26521. watchSlidesProgress: false,
  26522. // Cursor
  26523. grabCursor: false,
  26524. // Clicks
  26525. preventClicks: true,
  26526. preventClicksPropagation: true,
  26527. slideToClickedSlide: false,
  26528. // loop
  26529. loop: false,
  26530. loopAddBlankSlides: true,
  26531. loopAdditionalSlides: 0,
  26532. loopPreventsSliding: true,
  26533. // rewind
  26534. rewind: false,
  26535. // Swiping/no swiping
  26536. allowSlidePrev: true,
  26537. allowSlideNext: true,
  26538. swipeHandler: null,
  26539. // '.swipe-handler',
  26540. noSwiping: true,
  26541. noSwipingClass: 'swiper-no-swiping',
  26542. noSwipingSelector: null,
  26543. // Passive Listeners
  26544. passiveListeners: true,
  26545. maxBackfaceHiddenSlides: 10,
  26546. // NS
  26547. containerModifierClass: 'swiper-',
  26548. // NEW
  26549. slideClass: 'swiper-slide',
  26550. slideBlankClass: 'swiper-slide-blank',
  26551. slideActiveClass: 'swiper-slide-active',
  26552. slideVisibleClass: 'swiper-slide-visible',
  26553. slideFullyVisibleClass: 'swiper-slide-fully-visible',
  26554. slideNextClass: 'swiper-slide-next',
  26555. slidePrevClass: 'swiper-slide-prev',
  26556. wrapperClass: 'swiper-wrapper',
  26557. lazyPreloaderClass: 'swiper-lazy-preloader',
  26558. lazyPreloadPrevNext: 0,
  26559. // Callbacks
  26560. runCallbacksOnInit: true,
  26561. // Internals
  26562. _emitClasses: false
  26563. };
  26564. function moduleExtendParams(params, allModulesParams) {
  26565. return function extendParams(obj) {
  26566. if (obj === void 0) {
  26567. obj = {};
  26568. }
  26569. const moduleParamName = Object.keys(obj)[0];
  26570. const moduleParams = obj[moduleParamName];
  26571. if (typeof moduleParams !== 'object' || moduleParams === null) {
  26572. extend(allModulesParams, obj);
  26573. return;
  26574. }
  26575. if (params[moduleParamName] === true) {
  26576. params[moduleParamName] = {
  26577. enabled: true
  26578. };
  26579. }
  26580. if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
  26581. params[moduleParamName].auto = true;
  26582. }
  26583. if (['pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
  26584. params[moduleParamName].auto = true;
  26585. }
  26586. if (!(moduleParamName in params && 'enabled' in moduleParams)) {
  26587. extend(allModulesParams, obj);
  26588. return;
  26589. }
  26590. if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
  26591. params[moduleParamName].enabled = true;
  26592. }
  26593. if (!params[moduleParamName]) params[moduleParamName] = {
  26594. enabled: false
  26595. };
  26596. extend(allModulesParams, obj);
  26597. };
  26598. }
  26599. /* eslint no-param-reassign: "off" */
  26600. const prototypes = {
  26601. eventsEmitter,
  26602. update,
  26603. translate,
  26604. transition,
  26605. slide,
  26606. loop,
  26607. grabCursor,
  26608. events: events$1,
  26609. breakpoints,
  26610. checkOverflow: checkOverflow$1,
  26611. classes
  26612. };
  26613. const extendedDefaults = {};
  26614. class Swiper {
  26615. constructor() {
  26616. let el;
  26617. let params;
  26618. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  26619. args[_key] = arguments[_key];
  26620. }
  26621. if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
  26622. params = args[0];
  26623. } else {
  26624. [el, params] = args;
  26625. }
  26626. if (!params) params = {};
  26627. params = extend({}, params);
  26628. if (el && !params.el) params.el = el;
  26629. const document = getDocument();
  26630. if (params.el && typeof params.el === 'string' && document.querySelectorAll(params.el).length > 1) {
  26631. const swipers = [];
  26632. document.querySelectorAll(params.el).forEach(containerEl => {
  26633. const newParams = extend({}, params, {
  26634. el: containerEl
  26635. });
  26636. swipers.push(new Swiper(newParams));
  26637. });
  26638. // eslint-disable-next-line no-constructor-return
  26639. return swipers;
  26640. }
  26641. // Swiper Instance
  26642. const swiper = this;
  26643. swiper.__swiper__ = true;
  26644. swiper.support = getSupport();
  26645. swiper.device = getDevice({
  26646. userAgent: params.userAgent
  26647. });
  26648. swiper.browser = getBrowser();
  26649. swiper.eventsListeners = {};
  26650. swiper.eventsAnyListeners = [];
  26651. swiper.modules = [...swiper.__modules__];
  26652. if (params.modules && Array.isArray(params.modules)) {
  26653. swiper.modules.push(...params.modules);
  26654. }
  26655. const allModulesParams = {};
  26656. swiper.modules.forEach(mod => {
  26657. mod({
  26658. params,
  26659. swiper,
  26660. extendParams: moduleExtendParams(params, allModulesParams),
  26661. on: swiper.on.bind(swiper),
  26662. once: swiper.once.bind(swiper),
  26663. off: swiper.off.bind(swiper),
  26664. emit: swiper.emit.bind(swiper)
  26665. });
  26666. });
  26667. // Extend defaults with modules params
  26668. const swiperParams = extend({}, defaults, allModulesParams);
  26669. // Extend defaults with passed params
  26670. swiper.params = extend({}, swiperParams, extendedDefaults, params);
  26671. swiper.originalParams = extend({}, swiper.params);
  26672. swiper.passedParams = extend({}, params);
  26673. // add event listeners
  26674. if (swiper.params && swiper.params.on) {
  26675. Object.keys(swiper.params.on).forEach(eventName => {
  26676. swiper.on(eventName, swiper.params.on[eventName]);
  26677. });
  26678. }
  26679. if (swiper.params && swiper.params.onAny) {
  26680. swiper.onAny(swiper.params.onAny);
  26681. }
  26682. // Extend Swiper
  26683. Object.assign(swiper, {
  26684. enabled: swiper.params.enabled,
  26685. el,
  26686. // Classes
  26687. classNames: [],
  26688. // Slides
  26689. slides: [],
  26690. slidesGrid: [],
  26691. snapGrid: [],
  26692. slidesSizesGrid: [],
  26693. // isDirection
  26694. isHorizontal() {
  26695. return swiper.params.direction === 'horizontal';
  26696. },
  26697. isVertical() {
  26698. return swiper.params.direction === 'vertical';
  26699. },
  26700. // Indexes
  26701. activeIndex: 0,
  26702. realIndex: 0,
  26703. //
  26704. isBeginning: true,
  26705. isEnd: false,
  26706. // Props
  26707. translate: 0,
  26708. previousTranslate: 0,
  26709. progress: 0,
  26710. velocity: 0,
  26711. animating: false,
  26712. cssOverflowAdjustment() {
  26713. // Returns 0 unless `translate` is > 2**23
  26714. // Should be subtracted from css values to prevent overflow
  26715. return Math.trunc(this.translate / 2 ** 23) * 2 ** 23;
  26716. },
  26717. // Locks
  26718. allowSlideNext: swiper.params.allowSlideNext,
  26719. allowSlidePrev: swiper.params.allowSlidePrev,
  26720. // Touch Events
  26721. touchEventsData: {
  26722. isTouched: undefined,
  26723. isMoved: undefined,
  26724. allowTouchCallbacks: undefined,
  26725. touchStartTime: undefined,
  26726. isScrolling: undefined,
  26727. currentTranslate: undefined,
  26728. startTranslate: undefined,
  26729. allowThresholdMove: undefined,
  26730. // Form elements to match
  26731. focusableElements: swiper.params.focusableElements,
  26732. // Last click time
  26733. lastClickTime: 0,
  26734. clickTimeout: undefined,
  26735. // Velocities
  26736. velocities: [],
  26737. allowMomentumBounce: undefined,
  26738. startMoving: undefined,
  26739. pointerId: null,
  26740. touchId: null
  26741. },
  26742. // Clicks
  26743. allowClick: true,
  26744. // Touches
  26745. allowTouchMove: swiper.params.allowTouchMove,
  26746. touches: {
  26747. startX: 0,
  26748. startY: 0,
  26749. currentX: 0,
  26750. currentY: 0,
  26751. diff: 0
  26752. },
  26753. // Images
  26754. imagesToLoad: [],
  26755. imagesLoaded: 0
  26756. });
  26757. swiper.emit('_swiper');
  26758. // Init
  26759. if (swiper.params.init) {
  26760. swiper.init();
  26761. }
  26762. // Return app instance
  26763. // eslint-disable-next-line no-constructor-return
  26764. return swiper;
  26765. }
  26766. getDirectionLabel(property) {
  26767. if (this.isHorizontal()) {
  26768. return property;
  26769. }
  26770. // prettier-ignore
  26771. return {
  26772. 'width': 'height',
  26773. 'margin-top': 'margin-left',
  26774. 'margin-bottom ': 'margin-right',
  26775. 'margin-left': 'margin-top',
  26776. 'margin-right': 'margin-bottom',
  26777. 'padding-left': 'padding-top',
  26778. 'padding-right': 'padding-bottom',
  26779. 'marginRight': 'marginBottom'
  26780. }[property];
  26781. }
  26782. getSlideIndex(slideEl) {
  26783. const {
  26784. slidesEl,
  26785. params
  26786. } = this;
  26787. const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
  26788. const firstSlideIndex = elementIndex(slides[0]);
  26789. return elementIndex(slideEl) - firstSlideIndex;
  26790. }
  26791. getSlideIndexByData(index) {
  26792. return this.getSlideIndex(this.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index)[0]);
  26793. }
  26794. recalcSlides() {
  26795. const swiper = this;
  26796. const {
  26797. slidesEl,
  26798. params
  26799. } = swiper;
  26800. swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
  26801. }
  26802. enable() {
  26803. const swiper = this;
  26804. if (swiper.enabled) return;
  26805. swiper.enabled = true;
  26806. if (swiper.params.grabCursor) {
  26807. swiper.setGrabCursor();
  26808. }
  26809. swiper.emit('enable');
  26810. }
  26811. disable() {
  26812. const swiper = this;
  26813. if (!swiper.enabled) return;
  26814. swiper.enabled = false;
  26815. if (swiper.params.grabCursor) {
  26816. swiper.unsetGrabCursor();
  26817. }
  26818. swiper.emit('disable');
  26819. }
  26820. setProgress(progress, speed) {
  26821. const swiper = this;
  26822. progress = Math.min(Math.max(progress, 0), 1);
  26823. const min = swiper.minTranslate();
  26824. const max = swiper.maxTranslate();
  26825. const current = (max - min) * progress + min;
  26826. swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
  26827. swiper.updateActiveIndex();
  26828. swiper.updateSlidesClasses();
  26829. }
  26830. emitContainerClasses() {
  26831. const swiper = this;
  26832. if (!swiper.params._emitClasses || !swiper.el) return;
  26833. const cls = swiper.el.className.split(' ').filter(className => {
  26834. return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
  26835. });
  26836. swiper.emit('_containerClasses', cls.join(' '));
  26837. }
  26838. getSlideClasses(slideEl) {
  26839. const swiper = this;
  26840. if (swiper.destroyed) return '';
  26841. return slideEl.className.split(' ').filter(className => {
  26842. return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
  26843. }).join(' ');
  26844. }
  26845. emitSlidesClasses() {
  26846. const swiper = this;
  26847. if (!swiper.params._emitClasses || !swiper.el) return;
  26848. const updates = [];
  26849. swiper.slides.forEach(slideEl => {
  26850. const classNames = swiper.getSlideClasses(slideEl);
  26851. updates.push({
  26852. slideEl,
  26853. classNames
  26854. });
  26855. swiper.emit('_slideClass', slideEl, classNames);
  26856. });
  26857. swiper.emit('_slideClasses', updates);
  26858. }
  26859. slidesPerViewDynamic(view, exact) {
  26860. if (view === void 0) {
  26861. view = 'current';
  26862. }
  26863. if (exact === void 0) {
  26864. exact = false;
  26865. }
  26866. const swiper = this;
  26867. const {
  26868. params,
  26869. slides,
  26870. slidesGrid,
  26871. slidesSizesGrid,
  26872. size: swiperSize,
  26873. activeIndex
  26874. } = swiper;
  26875. let spv = 1;
  26876. if (typeof params.slidesPerView === 'number') return params.slidesPerView;
  26877. if (params.centeredSlides) {
  26878. let slideSize = slides[activeIndex] ? slides[activeIndex].swiperSlideSize : 0;
  26879. let breakLoop;
  26880. for (let i = activeIndex + 1; i < slides.length; i += 1) {
  26881. if (slides[i] && !breakLoop) {
  26882. slideSize += slides[i].swiperSlideSize;
  26883. spv += 1;
  26884. if (slideSize > swiperSize) breakLoop = true;
  26885. }
  26886. }
  26887. for (let i = activeIndex - 1; i >= 0; i -= 1) {
  26888. if (slides[i] && !breakLoop) {
  26889. slideSize += slides[i].swiperSlideSize;
  26890. spv += 1;
  26891. if (slideSize > swiperSize) breakLoop = true;
  26892. }
  26893. }
  26894. } else {
  26895. // eslint-disable-next-line
  26896. if (view === 'current') {
  26897. for (let i = activeIndex + 1; i < slides.length; i += 1) {
  26898. const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
  26899. if (slideInView) {
  26900. spv += 1;
  26901. }
  26902. }
  26903. } else {
  26904. // previous
  26905. for (let i = activeIndex - 1; i >= 0; i -= 1) {
  26906. const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
  26907. if (slideInView) {
  26908. spv += 1;
  26909. }
  26910. }
  26911. }
  26912. }
  26913. return spv;
  26914. }
  26915. update() {
  26916. const swiper = this;
  26917. if (!swiper || swiper.destroyed) return;
  26918. const {
  26919. snapGrid,
  26920. params
  26921. } = swiper;
  26922. // Breakpoints
  26923. if (params.breakpoints) {
  26924. swiper.setBreakpoint();
  26925. }
  26926. [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
  26927. if (imageEl.complete) {
  26928. processLazyPreloader(swiper, imageEl);
  26929. }
  26930. });
  26931. swiper.updateSize();
  26932. swiper.updateSlides();
  26933. swiper.updateProgress();
  26934. swiper.updateSlidesClasses();
  26935. function setTranslate() {
  26936. const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
  26937. const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
  26938. swiper.setTranslate(newTranslate);
  26939. swiper.updateActiveIndex();
  26940. swiper.updateSlidesClasses();
  26941. }
  26942. let translated;
  26943. if (params.freeMode && params.freeMode.enabled && !params.cssMode) {
  26944. setTranslate();
  26945. if (params.autoHeight) {
  26946. swiper.updateAutoHeight();
  26947. }
  26948. } else {
  26949. if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
  26950. const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
  26951. translated = swiper.slideTo(slides.length - 1, 0, false, true);
  26952. } else {
  26953. translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
  26954. }
  26955. if (!translated) {
  26956. setTranslate();
  26957. }
  26958. }
  26959. if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
  26960. swiper.checkOverflow();
  26961. }
  26962. swiper.emit('update');
  26963. }
  26964. changeDirection(newDirection, needUpdate) {
  26965. if (needUpdate === void 0) {
  26966. needUpdate = true;
  26967. }
  26968. const swiper = this;
  26969. const currentDirection = swiper.params.direction;
  26970. if (!newDirection) {
  26971. // eslint-disable-next-line
  26972. newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
  26973. }
  26974. if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
  26975. return swiper;
  26976. }
  26977. swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`);
  26978. swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`);
  26979. swiper.emitContainerClasses();
  26980. swiper.params.direction = newDirection;
  26981. swiper.slides.forEach(slideEl => {
  26982. if (newDirection === 'vertical') {
  26983. slideEl.style.width = '';
  26984. } else {
  26985. slideEl.style.height = '';
  26986. }
  26987. });
  26988. swiper.emit('changeDirection');
  26989. if (needUpdate) swiper.update();
  26990. return swiper;
  26991. }
  26992. changeLanguageDirection(direction) {
  26993. const swiper = this;
  26994. if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
  26995. swiper.rtl = direction === 'rtl';
  26996. swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
  26997. if (swiper.rtl) {
  26998. swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`);
  26999. swiper.el.dir = 'rtl';
  27000. } else {
  27001. swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`);
  27002. swiper.el.dir = 'ltr';
  27003. }
  27004. swiper.update();
  27005. }
  27006. mount(element) {
  27007. const swiper = this;
  27008. if (swiper.mounted) return true;
  27009. // Find el
  27010. let el = element || swiper.params.el;
  27011. if (typeof el === 'string') {
  27012. el = document.querySelector(el);
  27013. }
  27014. if (!el) {
  27015. return false;
  27016. }
  27017. el.swiper = swiper;
  27018. if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === 'SWIPER-CONTAINER') {
  27019. swiper.isElement = true;
  27020. }
  27021. const getWrapperSelector = () => {
  27022. return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
  27023. };
  27024. const getWrapper = () => {
  27025. if (el && el.shadowRoot && el.shadowRoot.querySelector) {
  27026. const res = el.shadowRoot.querySelector(getWrapperSelector());
  27027. // Children needs to return slot items
  27028. return res;
  27029. }
  27030. return elementChildren(el, getWrapperSelector())[0];
  27031. };
  27032. // Find Wrapper
  27033. let wrapperEl = getWrapper();
  27034. if (!wrapperEl && swiper.params.createElements) {
  27035. wrapperEl = createElement('div', swiper.params.wrapperClass);
  27036. el.append(wrapperEl);
  27037. elementChildren(el, `.${swiper.params.slideClass}`).forEach(slideEl => {
  27038. wrapperEl.append(slideEl);
  27039. });
  27040. }
  27041. Object.assign(swiper, {
  27042. el,
  27043. wrapperEl,
  27044. slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
  27045. hostEl: swiper.isElement ? el.parentNode.host : el,
  27046. mounted: true,
  27047. // RTL
  27048. rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
  27049. rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
  27050. wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
  27051. });
  27052. return true;
  27053. }
  27054. init(el) {
  27055. const swiper = this;
  27056. if (swiper.initialized) return swiper;
  27057. const mounted = swiper.mount(el);
  27058. if (mounted === false) return swiper;
  27059. swiper.emit('beforeInit');
  27060. // Set breakpoint
  27061. if (swiper.params.breakpoints) {
  27062. swiper.setBreakpoint();
  27063. }
  27064. // Add Classes
  27065. swiper.addClasses();
  27066. // Update size
  27067. swiper.updateSize();
  27068. // Update slides
  27069. swiper.updateSlides();
  27070. if (swiper.params.watchOverflow) {
  27071. swiper.checkOverflow();
  27072. }
  27073. // Set Grab Cursor
  27074. if (swiper.params.grabCursor && swiper.enabled) {
  27075. swiper.setGrabCursor();
  27076. }
  27077. // Slide To Initial Slide
  27078. if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
  27079. swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
  27080. } else {
  27081. swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
  27082. }
  27083. // Create loop
  27084. if (swiper.params.loop) {
  27085. swiper.loopCreate();
  27086. }
  27087. // Attach events
  27088. swiper.attachEvents();
  27089. const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
  27090. if (swiper.isElement) {
  27091. lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]'));
  27092. }
  27093. lazyElements.forEach(imageEl => {
  27094. if (imageEl.complete) {
  27095. processLazyPreloader(swiper, imageEl);
  27096. } else {
  27097. imageEl.addEventListener('load', e => {
  27098. processLazyPreloader(swiper, e.target);
  27099. });
  27100. }
  27101. });
  27102. preload(swiper);
  27103. // Init Flag
  27104. swiper.initialized = true;
  27105. preload(swiper);
  27106. // Emit
  27107. swiper.emit('init');
  27108. swiper.emit('afterInit');
  27109. return swiper;
  27110. }
  27111. destroy(deleteInstance, cleanStyles) {
  27112. if (deleteInstance === void 0) {
  27113. deleteInstance = true;
  27114. }
  27115. if (cleanStyles === void 0) {
  27116. cleanStyles = true;
  27117. }
  27118. const swiper = this;
  27119. const {
  27120. params,
  27121. el,
  27122. wrapperEl,
  27123. slides
  27124. } = swiper;
  27125. if (typeof swiper.params === 'undefined' || swiper.destroyed) {
  27126. return null;
  27127. }
  27128. swiper.emit('beforeDestroy');
  27129. // Init Flag
  27130. swiper.initialized = false;
  27131. // Detach events
  27132. swiper.detachEvents();
  27133. // Destroy loop
  27134. if (params.loop) {
  27135. swiper.loopDestroy();
  27136. }
  27137. // Cleanup styles
  27138. if (cleanStyles) {
  27139. swiper.removeClasses();
  27140. el.removeAttribute('style');
  27141. wrapperEl.removeAttribute('style');
  27142. if (slides && slides.length) {
  27143. slides.forEach(slideEl => {
  27144. slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
  27145. slideEl.removeAttribute('style');
  27146. slideEl.removeAttribute('data-swiper-slide-index');
  27147. });
  27148. }
  27149. }
  27150. swiper.emit('destroy');
  27151. // Detach emitter events
  27152. Object.keys(swiper.eventsListeners).forEach(eventName => {
  27153. swiper.off(eventName);
  27154. });
  27155. if (deleteInstance !== false) {
  27156. swiper.el.swiper = null;
  27157. deleteProps(swiper);
  27158. }
  27159. swiper.destroyed = true;
  27160. return null;
  27161. }
  27162. static extendDefaults(newDefaults) {
  27163. extend(extendedDefaults, newDefaults);
  27164. }
  27165. static get extendedDefaults() {
  27166. return extendedDefaults;
  27167. }
  27168. static get defaults() {
  27169. return defaults;
  27170. }
  27171. static installModule(mod) {
  27172. if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
  27173. const modules = Swiper.prototype.__modules__;
  27174. if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
  27175. modules.push(mod);
  27176. }
  27177. }
  27178. static use(module) {
  27179. if (Array.isArray(module)) {
  27180. module.forEach(m => Swiper.installModule(m));
  27181. return Swiper;
  27182. }
  27183. Swiper.installModule(module);
  27184. return Swiper;
  27185. }
  27186. }
  27187. Object.keys(prototypes).forEach(prototypeGroup => {
  27188. Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
  27189. Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
  27190. });
  27191. });
  27192. Swiper.use([Resize, Observer]);
  27193. function Virtual(_ref) {
  27194. let {
  27195. swiper,
  27196. extendParams,
  27197. on,
  27198. emit
  27199. } = _ref;
  27200. extendParams({
  27201. virtual: {
  27202. enabled: false,
  27203. slides: [],
  27204. cache: true,
  27205. renderSlide: null,
  27206. renderExternal: null,
  27207. renderExternalUpdate: true,
  27208. addSlidesBefore: 0,
  27209. addSlidesAfter: 0
  27210. }
  27211. });
  27212. let cssModeTimeout;
  27213. const document = getDocument();
  27214. swiper.virtual = {
  27215. cache: {},
  27216. from: undefined,
  27217. to: undefined,
  27218. slides: [],
  27219. offset: 0,
  27220. slidesGrid: []
  27221. };
  27222. const tempDOM = document.createElement('div');
  27223. function renderSlide(slide, index) {
  27224. const params = swiper.params.virtual;
  27225. if (params.cache && swiper.virtual.cache[index]) {
  27226. return swiper.virtual.cache[index];
  27227. }
  27228. // eslint-disable-next-line
  27229. let slideEl;
  27230. if (params.renderSlide) {
  27231. slideEl = params.renderSlide.call(swiper, slide, index);
  27232. if (typeof slideEl === 'string') {
  27233. tempDOM.innerHTML = slideEl;
  27234. slideEl = tempDOM.children[0];
  27235. }
  27236. } else if (swiper.isElement) {
  27237. slideEl = createElement('swiper-slide');
  27238. } else {
  27239. slideEl = createElement('div', swiper.params.slideClass);
  27240. }
  27241. slideEl.setAttribute('data-swiper-slide-index', index);
  27242. if (!params.renderSlide) {
  27243. slideEl.innerHTML = slide;
  27244. }
  27245. if (params.cache) {
  27246. swiper.virtual.cache[index] = slideEl;
  27247. }
  27248. return slideEl;
  27249. }
  27250. function update(force) {
  27251. const {
  27252. slidesPerView,
  27253. slidesPerGroup,
  27254. centeredSlides,
  27255. loop: isLoop
  27256. } = swiper.params;
  27257. const {
  27258. addSlidesBefore,
  27259. addSlidesAfter
  27260. } = swiper.params.virtual;
  27261. const {
  27262. from: previousFrom,
  27263. to: previousTo,
  27264. slides,
  27265. slidesGrid: previousSlidesGrid,
  27266. offset: previousOffset
  27267. } = swiper.virtual;
  27268. if (!swiper.params.cssMode) {
  27269. swiper.updateActiveIndex();
  27270. }
  27271. const activeIndex = swiper.activeIndex || 0;
  27272. let offsetProp;
  27273. if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top';
  27274. let slidesAfter;
  27275. let slidesBefore;
  27276. if (centeredSlides) {
  27277. slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter;
  27278. slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore;
  27279. } else {
  27280. slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter;
  27281. slidesBefore = (isLoop ? slidesPerView : slidesPerGroup) + addSlidesBefore;
  27282. }
  27283. let from = activeIndex - slidesBefore;
  27284. let to = activeIndex + slidesAfter;
  27285. if (!isLoop) {
  27286. from = Math.max(from, 0);
  27287. to = Math.min(to, slides.length - 1);
  27288. }
  27289. let offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0);
  27290. if (isLoop && activeIndex >= slidesBefore) {
  27291. from -= slidesBefore;
  27292. if (!centeredSlides) offset += swiper.slidesGrid[0];
  27293. } else if (isLoop && activeIndex < slidesBefore) {
  27294. from = -slidesBefore;
  27295. if (centeredSlides) offset += swiper.slidesGrid[0];
  27296. }
  27297. Object.assign(swiper.virtual, {
  27298. from,
  27299. to,
  27300. offset,
  27301. slidesGrid: swiper.slidesGrid,
  27302. slidesBefore,
  27303. slidesAfter
  27304. });
  27305. function onRendered() {
  27306. swiper.updateSlides();
  27307. swiper.updateProgress();
  27308. swiper.updateSlidesClasses();
  27309. emit('virtualUpdate');
  27310. }
  27311. if (previousFrom === from && previousTo === to && !force) {
  27312. if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) {
  27313. swiper.slides.forEach(slideEl => {
  27314. slideEl.style[offsetProp] = `${offset - Math.abs(swiper.cssOverflowAdjustment())}px`;
  27315. });
  27316. }
  27317. swiper.updateProgress();
  27318. emit('virtualUpdate');
  27319. return;
  27320. }
  27321. if (swiper.params.virtual.renderExternal) {
  27322. swiper.params.virtual.renderExternal.call(swiper, {
  27323. offset,
  27324. from,
  27325. to,
  27326. slides: function getSlides() {
  27327. const slidesToRender = [];
  27328. for (let i = from; i <= to; i += 1) {
  27329. slidesToRender.push(slides[i]);
  27330. }
  27331. return slidesToRender;
  27332. }()
  27333. });
  27334. if (swiper.params.virtual.renderExternalUpdate) {
  27335. onRendered();
  27336. } else {
  27337. emit('virtualUpdate');
  27338. }
  27339. return;
  27340. }
  27341. const prependIndexes = [];
  27342. const appendIndexes = [];
  27343. const getSlideIndex = index => {
  27344. let slideIndex = index;
  27345. if (index < 0) {
  27346. slideIndex = slides.length + index;
  27347. } else if (slideIndex >= slides.length) {
  27348. // eslint-disable-next-line
  27349. slideIndex = slideIndex - slides.length;
  27350. }
  27351. return slideIndex;
  27352. };
  27353. if (force) {
  27354. swiper.slides.filter(el => el.matches(`.${swiper.params.slideClass}, swiper-slide`)).forEach(slideEl => {
  27355. slideEl.remove();
  27356. });
  27357. } else {
  27358. for (let i = previousFrom; i <= previousTo; i += 1) {
  27359. if (i < from || i > to) {
  27360. const slideIndex = getSlideIndex(i);
  27361. swiper.slides.filter(el => el.matches(`.${swiper.params.slideClass}[data-swiper-slide-index="${slideIndex}"], swiper-slide[data-swiper-slide-index="${slideIndex}"]`)).forEach(slideEl => {
  27362. slideEl.remove();
  27363. });
  27364. }
  27365. }
  27366. }
  27367. const loopFrom = isLoop ? -slides.length : 0;
  27368. const loopTo = isLoop ? slides.length * 2 : slides.length;
  27369. for (let i = loopFrom; i < loopTo; i += 1) {
  27370. if (i >= from && i <= to) {
  27371. const slideIndex = getSlideIndex(i);
  27372. if (typeof previousTo === 'undefined' || force) {
  27373. appendIndexes.push(slideIndex);
  27374. } else {
  27375. if (i > previousTo) appendIndexes.push(slideIndex);
  27376. if (i < previousFrom) prependIndexes.push(slideIndex);
  27377. }
  27378. }
  27379. }
  27380. appendIndexes.forEach(index => {
  27381. swiper.slidesEl.append(renderSlide(slides[index], index));
  27382. });
  27383. if (isLoop) {
  27384. for (let i = prependIndexes.length - 1; i >= 0; i -= 1) {
  27385. const index = prependIndexes[i];
  27386. swiper.slidesEl.prepend(renderSlide(slides[index], index));
  27387. }
  27388. } else {
  27389. prependIndexes.sort((a, b) => b - a);
  27390. prependIndexes.forEach(index => {
  27391. swiper.slidesEl.prepend(renderSlide(slides[index], index));
  27392. });
  27393. }
  27394. elementChildren(swiper.slidesEl, '.swiper-slide, swiper-slide').forEach(slideEl => {
  27395. slideEl.style[offsetProp] = `${offset - Math.abs(swiper.cssOverflowAdjustment())}px`;
  27396. });
  27397. onRendered();
  27398. }
  27399. function appendSlide(slides) {
  27400. if (typeof slides === 'object' && 'length' in slides) {
  27401. for (let i = 0; i < slides.length; i += 1) {
  27402. if (slides[i]) swiper.virtual.slides.push(slides[i]);
  27403. }
  27404. } else {
  27405. swiper.virtual.slides.push(slides);
  27406. }
  27407. update(true);
  27408. }
  27409. function prependSlide(slides) {
  27410. const activeIndex = swiper.activeIndex;
  27411. let newActiveIndex = activeIndex + 1;
  27412. let numberOfNewSlides = 1;
  27413. if (Array.isArray(slides)) {
  27414. for (let i = 0; i < slides.length; i += 1) {
  27415. if (slides[i]) swiper.virtual.slides.unshift(slides[i]);
  27416. }
  27417. newActiveIndex = activeIndex + slides.length;
  27418. numberOfNewSlides = slides.length;
  27419. } else {
  27420. swiper.virtual.slides.unshift(slides);
  27421. }
  27422. if (swiper.params.virtual.cache) {
  27423. const cache = swiper.virtual.cache;
  27424. const newCache = {};
  27425. Object.keys(cache).forEach(cachedIndex => {
  27426. const cachedEl = cache[cachedIndex];
  27427. const cachedElIndex = cachedEl.getAttribute('data-swiper-slide-index');
  27428. if (cachedElIndex) {
  27429. cachedEl.setAttribute('data-swiper-slide-index', parseInt(cachedElIndex, 10) + numberOfNewSlides);
  27430. }
  27431. newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = cachedEl;
  27432. });
  27433. swiper.virtual.cache = newCache;
  27434. }
  27435. update(true);
  27436. swiper.slideTo(newActiveIndex, 0);
  27437. }
  27438. function removeSlide(slidesIndexes) {
  27439. if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return;
  27440. let activeIndex = swiper.activeIndex;
  27441. if (Array.isArray(slidesIndexes)) {
  27442. for (let i = slidesIndexes.length - 1; i >= 0; i -= 1) {
  27443. if (swiper.params.virtual.cache) {
  27444. delete swiper.virtual.cache[slidesIndexes[i]];
  27445. // shift cache indexes
  27446. Object.keys(swiper.virtual.cache).forEach(key => {
  27447. if (key > slidesIndexes) {
  27448. swiper.virtual.cache[key - 1] = swiper.virtual.cache[key];
  27449. swiper.virtual.cache[key - 1].setAttribute('data-swiper-slide-index', key - 1);
  27450. delete swiper.virtual.cache[key];
  27451. }
  27452. });
  27453. }
  27454. swiper.virtual.slides.splice(slidesIndexes[i], 1);
  27455. if (slidesIndexes[i] < activeIndex) activeIndex -= 1;
  27456. activeIndex = Math.max(activeIndex, 0);
  27457. }
  27458. } else {
  27459. if (swiper.params.virtual.cache) {
  27460. delete swiper.virtual.cache[slidesIndexes];
  27461. // shift cache indexes
  27462. Object.keys(swiper.virtual.cache).forEach(key => {
  27463. if (key > slidesIndexes) {
  27464. swiper.virtual.cache[key - 1] = swiper.virtual.cache[key];
  27465. swiper.virtual.cache[key - 1].setAttribute('data-swiper-slide-index', key - 1);
  27466. delete swiper.virtual.cache[key];
  27467. }
  27468. });
  27469. }
  27470. swiper.virtual.slides.splice(slidesIndexes, 1);
  27471. if (slidesIndexes < activeIndex) activeIndex -= 1;
  27472. activeIndex = Math.max(activeIndex, 0);
  27473. }
  27474. update(true);
  27475. swiper.slideTo(activeIndex, 0);
  27476. }
  27477. function removeAllSlides() {
  27478. swiper.virtual.slides = [];
  27479. if (swiper.params.virtual.cache) {
  27480. swiper.virtual.cache = {};
  27481. }
  27482. update(true);
  27483. swiper.slideTo(0, 0);
  27484. }
  27485. on('beforeInit', () => {
  27486. if (!swiper.params.virtual.enabled) return;
  27487. let domSlidesAssigned;
  27488. if (typeof swiper.passedParams.virtual.slides === 'undefined') {
  27489. const slides = [...swiper.slidesEl.children].filter(el => el.matches(`.${swiper.params.slideClass}, swiper-slide`));
  27490. if (slides && slides.length) {
  27491. swiper.virtual.slides = [...slides];
  27492. domSlidesAssigned = true;
  27493. slides.forEach((slideEl, slideIndex) => {
  27494. slideEl.setAttribute('data-swiper-slide-index', slideIndex);
  27495. swiper.virtual.cache[slideIndex] = slideEl;
  27496. slideEl.remove();
  27497. });
  27498. }
  27499. }
  27500. if (!domSlidesAssigned) {
  27501. swiper.virtual.slides = swiper.params.virtual.slides;
  27502. }
  27503. swiper.classNames.push(`${swiper.params.containerModifierClass}virtual`);
  27504. swiper.params.watchSlidesProgress = true;
  27505. swiper.originalParams.watchSlidesProgress = true;
  27506. update();
  27507. });
  27508. on('setTranslate', () => {
  27509. if (!swiper.params.virtual.enabled) return;
  27510. if (swiper.params.cssMode && !swiper._immediateVirtual) {
  27511. clearTimeout(cssModeTimeout);
  27512. cssModeTimeout = setTimeout(() => {
  27513. update();
  27514. }, 100);
  27515. } else {
  27516. update();
  27517. }
  27518. });
  27519. on('init update resize', () => {
  27520. if (!swiper.params.virtual.enabled) return;
  27521. if (swiper.params.cssMode) {
  27522. setCSSProperty(swiper.wrapperEl, '--swiper-virtual-size', `${swiper.virtualSize}px`);
  27523. }
  27524. });
  27525. Object.assign(swiper.virtual, {
  27526. appendSlide,
  27527. prependSlide,
  27528. removeSlide,
  27529. removeAllSlides,
  27530. update
  27531. });
  27532. }
  27533. /* eslint-disable consistent-return */
  27534. function Keyboard(_ref) {
  27535. let {
  27536. swiper,
  27537. extendParams,
  27538. on,
  27539. emit
  27540. } = _ref;
  27541. const document = getDocument();
  27542. const window = getWindow();
  27543. swiper.keyboard = {
  27544. enabled: false
  27545. };
  27546. extendParams({
  27547. keyboard: {
  27548. enabled: false,
  27549. onlyInViewport: true,
  27550. pageUpDown: true
  27551. }
  27552. });
  27553. function handle(event) {
  27554. if (!swiper.enabled) return;
  27555. const {
  27556. rtlTranslate: rtl
  27557. } = swiper;
  27558. let e = event;
  27559. if (e.originalEvent) e = e.originalEvent; // jquery fix
  27560. const kc = e.keyCode || e.charCode;
  27561. const pageUpDown = swiper.params.keyboard.pageUpDown;
  27562. const isPageUp = pageUpDown && kc === 33;
  27563. const isPageDown = pageUpDown && kc === 34;
  27564. const isArrowLeft = kc === 37;
  27565. const isArrowRight = kc === 39;
  27566. const isArrowUp = kc === 38;
  27567. const isArrowDown = kc === 40;
  27568. // Directions locks
  27569. if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) {
  27570. return false;
  27571. }
  27572. if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) {
  27573. return false;
  27574. }
  27575. if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
  27576. return undefined;
  27577. }
  27578. if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
  27579. return undefined;
  27580. }
  27581. if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) {
  27582. let inView = false;
  27583. // Check that swiper should be inside of visible area of window
  27584. if (elementParents(swiper.el, `.${swiper.params.slideClass}, swiper-slide`).length > 0 && elementParents(swiper.el, `.${swiper.params.slideActiveClass}`).length === 0) {
  27585. return undefined;
  27586. }
  27587. const el = swiper.el;
  27588. const swiperWidth = el.clientWidth;
  27589. const swiperHeight = el.clientHeight;
  27590. const windowWidth = window.innerWidth;
  27591. const windowHeight = window.innerHeight;
  27592. const swiperOffset = elementOffset(el);
  27593. if (rtl) swiperOffset.left -= el.scrollLeft;
  27594. const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]];
  27595. for (let i = 0; i < swiperCoord.length; i += 1) {
  27596. const point = swiperCoord[i];
  27597. if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) {
  27598. if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
  27599. inView = true;
  27600. }
  27601. }
  27602. if (!inView) return undefined;
  27603. }
  27604. if (swiper.isHorizontal()) {
  27605. if (isPageUp || isPageDown || isArrowLeft || isArrowRight) {
  27606. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  27607. }
  27608. if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext();
  27609. if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev();
  27610. } else {
  27611. if (isPageUp || isPageDown || isArrowUp || isArrowDown) {
  27612. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  27613. }
  27614. if (isPageDown || isArrowDown) swiper.slideNext();
  27615. if (isPageUp || isArrowUp) swiper.slidePrev();
  27616. }
  27617. emit('keyPress', kc);
  27618. return undefined;
  27619. }
  27620. function enable() {
  27621. if (swiper.keyboard.enabled) return;
  27622. document.addEventListener('keydown', handle);
  27623. swiper.keyboard.enabled = true;
  27624. }
  27625. function disable() {
  27626. if (!swiper.keyboard.enabled) return;
  27627. document.removeEventListener('keydown', handle);
  27628. swiper.keyboard.enabled = false;
  27629. }
  27630. on('init', () => {
  27631. if (swiper.params.keyboard.enabled) {
  27632. enable();
  27633. }
  27634. });
  27635. on('destroy', () => {
  27636. if (swiper.keyboard.enabled) {
  27637. disable();
  27638. }
  27639. });
  27640. Object.assign(swiper.keyboard, {
  27641. enable,
  27642. disable
  27643. });
  27644. }
  27645. /* eslint-disable consistent-return */
  27646. function Mousewheel(_ref) {
  27647. let {
  27648. swiper,
  27649. extendParams,
  27650. on,
  27651. emit
  27652. } = _ref;
  27653. const window = getWindow();
  27654. extendParams({
  27655. mousewheel: {
  27656. enabled: false,
  27657. releaseOnEdges: false,
  27658. invert: false,
  27659. forceToAxis: false,
  27660. sensitivity: 1,
  27661. eventsTarget: 'container',
  27662. thresholdDelta: null,
  27663. thresholdTime: null,
  27664. noMousewheelClass: 'swiper-no-mousewheel'
  27665. }
  27666. });
  27667. swiper.mousewheel = {
  27668. enabled: false
  27669. };
  27670. let timeout;
  27671. let lastScrollTime = now();
  27672. let lastEventBeforeSnap;
  27673. const recentWheelEvents = [];
  27674. function normalize(e) {
  27675. // Reasonable defaults
  27676. const PIXEL_STEP = 10;
  27677. const LINE_HEIGHT = 40;
  27678. const PAGE_HEIGHT = 800;
  27679. let sX = 0;
  27680. let sY = 0; // spinX, spinY
  27681. let pX = 0;
  27682. let pY = 0; // pixelX, pixelY
  27683. // Legacy
  27684. if ('detail' in e) {
  27685. sY = e.detail;
  27686. }
  27687. if ('wheelDelta' in e) {
  27688. sY = -e.wheelDelta / 120;
  27689. }
  27690. if ('wheelDeltaY' in e) {
  27691. sY = -e.wheelDeltaY / 120;
  27692. }
  27693. if ('wheelDeltaX' in e) {
  27694. sX = -e.wheelDeltaX / 120;
  27695. }
  27696. // side scrolling on FF with DOMMouseScroll
  27697. if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) {
  27698. sX = sY;
  27699. sY = 0;
  27700. }
  27701. pX = sX * PIXEL_STEP;
  27702. pY = sY * PIXEL_STEP;
  27703. if ('deltaY' in e) {
  27704. pY = e.deltaY;
  27705. }
  27706. if ('deltaX' in e) {
  27707. pX = e.deltaX;
  27708. }
  27709. if (e.shiftKey && !pX) {
  27710. // if user scrolls with shift he wants horizontal scroll
  27711. pX = pY;
  27712. pY = 0;
  27713. }
  27714. if ((pX || pY) && e.deltaMode) {
  27715. if (e.deltaMode === 1) {
  27716. // delta in LINE units
  27717. pX *= LINE_HEIGHT;
  27718. pY *= LINE_HEIGHT;
  27719. } else {
  27720. // delta in PAGE units
  27721. pX *= PAGE_HEIGHT;
  27722. pY *= PAGE_HEIGHT;
  27723. }
  27724. }
  27725. // Fall-back if spin cannot be determined
  27726. if (pX && !sX) {
  27727. sX = pX < 1 ? -1 : 1;
  27728. }
  27729. if (pY && !sY) {
  27730. sY = pY < 1 ? -1 : 1;
  27731. }
  27732. return {
  27733. spinX: sX,
  27734. spinY: sY,
  27735. pixelX: pX,
  27736. pixelY: pY
  27737. };
  27738. }
  27739. function handleMouseEnter() {
  27740. if (!swiper.enabled) return;
  27741. swiper.mouseEntered = true;
  27742. }
  27743. function handleMouseLeave() {
  27744. if (!swiper.enabled) return;
  27745. swiper.mouseEntered = false;
  27746. }
  27747. function animateSlider(newEvent) {
  27748. if (swiper.params.mousewheel.thresholdDelta && newEvent.delta < swiper.params.mousewheel.thresholdDelta) {
  27749. // Prevent if delta of wheel scroll delta is below configured threshold
  27750. return false;
  27751. }
  27752. if (swiper.params.mousewheel.thresholdTime && now() - lastScrollTime < swiper.params.mousewheel.thresholdTime) {
  27753. // Prevent if time between scrolls is below configured threshold
  27754. return false;
  27755. }
  27756. // If the movement is NOT big enough and
  27757. // if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider):
  27758. // Don't go any further (avoid insignificant scroll movement).
  27759. if (newEvent.delta >= 6 && now() - lastScrollTime < 60) {
  27760. // Return false as a default
  27761. return true;
  27762. }
  27763. // If user is scrolling towards the end:
  27764. // If the slider hasn't hit the latest slide or
  27765. // if the slider is a loop and
  27766. // if the slider isn't moving right now:
  27767. // Go to next slide and
  27768. // emit a scroll event.
  27769. // Else (the user is scrolling towards the beginning) and
  27770. // if the slider hasn't hit the first slide or
  27771. // if the slider is a loop and
  27772. // if the slider isn't moving right now:
  27773. // Go to prev slide and
  27774. // emit a scroll event.
  27775. if (newEvent.direction < 0) {
  27776. if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) {
  27777. swiper.slideNext();
  27778. emit('scroll', newEvent.raw);
  27779. }
  27780. } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) {
  27781. swiper.slidePrev();
  27782. emit('scroll', newEvent.raw);
  27783. }
  27784. // If you got here is because an animation has been triggered so store the current time
  27785. lastScrollTime = new window.Date().getTime();
  27786. // Return false as a default
  27787. return false;
  27788. }
  27789. function releaseScroll(newEvent) {
  27790. const params = swiper.params.mousewheel;
  27791. if (newEvent.direction < 0) {
  27792. if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) {
  27793. // Return true to animate scroll on edges
  27794. return true;
  27795. }
  27796. } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) {
  27797. // Return true to animate scroll on edges
  27798. return true;
  27799. }
  27800. return false;
  27801. }
  27802. function handle(event) {
  27803. let e = event;
  27804. let disableParentSwiper = true;
  27805. if (!swiper.enabled) return;
  27806. // Ignore event if the target or its parents have the swiper-no-mousewheel class
  27807. if (event.target.closest(`.${swiper.params.mousewheel.noMousewheelClass}`)) return;
  27808. const params = swiper.params.mousewheel;
  27809. if (swiper.params.cssMode) {
  27810. e.preventDefault();
  27811. }
  27812. let targetEl = swiper.el;
  27813. if (swiper.params.mousewheel.eventsTarget !== 'container') {
  27814. targetEl = document.querySelector(swiper.params.mousewheel.eventsTarget);
  27815. }
  27816. const targetElContainsTarget = targetEl && targetEl.contains(e.target);
  27817. if (!swiper.mouseEntered && !targetElContainsTarget && !params.releaseOnEdges) return true;
  27818. if (e.originalEvent) e = e.originalEvent; // jquery fix
  27819. let delta = 0;
  27820. const rtlFactor = swiper.rtlTranslate ? -1 : 1;
  27821. const data = normalize(e);
  27822. if (params.forceToAxis) {
  27823. if (swiper.isHorizontal()) {
  27824. if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true;
  27825. } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true;
  27826. } else {
  27827. delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
  27828. }
  27829. if (delta === 0) return true;
  27830. if (params.invert) delta = -delta;
  27831. // Get the scroll positions
  27832. let positions = swiper.getTranslate() + delta * params.sensitivity;
  27833. if (positions >= swiper.minTranslate()) positions = swiper.minTranslate();
  27834. if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate();
  27835. // When loop is true:
  27836. // the disableParentSwiper will be true.
  27837. // When loop is false:
  27838. // if the scroll positions is not on edge,
  27839. // then the disableParentSwiper will be true.
  27840. // if the scroll on edge positions,
  27841. // then the disableParentSwiper will be false.
  27842. disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate());
  27843. if (disableParentSwiper && swiper.params.nested) e.stopPropagation();
  27844. if (!swiper.params.freeMode || !swiper.params.freeMode.enabled) {
  27845. // Register the new event in a variable which stores the relevant data
  27846. const newEvent = {
  27847. time: now(),
  27848. delta: Math.abs(delta),
  27849. direction: Math.sign(delta),
  27850. raw: event
  27851. };
  27852. // Keep the most recent events
  27853. if (recentWheelEvents.length >= 2) {
  27854. recentWheelEvents.shift(); // only store the last N events
  27855. }
  27856. const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
  27857. recentWheelEvents.push(newEvent);
  27858. // If there is at least one previous recorded event:
  27859. // If direction has changed or
  27860. // if the scroll is quicker than the previous one:
  27861. // Animate the slider.
  27862. // Else (this is the first time the wheel is moved):
  27863. // Animate the slider.
  27864. if (prevEvent) {
  27865. if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) {
  27866. animateSlider(newEvent);
  27867. }
  27868. } else {
  27869. animateSlider(newEvent);
  27870. }
  27871. // If it's time to release the scroll:
  27872. // Return now so you don't hit the preventDefault.
  27873. if (releaseScroll(newEvent)) {
  27874. return true;
  27875. }
  27876. } else {
  27877. // Freemode or scrollContainer:
  27878. // If we recently snapped after a momentum scroll, then ignore wheel events
  27879. // to give time for the deceleration to finish. Stop ignoring after 500 msecs
  27880. // or if it's a new scroll (larger delta or inverse sign as last event before
  27881. // an end-of-momentum snap).
  27882. const newEvent = {
  27883. time: now(),
  27884. delta: Math.abs(delta),
  27885. direction: Math.sign(delta)
  27886. };
  27887. const ignoreWheelEvents = lastEventBeforeSnap && newEvent.time < lastEventBeforeSnap.time + 500 && newEvent.delta <= lastEventBeforeSnap.delta && newEvent.direction === lastEventBeforeSnap.direction;
  27888. if (!ignoreWheelEvents) {
  27889. lastEventBeforeSnap = undefined;
  27890. let position = swiper.getTranslate() + delta * params.sensitivity;
  27891. const wasBeginning = swiper.isBeginning;
  27892. const wasEnd = swiper.isEnd;
  27893. if (position >= swiper.minTranslate()) position = swiper.minTranslate();
  27894. if (position <= swiper.maxTranslate()) position = swiper.maxTranslate();
  27895. swiper.setTransition(0);
  27896. swiper.setTranslate(position);
  27897. swiper.updateProgress();
  27898. swiper.updateActiveIndex();
  27899. swiper.updateSlidesClasses();
  27900. if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) {
  27901. swiper.updateSlidesClasses();
  27902. }
  27903. if (swiper.params.loop) {
  27904. swiper.loopFix({
  27905. direction: newEvent.direction < 0 ? 'next' : 'prev',
  27906. byMousewheel: true
  27907. });
  27908. }
  27909. if (swiper.params.freeMode.sticky) {
  27910. // When wheel scrolling starts with sticky (aka snap) enabled, then detect
  27911. // the end of a momentum scroll by storing recent (N=15?) wheel events.
  27912. // 1. do all N events have decreasing or same (absolute value) delta?
  27913. // 2. did all N events arrive in the last M (M=500?) msecs?
  27914. // 3. does the earliest event have an (absolute value) delta that's
  27915. // at least P (P=1?) larger than the most recent event's delta?
  27916. // 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels?
  27917. // If 1-4 are "yes" then we're near the end of a momentum scroll deceleration.
  27918. // Snap immediately and ignore remaining wheel events in this scroll.
  27919. // See comment above for "remaining wheel events in this scroll" determination.
  27920. // If 1-4 aren't satisfied, then wait to snap until 500ms after the last event.
  27921. clearTimeout(timeout);
  27922. timeout = undefined;
  27923. if (recentWheelEvents.length >= 15) {
  27924. recentWheelEvents.shift(); // only store the last N events
  27925. }
  27926. const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
  27927. const firstEvent = recentWheelEvents[0];
  27928. recentWheelEvents.push(newEvent);
  27929. if (prevEvent && (newEvent.delta > prevEvent.delta || newEvent.direction !== prevEvent.direction)) {
  27930. // Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log.
  27931. recentWheelEvents.splice(0);
  27932. } else if (recentWheelEvents.length >= 15 && newEvent.time - firstEvent.time < 500 && firstEvent.delta - newEvent.delta >= 1 && newEvent.delta <= 6) {
  27933. // We're at the end of the deceleration of a momentum scroll, so there's no need
  27934. // to wait for more events. Snap ASAP on the next tick.
  27935. // Also, because there's some remaining momentum we'll bias the snap in the
  27936. // direction of the ongoing scroll because it's better UX for the scroll to snap
  27937. // in the same direction as the scroll instead of reversing to snap. Therefore,
  27938. // if it's already scrolled more than 20% in the current direction, keep going.
  27939. const snapToThreshold = delta > 0 ? 0.8 : 0.2;
  27940. lastEventBeforeSnap = newEvent;
  27941. recentWheelEvents.splice(0);
  27942. timeout = nextTick(() => {
  27943. swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
  27944. }, 0); // no delay; move on next tick
  27945. }
  27946. if (!timeout) {
  27947. // if we get here, then we haven't detected the end of a momentum scroll, so
  27948. // we'll consider a scroll "complete" when there haven't been any wheel events
  27949. // for 500ms.
  27950. timeout = nextTick(() => {
  27951. const snapToThreshold = 0.5;
  27952. lastEventBeforeSnap = newEvent;
  27953. recentWheelEvents.splice(0);
  27954. swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
  27955. }, 500);
  27956. }
  27957. }
  27958. // Emit event
  27959. if (!ignoreWheelEvents) emit('scroll', e);
  27960. // Stop autoplay
  27961. if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop();
  27962. // Return page scroll on edge positions
  27963. if (params.releaseOnEdges && (position === swiper.minTranslate() || position === swiper.maxTranslate())) {
  27964. return true;
  27965. }
  27966. }
  27967. }
  27968. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  27969. return false;
  27970. }
  27971. function events(method) {
  27972. let targetEl = swiper.el;
  27973. if (swiper.params.mousewheel.eventsTarget !== 'container') {
  27974. targetEl = document.querySelector(swiper.params.mousewheel.eventsTarget);
  27975. }
  27976. targetEl[method]('mouseenter', handleMouseEnter);
  27977. targetEl[method]('mouseleave', handleMouseLeave);
  27978. targetEl[method]('wheel', handle);
  27979. }
  27980. function enable() {
  27981. if (swiper.params.cssMode) {
  27982. swiper.wrapperEl.removeEventListener('wheel', handle);
  27983. return true;
  27984. }
  27985. if (swiper.mousewheel.enabled) return false;
  27986. events('addEventListener');
  27987. swiper.mousewheel.enabled = true;
  27988. return true;
  27989. }
  27990. function disable() {
  27991. if (swiper.params.cssMode) {
  27992. swiper.wrapperEl.addEventListener(event, handle);
  27993. return true;
  27994. }
  27995. if (!swiper.mousewheel.enabled) return false;
  27996. events('removeEventListener');
  27997. swiper.mousewheel.enabled = false;
  27998. return true;
  27999. }
  28000. on('init', () => {
  28001. if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) {
  28002. disable();
  28003. }
  28004. if (swiper.params.mousewheel.enabled) enable();
  28005. });
  28006. on('destroy', () => {
  28007. if (swiper.params.cssMode) {
  28008. enable();
  28009. }
  28010. if (swiper.mousewheel.enabled) disable();
  28011. });
  28012. Object.assign(swiper.mousewheel, {
  28013. enable,
  28014. disable
  28015. });
  28016. }
  28017. function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
  28018. if (swiper.params.createElements) {
  28019. Object.keys(checkProps).forEach(key => {
  28020. if (!params[key] && params.auto === true) {
  28021. let element = elementChildren(swiper.el, `.${checkProps[key]}`)[0];
  28022. if (!element) {
  28023. element = createElement('div', checkProps[key]);
  28024. element.className = checkProps[key];
  28025. swiper.el.append(element);
  28026. }
  28027. params[key] = element;
  28028. originalParams[key] = element;
  28029. }
  28030. });
  28031. }
  28032. return params;
  28033. }
  28034. function Navigation(_ref) {
  28035. let {
  28036. swiper,
  28037. extendParams,
  28038. on,
  28039. emit
  28040. } = _ref;
  28041. extendParams({
  28042. navigation: {
  28043. nextEl: null,
  28044. prevEl: null,
  28045. hideOnClick: false,
  28046. disabledClass: 'swiper-button-disabled',
  28047. hiddenClass: 'swiper-button-hidden',
  28048. lockClass: 'swiper-button-lock',
  28049. navigationDisabledClass: 'swiper-navigation-disabled'
  28050. }
  28051. });
  28052. swiper.navigation = {
  28053. nextEl: null,
  28054. prevEl: null
  28055. };
  28056. const makeElementsArray = el => (Array.isArray(el) ? el : [el]).filter(e => !!e);
  28057. function getEl(el) {
  28058. let res;
  28059. if (el && typeof el === 'string' && swiper.isElement) {
  28060. res = swiper.el.querySelector(el);
  28061. if (res) return res;
  28062. }
  28063. if (el) {
  28064. if (typeof el === 'string') res = [...document.querySelectorAll(el)];
  28065. if (swiper.params.uniqueNavElements && typeof el === 'string' && res.length > 1 && swiper.el.querySelectorAll(el).length === 1) {
  28066. res = swiper.el.querySelector(el);
  28067. }
  28068. }
  28069. if (el && !res) return el;
  28070. // if (Array.isArray(res) && res.length === 1) res = res[0];
  28071. return res;
  28072. }
  28073. function toggleEl(el, disabled) {
  28074. const params = swiper.params.navigation;
  28075. el = makeElementsArray(el);
  28076. el.forEach(subEl => {
  28077. if (subEl) {
  28078. subEl.classList[disabled ? 'add' : 'remove'](...params.disabledClass.split(' '));
  28079. if (subEl.tagName === 'BUTTON') subEl.disabled = disabled;
  28080. if (swiper.params.watchOverflow && swiper.enabled) {
  28081. subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
  28082. }
  28083. }
  28084. });
  28085. }
  28086. function update() {
  28087. // Update Navigation Buttons
  28088. const {
  28089. nextEl,
  28090. prevEl
  28091. } = swiper.navigation;
  28092. if (swiper.params.loop) {
  28093. toggleEl(prevEl, false);
  28094. toggleEl(nextEl, false);
  28095. return;
  28096. }
  28097. toggleEl(prevEl, swiper.isBeginning && !swiper.params.rewind);
  28098. toggleEl(nextEl, swiper.isEnd && !swiper.params.rewind);
  28099. }
  28100. function onPrevClick(e) {
  28101. e.preventDefault();
  28102. if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return;
  28103. swiper.slidePrev();
  28104. emit('navigationPrev');
  28105. }
  28106. function onNextClick(e) {
  28107. e.preventDefault();
  28108. if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return;
  28109. swiper.slideNext();
  28110. emit('navigationNext');
  28111. }
  28112. function init() {
  28113. const params = swiper.params.navigation;
  28114. swiper.params.navigation = createElementIfNotDefined(swiper, swiper.originalParams.navigation, swiper.params.navigation, {
  28115. nextEl: 'swiper-button-next',
  28116. prevEl: 'swiper-button-prev'
  28117. });
  28118. if (!(params.nextEl || params.prevEl)) return;
  28119. let nextEl = getEl(params.nextEl);
  28120. let prevEl = getEl(params.prevEl);
  28121. Object.assign(swiper.navigation, {
  28122. nextEl,
  28123. prevEl
  28124. });
  28125. nextEl = makeElementsArray(nextEl);
  28126. prevEl = makeElementsArray(prevEl);
  28127. const initButton = (el, dir) => {
  28128. if (el) {
  28129. el.addEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
  28130. }
  28131. if (!swiper.enabled && el) {
  28132. el.classList.add(...params.lockClass.split(' '));
  28133. }
  28134. };
  28135. nextEl.forEach(el => initButton(el, 'next'));
  28136. prevEl.forEach(el => initButton(el, 'prev'));
  28137. }
  28138. function destroy() {
  28139. let {
  28140. nextEl,
  28141. prevEl
  28142. } = swiper.navigation;
  28143. nextEl = makeElementsArray(nextEl);
  28144. prevEl = makeElementsArray(prevEl);
  28145. const destroyButton = (el, dir) => {
  28146. el.removeEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
  28147. el.classList.remove(...swiper.params.navigation.disabledClass.split(' '));
  28148. };
  28149. nextEl.forEach(el => destroyButton(el, 'next'));
  28150. prevEl.forEach(el => destroyButton(el, 'prev'));
  28151. }
  28152. on('init', () => {
  28153. if (swiper.params.navigation.enabled === false) {
  28154. // eslint-disable-next-line
  28155. disable();
  28156. } else {
  28157. init();
  28158. update();
  28159. }
  28160. });
  28161. on('toEdge fromEdge lock unlock', () => {
  28162. update();
  28163. });
  28164. on('destroy', () => {
  28165. destroy();
  28166. });
  28167. on('enable disable', () => {
  28168. let {
  28169. nextEl,
  28170. prevEl
  28171. } = swiper.navigation;
  28172. nextEl = makeElementsArray(nextEl);
  28173. prevEl = makeElementsArray(prevEl);
  28174. if (swiper.enabled) {
  28175. update();
  28176. return;
  28177. }
  28178. [...nextEl, ...prevEl].filter(el => !!el).forEach(el => el.classList.add(swiper.params.navigation.lockClass));
  28179. });
  28180. on('click', (_s, e) => {
  28181. let {
  28182. nextEl,
  28183. prevEl
  28184. } = swiper.navigation;
  28185. nextEl = makeElementsArray(nextEl);
  28186. prevEl = makeElementsArray(prevEl);
  28187. const targetEl = e.target;
  28188. if (swiper.params.navigation.hideOnClick && !prevEl.includes(targetEl) && !nextEl.includes(targetEl)) {
  28189. if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return;
  28190. let isHidden;
  28191. if (nextEl.length) {
  28192. isHidden = nextEl[0].classList.contains(swiper.params.navigation.hiddenClass);
  28193. } else if (prevEl.length) {
  28194. isHidden = prevEl[0].classList.contains(swiper.params.navigation.hiddenClass);
  28195. }
  28196. if (isHidden === true) {
  28197. emit('navigationShow');
  28198. } else {
  28199. emit('navigationHide');
  28200. }
  28201. [...nextEl, ...prevEl].filter(el => !!el).forEach(el => el.classList.toggle(swiper.params.navigation.hiddenClass));
  28202. }
  28203. });
  28204. const enable = () => {
  28205. swiper.el.classList.remove(...swiper.params.navigation.navigationDisabledClass.split(' '));
  28206. init();
  28207. update();
  28208. };
  28209. const disable = () => {
  28210. swiper.el.classList.add(...swiper.params.navigation.navigationDisabledClass.split(' '));
  28211. destroy();
  28212. };
  28213. Object.assign(swiper.navigation, {
  28214. enable,
  28215. disable,
  28216. update,
  28217. init,
  28218. destroy
  28219. });
  28220. }
  28221. function classesToSelector(classes) {
  28222. if (classes === void 0) {
  28223. classes = '';
  28224. }
  28225. return `.${classes.trim().replace(/([\.:!+\/])/g, '\\$1') // eslint-disable-line
  28226. .replace(/ /g, '.')}`;
  28227. }
  28228. function Pagination(_ref) {
  28229. let {
  28230. swiper,
  28231. extendParams,
  28232. on,
  28233. emit
  28234. } = _ref;
  28235. const pfx = 'swiper-pagination';
  28236. extendParams({
  28237. pagination: {
  28238. el: null,
  28239. bulletElement: 'span',
  28240. clickable: false,
  28241. hideOnClick: false,
  28242. renderBullet: null,
  28243. renderProgressbar: null,
  28244. renderFraction: null,
  28245. renderCustom: null,
  28246. progressbarOpposite: false,
  28247. type: 'bullets',
  28248. // 'bullets' or 'progressbar' or 'fraction' or 'custom'
  28249. dynamicBullets: false,
  28250. dynamicMainBullets: 1,
  28251. formatFractionCurrent: number => number,
  28252. formatFractionTotal: number => number,
  28253. bulletClass: `${pfx}-bullet`,
  28254. bulletActiveClass: `${pfx}-bullet-active`,
  28255. modifierClass: `${pfx}-`,
  28256. currentClass: `${pfx}-current`,
  28257. totalClass: `${pfx}-total`,
  28258. hiddenClass: `${pfx}-hidden`,
  28259. progressbarFillClass: `${pfx}-progressbar-fill`,
  28260. progressbarOppositeClass: `${pfx}-progressbar-opposite`,
  28261. clickableClass: `${pfx}-clickable`,
  28262. lockClass: `${pfx}-lock`,
  28263. horizontalClass: `${pfx}-horizontal`,
  28264. verticalClass: `${pfx}-vertical`,
  28265. paginationDisabledClass: `${pfx}-disabled`
  28266. }
  28267. });
  28268. swiper.pagination = {
  28269. el: null,
  28270. bullets: []
  28271. };
  28272. let bulletSize;
  28273. let dynamicBulletIndex = 0;
  28274. const makeElementsArray = el => (Array.isArray(el) ? el : [el]).filter(e => !!e);
  28275. function isPaginationDisabled() {
  28276. return !swiper.params.pagination.el || !swiper.pagination.el || Array.isArray(swiper.pagination.el) && swiper.pagination.el.length === 0;
  28277. }
  28278. function setSideBullets(bulletEl, position) {
  28279. const {
  28280. bulletActiveClass
  28281. } = swiper.params.pagination;
  28282. if (!bulletEl) return;
  28283. bulletEl = bulletEl[`${position === 'prev' ? 'previous' : 'next'}ElementSibling`];
  28284. if (bulletEl) {
  28285. bulletEl.classList.add(`${bulletActiveClass}-${position}`);
  28286. bulletEl = bulletEl[`${position === 'prev' ? 'previous' : 'next'}ElementSibling`];
  28287. if (bulletEl) {
  28288. bulletEl.classList.add(`${bulletActiveClass}-${position}-${position}`);
  28289. }
  28290. }
  28291. }
  28292. function onBulletClick(e) {
  28293. const bulletEl = e.target.closest(classesToSelector(swiper.params.pagination.bulletClass));
  28294. if (!bulletEl) {
  28295. return;
  28296. }
  28297. e.preventDefault();
  28298. const index = elementIndex(bulletEl) * swiper.params.slidesPerGroup;
  28299. if (swiper.params.loop) {
  28300. if (swiper.realIndex === index) return;
  28301. swiper.slideToLoop(index);
  28302. } else {
  28303. swiper.slideTo(index);
  28304. }
  28305. }
  28306. function update() {
  28307. // Render || Update Pagination bullets/items
  28308. const rtl = swiper.rtl;
  28309. const params = swiper.params.pagination;
  28310. if (isPaginationDisabled()) return;
  28311. let el = swiper.pagination.el;
  28312. el = makeElementsArray(el);
  28313. // Current/Total
  28314. let current;
  28315. let previousIndex;
  28316. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
  28317. const total = swiper.params.loop ? Math.ceil(slidesLength / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
  28318. if (swiper.params.loop) {
  28319. previousIndex = swiper.previousRealIndex || 0;
  28320. current = swiper.params.slidesPerGroup > 1 ? Math.floor(swiper.realIndex / swiper.params.slidesPerGroup) : swiper.realIndex;
  28321. } else if (typeof swiper.snapIndex !== 'undefined') {
  28322. current = swiper.snapIndex;
  28323. previousIndex = swiper.previousSnapIndex;
  28324. } else {
  28325. previousIndex = swiper.previousIndex || 0;
  28326. current = swiper.activeIndex || 0;
  28327. }
  28328. // Types
  28329. if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
  28330. const bullets = swiper.pagination.bullets;
  28331. let firstIndex;
  28332. let lastIndex;
  28333. let midIndex;
  28334. if (params.dynamicBullets) {
  28335. bulletSize = elementOuterSize(bullets[0], swiper.isHorizontal() ? 'width' : 'height', true);
  28336. el.forEach(subEl => {
  28337. subEl.style[swiper.isHorizontal() ? 'width' : 'height'] = `${bulletSize * (params.dynamicMainBullets + 4)}px`;
  28338. });
  28339. if (params.dynamicMainBullets > 1 && previousIndex !== undefined) {
  28340. dynamicBulletIndex += current - (previousIndex || 0);
  28341. if (dynamicBulletIndex > params.dynamicMainBullets - 1) {
  28342. dynamicBulletIndex = params.dynamicMainBullets - 1;
  28343. } else if (dynamicBulletIndex < 0) {
  28344. dynamicBulletIndex = 0;
  28345. }
  28346. }
  28347. firstIndex = Math.max(current - dynamicBulletIndex, 0);
  28348. lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
  28349. midIndex = (lastIndex + firstIndex) / 2;
  28350. }
  28351. bullets.forEach(bulletEl => {
  28352. const classesToRemove = [...['', '-next', '-next-next', '-prev', '-prev-prev', '-main'].map(suffix => `${params.bulletActiveClass}${suffix}`)].map(s => typeof s === 'string' && s.includes(' ') ? s.split(' ') : s).flat();
  28353. bulletEl.classList.remove(...classesToRemove);
  28354. });
  28355. if (el.length > 1) {
  28356. bullets.forEach(bullet => {
  28357. const bulletIndex = elementIndex(bullet);
  28358. if (bulletIndex === current) {
  28359. bullet.classList.add(...params.bulletActiveClass.split(' '));
  28360. } else if (swiper.isElement) {
  28361. bullet.setAttribute('part', 'bullet');
  28362. }
  28363. if (params.dynamicBullets) {
  28364. if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
  28365. bullet.classList.add(...`${params.bulletActiveClass}-main`.split(' '));
  28366. }
  28367. if (bulletIndex === firstIndex) {
  28368. setSideBullets(bullet, 'prev');
  28369. }
  28370. if (bulletIndex === lastIndex) {
  28371. setSideBullets(bullet, 'next');
  28372. }
  28373. }
  28374. });
  28375. } else {
  28376. const bullet = bullets[current];
  28377. if (bullet) {
  28378. bullet.classList.add(...params.bulletActiveClass.split(' '));
  28379. }
  28380. if (swiper.isElement) {
  28381. bullets.forEach((bulletEl, bulletIndex) => {
  28382. bulletEl.setAttribute('part', bulletIndex === current ? 'bullet-active' : 'bullet');
  28383. });
  28384. }
  28385. if (params.dynamicBullets) {
  28386. const firstDisplayedBullet = bullets[firstIndex];
  28387. const lastDisplayedBullet = bullets[lastIndex];
  28388. for (let i = firstIndex; i <= lastIndex; i += 1) {
  28389. if (bullets[i]) {
  28390. bullets[i].classList.add(...`${params.bulletActiveClass}-main`.split(' '));
  28391. }
  28392. }
  28393. setSideBullets(firstDisplayedBullet, 'prev');
  28394. setSideBullets(lastDisplayedBullet, 'next');
  28395. }
  28396. }
  28397. if (params.dynamicBullets) {
  28398. const dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4);
  28399. const bulletsOffset = (bulletSize * dynamicBulletsLength - bulletSize) / 2 - midIndex * bulletSize;
  28400. const offsetProp = rtl ? 'right' : 'left';
  28401. bullets.forEach(bullet => {
  28402. bullet.style[swiper.isHorizontal() ? offsetProp : 'top'] = `${bulletsOffset}px`;
  28403. });
  28404. }
  28405. }
  28406. el.forEach((subEl, subElIndex) => {
  28407. if (params.type === 'fraction') {
  28408. subEl.querySelectorAll(classesToSelector(params.currentClass)).forEach(fractionEl => {
  28409. fractionEl.textContent = params.formatFractionCurrent(current + 1);
  28410. });
  28411. subEl.querySelectorAll(classesToSelector(params.totalClass)).forEach(totalEl => {
  28412. totalEl.textContent = params.formatFractionTotal(total);
  28413. });
  28414. }
  28415. if (params.type === 'progressbar') {
  28416. let progressbarDirection;
  28417. if (params.progressbarOpposite) {
  28418. progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
  28419. } else {
  28420. progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
  28421. }
  28422. const scale = (current + 1) / total;
  28423. let scaleX = 1;
  28424. let scaleY = 1;
  28425. if (progressbarDirection === 'horizontal') {
  28426. scaleX = scale;
  28427. } else {
  28428. scaleY = scale;
  28429. }
  28430. subEl.querySelectorAll(classesToSelector(params.progressbarFillClass)).forEach(progressEl => {
  28431. progressEl.style.transform = `translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`;
  28432. progressEl.style.transitionDuration = `${swiper.params.speed}ms`;
  28433. });
  28434. }
  28435. if (params.type === 'custom' && params.renderCustom) {
  28436. subEl.innerHTML = params.renderCustom(swiper, current + 1, total);
  28437. if (subElIndex === 0) emit('paginationRender', subEl);
  28438. } else {
  28439. if (subElIndex === 0) emit('paginationRender', subEl);
  28440. emit('paginationUpdate', subEl);
  28441. }
  28442. if (swiper.params.watchOverflow && swiper.enabled) {
  28443. subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
  28444. }
  28445. });
  28446. }
  28447. function render() {
  28448. // Render Container
  28449. const params = swiper.params.pagination;
  28450. if (isPaginationDisabled()) return;
  28451. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.grid && swiper.params.grid.rows > 1 ? swiper.slides.length / Math.ceil(swiper.params.grid.rows) : swiper.slides.length;
  28452. let el = swiper.pagination.el;
  28453. el = makeElementsArray(el);
  28454. let paginationHTML = '';
  28455. if (params.type === 'bullets') {
  28456. let numberOfBullets = swiper.params.loop ? Math.ceil(slidesLength / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
  28457. if (swiper.params.freeMode && swiper.params.freeMode.enabled && numberOfBullets > slidesLength) {
  28458. numberOfBullets = slidesLength;
  28459. }
  28460. for (let i = 0; i < numberOfBullets; i += 1) {
  28461. if (params.renderBullet) {
  28462. paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
  28463. } else {
  28464. // prettier-ignore
  28465. paginationHTML += `<${params.bulletElement} ${swiper.isElement ? 'part="bullet"' : ''} class="${params.bulletClass}"></${params.bulletElement}>`;
  28466. }
  28467. }
  28468. }
  28469. if (params.type === 'fraction') {
  28470. if (params.renderFraction) {
  28471. paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass);
  28472. } else {
  28473. paginationHTML = `<span class="${params.currentClass}"></span>` + ' / ' + `<span class="${params.totalClass}"></span>`;
  28474. }
  28475. }
  28476. if (params.type === 'progressbar') {
  28477. if (params.renderProgressbar) {
  28478. paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass);
  28479. } else {
  28480. paginationHTML = `<span class="${params.progressbarFillClass}"></span>`;
  28481. }
  28482. }
  28483. swiper.pagination.bullets = [];
  28484. el.forEach(subEl => {
  28485. if (params.type !== 'custom') {
  28486. subEl.innerHTML = paginationHTML || '';
  28487. }
  28488. if (params.type === 'bullets') {
  28489. swiper.pagination.bullets.push(...subEl.querySelectorAll(classesToSelector(params.bulletClass)));
  28490. }
  28491. });
  28492. if (params.type !== 'custom') {
  28493. emit('paginationRender', el[0]);
  28494. }
  28495. }
  28496. function init() {
  28497. swiper.params.pagination = createElementIfNotDefined(swiper, swiper.originalParams.pagination, swiper.params.pagination, {
  28498. el: 'swiper-pagination'
  28499. });
  28500. const params = swiper.params.pagination;
  28501. if (!params.el) return;
  28502. let el;
  28503. if (typeof params.el === 'string' && swiper.isElement) {
  28504. el = swiper.el.querySelector(params.el);
  28505. }
  28506. if (!el && typeof params.el === 'string') {
  28507. el = [...document.querySelectorAll(params.el)];
  28508. }
  28509. if (!el) {
  28510. el = params.el;
  28511. }
  28512. if (!el || el.length === 0) return;
  28513. if (swiper.params.uniqueNavElements && typeof params.el === 'string' && Array.isArray(el) && el.length > 1) {
  28514. el = [...swiper.el.querySelectorAll(params.el)];
  28515. // check if it belongs to another nested Swiper
  28516. if (el.length > 1) {
  28517. el = el.filter(subEl => {
  28518. if (elementParents(subEl, '.swiper')[0] !== swiper.el) return false;
  28519. return true;
  28520. })[0];
  28521. }
  28522. }
  28523. if (Array.isArray(el) && el.length === 1) el = el[0];
  28524. Object.assign(swiper.pagination, {
  28525. el
  28526. });
  28527. el = makeElementsArray(el);
  28528. el.forEach(subEl => {
  28529. if (params.type === 'bullets' && params.clickable) {
  28530. subEl.classList.add(...(params.clickableClass || '').split(' '));
  28531. }
  28532. subEl.classList.add(params.modifierClass + params.type);
  28533. subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28534. if (params.type === 'bullets' && params.dynamicBullets) {
  28535. subEl.classList.add(`${params.modifierClass}${params.type}-dynamic`);
  28536. dynamicBulletIndex = 0;
  28537. if (params.dynamicMainBullets < 1) {
  28538. params.dynamicMainBullets = 1;
  28539. }
  28540. }
  28541. if (params.type === 'progressbar' && params.progressbarOpposite) {
  28542. subEl.classList.add(params.progressbarOppositeClass);
  28543. }
  28544. if (params.clickable) {
  28545. subEl.addEventListener('click', onBulletClick);
  28546. }
  28547. if (!swiper.enabled) {
  28548. subEl.classList.add(params.lockClass);
  28549. }
  28550. });
  28551. }
  28552. function destroy() {
  28553. const params = swiper.params.pagination;
  28554. if (isPaginationDisabled()) return;
  28555. let el = swiper.pagination.el;
  28556. if (el) {
  28557. el = makeElementsArray(el);
  28558. el.forEach(subEl => {
  28559. subEl.classList.remove(params.hiddenClass);
  28560. subEl.classList.remove(params.modifierClass + params.type);
  28561. subEl.classList.remove(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28562. if (params.clickable) {
  28563. subEl.classList.remove(...(params.clickableClass || '').split(' '));
  28564. subEl.removeEventListener('click', onBulletClick);
  28565. }
  28566. });
  28567. }
  28568. if (swiper.pagination.bullets) swiper.pagination.bullets.forEach(subEl => subEl.classList.remove(...params.bulletActiveClass.split(' ')));
  28569. }
  28570. on('changeDirection', () => {
  28571. if (!swiper.pagination || !swiper.pagination.el) return;
  28572. const params = swiper.params.pagination;
  28573. let {
  28574. el
  28575. } = swiper.pagination;
  28576. el = makeElementsArray(el);
  28577. el.forEach(subEl => {
  28578. subEl.classList.remove(params.horizontalClass, params.verticalClass);
  28579. subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28580. });
  28581. });
  28582. on('init', () => {
  28583. if (swiper.params.pagination.enabled === false) {
  28584. // eslint-disable-next-line
  28585. disable();
  28586. } else {
  28587. init();
  28588. render();
  28589. update();
  28590. }
  28591. });
  28592. on('activeIndexChange', () => {
  28593. if (typeof swiper.snapIndex === 'undefined') {
  28594. update();
  28595. }
  28596. });
  28597. on('snapIndexChange', () => {
  28598. update();
  28599. });
  28600. on('snapGridLengthChange', () => {
  28601. render();
  28602. update();
  28603. });
  28604. on('destroy', () => {
  28605. destroy();
  28606. });
  28607. on('enable disable', () => {
  28608. let {
  28609. el
  28610. } = swiper.pagination;
  28611. if (el) {
  28612. el = makeElementsArray(el);
  28613. el.forEach(subEl => subEl.classList[swiper.enabled ? 'remove' : 'add'](swiper.params.pagination.lockClass));
  28614. }
  28615. });
  28616. on('lock unlock', () => {
  28617. update();
  28618. });
  28619. on('click', (_s, e) => {
  28620. const targetEl = e.target;
  28621. const el = makeElementsArray(swiper.pagination.el);
  28622. if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && el && el.length > 0 && !targetEl.classList.contains(swiper.params.pagination.bulletClass)) {
  28623. if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return;
  28624. const isHidden = el[0].classList.contains(swiper.params.pagination.hiddenClass);
  28625. if (isHidden === true) {
  28626. emit('paginationShow');
  28627. } else {
  28628. emit('paginationHide');
  28629. }
  28630. el.forEach(subEl => subEl.classList.toggle(swiper.params.pagination.hiddenClass));
  28631. }
  28632. });
  28633. const enable = () => {
  28634. swiper.el.classList.remove(swiper.params.pagination.paginationDisabledClass);
  28635. let {
  28636. el
  28637. } = swiper.pagination;
  28638. if (el) {
  28639. el = makeElementsArray(el);
  28640. el.forEach(subEl => subEl.classList.remove(swiper.params.pagination.paginationDisabledClass));
  28641. }
  28642. init();
  28643. render();
  28644. update();
  28645. };
  28646. const disable = () => {
  28647. swiper.el.classList.add(swiper.params.pagination.paginationDisabledClass);
  28648. let {
  28649. el
  28650. } = swiper.pagination;
  28651. if (el) {
  28652. el = makeElementsArray(el);
  28653. el.forEach(subEl => subEl.classList.add(swiper.params.pagination.paginationDisabledClass));
  28654. }
  28655. destroy();
  28656. };
  28657. Object.assign(swiper.pagination, {
  28658. enable,
  28659. disable,
  28660. render,
  28661. update,
  28662. init,
  28663. destroy
  28664. });
  28665. }
  28666. function Scrollbar(_ref) {
  28667. let {
  28668. swiper,
  28669. extendParams,
  28670. on,
  28671. emit
  28672. } = _ref;
  28673. const document = getDocument();
  28674. let isTouched = false;
  28675. let timeout = null;
  28676. let dragTimeout = null;
  28677. let dragStartPos;
  28678. let dragSize;
  28679. let trackSize;
  28680. let divider;
  28681. extendParams({
  28682. scrollbar: {
  28683. el: null,
  28684. dragSize: 'auto',
  28685. hide: false,
  28686. draggable: false,
  28687. snapOnRelease: true,
  28688. lockClass: 'swiper-scrollbar-lock',
  28689. dragClass: 'swiper-scrollbar-drag',
  28690. scrollbarDisabledClass: 'swiper-scrollbar-disabled',
  28691. horizontalClass: `swiper-scrollbar-horizontal`,
  28692. verticalClass: `swiper-scrollbar-vertical`
  28693. }
  28694. });
  28695. swiper.scrollbar = {
  28696. el: null,
  28697. dragEl: null
  28698. };
  28699. function setTranslate() {
  28700. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28701. const {
  28702. scrollbar,
  28703. rtlTranslate: rtl
  28704. } = swiper;
  28705. const {
  28706. dragEl,
  28707. el
  28708. } = scrollbar;
  28709. const params = swiper.params.scrollbar;
  28710. const progress = swiper.params.loop ? swiper.progressLoop : swiper.progress;
  28711. let newSize = dragSize;
  28712. let newPos = (trackSize - dragSize) * progress;
  28713. if (rtl) {
  28714. newPos = -newPos;
  28715. if (newPos > 0) {
  28716. newSize = dragSize - newPos;
  28717. newPos = 0;
  28718. } else if (-newPos + dragSize > trackSize) {
  28719. newSize = trackSize + newPos;
  28720. }
  28721. } else if (newPos < 0) {
  28722. newSize = dragSize + newPos;
  28723. newPos = 0;
  28724. } else if (newPos + dragSize > trackSize) {
  28725. newSize = trackSize - newPos;
  28726. }
  28727. if (swiper.isHorizontal()) {
  28728. dragEl.style.transform = `translate3d(${newPos}px, 0, 0)`;
  28729. dragEl.style.width = `${newSize}px`;
  28730. } else {
  28731. dragEl.style.transform = `translate3d(0px, ${newPos}px, 0)`;
  28732. dragEl.style.height = `${newSize}px`;
  28733. }
  28734. if (params.hide) {
  28735. clearTimeout(timeout);
  28736. el.style.opacity = 1;
  28737. timeout = setTimeout(() => {
  28738. el.style.opacity = 0;
  28739. el.style.transitionDuration = '400ms';
  28740. }, 1000);
  28741. }
  28742. }
  28743. function setTransition(duration) {
  28744. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28745. swiper.scrollbar.dragEl.style.transitionDuration = `${duration}ms`;
  28746. }
  28747. function updateSize() {
  28748. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28749. const {
  28750. scrollbar
  28751. } = swiper;
  28752. const {
  28753. dragEl,
  28754. el
  28755. } = scrollbar;
  28756. dragEl.style.width = '';
  28757. dragEl.style.height = '';
  28758. trackSize = swiper.isHorizontal() ? el.offsetWidth : el.offsetHeight;
  28759. divider = swiper.size / (swiper.virtualSize + swiper.params.slidesOffsetBefore - (swiper.params.centeredSlides ? swiper.snapGrid[0] : 0));
  28760. if (swiper.params.scrollbar.dragSize === 'auto') {
  28761. dragSize = trackSize * divider;
  28762. } else {
  28763. dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
  28764. }
  28765. if (swiper.isHorizontal()) {
  28766. dragEl.style.width = `${dragSize}px`;
  28767. } else {
  28768. dragEl.style.height = `${dragSize}px`;
  28769. }
  28770. if (divider >= 1) {
  28771. el.style.display = 'none';
  28772. } else {
  28773. el.style.display = '';
  28774. }
  28775. if (swiper.params.scrollbar.hide) {
  28776. el.style.opacity = 0;
  28777. }
  28778. if (swiper.params.watchOverflow && swiper.enabled) {
  28779. scrollbar.el.classList[swiper.isLocked ? 'add' : 'remove'](swiper.params.scrollbar.lockClass);
  28780. }
  28781. }
  28782. function getPointerPosition(e) {
  28783. return swiper.isHorizontal() ? e.clientX : e.clientY;
  28784. }
  28785. function setDragPosition(e) {
  28786. const {
  28787. scrollbar,
  28788. rtlTranslate: rtl
  28789. } = swiper;
  28790. const {
  28791. el
  28792. } = scrollbar;
  28793. let positionRatio;
  28794. positionRatio = (getPointerPosition(e) - elementOffset(el)[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
  28795. positionRatio = Math.max(Math.min(positionRatio, 1), 0);
  28796. if (rtl) {
  28797. positionRatio = 1 - positionRatio;
  28798. }
  28799. const position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio;
  28800. swiper.updateProgress(position);
  28801. swiper.setTranslate(position);
  28802. swiper.updateActiveIndex();
  28803. swiper.updateSlidesClasses();
  28804. }
  28805. function onDragStart(e) {
  28806. const params = swiper.params.scrollbar;
  28807. const {
  28808. scrollbar,
  28809. wrapperEl
  28810. } = swiper;
  28811. const {
  28812. el,
  28813. dragEl
  28814. } = scrollbar;
  28815. isTouched = true;
  28816. dragStartPos = e.target === dragEl ? getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
  28817. e.preventDefault();
  28818. e.stopPropagation();
  28819. wrapperEl.style.transitionDuration = '100ms';
  28820. dragEl.style.transitionDuration = '100ms';
  28821. setDragPosition(e);
  28822. clearTimeout(dragTimeout);
  28823. el.style.transitionDuration = '0ms';
  28824. if (params.hide) {
  28825. el.style.opacity = 1;
  28826. }
  28827. if (swiper.params.cssMode) {
  28828. swiper.wrapperEl.style['scroll-snap-type'] = 'none';
  28829. }
  28830. emit('scrollbarDragStart', e);
  28831. }
  28832. function onDragMove(e) {
  28833. const {
  28834. scrollbar,
  28835. wrapperEl
  28836. } = swiper;
  28837. const {
  28838. el,
  28839. dragEl
  28840. } = scrollbar;
  28841. if (!isTouched) return;
  28842. if (e.preventDefault) e.preventDefault();else e.returnValue = false;
  28843. setDragPosition(e);
  28844. wrapperEl.style.transitionDuration = '0ms';
  28845. el.style.transitionDuration = '0ms';
  28846. dragEl.style.transitionDuration = '0ms';
  28847. emit('scrollbarDragMove', e);
  28848. }
  28849. function onDragEnd(e) {
  28850. const params = swiper.params.scrollbar;
  28851. const {
  28852. scrollbar,
  28853. wrapperEl
  28854. } = swiper;
  28855. const {
  28856. el
  28857. } = scrollbar;
  28858. if (!isTouched) return;
  28859. isTouched = false;
  28860. if (swiper.params.cssMode) {
  28861. swiper.wrapperEl.style['scroll-snap-type'] = '';
  28862. wrapperEl.style.transitionDuration = '';
  28863. }
  28864. if (params.hide) {
  28865. clearTimeout(dragTimeout);
  28866. dragTimeout = nextTick(() => {
  28867. el.style.opacity = 0;
  28868. el.style.transitionDuration = '400ms';
  28869. }, 1000);
  28870. }
  28871. emit('scrollbarDragEnd', e);
  28872. if (params.snapOnRelease) {
  28873. swiper.slideToClosest();
  28874. }
  28875. }
  28876. function events(method) {
  28877. const {
  28878. scrollbar,
  28879. params
  28880. } = swiper;
  28881. const el = scrollbar.el;
  28882. if (!el) return;
  28883. const target = el;
  28884. const activeListener = params.passiveListeners ? {
  28885. passive: false,
  28886. capture: false
  28887. } : false;
  28888. const passiveListener = params.passiveListeners ? {
  28889. passive: true,
  28890. capture: false
  28891. } : false;
  28892. if (!target) return;
  28893. const eventMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
  28894. target[eventMethod]('pointerdown', onDragStart, activeListener);
  28895. document[eventMethod]('pointermove', onDragMove, activeListener);
  28896. document[eventMethod]('pointerup', onDragEnd, passiveListener);
  28897. }
  28898. function enableDraggable() {
  28899. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28900. events('on');
  28901. }
  28902. function disableDraggable() {
  28903. if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
  28904. events('off');
  28905. }
  28906. function init() {
  28907. const {
  28908. scrollbar,
  28909. el: swiperEl
  28910. } = swiper;
  28911. swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, {
  28912. el: 'swiper-scrollbar'
  28913. });
  28914. const params = swiper.params.scrollbar;
  28915. if (!params.el) return;
  28916. let el;
  28917. if (typeof params.el === 'string' && swiper.isElement) {
  28918. el = swiper.el.querySelector(params.el);
  28919. }
  28920. if (!el && typeof params.el === 'string') {
  28921. el = document.querySelectorAll(params.el);
  28922. if (!el.length) return;
  28923. } else if (!el) {
  28924. el = params.el;
  28925. }
  28926. if (swiper.params.uniqueNavElements && typeof params.el === 'string' && el.length > 1 && swiperEl.querySelectorAll(params.el).length === 1) {
  28927. el = swiperEl.querySelector(params.el);
  28928. }
  28929. if (el.length > 0) el = el[0];
  28930. el.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
  28931. let dragEl;
  28932. if (el) {
  28933. dragEl = el.querySelector(classesToSelector(swiper.params.scrollbar.dragClass));
  28934. if (!dragEl) {
  28935. dragEl = createElement('div', swiper.params.scrollbar.dragClass);
  28936. el.append(dragEl);
  28937. }
  28938. }
  28939. Object.assign(scrollbar, {
  28940. el,
  28941. dragEl
  28942. });
  28943. if (params.draggable) {
  28944. enableDraggable();
  28945. }
  28946. if (el) {
  28947. el.classList[swiper.enabled ? 'remove' : 'add'](...classesToTokens(swiper.params.scrollbar.lockClass));
  28948. }
  28949. }
  28950. function destroy() {
  28951. const params = swiper.params.scrollbar;
  28952. const el = swiper.scrollbar.el;
  28953. if (el) {
  28954. el.classList.remove(...classesToTokens(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass));
  28955. }
  28956. disableDraggable();
  28957. }
  28958. on('init', () => {
  28959. if (swiper.params.scrollbar.enabled === false) {
  28960. // eslint-disable-next-line
  28961. disable();
  28962. } else {
  28963. init();
  28964. updateSize();
  28965. setTranslate();
  28966. }
  28967. });
  28968. on('update resize observerUpdate lock unlock', () => {
  28969. updateSize();
  28970. });
  28971. on('setTranslate', () => {
  28972. setTranslate();
  28973. });
  28974. on('setTransition', (_s, duration) => {
  28975. setTransition(duration);
  28976. });
  28977. on('enable disable', () => {
  28978. const {
  28979. el
  28980. } = swiper.scrollbar;
  28981. if (el) {
  28982. el.classList[swiper.enabled ? 'remove' : 'add'](...classesToTokens(swiper.params.scrollbar.lockClass));
  28983. }
  28984. });
  28985. on('destroy', () => {
  28986. destroy();
  28987. });
  28988. const enable = () => {
  28989. swiper.el.classList.remove(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  28990. if (swiper.scrollbar.el) {
  28991. swiper.scrollbar.el.classList.remove(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  28992. }
  28993. init();
  28994. updateSize();
  28995. setTranslate();
  28996. };
  28997. const disable = () => {
  28998. swiper.el.classList.add(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  28999. if (swiper.scrollbar.el) {
  29000. swiper.scrollbar.el.classList.add(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
  29001. }
  29002. destroy();
  29003. };
  29004. Object.assign(swiper.scrollbar, {
  29005. enable,
  29006. disable,
  29007. updateSize,
  29008. setTranslate,
  29009. init,
  29010. destroy
  29011. });
  29012. }
  29013. function Parallax(_ref) {
  29014. let {
  29015. swiper,
  29016. extendParams,
  29017. on
  29018. } = _ref;
  29019. extendParams({
  29020. parallax: {
  29021. enabled: false
  29022. }
  29023. });
  29024. const elementsSelector = '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]';
  29025. const setTransform = (el, progress) => {
  29026. const {
  29027. rtl
  29028. } = swiper;
  29029. const rtlFactor = rtl ? -1 : 1;
  29030. const p = el.getAttribute('data-swiper-parallax') || '0';
  29031. let x = el.getAttribute('data-swiper-parallax-x');
  29032. let y = el.getAttribute('data-swiper-parallax-y');
  29033. const scale = el.getAttribute('data-swiper-parallax-scale');
  29034. const opacity = el.getAttribute('data-swiper-parallax-opacity');
  29035. const rotate = el.getAttribute('data-swiper-parallax-rotate');
  29036. if (x || y) {
  29037. x = x || '0';
  29038. y = y || '0';
  29039. } else if (swiper.isHorizontal()) {
  29040. x = p;
  29041. y = '0';
  29042. } else {
  29043. y = p;
  29044. x = '0';
  29045. }
  29046. if (x.indexOf('%') >= 0) {
  29047. x = `${parseInt(x, 10) * progress * rtlFactor}%`;
  29048. } else {
  29049. x = `${x * progress * rtlFactor}px`;
  29050. }
  29051. if (y.indexOf('%') >= 0) {
  29052. y = `${parseInt(y, 10) * progress}%`;
  29053. } else {
  29054. y = `${y * progress}px`;
  29055. }
  29056. if (typeof opacity !== 'undefined' && opacity !== null) {
  29057. const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
  29058. el.style.opacity = currentOpacity;
  29059. }
  29060. let transform = `translate3d(${x}, ${y}, 0px)`;
  29061. if (typeof scale !== 'undefined' && scale !== null) {
  29062. const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
  29063. transform += ` scale(${currentScale})`;
  29064. }
  29065. if (rotate && typeof rotate !== 'undefined' && rotate !== null) {
  29066. const currentRotate = rotate * progress * -1;
  29067. transform += ` rotate(${currentRotate}deg)`;
  29068. }
  29069. el.style.transform = transform;
  29070. };
  29071. const setTranslate = () => {
  29072. const {
  29073. el,
  29074. slides,
  29075. progress,
  29076. snapGrid,
  29077. isElement
  29078. } = swiper;
  29079. const elements = elementChildren(el, elementsSelector);
  29080. if (swiper.isElement) {
  29081. elements.push(...elementChildren(swiper.hostEl, elementsSelector));
  29082. }
  29083. elements.forEach(subEl => {
  29084. setTransform(subEl, progress);
  29085. });
  29086. slides.forEach((slideEl, slideIndex) => {
  29087. let slideProgress = slideEl.progress;
  29088. if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
  29089. slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
  29090. }
  29091. slideProgress = Math.min(Math.max(slideProgress, -1), 1);
  29092. slideEl.querySelectorAll(`${elementsSelector}, [data-swiper-parallax-rotate]`).forEach(subEl => {
  29093. setTransform(subEl, slideProgress);
  29094. });
  29095. });
  29096. };
  29097. const setTransition = function (duration) {
  29098. if (duration === void 0) {
  29099. duration = swiper.params.speed;
  29100. }
  29101. const {
  29102. el,
  29103. hostEl
  29104. } = swiper;
  29105. const elements = [...el.querySelectorAll(elementsSelector)];
  29106. if (swiper.isElement) {
  29107. elements.push(...hostEl.querySelectorAll(elementsSelector));
  29108. }
  29109. elements.forEach(parallaxEl => {
  29110. let parallaxDuration = parseInt(parallaxEl.getAttribute('data-swiper-parallax-duration'), 10) || duration;
  29111. if (duration === 0) parallaxDuration = 0;
  29112. parallaxEl.style.transitionDuration = `${parallaxDuration}ms`;
  29113. });
  29114. };
  29115. on('beforeInit', () => {
  29116. if (!swiper.params.parallax.enabled) return;
  29117. swiper.params.watchSlidesProgress = true;
  29118. swiper.originalParams.watchSlidesProgress = true;
  29119. });
  29120. on('init', () => {
  29121. if (!swiper.params.parallax.enabled) return;
  29122. setTranslate();
  29123. });
  29124. on('setTranslate', () => {
  29125. if (!swiper.params.parallax.enabled) return;
  29126. setTranslate();
  29127. });
  29128. on('setTransition', (_swiper, duration) => {
  29129. if (!swiper.params.parallax.enabled) return;
  29130. setTransition(duration);
  29131. });
  29132. }
  29133. function Zoom(_ref) {
  29134. let {
  29135. swiper,
  29136. extendParams,
  29137. on,
  29138. emit
  29139. } = _ref;
  29140. const window = getWindow();
  29141. extendParams({
  29142. zoom: {
  29143. enabled: false,
  29144. maxRatio: 3,
  29145. minRatio: 1,
  29146. toggle: true,
  29147. containerClass: 'swiper-zoom-container',
  29148. zoomedSlideClass: 'swiper-slide-zoomed'
  29149. }
  29150. });
  29151. swiper.zoom = {
  29152. enabled: false
  29153. };
  29154. let currentScale = 1;
  29155. let isScaling = false;
  29156. let fakeGestureTouched;
  29157. let fakeGestureMoved;
  29158. const evCache = [];
  29159. const gesture = {
  29160. originX: 0,
  29161. originY: 0,
  29162. slideEl: undefined,
  29163. slideWidth: undefined,
  29164. slideHeight: undefined,
  29165. imageEl: undefined,
  29166. imageWrapEl: undefined,
  29167. maxRatio: 3
  29168. };
  29169. const image = {
  29170. isTouched: undefined,
  29171. isMoved: undefined,
  29172. currentX: undefined,
  29173. currentY: undefined,
  29174. minX: undefined,
  29175. minY: undefined,
  29176. maxX: undefined,
  29177. maxY: undefined,
  29178. width: undefined,
  29179. height: undefined,
  29180. startX: undefined,
  29181. startY: undefined,
  29182. touchesStart: {},
  29183. touchesCurrent: {}
  29184. };
  29185. const velocity = {
  29186. x: undefined,
  29187. y: undefined,
  29188. prevPositionX: undefined,
  29189. prevPositionY: undefined,
  29190. prevTime: undefined
  29191. };
  29192. let scale = 1;
  29193. Object.defineProperty(swiper.zoom, 'scale', {
  29194. get() {
  29195. return scale;
  29196. },
  29197. set(value) {
  29198. if (scale !== value) {
  29199. const imageEl = gesture.imageEl;
  29200. const slideEl = gesture.slideEl;
  29201. emit('zoomChange', value, imageEl, slideEl);
  29202. }
  29203. scale = value;
  29204. }
  29205. });
  29206. function getDistanceBetweenTouches() {
  29207. if (evCache.length < 2) return 1;
  29208. const x1 = evCache[0].pageX;
  29209. const y1 = evCache[0].pageY;
  29210. const x2 = evCache[1].pageX;
  29211. const y2 = evCache[1].pageY;
  29212. const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
  29213. return distance;
  29214. }
  29215. function getScaleOrigin() {
  29216. if (evCache.length < 2) return {
  29217. x: null,
  29218. y: null
  29219. };
  29220. const box = gesture.imageEl.getBoundingClientRect();
  29221. return [(evCache[0].pageX + (evCache[1].pageX - evCache[0].pageX) / 2 - box.x - window.scrollX) / currentScale, (evCache[0].pageY + (evCache[1].pageY - evCache[0].pageY) / 2 - box.y - window.scrollY) / currentScale];
  29222. }
  29223. function getSlideSelector() {
  29224. return swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
  29225. }
  29226. function eventWithinSlide(e) {
  29227. const slideSelector = getSlideSelector();
  29228. if (e.target.matches(slideSelector)) return true;
  29229. if (swiper.slides.filter(slideEl => slideEl.contains(e.target)).length > 0) return true;
  29230. return false;
  29231. }
  29232. function eventWithinZoomContainer(e) {
  29233. const selector = `.${swiper.params.zoom.containerClass}`;
  29234. if (e.target.matches(selector)) return true;
  29235. if ([...swiper.hostEl.querySelectorAll(selector)].filter(containerEl => containerEl.contains(e.target)).length > 0) return true;
  29236. return false;
  29237. }
  29238. // Events
  29239. function onGestureStart(e) {
  29240. if (e.pointerType === 'mouse') {
  29241. evCache.splice(0, evCache.length);
  29242. }
  29243. if (!eventWithinSlide(e)) return;
  29244. const params = swiper.params.zoom;
  29245. fakeGestureTouched = false;
  29246. fakeGestureMoved = false;
  29247. evCache.push(e);
  29248. if (evCache.length < 2) {
  29249. return;
  29250. }
  29251. fakeGestureTouched = true;
  29252. gesture.scaleStart = getDistanceBetweenTouches();
  29253. if (!gesture.slideEl) {
  29254. gesture.slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
  29255. if (!gesture.slideEl) gesture.slideEl = swiper.slides[swiper.activeIndex];
  29256. let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
  29257. if (imageEl) {
  29258. imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
  29259. }
  29260. gesture.imageEl = imageEl;
  29261. if (imageEl) {
  29262. gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
  29263. } else {
  29264. gesture.imageWrapEl = undefined;
  29265. }
  29266. if (!gesture.imageWrapEl) {
  29267. gesture.imageEl = undefined;
  29268. return;
  29269. }
  29270. gesture.maxRatio = gesture.imageWrapEl.getAttribute('data-swiper-zoom') || params.maxRatio;
  29271. }
  29272. if (gesture.imageEl) {
  29273. const [originX, originY] = getScaleOrigin();
  29274. gesture.originX = originX;
  29275. gesture.originY = originY;
  29276. gesture.imageEl.style.transitionDuration = '0ms';
  29277. }
  29278. isScaling = true;
  29279. }
  29280. function onGestureChange(e) {
  29281. if (!eventWithinSlide(e)) return;
  29282. const params = swiper.params.zoom;
  29283. const zoom = swiper.zoom;
  29284. const pointerIndex = evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
  29285. if (pointerIndex >= 0) evCache[pointerIndex] = e;
  29286. if (evCache.length < 2) {
  29287. return;
  29288. }
  29289. fakeGestureMoved = true;
  29290. gesture.scaleMove = getDistanceBetweenTouches();
  29291. if (!gesture.imageEl) {
  29292. return;
  29293. }
  29294. zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale;
  29295. if (zoom.scale > gesture.maxRatio) {
  29296. zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5;
  29297. }
  29298. if (zoom.scale < params.minRatio) {
  29299. zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5;
  29300. }
  29301. gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
  29302. }
  29303. function onGestureEnd(e) {
  29304. if (!eventWithinSlide(e)) return;
  29305. if (e.pointerType === 'mouse' && e.type === 'pointerout') return;
  29306. const params = swiper.params.zoom;
  29307. const zoom = swiper.zoom;
  29308. const pointerIndex = evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
  29309. if (pointerIndex >= 0) evCache.splice(pointerIndex, 1);
  29310. if (!fakeGestureTouched || !fakeGestureMoved) {
  29311. return;
  29312. }
  29313. fakeGestureTouched = false;
  29314. fakeGestureMoved = false;
  29315. if (!gesture.imageEl) return;
  29316. zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
  29317. gesture.imageEl.style.transitionDuration = `${swiper.params.speed}ms`;
  29318. gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
  29319. currentScale = zoom.scale;
  29320. isScaling = false;
  29321. if (zoom.scale > 1 && gesture.slideEl) {
  29322. gesture.slideEl.classList.add(`${params.zoomedSlideClass}`);
  29323. } else if (zoom.scale <= 1 && gesture.slideEl) {
  29324. gesture.slideEl.classList.remove(`${params.zoomedSlideClass}`);
  29325. }
  29326. if (zoom.scale === 1) {
  29327. gesture.originX = 0;
  29328. gesture.originY = 0;
  29329. gesture.slideEl = undefined;
  29330. }
  29331. }
  29332. function onTouchStart(e) {
  29333. const device = swiper.device;
  29334. if (!gesture.imageEl) return;
  29335. if (image.isTouched) return;
  29336. if (device.android && e.cancelable) e.preventDefault();
  29337. image.isTouched = true;
  29338. const event = evCache.length > 0 ? evCache[0] : e;
  29339. image.touchesStart.x = event.pageX;
  29340. image.touchesStart.y = event.pageY;
  29341. }
  29342. function onTouchMove(e) {
  29343. if (!eventWithinSlide(e) || !eventWithinZoomContainer(e)) return;
  29344. const zoom = swiper.zoom;
  29345. if (!gesture.imageEl) return;
  29346. if (!image.isTouched || !gesture.slideEl) return;
  29347. if (!image.isMoved) {
  29348. image.width = gesture.imageEl.offsetWidth;
  29349. image.height = gesture.imageEl.offsetHeight;
  29350. image.startX = getTranslate(gesture.imageWrapEl, 'x') || 0;
  29351. image.startY = getTranslate(gesture.imageWrapEl, 'y') || 0;
  29352. gesture.slideWidth = gesture.slideEl.offsetWidth;
  29353. gesture.slideHeight = gesture.slideEl.offsetHeight;
  29354. gesture.imageWrapEl.style.transitionDuration = '0ms';
  29355. }
  29356. // Define if we need image drag
  29357. const scaledWidth = image.width * zoom.scale;
  29358. const scaledHeight = image.height * zoom.scale;
  29359. if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return;
  29360. image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
  29361. image.maxX = -image.minX;
  29362. image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
  29363. image.maxY = -image.minY;
  29364. image.touchesCurrent.x = evCache.length > 0 ? evCache[0].pageX : e.pageX;
  29365. image.touchesCurrent.y = evCache.length > 0 ? evCache[0].pageY : e.pageY;
  29366. const touchesDiff = Math.max(Math.abs(image.touchesCurrent.x - image.touchesStart.x), Math.abs(image.touchesCurrent.y - image.touchesStart.y));
  29367. if (touchesDiff > 5) {
  29368. swiper.allowClick = false;
  29369. }
  29370. if (!image.isMoved && !isScaling) {
  29371. if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
  29372. image.isTouched = false;
  29373. return;
  29374. }
  29375. if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
  29376. image.isTouched = false;
  29377. return;
  29378. }
  29379. }
  29380. if (e.cancelable) {
  29381. e.preventDefault();
  29382. }
  29383. e.stopPropagation();
  29384. image.isMoved = true;
  29385. const scaleRatio = (zoom.scale - currentScale) / (gesture.maxRatio - swiper.params.zoom.minRatio);
  29386. const {
  29387. originX,
  29388. originY
  29389. } = gesture;
  29390. image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX + scaleRatio * (image.width - originX * 2);
  29391. image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY + scaleRatio * (image.height - originY * 2);
  29392. if (image.currentX < image.minX) {
  29393. image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8;
  29394. }
  29395. if (image.currentX > image.maxX) {
  29396. image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8;
  29397. }
  29398. if (image.currentY < image.minY) {
  29399. image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8;
  29400. }
  29401. if (image.currentY > image.maxY) {
  29402. image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8;
  29403. }
  29404. // Velocity
  29405. if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
  29406. if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
  29407. if (!velocity.prevTime) velocity.prevTime = Date.now();
  29408. velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
  29409. velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
  29410. if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
  29411. if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
  29412. velocity.prevPositionX = image.touchesCurrent.x;
  29413. velocity.prevPositionY = image.touchesCurrent.y;
  29414. velocity.prevTime = Date.now();
  29415. gesture.imageWrapEl.style.transform = `translate3d(${image.currentX}px, ${image.currentY}px,0)`;
  29416. }
  29417. function onTouchEnd() {
  29418. const zoom = swiper.zoom;
  29419. if (!gesture.imageEl) return;
  29420. if (!image.isTouched || !image.isMoved) {
  29421. image.isTouched = false;
  29422. image.isMoved = false;
  29423. return;
  29424. }
  29425. image.isTouched = false;
  29426. image.isMoved = false;
  29427. let momentumDurationX = 300;
  29428. let momentumDurationY = 300;
  29429. const momentumDistanceX = velocity.x * momentumDurationX;
  29430. const newPositionX = image.currentX + momentumDistanceX;
  29431. const momentumDistanceY = velocity.y * momentumDurationY;
  29432. const newPositionY = image.currentY + momentumDistanceY;
  29433. // Fix duration
  29434. if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
  29435. if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
  29436. const momentumDuration = Math.max(momentumDurationX, momentumDurationY);
  29437. image.currentX = newPositionX;
  29438. image.currentY = newPositionY;
  29439. // Define if we need image drag
  29440. const scaledWidth = image.width * zoom.scale;
  29441. const scaledHeight = image.height * zoom.scale;
  29442. image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
  29443. image.maxX = -image.minX;
  29444. image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
  29445. image.maxY = -image.minY;
  29446. image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
  29447. image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
  29448. gesture.imageWrapEl.style.transitionDuration = `${momentumDuration}ms`;
  29449. gesture.imageWrapEl.style.transform = `translate3d(${image.currentX}px, ${image.currentY}px,0)`;
  29450. }
  29451. function onTransitionEnd() {
  29452. const zoom = swiper.zoom;
  29453. if (gesture.slideEl && swiper.activeIndex !== swiper.slides.indexOf(gesture.slideEl)) {
  29454. if (gesture.imageEl) {
  29455. gesture.imageEl.style.transform = 'translate3d(0,0,0) scale(1)';
  29456. }
  29457. if (gesture.imageWrapEl) {
  29458. gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
  29459. }
  29460. gesture.slideEl.classList.remove(`${swiper.params.zoom.zoomedSlideClass}`);
  29461. zoom.scale = 1;
  29462. currentScale = 1;
  29463. gesture.slideEl = undefined;
  29464. gesture.imageEl = undefined;
  29465. gesture.imageWrapEl = undefined;
  29466. gesture.originX = 0;
  29467. gesture.originY = 0;
  29468. }
  29469. }
  29470. function zoomIn(e) {
  29471. const zoom = swiper.zoom;
  29472. const params = swiper.params.zoom;
  29473. if (!gesture.slideEl) {
  29474. if (e && e.target) {
  29475. gesture.slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
  29476. }
  29477. if (!gesture.slideEl) {
  29478. if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
  29479. gesture.slideEl = elementChildren(swiper.slidesEl, `.${swiper.params.slideActiveClass}`)[0];
  29480. } else {
  29481. gesture.slideEl = swiper.slides[swiper.activeIndex];
  29482. }
  29483. }
  29484. let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
  29485. if (imageEl) {
  29486. imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
  29487. }
  29488. gesture.imageEl = imageEl;
  29489. if (imageEl) {
  29490. gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
  29491. } else {
  29492. gesture.imageWrapEl = undefined;
  29493. }
  29494. }
  29495. if (!gesture.imageEl || !gesture.imageWrapEl) return;
  29496. if (swiper.params.cssMode) {
  29497. swiper.wrapperEl.style.overflow = 'hidden';
  29498. swiper.wrapperEl.style.touchAction = 'none';
  29499. }
  29500. gesture.slideEl.classList.add(`${params.zoomedSlideClass}`);
  29501. let touchX;
  29502. let touchY;
  29503. let offsetX;
  29504. let offsetY;
  29505. let diffX;
  29506. let diffY;
  29507. let translateX;
  29508. let translateY;
  29509. let imageWidth;
  29510. let imageHeight;
  29511. let scaledWidth;
  29512. let scaledHeight;
  29513. let translateMinX;
  29514. let translateMinY;
  29515. let translateMaxX;
  29516. let translateMaxY;
  29517. let slideWidth;
  29518. let slideHeight;
  29519. if (typeof image.touchesStart.x === 'undefined' && e) {
  29520. touchX = e.pageX;
  29521. touchY = e.pageY;
  29522. } else {
  29523. touchX = image.touchesStart.x;
  29524. touchY = image.touchesStart.y;
  29525. }
  29526. const forceZoomRatio = typeof e === 'number' ? e : null;
  29527. if (currentScale === 1 && forceZoomRatio) {
  29528. touchX = undefined;
  29529. touchY = undefined;
  29530. }
  29531. zoom.scale = forceZoomRatio || gesture.imageWrapEl.getAttribute('data-swiper-zoom') || params.maxRatio;
  29532. currentScale = forceZoomRatio || gesture.imageWrapEl.getAttribute('data-swiper-zoom') || params.maxRatio;
  29533. if (e && !(currentScale === 1 && forceZoomRatio)) {
  29534. slideWidth = gesture.slideEl.offsetWidth;
  29535. slideHeight = gesture.slideEl.offsetHeight;
  29536. offsetX = elementOffset(gesture.slideEl).left + window.scrollX;
  29537. offsetY = elementOffset(gesture.slideEl).top + window.scrollY;
  29538. diffX = offsetX + slideWidth / 2 - touchX;
  29539. diffY = offsetY + slideHeight / 2 - touchY;
  29540. imageWidth = gesture.imageEl.offsetWidth;
  29541. imageHeight = gesture.imageEl.offsetHeight;
  29542. scaledWidth = imageWidth * zoom.scale;
  29543. scaledHeight = imageHeight * zoom.scale;
  29544. translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
  29545. translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
  29546. translateMaxX = -translateMinX;
  29547. translateMaxY = -translateMinY;
  29548. translateX = diffX * zoom.scale;
  29549. translateY = diffY * zoom.scale;
  29550. if (translateX < translateMinX) {
  29551. translateX = translateMinX;
  29552. }
  29553. if (translateX > translateMaxX) {
  29554. translateX = translateMaxX;
  29555. }
  29556. if (translateY < translateMinY) {
  29557. translateY = translateMinY;
  29558. }
  29559. if (translateY > translateMaxY) {
  29560. translateY = translateMaxY;
  29561. }
  29562. } else {
  29563. translateX = 0;
  29564. translateY = 0;
  29565. }
  29566. if (forceZoomRatio && zoom.scale === 1) {
  29567. gesture.originX = 0;
  29568. gesture.originY = 0;
  29569. }
  29570. gesture.imageWrapEl.style.transitionDuration = '300ms';
  29571. gesture.imageWrapEl.style.transform = `translate3d(${translateX}px, ${translateY}px,0)`;
  29572. gesture.imageEl.style.transitionDuration = '300ms';
  29573. gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
  29574. }
  29575. function zoomOut() {
  29576. const zoom = swiper.zoom;
  29577. const params = swiper.params.zoom;
  29578. if (!gesture.slideEl) {
  29579. if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
  29580. gesture.slideEl = elementChildren(swiper.slidesEl, `.${swiper.params.slideActiveClass}`)[0];
  29581. } else {
  29582. gesture.slideEl = swiper.slides[swiper.activeIndex];
  29583. }
  29584. let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
  29585. if (imageEl) {
  29586. imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
  29587. }
  29588. gesture.imageEl = imageEl;
  29589. if (imageEl) {
  29590. gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
  29591. } else {
  29592. gesture.imageWrapEl = undefined;
  29593. }
  29594. }
  29595. if (!gesture.imageEl || !gesture.imageWrapEl) return;
  29596. if (swiper.params.cssMode) {
  29597. swiper.wrapperEl.style.overflow = '';
  29598. swiper.wrapperEl.style.touchAction = '';
  29599. }
  29600. zoom.scale = 1;
  29601. currentScale = 1;
  29602. gesture.imageWrapEl.style.transitionDuration = '300ms';
  29603. gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
  29604. gesture.imageEl.style.transitionDuration = '300ms';
  29605. gesture.imageEl.style.transform = 'translate3d(0,0,0) scale(1)';
  29606. gesture.slideEl.classList.remove(`${params.zoomedSlideClass}`);
  29607. gesture.slideEl = undefined;
  29608. gesture.originX = 0;
  29609. gesture.originY = 0;
  29610. }
  29611. // Toggle Zoom
  29612. function zoomToggle(e) {
  29613. const zoom = swiper.zoom;
  29614. if (zoom.scale && zoom.scale !== 1) {
  29615. // Zoom Out
  29616. zoomOut();
  29617. } else {
  29618. // Zoom In
  29619. zoomIn(e);
  29620. }
  29621. }
  29622. function getListeners() {
  29623. const passiveListener = swiper.params.passiveListeners ? {
  29624. passive: true,
  29625. capture: false
  29626. } : false;
  29627. const activeListenerWithCapture = swiper.params.passiveListeners ? {
  29628. passive: false,
  29629. capture: true
  29630. } : true;
  29631. return {
  29632. passiveListener,
  29633. activeListenerWithCapture
  29634. };
  29635. }
  29636. // Attach/Detach Events
  29637. function enable() {
  29638. const zoom = swiper.zoom;
  29639. if (zoom.enabled) return;
  29640. zoom.enabled = true;
  29641. const {
  29642. passiveListener,
  29643. activeListenerWithCapture
  29644. } = getListeners();
  29645. // Scale image
  29646. swiper.wrapperEl.addEventListener('pointerdown', onGestureStart, passiveListener);
  29647. swiper.wrapperEl.addEventListener('pointermove', onGestureChange, activeListenerWithCapture);
  29648. ['pointerup', 'pointercancel', 'pointerout'].forEach(eventName => {
  29649. swiper.wrapperEl.addEventListener(eventName, onGestureEnd, passiveListener);
  29650. });
  29651. // Move image
  29652. swiper.wrapperEl.addEventListener('pointermove', onTouchMove, activeListenerWithCapture);
  29653. }
  29654. function disable() {
  29655. const zoom = swiper.zoom;
  29656. if (!zoom.enabled) return;
  29657. zoom.enabled = false;
  29658. const {
  29659. passiveListener,
  29660. activeListenerWithCapture
  29661. } = getListeners();
  29662. // Scale image
  29663. swiper.wrapperEl.removeEventListener('pointerdown', onGestureStart, passiveListener);
  29664. swiper.wrapperEl.removeEventListener('pointermove', onGestureChange, activeListenerWithCapture);
  29665. ['pointerup', 'pointercancel', 'pointerout'].forEach(eventName => {
  29666. swiper.wrapperEl.removeEventListener(eventName, onGestureEnd, passiveListener);
  29667. });
  29668. // Move image
  29669. swiper.wrapperEl.removeEventListener('pointermove', onTouchMove, activeListenerWithCapture);
  29670. }
  29671. on('init', () => {
  29672. if (swiper.params.zoom.enabled) {
  29673. enable();
  29674. }
  29675. });
  29676. on('destroy', () => {
  29677. disable();
  29678. });
  29679. on('touchStart', (_s, e) => {
  29680. if (!swiper.zoom.enabled) return;
  29681. onTouchStart(e);
  29682. });
  29683. on('touchEnd', (_s, e) => {
  29684. if (!swiper.zoom.enabled) return;
  29685. onTouchEnd();
  29686. });
  29687. on('doubleTap', (_s, e) => {
  29688. if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
  29689. zoomToggle(e);
  29690. }
  29691. });
  29692. on('transitionEnd', () => {
  29693. if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
  29694. onTransitionEnd();
  29695. }
  29696. });
  29697. on('slideChange', () => {
  29698. if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
  29699. onTransitionEnd();
  29700. }
  29701. });
  29702. Object.assign(swiper.zoom, {
  29703. enable,
  29704. disable,
  29705. in: zoomIn,
  29706. out: zoomOut,
  29707. toggle: zoomToggle
  29708. });
  29709. }
  29710. /* eslint no-bitwise: ["error", { "allow": [">>"] }] */
  29711. function Controller(_ref) {
  29712. let {
  29713. swiper,
  29714. extendParams,
  29715. on
  29716. } = _ref;
  29717. extendParams({
  29718. controller: {
  29719. control: undefined,
  29720. inverse: false,
  29721. by: 'slide' // or 'container'
  29722. }
  29723. });
  29724. swiper.controller = {
  29725. control: undefined
  29726. };
  29727. function LinearSpline(x, y) {
  29728. const binarySearch = function search() {
  29729. let maxIndex;
  29730. let minIndex;
  29731. let guess;
  29732. return (array, val) => {
  29733. minIndex = -1;
  29734. maxIndex = array.length;
  29735. while (maxIndex - minIndex > 1) {
  29736. guess = maxIndex + minIndex >> 1;
  29737. if (array[guess] <= val) {
  29738. minIndex = guess;
  29739. } else {
  29740. maxIndex = guess;
  29741. }
  29742. }
  29743. return maxIndex;
  29744. };
  29745. }();
  29746. this.x = x;
  29747. this.y = y;
  29748. this.lastIndex = x.length - 1;
  29749. // Given an x value (x2), return the expected y2 value:
  29750. // (x1,y1) is the known point before given value,
  29751. // (x3,y3) is the known point after given value.
  29752. let i1;
  29753. let i3;
  29754. this.interpolate = function interpolate(x2) {
  29755. if (!x2) return 0;
  29756. // Get the indexes of x1 and x3 (the array indexes before and after given x2):
  29757. i3 = binarySearch(this.x, x2);
  29758. i1 = i3 - 1;
  29759. // We have our indexes i1 & i3, so we can calculate already:
  29760. // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
  29761. return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
  29762. };
  29763. return this;
  29764. }
  29765. function getInterpolateFunction(c) {
  29766. swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid);
  29767. }
  29768. function setTranslate(_t, byController) {
  29769. const controlled = swiper.controller.control;
  29770. let multiplier;
  29771. let controlledTranslate;
  29772. const Swiper = swiper.constructor;
  29773. function setControlledTranslate(c) {
  29774. if (c.destroyed) return;
  29775. // this will create an Interpolate function based on the snapGrids
  29776. // x is the Grid of the scrolled scroller and y will be the controlled scroller
  29777. // it makes sense to create this only once and recall it for the interpolation
  29778. // the function does a lot of value caching for performance
  29779. const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
  29780. if (swiper.params.controller.by === 'slide') {
  29781. getInterpolateFunction(c);
  29782. // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
  29783. // but it did not work out
  29784. controlledTranslate = -swiper.controller.spline.interpolate(-translate);
  29785. }
  29786. if (!controlledTranslate || swiper.params.controller.by === 'container') {
  29787. multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
  29788. if (Number.isNaN(multiplier) || !Number.isFinite(multiplier)) {
  29789. multiplier = 1;
  29790. }
  29791. controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
  29792. }
  29793. if (swiper.params.controller.inverse) {
  29794. controlledTranslate = c.maxTranslate() - controlledTranslate;
  29795. }
  29796. c.updateProgress(controlledTranslate);
  29797. c.setTranslate(controlledTranslate, swiper);
  29798. c.updateActiveIndex();
  29799. c.updateSlidesClasses();
  29800. }
  29801. if (Array.isArray(controlled)) {
  29802. for (let i = 0; i < controlled.length; i += 1) {
  29803. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  29804. setControlledTranslate(controlled[i]);
  29805. }
  29806. }
  29807. } else if (controlled instanceof Swiper && byController !== controlled) {
  29808. setControlledTranslate(controlled);
  29809. }
  29810. }
  29811. function setTransition(duration, byController) {
  29812. const Swiper = swiper.constructor;
  29813. const controlled = swiper.controller.control;
  29814. let i;
  29815. function setControlledTransition(c) {
  29816. if (c.destroyed) return;
  29817. c.setTransition(duration, swiper);
  29818. if (duration !== 0) {
  29819. c.transitionStart();
  29820. if (c.params.autoHeight) {
  29821. nextTick(() => {
  29822. c.updateAutoHeight();
  29823. });
  29824. }
  29825. elementTransitionEnd(c.wrapperEl, () => {
  29826. if (!controlled) return;
  29827. c.transitionEnd();
  29828. });
  29829. }
  29830. }
  29831. if (Array.isArray(controlled)) {
  29832. for (i = 0; i < controlled.length; i += 1) {
  29833. if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
  29834. setControlledTransition(controlled[i]);
  29835. }
  29836. }
  29837. } else if (controlled instanceof Swiper && byController !== controlled) {
  29838. setControlledTransition(controlled);
  29839. }
  29840. }
  29841. function removeSpline() {
  29842. if (!swiper.controller.control) return;
  29843. if (swiper.controller.spline) {
  29844. swiper.controller.spline = undefined;
  29845. delete swiper.controller.spline;
  29846. }
  29847. }
  29848. on('beforeInit', () => {
  29849. if (typeof window !== 'undefined' && (
  29850. // eslint-disable-line
  29851. typeof swiper.params.controller.control === 'string' || swiper.params.controller.control instanceof HTMLElement)) {
  29852. const controlElement = document.querySelector(swiper.params.controller.control);
  29853. if (controlElement && controlElement.swiper) {
  29854. swiper.controller.control = controlElement.swiper;
  29855. } else if (controlElement) {
  29856. const onControllerSwiper = e => {
  29857. swiper.controller.control = e.detail[0];
  29858. swiper.update();
  29859. controlElement.removeEventListener('init', onControllerSwiper);
  29860. };
  29861. controlElement.addEventListener('init', onControllerSwiper);
  29862. }
  29863. return;
  29864. }
  29865. swiper.controller.control = swiper.params.controller.control;
  29866. });
  29867. on('update', () => {
  29868. removeSpline();
  29869. });
  29870. on('resize', () => {
  29871. removeSpline();
  29872. });
  29873. on('observerUpdate', () => {
  29874. removeSpline();
  29875. });
  29876. on('setTranslate', (_s, translate, byController) => {
  29877. if (!swiper.controller.control || swiper.controller.control.destroyed) return;
  29878. swiper.controller.setTranslate(translate, byController);
  29879. });
  29880. on('setTransition', (_s, duration, byController) => {
  29881. if (!swiper.controller.control || swiper.controller.control.destroyed) return;
  29882. swiper.controller.setTransition(duration, byController);
  29883. });
  29884. Object.assign(swiper.controller, {
  29885. setTranslate,
  29886. setTransition
  29887. });
  29888. }
  29889. function A11y(_ref) {
  29890. let {
  29891. swiper,
  29892. extendParams,
  29893. on
  29894. } = _ref;
  29895. extendParams({
  29896. a11y: {
  29897. enabled: true,
  29898. notificationClass: 'swiper-notification',
  29899. prevSlideMessage: 'Previous slide',
  29900. nextSlideMessage: 'Next slide',
  29901. firstSlideMessage: 'This is the first slide',
  29902. lastSlideMessage: 'This is the last slide',
  29903. paginationBulletMessage: 'Go to slide {{index}}',
  29904. slideLabelMessage: '{{index}} / {{slidesLength}}',
  29905. containerMessage: null,
  29906. containerRoleDescriptionMessage: null,
  29907. itemRoleDescriptionMessage: null,
  29908. slideRole: 'group',
  29909. id: null
  29910. }
  29911. });
  29912. swiper.a11y = {
  29913. clicked: false
  29914. };
  29915. let liveRegion = null;
  29916. function notify(message) {
  29917. const notification = liveRegion;
  29918. if (notification.length === 0) return;
  29919. notification.innerHTML = '';
  29920. notification.innerHTML = message;
  29921. }
  29922. const makeElementsArray = el => (Array.isArray(el) ? el : [el]).filter(e => !!e);
  29923. function getRandomNumber(size) {
  29924. if (size === void 0) {
  29925. size = 16;
  29926. }
  29927. const randomChar = () => Math.round(16 * Math.random()).toString(16);
  29928. return 'x'.repeat(size).replace(/x/g, randomChar);
  29929. }
  29930. function makeElFocusable(el) {
  29931. el = makeElementsArray(el);
  29932. el.forEach(subEl => {
  29933. subEl.setAttribute('tabIndex', '0');
  29934. });
  29935. }
  29936. function makeElNotFocusable(el) {
  29937. el = makeElementsArray(el);
  29938. el.forEach(subEl => {
  29939. subEl.setAttribute('tabIndex', '-1');
  29940. });
  29941. }
  29942. function addElRole(el, role) {
  29943. el = makeElementsArray(el);
  29944. el.forEach(subEl => {
  29945. subEl.setAttribute('role', role);
  29946. });
  29947. }
  29948. function addElRoleDescription(el, description) {
  29949. el = makeElementsArray(el);
  29950. el.forEach(subEl => {
  29951. subEl.setAttribute('aria-roledescription', description);
  29952. });
  29953. }
  29954. function addElControls(el, controls) {
  29955. el = makeElementsArray(el);
  29956. el.forEach(subEl => {
  29957. subEl.setAttribute('aria-controls', controls);
  29958. });
  29959. }
  29960. function addElLabel(el, label) {
  29961. el = makeElementsArray(el);
  29962. el.forEach(subEl => {
  29963. subEl.setAttribute('aria-label', label);
  29964. });
  29965. }
  29966. function addElId(el, id) {
  29967. el = makeElementsArray(el);
  29968. el.forEach(subEl => {
  29969. subEl.setAttribute('id', id);
  29970. });
  29971. }
  29972. function addElLive(el, live) {
  29973. el = makeElementsArray(el);
  29974. el.forEach(subEl => {
  29975. subEl.setAttribute('aria-live', live);
  29976. });
  29977. }
  29978. function disableEl(el) {
  29979. el = makeElementsArray(el);
  29980. el.forEach(subEl => {
  29981. subEl.setAttribute('aria-disabled', true);
  29982. });
  29983. }
  29984. function enableEl(el) {
  29985. el = makeElementsArray(el);
  29986. el.forEach(subEl => {
  29987. subEl.setAttribute('aria-disabled', false);
  29988. });
  29989. }
  29990. function onEnterOrSpaceKey(e) {
  29991. if (e.keyCode !== 13 && e.keyCode !== 32) return;
  29992. const params = swiper.params.a11y;
  29993. const targetEl = e.target;
  29994. if (swiper.pagination && swiper.pagination.el && (targetEl === swiper.pagination.el || swiper.pagination.el.contains(e.target))) {
  29995. if (!e.target.matches(classesToSelector(swiper.params.pagination.bulletClass))) return;
  29996. }
  29997. if (swiper.navigation && swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl) {
  29998. if (!(swiper.isEnd && !swiper.params.loop)) {
  29999. swiper.slideNext();
  30000. }
  30001. if (swiper.isEnd) {
  30002. notify(params.lastSlideMessage);
  30003. } else {
  30004. notify(params.nextSlideMessage);
  30005. }
  30006. }
  30007. if (swiper.navigation && swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl) {
  30008. if (!(swiper.isBeginning && !swiper.params.loop)) {
  30009. swiper.slidePrev();
  30010. }
  30011. if (swiper.isBeginning) {
  30012. notify(params.firstSlideMessage);
  30013. } else {
  30014. notify(params.prevSlideMessage);
  30015. }
  30016. }
  30017. if (swiper.pagination && targetEl.matches(classesToSelector(swiper.params.pagination.bulletClass))) {
  30018. targetEl.click();
  30019. }
  30020. }
  30021. function updateNavigation() {
  30022. if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
  30023. const {
  30024. nextEl,
  30025. prevEl
  30026. } = swiper.navigation;
  30027. if (prevEl) {
  30028. if (swiper.isBeginning) {
  30029. disableEl(prevEl);
  30030. makeElNotFocusable(prevEl);
  30031. } else {
  30032. enableEl(prevEl);
  30033. makeElFocusable(prevEl);
  30034. }
  30035. }
  30036. if (nextEl) {
  30037. if (swiper.isEnd) {
  30038. disableEl(nextEl);
  30039. makeElNotFocusable(nextEl);
  30040. } else {
  30041. enableEl(nextEl);
  30042. makeElFocusable(nextEl);
  30043. }
  30044. }
  30045. }
  30046. function hasPagination() {
  30047. return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
  30048. }
  30049. function hasClickablePagination() {
  30050. return hasPagination() && swiper.params.pagination.clickable;
  30051. }
  30052. function updatePagination() {
  30053. const params = swiper.params.a11y;
  30054. if (!hasPagination()) return;
  30055. swiper.pagination.bullets.forEach(bulletEl => {
  30056. if (swiper.params.pagination.clickable) {
  30057. makeElFocusable(bulletEl);
  30058. if (!swiper.params.pagination.renderBullet) {
  30059. addElRole(bulletEl, 'button');
  30060. addElLabel(bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, elementIndex(bulletEl) + 1));
  30061. }
  30062. }
  30063. if (bulletEl.matches(classesToSelector(swiper.params.pagination.bulletActiveClass))) {
  30064. bulletEl.setAttribute('aria-current', 'true');
  30065. } else {
  30066. bulletEl.removeAttribute('aria-current');
  30067. }
  30068. });
  30069. }
  30070. const initNavEl = (el, wrapperId, message) => {
  30071. makeElFocusable(el);
  30072. if (el.tagName !== 'BUTTON') {
  30073. addElRole(el, 'button');
  30074. el.addEventListener('keydown', onEnterOrSpaceKey);
  30075. }
  30076. addElLabel(el, message);
  30077. addElControls(el, wrapperId);
  30078. };
  30079. const handlePointerDown = () => {
  30080. swiper.a11y.clicked = true;
  30081. };
  30082. const handlePointerUp = () => {
  30083. requestAnimationFrame(() => {
  30084. requestAnimationFrame(() => {
  30085. if (!swiper.destroyed) {
  30086. swiper.a11y.clicked = false;
  30087. }
  30088. });
  30089. });
  30090. };
  30091. const handleFocus = e => {
  30092. if (swiper.a11y.clicked) return;
  30093. const slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
  30094. if (!slideEl || !swiper.slides.includes(slideEl)) return;
  30095. const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
  30096. const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
  30097. if (isActive || isVisible) return;
  30098. if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
  30099. if (swiper.isHorizontal()) {
  30100. swiper.el.scrollLeft = 0;
  30101. } else {
  30102. swiper.el.scrollTop = 0;
  30103. }
  30104. swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
  30105. };
  30106. const initSlides = () => {
  30107. const params = swiper.params.a11y;
  30108. if (params.itemRoleDescriptionMessage) {
  30109. addElRoleDescription(swiper.slides, params.itemRoleDescriptionMessage);
  30110. }
  30111. if (params.slideRole) {
  30112. addElRole(swiper.slides, params.slideRole);
  30113. }
  30114. const slidesLength = swiper.slides.length;
  30115. if (params.slideLabelMessage) {
  30116. swiper.slides.forEach((slideEl, index) => {
  30117. const slideIndex = swiper.params.loop ? parseInt(slideEl.getAttribute('data-swiper-slide-index'), 10) : index;
  30118. const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
  30119. addElLabel(slideEl, ariaLabelMessage);
  30120. });
  30121. }
  30122. };
  30123. const init = () => {
  30124. const params = swiper.params.a11y;
  30125. swiper.el.append(liveRegion);
  30126. // Container
  30127. const containerEl = swiper.el;
  30128. if (params.containerRoleDescriptionMessage) {
  30129. addElRoleDescription(containerEl, params.containerRoleDescriptionMessage);
  30130. }
  30131. if (params.containerMessage) {
  30132. addElLabel(containerEl, params.containerMessage);
  30133. }
  30134. // Wrapper
  30135. const wrapperEl = swiper.wrapperEl;
  30136. const wrapperId = params.id || wrapperEl.getAttribute('id') || `swiper-wrapper-${getRandomNumber(16)}`;
  30137. const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
  30138. addElId(wrapperEl, wrapperId);
  30139. addElLive(wrapperEl, live);
  30140. // Slide
  30141. initSlides();
  30142. // Navigation
  30143. let {
  30144. nextEl,
  30145. prevEl
  30146. } = swiper.navigation ? swiper.navigation : {};
  30147. nextEl = makeElementsArray(nextEl);
  30148. prevEl = makeElementsArray(prevEl);
  30149. if (nextEl) {
  30150. nextEl.forEach(el => initNavEl(el, wrapperId, params.nextSlideMessage));
  30151. }
  30152. if (prevEl) {
  30153. prevEl.forEach(el => initNavEl(el, wrapperId, params.prevSlideMessage));
  30154. }
  30155. // Pagination
  30156. if (hasClickablePagination()) {
  30157. const paginationEl = makeElementsArray(swiper.pagination.el);
  30158. paginationEl.forEach(el => {
  30159. el.addEventListener('keydown', onEnterOrSpaceKey);
  30160. });
  30161. }
  30162. // Tab focus
  30163. swiper.el.addEventListener('focus', handleFocus, true);
  30164. swiper.el.addEventListener('pointerdown', handlePointerDown, true);
  30165. swiper.el.addEventListener('pointerup', handlePointerUp, true);
  30166. };
  30167. function destroy() {
  30168. if (liveRegion) liveRegion.remove();
  30169. let {
  30170. nextEl,
  30171. prevEl
  30172. } = swiper.navigation ? swiper.navigation : {};
  30173. nextEl = makeElementsArray(nextEl);
  30174. prevEl = makeElementsArray(prevEl);
  30175. if (nextEl) {
  30176. nextEl.forEach(el => el.removeEventListener('keydown', onEnterOrSpaceKey));
  30177. }
  30178. if (prevEl) {
  30179. prevEl.forEach(el => el.removeEventListener('keydown', onEnterOrSpaceKey));
  30180. }
  30181. // Pagination
  30182. if (hasClickablePagination()) {
  30183. const paginationEl = makeElementsArray(swiper.pagination.el);
  30184. paginationEl.forEach(el => {
  30185. el.removeEventListener('keydown', onEnterOrSpaceKey);
  30186. });
  30187. }
  30188. // Tab focus
  30189. swiper.el.removeEventListener('focus', handleFocus, true);
  30190. swiper.el.removeEventListener('pointerdown', handlePointerDown, true);
  30191. swiper.el.removeEventListener('pointerup', handlePointerUp, true);
  30192. }
  30193. on('beforeInit', () => {
  30194. liveRegion = createElement('span', swiper.params.a11y.notificationClass);
  30195. liveRegion.setAttribute('aria-live', 'assertive');
  30196. liveRegion.setAttribute('aria-atomic', 'true');
  30197. });
  30198. on('afterInit', () => {
  30199. if (!swiper.params.a11y.enabled) return;
  30200. init();
  30201. });
  30202. on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => {
  30203. if (!swiper.params.a11y.enabled) return;
  30204. initSlides();
  30205. });
  30206. on('fromEdge toEdge afterInit lock unlock', () => {
  30207. if (!swiper.params.a11y.enabled) return;
  30208. updateNavigation();
  30209. });
  30210. on('paginationUpdate', () => {
  30211. if (!swiper.params.a11y.enabled) return;
  30212. updatePagination();
  30213. });
  30214. on('destroy', () => {
  30215. if (!swiper.params.a11y.enabled) return;
  30216. destroy();
  30217. });
  30218. }
  30219. function History(_ref) {
  30220. let {
  30221. swiper,
  30222. extendParams,
  30223. on
  30224. } = _ref;
  30225. extendParams({
  30226. history: {
  30227. enabled: false,
  30228. root: '',
  30229. replaceState: false,
  30230. key: 'slides',
  30231. keepQuery: false
  30232. }
  30233. });
  30234. let initialized = false;
  30235. let paths = {};
  30236. const slugify = text => {
  30237. return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
  30238. };
  30239. const getPathValues = urlOverride => {
  30240. const window = getWindow();
  30241. let location;
  30242. if (urlOverride) {
  30243. location = new URL(urlOverride);
  30244. } else {
  30245. location = window.location;
  30246. }
  30247. const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
  30248. const total = pathArray.length;
  30249. const key = pathArray[total - 2];
  30250. const value = pathArray[total - 1];
  30251. return {
  30252. key,
  30253. value
  30254. };
  30255. };
  30256. const setHistory = (key, index) => {
  30257. const window = getWindow();
  30258. if (!initialized || !swiper.params.history.enabled) return;
  30259. let location;
  30260. if (swiper.params.url) {
  30261. location = new URL(swiper.params.url);
  30262. } else {
  30263. location = window.location;
  30264. }
  30265. const slide = swiper.slides[index];
  30266. let value = slugify(slide.getAttribute('data-history'));
  30267. if (swiper.params.history.root.length > 0) {
  30268. let root = swiper.params.history.root;
  30269. if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
  30270. value = `${root}/${key ? `${key}/` : ''}${value}`;
  30271. } else if (!location.pathname.includes(key)) {
  30272. value = `${key ? `${key}/` : ''}${value}`;
  30273. }
  30274. if (swiper.params.history.keepQuery) {
  30275. value += location.search;
  30276. }
  30277. const currentState = window.history.state;
  30278. if (currentState && currentState.value === value) {
  30279. return;
  30280. }
  30281. if (swiper.params.history.replaceState) {
  30282. window.history.replaceState({
  30283. value
  30284. }, null, value);
  30285. } else {
  30286. window.history.pushState({
  30287. value
  30288. }, null, value);
  30289. }
  30290. };
  30291. const scrollToSlide = (speed, value, runCallbacks) => {
  30292. if (value) {
  30293. for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
  30294. const slide = swiper.slides[i];
  30295. const slideHistory = slugify(slide.getAttribute('data-history'));
  30296. if (slideHistory === value) {
  30297. const index = swiper.getSlideIndex(slide);
  30298. swiper.slideTo(index, speed, runCallbacks);
  30299. }
  30300. }
  30301. } else {
  30302. swiper.slideTo(0, speed, runCallbacks);
  30303. }
  30304. };
  30305. const setHistoryPopState = () => {
  30306. paths = getPathValues(swiper.params.url);
  30307. scrollToSlide(swiper.params.speed, paths.value, false);
  30308. };
  30309. const init = () => {
  30310. const window = getWindow();
  30311. if (!swiper.params.history) return;
  30312. if (!window.history || !window.history.pushState) {
  30313. swiper.params.history.enabled = false;
  30314. swiper.params.hashNavigation.enabled = true;
  30315. return;
  30316. }
  30317. initialized = true;
  30318. paths = getPathValues(swiper.params.url);
  30319. if (!paths.key && !paths.value) {
  30320. if (!swiper.params.history.replaceState) {
  30321. window.addEventListener('popstate', setHistoryPopState);
  30322. }
  30323. return;
  30324. }
  30325. scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
  30326. if (!swiper.params.history.replaceState) {
  30327. window.addEventListener('popstate', setHistoryPopState);
  30328. }
  30329. };
  30330. const destroy = () => {
  30331. const window = getWindow();
  30332. if (!swiper.params.history.replaceState) {
  30333. window.removeEventListener('popstate', setHistoryPopState);
  30334. }
  30335. };
  30336. on('init', () => {
  30337. if (swiper.params.history.enabled) {
  30338. init();
  30339. }
  30340. });
  30341. on('destroy', () => {
  30342. if (swiper.params.history.enabled) {
  30343. destroy();
  30344. }
  30345. });
  30346. on('transitionEnd _freeModeNoMomentumRelease', () => {
  30347. if (initialized) {
  30348. setHistory(swiper.params.history.key, swiper.activeIndex);
  30349. }
  30350. });
  30351. on('slideChange', () => {
  30352. if (initialized && swiper.params.cssMode) {
  30353. setHistory(swiper.params.history.key, swiper.activeIndex);
  30354. }
  30355. });
  30356. }
  30357. function HashNavigation(_ref) {
  30358. let {
  30359. swiper,
  30360. extendParams,
  30361. emit,
  30362. on
  30363. } = _ref;
  30364. let initialized = false;
  30365. const document = getDocument();
  30366. const window = getWindow();
  30367. extendParams({
  30368. hashNavigation: {
  30369. enabled: false,
  30370. replaceState: false,
  30371. watchState: false,
  30372. getSlideIndex(_s, hash) {
  30373. if (swiper.virtual && swiper.params.virtual.enabled) {
  30374. const slideWithHash = swiper.slides.filter(slideEl => slideEl.getAttribute('data-hash') === hash)[0];
  30375. if (!slideWithHash) return 0;
  30376. const index = parseInt(slideWithHash.getAttribute('data-swiper-slide-index'), 10);
  30377. return index;
  30378. }
  30379. return swiper.getSlideIndex(elementChildren(swiper.slidesEl, `.${swiper.params.slideClass}[data-hash="${hash}"], swiper-slide[data-hash="${hash}"]`)[0]);
  30380. }
  30381. }
  30382. });
  30383. const onHashChange = () => {
  30384. emit('hashChange');
  30385. const newHash = document.location.hash.replace('#', '');
  30386. const activeSlideEl = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${swiper.activeIndex}"]`) : swiper.slides[swiper.activeIndex];
  30387. const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') : '';
  30388. if (newHash !== activeSlideHash) {
  30389. const newIndex = swiper.params.hashNavigation.getSlideIndex(swiper, newHash);
  30390. if (typeof newIndex === 'undefined' || Number.isNaN(newIndex)) return;
  30391. swiper.slideTo(newIndex);
  30392. }
  30393. };
  30394. const setHash = () => {
  30395. if (!initialized || !swiper.params.hashNavigation.enabled) return;
  30396. const activeSlideEl = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${swiper.activeIndex}"]`) : swiper.slides[swiper.activeIndex];
  30397. const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') || activeSlideEl.getAttribute('data-history') : '';
  30398. if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
  30399. window.history.replaceState(null, null, `#${activeSlideHash}` || '');
  30400. emit('hashSet');
  30401. } else {
  30402. document.location.hash = activeSlideHash || '';
  30403. emit('hashSet');
  30404. }
  30405. };
  30406. const init = () => {
  30407. if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
  30408. initialized = true;
  30409. const hash = document.location.hash.replace('#', '');
  30410. if (hash) {
  30411. const speed = 0;
  30412. const index = swiper.params.hashNavigation.getSlideIndex(swiper, hash);
  30413. swiper.slideTo(index || 0, speed, swiper.params.runCallbacksOnInit, true);
  30414. }
  30415. if (swiper.params.hashNavigation.watchState) {
  30416. window.addEventListener('hashchange', onHashChange);
  30417. }
  30418. };
  30419. const destroy = () => {
  30420. if (swiper.params.hashNavigation.watchState) {
  30421. window.removeEventListener('hashchange', onHashChange);
  30422. }
  30423. };
  30424. on('init', () => {
  30425. if (swiper.params.hashNavigation.enabled) {
  30426. init();
  30427. }
  30428. });
  30429. on('destroy', () => {
  30430. if (swiper.params.hashNavigation.enabled) {
  30431. destroy();
  30432. }
  30433. });
  30434. on('transitionEnd _freeModeNoMomentumRelease', () => {
  30435. if (initialized) {
  30436. setHash();
  30437. }
  30438. });
  30439. on('slideChange', () => {
  30440. if (initialized && swiper.params.cssMode) {
  30441. setHash();
  30442. }
  30443. });
  30444. }
  30445. /* eslint no-underscore-dangle: "off" */
  30446. /* eslint no-use-before-define: "off" */
  30447. function Autoplay(_ref) {
  30448. let {
  30449. swiper,
  30450. extendParams,
  30451. on,
  30452. emit,
  30453. params
  30454. } = _ref;
  30455. swiper.autoplay = {
  30456. running: false,
  30457. paused: false,
  30458. timeLeft: 0
  30459. };
  30460. extendParams({
  30461. autoplay: {
  30462. enabled: false,
  30463. delay: 3000,
  30464. waitForTransition: true,
  30465. disableOnInteraction: false,
  30466. stopOnLastSlide: false,
  30467. reverseDirection: false,
  30468. pauseOnMouseEnter: false
  30469. }
  30470. });
  30471. let timeout;
  30472. let raf;
  30473. let autoplayDelayTotal = params && params.autoplay ? params.autoplay.delay : 3000;
  30474. let autoplayDelayCurrent = params && params.autoplay ? params.autoplay.delay : 3000;
  30475. let autoplayTimeLeft;
  30476. let autoplayStartTime = new Date().getTime();
  30477. let wasPaused;
  30478. let isTouched;
  30479. let pausedByTouch;
  30480. let touchStartTimeout;
  30481. let slideChanged;
  30482. let pausedByInteraction;
  30483. let pausedByPointerEnter;
  30484. function onTransitionEnd(e) {
  30485. if (!swiper || swiper.destroyed || !swiper.wrapperEl) return;
  30486. if (e.target !== swiper.wrapperEl) return;
  30487. swiper.wrapperEl.removeEventListener('transitionend', onTransitionEnd);
  30488. if (pausedByPointerEnter) {
  30489. return;
  30490. }
  30491. resume();
  30492. }
  30493. const calcTimeLeft = () => {
  30494. if (swiper.destroyed || !swiper.autoplay.running) return;
  30495. if (swiper.autoplay.paused) {
  30496. wasPaused = true;
  30497. } else if (wasPaused) {
  30498. autoplayDelayCurrent = autoplayTimeLeft;
  30499. wasPaused = false;
  30500. }
  30501. const timeLeft = swiper.autoplay.paused ? autoplayTimeLeft : autoplayStartTime + autoplayDelayCurrent - new Date().getTime();
  30502. swiper.autoplay.timeLeft = timeLeft;
  30503. emit('autoplayTimeLeft', timeLeft, timeLeft / autoplayDelayTotal);
  30504. raf = requestAnimationFrame(() => {
  30505. calcTimeLeft();
  30506. });
  30507. };
  30508. const getSlideDelay = () => {
  30509. let activeSlideEl;
  30510. if (swiper.virtual && swiper.params.virtual.enabled) {
  30511. activeSlideEl = swiper.slides.filter(slideEl => slideEl.classList.contains('swiper-slide-active'))[0];
  30512. } else {
  30513. activeSlideEl = swiper.slides[swiper.activeIndex];
  30514. }
  30515. if (!activeSlideEl) return undefined;
  30516. const currentSlideDelay = parseInt(activeSlideEl.getAttribute('data-swiper-autoplay'), 10);
  30517. return currentSlideDelay;
  30518. };
  30519. const run = delayForce => {
  30520. if (swiper.destroyed || !swiper.autoplay.running) return;
  30521. cancelAnimationFrame(raf);
  30522. calcTimeLeft();
  30523. let delay = typeof delayForce === 'undefined' ? swiper.params.autoplay.delay : delayForce;
  30524. autoplayDelayTotal = swiper.params.autoplay.delay;
  30525. autoplayDelayCurrent = swiper.params.autoplay.delay;
  30526. const currentSlideDelay = getSlideDelay();
  30527. if (!Number.isNaN(currentSlideDelay) && currentSlideDelay > 0 && typeof delayForce === 'undefined') {
  30528. delay = currentSlideDelay;
  30529. autoplayDelayTotal = currentSlideDelay;
  30530. autoplayDelayCurrent = currentSlideDelay;
  30531. }
  30532. autoplayTimeLeft = delay;
  30533. const speed = swiper.params.speed;
  30534. const proceed = () => {
  30535. if (!swiper || swiper.destroyed) return;
  30536. if (swiper.params.autoplay.reverseDirection) {
  30537. if (!swiper.isBeginning || swiper.params.loop || swiper.params.rewind) {
  30538. swiper.slidePrev(speed, true, true);
  30539. emit('autoplay');
  30540. } else if (!swiper.params.autoplay.stopOnLastSlide) {
  30541. swiper.slideTo(swiper.slides.length - 1, speed, true, true);
  30542. emit('autoplay');
  30543. }
  30544. } else {
  30545. if (!swiper.isEnd || swiper.params.loop || swiper.params.rewind) {
  30546. swiper.slideNext(speed, true, true);
  30547. emit('autoplay');
  30548. } else if (!swiper.params.autoplay.stopOnLastSlide) {
  30549. swiper.slideTo(0, speed, true, true);
  30550. emit('autoplay');
  30551. }
  30552. }
  30553. if (swiper.params.cssMode) {
  30554. autoplayStartTime = new Date().getTime();
  30555. requestAnimationFrame(() => {
  30556. run();
  30557. });
  30558. }
  30559. };
  30560. if (delay > 0) {
  30561. clearTimeout(timeout);
  30562. timeout = setTimeout(() => {
  30563. proceed();
  30564. }, delay);
  30565. } else {
  30566. requestAnimationFrame(() => {
  30567. proceed();
  30568. });
  30569. }
  30570. // eslint-disable-next-line
  30571. return delay;
  30572. };
  30573. const start = () => {
  30574. autoplayStartTime = new Date().getTime();
  30575. swiper.autoplay.running = true;
  30576. run();
  30577. emit('autoplayStart');
  30578. };
  30579. const stop = () => {
  30580. swiper.autoplay.running = false;
  30581. clearTimeout(timeout);
  30582. cancelAnimationFrame(raf);
  30583. emit('autoplayStop');
  30584. };
  30585. const pause = (internal, reset) => {
  30586. if (swiper.destroyed || !swiper.autoplay.running) return;
  30587. clearTimeout(timeout);
  30588. if (!internal) {
  30589. pausedByInteraction = true;
  30590. }
  30591. const proceed = () => {
  30592. emit('autoplayPause');
  30593. if (swiper.params.autoplay.waitForTransition) {
  30594. swiper.wrapperEl.addEventListener('transitionend', onTransitionEnd);
  30595. } else {
  30596. resume();
  30597. }
  30598. };
  30599. swiper.autoplay.paused = true;
  30600. if (reset) {
  30601. if (slideChanged) {
  30602. autoplayTimeLeft = swiper.params.autoplay.delay;
  30603. }
  30604. slideChanged = false;
  30605. proceed();
  30606. return;
  30607. }
  30608. const delay = autoplayTimeLeft || swiper.params.autoplay.delay;
  30609. autoplayTimeLeft = delay - (new Date().getTime() - autoplayStartTime);
  30610. if (swiper.isEnd && autoplayTimeLeft < 0 && !swiper.params.loop) return;
  30611. if (autoplayTimeLeft < 0) autoplayTimeLeft = 0;
  30612. proceed();
  30613. };
  30614. const resume = () => {
  30615. if (swiper.isEnd && autoplayTimeLeft < 0 && !swiper.params.loop || swiper.destroyed || !swiper.autoplay.running) return;
  30616. autoplayStartTime = new Date().getTime();
  30617. if (pausedByInteraction) {
  30618. pausedByInteraction = false;
  30619. run(autoplayTimeLeft);
  30620. } else {
  30621. run();
  30622. }
  30623. swiper.autoplay.paused = false;
  30624. emit('autoplayResume');
  30625. };
  30626. const onVisibilityChange = () => {
  30627. if (swiper.destroyed || !swiper.autoplay.running) return;
  30628. const document = getDocument();
  30629. if (document.visibilityState === 'hidden') {
  30630. pausedByInteraction = true;
  30631. pause(true);
  30632. }
  30633. if (document.visibilityState === 'visible') {
  30634. resume();
  30635. }
  30636. };
  30637. const onPointerEnter = e => {
  30638. if (e.pointerType !== 'mouse') return;
  30639. pausedByInteraction = true;
  30640. pausedByPointerEnter = true;
  30641. if (swiper.animating || swiper.autoplay.paused) return;
  30642. pause(true);
  30643. };
  30644. const onPointerLeave = e => {
  30645. if (e.pointerType !== 'mouse') return;
  30646. pausedByPointerEnter = false;
  30647. if (swiper.autoplay.paused) {
  30648. resume();
  30649. }
  30650. };
  30651. const attachMouseEvents = () => {
  30652. if (swiper.params.autoplay.pauseOnMouseEnter) {
  30653. swiper.el.addEventListener('pointerenter', onPointerEnter);
  30654. swiper.el.addEventListener('pointerleave', onPointerLeave);
  30655. }
  30656. };
  30657. const detachMouseEvents = () => {
  30658. swiper.el.removeEventListener('pointerenter', onPointerEnter);
  30659. swiper.el.removeEventListener('pointerleave', onPointerLeave);
  30660. };
  30661. const attachDocumentEvents = () => {
  30662. const document = getDocument();
  30663. document.addEventListener('visibilitychange', onVisibilityChange);
  30664. };
  30665. const detachDocumentEvents = () => {
  30666. const document = getDocument();
  30667. document.removeEventListener('visibilitychange', onVisibilityChange);
  30668. };
  30669. on('init', () => {
  30670. if (swiper.params.autoplay.enabled) {
  30671. attachMouseEvents();
  30672. attachDocumentEvents();
  30673. start();
  30674. }
  30675. });
  30676. on('destroy', () => {
  30677. detachMouseEvents();
  30678. detachDocumentEvents();
  30679. if (swiper.autoplay.running) {
  30680. stop();
  30681. }
  30682. });
  30683. on('_freeModeStaticRelease', () => {
  30684. if (pausedByTouch || pausedByInteraction) {
  30685. resume();
  30686. }
  30687. });
  30688. on('_freeModeNoMomentumRelease', () => {
  30689. if (!swiper.params.autoplay.disableOnInteraction) {
  30690. pause(true, true);
  30691. } else {
  30692. stop();
  30693. }
  30694. });
  30695. on('beforeTransitionStart', (_s, speed, internal) => {
  30696. if (swiper.destroyed || !swiper.autoplay.running) return;
  30697. if (internal || !swiper.params.autoplay.disableOnInteraction) {
  30698. pause(true, true);
  30699. } else {
  30700. stop();
  30701. }
  30702. });
  30703. on('sliderFirstMove', () => {
  30704. if (swiper.destroyed || !swiper.autoplay.running) return;
  30705. if (swiper.params.autoplay.disableOnInteraction) {
  30706. stop();
  30707. return;
  30708. }
  30709. isTouched = true;
  30710. pausedByTouch = false;
  30711. pausedByInteraction = false;
  30712. touchStartTimeout = setTimeout(() => {
  30713. pausedByInteraction = true;
  30714. pausedByTouch = true;
  30715. pause(true);
  30716. }, 200);
  30717. });
  30718. on('touchEnd', () => {
  30719. if (swiper.destroyed || !swiper.autoplay.running || !isTouched) return;
  30720. clearTimeout(touchStartTimeout);
  30721. clearTimeout(timeout);
  30722. if (swiper.params.autoplay.disableOnInteraction) {
  30723. pausedByTouch = false;
  30724. isTouched = false;
  30725. return;
  30726. }
  30727. if (pausedByTouch && swiper.params.cssMode) resume();
  30728. pausedByTouch = false;
  30729. isTouched = false;
  30730. });
  30731. on('slideChange', () => {
  30732. if (swiper.destroyed || !swiper.autoplay.running) return;
  30733. slideChanged = true;
  30734. });
  30735. Object.assign(swiper.autoplay, {
  30736. start,
  30737. stop,
  30738. pause,
  30739. resume
  30740. });
  30741. }
  30742. function Thumb(_ref) {
  30743. let {
  30744. swiper,
  30745. extendParams,
  30746. on
  30747. } = _ref;
  30748. extendParams({
  30749. thumbs: {
  30750. swiper: null,
  30751. multipleActiveThumbs: true,
  30752. autoScrollOffset: 0,
  30753. slideThumbActiveClass: 'swiper-slide-thumb-active',
  30754. thumbsContainerClass: 'swiper-thumbs'
  30755. }
  30756. });
  30757. let initialized = false;
  30758. let swiperCreated = false;
  30759. swiper.thumbs = {
  30760. swiper: null
  30761. };
  30762. function onThumbClick() {
  30763. const thumbsSwiper = swiper.thumbs.swiper;
  30764. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  30765. const clickedIndex = thumbsSwiper.clickedIndex;
  30766. const clickedSlide = thumbsSwiper.clickedSlide;
  30767. if (clickedSlide && clickedSlide.classList.contains(swiper.params.thumbs.slideThumbActiveClass)) return;
  30768. if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
  30769. let slideToIndex;
  30770. if (thumbsSwiper.params.loop) {
  30771. slideToIndex = parseInt(thumbsSwiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
  30772. } else {
  30773. slideToIndex = clickedIndex;
  30774. }
  30775. if (swiper.params.loop) {
  30776. swiper.slideToLoop(slideToIndex);
  30777. } else {
  30778. swiper.slideTo(slideToIndex);
  30779. }
  30780. }
  30781. function init() {
  30782. const {
  30783. thumbs: thumbsParams
  30784. } = swiper.params;
  30785. if (initialized) return false;
  30786. initialized = true;
  30787. const SwiperClass = swiper.constructor;
  30788. if (thumbsParams.swiper instanceof SwiperClass) {
  30789. swiper.thumbs.swiper = thumbsParams.swiper;
  30790. Object.assign(swiper.thumbs.swiper.originalParams, {
  30791. watchSlidesProgress: true,
  30792. slideToClickedSlide: false
  30793. });
  30794. Object.assign(swiper.thumbs.swiper.params, {
  30795. watchSlidesProgress: true,
  30796. slideToClickedSlide: false
  30797. });
  30798. swiper.thumbs.swiper.update();
  30799. } else if (isObject(thumbsParams.swiper)) {
  30800. const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper);
  30801. Object.assign(thumbsSwiperParams, {
  30802. watchSlidesProgress: true,
  30803. slideToClickedSlide: false
  30804. });
  30805. swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams);
  30806. swiperCreated = true;
  30807. }
  30808. swiper.thumbs.swiper.el.classList.add(swiper.params.thumbs.thumbsContainerClass);
  30809. swiper.thumbs.swiper.on('tap', onThumbClick);
  30810. return true;
  30811. }
  30812. function update(initial) {
  30813. const thumbsSwiper = swiper.thumbs.swiper;
  30814. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  30815. const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView;
  30816. // Activate thumbs
  30817. let thumbsToActivate = 1;
  30818. const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
  30819. if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
  30820. thumbsToActivate = swiper.params.slidesPerView;
  30821. }
  30822. if (!swiper.params.thumbs.multipleActiveThumbs) {
  30823. thumbsToActivate = 1;
  30824. }
  30825. thumbsToActivate = Math.floor(thumbsToActivate);
  30826. thumbsSwiper.slides.forEach(slideEl => slideEl.classList.remove(thumbActiveClass));
  30827. if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
  30828. for (let i = 0; i < thumbsToActivate; i += 1) {
  30829. elementChildren(thumbsSwiper.slidesEl, `[data-swiper-slide-index="${swiper.realIndex + i}"]`).forEach(slideEl => {
  30830. slideEl.classList.add(thumbActiveClass);
  30831. });
  30832. }
  30833. } else {
  30834. for (let i = 0; i < thumbsToActivate; i += 1) {
  30835. if (thumbsSwiper.slides[swiper.realIndex + i]) {
  30836. thumbsSwiper.slides[swiper.realIndex + i].classList.add(thumbActiveClass);
  30837. }
  30838. }
  30839. }
  30840. const autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
  30841. const useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
  30842. if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
  30843. const currentThumbsIndex = thumbsSwiper.activeIndex;
  30844. let newThumbsIndex;
  30845. let direction;
  30846. if (thumbsSwiper.params.loop) {
  30847. const newThumbsSlide = thumbsSwiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') === `${swiper.realIndex}`)[0];
  30848. newThumbsIndex = thumbsSwiper.slides.indexOf(newThumbsSlide);
  30849. direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
  30850. } else {
  30851. newThumbsIndex = swiper.realIndex;
  30852. direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
  30853. }
  30854. if (useOffset) {
  30855. newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
  30856. }
  30857. if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
  30858. if (thumbsSwiper.params.centeredSlides) {
  30859. if (newThumbsIndex > currentThumbsIndex) {
  30860. newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
  30861. } else {
  30862. newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
  30863. }
  30864. } else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ;
  30865. thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
  30866. }
  30867. }
  30868. }
  30869. on('beforeInit', () => {
  30870. const {
  30871. thumbs
  30872. } = swiper.params;
  30873. if (!thumbs || !thumbs.swiper) return;
  30874. if (typeof thumbs.swiper === 'string' || thumbs.swiper instanceof HTMLElement) {
  30875. const document = getDocument();
  30876. const getThumbsElementAndInit = () => {
  30877. const thumbsElement = typeof thumbs.swiper === 'string' ? document.querySelector(thumbs.swiper) : thumbs.swiper;
  30878. if (thumbsElement && thumbsElement.swiper) {
  30879. thumbs.swiper = thumbsElement.swiper;
  30880. init();
  30881. update(true);
  30882. } else if (thumbsElement) {
  30883. const onThumbsSwiper = e => {
  30884. thumbs.swiper = e.detail[0];
  30885. thumbsElement.removeEventListener('init', onThumbsSwiper);
  30886. init();
  30887. update(true);
  30888. thumbs.swiper.update();
  30889. swiper.update();
  30890. };
  30891. thumbsElement.addEventListener('init', onThumbsSwiper);
  30892. }
  30893. return thumbsElement;
  30894. };
  30895. const watchForThumbsToAppear = () => {
  30896. if (swiper.destroyed) return;
  30897. const thumbsElement = getThumbsElementAndInit();
  30898. if (!thumbsElement) {
  30899. requestAnimationFrame(watchForThumbsToAppear);
  30900. }
  30901. };
  30902. requestAnimationFrame(watchForThumbsToAppear);
  30903. } else {
  30904. init();
  30905. update(true);
  30906. }
  30907. });
  30908. on('slideChange update resize observerUpdate', () => {
  30909. update();
  30910. });
  30911. on('setTransition', (_s, duration) => {
  30912. const thumbsSwiper = swiper.thumbs.swiper;
  30913. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  30914. thumbsSwiper.setTransition(duration);
  30915. });
  30916. on('beforeDestroy', () => {
  30917. const thumbsSwiper = swiper.thumbs.swiper;
  30918. if (!thumbsSwiper || thumbsSwiper.destroyed) return;
  30919. if (swiperCreated) {
  30920. thumbsSwiper.destroy();
  30921. }
  30922. });
  30923. Object.assign(swiper.thumbs, {
  30924. init,
  30925. update
  30926. });
  30927. }
  30928. function freeMode(_ref) {
  30929. let {
  30930. swiper,
  30931. extendParams,
  30932. emit,
  30933. once
  30934. } = _ref;
  30935. extendParams({
  30936. freeMode: {
  30937. enabled: false,
  30938. momentum: true,
  30939. momentumRatio: 1,
  30940. momentumBounce: true,
  30941. momentumBounceRatio: 1,
  30942. momentumVelocityRatio: 1,
  30943. sticky: false,
  30944. minimumVelocity: 0.02
  30945. }
  30946. });
  30947. function onTouchStart() {
  30948. if (swiper.params.cssMode) return;
  30949. const translate = swiper.getTranslate();
  30950. swiper.setTranslate(translate);
  30951. swiper.setTransition(0);
  30952. swiper.touchEventsData.velocities.length = 0;
  30953. swiper.freeMode.onTouchEnd({
  30954. currentPos: swiper.rtl ? swiper.translate : -swiper.translate
  30955. });
  30956. }
  30957. function onTouchMove() {
  30958. if (swiper.params.cssMode) return;
  30959. const {
  30960. touchEventsData: data,
  30961. touches
  30962. } = swiper;
  30963. // Velocity
  30964. if (data.velocities.length === 0) {
  30965. data.velocities.push({
  30966. position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
  30967. time: data.touchStartTime
  30968. });
  30969. }
  30970. data.velocities.push({
  30971. position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
  30972. time: now()
  30973. });
  30974. }
  30975. function onTouchEnd(_ref2) {
  30976. let {
  30977. currentPos
  30978. } = _ref2;
  30979. if (swiper.params.cssMode) return;
  30980. const {
  30981. params,
  30982. wrapperEl,
  30983. rtlTranslate: rtl,
  30984. snapGrid,
  30985. touchEventsData: data
  30986. } = swiper;
  30987. // Time diff
  30988. const touchEndTime = now();
  30989. const timeDiff = touchEndTime - data.touchStartTime;
  30990. if (currentPos < -swiper.minTranslate()) {
  30991. swiper.slideTo(swiper.activeIndex);
  30992. return;
  30993. }
  30994. if (currentPos > -swiper.maxTranslate()) {
  30995. if (swiper.slides.length < snapGrid.length) {
  30996. swiper.slideTo(snapGrid.length - 1);
  30997. } else {
  30998. swiper.slideTo(swiper.slides.length - 1);
  30999. }
  31000. return;
  31001. }
  31002. if (params.freeMode.momentum) {
  31003. if (data.velocities.length > 1) {
  31004. const lastMoveEvent = data.velocities.pop();
  31005. const velocityEvent = data.velocities.pop();
  31006. const distance = lastMoveEvent.position - velocityEvent.position;
  31007. const time = lastMoveEvent.time - velocityEvent.time;
  31008. swiper.velocity = distance / time;
  31009. swiper.velocity /= 2;
  31010. if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) {
  31011. swiper.velocity = 0;
  31012. }
  31013. // this implies that the user stopped moving a finger then released.
  31014. // There would be no events with distance zero, so the last event is stale.
  31015. if (time > 150 || now() - lastMoveEvent.time > 300) {
  31016. swiper.velocity = 0;
  31017. }
  31018. } else {
  31019. swiper.velocity = 0;
  31020. }
  31021. swiper.velocity *= params.freeMode.momentumVelocityRatio;
  31022. data.velocities.length = 0;
  31023. let momentumDuration = 1000 * params.freeMode.momentumRatio;
  31024. const momentumDistance = swiper.velocity * momentumDuration;
  31025. let newPosition = swiper.translate + momentumDistance;
  31026. if (rtl) newPosition = -newPosition;
  31027. let doBounce = false;
  31028. let afterBouncePosition;
  31029. const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio;
  31030. let needsLoopFix;
  31031. if (newPosition < swiper.maxTranslate()) {
  31032. if (params.freeMode.momentumBounce) {
  31033. if (newPosition + swiper.maxTranslate() < -bounceAmount) {
  31034. newPosition = swiper.maxTranslate() - bounceAmount;
  31035. }
  31036. afterBouncePosition = swiper.maxTranslate();
  31037. doBounce = true;
  31038. data.allowMomentumBounce = true;
  31039. } else {
  31040. newPosition = swiper.maxTranslate();
  31041. }
  31042. if (params.loop && params.centeredSlides) needsLoopFix = true;
  31043. } else if (newPosition > swiper.minTranslate()) {
  31044. if (params.freeMode.momentumBounce) {
  31045. if (newPosition - swiper.minTranslate() > bounceAmount) {
  31046. newPosition = swiper.minTranslate() + bounceAmount;
  31047. }
  31048. afterBouncePosition = swiper.minTranslate();
  31049. doBounce = true;
  31050. data.allowMomentumBounce = true;
  31051. } else {
  31052. newPosition = swiper.minTranslate();
  31053. }
  31054. if (params.loop && params.centeredSlides) needsLoopFix = true;
  31055. } else if (params.freeMode.sticky) {
  31056. let nextSlide;
  31057. for (let j = 0; j < snapGrid.length; j += 1) {
  31058. if (snapGrid[j] > -newPosition) {
  31059. nextSlide = j;
  31060. break;
  31061. }
  31062. }
  31063. if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
  31064. newPosition = snapGrid[nextSlide];
  31065. } else {
  31066. newPosition = snapGrid[nextSlide - 1];
  31067. }
  31068. newPosition = -newPosition;
  31069. }
  31070. if (needsLoopFix) {
  31071. once('transitionEnd', () => {
  31072. swiper.loopFix();
  31073. });
  31074. }
  31075. // Fix duration
  31076. if (swiper.velocity !== 0) {
  31077. if (rtl) {
  31078. momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
  31079. } else {
  31080. momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
  31081. }
  31082. if (params.freeMode.sticky) {
  31083. // If freeMode.sticky is active and the user ends a swipe with a slow-velocity
  31084. // event, then durations can be 20+ seconds to slide one (or zero!) slides.
  31085. // It's easy to see this when simulating touch with mouse events. To fix this,
  31086. // limit single-slide swipes to the default slide duration. This also has the
  31087. // nice side effect of matching slide speed if the user stopped moving before
  31088. // lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
  31089. // For faster swipes, also apply limits (albeit higher ones).
  31090. const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
  31091. const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
  31092. if (moveDistance < currentSlideSize) {
  31093. momentumDuration = params.speed;
  31094. } else if (moveDistance < 2 * currentSlideSize) {
  31095. momentumDuration = params.speed * 1.5;
  31096. } else {
  31097. momentumDuration = params.speed * 2.5;
  31098. }
  31099. }
  31100. } else if (params.freeMode.sticky) {
  31101. swiper.slideToClosest();
  31102. return;
  31103. }
  31104. if (params.freeMode.momentumBounce && doBounce) {
  31105. swiper.updateProgress(afterBouncePosition);
  31106. swiper.setTransition(momentumDuration);
  31107. swiper.setTranslate(newPosition);
  31108. swiper.transitionStart(true, swiper.swipeDirection);
  31109. swiper.animating = true;
  31110. elementTransitionEnd(wrapperEl, () => {
  31111. if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
  31112. emit('momentumBounce');
  31113. swiper.setTransition(params.speed);
  31114. setTimeout(() => {
  31115. swiper.setTranslate(afterBouncePosition);
  31116. elementTransitionEnd(wrapperEl, () => {
  31117. if (!swiper || swiper.destroyed) return;
  31118. swiper.transitionEnd();
  31119. });
  31120. }, 0);
  31121. });
  31122. } else if (swiper.velocity) {
  31123. emit('_freeModeNoMomentumRelease');
  31124. swiper.updateProgress(newPosition);
  31125. swiper.setTransition(momentumDuration);
  31126. swiper.setTranslate(newPosition);
  31127. swiper.transitionStart(true, swiper.swipeDirection);
  31128. if (!swiper.animating) {
  31129. swiper.animating = true;
  31130. elementTransitionEnd(wrapperEl, () => {
  31131. if (!swiper || swiper.destroyed) return;
  31132. swiper.transitionEnd();
  31133. });
  31134. }
  31135. } else {
  31136. swiper.updateProgress(newPosition);
  31137. }
  31138. swiper.updateActiveIndex();
  31139. swiper.updateSlidesClasses();
  31140. } else if (params.freeMode.sticky) {
  31141. swiper.slideToClosest();
  31142. return;
  31143. } else if (params.freeMode) {
  31144. emit('_freeModeNoMomentumRelease');
  31145. }
  31146. if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) {
  31147. emit('_freeModeStaticRelease');
  31148. swiper.updateProgress();
  31149. swiper.updateActiveIndex();
  31150. swiper.updateSlidesClasses();
  31151. }
  31152. }
  31153. Object.assign(swiper, {
  31154. freeMode: {
  31155. onTouchStart,
  31156. onTouchMove,
  31157. onTouchEnd
  31158. }
  31159. });
  31160. }
  31161. function Grid(_ref) {
  31162. let {
  31163. swiper,
  31164. extendParams,
  31165. on
  31166. } = _ref;
  31167. extendParams({
  31168. grid: {
  31169. rows: 1,
  31170. fill: 'column'
  31171. }
  31172. });
  31173. let slidesNumberEvenToRows;
  31174. let slidesPerRow;
  31175. let numFullColumns;
  31176. let wasMultiRow;
  31177. const getSpaceBetween = () => {
  31178. let spaceBetween = swiper.params.spaceBetween;
  31179. if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
  31180. spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
  31181. } else if (typeof spaceBetween === 'string') {
  31182. spaceBetween = parseFloat(spaceBetween);
  31183. }
  31184. return spaceBetween;
  31185. };
  31186. const initSlides = slides => {
  31187. const {
  31188. slidesPerView
  31189. } = swiper.params;
  31190. const {
  31191. rows,
  31192. fill
  31193. } = swiper.params.grid;
  31194. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : slides.length;
  31195. numFullColumns = Math.floor(slidesLength / rows);
  31196. if (Math.floor(slidesLength / rows) === slidesLength / rows) {
  31197. slidesNumberEvenToRows = slidesLength;
  31198. } else {
  31199. slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
  31200. }
  31201. if (slidesPerView !== 'auto' && fill === 'row') {
  31202. slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
  31203. }
  31204. slidesPerRow = slidesNumberEvenToRows / rows;
  31205. };
  31206. const unsetSlides = () => {
  31207. if (swiper.slides) {
  31208. swiper.slides.forEach(slide => {
  31209. if (slide.swiperSlideGridSet) {
  31210. slide.style.height = '';
  31211. slide.style[swiper.getDirectionLabel('margin-top')] = '';
  31212. }
  31213. });
  31214. }
  31215. };
  31216. const updateSlide = (i, slide, slides) => {
  31217. const {
  31218. slidesPerGroup
  31219. } = swiper.params;
  31220. const spaceBetween = getSpaceBetween();
  31221. const {
  31222. rows,
  31223. fill
  31224. } = swiper.params.grid;
  31225. const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : slides.length;
  31226. // Set slides order
  31227. let newSlideOrderIndex;
  31228. let column;
  31229. let row;
  31230. if (fill === 'row' && slidesPerGroup > 1) {
  31231. const groupIndex = Math.floor(i / (slidesPerGroup * rows));
  31232. const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
  31233. const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
  31234. row = Math.floor(slideIndexInGroup / columnsInGroup);
  31235. column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
  31236. newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
  31237. slide.style.order = newSlideOrderIndex;
  31238. } else if (fill === 'column') {
  31239. column = Math.floor(i / rows);
  31240. row = i - column * rows;
  31241. if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
  31242. row += 1;
  31243. if (row >= rows) {
  31244. row = 0;
  31245. column += 1;
  31246. }
  31247. }
  31248. } else {
  31249. row = Math.floor(i / slidesPerRow);
  31250. column = i - row * slidesPerRow;
  31251. }
  31252. slide.row = row;
  31253. slide.column = column;
  31254. slide.style.height = `calc((100% - ${(rows - 1) * spaceBetween}px) / ${rows})`;
  31255. slide.style[swiper.getDirectionLabel('margin-top')] = row !== 0 ? spaceBetween && `${spaceBetween}px` : '';
  31256. slide.swiperSlideGridSet = true;
  31257. };
  31258. const updateWrapperSize = (slideSize, snapGrid) => {
  31259. const {
  31260. centeredSlides,
  31261. roundLengths
  31262. } = swiper.params;
  31263. const spaceBetween = getSpaceBetween();
  31264. const {
  31265. rows
  31266. } = swiper.params.grid;
  31267. swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
  31268. swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
  31269. if (!swiper.params.cssMode) {
  31270. swiper.wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
  31271. }
  31272. if (centeredSlides) {
  31273. const newSlidesGrid = [];
  31274. for (let i = 0; i < snapGrid.length; i += 1) {
  31275. let slidesGridItem = snapGrid[i];
  31276. if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
  31277. if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
  31278. }
  31279. snapGrid.splice(0, snapGrid.length);
  31280. snapGrid.push(...newSlidesGrid);
  31281. }
  31282. };
  31283. const onInit = () => {
  31284. wasMultiRow = swiper.params.grid && swiper.params.grid.rows > 1;
  31285. };
  31286. const onUpdate = () => {
  31287. const {
  31288. params,
  31289. el
  31290. } = swiper;
  31291. const isMultiRow = params.grid && params.grid.rows > 1;
  31292. if (wasMultiRow && !isMultiRow) {
  31293. el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
  31294. numFullColumns = 1;
  31295. swiper.emitContainerClasses();
  31296. } else if (!wasMultiRow && isMultiRow) {
  31297. el.classList.add(`${params.containerModifierClass}grid`);
  31298. if (params.grid.fill === 'column') {
  31299. el.classList.add(`${params.containerModifierClass}grid-column`);
  31300. }
  31301. swiper.emitContainerClasses();
  31302. }
  31303. wasMultiRow = isMultiRow;
  31304. };
  31305. on('init', onInit);
  31306. on('update', onUpdate);
  31307. swiper.grid = {
  31308. initSlides,
  31309. unsetSlides,
  31310. updateSlide,
  31311. updateWrapperSize
  31312. };
  31313. }
  31314. function appendSlide(slides) {
  31315. const swiper = this;
  31316. const {
  31317. params,
  31318. slidesEl
  31319. } = swiper;
  31320. if (params.loop) {
  31321. swiper.loopDestroy();
  31322. }
  31323. const appendElement = slideEl => {
  31324. if (typeof slideEl === 'string') {
  31325. const tempDOM = document.createElement('div');
  31326. tempDOM.innerHTML = slideEl;
  31327. slidesEl.append(tempDOM.children[0]);
  31328. tempDOM.innerHTML = '';
  31329. } else {
  31330. slidesEl.append(slideEl);
  31331. }
  31332. };
  31333. if (typeof slides === 'object' && 'length' in slides) {
  31334. for (let i = 0; i < slides.length; i += 1) {
  31335. if (slides[i]) appendElement(slides[i]);
  31336. }
  31337. } else {
  31338. appendElement(slides);
  31339. }
  31340. swiper.recalcSlides();
  31341. if (params.loop) {
  31342. swiper.loopCreate();
  31343. }
  31344. if (!params.observer || swiper.isElement) {
  31345. swiper.update();
  31346. }
  31347. }
  31348. function prependSlide(slides) {
  31349. const swiper = this;
  31350. const {
  31351. params,
  31352. activeIndex,
  31353. slidesEl
  31354. } = swiper;
  31355. if (params.loop) {
  31356. swiper.loopDestroy();
  31357. }
  31358. let newActiveIndex = activeIndex + 1;
  31359. const prependElement = slideEl => {
  31360. if (typeof slideEl === 'string') {
  31361. const tempDOM = document.createElement('div');
  31362. tempDOM.innerHTML = slideEl;
  31363. slidesEl.prepend(tempDOM.children[0]);
  31364. tempDOM.innerHTML = '';
  31365. } else {
  31366. slidesEl.prepend(slideEl);
  31367. }
  31368. };
  31369. if (typeof slides === 'object' && 'length' in slides) {
  31370. for (let i = 0; i < slides.length; i += 1) {
  31371. if (slides[i]) prependElement(slides[i]);
  31372. }
  31373. newActiveIndex = activeIndex + slides.length;
  31374. } else {
  31375. prependElement(slides);
  31376. }
  31377. swiper.recalcSlides();
  31378. if (params.loop) {
  31379. swiper.loopCreate();
  31380. }
  31381. if (!params.observer || swiper.isElement) {
  31382. swiper.update();
  31383. }
  31384. swiper.slideTo(newActiveIndex, 0, false);
  31385. }
  31386. function addSlide(index, slides) {
  31387. const swiper = this;
  31388. const {
  31389. params,
  31390. activeIndex,
  31391. slidesEl
  31392. } = swiper;
  31393. let activeIndexBuffer = activeIndex;
  31394. if (params.loop) {
  31395. activeIndexBuffer -= swiper.loopedSlides;
  31396. swiper.loopDestroy();
  31397. swiper.recalcSlides();
  31398. }
  31399. const baseLength = swiper.slides.length;
  31400. if (index <= 0) {
  31401. swiper.prependSlide(slides);
  31402. return;
  31403. }
  31404. if (index >= baseLength) {
  31405. swiper.appendSlide(slides);
  31406. return;
  31407. }
  31408. let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
  31409. const slidesBuffer = [];
  31410. for (let i = baseLength - 1; i >= index; i -= 1) {
  31411. const currentSlide = swiper.slides[i];
  31412. currentSlide.remove();
  31413. slidesBuffer.unshift(currentSlide);
  31414. }
  31415. if (typeof slides === 'object' && 'length' in slides) {
  31416. for (let i = 0; i < slides.length; i += 1) {
  31417. if (slides[i]) slidesEl.append(slides[i]);
  31418. }
  31419. newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
  31420. } else {
  31421. slidesEl.append(slides);
  31422. }
  31423. for (let i = 0; i < slidesBuffer.length; i += 1) {
  31424. slidesEl.append(slidesBuffer[i]);
  31425. }
  31426. swiper.recalcSlides();
  31427. if (params.loop) {
  31428. swiper.loopCreate();
  31429. }
  31430. if (!params.observer || swiper.isElement) {
  31431. swiper.update();
  31432. }
  31433. if (params.loop) {
  31434. swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
  31435. } else {
  31436. swiper.slideTo(newActiveIndex, 0, false);
  31437. }
  31438. }
  31439. function removeSlide(slidesIndexes) {
  31440. const swiper = this;
  31441. const {
  31442. params,
  31443. activeIndex
  31444. } = swiper;
  31445. let activeIndexBuffer = activeIndex;
  31446. if (params.loop) {
  31447. activeIndexBuffer -= swiper.loopedSlides;
  31448. swiper.loopDestroy();
  31449. }
  31450. let newActiveIndex = activeIndexBuffer;
  31451. let indexToRemove;
  31452. if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
  31453. for (let i = 0; i < slidesIndexes.length; i += 1) {
  31454. indexToRemove = slidesIndexes[i];
  31455. if (swiper.slides[indexToRemove]) swiper.slides[indexToRemove].remove();
  31456. if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
  31457. }
  31458. newActiveIndex = Math.max(newActiveIndex, 0);
  31459. } else {
  31460. indexToRemove = slidesIndexes;
  31461. if (swiper.slides[indexToRemove]) swiper.slides[indexToRemove].remove();
  31462. if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
  31463. newActiveIndex = Math.max(newActiveIndex, 0);
  31464. }
  31465. swiper.recalcSlides();
  31466. if (params.loop) {
  31467. swiper.loopCreate();
  31468. }
  31469. if (!params.observer || swiper.isElement) {
  31470. swiper.update();
  31471. }
  31472. if (params.loop) {
  31473. swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
  31474. } else {
  31475. swiper.slideTo(newActiveIndex, 0, false);
  31476. }
  31477. }
  31478. function removeAllSlides() {
  31479. const swiper = this;
  31480. const slidesIndexes = [];
  31481. for (let i = 0; i < swiper.slides.length; i += 1) {
  31482. slidesIndexes.push(i);
  31483. }
  31484. swiper.removeSlide(slidesIndexes);
  31485. }
  31486. function Manipulation(_ref) {
  31487. let {
  31488. swiper
  31489. } = _ref;
  31490. Object.assign(swiper, {
  31491. appendSlide: appendSlide.bind(swiper),
  31492. prependSlide: prependSlide.bind(swiper),
  31493. addSlide: addSlide.bind(swiper),
  31494. removeSlide: removeSlide.bind(swiper),
  31495. removeAllSlides: removeAllSlides.bind(swiper)
  31496. });
  31497. }
  31498. function effectInit(params) {
  31499. const {
  31500. effect,
  31501. swiper,
  31502. on,
  31503. setTranslate,
  31504. setTransition,
  31505. overwriteParams,
  31506. perspective,
  31507. recreateShadows,
  31508. getEffectParams
  31509. } = params;
  31510. on('beforeInit', () => {
  31511. if (swiper.params.effect !== effect) return;
  31512. swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
  31513. if (perspective && perspective()) {
  31514. swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
  31515. }
  31516. const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
  31517. Object.assign(swiper.params, overwriteParamsResult);
  31518. Object.assign(swiper.originalParams, overwriteParamsResult);
  31519. });
  31520. on('setTranslate', () => {
  31521. if (swiper.params.effect !== effect) return;
  31522. setTranslate();
  31523. });
  31524. on('setTransition', (_s, duration) => {
  31525. if (swiper.params.effect !== effect) return;
  31526. setTransition(duration);
  31527. });
  31528. on('transitionEnd', () => {
  31529. if (swiper.params.effect !== effect) return;
  31530. if (recreateShadows) {
  31531. if (!getEffectParams || !getEffectParams().slideShadows) return;
  31532. // remove shadows
  31533. swiper.slides.forEach(slideEl => {
  31534. slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => shadowEl.remove());
  31535. });
  31536. // create new one
  31537. recreateShadows();
  31538. }
  31539. });
  31540. let requireUpdateOnVirtual;
  31541. on('virtualUpdate', () => {
  31542. if (swiper.params.effect !== effect) return;
  31543. if (!swiper.slides.length) {
  31544. requireUpdateOnVirtual = true;
  31545. }
  31546. requestAnimationFrame(() => {
  31547. if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) {
  31548. setTranslate();
  31549. requireUpdateOnVirtual = false;
  31550. }
  31551. });
  31552. });
  31553. }
  31554. function effectTarget(effectParams, slideEl) {
  31555. const transformEl = getSlideTransformEl(slideEl);
  31556. if (transformEl !== slideEl) {
  31557. transformEl.style.backfaceVisibility = 'hidden';
  31558. transformEl.style['-webkit-backface-visibility'] = 'hidden';
  31559. }
  31560. return transformEl;
  31561. }
  31562. function effectVirtualTransitionEnd(_ref) {
  31563. let {
  31564. swiper,
  31565. duration,
  31566. transformElements,
  31567. allSlides
  31568. } = _ref;
  31569. const {
  31570. activeIndex
  31571. } = swiper;
  31572. const getSlide = el => {
  31573. if (!el.parentElement) {
  31574. // assume shadow root
  31575. const slide = swiper.slides.filter(slideEl => slideEl.shadowRoot && slideEl.shadowRoot === el.parentNode)[0];
  31576. return slide;
  31577. }
  31578. return el.parentElement;
  31579. };
  31580. if (swiper.params.virtualTranslate && duration !== 0) {
  31581. let eventTriggered = false;
  31582. let transitionEndTarget;
  31583. if (allSlides) {
  31584. transitionEndTarget = transformElements;
  31585. } else {
  31586. transitionEndTarget = transformElements.filter(transformEl => {
  31587. const el = transformEl.classList.contains('swiper-slide-transform') ? getSlide(transformEl) : transformEl;
  31588. return swiper.getSlideIndex(el) === activeIndex;
  31589. });
  31590. }
  31591. transitionEndTarget.forEach(el => {
  31592. elementTransitionEnd(el, () => {
  31593. if (eventTriggered) return;
  31594. if (!swiper || swiper.destroyed) return;
  31595. eventTriggered = true;
  31596. swiper.animating = false;
  31597. const evt = new window.CustomEvent('transitionend', {
  31598. bubbles: true,
  31599. cancelable: true
  31600. });
  31601. swiper.wrapperEl.dispatchEvent(evt);
  31602. });
  31603. });
  31604. }
  31605. }
  31606. function EffectFade(_ref) {
  31607. let {
  31608. swiper,
  31609. extendParams,
  31610. on
  31611. } = _ref;
  31612. extendParams({
  31613. fadeEffect: {
  31614. crossFade: false
  31615. }
  31616. });
  31617. const setTranslate = () => {
  31618. const {
  31619. slides
  31620. } = swiper;
  31621. const params = swiper.params.fadeEffect;
  31622. for (let i = 0; i < slides.length; i += 1) {
  31623. const slideEl = swiper.slides[i];
  31624. const offset = slideEl.swiperSlideOffset;
  31625. let tx = -offset;
  31626. if (!swiper.params.virtualTranslate) tx -= swiper.translate;
  31627. let ty = 0;
  31628. if (!swiper.isHorizontal()) {
  31629. ty = tx;
  31630. tx = 0;
  31631. }
  31632. const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs(slideEl.progress), 0) : 1 + Math.min(Math.max(slideEl.progress, -1), 0);
  31633. const targetEl = effectTarget(params, slideEl);
  31634. targetEl.style.opacity = slideOpacity;
  31635. targetEl.style.transform = `translate3d(${tx}px, ${ty}px, 0px)`;
  31636. }
  31637. };
  31638. const setTransition = duration => {
  31639. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  31640. transformElements.forEach(el => {
  31641. el.style.transitionDuration = `${duration}ms`;
  31642. });
  31643. effectVirtualTransitionEnd({
  31644. swiper,
  31645. duration,
  31646. transformElements,
  31647. allSlides: true
  31648. });
  31649. };
  31650. effectInit({
  31651. effect: 'fade',
  31652. swiper,
  31653. on,
  31654. setTranslate,
  31655. setTransition,
  31656. overwriteParams: () => ({
  31657. slidesPerView: 1,
  31658. slidesPerGroup: 1,
  31659. watchSlidesProgress: true,
  31660. spaceBetween: 0,
  31661. virtualTranslate: !swiper.params.cssMode
  31662. })
  31663. });
  31664. }
  31665. function EffectCube(_ref) {
  31666. let {
  31667. swiper,
  31668. extendParams,
  31669. on
  31670. } = _ref;
  31671. extendParams({
  31672. cubeEffect: {
  31673. slideShadows: true,
  31674. shadow: true,
  31675. shadowOffset: 20,
  31676. shadowScale: 0.94
  31677. }
  31678. });
  31679. const createSlideShadows = (slideEl, progress, isHorizontal) => {
  31680. let shadowBefore = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
  31681. let shadowAfter = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
  31682. if (!shadowBefore) {
  31683. shadowBefore = createElement('div', `swiper-slide-shadow-cube swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}`.split(' '));
  31684. slideEl.append(shadowBefore);
  31685. }
  31686. if (!shadowAfter) {
  31687. shadowAfter = createElement('div', `swiper-slide-shadow-cube swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}`.split(' '));
  31688. slideEl.append(shadowAfter);
  31689. }
  31690. if (shadowBefore) shadowBefore.style.opacity = Math.max(-progress, 0);
  31691. if (shadowAfter) shadowAfter.style.opacity = Math.max(progress, 0);
  31692. };
  31693. const recreateShadows = () => {
  31694. // create new ones
  31695. const isHorizontal = swiper.isHorizontal();
  31696. swiper.slides.forEach(slideEl => {
  31697. const progress = Math.max(Math.min(slideEl.progress, 1), -1);
  31698. createSlideShadows(slideEl, progress, isHorizontal);
  31699. });
  31700. };
  31701. const setTranslate = () => {
  31702. const {
  31703. el,
  31704. wrapperEl,
  31705. slides,
  31706. width: swiperWidth,
  31707. height: swiperHeight,
  31708. rtlTranslate: rtl,
  31709. size: swiperSize,
  31710. browser
  31711. } = swiper;
  31712. const params = swiper.params.cubeEffect;
  31713. const isHorizontal = swiper.isHorizontal();
  31714. const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
  31715. let wrapperRotate = 0;
  31716. let cubeShadowEl;
  31717. if (params.shadow) {
  31718. if (isHorizontal) {
  31719. cubeShadowEl = swiper.wrapperEl.querySelector('.swiper-cube-shadow');
  31720. if (!cubeShadowEl) {
  31721. cubeShadowEl = createElement('div', 'swiper-cube-shadow');
  31722. swiper.wrapperEl.append(cubeShadowEl);
  31723. }
  31724. cubeShadowEl.style.height = `${swiperWidth}px`;
  31725. } else {
  31726. cubeShadowEl = el.querySelector('.swiper-cube-shadow');
  31727. if (!cubeShadowEl) {
  31728. cubeShadowEl = createElement('div', 'swiper-cube-shadow');
  31729. el.append(cubeShadowEl);
  31730. }
  31731. }
  31732. }
  31733. for (let i = 0; i < slides.length; i += 1) {
  31734. const slideEl = slides[i];
  31735. let slideIndex = i;
  31736. if (isVirtual) {
  31737. slideIndex = parseInt(slideEl.getAttribute('data-swiper-slide-index'), 10);
  31738. }
  31739. let slideAngle = slideIndex * 90;
  31740. let round = Math.floor(slideAngle / 360);
  31741. if (rtl) {
  31742. slideAngle = -slideAngle;
  31743. round = Math.floor(-slideAngle / 360);
  31744. }
  31745. const progress = Math.max(Math.min(slideEl.progress, 1), -1);
  31746. let tx = 0;
  31747. let ty = 0;
  31748. let tz = 0;
  31749. if (slideIndex % 4 === 0) {
  31750. tx = -round * 4 * swiperSize;
  31751. tz = 0;
  31752. } else if ((slideIndex - 1) % 4 === 0) {
  31753. tx = 0;
  31754. tz = -round * 4 * swiperSize;
  31755. } else if ((slideIndex - 2) % 4 === 0) {
  31756. tx = swiperSize + round * 4 * swiperSize;
  31757. tz = swiperSize;
  31758. } else if ((slideIndex - 3) % 4 === 0) {
  31759. tx = -swiperSize;
  31760. tz = 3 * swiperSize + swiperSize * 4 * round;
  31761. }
  31762. if (rtl) {
  31763. tx = -tx;
  31764. }
  31765. if (!isHorizontal) {
  31766. ty = tx;
  31767. tx = 0;
  31768. }
  31769. const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
  31770. if (progress <= 1 && progress > -1) {
  31771. wrapperRotate = slideIndex * 90 + progress * 90;
  31772. if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
  31773. if (swiper.browser && swiper.browser.isSafari && Math.abs(wrapperRotate) / 90 % 2 === 1) {
  31774. wrapperRotate += 0.001;
  31775. }
  31776. }
  31777. slideEl.style.transform = transform;
  31778. if (params.slideShadows) {
  31779. createSlideShadows(slideEl, progress, isHorizontal);
  31780. }
  31781. }
  31782. wrapperEl.style.transformOrigin = `50% 50% -${swiperSize / 2}px`;
  31783. wrapperEl.style['-webkit-transform-origin'] = `50% 50% -${swiperSize / 2}px`;
  31784. if (params.shadow) {
  31785. if (isHorizontal) {
  31786. cubeShadowEl.style.transform = `translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(89.99deg) rotateZ(0deg) scale(${params.shadowScale})`;
  31787. } else {
  31788. const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
  31789. const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
  31790. const scale1 = params.shadowScale;
  31791. const scale2 = params.shadowScale / multiplier;
  31792. const offset = params.shadowOffset;
  31793. cubeShadowEl.style.transform = `scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-89.99deg)`;
  31794. }
  31795. }
  31796. const zFactor = (browser.isSafari || browser.isWebView) && browser.needPerspectiveFix ? -swiperSize / 2 : 0;
  31797. wrapperEl.style.transform = `translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`;
  31798. wrapperEl.style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
  31799. };
  31800. const setTransition = duration => {
  31801. const {
  31802. el,
  31803. slides
  31804. } = swiper;
  31805. slides.forEach(slideEl => {
  31806. slideEl.style.transitionDuration = `${duration}ms`;
  31807. slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(subEl => {
  31808. subEl.style.transitionDuration = `${duration}ms`;
  31809. });
  31810. });
  31811. if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
  31812. const shadowEl = el.querySelector('.swiper-cube-shadow');
  31813. if (shadowEl) shadowEl.style.transitionDuration = `${duration}ms`;
  31814. }
  31815. };
  31816. effectInit({
  31817. effect: 'cube',
  31818. swiper,
  31819. on,
  31820. setTranslate,
  31821. setTransition,
  31822. recreateShadows,
  31823. getEffectParams: () => swiper.params.cubeEffect,
  31824. perspective: () => true,
  31825. overwriteParams: () => ({
  31826. slidesPerView: 1,
  31827. slidesPerGroup: 1,
  31828. watchSlidesProgress: true,
  31829. resistanceRatio: 0,
  31830. spaceBetween: 0,
  31831. centeredSlides: false,
  31832. virtualTranslate: true
  31833. })
  31834. });
  31835. }
  31836. function createShadow(suffix, slideEl, side) {
  31837. const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}${suffix ? ` swiper-slide-shadow-${suffix}` : ''}`;
  31838. const shadowContainer = getSlideTransformEl(slideEl);
  31839. let shadowEl = shadowContainer.querySelector(`.${shadowClass.split(' ').join('.')}`);
  31840. if (!shadowEl) {
  31841. shadowEl = createElement('div', shadowClass.split(' '));
  31842. shadowContainer.append(shadowEl);
  31843. }
  31844. return shadowEl;
  31845. }
  31846. function EffectFlip(_ref) {
  31847. let {
  31848. swiper,
  31849. extendParams,
  31850. on
  31851. } = _ref;
  31852. extendParams({
  31853. flipEffect: {
  31854. slideShadows: true,
  31855. limitRotation: true
  31856. }
  31857. });
  31858. const createSlideShadows = (slideEl, progress) => {
  31859. let shadowBefore = swiper.isHorizontal() ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
  31860. let shadowAfter = swiper.isHorizontal() ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
  31861. if (!shadowBefore) {
  31862. shadowBefore = createShadow('flip', slideEl, swiper.isHorizontal() ? 'left' : 'top');
  31863. }
  31864. if (!shadowAfter) {
  31865. shadowAfter = createShadow('flip', slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
  31866. }
  31867. if (shadowBefore) shadowBefore.style.opacity = Math.max(-progress, 0);
  31868. if (shadowAfter) shadowAfter.style.opacity = Math.max(progress, 0);
  31869. };
  31870. const recreateShadows = () => {
  31871. // Set shadows
  31872. swiper.params.flipEffect;
  31873. swiper.slides.forEach(slideEl => {
  31874. let progress = slideEl.progress;
  31875. if (swiper.params.flipEffect.limitRotation) {
  31876. progress = Math.max(Math.min(slideEl.progress, 1), -1);
  31877. }
  31878. createSlideShadows(slideEl, progress);
  31879. });
  31880. };
  31881. const setTranslate = () => {
  31882. const {
  31883. slides,
  31884. rtlTranslate: rtl
  31885. } = swiper;
  31886. const params = swiper.params.flipEffect;
  31887. for (let i = 0; i < slides.length; i += 1) {
  31888. const slideEl = slides[i];
  31889. let progress = slideEl.progress;
  31890. if (swiper.params.flipEffect.limitRotation) {
  31891. progress = Math.max(Math.min(slideEl.progress, 1), -1);
  31892. }
  31893. const offset = slideEl.swiperSlideOffset;
  31894. const rotate = -180 * progress;
  31895. let rotateY = rotate;
  31896. let rotateX = 0;
  31897. let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
  31898. let ty = 0;
  31899. if (!swiper.isHorizontal()) {
  31900. ty = tx;
  31901. tx = 0;
  31902. rotateX = -rotateY;
  31903. rotateY = 0;
  31904. } else if (rtl) {
  31905. rotateY = -rotateY;
  31906. }
  31907. if (swiper.browser && swiper.browser.isSafari) {
  31908. if (Math.abs(rotateY) / 90 % 2 === 1) {
  31909. rotateY += 0.001;
  31910. }
  31911. if (Math.abs(rotateX) / 90 % 2 === 1) {
  31912. rotateX += 0.001;
  31913. }
  31914. }
  31915. slideEl.style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
  31916. if (params.slideShadows) {
  31917. createSlideShadows(slideEl, progress);
  31918. }
  31919. const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
  31920. const targetEl = effectTarget(params, slideEl);
  31921. targetEl.style.transform = transform;
  31922. }
  31923. };
  31924. const setTransition = duration => {
  31925. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  31926. transformElements.forEach(el => {
  31927. el.style.transitionDuration = `${duration}ms`;
  31928. el.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => {
  31929. shadowEl.style.transitionDuration = `${duration}ms`;
  31930. });
  31931. });
  31932. effectVirtualTransitionEnd({
  31933. swiper,
  31934. duration,
  31935. transformElements
  31936. });
  31937. };
  31938. effectInit({
  31939. effect: 'flip',
  31940. swiper,
  31941. on,
  31942. setTranslate,
  31943. setTransition,
  31944. recreateShadows,
  31945. getEffectParams: () => swiper.params.flipEffect,
  31946. perspective: () => true,
  31947. overwriteParams: () => ({
  31948. slidesPerView: 1,
  31949. slidesPerGroup: 1,
  31950. watchSlidesProgress: true,
  31951. spaceBetween: 0,
  31952. virtualTranslate: !swiper.params.cssMode
  31953. })
  31954. });
  31955. }
  31956. function EffectCoverflow(_ref) {
  31957. let {
  31958. swiper,
  31959. extendParams,
  31960. on
  31961. } = _ref;
  31962. extendParams({
  31963. coverflowEffect: {
  31964. rotate: 50,
  31965. stretch: 0,
  31966. depth: 100,
  31967. scale: 1,
  31968. modifier: 1,
  31969. slideShadows: true
  31970. }
  31971. });
  31972. const setTranslate = () => {
  31973. const {
  31974. width: swiperWidth,
  31975. height: swiperHeight,
  31976. slides,
  31977. slidesSizesGrid
  31978. } = swiper;
  31979. const params = swiper.params.coverflowEffect;
  31980. const isHorizontal = swiper.isHorizontal();
  31981. const transform = swiper.translate;
  31982. const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
  31983. const rotate = isHorizontal ? params.rotate : -params.rotate;
  31984. const translate = params.depth;
  31985. // Each slide offset from center
  31986. for (let i = 0, length = slides.length; i < length; i += 1) {
  31987. const slideEl = slides[i];
  31988. const slideSize = slidesSizesGrid[i];
  31989. const slideOffset = slideEl.swiperSlideOffset;
  31990. const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
  31991. const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
  31992. let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
  31993. let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier;
  31994. // var rotateZ = 0
  31995. let translateZ = -translate * Math.abs(offsetMultiplier);
  31996. let stretch = params.stretch;
  31997. // Allow percentage to make a relative stretch for responsive sliders
  31998. if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
  31999. stretch = parseFloat(params.stretch) / 100 * slideSize;
  32000. }
  32001. let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
  32002. let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
  32003. let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier);
  32004. // Fix for ultra small values
  32005. if (Math.abs(translateX) < 0.001) translateX = 0;
  32006. if (Math.abs(translateY) < 0.001) translateY = 0;
  32007. if (Math.abs(translateZ) < 0.001) translateZ = 0;
  32008. if (Math.abs(rotateY) < 0.001) rotateY = 0;
  32009. if (Math.abs(rotateX) < 0.001) rotateX = 0;
  32010. if (Math.abs(scale) < 0.001) scale = 0;
  32011. if (swiper.browser && swiper.browser.isSafari) {
  32012. if (Math.abs(rotateY) / 90 % 2 === 1) {
  32013. rotateY += 0.001;
  32014. }
  32015. if (Math.abs(rotateX) / 90 % 2 === 1) {
  32016. rotateX += 0.001;
  32017. }
  32018. }
  32019. const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`;
  32020. const targetEl = effectTarget(params, slideEl);
  32021. targetEl.style.transform = slideTransform;
  32022. slideEl.style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
  32023. if (params.slideShadows) {
  32024. // Set shadows
  32025. let shadowBeforeEl = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
  32026. let shadowAfterEl = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
  32027. if (!shadowBeforeEl) {
  32028. shadowBeforeEl = createShadow('coverflow', slideEl, isHorizontal ? 'left' : 'top');
  32029. }
  32030. if (!shadowAfterEl) {
  32031. shadowAfterEl = createShadow('coverflow', slideEl, isHorizontal ? 'right' : 'bottom');
  32032. }
  32033. if (shadowBeforeEl) shadowBeforeEl.style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
  32034. if (shadowAfterEl) shadowAfterEl.style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
  32035. }
  32036. }
  32037. };
  32038. const setTransition = duration => {
  32039. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32040. transformElements.forEach(el => {
  32041. el.style.transitionDuration = `${duration}ms`;
  32042. el.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => {
  32043. shadowEl.style.transitionDuration = `${duration}ms`;
  32044. });
  32045. });
  32046. };
  32047. effectInit({
  32048. effect: 'coverflow',
  32049. swiper,
  32050. on,
  32051. setTranslate,
  32052. setTransition,
  32053. perspective: () => true,
  32054. overwriteParams: () => ({
  32055. watchSlidesProgress: true
  32056. })
  32057. });
  32058. }
  32059. function EffectCreative(_ref) {
  32060. let {
  32061. swiper,
  32062. extendParams,
  32063. on
  32064. } = _ref;
  32065. extendParams({
  32066. creativeEffect: {
  32067. limitProgress: 1,
  32068. shadowPerProgress: false,
  32069. progressMultiplier: 1,
  32070. perspective: true,
  32071. prev: {
  32072. translate: [0, 0, 0],
  32073. rotate: [0, 0, 0],
  32074. opacity: 1,
  32075. scale: 1
  32076. },
  32077. next: {
  32078. translate: [0, 0, 0],
  32079. rotate: [0, 0, 0],
  32080. opacity: 1,
  32081. scale: 1
  32082. }
  32083. }
  32084. });
  32085. const getTranslateValue = value => {
  32086. if (typeof value === 'string') return value;
  32087. return `${value}px`;
  32088. };
  32089. const setTranslate = () => {
  32090. const {
  32091. slides,
  32092. wrapperEl,
  32093. slidesSizesGrid
  32094. } = swiper;
  32095. const params = swiper.params.creativeEffect;
  32096. const {
  32097. progressMultiplier: multiplier
  32098. } = params;
  32099. const isCenteredSlides = swiper.params.centeredSlides;
  32100. if (isCenteredSlides) {
  32101. const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
  32102. wrapperEl.style.transform = `translateX(calc(50% - ${margin}px))`;
  32103. }
  32104. for (let i = 0; i < slides.length; i += 1) {
  32105. const slideEl = slides[i];
  32106. const slideProgress = slideEl.progress;
  32107. const progress = Math.min(Math.max(slideEl.progress, -params.limitProgress), params.limitProgress);
  32108. let originalProgress = progress;
  32109. if (!isCenteredSlides) {
  32110. originalProgress = Math.min(Math.max(slideEl.originalProgress, -params.limitProgress), params.limitProgress);
  32111. }
  32112. const offset = slideEl.swiperSlideOffset;
  32113. const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
  32114. const r = [0, 0, 0];
  32115. let custom = false;
  32116. if (!swiper.isHorizontal()) {
  32117. t[1] = t[0];
  32118. t[0] = 0;
  32119. }
  32120. let data = {
  32121. translate: [0, 0, 0],
  32122. rotate: [0, 0, 0],
  32123. scale: 1,
  32124. opacity: 1
  32125. };
  32126. if (progress < 0) {
  32127. data = params.next;
  32128. custom = true;
  32129. } else if (progress > 0) {
  32130. data = params.prev;
  32131. custom = true;
  32132. }
  32133. // set translate
  32134. t.forEach((value, index) => {
  32135. t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
  32136. });
  32137. // set rotates
  32138. r.forEach((value, index) => {
  32139. let val = data.rotate[index] * Math.abs(progress * multiplier);
  32140. if (swiper.browser && swiper.browser.isSafari && Math.abs(val) / 90 % 2 === 1) {
  32141. val += 0.001;
  32142. }
  32143. r[index] = val;
  32144. });
  32145. slideEl.style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
  32146. const translateString = t.join(', ');
  32147. const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`;
  32148. const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
  32149. const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
  32150. const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`;
  32151. // Set shadows
  32152. if (custom && data.shadow || !custom) {
  32153. let shadowEl = slideEl.querySelector('.swiper-slide-shadow');
  32154. if (!shadowEl && data.shadow) {
  32155. shadowEl = createShadow('creative', slideEl);
  32156. }
  32157. if (shadowEl) {
  32158. const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
  32159. shadowEl.style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
  32160. }
  32161. }
  32162. const targetEl = effectTarget(params, slideEl);
  32163. targetEl.style.transform = transform;
  32164. targetEl.style.opacity = opacityString;
  32165. if (data.origin) {
  32166. targetEl.style.transformOrigin = data.origin;
  32167. }
  32168. }
  32169. };
  32170. const setTransition = duration => {
  32171. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32172. transformElements.forEach(el => {
  32173. el.style.transitionDuration = `${duration}ms`;
  32174. el.querySelectorAll('.swiper-slide-shadow').forEach(shadowEl => {
  32175. shadowEl.style.transitionDuration = `${duration}ms`;
  32176. });
  32177. });
  32178. effectVirtualTransitionEnd({
  32179. swiper,
  32180. duration,
  32181. transformElements,
  32182. allSlides: true
  32183. });
  32184. };
  32185. effectInit({
  32186. effect: 'creative',
  32187. swiper,
  32188. on,
  32189. setTranslate,
  32190. setTransition,
  32191. perspective: () => swiper.params.creativeEffect.perspective,
  32192. overwriteParams: () => ({
  32193. watchSlidesProgress: true,
  32194. virtualTranslate: !swiper.params.cssMode
  32195. })
  32196. });
  32197. }
  32198. function EffectCards(_ref) {
  32199. let {
  32200. swiper,
  32201. extendParams,
  32202. on
  32203. } = _ref;
  32204. extendParams({
  32205. cardsEffect: {
  32206. slideShadows: true,
  32207. rotate: true,
  32208. perSlideRotate: 2,
  32209. perSlideOffset: 8
  32210. }
  32211. });
  32212. const setTranslate = () => {
  32213. const {
  32214. slides,
  32215. activeIndex,
  32216. rtlTranslate: rtl
  32217. } = swiper;
  32218. const params = swiper.params.cardsEffect;
  32219. const {
  32220. startTranslate,
  32221. isTouched
  32222. } = swiper.touchEventsData;
  32223. const currentTranslate = rtl ? -swiper.translate : swiper.translate;
  32224. for (let i = 0; i < slides.length; i += 1) {
  32225. const slideEl = slides[i];
  32226. const slideProgress = slideEl.progress;
  32227. const progress = Math.min(Math.max(slideProgress, -4), 4);
  32228. let offset = slideEl.swiperSlideOffset;
  32229. if (swiper.params.centeredSlides && !swiper.params.cssMode) {
  32230. swiper.wrapperEl.style.transform = `translateX(${swiper.minTranslate()}px)`;
  32231. }
  32232. if (swiper.params.centeredSlides && swiper.params.cssMode) {
  32233. offset -= slides[0].swiperSlideOffset;
  32234. }
  32235. let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
  32236. let tY = 0;
  32237. const tZ = -100 * Math.abs(progress);
  32238. let scale = 1;
  32239. let rotate = -params.perSlideRotate * progress;
  32240. let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
  32241. const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
  32242. const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
  32243. const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
  32244. if (isSwipeToNext || isSwipeToPrev) {
  32245. const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
  32246. rotate += -28 * progress * subProgress;
  32247. scale += -0.5 * subProgress;
  32248. tXAdd += 96 * subProgress;
  32249. tY = `${-25 * subProgress * Math.abs(progress)}%`;
  32250. }
  32251. if (progress < 0) {
  32252. // next
  32253. tX = `calc(${tX}px ${rtl ? '-' : '+'} (${tXAdd * Math.abs(progress)}%))`;
  32254. } else if (progress > 0) {
  32255. // prev
  32256. tX = `calc(${tX}px ${rtl ? '-' : '+'} (-${tXAdd * Math.abs(progress)}%))`;
  32257. } else {
  32258. tX = `${tX}px`;
  32259. }
  32260. if (!swiper.isHorizontal()) {
  32261. const prevY = tY;
  32262. tY = tX;
  32263. tX = prevY;
  32264. }
  32265. const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
  32266. /* eslint-disable */
  32267. const transform = `
  32268. translate3d(${tX}, ${tY}, ${tZ}px)
  32269. rotateZ(${params.rotate ? rtl ? -rotate : rotate : 0}deg)
  32270. scale(${scaleString})
  32271. `;
  32272. /* eslint-enable */
  32273. if (params.slideShadows) {
  32274. // Set shadows
  32275. let shadowEl = slideEl.querySelector('.swiper-slide-shadow');
  32276. if (!shadowEl) {
  32277. shadowEl = createShadow('cards', slideEl);
  32278. }
  32279. if (shadowEl) shadowEl.style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
  32280. }
  32281. slideEl.style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
  32282. const targetEl = effectTarget(params, slideEl);
  32283. targetEl.style.transform = transform;
  32284. }
  32285. };
  32286. const setTransition = duration => {
  32287. const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
  32288. transformElements.forEach(el => {
  32289. el.style.transitionDuration = `${duration}ms`;
  32290. el.querySelectorAll('.swiper-slide-shadow').forEach(shadowEl => {
  32291. shadowEl.style.transitionDuration = `${duration}ms`;
  32292. });
  32293. });
  32294. effectVirtualTransitionEnd({
  32295. swiper,
  32296. duration,
  32297. transformElements
  32298. });
  32299. };
  32300. effectInit({
  32301. effect: 'cards',
  32302. swiper,
  32303. on,
  32304. setTranslate,
  32305. setTransition,
  32306. perspective: () => true,
  32307. overwriteParams: () => ({
  32308. watchSlidesProgress: true,
  32309. virtualTranslate: !swiper.params.cssMode
  32310. })
  32311. });
  32312. }
  32313. /**
  32314. * Swiper 11.0.5
  32315. * Most modern mobile touch slider and framework with hardware accelerated transitions
  32316. * https://swiperjs.com
  32317. *
  32318. * Copyright 2014-2023 Vladimir Kharlampidi
  32319. *
  32320. * Released under the MIT License
  32321. *
  32322. * Released on: November 22, 2023
  32323. */
  32324. // Swiper Class
  32325. const modules = [Virtual, Keyboard, Mousewheel, Navigation, Pagination, Scrollbar, Parallax, Zoom, Controller, A11y, History, HashNavigation, Autoplay, Thumb, freeMode, Grid, Manipulation, EffectFade, EffectCube, EffectFlip, EffectCoverflow, EffectCreative, EffectCards];
  32326. Swiper.use(modules);
  32327. return Swiper;
  32328. })();